var en=Object.defineProperty;var nn=(p,t,e)=>t in p?en(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e;var g=(p,t,e)=>(nn(p,typeof t!="symbol"?t+"":t,e),e);/*! @license DOMPurify 3.2.4 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.4/LICENSE */const{entries:Ne,setPrototypeOf:be,isFrozen:an,getPrototypeOf:rn,getOwnPropertyDescriptor:on}=Object;let{freeze:S,seal:L,create:Oe}=Object,{apply:Yt,construct:Vt}=typeof Reflect1?e-1:0),i=1;i2&&arguments[2]!==void 0?arguments[2]:_t;be&&be(p,null);let n=t.length;for(;n--;){let i=t[n];if(typeof i=="string"){const a=e(i);a!==i&&(an(t)||(t[n]=a),i=a)}p[i]=!0}return p}function dn(p){for(let t=0;t/gm),Tn=L(/\$\{[\w\W]*/gm),An=L(/^data-[\-\w.\u00B7-\uFFFF]+$/),bn=L(/^aria-[\-\w]+$/),Me=L(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),yn=L(/^(?:\w+script|data):/i),wn=L(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Ie=L(/^html$/i),En=L(/^[a-z][.\w]*(-[.\w]+)+$/i);var ve=Object.freeze({__proto__:null,ARIA_ATTR:bn,ATTR_WHITESPACE:wn,CUSTOM_ELEMENT:En,DATA_ATTR:An,DOCTYPE_NAME:Ie,ERB_EXPR:gn,IS_ALLOWED_URI:Me,IS_SCRIPT_OR_DATA:yn,MUSTACHE_EXPR:hn,TMPLIT_EXPR:Tn});const ut={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},_n=function(){return typeof window>"u"?null:window},Cn=function(t,e){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let n=null;const i="data-tt-policy-suffix";e&&e.hasAttribute(i)&&(n=e.getAttribute(i));const a="dompurify"+(n?"#"+n:"");try{return t.createPolicy(a,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},De=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Le(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:_n();const t=d=>Le(d);if(t.version="3.2.4",t.removed=[],!p||!p.document||p.document.nodeType!==ut.document||!p.Element)return t.isSupported=!1,t;let{document:e}=p;const n=e,i=n.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:s,Element:f,NodeFilter:T,NamedNodeMap:O=p.NamedNodeMap||p.MozNamedAttrMap,HTMLFormElement:G,DOMParser:tt,trustedTypes:h}=p,B=f.prototype,qt=ct(B,"cloneNode"),xe=ct(B,"remove"),Fe=ct(B,"nextSibling"),Ue=ct(B,"childNodes"),pt=ct(B,"parentNode");if(typeof o=="function"){const d=e.createElement("template");d.content&&d.content.ownerDocument&&(e=d.content.ownerDocument)}let k,et="";const{implementation:Ct,createNodeIterator:He,createDocumentFragment:We,getElementsByTagName:ze}=e,{importNode:Be}=n;let v=De();t.isSupported=typeof Ne=="function"&&typeof pt=="function"&&Ct&&Ct.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:kt,ERB_EXPR:vt,TMPLIT_EXPR:Dt,DATA_ATTR:Ge,ARIA_ATTR:Ye,IS_SCRIPT_OR_DATA:Ve,ATTR_WHITESPACE:Xt,CUSTOM_ELEMENT:$e}=ve;let{IS_ALLOWED_URI:Jt}=ve,y=null;const Kt=m({},[...Ee,...Wt,...zt,...Bt,..._e]);let E=null;const jt=m({},[...Ce,...Gt,...ke,...Et]);let b=Object.seal(Oe(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),nt=null,Rt=null,Zt=!0,St=!0,Qt=!1,te=!0,$=!1,Nt=!0,Y=!1,Ot=!1,Mt=!1,q=!1,mt=!1,ht=!1,ee=!0,ne=!1;const qe="user-content-";let It=!0,it=!1,X={},J=null;const ie=m({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ae=null;const re=m({},["audio","video","img","source","image","track"]);let Lt=null;const oe=m({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),gt="http://www.w3.org/1998/Math/MathML",Tt="http://www.w3.org/2000/svg",U="http://www.w3.org/1999/xhtml";let K=U,Pt=!1,xt=null;const Xe=m({},[gt,Tt,U],Ht);let At=m({},["mi","mo","mn","ms","mtext"]),bt=m({},["annotation-xml"]);const Je=m({},["title","style","font","a","script"]);let at=null;const Ke=["application/xhtml+xml","text/html"],je="text/html";let w=null,j=null;const Ze=e.createElement("form"),se=function(r){return r instanceof RegExp||r instanceof Function},Ft=function(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(j&&j===r)){if((!r||typeof r!="object")&&(r={}),r=V(r),at=Ke.indexOf(r.PARSER_MEDIA_TYPE)===-1?je:r.PARSER_MEDIA_TYPE,w=at==="application/xhtml+xml"?Ht:_t,y=P(r,"ALLOWED_TAGS")?m({},r.ALLOWED_TAGS,w):Kt,E=P(r,"ALLOWED_ATTR")?m({},r.ALLOWED_ATTR,w):jt,xt=P(r,"ALLOWED_NAMESPACES")?m({},r.ALLOWED_NAMESPACES,Ht):Xe,Lt=P(r,"ADD_URI_SAFE_ATTR")?m(V(oe),r.ADD_URI_SAFE_ATTR,w):oe,ae=P(r,"ADD_DATA_URI_TAGS")?m(V(re),r.ADD_DATA_URI_TAGS,w):re,J=P(r,"FORBID_CONTENTS")?m({},r.FORBID_CONTENTS,w):ie,nt=P(r,"FORBID_TAGS")?m({},r.FORBID_TAGS,w):{},Rt=P(r,"FORBID_ATTR")?m({},r.FORBID_ATTR,w):{},X=P(r,"USE_PROFILES")?r.USE_PROFILES:!1,Zt=r.ALLOW_ARIA_ATTR!==!1,St=r.ALLOW_DATA_ATTR!==!1,Qt=r.ALLOW_UNKNOWN_PROTOCOLS||!1,te=r.ALLOW_SELF_CLOSE_IN_ATTR!==!1,$=r.SAFE_FOR_TEMPLATES||!1,Nt=r.SAFE_FOR_XML!==!1,Y=r.WHOLE_DOCUMENT||!1,q=r.RETURN_DOM||!1,mt=r.RETURN_DOM_FRAGMENT||!1,ht=r.RETURN_TRUSTED_TYPE||!1,Mt=r.FORCE_BODY||!1,ee=r.SANITIZE_DOM!==!1,ne=r.SANITIZE_NAMED_PROPS||!1,It=r.KEEP_CONTENT!==!1,it=r.IN_PLACE||!1,Jt=r.ALLOWED_URI_REGEXP||Me,K=r.NAMESPACE||U,At=r.MATHML_TEXT_INTEGRATION_POINTS||At,bt=r.HTML_INTEGRATION_POINTS||bt,b=r.CUSTOM_ELEMENT_HANDLING||{},r.CUSTOM_ELEMENT_HANDLING&&se(r.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(b.tagNameCheck=r.CUSTOM_ELEMENT_HANDLING.tagNameCheck),r.CUSTOM_ELEMENT_HANDLING&&se(r.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(b.attributeNameCheck=r.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),r.CUSTOM_ELEMENT_HANDLING&&typeof r.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(b.allowCustomizedBuiltInElements=r.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),$&&(St=!1),mt&&(q=!0),X&&(y=m({},_e),E=[],X.html===!0&&(m(y,Ee),m(E,Ce)),X.svg===!0&&(m(y,Wt),m(E,Gt),m(E,Et)),X.svgFilters===!0&&(m(y,zt),m(E,Gt),m(E,Et)),X.mathMl===!0&&(m(y,Bt),m(E,ke),m(E,Et))),r.ADD_TAGS&&(y===Kt&&(y=V(y)),m(y,r.ADD_TAGS,w)),r.ADD_ATTR&&(E===jt&&(E=V(E)),m(E,r.ADD_ATTR,w)),r.ADD_URI_SAFE_ATTR&&m(Lt,r.ADD_URI_SAFE_ATTR,w),r.FORBID_CONTENTS&&(J===ie&&(J=V(J)),m(J,r.FORBID_CONTENTS,w)),It&&(y["#text"]=!0),Y&&m(y,["html","head","body"]),y.table&&(m(y,["tbody"]),delete nt.tbody),r.TRUSTED_TYPES_POLICY){if(typeof r.TRUSTED_TYPES_POLICY.createHTML!="function")throw lt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof r.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw lt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');k=r.TRUSTED_TYPES_POLICY,et=k.createHTML("")}else k===void 0&&(k=Cn(h,i)),k!==null&&typeof et=="string"&&(et=k.createHTML(""));S&&S(r),j=r}},le=m({},[...Wt,...zt,...pn]),ce=m({},[...Bt,...mn]),Qe=function(r){let l=pt(r);(!l||!l.tagName)&&(l={namespaceURI:K,tagName:"template"});const u=_t(r.tagName),A=_t(l.tagName);return xt[r.namespaceURI]?r.namespaceURI===Tt?l.namespaceURI===U?u==="svg":l.namespaceURI===gt?u==="svg"&&(A==="annotation-xml"||At[A]):!!le[u]:r.namespaceURI===gt?l.namespaceURI===U?u==="math":l.namespaceURI===Tt?u==="math"&&bt[A]:!!ce[u]:r.namespaceURI===U?l.namespaceURI===Tt&&!bt[A]||l.namespaceURI===gt&&!At[A]?!1:!ce[u]&&(Je[u]||!le[u]):!!(at==="application/xhtml+xml"&&xt[r.namespaceURI]):!1},x=function(r){ot(t.removed,{element:r});try{pt(r).removeChild(r)}catch{xe(r)}},yt=function(r,l){try{ot(t.removed,{attribute:l.getAttributeNode(r),from:l})}catch{ot(t.removed,{attribute:null,from:l})}if(l.removeAttribute(r),r==="is")if(q||mt)try{x(l)}catch{}else try{l.setAttribute(r,"")}catch{}},ue=function(r){let l=null,u=null;if(Mt)r=""+r;else{const _=we(r,/^[\r\n\t ]+/);u=_&&_[0]}at==="application/xhtml+xml"&&K===U&&(r=''+r+"");const A=k?k.createHTML(r):r;if(K===U)try{l=new tt().parseFromString(A,at)}catch{}if(!l||!l.documentElement){l=Ct.createDocument(K,"template",null);try{l.documentElement.innerHTML=Pt?et:A}catch{}}const C=l.body||l.documentElement;return r&&u&&C.insertBefore(e.createTextNode(u),C.childNodes[0]||null),K===U?ze.call(l,Y?"html":"body")[0]:Y?l.documentElement:C},fe=function(r){return He.call(r.ownerDocument||r,r,T.SHOW_ELEMENT|T.SHOW_COMMENT|T.SHOW_TEXT|T.SHOW_PROCESSING_INSTRUCTION|T.SHOW_CDATA_SECTION,null)},Ut=function(r){return r instanceof G&&(typeof r.nodeName!="string"||typeof r.textContent!="string"||typeof r.removeChild!="function"||!(r.attributes instanceof O)||typeof r.removeAttribute!="function"||typeof r.setAttribute!="function"||typeof r.namespaceURI!="string"||typeof r.insertBefore!="function"||typeof r.hasChildNodes!="function")},de=function(r){return typeof s=="function"&&r instanceof s};function H(d,r,l){wt(d,u=>{u.call(t,r,l,j)})}const pe=function(r){let l=null;if(H(v.beforeSanitizeElements,r,null),Ut(r))return x(r),!0;const u=w(r.nodeName);if(H(v.uponSanitizeElement,r,{tagName:u,allowedTags:y}),r.hasChildNodes()&&!de(r.firstElementChild)&&R(/=0;--M){const F=qt(C[M],!0);F.__removalCount=(r.__removalCount||0)+1,A.insertBefore(F,Fe(r))}}}return x(r),!0}return r instanceof f&&!Qe(r)||(u==="noscript"||u==="noembed"||u==="noframes")&&R(/{l=st(l,A," ")}),r.textContent!==l&&(ot(t.removed,{element:r.cloneNode()}),r.textContent=l)),H(v.afterSanitizeElements,r,null),!1)},me=function(r,l,u){if(ee&&(l==="id"||l==="name")&&(u in e||u in Ze))return!1;if(!(St&&!Rt[l]&&R(Ge,l))){if(!(Zt&&R(Ye,l))){if(!E[l]||Rt[l]){if(!(he(r)&&(b.tagNameCheck instanceof RegExp&&R(b.tagNameCheck,r)||b.tagNameCheck instanceof Function&&b.tagNameCheck(r))&&(b.attributeNameCheck instanceof RegExp&&R(b.attributeNameCheck,l)||b.attributeNameCheck instanceof Function&&b.attributeNameCheck(l))||l==="is"&&b.allowCustomizedBuiltInElements&&(b.tagNameCheck instanceof RegExp&&R(b.tagNameCheck,u)||b.tagNameCheck instanceof Function&&b.tagNameCheck(u))))return!1}else if(!Lt[l]){if(!R(Jt,st(u,Xt,""))){if(!((l==="src"||l==="xlink:href"||l==="href")&&r!=="script"&&cn(u,"data:")===0&&ae[r])){if(!(Qt&&!R(Ve,st(u,Xt,"")))){if(u)return!1}}}}}}return!0},he=function(r){return r!=="annotation-xml"&&we(r,$e)},ge=function(r){H(v.beforeSanitizeAttributes,r,null);const{attributes:l}=r;if(!l||Ut(r))return;const u={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:E,forceKeepAttr:void 0};let A=l.length;for(;A--;){const C=l[A],{name:_,namespaceURI:M,value:F}=C,rt=w(_);let D=_==="value"?F:un(F);if(u.attrName=rt,u.attrValue=D,u.keepAttr=!0,u.forceKeepAttr=void 0,H(v.uponSanitizeAttribute,r,u),D=u.attrValue,ne&&(rt==="id"||rt==="name")&&(yt(_,r),D=qe+D),Nt&&R(/((--!?|])>)|/i,D)){yt(_,r);continue}$&&wt([kt,vt,Dt],Ae=>{D=st(D,Ae," ")});const Te=w(r.nodeName);if(me(Te,rt,D)){if(k&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!M)switch(h.getAttributeType(Te,rt)){case"TrustedHTML":{D=k.createHTML(D);break}case"TrustedScriptURL":{D=k.createScriptURL(D);break}}try{M?r.setAttributeNS(M,_,D):r.setAttribute(_,D),Ut(r)?x(r):ye(t.removed)}catch{}}}H(v.afterSanitizeAttributes,r,null)},tn=function d(r){let l=null;const u=fe(r);for(H(v.beforeSanitizeShadowDOM,r,null);l=u.nextNode();)H(v.uponSanitizeShadowNode,l,null),pe(l),ge(l),l.content instanceof a&&d(l.content);H(v.afterSanitizeShadowDOM,r,null)};return t.sanitize=function(d){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=null,u=null,A=null,C=null;if(Pt=!d,Pt&&(d=""),typeof d!="string"&&!de(d))if(typeof d.toString=="function"){if(d=d.toString(),typeof d!="string")throw lt("dirty is not a string, aborting")}else throw lt("toString is not a function");if(!t.isSupported)return d;if(Ot||Ft(r),t.removed=[],typeof d=="string"&&(it=!1),it){if(d.nodeName){const F=w(d.nodeName);if(!y[F]||nt[F])throw lt("root node is forbidden and cannot be sanitized in-place")}}else if(d instanceof s)l=ue(""),u=l.ownerDocument.importNode(d,!0),u.nodeType===ut.element&&u.nodeName==="BODY"||u.nodeName==="HTML"?l=u:l.appendChild(u);else{if(!q&&!$&&!Y&&d.indexOf(" `+M),$&&wt([kt,vt,Dt],F=>{M=st(M,F," ")}),k&&ht?k.createHTML(M):M},t.setConfig=function(){let d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Ft(d),Ot=!0},t.clearConfig=function(){j=null,Ot=!1},t.isValidAttribute=function(d,r,l){j||Ft({});const u=w(d),A=w(r);return me(u,A,l)},t.addHook=function(d,r){typeof r=="function"&&ot(v[d],r)},t.removeHook=function(d,r){if(r!==void 0){const l=sn(v[d],r);return l===-1?void 0:ln(v[d],l,1)[0]}return ye(v[d])},t.removeHooks=function(d){v[d]=[]},t.removeAllHooks=function(){v=De()},t}var Re=Le();class Q{static noNull(t){return t==null?void 0:t.filter(e=>e!=null)}static noEmpty(t){return t?t.filter(e=>e!==""):[]}static noEmptyNull(t){return t?t.filter(e=>e!==""&&e!==null&&e!==void 0):[]}static dedup(t){if(t===void 0)return;if(t===null)return null;const e=[];for(const n of t)e.indexOf(n)=0;e--)(t[e]===null||t[e]===void 0||t[e]==="")&&t.splice(e,1);return t}static sum(t){let e=0;for(const n of t)e+=n;return e}static flatten(t){const e=[];for(const n of t)Array.isArray(n)?e.push(...n):e.push(n);return e}static dedupOnId(t,e){const n=[],i=new Set;e===void 0&&(e=a=>a.id);for(const a of t){if(!a)continue;const o=e(a);if(typeof o=="string")i.has(o)||(i.add(o),n.push(a));else if(o){const s=Q.noNull(o);s.some(T=>i.has(T))||n.push(a);for(const T of s)i.add(T)}}return n}static duplicates(t){if(t===void 0)return;const e=new Set,n=new Set;for(const i of t)e.has(i)&&n.add(i),e.add(i);return Array.from(n)}static sameList(t,e){if(t==e)return!0;if(t==null||e===void 0||e===null||t.length!==e.length)return!1;for(let n=0;n{const a=Number(n),o=Number(i);return!isNaN(a)&&!isNaN(o)?ao?1:0:ni?1:0}),e}}const c=class c{static initDomPurify(){c.runningFromConsole||Re.addHook("afterSanitizeAttributes",function(t){t.getAttribute("target")&&(t.setAttribute("target","_blank"),t.setAttribute("rel","noopener noreferrer"))})}static purify(t){return Re.sanitize(t,{USE_PROFILES:{html:!0},ADD_ATTR:["target"]})}static ParseVisArgs(t,e){var i;const n={};if(e.length>t.length)throw"To much arguments for special visualization: got "+e.join(",")+" but expected only "+e.length+" arguments";for(let a=0;a/g,">").replace(/"/g,""").replace(/'/g,"'")}static upper(t){return t.substring(0,1).toUpperCase()+t.substring(1)}static twoDigits(t){return t=0?"0"+t:""+t}static round7(t){if(t!=null)return Math.round(t*1e7)/1e7}static times(t,e){let n="";for(let i=0;i{delete t[e];try{return t[e]=n(),i&&i(),t[e]}catch(a){console.error("Error while calculating a lazy property",a);return}}})}static AddLazyPropertyAsync(t,e,n,i){Object.defineProperty(t,e,{enumerable:!1,configurable:!0,get:()=>{n().then(a=>{delete t[e],t[e]=a,i&&i()})}})}static FixedLength(t,e){for(t=c.EllipsesAfter(t,e);t.lengthi===a;for(let i=0;i=0&&([G,tt]=T.split("??"));let h=(e==null?void 0:e[G])??tt;h!=null?(h.toISOString!=null&&(h=h.toISOString()),typeof h!="string"&&(h.asHumanString?h=h.asHumanString(!0,!1):n!==void 0&&(h==null?void 0:h.translations)!==void 0?h=h.translations[n]??h.translations["*"]??(h==null?void 0:h.textFor(n))??h:typeof h=="object"?h=JSON.stringify(h):h=""+h),h=h.replace(/\n/g,"
")):h="",o+=f+h,a=O.match(i),a||(o+=O)}return o}static LoadCustomCss(t){const e=document.getElementsByTagName("head")[0],n=document.createElement("link");n.id="customCss",n.rel="stylesheet",n.type="text/css",n.href=t,n.media="all",e.appendChild(n),console.log("Added custom css file ",t)}static PushList(t,e){e!==void 0&&t.push(...e)}static Merge(t,e){if(e===null)return c.CleanMergeObject(t);for(const n in t){if(n.startsWith("=")){const o=n.substring(1);e[o]=t[n];continue}if(n.endsWith("=")){const o=n.substring(0,n.length-1);e[o]=t[n];continue}if(n.startsWith("+")||n.endsWith("+")){const o=n.replace("+",""),s=t[n],f=e[o]??[];let T;if(n.startsWith("+")){if(!Array.isArray(f))throw new Error("Cannot concatenate: value to add is not an array: "+JSON.stringify(f));if(Array.isArray(s))T=s.concat(f)??f;else throw new Error("Could not merge concatenate "+JSON.stringify(s)+" and "+JSON.stringify(f))}else T=f.concat(s??[]);e[o]=T;continue}const i=t[n],a=e[n];typeof i=="object"?i===null?e[n]=null:a===void 0?e[n]=c.CleanMergeObject(i):(c.Merge(i,a),Array.isArray(a)&&(e[n]=Q.noNull(a))):e[n]=c.CleanMergeObject(i)}return e}static WalkPath(t,e,n,i=[]){if(e==null)return;const a=t[0];if(t.length===1){const s=e[a];s!==void 0&&(Array.isArray(s)?e[a]=s.map(f=>n(f,i)):(e[a]=n(s,i),e[a]===void 0&&delete e[a]));return}const o=e[a];if(o!==void 0&&typeof o=="object"){if(Array.isArray(o)){if(typeof t[1]=="number"){const s=t[1];if(t.length==2){const f=o[s];f!==void 0&&(o[s]=n(f,[...i,""+a,""+s]),o[s]===void 0&&delete o[s])}else c.WalkPath(t.slice(2),o[s],n,[...i,""+a,""+s])}else o.forEach((s,f)=>c.WalkPath(t.slice(1),s,n,[...i,""+a,""+f]));return}c.WalkPath(t.slice(1),o,n,[...i,""+a])}}static CollectPath(t,e,n=[],i=[]){if(e==null)return n;const a=t[0];if(i=[...i,a],t.length===1){const s=e[a];if(s==null)return n;if(Array.isArray(s))for(let f=0;fc.CollectPath(t.slice(1),s,n,[...i,""+f])),n):typeof o!="object"?n:c.CollectPath(t.slice(1),o,n,i)}static WalkJson(t,e,n=void 0,i=[]){if(t==null)return e(t,i);const a=typeof t;if(n!==void 0)if(a==="object"){if(n(t))return e(t,i)}else return t;else if(a==="boolean"||a==="string"||a==="number")return e(t,i);if(Array.isArray(t))return t.map((s,f)=>c.WalkJson(s,e,n,[...i,""+f]));const o={...t};for(const s in t)o[s]=c.WalkJson(t[s],e,n,[...i,s]);return o}static WalkObject(t,e,n=void 0,i=[]){if(t===void 0)return;const a=typeof t;if(n!==void 0){if(a!=="object")return;if(n(t))return e(t,i)}else if(a==="boolean"||a==="string"||a==="number"){e(t,i);return}if(Array.isArray(t)){t.map((o,s)=>c.WalkObject(o,e,n,[...i,s]));return}for(const o in t)c.WalkObject(t[o],e,n,[...i,o])}static getOrSetDefault(t,e,n){const i=t.get(e);return i!==void 0?i:(t.set(e,n()),t.get(e))}static injectJsonDownloadForTests(t,e){c.injectedDownloads[t]=e}static async download(t,e){const n=await c.downloadAdvanced(t,e);if(n.error!==void 0)throw n.error;return n.content}static async downloadAdvanced(t,e,n="GET",i,a=3){let o;for(let s=0;s{const s=new XMLHttpRequest;if(s.onload=()=>{s.status==200?a({content:s.response}):s.status===302?a({redirect:s.getResponseHeader("location")}):s.status===509||s.status===429?a({error:"rate limited",url:t,statuscode:s.status,errContent:s.responseText}):a({error:"other error: "+s.statusText+", "+s.responseText,url:t,statuscode:s.status,errContent:s.responseText})},s.open(n,t),e!==void 0)for(const f in e)s.setRequestHeader(f,e[f]);s.send(i),s.onerror=f=>{console.trace("Error: could not load",f),o("Could not get "+t+", xhr status code is "+s.status+" ("+s.statusText+")")}})}static upload(t,e,n){return new Promise((i,a)=>{const o=new XMLHttpRequest;if(o.onload=()=>{o.status==200?i(o.response):o.status===509||o.status===429?a("rate limited"):a(o.statusText)},o.open("POST",t),n!==void 0)for(const s in n)o.setRequestHeader(s,n[s]);o.send(e),o.onerror=a})}static async downloadJsonCached(t,e,n,i=!1){const a=await c.downloadJsonCachedAdvanced(t,e,n,i);if(a.content)return a.content;throw a.error}static async downloadJsonCachedAdvanced(t,e,n,i=!1,a=3){const o=c._download_cache.get(t);if(o!==void 0&&new Date().getTime()-o.timestamp{window.requestAnimationFrame(()=>{t()})})}static awaitIdle(t){return new Promise(e=>{window.requestIdleCallback(()=>{e()},{timeout:t})})}static async downloadJsonAdvanced(t,e,n=3){const i=c.injectedDownloads[t];if(i!==void 0)return{content:i};const a=await c.downloadAdvanced(t,c.Merge({accept:"application/json"},e??{}),"GET",void 0,n);if(a.error!==void 0)return a;const o=a.content;try{return typeof o=="string"?o===""?{content:{}}:{content:JSON.parse(o)}:{content:o}}catch(s){return console.error("Could not parse the response of",t,"which contains",o,"due to",s,` `,s.stack),{error:"malformed",url:t}}}static offerContentsAsDownloadableFile(t,e="download.txt",n){const i=document.createElement("a");let a;typeof t=="string"?a=new Blob([t],{type:(n==null?void 0:n.mimetype)??"text/plain"}):a=t,i.href=URL.createObjectURL(a),i.download=e,document.body.appendChild(i),i.click()}static async waitFor(t,e){if(!c.runningFromConsole)return new Promise(n=>{window.setTimeout(()=>{n(e)},t)})}static toHumanTime(t){t=Math.floor(t);let e=Math.floor(t/60);t=t%60;let n=Math.floor(e/60);e=e%60;const i=Math.floor(n/24);return n=n%24,i>0?i+"days "+n+"h":n+":"+c.twoDigits(e)+":"+c.twoDigits(t)}static toHumanByteSize(t){const e=["b","KB","MB","GB","TB"];let n=0;for(;t>1e3;)t=t/1e3,n++;return Math.round(t)+e[n]}static HomepageLink(){if(typeof window>"u")return"https://mapcomplete.org";const t=(window.location.protocol+"//"+window.location.host+window.location.pathname).split("/");return t.pop(),t.push("noindex.html"),t.join("/")}static OsmChaLinkFor(t,e=void 0){const n=new Date,i=new Date(n.getTime()-t*24*60*60*1e3),a=i.getFullYear()+"-"+c.twoDigits(i.getMonth()+1)+"-"+c.twoDigits(i.getDate());let o=`"date__gte":[{"label":"${a}","value":"${a}"}],"editor":[{"label":"mapcomplete","value":"mapcomplete"}]`;return e!==void 0&&(o=o+`,"comment":[{"label":"#${e}","value":"#${e}"}]`),"https://osmcha.org/?filters="+encodeURIComponent("{"+o+"}")}static Clone(t){if(t!==void 0)return JSON.parse(JSON.stringify(t))}static ParseDate(t){return t.endsWith(" UTC")&&(t=t.replace(" UTC","+00")),new Date(t)}static selectTextIn(t){if(document.body.createTextRange){const e=document.body.createTextRange();e.moveToElementText(t),e.select()}else if(window.getSelection){const e=window.getSelection(),n=document.createRange();n.selectNodeContents(t),e.removeAllRanges(),e.addRange(n)}else console.warn("Could not select text in node: Unsupported browser.")}static sortedByLevenshteinDistance(t,e,n){n??(n=a=>a);const i=e.map(a=>[a,c.levenshteinDistance(n(a),t)]);return i.sort(([a,o],[s,f])=>o-f),i.map(a=>a[0])}static levenshteinDistance(t,e){const n=Array(e.length+1).fill(null).map(()=>Array(t.length+1).fill(null));for(let i=0;ia);for(const a of i)n[a]=e(t.get(a),a);return n}static TransposeMap(t){const e={};for(const n in t){const i=t[n];for(const a of i){const o=e[a];o===void 0?e[a]=[n]:o.push(n)}}return e}static transposeMapSimple(t){const e={};for(const n in t){const i=t[n];e[i]=n}return e}static colorAsHex(t){if(t===void 0)return;function e(n){const i=n.toString(16);return i.length==1?"0"+i:i}return"#"+e(t.r)+e(t.g)+e(t.b)}static percentageToNumber(t){if(t=t.trim(),t.endsWith("%"))return Math.round(parseInt(t)*255/100);const e=Number(t);if(!isNaN(e))return e}static color(t){if(t!==void 0){if(t=t.replace(/[ \t]/g,""),t.startsWith("rgba(")||t.startsWith("rgb(")){const e=t.match(/rgba?\(([0-9.]+%?),([0-9.]+%?),([0-9.]+%?)(,[0-9.]+%?)?\)/);return e==null?void 0:{r:c.percentageToNumber(e[1]),g:c.percentageToNumber(e[2]),b:c.percentageToNumber(e[3])}}if(t.startsWith("#"))return t.length===4?{r:parseInt(t.substr(1,1),16),g:parseInt(t.substr(2,1),16),b:parseInt(t.substr(3,1),16)}:{r:parseInt(t.substr(1,2),16),g:parseInt(t.substr(3,2),16),b:parseInt(t.substr(5,2),16)}}}static asDict(t){const e=new Map;for(const n of t)e.set(n.key,n.value);return e}static asRecord(t,e){const n={};for(const i of t)n[i]=e(i);return n}static toIdRecord(t){const e={};for(const n of t)e[n.id]=n;return e}static SetMidnight(t){t.setUTCHours(0),t.setUTCSeconds(0),t.setUTCMilliseconds(0),t.setUTCMinutes(0)}static scrollIntoView(t){var T;if(!t)return;const e=(T=c.findParentWithScrolling(t))==null?void 0:T.getBoundingClientRect();if(!e)return;const n=t.getBoundingClientRect(),i=n.top>=e.top,a=n.bottom=e.left,s=n.right{t.focus()})}static focusOnFocusableChild(t){t&&requestAnimationFrame(()=>{let e=t.getElementsByClassName("focusable");e.length==0&&(e=t.getElementsByTagName("button"),e.length===0&&(e=t.getElementsByTagName("a")));const n=e.item(0);n!==null&&(n.tagName!=="button"&&n.tagName!=="a"&&n.hasAttribute("tabindex")&&n.setAttribute("tabindex","-1"),n==null||n.focus())})}static findParentWithScrolling(t){return t.scrollHeight>t.clientHeight?t:t.parentElement?c.findParentWithScrolling(t.parentElement):null}static numberWithMetricPrefix(t){let e=0;for(;t>1e3;)t=Math.round(t/1e3),e++;return t+c._metrixPrefixes[e]}static roundHuman(t){return t"u"),g(c,"prefersReducedMotion",!c.runningFromConsole&&window.matchMedia("(prefers-reduced-motion: reduce)")===!0||!c.runningFromConsole&&window.matchMedia("(prefers-reduced-motion: reduce)").matches===!0),g(c,"externalDownloadFunction"),g(c,"Special_visualizations_tagsToApplyHelpText","These can either be a tag to add, such as `amenity=fast_food` or can use a substitution, e.g. `addr:housenumber=$number`.\nThis new point will then have the tags `amenity=fast_food` and `addr:housenumber` with the value that was saved in `number` in the original feature.\n\nIf a value to substitute is undefined, empty string will be used instead.\n\nThis supports multiple values, e.g. `ref=$source:geometry:type/$source:geometry:ref`\n\nRemark that the syntax is slightly different then expected; it uses '$' to note a value to copy, followed by a name (matched with `[a-zA-Z0-9_:]*`). Sadly, delimiting with `{}` as these already mark the boundaries of the special rendering...\n\nNote that these values can be prepare with javascript in the theme by using a [calculatedTag](calculatedTags.md#calculating-tags-with-javascript)\n "),g(c,"imageExtensions",new Set(["jpg","png","svg","jpeg",".gif"])),g(c,"special_visualizations_importRequirementDocs",`#### Importing a dataset into OpenStreetMap: requirements If you want to import a dataset, make sure that: 1. The dataset to import has a suitable license 2. The community has been informed of the import 3. All other requirements of the [import guidelines](https://wiki.openstreetmap.org/wiki/Import/Guidelines) have been followed There are also some technicalities in your theme to keep in mind: 1. The new feature will be added and will flow through the program as any other new point as if it came from OSM. This means that there should be a layer which will match the new tags and which will display it. 2. The original feature from your geojson layer will gain the tag '_imported=yes'. This should be used to change the appearance or even to hide it (eg by changing the icon size to zero) 3. There should be a way for the theme to detect previously imported points, even after reloading. A reference number to the original dataset is an excellent way to do this 4. When importing ways, the theme creator is also responsible of avoiding overlapping ways. #### Disabled in unofficial themes The import button can be tested in an unofficial theme by adding \`test=true\` or \`backend=osm-test\` as [URL-paramter](URL_Parameters.md). The import button will show up then. If in testmode, you can read the changeset-XML directly in the web console. In the case that MapComplete is pointed to the testing grounds, the edit will be made on https://master.apis.dev.openstreetmap.org`),g(c,"injectedDownloads",{}),g(c,"_download_cache",new Map),g(c,"empty"),g(c,"isIframe",!c.runningFromConsole&&window!==window.top),g(c,"liveLocationFormat",/(.*)@https?:\/\/[^\/]+\/(.*)\?t=\d+:(\d+):(\d+)/),g(c,"_metrixPrefixes",["","k","M","G","T","P","E"]);let Z=c;class vn{static chronic(t,e=void 0,n=""){let i;typeof e=="string"?n=e:i=e;const a=new z(void 0,`chronic(${t},${n})`);function o(){i!==void 0&&!i()||(a.setData(new Date),!Z.runningFromConsole&&window.setTimeout(o,t))}return o(),a}static concat(t,e){const n=new z(t.map(a=>a==null?void 0:a.data,e),e);function i(){if(n._callbacks.isDestroyed)return!0;const a=[];for(const o of t)o&&a.push(o.data);n.setData(a)}for(const a of t)a==null||a.addCallback(()=>i());return n}static listStabilized(t){const e=new z(void 0);return t.addCallbackAndRun(n=>{if(n===void 0){e.setData(void 0);return}Q.sameList(e.data,n)||e.setData(n)}),e}static holdDefined(t){const e=new z(t.data);return t.addCallbackD(n=>{e.setData(n)}),e}}class $t{constructor(t=void 0){g(this,"tag");if(typeof t=="function"&&(t(()=>this.destroy()),t=""),this.tag=t,t===void 0||t===""){let e=Z.runningFromConsole;if(Z.runningFromConsole||(e=window.location.hostname==="127.0.0.1"),e){const n=new Error().stack.split(` `);this.tag=n[1]}}}mapD(t,e,n){return this.map(i=>{if(i!==void 0)return i===null?null:t(i)},typeof e=="function"?[]:e,n??(typeof e=="function"?e:void 0))}bind(t,e,n){const i=this.map(t,typeof e=="function"?void 0:e,n??(typeof e=="function"?e:void 0)),a=new z(void 0),o=new Set;return i.addCallbackAndRun(s=>{if(s===null){a.setData(null);return}if(s===void 0){a.setData(void 0);return}if(o.has(s)){a.setData(s.data);return}o.add(s),s.addCallbackAndRun(f=>{if(i.data===s&&a.setData(f),a._callbacks.isDestroyed)return!0})}),a}bindD(t,e,n){return this.bind(i=>{if(i===null)return null;if(i!==void 0)return t(i)},e,n)}stabilized(t,e=!1){if(Z.runningFromConsole)return this;const n=new z(this.data);if(e){let i=0;this.addCallback(()=>{const a=new Date().getTime();i=a,window.setTimeout(()=>{a===i&&n.ping()},t)})}else this.addCallback(i=>{window.setTimeout(()=>{this.data==i&&n.setData(i)},t)});return n}AsPromise(t){return t=t??(e=>e!==void 0),new Promise(e=>{const n=this.data;t(n)?e(n):this.addCallbackD(i=>t(i)?(e(i),!0):!1)})}subscribe(t){return this.addCallbackAndRun(e=>{t(e)})}once(t,e){e??(e=n=>!!n),this.addCallbackAndRunD(n=>{if(e(n))return t(n),!0})}awaitValue(t){return new Promise(e=>{this.once(n=>e(n),t)})}followingClone(t){const e=new z(this.data,t);return this.addCallback(n=>e.setData(n),t),e}}const I=class I extends $t{constructor(e){super();g(this,"data");this.data=e}addCallback(e){return I.pass}addCallbackAndRun(e){return e(this.data),I.pass}addCallbackAndRunD(e){return this.data!==void 0&&e(this.data),I.pass}addCallbackD(e){return I.pass}map(e,n=void 0,i){return(n==null?void 0:n.length)>0?new dt(this,e,n,void 0,e(this.data),i):new I(e(this.data))}bind(e){return e(this.data)}destroy(){}};g(I,"FALSE",new I(!1)),g(I,"TRUE",new I(!0)),g(I,"pass",()=>{});let Se=I;class Pe{constructor(){g(this,"pingCount",0);g(this,"_callbacks",[]);g(this,"isDestroyed",!1)}addCallback(t,e){if(t===console.log)throw"Don't add console.log directly as a callback - you'll won't be able to find it afterwards. Wrap it in a lambda instead.";this._callbacks.push(t);const n=()=>{const i=this._callbacks.indexOf(t);i>=0&&this._callbacks.splice(i,1)};return e&&e(n),n}ping(t){this.pingCount++;let e;for(const n of this._callbacks)try{n(t)===!0&&(e===void 0?e=[n]:e.push(n))}catch(i){console.error("Got an error while running a callback:",i)}if(e!==void 0)for(const n of e)this._callbacks.splice(this._callbacks.indexOf(n),1);return this._callbacks.length}length(){return this._callbacks.length}destroy(){this.isDestroyed=!0,this._callbacks.splice(0,this._callbacks.length)}}const ft=class ft extends $t{constructor(e,n,i,a,o,s){super();g(this,"_upstream");g(this,"_upstreamCallbackHandler");g(this,"_upstreamPingCount",-1);g(this,"_unregisterFromUpstream");g(this,"_f");g(this,"_extraStores");g(this,"_unregisterFromExtraStores");g(this,"_callbacks",new Pe);g(this,"_callbacksAreRegistered",!1);g(this,"_data");this._upstream=e,this._upstreamCallbackHandler=a,this._f=n,this._data=o,this._upstreamPingCount=a==null?void 0:a.pingCount,typeof i=="function"?s??(s=i):this._extraStores=Q.noNull(i),this.registerCallbacksToUpstream(),s!==void 0&&s(()=>this.unregisterFromUpstream())}get data(){var e;return this._callbacksAreRegistered?this._data:(((e=this._upstreamCallbackHandler)==null?void 0:e.pingCount)!=this._upstreamPingCount&&(this._data=this._f(this._upstream.data)),this._data)}map(e,n=void 0,i){var o,s,f;let a;return typeof n!="function"&&(((n==null?void 0:n.length)>0||((o=this._extraStores)==null?void 0:o.length)>0)&&(a=[]),(n==null?void 0:n.length)>0&&(a==null||a.push(...n)),((s=this._extraStores)==null?void 0:s.length)>0&&((f=this._extraStores)==null||f.forEach(T=>{a.indexOf(T){i(),this._callbacks.length()==0&&this.unregisterFromUpstream()};return n&&n(a),a}addCallbackAndRun(e,n){const i=this.addCallback(e,n);return e(this.data)===!0?(i(),ft.pass):i}addCallbackAndRunD(e,n){return this.addCallbackAndRun(i=>{if(i!==void 0)return e(i)},n)}addCallbackD(e,n){return this.addCallback(i=>{if(i!==void 0)return e(i)},n)}unregisterFromUpstream(){var e,n;this._callbacksAreRegistered&&(this._upstreamPingCount=(e=this._upstreamCallbackHandler)==null?void 0:e.pingCount,this._callbacksAreRegistered=!1,this._unregisterFromUpstream(),(n=this._unregisterFromExtraStores)==null||n.forEach(i=>i()))}registerCallbacksToUpstream(){var e;this._unregisterFromUpstream=this._upstream.addCallback(()=>this.update()),this._unregisterFromExtraStores=(e=this._extraStores)==null?void 0:e.map(n=>n!=null&&n.addCallback?n==null?void 0:n.addCallback(()=>this.update()):()=>{}),this._callbacksAreRegistered=!0}update(){var n;const e=this._f(this._upstream.data);this._upstreamPingCount=(n=this._upstreamCallbackHandler)==null?void 0:n.pingCount,this._data!==e&&(this._data=e,this._callbacks.ping(this._data))}destroy(){this.unregisterFromUpstream()}};g(ft,"pass");let dt=ft;const W=class W extends $t{constructor(e,n=""){super(n);g(this,"data");g(this,"_callbacks",new Pe);this.data=e}destroy(){this._callbacks.destroy()}static flatten(e,n){var a;const i=new W((a=e.data)==null?void 0:a.data);e.addCallback(o=>{i.setData(o==null?void 0:o.data),o.addCallback(s=>{if(e.data!==o)return!0;i.setData(s)})});for(const o of n??[])o==null||o.addCallback(()=>{var s;i.setData((s=e.data)==null?void 0:s.data)});return i}static fromPromise(e,n=void 0){const i=new W(void 0);return e==null||e.then(a=>i.setData(a)),e==null||e.catch(a=>{n!==void 0?n(a):console.warn("Promise failed:",a)}),i}static fromPromiseWithErr(e){var i;const n=new W(void 0);return(i=e==null?void 0:e.then(a=>n.setData({success:a})))==null||i.catch(a=>n.setData({error:a})),n}static asInt(e){return e.sync(n=>{const i=parseInt(n);return isNaN(i)?void 0:i},[],n=>{if(!(n===void 0||isNaN(n)))return""+n})}static asFloat(e){return e.sync(n=>{const i=parseFloat(n);return isNaN(i)?void 0:i},[],n=>{if(!(n===void 0||isNaN(n)))return""+n})}static asBoolean(e){return e.sync(n=>n==="true",[],n=>""+n)}static asObject(e,n){return e.sync(i=>{if(i==null||i==="")return n;try{return JSON.parse(i)}catch(a){return console.error("Could not parse value",i,"due to",a,"; the underlying data store has tag. Will return the default value instead",e.tag),n}},[],i=>JSON.stringify(i)??"")}addCallback(e,n){return this._callbacks.addCallback(e,n)}addCallbackAndRun(e,n){return e(this.data)!==!0?this.addCallback(e,n):W.pass}addCallbackAndRunD(e,n){return this.addCallbackAndRun(i=>{if(i!=null)return e(i)},n)}addCallbackD(e,n){return this.addCallback(i=>{if(i!=null)return e(i)},n)}setData(e){if(this.data!=e)return this.data=e,this._callbacks.ping(e),this}ping(){this._callbacks.ping(this.data)}map(e,n,i){return new dt(this,e,n,this._callbacks,e(this.data),i)}mapD(e,n,i){return new dt(this,a=>{if(a!==void 0)return a===null?null:e(a)},n,this._callbacks,this.data===void 0||this.data===null?this.data:e(this.data),i)}mapAsyncD(e){return this.bindD(n=>W.fromPromise(e(n)))}sync(e,n,i,a=!1){const s=new Error().stack.split(` `)[1],f=new W(e(this.data),"map("+this.tag+")@"+s),T=()=>(f.setData(e(this.data)),a&&f._callbacks.length()===0);this.addCallback(T);for(const O of n)O==null||O.addCallback(T);return i!==void 0&&f.addCallback(O=>{this.setData(i(O,this.data))}),f}syncWith(e,n=!1){return e==this?this:(this.addCallback(i=>e.setData(i)),e.addCallback(i=>this.setData(i)),n?e.data!==void 0&&this.setData(e.data):this.data===void 0?this.setData(e.data):e.setData(this.data),this)}set(e){this.setData(e)}update(e){this.setData(e(this.data))}setDataForcePing(e){if(e==this.data){this.ping();return}this.setData(e)}};g(W,"pass",()=>{});let z=W;export{Se as I,Q as L,vn as S,Z as U,z as a}; //# sourceMappingURL=UIEventSource-92ac4fe9.js.map