json-canvas-viewer 3.4.3 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +51 -107
- package/dist/chimp.js +1 -1
- package/dist/index.d.ts +619 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kernel/BaseModule.js +2 -0
- package/dist/kernel/BaseModule.js.map +1 -0
- package/dist/kernel/Controller.js +2 -0
- package/dist/kernel/Controller.js.map +1 -0
- package/dist/kernel/DataManager.js +2 -0
- package/dist/kernel/DataManager.js.map +1 -0
- package/dist/kernel/InteractionHandler.js +2 -0
- package/dist/kernel/InteractionHandler.js.map +1 -0
- package/dist/kernel/OverlayManager.js +2 -0
- package/dist/kernel/OverlayManager.js.map +1 -0
- package/dist/kernel/Renderer.js +2 -0
- package/dist/kernel/Renderer.js.map +1 -0
- package/dist/kernel/StyleManager.js +2 -0
- package/dist/kernel/StyleManager.js.map +1 -0
- package/dist/kernel/index.js +2 -0
- package/dist/kernel/index.js.map +1 -0
- package/dist/kernel/styles.scss.js +2 -0
- package/dist/kernel/styles.scss.js.map +1 -0
- package/dist/kernel/utilities.js +2 -0
- package/dist/kernel/utilities.js.map +1 -0
- package/dist/modules/Controls/index.js +2 -0
- package/dist/modules/Controls/index.js.map +1 -0
- package/dist/modules/Controls/styles.scss.js +2 -0
- package/dist/modules/Controls/styles.scss.js.map +1 -0
- package/dist/modules/DebugPanel/index.js +2 -0
- package/dist/modules/DebugPanel/index.js.map +1 -0
- package/dist/modules/DebugPanel/styles.scss.js +2 -0
- package/dist/modules/DebugPanel/styles.scss.js.map +1 -0
- package/dist/modules/Minimap/index.js +2 -0
- package/dist/modules/Minimap/index.js.map +1 -0
- package/dist/modules/Minimap/styles.scss.js +2 -0
- package/dist/modules/Minimap/styles.scss.js.map +1 -0
- package/dist/modules/MistouchPreventer/index.js +2 -0
- package/dist/modules/MistouchPreventer/index.js.map +1 -0
- package/dist/modules/MistouchPreventer/styles.scss.js +2 -0
- package/dist/modules/MistouchPreventer/styles.scss.js.map +1 -0
- package/dist/utilities/fetchCanvas.js +2 -0
- package/dist/utilities/fetchCanvas.js.map +1 -0
- package/dist/utilities/parser.js +2 -0
- package/dist/utilities/parser.js.map +1 -0
- package/dist/{renderToString-Dp8A-Rka.js → utilities/renderToString.js} +2 -2
- package/dist/utilities/renderToString.js.map +1 -0
- package/package.json +14 -46
- package/dist/bridges.js +0 -2
- package/dist/bridges.js.map +0 -1
- package/dist/dev.js +0 -2
- package/dist/dev.js.map +0 -1
- package/dist/index-BPBGNZi4.js +0 -2
- package/dist/index-BPBGNZi4.js.map +0 -1
- package/dist/interactionHandler-CrVH9u7P.js +0 -2
- package/dist/interactionHandler-CrVH9u7P.js.map +0 -1
- package/dist/modules.js +0 -2
- package/dist/modules.js.map +0 -1
- package/dist/react.js +0 -2
- package/dist/react.js.map +0 -1
- package/dist/renderToString-Dp8A-Rka.js.map +0 -1
- package/dist/renderer-BGA72dN1.js +0 -2
- package/dist/renderer-BGA72dN1.js.map +0 -1
- package/dist/types/bridges/reactComponent.d.ts +0 -12
- package/dist/types/bridges/renderToString.d.ts +0 -6
- package/dist/types/bridges/vitePlugin.d.ts +0 -8
- package/dist/types/bridges/vueComponent.vue.d.ts +0 -28
- package/dist/types/bridges/webpackPlugin.d.ts +0 -7
- package/dist/types/bridges.d.ts +0 -3
- package/dist/types/chimp.d.ts +0 -7
- package/dist/types/core/baseModule.d.ts +0 -19
- package/dist/types/core/controller.d.ts +0 -35
- package/dist/types/core/dataManager.d.ts +0 -59
- package/dist/types/core/declarations.d.ts +0 -105
- package/dist/types/core/index.d.ts +0 -25
- package/dist/types/core/interactionHandler.d.ts +0 -39
- package/dist/types/core/overlayManager.d.ts +0 -44
- package/dist/types/core/renderer.d.ts +0 -32
- package/dist/types/core/styleManager.d.ts +0 -49
- package/dist/types/core/utilities.d.ts +0 -25
- package/dist/types/dev.d.ts +0 -9
- package/dist/types/index.d.ts +0 -2
- package/dist/types/modules/controls/index.d.ts +0 -38
- package/dist/types/modules/debugPanel/index.d.ts +0 -9
- package/dist/types/modules/minimap/index.d.ts +0 -32
- package/dist/types/modules/mistouchPreventer/index.d.ts +0 -25
- package/dist/types/modules.d.ts +0 -4
- package/dist/vue.js +0 -2
- package/dist/vue.js.map +0 -1
- package/dist/webpackLoader.js +0 -33
package/dist/chimp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const{entries:e,setPrototypeOf:t,isFrozen:n,getPrototypeOf:i,getOwnPropertyDescriptor:s}=Object;let{freeze:r,seal:o,create:a}=Object,{apply:l,construct:c}="undefined"!=typeof Reflect&&Reflect;r||(r=function(e){return e}),o||(o=function(e){return e}),l||(l=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];return e.apply(t,i)}),c||(c=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const h=T(Array.prototype.forEach),p=T(Array.prototype.lastIndexOf),u=T(Array.prototype.pop),d=T(Array.prototype.push),m=T(Array.prototype.splice),g=T(String.prototype.toLowerCase),f=T(String.prototype.toString),b=T(String.prototype.match),x=T(String.prototype.replace),w=T(String.prototype.indexOf),k=T(String.prototype.trim),v=T(Object.prototype.hasOwnProperty),y=T(RegExp.prototype.test),C=(S=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return c(S,t)});var S;function T(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return l(e,t,i)}}function E(e,i){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:g;t&&t(e,null);let r=i.length;for(;r--;){let t=i[r];if("string"==typeof t){const e=s(t);e!==t&&(n(i)||(i[r]=e),t=e)}e[t]=!0}return e}function M(e){for(let t=0;t<e.length;t++){v(e,t)||(e[t]=null)}return e}function _(t){const n=a(null);for(const[i,s]of e(t)){v(t,i)&&(Array.isArray(s)?n[i]=M(s):s&&"object"==typeof s&&s.constructor===Object?n[i]=_(s):n[i]=s)}return n}function R(e,t){for(;null!==e;){const n=s(e,t);if(n){if(n.get)return T(n.get);if("function"==typeof n.value)return T(n.value)}e=i(e)}return function(){return null}}const z=r(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),A=r(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),D=r(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),I=r(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),N=r(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),L=r(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),O=r(["#text"]),P=r(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),B=r(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),$=r(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),F=r(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),H=o(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Y=o(/<%[\w\W]*|[\w\W]*%>/gm),X=o(/\$\{[\w\W]*/gm),j=o(/^data-[\-\w.\u00B7-\uFFFF]+$/),U=o(/^aria-[\-\w]+$/),q=o(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),W=o(/^(?:\w+script|data):/i),V=o(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),G=o(/^html$/i),Z=o(/^[a-z][.\w]*(-[.\w]+)+$/i);var Q=/* @__PURE__ */Object.freeze({__proto__:null,ARIA_ATTR:U,ATTR_WHITESPACE:V,CUSTOM_ELEMENT:Z,DATA_ATTR:j,DOCTYPE_NAME:G,ERB_EXPR:Y,IS_ALLOWED_URI:q,IS_SCRIPT_OR_DATA:W,MUSTACHE_EXPR:H,TMPLIT_EXPR:X});const K=1,J=3,ee=7,te=8,ne=9;var ie=function t(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"undefined"==typeof window?null:window;const i=e=>t(e);if(i.version="3.3.1",i.removed=[],!n||!n.document||n.document.nodeType!==ne||!n.Element)return i.isSupported=!1,i;let{document:s}=n;const o=s,l=o.currentScript,{DocumentFragment:c,HTMLTemplateElement:S,Node:T,Element:M,NodeFilter:H,NamedNodeMap:Y=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:X,DOMParser:j,trustedTypes:U}=n,W=M.prototype,V=R(W,"cloneNode"),Z=R(W,"remove"),ie=R(W,"nextSibling"),se=R(W,"childNodes"),re=R(W,"parentNode");if("function"==typeof S){const e=s.createElement("template");e.content&&e.content.ownerDocument&&(s=e.content.ownerDocument)}let oe,ae="";const{implementation:le,createNodeIterator:ce,createDocumentFragment:he,getElementsByTagName:pe}=s,{importNode:ue}=o;let de={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};i.isSupported="function"==typeof e&&"function"==typeof re&&le&&void 0!==le.createHTMLDocument;const{MUSTACHE_EXPR:me,ERB_EXPR:ge,TMPLIT_EXPR:fe,DATA_ATTR:be,ARIA_ATTR:xe,IS_SCRIPT_OR_DATA:we,ATTR_WHITESPACE:ke,CUSTOM_ELEMENT:ve}=Q;let{IS_ALLOWED_URI:ye}=Q,Ce=null;const Se=E({},[...z,...A,...D,...N,...O]);let Te=null;const Ee=E({},[...P,...B,...$,...F]);let Me=Object.seal(a(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}})),_e=null,Re=null;const ze=Object.seal(a(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ae=!0,De=!0,Ie=!1,Ne=!0,Le=!1,Oe=!0,Pe=!1,Be=!1,$e=!1,Fe=!1,He=!1,Ye=!1,Xe=!0,je=!1,Ue=!0,qe=!1,We={},Ve=null;const Ge=E({},["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 Ze=null;const Qe=E({},["audio","video","img","source","image","track"]);let Ke=null;const Je=E({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),et="http://www.w3.org/1998/Math/MathML",tt="http://www.w3.org/2000/svg",nt="http://www.w3.org/1999/xhtml";let it=nt,st=!1,rt=null;const ot=E({},[et,tt,nt],f);let at=E({},["mi","mo","mn","ms","mtext"]),lt=E({},["annotation-xml"]);const ct=E({},["title","style","font","a","script"]);let ht=null;const pt=["application/xhtml+xml","text/html"];let ut=null,dt=null;const mt=s.createElement("form"),gt=function(e){return e instanceof RegExp||e instanceof Function},ft=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!dt||dt!==e){if(e&&"object"==typeof e||(e={}),e=_(e),ht=-1===pt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,ut="application/xhtml+xml"===ht?f:g,Ce=v(e,"ALLOWED_TAGS")?E({},e.ALLOWED_TAGS,ut):Se,Te=v(e,"ALLOWED_ATTR")?E({},e.ALLOWED_ATTR,ut):Ee,rt=v(e,"ALLOWED_NAMESPACES")?E({},e.ALLOWED_NAMESPACES,f):ot,Ke=v(e,"ADD_URI_SAFE_ATTR")?E(_(Je),e.ADD_URI_SAFE_ATTR,ut):Je,Ze=v(e,"ADD_DATA_URI_TAGS")?E(_(Qe),e.ADD_DATA_URI_TAGS,ut):Qe,Ve=v(e,"FORBID_CONTENTS")?E({},e.FORBID_CONTENTS,ut):Ge,_e=v(e,"FORBID_TAGS")?E({},e.FORBID_TAGS,ut):_({}),Re=v(e,"FORBID_ATTR")?E({},e.FORBID_ATTR,ut):_({}),We=!!v(e,"USE_PROFILES")&&e.USE_PROFILES,Ae=!1!==e.ALLOW_ARIA_ATTR,De=!1!==e.ALLOW_DATA_ATTR,Ie=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ne=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Le=e.SAFE_FOR_TEMPLATES||!1,Oe=!1!==e.SAFE_FOR_XML,Pe=e.WHOLE_DOCUMENT||!1,Fe=e.RETURN_DOM||!1,He=e.RETURN_DOM_FRAGMENT||!1,Ye=e.RETURN_TRUSTED_TYPE||!1,$e=e.FORCE_BODY||!1,Xe=!1!==e.SANITIZE_DOM,je=e.SANITIZE_NAMED_PROPS||!1,Ue=!1!==e.KEEP_CONTENT,qe=e.IN_PLACE||!1,ye=e.ALLOWED_URI_REGEXP||q,it=e.NAMESPACE||nt,at=e.MATHML_TEXT_INTEGRATION_POINTS||at,lt=e.HTML_INTEGRATION_POINTS||lt,Me=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&>(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Me.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&>(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Me.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Me.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Le&&(De=!1),He&&(Fe=!0),We&&(Ce=E({},O),Te=[],!0===We.html&&(E(Ce,z),E(Te,P)),!0===We.svg&&(E(Ce,A),E(Te,B),E(Te,F)),!0===We.svgFilters&&(E(Ce,D),E(Te,B),E(Te,F)),!0===We.mathMl&&(E(Ce,N),E(Te,$),E(Te,F))),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?ze.tagCheck=e.ADD_TAGS:(Ce===Se&&(Ce=_(Ce)),E(Ce,e.ADD_TAGS,ut))),e.ADD_ATTR&&("function"==typeof e.ADD_ATTR?ze.attributeCheck=e.ADD_ATTR:(Te===Ee&&(Te=_(Te)),E(Te,e.ADD_ATTR,ut))),e.ADD_URI_SAFE_ATTR&&E(Ke,e.ADD_URI_SAFE_ATTR,ut),e.FORBID_CONTENTS&&(Ve===Ge&&(Ve=_(Ve)),E(Ve,e.FORBID_CONTENTS,ut)),e.ADD_FORBID_CONTENTS&&(Ve===Ge&&(Ve=_(Ve)),E(Ve,e.ADD_FORBID_CONTENTS,ut)),Ue&&(Ce["#text"]=!0),Pe&&E(Ce,["html","head","body"]),Ce.table&&(E(Ce,["tbody"]),delete _e.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw C('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw C('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');oe=e.TRUSTED_TYPES_POLICY,ae=oe.createHTML("")}else void 0===oe&&(oe=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const s="dompurify"+(n?"#"+n:"");try{return e.createPolicy(s,{createHTML:e=>e,createScriptURL:e=>e})}catch(r){return console.warn("TrustedTypes policy "+s+" could not be created."),null}}(U,l)),null!==oe&&"string"==typeof ae&&(ae=oe.createHTML(""));r&&r(e),dt=e}},bt=E({},[...A,...D,...I]),xt=E({},[...N,...L]),wt=function(e){d(i.removed,{element:e});try{re(e).removeChild(e)}catch(t){Z(e)}},kt=function(e,t){try{d(i.removed,{attribute:t.getAttributeNode(e),from:t})}catch(n){d(i.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(Fe||He)try{wt(t)}catch(n){}else try{t.setAttribute(e,"")}catch(n){}},vt=function(e){let t=null,n=null;if($e)e="<remove></remove>"+e;else{const t=b(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===ht&&it===nt&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const i=oe?oe.createHTML(e):e;if(it===nt)try{t=(new j).parseFromString(i,ht)}catch(o){}if(!t||!t.documentElement){t=le.createDocument(it,"template",null);try{t.documentElement.innerHTML=st?ae:i}catch(o){}}const r=t.body||t.documentElement;return e&&n&&r.insertBefore(s.createTextNode(n),r.childNodes[0]||null),it===nt?pe.call(t,Pe?"html":"body")[0]:Pe?t.documentElement:r},yt=function(e){return ce.call(e.ownerDocument||e,e,H.SHOW_ELEMENT|H.SHOW_COMMENT|H.SHOW_TEXT|H.SHOW_PROCESSING_INSTRUCTION|H.SHOW_CDATA_SECTION,null)},Ct=function(e){return e instanceof X&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof Y)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},St=function(e){return"function"==typeof T&&e instanceof T};function Tt(e,t,n){h(e,e=>{e.call(i,t,n,dt)})}const Et=function(e){let t=null;if(Tt(de.beforeSanitizeElements,e,null),Ct(e))return wt(e),!0;const n=ut(e.nodeName);if(Tt(de.uponSanitizeElement,e,{tagName:n,allowedTags:Ce}),Oe&&e.hasChildNodes()&&!St(e.firstElementChild)&&y(/<[/\w!]/g,e.innerHTML)&&y(/<[/\w!]/g,e.textContent))return wt(e),!0;if(e.nodeType===ee)return wt(e),!0;if(Oe&&e.nodeType===te&&y(/<[/\w]/g,e.data))return wt(e),!0;if(!(ze.tagCheck instanceof Function&&ze.tagCheck(n))&&(!Ce[n]||_e[n])){if(!_e[n]&&_t(n)){if(Me.tagNameCheck instanceof RegExp&&y(Me.tagNameCheck,n))return!1;if(Me.tagNameCheck instanceof Function&&Me.tagNameCheck(n))return!1}if(Ue&&!Ve[n]){const t=re(e)||e.parentNode,n=se(e)||e.childNodes;if(n&&t){for(let i=n.length-1;i>=0;--i){const s=V(n[i],!0);s.__removalCount=(e.__removalCount||0)+1,t.insertBefore(s,ie(e))}}}return wt(e),!0}return e instanceof M&&!function(e){let t=re(e);t&&t.tagName||(t={namespaceURI:it,tagName:"template"});const n=g(e.tagName),i=g(t.tagName);return!!rt[e.namespaceURI]&&(e.namespaceURI===tt?t.namespaceURI===nt?"svg"===n:t.namespaceURI===et?"svg"===n&&("annotation-xml"===i||at[i]):Boolean(bt[n]):e.namespaceURI===et?t.namespaceURI===nt?"math"===n:t.namespaceURI===tt?"math"===n&<[i]:Boolean(xt[n]):e.namespaceURI===nt?!(t.namespaceURI===tt&&!lt[i])&&!(t.namespaceURI===et&&!at[i])&&!xt[n]&&(ct[n]||!bt[n]):!("application/xhtml+xml"!==ht||!rt[e.namespaceURI]))}(e)?(wt(e),!0):"noscript"!==n&&"noembed"!==n&&"noframes"!==n||!y(/<\/no(script|embed|frames)/i,e.innerHTML)?(Le&&e.nodeType===J&&(t=e.textContent,h([me,ge,fe],e=>{t=x(t,e," ")}),e.textContent!==t&&(d(i.removed,{element:e.cloneNode()}),e.textContent=t)),Tt(de.afterSanitizeElements,e,null),!1):(wt(e),!0)},Mt=function(e,t,n){if(Xe&&("id"===t||"name"===t)&&(n in s||n in mt))return!1;if(De&&!Re[t]&&y(be,t));else if(Ae&&y(xe,t));else if(ze.attributeCheck instanceof Function&&ze.attributeCheck(t,e));else if(!Te[t]||Re[t]){if(!(_t(e)&&(Me.tagNameCheck instanceof RegExp&&y(Me.tagNameCheck,e)||Me.tagNameCheck instanceof Function&&Me.tagNameCheck(e))&&(Me.attributeNameCheck instanceof RegExp&&y(Me.attributeNameCheck,t)||Me.attributeNameCheck instanceof Function&&Me.attributeNameCheck(t,e))||"is"===t&&Me.allowCustomizedBuiltInElements&&(Me.tagNameCheck instanceof RegExp&&y(Me.tagNameCheck,n)||Me.tagNameCheck instanceof Function&&Me.tagNameCheck(n))))return!1}else if(Ke[t]);else if(y(ye,x(n,ke,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==w(n,"data:")||!Ze[e]){if(Ie&&!y(we,x(n,ke,"")));else if(n)return!1}else;return!0},_t=function(e){return"annotation-xml"!==e&&b(e,ve)},Rt=function(e){Tt(de.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||Ct(e))return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Te,forceKeepAttr:void 0};let s=t.length;for(;s--;){const o=t[s],{name:a,namespaceURI:l,value:c}=o,p=ut(a),d=c;let m="value"===a?d:k(d);if(n.attrName=p,n.attrValue=m,n.keepAttr=!0,n.forceKeepAttr=void 0,Tt(de.uponSanitizeAttribute,e,n),m=n.attrValue,!je||"id"!==p&&"name"!==p||(kt(a,e),m="user-content-"+m),Oe&&y(/((--!?|])>)|<\/(style|title|textarea)/i,m)){kt(a,e);continue}if("attributename"===p&&b(m,"href")){kt(a,e);continue}if(n.forceKeepAttr)continue;if(!n.keepAttr){kt(a,e);continue}if(!Ne&&y(/\/>/i,m)){kt(a,e);continue}Le&&h([me,ge,fe],e=>{m=x(m,e," ")});const g=ut(e.nodeName);if(Mt(g,p,m)){if(oe&&"object"==typeof U&&"function"==typeof U.getAttributeType)if(l);else switch(U.getAttributeType(g,p)){case"TrustedHTML":m=oe.createHTML(m);break;case"TrustedScriptURL":m=oe.createScriptURL(m)}if(m!==d)try{l?e.setAttributeNS(l,a,m):e.setAttribute(a,m),Ct(e)?wt(e):u(i.removed)}catch(r){kt(a,e)}}else kt(a,e)}Tt(de.afterSanitizeAttributes,e,null)},zt=function e(t){let n=null;const i=yt(t);for(Tt(de.beforeSanitizeShadowDOM,t,null);n=i.nextNode();)Tt(de.uponSanitizeShadowNode,n,null),Et(n),Rt(n),n.content instanceof c&&e(n.content);Tt(de.afterSanitizeShadowDOM,t,null)};return i.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,s=null,r=null,a=null;if(st=!e,st&&(e="\x3c!--\x3e"),"string"!=typeof e&&!St(e)){if("function"!=typeof e.toString)throw C("toString is not a function");if("string"!=typeof(e=e.toString()))throw C("dirty is not a string, aborting")}if(!i.isSupported)return e;if(Be||ft(t),i.removed=[],"string"==typeof e&&(qe=!1),qe){if(e.nodeName){const t=ut(e.nodeName);if(!Ce[t]||_e[t])throw C("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof T)n=vt("\x3c!----\x3e"),s=n.ownerDocument.importNode(e,!0),s.nodeType===K&&"BODY"===s.nodeName||"HTML"===s.nodeName?n=s:n.appendChild(s);else{if(!Fe&&!Le&&!Pe&&-1===e.indexOf("<"))return oe&&Ye?oe.createHTML(e):e;if(n=vt(e),!n)return Fe?null:Ye?ae:""}n&&$e&&wt(n.firstChild);const l=yt(qe?e:n);for(;r=l.nextNode();)Et(r),Rt(r),r.content instanceof c&&zt(r.content);if(qe)return e;if(Fe){if(He)for(a=he.call(n.ownerDocument);n.firstChild;)a.appendChild(n.firstChild);else a=n;return(Te.shadowroot||Te.shadowrootmode)&&(a=ue.call(o,a,!0)),a}let p=Pe?n.outerHTML:n.innerHTML;return Pe&&Ce["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&y(G,n.ownerDocument.doctype.name)&&(p="<!DOCTYPE "+n.ownerDocument.doctype.name+">\n"+p),Le&&h([me,ge,fe],e=>{p=x(p,e," ")}),oe&&Ye?oe.createHTML(p):p},i.setConfig=function(){ft(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Be=!0},i.clearConfig=function(){dt=null,Be=!1},i.isValidAttribute=function(e,t,n){dt||ft({});const i=ut(e),s=ut(t);return Mt(i,s,n)},i.addHook=function(e,t){"function"==typeof t&&d(de[e],t)},i.removeHook=function(e,t){if(void 0!==t){const n=p(de[e],t);return-1===n?void 0:m(de[e],n,1)[0]}return u(de[e])},i.removeHooks=function(e){de[e]=[]},i.removeAllHooks=function(){de={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},i}();function se(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var re={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function oe(e){re=e}var ae={exec:()=>null};function le(e,t=""){let n="string"==typeof e?e:e.source,i={replace:(e,t)=>{let s="string"==typeof t?t:t.source;return s=s.replace(he.caret,"$1"),n=n.replace(e,s),i},getRegex:()=>new RegExp(n,t)};return i}var ce=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),he={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},pe=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ue=/(?:[*+-]|\d{1,9}[.)])/,de=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,me=le(de).replace(/bull/g,ue).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),ge=le(de).replace(/bull/g,ue).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),fe=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,be=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,xe=le(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",be).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),we=le(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ue).getRegex(),ke="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ve=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,ye=le("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",ve).replace("tag",ke).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ce=le(fe).replace("hr",pe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ke).getRegex(),Se={blockquote:le(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Ce).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:xe,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:pe,html:ye,lheading:me,list:we,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:Ce,table:ae,text:/^[^\n]+/},Te=le("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",pe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ke).getRegex(),Ee={...Se,lheading:ge,table:Te,paragraph:le(fe).replace("hr",pe).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",Te).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ke).getRegex()},Me={...Se,html:le("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",ve).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ae,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:le(fe).replace("hr",pe).replace("heading"," *#{1,6} *[^\n]").replace("lheading",me).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},_e=/^( {2,}|\\)\n(?!\s*$)/,Re=/[\p{P}\p{S}]/u,ze=/[\s\p{P}\p{S}]/u,Ae=/[^\s\p{P}\p{S}]/u,De=le(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,ze).getRegex(),Ie=/(?!~)[\p{P}\p{S}]/u,Ne=le(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",ce?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Le=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Oe=le(Le,"u").replace(/punct/g,Re).getRegex(),Pe=le(Le,"u").replace(/punct/g,Ie).getRegex(),Be="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",$e=le(Be,"gu").replace(/notPunctSpace/g,Ae).replace(/punctSpace/g,ze).replace(/punct/g,Re).getRegex(),Fe=le(Be,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,Ie).getRegex(),He=le("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Ae).replace(/punctSpace/g,ze).replace(/punct/g,Re).getRegex(),Ye=le(/\\(punct)/,"gu").replace(/punct/g,Re).getRegex(),Xe=le(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),je=le(ve).replace("(?:--\x3e|$)","--\x3e").getRegex(),Ue=le("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",je).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),qe=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,We=le(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",qe).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ve=le(/^!?\[(label)\]\[(ref)\]/).replace("label",qe).replace("ref",be).getRegex(),Ge=le(/^!?\[(ref)\](?:\[\])?/).replace("ref",be).getRegex(),Ze=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Qe={_backpedal:ae,anyPunctuation:Ye,autolink:Xe,blockSkip:Ne,br:_e,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:ae,emStrongLDelim:Oe,emStrongRDelimAst:$e,emStrongRDelimUnd:He,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:We,nolink:Ge,punctuation:De,reflink:Ve,reflinkSearch:le("reflink|nolink(?!\\()","g").replace("reflink",Ve).replace("nolink",Ge).getRegex(),tag:Ue,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:ae},Ke={...Qe,link:le(/^!?\[(label)\]\((.*?)\)/).replace("label",qe).getRegex(),reflink:le(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",qe).getRegex()},Je={...Qe,emStrongRDelimAst:Fe,emStrongLDelim:Pe,url:le(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Ze).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:le(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Ze).getRegex()},et={...Je,br:le(_e).replace("{2,}","*").getRegex(),text:le(Je.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},tt={normal:Se,gfm:Ee,pedantic:Me},nt={normal:Qe,gfm:Je,breaks:et,pedantic:Ke},it={"&":"&","<":"<",">":">",'"':""","'":"'"},st=e=>it[e];function rt(e,t){if(t){if(he.escapeTest.test(e))return e.replace(he.escapeReplace,st)}else if(he.escapeTestNoEncode.test(e))return e.replace(he.escapeReplaceNoEncode,st);return e}function ot(e){try{e=encodeURI(e).replace(he.percentDecode,"%")}catch{return null}return e}function at(e,t){let n=e.replace(he.findPipe,(e,t,n)=>{let i=!1,s=t;for(;--s>=0&&"\\"===n[s];)i=!i;return i?"|":" |"}).split(he.splitPipe),i=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(he.slashPipe,"|");return n}function lt(e,t,n){let i=e.length;if(0===i)return"";let s=0;for(;s<i;){if(e.charAt(i-s-1)!==t)break;s++}return e.slice(0,i-s)}function ct(e,t,n,i,s){let r=t.href,o=t.title||null,a=e[1].replace(s.other.outputLinkReplace,"$1");i.state.inLink=!0;let l={type:"!"===e[0].charAt(0)?"image":"link",raw:n,href:r,title:o,text:a,tokens:i.inlineTokens(a)};return i.state.inLink=!1,l}var ht=class{options;rules;lexer;constructor(e){this.options=e||re}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:lt(e,"\n")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(null===i)return t;let s=i[1];return t.split("\n").map(e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[i]=t;return i.length>=s.length?e.slice(s.length):e}).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=lt(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:lt(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=lt(t[0],"\n").split("\n"),n="",i="",s=[];for(;e.length>0;){let t,r=!1,o=[];for(t=0;t<e.length;t++)if(this.rules.other.blockquoteStart.test(e[t]))o.push(e[t]),r=!0;else{if(r)break;o.push(e[t])}e=e.slice(t);let a=o.join("\n"),l=a.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${a}`:a,i=i?`${i}\n${l}`:l;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,s,!0),this.lexer.state.top=c,0===e.length)break;let h=s.at(-1);if("code"===h?.type)break;if("blockquote"===h?.type){let t=h,r=t.raw+"\n"+e.join("\n"),o=this.blockquote(r);s[s.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,i=i.substring(0,i.length-t.text.length)+o.text;break}if("list"===h?.type){let t=h,r=t.raw+"\n"+e.join("\n"),o=this.list(r);s[s.length-1]=o,n=n.substring(0,n.length-h.raw.length)+o.raw,i=i.substring(0,i.length-t.raw.length)+o.raw,e=r.substring(s.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:n,tokens:s,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),i=n.length>1,s={type:"list",raw:"",ordered:i,start:i?+n.slice(0,-1):"",loose:!1,items:[]};n=i?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=i?n:"[*+-]");let r=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,i="",a="";if(!(t=r.exec(e))||this.rules.block.hr.test(e))break;i=t[0],e=e.substring(i.length);let l=t[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,e=>" ".repeat(3*e.length)),c=e.split("\n",1)[0],h=!l.trim(),p=0;if(this.options.pedantic?(p=2,a=l.trimStart()):h?p=t[1].length+1:(p=t[2].search(this.rules.other.nonSpaceChar),p=p>4?1:p,a=l.slice(p),p+=t[1].length),h&&this.rules.other.blankLine.test(c)&&(i+=c+"\n",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(p),n=this.rules.other.hrRegex(p),s=this.rules.other.fencesBeginRegex(p),r=this.rules.other.headingBeginRegex(p),o=this.rules.other.htmlBeginRegex(p);for(;e;){let u,d=e.split("\n",1)[0];if(c=d,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),u=c):u=c.replace(this.rules.other.tabCharGlobal," "),s.test(c)||r.test(c)||o.test(c)||t.test(c)||n.test(c))break;if(u.search(this.rules.other.nonSpaceChar)>=p||!c.trim())a+="\n"+u.slice(p);else{if(h||l.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||s.test(l)||r.test(l)||n.test(l))break;a+="\n"+c}!h&&!c.trim()&&(h=!0),i+=d+"\n",e=e.substring(d.length+1),l=u.slice(p)}}s.loose||(o?s.loose=!0:this.rules.other.doubleBlankLine.test(i)&&(o=!0)),s.items.push({type:"list_item",raw:i,task:!!this.options.gfm&&this.rules.other.listIsTask.test(a),loose:!1,text:a,tokens:[]}),s.raw+=i}let a=s.items.at(-1);if(!a)return;a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd(),s.raw=s.raw.trimEnd();for(let e of s.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,""),"text"===e.tokens[0]?.type||"paragraph"===e.tokens[0]?.type){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:"checkbox",raw:t[0]+" ",checked:"[ ]"!==t[0]};e.checked=n.checked,s.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:"paragraph",raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!s.loose){let t=e.tokens.filter(e=>"space"===e.type),n=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw));s.loose=n}}if(s.loose)for(let e of s.items){e.loose=!0;for(let t of e.tokens)"text"===t.type&&(t.type="paragraph")}return s}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=at(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(let e of i)this.rules.other.tableAlignRight.test(e)?r.align.push("right"):this.rules.other.tableAlignCenter.test(e)?r.align.push("center"):this.rules.other.tableAlignLeft.test(e)?r.align.push("left"):r.align.push(null);for(let e=0;e<n.length;e++)r.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:r.align[e]});for(let e of s)r.rows.push(at(e,r.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:r.align[t]})));return r}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=lt(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let i=0;i<e.length;i++)if("\\"===e[i])i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],i="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],i=e[3])}else i=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),ct(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return ct(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!i[1]&&!i[2]||!n||this.rules.inline.punctuation.exec(n))){let n,s,r=[...i[0]].length-1,o=r,a=0,l="*"===i[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+r);null!=(i=l.exec(t));){if(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!n)continue;if(s=[...n].length,i[3]||i[4]){o+=s;continue}if((i[5]||i[6])&&r%3&&!((r+s)%3)){a+=s;continue}if(o-=s,o>0)continue;s=Math.min(s,s+o+a);let t=[...i[0]][0].length,l=e.slice(0,r+i.index+t+s);if(Math.min(r,s)%2){let e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}let c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=t[0],n="mailto:"+e;else{let i;do{i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(i!==t[0]);e=t[0],n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},pt=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=/* @__PURE__ */Object.create(null),this.options=e||re,this.options.tokenizer=this.options.tokenizer||new ht,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:he,block:tt.normal,inline:nt.normal};this.options.pedantic?(t.block=tt.pedantic,t.inline=nt.pedantic):this.options.gfm&&(t.block=tt.gfm,this.options.breaks?t.inline=nt.breaks:t.inline=nt.gfm),this.tokenizer.rules=t}static get rules(){return{block:tt,inline:nt}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(he.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let e=this.inlineQueue[t];this.inlineTokens(e.src,e.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(he.tabCharGlobal," ").replace(he.spaceLine,""));e;){let i;if(this.options.extensions?.block?.some(n=>!!(i=n.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);1===i.raw.length&&void 0!==n?n.raw+="\n":t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+i.raw,n.text+="\n"+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+i.raw,n.text+="\n"+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let s=e;if(this.options.extensions?.startBlock){let t,n=1/0,i=e.slice(1);this.options.extensions.startBlock.forEach(e=>{t=e.call({lexer:this},i),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(s=e.substring(0,n+1))}if(this.state.top&&(i=this.tokenizer.paragraph(s))){let r=t.at(-1);n&&"paragraph"===r?.type?(r.raw+=(r.raw.endsWith("\n")?"":"\n")+i.raw,r.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=s.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+i.raw,n.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,i=e,s=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(s=this.tokenizer.rules.inline.reflinkSearch.exec(i));)e.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(s=this.tokenizer.rules.inline.anyPunctuation.exec(i));)i=i.slice(0,s.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(s=this.tokenizer.rules.inline.blockSkip.exec(i));)n=s[2]?s[2].length:0,i=i.slice(0,s.index+n)+"["+"a".repeat(s[0].length-n-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let r=!1,o="";for(;e;){let n;if(r||(o=""),r=!1,this.options.extensions?.inline?.some(i=>!!(n=i.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))continue;if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length);let i=t.at(-1);"text"===n.type&&"text"===i?.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,i,o)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),t.push(n);continue}let s=e;if(this.options.extensions?.startInline){let t,n=1/0,i=e.slice(1);this.options.extensions.startInline.forEach(e=>{t=e.call({lexer:this},i),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(s=e.substring(0,n+1))}if(n=this.tokenizer.inlineText(s)){e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(o=n.raw.slice(-1)),r=!0;let i=t.at(-1);"text"===i?.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return t}},ut=class{options;parser;constructor(e){this.options=e||re}space(e){return""}code({text:e,lang:t,escaped:n}){let i=(t||"").match(he.notSpaceStart)?.[0],s=e.replace(he.endingNewline,"")+"\n";return i?'<pre><code class="language-'+rt(i)+'">'+(n?s:rt(s,!0))+"</code></pre>\n":"<pre><code>"+(n?s:rt(s,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){let t=e.ordered,n=e.start,i="";for(let r=0;r<e.items.length;r++){let t=e.items[r];i+=this.listitem(t)}let s=t?"ol":"ul";return"<"+s+(t&&1!==n?' start="'+n+'"':"")+">\n"+i+"</"+s+">\n"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let t="",n="";for(let s=0;s<e.header.length;s++)n+=this.tablecell(e.header[s]);t+=this.tablerow({text:n});let i="";for(let s=0;s<e.rows.length;s++){let t=e.rows[s];n="";for(let e=0;e<t.length;e++)n+=this.tablecell(t[e]);i+=this.tablerow({text:n})}return i&&(i=`<tbody>${i}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+i+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${rt(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let i=this.parser.parseInline(n),s=ot(e);if(null===s)return i;let r='<a href="'+(e=s)+'"';return t&&(r+=' title="'+rt(t)+'"'),r+=">"+i+"</a>",r}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let s=ot(e);if(null===s)return rt(n);let r=`<img src="${e=s}" alt="${n}"`;return t&&(r+=` title="${rt(t)}"`),r+=">",r}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:rt(e.text)}},dt=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},mt=class e{options;renderer;textRenderer;constructor(e){this.options=e||re,this.options.renderer=this.options.renderer||new ut,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new dt}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){let t="";for(let n=0;n<e.length;n++){let i=e[n];if(this.options.extensions?.renderers?.[i.type]){let e=i,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==n||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){t+=n||"";continue}}let s=i;switch(s.type){case"space":t+=this.renderer.space(s);break;case"hr":t+=this.renderer.hr(s);break;case"heading":t+=this.renderer.heading(s);break;case"code":t+=this.renderer.code(s);break;case"table":t+=this.renderer.table(s);break;case"blockquote":t+=this.renderer.blockquote(s);break;case"list":t+=this.renderer.list(s);break;case"checkbox":t+=this.renderer.checkbox(s);break;case"html":t+=this.renderer.html(s);break;case"def":t+=this.renderer.def(s);break;case"paragraph":t+=this.renderer.paragraph(s);break;case"text":t+=this.renderer.text(s);break;default:{let e='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return t}parseInline(e,t=this.renderer){let n="";for(let i=0;i<e.length;i++){let s=e[i];if(this.options.extensions?.renderers?.[s.type]){let e=this.options.extensions.renderers[s.type].call({parser:this},s);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){n+=e||"";continue}}let r=s;switch(r.type){case"escape":case"text":n+=t.text(r);break;case"html":n+=t.html(r);break;case"link":n+=t.link(r);break;case"image":n+=t.image(r);break;case"checkbox":n+=t.checkbox(r);break;case"strong":n+=t.strong(r);break;case"em":n+=t.em(r);break;case"codespan":n+=t.codespan(r);break;case"br":n+=t.br(r);break;case"del":n+=t.del(r);break;default:{let e='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}},gt=class{options;block;constructor(e){this.options=e||re}static passThroughHooks=/* @__PURE__ */new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=/* @__PURE__ */new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?pt.lex:pt.lexInline}provideParser(){return this.block?mt.parse:mt.parseInline}},ft=new class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=mt;Renderer=ut;TextRenderer=dt;Lexer=pt;Tokenizer=ht;Hooks=gt;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let i of e)switch(n=n.concat(t.call(this,i)),i.type){case"table":{let e=i;for(let i of e.header)n=n.concat(this.walkTokens(i.tokens,t));for(let i of e.rows)for(let e of i)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{let e=i;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=i;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(i=>{let s=e[i].flat(1/0);n=n.concat(this.walkTokens(s,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let i=e.renderer.apply(this,t);return!1===i&&(i=n.apply(this,t)),i}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new ut(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let i=n,s=e.renderer[i],r=t[i];t[i]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=r.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new ht(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let i=n,s=e.tokenizer[i],r=t[i];t[i]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=r.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new gt;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let i=n,s=e.hooks[i],r=t[i];gt.passThroughHooks.has(n)?t[i]=e=>{if(this.defaults.async&>.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await s.call(t,e);return r.call(t,n)})();let i=s.call(t,e);return r.call(t,i)}:t[i]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await s.apply(t,e);return!1===n&&(n=await r.apply(t,e)),n})();let n=s.apply(t,e);return!1===n&&(n=r.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,i=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(i.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return pt.lex(e,t??this.defaults)}parser(e,t){return mt.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},s={...this.defaults,...i},r=this.onError(!!s.silent,!!s.async);if(!0===this.defaults.async&&!1===i.async)return r(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return r(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return r(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let n=s.hooks?await s.hooks.preprocess(t):t,i=await(s.hooks?await s.hooks.provideLexer():e?pt.lex:pt.lexInline)(n,s),r=s.hooks?await s.hooks.processAllTokens(i):i;s.walkTokens&&await Promise.all(this.walkTokens(r,s.walkTokens));let o=await(s.hooks?await s.hooks.provideParser():e?mt.parse:mt.parseInline)(r,s);return s.hooks?await s.hooks.postprocess(o):o})().catch(r);try{s.hooks&&(t=s.hooks.preprocess(t));let n=(s.hooks?s.hooks.provideLexer():e?pt.lex:pt.lexInline)(t,s);s.hooks&&(n=s.hooks.processAllTokens(n)),s.walkTokens&&this.walkTokens(n,s.walkTokens);let i=(s.hooks?s.hooks.provideParser():e?mt.parse:mt.parseInline)(n,s);return s.hooks&&(i=s.hooks.postprocess(i)),i}catch(o){return r(o)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+rt(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function bt(e,t){return ft.parse(e,t)}bt.options=bt.setOptions=function(e){return ft.setOptions(e),bt.defaults=ft.defaults,oe(bt.defaults),bt},bt.getDefaults=se,bt.defaults=re,bt.use=function(...e){return ft.use(...e),bt.defaults=ft.defaults,oe(bt.defaults),bt},bt.walkTokens=function(e,t){return ft.walkTokens(e,t)},bt.parseInline=ft.parseInline,bt.Parser=mt,bt.parser=mt.parse,bt.Renderer=ut,bt.TextRenderer=dt,bt.Lexer=pt,bt.lexer=pt.lex,bt.Tokenizer=ht,bt.Hooks=gt,bt.parse=bt,bt.options,bt.setOptions,bt.use,bt.walkTokens,bt.parseInline,mt.parse,pt.lex;class xt{constructor(e,t,n,i,s,r){this.container=e,this.augment=r,this.options=t,this.onStart=n.subscribe,this.onDispose=i.subscribe,this.onRestart=s.subscribe}onStart;onRestart;onDispose;options}const wt={round:function(e,t){const n=10**t;return Math.round(e*n)/n},resizeCanvasForDPR:function(e,t,n){const i=window.devicePixelRatio??1,s=e.getContext("2d");if(!s)throw new Error("[JSONCanvasViewer] This error is unexpected, probably caused uncontrollable runtime errors. Please contact the developer and show how to reproduce.");e.width=Math.round(t*i),e.height=Math.round(n*i),s.setTransform(1,0,0,1,0,0),s.scale(i,i)},applyStyles:function(e,t){const n=document.createElement("style");n.innerHTML=t,e.appendChild(n)},drawRoundRect:function(e,t,n,i,s,r){e.beginPath(),e.moveTo(t+r,n),e.lineTo(t+i-r,n),e.quadraticCurveTo(t+i,n,t+i,n+r),e.lineTo(t+i,n+s-r),e.quadraticCurveTo(t+i,n+s,t+i-r,n+s),e.lineTo(t+r,n+s),e.quadraticCurveTo(t,n+s,t,n+s-r),e.lineTo(t,n+r),e.quadraticCurveTo(t,n,t+r,n),e.closePath()},getAnchorCoord:function(e,t){const n=e.x+e.width/2,i=e.y+e.height/2;switch(t){case"top":return{x:n,y:e.y};case"bottom":return{x:n,y:e.y+e.height};case"left":return{x:e.x,y:i};case"right":return{x:e.x+e.width,y:i};default:return{x:n,y:i}}},makeHook:function(e=!1){const t=(...n)=>{if(e){Array.from(t.subs).reverse().forEach(e=>{e(...n)})}else t.subs.forEach(e=>{e(...n)})};return t.subs=/* @__PURE__ */new Set,t.subscribe=e=>{t.subs.add(e)},t.unsubscribe=e=>{t.subs.delete(e)},t}},kt=new Error("[JSONCanvasViewer] Resource hasn't been set up or has been disposed.");class vt extends xt{onToggleFullscreen=wt.makeHook();data={canvasData:{nodes:[],edges:[]},nodeMap:{},edgeMap:{},canvasBaseDir:"./",nodeBounds:{maxX:0,maxY:0,minX:0,minY:0,width:0,height:0,centerX:0,centerY:0},offsetX:0,offsetY:0,scale:1,container:document.createElement("div")};constructor(...e){super(...e);const t=this.options.container;for(;t.firstElementChild;)t.firstElementChild.remove();t.innerHTML="";const n=this.options.noShadow??!1?t:t.attachShadow({mode:"open"});wt.applyStyles(n,".full,.overlay-container .click-layer,.overlay-container .link-iframe,.overlay-container .audio{top:0;left:0;width:100%;height:100%;position:absolute}.flex-center,.overlay-container.markdown-content{display:flex;justify-content:center;align-items:center}.border-shadow-bg{background:var(--background-secondary);border:1px solid var(--border);box-shadow:var(--shadow)}.collapse-button{border-radius:8px;transition:transform .2s,background-color .2s}.collapse-button:hover{background-color:var(--border)}button{cursor:pointer;font-size:18px;height:32px;border:none;transition:var(--containerTransition);text-align:center;width:32px;padding:5px 0}button svg{width:100%;height:100%}.container{--contentTransition: color .2s, opacity .2s, text-shadow .2s, fill .2s;--containerTransition: background .2s, opacity .2s, box-shadow .2s, border .2s, filter .2s, backdrop-filter .2s;color:var(--text);fill:var(--text);stroke:var(--text);background-color:var(--background);position:relative;width:100%;height:100%;overflow:hidden}.container.numb,.container.numb *{pointer-events:none!important}.main-canvas{width:100%;height:100%;transform-origin:top left}.overlays{position:absolute;transform-origin:top left;will-change:transform}.overlay-container{position:absolute;box-sizing:border-box;border-radius:12px;overflow:hidden;-webkit-user-select:none;user-select:none;contain:strict;content-visibility:auto;box-shadow:var(--shadow);background-color:var(--overlay-card);transition:var(--containerTransition)}.overlay-container .overlay-border{box-sizing:border-box;pointer-events:none;position:absolute;color:var(--overlay-border);top:0;left:0;width:100%;height:100%;border-width:1px;border-style:solid;border-radius:12px;transition:var(--containerTransition)}.overlay-container.active{-webkit-user-select:auto;user-select:auto;pointer-events:auto}.overlay-container.active .overlay-border{border:4px solid var(--overlay-active)}.overlay-container .link-iframe,.overlay-container .audio{border:none;background:transparent}.overlay-container .click-layer{background:transparent;pointer-events:auto}.overlay-container.active .click-layer{pointer-events:none}.overlay-container img{width:100%;height:100%;object-fit:cover;pointer-events:none}.overlay-container.active img{pointer-events:auto}.overlay-container.markdown-content{position:absolute;padding:0 7px}.overlay-container.markdown-content.rtl{direction:rtl;text-align:right}.overlay-container .parsed-content-wrapper{font-family:sans-serif;box-sizing:border-box;max-width:100%;max-height:100%;padding:10px 6px;pointer-events:none;overflow:hidden;scrollbar-gutter:stable both-edges;display:flex;flex-direction:column;gap:12px}@supports not (scrollbar-gutter: stable both-edges){.overlay-container .parsed-content-wrapper{padding:10px}}.overlay-container.active .parsed-content-wrapper{overflow:auto}::-webkit-scrollbar{width:4px}::-webkit-scrollbar-track{background-color:transparent}::-webkit-scrollbar-thumb{border-radius:2px;background:#ffffff40}::-webkit-scrollbar-thumb:hover{background:#1e1e1ebf}p{font-size:16px;line-height:21px}.parsed-content-wrapper img{width:100%;border-radius:8px}h1{font-size:25px}h2{font-size:23px}h3{font-size:22px}h4{font-size:20px}h5{font-size:19px}h6{font-size:17px}p,h1,h2,h3,h4,h5,h6,ol,ul{margin:0}h1,h2{font-weight:800}h3,h4{font-weight:700}h5,h6{font-weight:600}code{background:#ffffff1a;padding:2px 4px;border-radius:8px}pre code{display:block;box-sizing:border-box;width:100%}pre:has(code),table{margin:6px 0}strong{color:#fe8e7c}em{color:#5affb2}a{text-decoration:none;color:#6dadd0;font-weight:800;font-style:italic;cursor:pointer;transition:var(--contentTransition)}a:hover{color:#86d3fd}hr{height:1px;width:100%;background-color:#fff3;border:none}li{margin:5px 0}ul{padding-left:16px}ol{padding-left:15px;padding-right:7.5px}table{border-collapse:collapse;border-radius:8px;overflow:hidden;width:100%}table th,table td{border:1px solid rgba(255,255,255,.2);padding:6px 10px;background:#ffffff0f;text-align:left}table th{background:#ffffff1f;font-weight:700}"+this.options.extraCSS),this.data.container.classList.add("container"),n.appendChild(this.data.container),this.augment({resetView:this.resetView,shiftFullscreen:this.shiftFullscreen}),this.onStart(this.start),this.onRestart(this.start),this.onDispose(this.dispose)}start=()=>{const e=Object.assign({nodes:[],edges:[]},this.options.canvas);Object.assign(this.data,{canvasData:e,nodeMap:{},edgeMap:{},canvasBaseDir:this.processBaseDir(this.options.attachmentDir),nodeBounds:this.calculateNodeBounds(e),offsetX:0,offsetY:0,scale:1}),this.data.canvasData.nodes.forEach(e=>{const t={ref:e,box:this.getNodeBox(e)};if(this.data.nodeMap[e.id]=t,"file"===e.type){const n=e.file.split("/").pop()??"";t.fileName=n,e.file.startsWith("http://")||e.file.startsWith("https://")||(e.file=this.data.canvasBaseDir+n)}}),this.data.canvasData.edges.forEach(e=>{this.data.edgeMap[e.id]={ref:e,box:this.getEdgeBox(e)}}),this.resetView()};processBaseDir=e=>{if(!e)return"./";const t=e?.slice(-1);return"/"===t?e:`${e}/`};getNodeBox=e=>({left:e.x,top:"file"===e.type||"group"===e.type?e.y-40:e.y,right:e.width+e.x,bottom:e.y+e.height});getEdgeBox=e=>{const t=this.data.nodeMap,n=t[e.fromNode].ref,i=t[e.toNode].ref,s=wt.getAnchorCoord(n,e.fromSide),r=wt.getAnchorCoord(i,e.toSide),o=Math.min(s.x,r.x),a=Math.min(s.y,r.y),l=Math.max(s.x,r.x),c=Math.max(s.y,r.y),h=l-o,p=c-a,u=Math.min(h,p),d=0===u?1:u,m=Math.max(h,p),g=10*Math.log2(m/d);return{left:o-g,top:a-g,right:l+g,bottom:c+g}};calculateNodeBounds(e){let t=1/0,n=1/0,i=-1/0,s=-1/0;e.nodes.forEach(e=>{t=Math.min(t,e.x),n=Math.min(n,e.y),i=Math.max(i,e.x+e.width),s=Math.max(s,e.y+e.height)});const r=i-t,o=s-n;return{minX:t,minY:n,maxX:i,maxY:s,width:r,height:o,centerX:t+r/2,centerY:n+o/2}}shiftFullscreen=async e=>{document.fullscreenElement||e&&"enter"!==e?!document.fullscreenElement||e&&"exit"!==e||(await document.exitFullscreen(),this.onToggleFullscreen(!1)):(await this.data.container.requestFullscreen(),this.onToggleFullscreen(!0))};resetView=()=>{const e=this.data.nodeBounds,t=this.data.container;if(!e||!t)return;const n=e.width+200,i=e.height+200,s=t.clientWidth,r=t.clientHeight,o=s/n,a=r/i,l=Math.round(1e3*Math.min(o,a))/1e3,c={scale:l,offsetX:s/2-e.centerX*l,offsetY:r/2-e.centerY*l};this.data.offsetX=c.offsetX,this.data.offsetY=c.offsetY,this.data.scale=c.scale};middleViewer=()=>{const e=this.data.container;return{x:e.clientWidth/2,y:e.clientHeight/2,width:e.clientWidth,height:e.clientHeight}};dispose=()=>this.data.container.remove()}const yt=(e,t,n)=>e>=t&&e<=n,Ct=e=>{const t=e.trim();return t?t.endsWith("%")?Number(t.slice(0,-1))/100*255:Number(t):NaN},St=e=>{const{red:t,green:n,blue:i,alpha:s}=e;return yt(t,0,255)&&yt(n,0,255)&&yt(i,0,255)&&(void 0===s||yt(s,0,1))},Tt=e=>{const t=e.match(/^rgba?\(\s*(\d{1,3}|[\d.]+%)\s*[, ]\s*(\d{1,3}|[\d.]+%)\s*[, ]\s*(\d{1,3}|[\d.]+%)\s*(?:[,/]\s*([01]?\.?\d+%?))?\s*\)$/);if(!t)return!1;const[,n,i,s,r]=t,o=Ct(n),a=Ct(i),l=Ct(s);return!!(yt(o,0,255)&&yt(a,0,255)&&yt(l,0,255))&&(void 0===r||(e=>{if("number"==typeof e)return yt(e,0,1);if("string"==typeof e){const t=parseFloat(e);return!isNaN(t)&&(e.endsWith("%")?yt(t/100,0,1):yt(t,0,1))}return!1})(r))},Et=e=>{if("number"==typeof e){if(!yt(e,0,1))throw new Error("Alpha value must be between 0 and 1");return e}if("string"==typeof e){const t=e.trim();let n;if(n=t.endsWith("%")?Number(t.slice(0,-1))/100:Number(t),isNaN(n))throw new Error(`Invalid alpha value: "${e}"`);if(!yt(n,0,1))throw new Error("Alpha value must be between 0 and 1");return n}throw new Error("Invalid alpha value format")},Mt=e=>{if("string"!=typeof e)throw new Error("Invalid HSL color format");const t=e.match(/^hsla?\(\s*(-?[\d.]+(?:deg|rad|grad|turn)?)\s*[, ]\s*(-?[\d.]+%?)\s*[, ]\s*(-?[\d.]+%?)\s*(?:[,/]\s*(-?[\d.]+%?))?\s*\)$/i);if(!t)throw new Error("Invalid HSL color format");const[,n,i,s,r]=t,o=(e=>{const t=e.trim().toLowerCase().match(/^(-?[\d.]+)(deg|rad|grad|turn)?$/);if(!t)return NaN;const n=parseFloat(t[1]),i=t[2];if(isNaN(n))return NaN;let s;switch(i){case"rad":s=180*n/Math.PI;break;case"grad":s=n/400*360;break;case"turn":s=360*n;break;default:s=n}return(s%360+360)%360})(n),a=parseFloat(i),l=parseFloat(s);if(isNaN(o)||isNaN(a)||isNaN(l)||!yt(a,0,100)||!yt(l,0,100))throw new Error("Invalid HSL color values");return void 0!==r?{hue:o,saturation:a,lightness:l,alpha:Et(r)}:{hue:o,saturation:a,lightness:l,alpha:1}},_t=e=>{if("string"!=typeof e)throw new Error("Invalid Hex color format.");const t=e.match(/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i);if(!t)throw new Error("Invalid Hex color format.");let n=t[1];3!==n.length&&4!==n.length||(n=n.split("").map(e=>e+e).join(""));const i=parseInt(n.substring(0,2),16),s=parseInt(n.substring(2,4),16),r=parseInt(n.substring(4,6),16);let o=1;if(8===n.length){const e=parseInt(n.substring(6,8),16);o=Number((e/255).toFixed(2))}return{red:i,green:s,blue:r,alpha:o}},Rt=e=>{if(!(e=>"string"==typeof e?Tt(e):"object"==typeof e&&null!==e&&St(e))(e))throw new Error("Invalid RGB color format");const t="string"==typeof e?(e=>{if("string"!=typeof e)throw new Error("Invalid RGB color format");const t=e.match(/^rgba?\(\s*(-?[\d.]+%?)\s*[, ]\s*(-?[\d.]+%?)\s*[, ]\s*(-?[\d.]+%?)\s*(?:[,/]\s*(-?[\d.]+%?))?\s*\)$/i);if(!t)throw new Error("Invalid RGB color format");const[,n,i,s,r]=t,o=Ct(n),a=Ct(i),l=Ct(s);if(!yt(o,0,255)||!yt(a,0,255)||!yt(l,0,255))throw new Error("RGB values must be between 0 and 255");return{red:o,green:a,blue:l,alpha:void 0!==r?Et(r):1}})(e):e,{red:n,green:i,blue:s,alpha:r}=t,o=n/255,a=i/255,l=s/255,c=Math.max(o,a,l),h=Math.min(o,a,l),p=c-h;let u=0,d=0;const m=(c+h)/2;if(0!==p){switch(d=m>.5?p/(2-c-h):p/(c+h),c){case o:u=(a-l)/p+(a<l?6:0);break;case a:u=(l-o)/p+2;break;case l:u=(o-a)/p+4}u*=60}return{hue:Math.round(u),saturation:Math.round(100*d),lightness:Math.round(100*m),alpha:r}},zt=e=>{const t=(e=>{if("string"==typeof e){if(e.startsWith("#"))return"hex";if(e.startsWith("rgb"))return"rgbString";if(e.startsWith("hsl"))return"hslString"}if("object"==typeof e&&null!==e){if("red"in e&&"green"in e&&"blue"in e)return"rgb";if("hue"in e&&"saturation"in e&&"lightness"in e)return"hsl"}throw new Error("Invalid color format")})(e);if("hsl"===t)return e;if("rgb"===t)return Rt(e);if("hex"===t)return(e=>{const t=_t(e);return Rt(t)})(e);if("hslString"===t)return Mt(e);if("rgbString"===t)return Rt(e);throw new Error("Invalid color format")},At=e=>(e=>{if("object"!=typeof e||null===e)throw new Error("Invalid color format. Expected an RGB or HSL object.");if("red"in e&&"green"in e&&"blue"in e){const{red:t,green:n,blue:i,alpha:s}=e;return void 0===s||1===s?`rgb(${t}, ${n}, ${i})`:`rgba(${t}, ${n}, ${i}, ${s})`}if("hue"in e&&"saturation"in e&&"lightness"in e){const{hue:t,saturation:n,lightness:i,alpha:s}=e;return void 0===s||1===s?`hsl(${t}, ${n}%, ${i}%)`:`hsla(${t}, ${n}%, ${i}%, ${s})`}throw new Error("Invalid color format. Expected an RGB or HSL object.")})(zt(e)),Dt={light:{0:{hue:0,saturation:0,lightness:72},1:{hue:358,saturation:81,lightness:55},2:{hue:19,saturation:87,lightness:58},3:{hue:41,saturation:79,lightness:52},4:{hue:150,saturation:100,lightness:37},5:{hue:221,saturation:100,lightness:59},6:{hue:257,saturation:81,lightness:62}},dark:{0:{hue:0,saturation:0,lightness:40},1:{hue:358,saturation:100,lightness:65},2:{hue:23,saturation:86,lightness:63},3:{hue:39,saturation:91,lightness:70},4:{hue:153,saturation:80,lightness:45},5:{hue:217,saturation:100,lightness:62},6:{hue:259,saturation:100,lightness:75}}},It={light:{dots:"hsla(0, 0%, 72%, 0.4)",text:"rgb(30, 30, 30)",background:"rgb(250, 250, 250)","background-secondary":"rgb(255, 255, 255)",shadow:"0px 0px 8px rgb(0, 0, 0, 0.1)",border:"hsla(0, 0%, 82%, 0.7)"},dark:{dots:"hsla(0, 0%, 40%, 0.3)",text:"rgb(242, 242, 242)",background:"rgb(30, 30, 30)","background-secondary":"rgb(37, 37, 40)",shadow:"0px 0px 8px rgb(0, 0, 0, 0.2)",border:"hsla(0, 0%, 30%, 0.7)"}};class Nt extends xt{theme="light";onChangeTheme=wt.makeHook();colorCache={dark:{},light:{}};constructor(...e){super(...e),this.changeTheme(this.options.theme??"light"),this.augment({changeTheme:this.changeTheme})}hslProcessor=e=>{const{hue:t,saturation:n,lightness:i}=e;let s;return s="dark"===this.theme?{active:e,card:{hue:t,saturation:n/3,lightness:i/3},border:{...e,alpha:.7},background:{...e,alpha:.1},text:e.lightness>=70?"rgb(30, 30, 30)":"rgb(242, 242, 242)"}:{active:e,card:0===t?{hue:t,saturation:n,lightness:100}:{hue:t,saturation:.4*n,lightness:90},border:{...e,alpha:.7},background:{...e,alpha:.1},text:e.lightness>=70?"rgb(30, 30, 30)":"rgb(242, 242, 242)"},{active:At(s.active),card:At(s.card),border:At(s.border),background:At(s.background),text:s.text}};getColor=(e="0")=>{const t=this.theme;let n;return this.colorCache[t][e]?this.colorCache[t][e]:(n=e in Dt[t]?this.hslProcessor(Dt[t][e]):this.hslProcessor(Rt(_t(e))),this.colorCache[t][e]=n,n)};getNamedColor=e=>It[this.theme][e];changeTheme=e=>{this.theme=e||("dark"===this.theme?"light":"dark");const t=this.container.get(vt).data.container;Object.entries(It[this.theme]).forEach(([e,n])=>{t.style.setProperty(`--${e}`,n)}),this.onChangeTheme(this.theme)}}class Lt extends xt{animationId=null;resizeAnimationId=null;DM;SM;resizeObserver;perFrame={lastScale:1,lastOffsets:{x:0,y:0}};lastResizeCenter={x:null,y:null};hooks={onResize:wt.makeHook(),onRefresh:wt.makeHook()};constructor(...e){super(...e),this.DM=this.container.get(vt),this.SM=this.container.get(Nt),this.resizeObserver=new ResizeObserver(this.onResize),this.SM.onChangeTheme.subscribe(this.refresh),this.augment({refresh:this.refresh}),this.onStart(this.start),this.onRestart(this.refresh),this.onDispose(this.dispose)}start=()=>{this.resizeObserver.observe(this.DM.data.container),this.animationId=requestAnimationFrame(this.draw)};draw=()=>{this.perFrame.lastScale===this.DM.data.scale&&this.perFrame.lastOffsets.x===this.DM.data.offsetX&&this.perFrame.lastOffsets.y===this.DM.data.offsetY||this.refresh(),this.animationId=requestAnimationFrame(this.draw)};refresh=()=>{this.perFrame={lastScale:this.DM.data.scale,lastOffsets:{x:this.DM.data.offsetX,y:this.DM.data.offsetY}},this.hooks.onRefresh()};onResize=()=>{this.resizeAnimationId=requestAnimationFrame(()=>{const e=this.DM.middleViewer();this.lastResizeCenter.x&&this.lastResizeCenter.y&&(this.DM.data.offsetX=this.DM.data.offsetX+e.x-this.lastResizeCenter.x,this.DM.data.offsetY=this.DM.data.offsetY+e.y-this.lastResizeCenter.y),this.lastResizeCenter.x=e.x,this.lastResizeCenter.y=e.y,this.hooks.onResize(e.width,e.height),this.refresh()})};dispose=()=>{this.animationId&&cancelAnimationFrame(this.animationId),this.resizeAnimationId&&cancelAnimationFrame(this.resizeAnimationId),this.resizeObserver.disconnect()}}class Ot extends xt{_overlaysLayer=document.createElement("div");overlays={};selectedId=null;eventListeners={};DM;SM;parse;get overlaysLayer(){if(!this._overlaysLayer)throw kt;return this._overlaysLayer}hooks={onInteractionStart:wt.makeHook(),onInteractionEnd:wt.makeHook()};constructor(...e){super(...e),this.parse=this.options.markdownParser||(e=>e),this.DM=this.container.get(vt),this.SM=this.container.get(Nt);this.container.get(Lt).hooks.onRefresh.subscribe(this.updateOverlays),this.SM.onChangeTheme.subscribe(this.themeChanged),this._overlaysLayer=document.createElement("div"),this._overlaysLayer.className="overlays",this._overlaysLayer.id="overlays",this.DM.data.container.appendChild(this.overlaysLayer),this.onStart(this.start),this.onRestart(this.restart),this.onDispose(this.dispose)}start=()=>{this.container.get(Zt).onClick.subscribe(this.select),this.renderOverlays()};restart=()=>{this.clearOverlays(),this.renderOverlays()};renderOverlays=()=>{const e=async e=>{switch(e.type){case"text":await this.createOverlay(e,e.text,"text");break;case"file":e.file.match(/\.md$/i)?await this.loadMarkdownForNode(e):e.file.match(/\.(png|jpg|jpeg|gif|svg|webp)$/i)?await this.createOverlay(e,e.file,"image"):e.file.match(/\.(mp3|wav)$/i)&&await this.createOverlay(e,e.file,"audio");break;case"link":await this.createOverlay(e,e.url,"link")}};Object.values(this.DM.data.nodeMap).forEach(async t=>{await e(t.ref)})};themeChanged=()=>{Object.values(this.overlays).forEach(e=>{const t=this.DM.data.nodeMap[e.id].ref,n=this.SM.getColor(t.color);this.setOverlayColor(e,n)})};select=e=>{const t=this.selectedId?this.overlays[this.selectedId]:null,n=e?this.overlays[e]:null;t&&t.classList.remove("active"),n?(n.classList.add("active"),this.hooks.onInteractionStart()):this.hooks.onInteractionEnd(),this.selectedId=e};loadMarkdownForNode=async e=>{let t;await this.createOverlay(e,"Loading...","text");try{const n=await fetch(e.file),i=await n.text(),s=i.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);t=s?await this.parse(s[2]):await this.parse(i)}catch(n){console.error("[JSONCanvasViewer] Failed to load markdown:",n),t="Failed to load content."}this.updateOverlay(e,{content:t})};updateOverlays=()=>{const e=this.DM.data;this.overlaysLayer.style.transform=`translate(${e.offsetX}px, ${e.offsetY}px) scale(${e.scale})`};async createOverlay(e,t,n){let i=this.overlays[e.id];i||(i=await this.constructOverlay(e,t,n),this.overlaysLayer.appendChild(i),this.overlays[e.id]=i,i.style.left=`${e.x}px`,i.style.top=`${e.y}px`,i.style.width=`${e.width}px`,i.style.height=`${e.height}px`)}updateOverlay(e,t){const n=this.overlays[e.id];if(t.content){const e=n.getElementsByClassName("parsed-content-wrapper")[0];e&&(e.innerHTML=t.content)}t.color&&this.setOverlayColor(n,t.color)}async constructOverlay(e,t,n){const i=document.createElement("div");switch(i.classList.add("overlay-container"),i.id=e.id,this.setOverlayColor(i,this.SM.getColor(e.color)),n){case"text":{i.classList.add("markdown-content");const e=document.createElement("div");e.innerHTML=await this.parse(t||""),e.classList.add("parsed-content-wrapper"),i.appendChild(e);break}case"link":{const e=document.createElement("iframe");e.src=t,e.sandbox="allow-scripts allow-same-origin",e.className="link-iframe",e.loading="lazy",i.appendChild(e);break}case"audio":{const e=document.createElement("audio");e.className="audio",e.src=t,e.controls=!0,i.appendChild(e);break}case"image":{const e=document.createElement("img");e.src=t,e.loading="lazy",i.appendChild(e)}}switch(n){case"link":case"audio":{const e=document.createElement("div");e.className="click-layer",i.appendChild(e)}}const s=document.createElement("div");s.className="overlay-border",i.appendChild(s);const r=()=>{e.id===this.selectedId&&this.hooks.onInteractionStart()},o=()=>{e.id===this.selectedId&&this.hooks.onInteractionEnd()};return i.addEventListener("pointerenter",r),i.addEventListener("pointerleave",o),i.addEventListener("touchstart",r),i.addEventListener("touchend",o),this.eventListeners[e.id]=[r,o],i}setOverlayColor=(e,t)=>{Object.entries(t).forEach(([t,n])=>{e.style.setProperty(`--overlay-${t}`,n)})};clearOverlays=()=>{Object.entries(this.overlays).forEach(([e,t])=>{if(this.eventListeners[e]){const n=this.eventListeners[e][0],i=this.eventListeners[e][1];if(!n||!i)throw kt;t.removeEventListener("pointerenter",n),t.removeEventListener("pointerleave",i),t.removeEventListener("touchstart",n),t.removeEventListener("touchend",i),this.eventListeners[e][0]=null,this.eventListeners[e][1]=null}t.remove(),delete this.overlays[e]})};dispose=()=>{this.clearOverlays(),this.overlaysLayer.remove(),this._overlaysLayer=null}}class Pt{constructor(e,t,n,i,s){this.window=t,this.pointers=n,this.element=i,this.getNthPointer=e.getNthPointer,this.toTargetCoords=e.toTargetCoords,this.augment=e.augment,this.dispatch=e.dispatch,this.options=s}getNthPointer;toTargetCoords;augment;dispatch;options;onPointerDown;onPointerUp;onPointerMove;onWheel;onStart;onStop;dispose;modifiers}function Bt(e,t=0){return e[e.length-1-t]}function $t(e){return Array.isArray(e)?e:[e]}class Ft extends Pt{#e=-1/0;#t=0;onPointerDown=(e,t,n)=>{2===n.size&&(this.getNthPointer(0).interrupted=!0,t.interrupted=!0)};onPointerUp=(e,t)=>{if(t.interrupted)return;const n=this.options.moveThreshold??5;if(Math.abs(t.records[0].x-e.clientX)>=n||Math.abs(t.records[0].y-e.clientY)>=n)return;const i=Bt(t.records).timestamp,s=this.options.clickPreserveTime??400;i-this.#e<=s?this.#t++:this.#t=1,this.#e=i;const r=this.toTargetCoords({x:e.clientX,y:e.clientY});this.dispatch("trueClick",{...r,target:t.target,streak:this.#t})}}class Ht extends Pt{onPointerMove=(e,t,n)=>{const i=Bt(t.records,1);if(1===n.size){const t=e.clientX-i.x,n=e.clientY-i.y;this.dispatch("drag",{deltaX:t,deltaY:n,x:e.clientX,y:e.clientY})}}}class Yt extends Pt{#n={lastDistance:0,lastMidpoint:{x:0,y:0}};#i(){const e=Bt(this.getNthPointer(0).records),t=Bt(this.getNthPointer(1).records),n=e.x-t.x,i=e.y-t.y;return Math.sqrt(n*n+i*i)}#s(){const e=Bt(this.getNthPointer(0).records),t=Bt(this.getNthPointer(1).records);return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}onPointerDown=(e,t,n)=>{2===n.size&&(this.#n.lastDistance=this.#i(),this.#n.lastMidpoint=this.toTargetCoords(this.#s()))};onPointerMove=(e,t,n)=>{if(2===n.size){const e=this.#i(),t=this.#s(),n=e/this.#n.lastDistance;this.#n.lastDistance=e;const i=this.toTargetCoords(t),s=i.x-this.#n.lastMidpoint.x,r=i.y-this.#n.lastMidpoint.y;this.#n.lastMidpoint=i,this.#r({deltaX:s,deltaY:r}),this.#o(n,i)}};#o(e,t){this.dispatch("zoom",{x:t.x,y:t.y,factor:e})}#r(e){this.dispatch("pan",e)}}class Xt extends Pt{onWheel=e=>e.preventDefault();#a=e=>e.preventDefault();onStart=()=>{this.element.style.touchAction="none",this.element.addEventListener("gesturestart",this.#a,{passive:!1}),this.element.addEventListener("gesturechange",this.#a,{passive:!1})};onStop=()=>{this.element.style.touchAction="",this.element.removeEventListener("gesturestart",this.#a),this.element.removeEventListener("gesturechange",this.#a)};dispose=this.onStop}class jt extends Pt{constructor(...e){super(...e),function(e,t){for(const[n,i]of Object.entries({proControlSchema:!1,zoomFactor:.1,lockControlSchema:!1}))n in t||(t[n]=i)}(0,this.options)}onWheel=e=>{const t=this.options;if(t.proControlSchema||t.lockControlSchema||!(e.ctrlKey||e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))||(t.proControlSchema=!0),t.proControlSchema)if(e.ctrlKey){const n=1-t.zoomFactor*e.deltaY,i=this.toTargetCoords({x:e.clientX,y:e.clientY});this.#o(n,i)}else e.shiftKey&&Math.abs(e.deltaX)<=Math.abs(e.deltaY)?this.#r({deltaX:-e.deltaY,deltaY:-e.deltaX}):this.#r({deltaX:-e.deltaX,deltaY:-e.deltaY});else{const n=1-t.zoomFactor/20*e.deltaY,i=this.toTargetCoords({x:e.clientX,y:e.clientY});this.#o(n,i)}};#o(e,t){this.dispatch("zoom",{x:t.x,y:t.y,factor:e})}#r(e){this.dispatch("pan",e)}}class Ut extends Pt{#l={};#c=null;constructor(...e){super(...e);const t=this.options.lubricator;t&&Object.entries(t).forEach(([e,t])=>{const n={sample:{},fields:{}};Object.keys(t.fields).forEach(e=>{n.fields[e]={catch:1,release:1}}),this.#l[e]=n,this.modifiers[e]=this.#h(n,t)})}onStart=()=>{this.#c=requestAnimationFrame(this.#p)};onStop=()=>{this.#c&&cancelAnimationFrame(this.#c),this.#c=null,Object.values(this.#l).forEach(e=>{Object.values(e.fields).forEach(e=>{e.release=1,e.catch=1})})};#h=(e,t)=>n=>!!n.lubricated||(e.sample=n,this.#u(e.fields,t.fields,n),!1);#u=(e,t,n)=>{Object.entries(e).forEach(([e,i])=>{if("number"!=typeof n[e])return;const s=t[e].countType;"sum"===s?i.catch+=n[e]:"product"===s&&(i.catch*=n[e])})};#p=()=>{const e=this.#l,t=this.options.lubricator;t&&(Object.entries(e).forEach(([e,n])=>{const i=n.sample;i.lubricated=!0;let s=!1;for(const[r,o]of Object.entries(n.fields)){if(1===o.catch)continue;const n=t[e].fields[r].countType;let a,l,c;"sum"===n?(l=o.catch-o.release,a=Math.abs(l)):(l=o.catch/o.release,a=this.#d(l)-1),a<=t[e].fields[r].diminishBoundary?(s||(s=!0),i[r]=l,o.release=1,o.catch=1):("sum"===n?(c=l*t[e].decayFactor,o.release+=c):(c=Math.pow(l,t[e].decayFactor),o.release*=c),i[r]=c,s=!0)}s&&this.dispatch(e,i)}),this.#c=requestAnimationFrame(this.#p))};#d=e=>e>1?e:1/e;modifiers={}}const qt={decayFactor:.25,fields:{deltaX:{countType:"sum",diminishBoundary:.5},deltaY:{countType:"sum",diminishBoundary:.5}}},Wt=qt,Vt={decayFactor:.25,fields:{factor:{countType:"product",diminishBoundary:.01}}};class Gt{#m;#g=/* @__PURE__ */new Map;#f={};#b={};#x;#w={};options;get#k(){if(!this.#x)throw new Error("[Pointeract] Window is not defined.");return this.#x}constructor(e,t){const n=$t(t||[]);this.#x=e.element.ownerDocument.defaultView,this.#m=e.element,e.coordinateOutput||(e.coordinateOutput="relative"),this.options=e,n.forEach(t=>{const n=new t(this.moduleUtils,this.#k,this.#g,this.#m,this.options);Object.assign(n,{options:e}),this.#f[t.name]=n})}on=(e,t)=>(this.#w[e]||(this.#w[e]=/* @__PURE__ */new Set),this.#w[e]?.add(t),this);off(e,t){return this.#w[e]?.delete(t),this}moduleUtils={getNthPointer:e=>{const t=new Error("[Pointeract] Invalid pointer index.");if(e<0||e>=this.#g.size)throw t;let n=0;for(const i of this.#g.values()){if(n===e)return i;n++}throw t},toTargetCoords:e=>{if("absolute"===this.options.coordinateOutput)return e;const t=this.#m.getBoundingClientRect();return e.x-=t.left,e.y-=t.top,"relative"===this.options.coordinateOutput||(e.x/=t.width,e.y/=t.height),e},dispatch:(...e)=>{const t=e[0],n=e[1];let i,s=!0;for(const r of Object.values(this.#f))if(r.modifiers&&t in r.modifiers&&(s=void 0===n?r.modifiers[t]():r.modifiers[t](n),!1===s))return;i=!0===s?n:s,this.#w[t]?.forEach(e=>e(i))},augment:e=>{Object.entries(e).forEach(([e,t])=>this[e]=t)}};dispatch=this.moduleUtils.dispatch;#v(e,...t){Object.values(this.#f).forEach(n=>{const i=n[e];i&&i(...t)})}#y=e=>{if(this.#g.size>=2)return;e.isPrimary&&this.#g.clear();const t={records:[{x:e.clientX,y:e.clientY,timestamp:Date.now()}],target:e.target};this.#g.set(e.pointerId,t),this.#v("onPointerDown",e,t,this.#g)};#C=e=>{const t=this.#g.get(e.pointerId);t&&(t.records.push({x:e.clientX,y:e.clientY,timestamp:Date.now()}),this.#v("onPointerMove",e,t,this.#g))};#S=e=>{const t=this.#g.get(e.pointerId);t&&(this.#g.delete(e.pointerId),this.#v("onPointerUp",e,t,this.#g))};#T=e=>this.#v("onWheel",e);stop=e=>{const t=e=>{if(!(e.name in this.#f))return;const t=this.#f[e.name];t.onStop&&t.onStop(),this.#b[e.name]=t,delete this.#f[e.name]};return e?$t(e).forEach(e=>{t(e)}):(()=>{this.#m.removeEventListener("pointerdown",this.#y),this.#k.removeEventListener("pointermove",this.#C),this.#k.removeEventListener("pointerup",this.#S),this.#m.removeEventListener("wheel",this.#T),this.#v("onStop")})(),this};start=e=>{const t=e=>{if(!(e.name in this.#b))return;const t=this.#b[e.name];t.onStart&&t.onStart(),this.#f[e.name]=t,delete this.#b[e.name]};return e?$t(e).forEach(e=>{t(e)}):(()=>{this.#m.addEventListener("pointerdown",this.#y),this.#k.addEventListener("pointermove",this.#C),this.#k.addEventListener("pointerup",this.#S),this.#m.addEventListener("wheel",this.#T,{passive:!1}),this.#v("onStart")})(),this};dispose=()=>{this.stop(),this.#x=null,this.#v("dispose"),this.#w={}}}class Zt extends xt{pointeract;DM;onClick=wt.makeHook();constructor(...e){super(...e),this.DM=this.container.get(vt);const t=Object.assign(this.options.pointeract??{},{coordinateOutput:"relative",element:this.DM.data.container,lubricator:{pan:qt,zoom:Vt,drag:Wt}});this.pointeract=new Gt(t,[Ft,Ht,jt,Xt,Yt,Ut]);const n=this.container.get(Ot);n.hooks.onInteractionStart.subscribe(this.pointeract.stop),n.hooks.onInteractionEnd.subscribe(this.pointeract.start),this.augment({pan:this.pan,panToCoords:this.panToCoords,zoom:this.zoom,zoomToScale:this.zoomToScale}),this.onStart(this.start),this.onDispose(this.dispose)}start=()=>{this.pointeract.on("pan",this.onPan).on("drag",this.onPan).on("zoom",this.onZoom).on("trueClick",this.onTrueClick).start()};onPan=e=>{this.truePan({x:e.deltaX,y:e.deltaY})};onZoom=e=>{this.trueZoom(e.factor,e)};trueZoom=(e,t)=>{const n=Math.max(Math.min(this.DM.data.scale*e,20),.05);if(n===this.DM.data.scale)return;const i=n/this.DM.data.scale,s=this.C2C(t);this.DM.data.offsetX=t.x-s.x*i,this.DM.data.offsetY=t.y-s.y*i,this.DM.data.scale=n};truePan=({x:e,y:t})=>{this.DM.data.offsetX=this.DM.data.offsetX+e,this.DM.data.offsetY=this.DM.data.offsetY+t};zoom=(e,t)=>{this.pointeract.dispatch("zoom",{factor:e,...t})};pan=({x:e,y:t})=>{this.pointeract.dispatch("pan",{deltaX:e,deltaY:t})};zoomToScale=(e,t)=>{const n=e/this.DM.data.scale;this.pointeract.dispatch("zoom",{factor:n,...t})};panToCoords=({x:e,y:t})=>{this.pointeract.dispatch("pan",{deltaX:e-this.DM.data.offsetX,deltaY:t-this.DM.data.offsetY})};C2C=({x:e,y:t})=>({x:e-this.DM.data.offsetX,y:t-this.DM.data.offsetY});onTrueClick=e=>{const t=e.target;if(this.isUIControl(t))return;const n=this.findNodeId(t);this.onClick(n)};isUIControl=e=>!!e&&(e.closest(".controls")||e.closest("button")||e.closest("input"));findNodeId=e=>{if(!e)return null;let t=e;for(;(!t.id||""===t.id)&&t.parentElement;)t=t.parentElement;return"overlays"!==t.id&&t.id&&""!==t.id?t.id:null};dispose=()=>this.pointeract.dispose()}const Qt='<svg viewBox="-5.28 -5.28 34.56 34.56" fill="none"><path d="M4 9V5.6c0-.56 0-.84.109-1.054a1 1 0 0 1 .437-.437C4.76 4 5.04 4 5.6 4H9M4 15v3.4c0 .56 0 .84.109 1.054a1 1 0 0 0 .437.437C4.76 20 5.04 20 5.6 20H9m6-16h3.4c.56 0 .84 0 1.054.109a1 1 0 0 1 .437.437C20 4.76 20 5.04 20 5.6V9m0 6v3.4c0 .56 0 .84-.109 1.054a1 1 0 0 1-.437.437C19.24 20 18.96 20 18.4 20H15" stroke-width="2.4" stroke-linecap="round"/></svg>';class Kt extends xt{_controlsPanel=null;_toggleCollapseBtn=null;_toggleFullscreenBtn=null;_zoomOutBtn=null;_zoomSlider=null;_zoomInBtn=null;_resetViewBtn=null;DM;IH;collapsed;get controlsPanel(){if(null===this._controlsPanel)throw kt;return this._controlsPanel}get toggleCollapseBtn(){if(null===this._toggleCollapseBtn)throw kt;return this._toggleCollapseBtn}get toggleFullscreenBtn(){if(null===this._toggleFullscreenBtn)throw kt;return this._toggleFullscreenBtn}get zoomOutBtn(){if(null===this._zoomOutBtn)throw kt;return this._zoomOutBtn}get zoomSlider(){if(null===this._zoomSlider)throw kt;return this._zoomSlider}get zoomInBtn(){if(null===this._zoomInBtn)throw kt;return this._zoomInBtn}get resetViewBtn(){if(null===this._resetViewBtn)throw kt;return this._resetViewBtn}constructor(...e){super(...e),this.collapsed=this.options.controlsCollapsed??!1,this.DM=this.container.get(vt),this.IH=this.container.get(Zt),this.DM.onToggleFullscreen.subscribe(this.updateFullscreenBtn),this.container.get(Lt).hooks.onRefresh.subscribe(this.updateSlider),this._controlsPanel=document.createElement("div"),this._controlsPanel.className="controls",this._controlsPanel.classList.toggle("collapsed",this.collapsed),wt.applyStyles(this._controlsPanel,".controls{position:absolute;top:10px;right:10px;display:flex;align-items:center;transition:transform .2s;border-radius:8px;gap:10px}.controls.collapsed{transform:translate(calc(100% - 32px))}.controls.collapsed .collapse-button{transform:rotate(180deg)}.controls .controls-content{display:flex;gap:1px;align-items:center;border-radius:8px;overflow:hidden;background:var(--border);box-shadow:var(--shadow);outline:1px solid var(--border)}.controls button{background-color:var(--background-secondary)}.controls button:hover{background:var(--border)}.zoom-slider{width:100px;margin:0 10px}"),this._toggleCollapseBtn=document.createElement("button"),this._toggleCollapseBtn.className="collapse-button border-shadow-bg",this._toggleCollapseBtn.innerHTML='<svg viewBox="-3.6 -3.6 31.2 31.2" stroke-width=".4"><path d="M15.707 4.293a1 1 0 0 1 0 1.414L9.414 12l6.293 6.293a1 1 0 0 1-1.414 1.414l-7-7a1 1 0 0 1 0-1.414l7-7a1 1 0 0 1 1.414 0Z" /></svg>',this._controlsPanel.appendChild(this._toggleCollapseBtn);const t=document.createElement("div");t.className="controls-content",this._toggleFullscreenBtn=document.createElement("button"),this._toggleFullscreenBtn.innerHTML=Qt,t.appendChild(this._toggleFullscreenBtn),this._zoomOutBtn=document.createElement("button"),this._zoomOutBtn.innerHTML='<svg viewBox="-1.2 -1.2 26.4 26.4"><path d="M6 12h12" stroke-width="2" stroke-linecap="round" /></svg>',t.appendChild(this._zoomOutBtn),this._zoomSlider=document.createElement("input"),this._zoomSlider.type="range",this._zoomSlider.className="zoom-slider",this._zoomSlider.min="-30",this._zoomSlider.max="30",this._zoomSlider.value="0",t.appendChild(this._zoomSlider),this._zoomInBtn=document.createElement("button"),this._zoomInBtn.innerHTML='<svg viewBox="-1.2 -1.2 26.4 26.4"><path d="M6 12h12m-6-6v12" stroke-width="2" stroke-linecap="round" /></svg>',t.appendChild(this._zoomInBtn),this._resetViewBtn=document.createElement("button"),this._resetViewBtn.innerHTML='<svg viewBox="-6 -6 30 30" stroke-width=".08"><path d="m14.955 7.986.116.01a1 1 0 0 1 .85 1.13 8 8 0 0 1-13.374 4.728l-.84.84c-.63.63-1.707.184-1.707-.707V10h3.987c.89 0 1.337 1.077.707 1.707l-.731.731a6 6 0 0 0 8.347-.264 6 6 0 0 0 1.63-3.33 1 1 0 0 1 1.131-.848zM11.514.813a8 8 0 0 1 1.942 1.336l.837-.837c.63-.63 1.707-.184 1.707.707V6h-3.981c-.89 0-1.337-1.077-.707-1.707l.728-.729a6 6 0 0 0-9.98 3.591 1 1 0 1 1-1.98-.281A8 8 0 0 1 11.514.813Z" /></svg>',t.appendChild(this._resetViewBtn),this._controlsPanel.appendChild(t),this.DM.data.container.appendChild(this._controlsPanel),this._toggleCollapseBtn.addEventListener("click",this.toggleCollapse),this._zoomInBtn.addEventListener("click",this.zoomIn),this._zoomOutBtn.addEventListener("click",this.zoomOut),this._zoomSlider.addEventListener("input",this.slide),this._resetViewBtn.addEventListener("click",this.DM.resetView),this._toggleFullscreenBtn.addEventListener("click",this.toggleFullscreen),this.augment({toggleControlsCollapse:this.toggleCollapse}),this.onDispose(this.dispose)}toggleCollapse=()=>{this.collapsed=!this.collapsed,this.controlsPanel.classList.toggle("collapsed",this.collapsed),this.collapsed||this.updateSlider()};zoomIn=()=>this.IH.zoom(1.3,this.DM.middleViewer());zoomOut=()=>this.IH.zoom(1/1.3,this.DM.middleViewer());slide=()=>this.IH.trueZoom(1.1**Number(this.zoomSlider.value)/this.DM.data.scale,this.DM.middleViewer());updateFullscreenBtn=e=>{this.toggleFullscreenBtn.innerHTML=e?'<svg viewBox="-40.32 -40.32 176.64 176.64"><path d="M30 60H6a6 6 0 0 0 0 12h18v18a6 6 0 0 0 12 0V66a5.997 5.997 0 0 0-6-6Zm60 0H66a5.997 5.997 0 0 0-6 6v24a6 6 0 0 0 12 0V72h18a6 6 0 0 0 0-12ZM66 36h24a6 6 0 0 0 0-12H72V6a6 6 0 0 0-12 0v24a5.997 5.997 0 0 0 6 6ZM30 0a5.997 5.997 0 0 0-6 6v18H6a6 6 0 0 0 0 12h24a5.997 5.997 0 0 0 6-6V6a5.997 5.997 0 0 0-6-6Z"/></svg>':Qt};toggleFullscreen=()=>this.DM.shiftFullscreen();updateSlider=()=>{this.collapsed||(this.zoomSlider.value=String(this.scaleToSlider(this.DM.data.scale)))};scaleToSlider=e=>Math.log(e)/Math.log(1.1);dispose=()=>{this.toggleCollapseBtn.removeEventListener("click",this.toggleCollapse),this.zoomInBtn.removeEventListener("click",this.zoomIn),this.zoomOutBtn.removeEventListener("click",this.zoomOut),this.zoomSlider.removeEventListener("input",this.slide),this.resetViewBtn.removeEventListener("click",this.DM.resetView),this.toggleFullscreenBtn.removeEventListener("click",this.toggleFullscreen),this.controlsPanel.remove(),this._controlsPanel=null,this._toggleCollapseBtn=null,this._zoomInBtn=null,this._zoomOutBtn=null,this._zoomSlider=null,this._resetViewBtn=null,this._toggleFullscreenBtn=null}}class Jt extends xt{_debugPanel=null;DM;get debugPanel(){if(!this._debugPanel)throw kt;return this._debugPanel}constructor(...e){super(...e),this.DM=this.container.get(vt),this.container.get(Lt).hooks.onRefresh.subscribe(this.update),this._debugPanel=document.createElement("div"),this._debugPanel.className="debug-panel border-shadow-bg";const t=this.DM.data.container;wt.applyStyles(t,".debug-panel{position:absolute;bottom:12px;left:12px;border-radius:12px;padding:12px;color:var(--text);font-size:calc(14px + .3vw);line-height:calc(17px + .3vw);pointer-events:none}"),t.appendChild(this._debugPanel),this.onDispose(this.dispose)}update=()=>{const e=wt.round,t=this.DM.data;this.debugPanel.innerHTML=`<p>Scale: ${e(t.scale,3)}</p><p>Offset: ${e(t.offsetX,1)}, ${e(t.offsetY,1)}</p>`};dispose=()=>{this.debugPanel.remove(),this._debugPanel=null}}class en extends xt{_minimapCtx=null;_viewportRectangle=null;_minimap=null;_minimapContainer=null;_toggleMinimapBtn=null;minimapCache={scale:1,centerX:0,centerY:0};DM;SM;collapsed;get minimap(){if(null===this._minimap)throw kt;return this._minimap}get minimapCtx(){if(null===this._minimapCtx)throw kt;return this._minimapCtx}get viewportRectangle(){if(null===this._viewportRectangle)throw kt;return this._viewportRectangle}get minimapContainer(){if(null===this._minimapContainer)throw kt;return this._minimapContainer}get toggleMinimapBtn(){if(null===this._toggleMinimapBtn)throw kt;return this._toggleMinimapBtn}constructor(...e){super(...e),this.collapsed=this.options.minimapCollapsed??!1,this.container.get(Lt).hooks.onRefresh.subscribe(this.updateViewportRectangle),this.DM=this.container.get(vt),this.SM=this.container.get(Nt),this._minimapContainer=document.createElement("div"),this._minimapContainer.className="minimap-container",wt.applyStyles(this._minimapContainer,".minimap-container{position:absolute;bottom:10px;right:10px;display:flex;pointer-events:none;transition:transform .2s}.minimap-container.collapsed{transform:translate(calc(100% - 32px))}.toggle-minimap{margin:auto 10px 0 0;pointer-events:auto}.collapsed .toggle-minimap{transform:rotate(180deg)}.minimap{position:relative;pointer-events:none;width:200px;height:150px;overflow:hidden;border-radius:12px;transform-origin:0 0}.minimap .minimap-canvas{width:100%;height:100%}.minimap .viewport-rectangle{position:absolute;top:0;left:0;pointer-events:none;border-radius:6px;box-sizing:border-box;border:2px dashed var(--text)}@container (max-width: 768px){.container .minimap{transform:scale(.6)}.container .toggle-minimap{transform:translateY(-60px)}.collapsed .container .toggle-minimap{transform:translateY(-60px) rotate(180deg)}.container .minimap-container{transform:translateY(60px) translate(80px)}.container .minimap-container.collapsed{transform:translateY(60px) translate(calc(100% - 32px))}}"),this._toggleMinimapBtn=document.createElement("button"),this._toggleMinimapBtn.className="toggle-minimap collapse-button border-shadow-bg",this._toggleMinimapBtn.innerHTML='<svg viewBox="-3.6 -3.6 31.2 31.2" stroke-width=".4"><path d="M15.707 4.293a1 1 0 0 1 0 1.414L9.414 12l6.293 6.293a1 1 0 0 1-1.414 1.414l-7-7a1 1 0 0 1 0-1.414l7-7a1 1 0 0 1 1.414 0Z" /></svg>',this._minimapContainer.appendChild(this._toggleMinimapBtn),this._minimap=document.createElement("div"),this._minimap.className="minimap border-shadow-bg";const t=document.createElement("canvas");t.className="minimap-canvas",t.width=200,t.height=150,this._minimap.appendChild(t),this._minimapCtx=t.getContext("2d"),this._viewportRectangle=document.createElement("div"),this._viewportRectangle.className="viewport-rectangle",this._minimap.appendChild(this._viewportRectangle),this._minimapContainer.appendChild(this._minimap),this.DM.data.container.appendChild(this._minimapContainer),this._minimapContainer.classList.toggle("collapsed",this.collapsed),this._toggleMinimapBtn.addEventListener("click",this.toggleCollapse),wt.resizeCanvasForDPR(t,t.width,t.height),this.augment({toggleMinimapCollapse:this.toggleCollapse}),this.onStart(this.start),this.onRestart(this.start),this.onDispose(this.dispose)}toggleCollapse=()=>{this.collapsed=!this.collapsed,this.minimapContainer.classList.toggle("collapsed",this.collapsed),this.collapsed||this.updateViewportRectangle()};start=()=>{const e=this.DM.data.nodeBounds;if(!e)return;const t=this.minimap.clientWidth,n=this.minimap.clientHeight,i=t/e.width,s=n/e.height;this.minimapCache.scale=.9*Math.min(i,s),this.minimapCache.centerX=t/2,this.minimapCache.centerY=n/2,this.minimapCtx.clearRect(0,0,t,n),this.minimapCtx.save(),this.minimapCtx.translate(this.minimapCache.centerX,this.minimapCache.centerY),this.minimapCtx.scale(this.minimapCache.scale,this.minimapCache.scale),this.minimapCtx.translate(-e.centerX,-e.centerY);const r=this.DM.data.canvasData;for(const o of r.edges)this.drawMinimapEdge(o);for(const o of r.nodes)this.drawMinimapNode(o);this.minimapCtx.restore()};drawMinimapNode=e=>{const t=this.SM.getColor(e.color);this.minimapCtx.fillStyle=t.border,wt.drawRoundRect(this.minimapCtx,e.x,e.y,e.width,e.height,25),this.minimapCtx.fill()};drawMinimapEdge=e=>{const t=this.DM.data.nodeMap,n=t[e.fromNode].ref,i=t[e.toNode].ref;if(!n||!i)return;const{x:s,y:r}=wt.getAnchorCoord(n,e.fromSide),{x:o,y:a}=wt.getAnchorCoord(i,e.toSide);this.minimapCtx.beginPath(),this.minimapCtx.moveTo(s,r),this.minimapCtx.lineTo(o,a),this.minimapCtx.strokeStyle=this.SM.getColor(e.color).active,this.minimapCtx.lineWidth=10,this.minimapCtx.stroke()};updateViewportRectangle=()=>{if(this.collapsed)return;const e=this.DM.data.nodeBounds,t=this.DM.data.container,n=this.DM.data.scale;if(!e)return;const i=t.clientWidth/n,s=t.clientHeight/n,r=-this.DM.data.offsetX/n+t.clientWidth/(2*n),o=-this.DM.data.offsetY/n+t.clientHeight/(2*n),a=this.minimapCache.centerX+(r-i/2-e.centerX)*this.minimapCache.scale,l=this.minimapCache.centerY+(o-s/2-e.centerY)*this.minimapCache.scale,c=i*this.minimapCache.scale,h=s*this.minimapCache.scale;this.viewportRectangle.style.left=`${a}px`,this.viewportRectangle.style.top=`${l}px`,this.viewportRectangle.style.width=`${c}px`,this.viewportRectangle.style.height=`${h}px`};dispose=()=>{this.toggleMinimapBtn.removeEventListener("click",this.toggleCollapse),this.minimapCtx.clearRect(0,0,this.minimap.clientWidth,this.minimap.clientHeight),this.minimapContainer.remove(),this._minimapContainer=null,this._toggleMinimapBtn=null,this._viewportRectangle=null,this._minimap=null}}class tn extends xt{_preventionContainer=null;preventMt=!1;DM;preventMistouch={record:!1,lastX:0,lastY:0,initialX:0,initialY:0};get preventionContainer(){if(null===this._preventionContainer)throw kt;return this._preventionContainer}constructor(...e){super(...e);const t=document.createElement("div");t.className="prevention-banner border-shadow-bg",t.textContent=this.options.mistouchPreventerBannerText??"Click on to unlock.",this.DM=this.container.get(vt),this._preventionContainer=document.createElement("div"),this._preventionContainer.className="prevention-container hidden",wt.applyStyles(this._preventionContainer,".full,.prevention-container{top:0;left:0;width:100%;height:100%;position:absolute}.flex-center,.prevention-container{display:flex;justify-content:center;align-items:center}.prevention-container{overflow:visible;transition:background .2s,opacity .2s,box-shadow .2s,border .2s,filter .2s,backdrop-filter .2s}.prevention-container.hidden{pointer-events:none;opacity:0}.prevention-container .prevention-banner{border-radius:12px;padding:12px;margin:12px;font-size:calc(14px + .3vw);line-height:calc(17px + .3vw);text-align:center}"),this._preventionContainer.appendChild(t),this.DM.data.container.appendChild(this._preventionContainer),this.options.preventMistouchAtStart&&this.startPrevention(),window.addEventListener("pointerdown",this.onPointerDown),window.addEventListener("pointermove",this.onPointerMove),window.addEventListener("pointerup",this.onPointerUp),this.augment({startMistouchPrevention:this.startPrevention,endMistouchPrevention:this.endPrevention}),this.onDispose(this.dispose)}onPointerDown=e=>{const t=this.DM.data.container.getBoundingClientRect();e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom?this.preventMt||this.startPrevention():this.preventMt&&(this.preventMistouch.initialX=e.clientX,this.preventMistouch.initialY=e.clientY,this.preventMistouch.lastX=e.clientX,this.preventMistouch.lastY=e.clientY,this.preventMistouch.record=!0)};onPointerMove=e=>{this.preventMistouch.record&&(this.preventMistouch.lastX=e.clientX,this.preventMistouch.lastY=e.clientY)};onPointerUp=()=>{this.preventMistouch.record&&(this.preventMistouch.record=!1,Math.abs(this.preventMistouch.lastX-this.preventMistouch.initialX)+Math.abs(this.preventMistouch.lastY-this.preventMistouch.initialY)<5&&this.endPrevention())};startPrevention=()=>{this.preventionContainer.classList.remove("hidden"),this.DM.data.container.classList.add("numb"),this.preventMt=!0};endPrevention=()=>{this.preventMt=!1,this.preventionContainer.classList.add("hidden"),setTimeout(()=>this.DM.data.container.classList.remove("numb"),50)};dispose=()=>{window.removeEventListener("pointerdown",this.onPointerDown),window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),this.preventionContainer.remove(),this._preventionContainer=null}}class nn extends xt{_canvas;ctx;DM;SM;zoomInOptimize={lastDrawnScale:0,lastDrawnViewport:{left:0,right:0,top:0,bottom:0},timeout:null,lastCallTime:0};get canvas(){if(null===this._canvas)throw kt;return this._canvas}constructor(...e){super(...e);const t=this.container.get(Lt);this.SM=this.container.get(Nt),t.hooks.onRefresh.subscribe(this.redraw),t.hooks.onResize.subscribe(this.optimizeDPR),this.DM=this.container.get(vt),this._canvas=document.createElement("canvas"),this._canvas.className="main-canvas",this.ctx=this._canvas.getContext("2d"),this.DM.data.container.appendChild(this._canvas),this.onDispose(this.dispose)}optimizeDPR=()=>{const e=this.DM.data.container;wt.resizeCanvasForDPR(this.canvas,e.offsetWidth,e.offsetHeight)};redraw=()=>{const e=this.DM.data.offsetX,t=this.DM.data.offsetY,n=this.DM.data.scale,i=this.getCurrentViewport(e,t,n);if(!this.options.zoomInOptimization)return void this.trueRedraw(e,t,n,i);this.zoomInOptimize.timeout&&(clearTimeout(this.zoomInOptimize.timeout),this.zoomInOptimize.timeout=null);const s=Date.now();if(this.isInside(i,this.zoomInOptimize.lastDrawnViewport)&&n!==this.zoomInOptimize.lastDrawnScale){if(s-this.zoomInOptimize.lastCallTime<500)return this.zoomInOptimize.timeout=setTimeout(()=>{this.trueRedraw(e,t,n,i),this.zoomInOptimize.lastCallTime=s,this.zoomInOptimize.timeout=null},60),void this.fakeRedraw(i,n)}this.zoomInOptimize.lastCallTime=s,this.trueRedraw(e,t,n,i)};trueRedraw(e,t,n,i){this.zoomInOptimize.lastDrawnViewport=i,this.zoomInOptimize.lastDrawnScale=n,this.canvas.style.transform="",this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.save(),this.drawGridDots(n,e,t),this.ctx.translate(e,t),this.ctx.scale(n,n),Object.values(this.DM.data.nodeMap).forEach(e=>{if(this.isOutside(e.box,i))return;const t=e.ref;"file"===t.type?this.drawFile(e):"group"===t.type&&this.drawGroup(t,n)}),Object.values(this.DM.data.edgeMap).forEach(e=>{this.isOutside(e.box,i)||this.drawEdge(e)}),this.ctx.restore()}fakeRedraw(e,t){const n=t/this.zoomInOptimize.lastDrawnScale,i=(this.zoomInOptimize.lastDrawnViewport.left-e.left)*t,s=(this.zoomInOptimize.lastDrawnViewport.top-e.top)*t;this.canvas.style.transform=`translate(${i}px, ${s}px) scale(${n})`}isInside=(e,t)=>e.left>t.left&&e.top>t.top&&e.right<t.right&&e.bottom<t.bottom;isOutside=(e,t)=>e.right<t.left||e.bottom<t.top||e.left>t.right||e.top>t.bottom;getCurrentViewport=(e,t,n)=>{const i=-e/n,s=-t/n,r=this.DM.data.container;return{left:i,top:s,right:i+r.clientWidth/n,bottom:s+r.clientHeight/n}};drawLabelBar=(e,t,n,i,s,r)=>{const o=30*r,a=6*r,l=8*r,c=16*r,h=6*r;this.ctx.save(),this.ctx.translate(e,t),this.ctx.scale(1/r,1/r),this.ctx.font=`${c}px 'Inter', sans-serif`;const p=this.ctx.measureText(n).width+2*h;this.ctx.translate(0,-o-l),this.ctx.fillStyle=i,this.ctx.beginPath(),this.ctx.moveTo(a,0),this.ctx.lineTo(p-a,0),this.ctx.quadraticCurveTo(p,0,p,a),this.ctx.lineTo(p,o-a),this.ctx.quadraticCurveTo(p,o,p-a,o),this.ctx.lineTo(a,o),this.ctx.quadraticCurveTo(0,o,0,o-a),this.ctx.lineTo(0,a),this.ctx.quadraticCurveTo(0,0,a,0),this.ctx.closePath(),this.ctx.fill(),this.ctx.fillStyle=s,this.ctx.fillText(n,h,.65*o),this.ctx.restore()};drawNodeBackground=e=>{const t=this.SM.getColor(e.color);this.ctx.globalAlpha=1,this.ctx.fillStyle=t.background,wt.drawRoundRect(this.ctx,e.x+1,e.y+1,e.width-2,e.height-2,12),this.ctx.fill(),this.ctx.strokeStyle=t.border,this.ctx.lineWidth=2,wt.drawRoundRect(this.ctx,e.x,e.y,e.width,e.height,12),this.ctx.stroke()};drawGroup=(e,t)=>{if(this.drawNodeBackground(e),e.label){const n=this.SM.getColor(e.color);this.drawLabelBar(e.x,e.y,e.label,n.active,n.text,t)}};drawFile=e=>{this.ctx.fillStyle=this.SM.getColor().text;const t=e.ref;this.ctx.font="16px sans-serif",this.ctx.fillText(e.fileName??"",t.x+5,t.y-10)};drawEdge=e=>{const t=e.ref,n=this.DM.data.nodeMap[t.fromNode].ref,i=this.DM.data.nodeMap[t.toNode].ref,s=wt.getAnchorCoord,{x:r,y:o}=s(n,t.fromSide),{x:a,y:l}=s(i,t.toSide),c=this.SM.getColor(t.color);let[h,p,u,d]=[0,0,0,0];if(e.controlPoints?[h,p,u,d]=e.controlPoints:([h,p,u,d]=this.getControlPoints(r,o,a,l,t.fromSide,t.toSide),e.controlPoints=[h,p,u,d]),this.drawCurvedPath(r,o,a,l,h,p,u,d,c.active),this.drawArrowhead(a,l,u,d,c.active),t.label){const e=.5,n=(1-e)**3*r+3*(1-e)**2*e*h+3*(1-e)*e*e*u+e**3*a,i=(1-e)**3*o+3*(1-e)**2*e*p+3*(1-e)*e*e*d+e**3*l;this.ctx.font="18px sans-serif";const s=8,m=this.ctx.measureText(t.label).width+2*s,g=20;this.ctx.fillStyle=c.active,this.ctx.beginPath(),wt.drawRoundRect(this.ctx,n-m/2,i-g/2-2,m,g,4),this.ctx.fill(),this.ctx.fillStyle=c.text,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(t.label,n,i-2),this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic"}};getControlPoints=(e,t,n,i,s,r)=>{const o=n-e,a=i-t,l=Math.min(Math.abs(o),Math.abs(a))+.3*Math.max(Math.abs(o),Math.abs(a)),c=(h=.5*l,p=60,u=300,Math.max(p,Math.min(u,h)));var h,p,u;let d=e,m=t,g=n,f=i;switch(s){case"top":m=t-c;break;case"bottom":m=t+c;break;case"left":d=e-c;break;case"right":d=e+c}switch(r){case"top":f=i-c;break;case"bottom":f=i+c;break;case"left":g=n-c;break;case"right":g=n+c}return[d,m,g,f]};drawGridDots=(e,t,n)=>{const i=10*2**-Math.floor(Math.log2(e))*e,s=this.canvas.width,r=this.canvas.height,o=t%i,a=n%i;this.ctx.fillStyle=this.SM.getNamedColor("dots");for(let l=o;l<=s;l+=i)for(let e=a;e<=r;e+=i)this.ctx.beginPath(),this.ctx.arc(l,e,1,0,2*Math.PI),this.ctx.fill()};drawCurvedPath=(e,t,n,i,s,r,o,a,l)=>{this.ctx.beginPath(),this.ctx.moveTo(e,t),this.ctx.bezierCurveTo(s,r,o,a,n,i),this.ctx.strokeStyle=l,this.ctx.lineWidth=2,this.ctx.stroke()};drawArrowhead=(e,t,n,i,s)=>{const r=e-n,o=t-i,a=Math.sqrt(r*r+o*o);if(0===a)return;const l=r/a,c=o/a,h=e-12*l-4*c,p=t-12*c+4*l,u=e-12*l+4*c,d=t-12*c-4*l;this.ctx.beginPath(),this.ctx.fillStyle=s,this.ctx.moveTo(e,t),this.ctx.lineTo(h,p),this.ctx.lineTo(u,d),this.ctx.closePath(),this.ctx.fill()};dispose=()=>{this.zoomInOptimize.timeout&&(clearTimeout(this.zoomInOptimize.timeout),this.zoomInOptimize.timeout=null),this.canvas.remove(),this._canvas=null}}function sn(e){return"function"==typeof e}function rn(e){const t=[];let n=e;for(;Object.getPrototypeOf(n).name;){const e=Object.getPrototypeOf(n);t.push(e),n=e}return t}function on(e){if(null==e)throw Error("Expected value to be not null or undefined");return e}function an(e,t){if(e.length>1)throw t();const n=e.at(0);if(void 0===n)throw t();return n}function ln(e){return sn(e)}function cn(e){return"provide"in e&&"useClass"in e}function hn(e){return"provide"in e&&"useFactory"in e}function pn(e){return hn(e)&&!0===e.async}function un(e){return"provide"in e&&"useExisting"in e}function dn(e){return"provide"in e&&"multi"in e&&!0===e.multi}class mn{description;options;constructor(e,t){this.description=e,this.options=t}toString(){return`InjectionToken "${String(this.description)}"`}}function gn(e){return sn(e)}function fn(e){return sn(e)?e.name:"symbol"==typeof e?e.description??String(e):e instanceof mn?e.toString():e}function bn(e){return ln(e)?e:e.provide}const xn=/* @__PURE__ */Symbol("injectable");class wn{container;underConstruction=[];constructor(e){this.container=e}construct(e,t){if(pn(e))throw new kn(t);try{if(this.underConstruction.includes(e)){const t=[...this.underConstruction,e].map(bn).map(fn);throw new vn(t)}return this.underConstruction.push(e),this.doConstruct(e)}finally{this.underConstruction.pop()}}async constructAsync(e){try{if(this.underConstruction.includes(e)){const t=[...this.underConstruction,e].map(bn).map(fn);throw new vn(t)}if(this.underConstruction.push(e),pn(e))return[await e.useFactory(this.container)];if(cn(e)||ln(e)){const t=ln(e)?()=>[new e]:()=>[new e.useClass];return async function(e,t,n){for(;;)try{return await t()}catch(i){if(!(i instanceof e))throw i;await n(i)}}(kn,async()=>t(),async e=>{await this.container.getAsync(e.token,{multi:!0,optional:!0})})}return this.doConstruct(e)}finally{this.underConstruction.pop()}}doConstruct(e){return ln(e)?[new e]:cn(e)?[new e.useClass]:function(e){return"provide"in e&&"useValue"in e}(e)?[e.useValue]:hn(e)?[e.useFactory(this.container)]:un(e)?this.container.get(e.useExisting,{multi:!0}):function(){throw new Error("invalid state")}()}}class kn extends Error{token;constructor(e){super(`Some providers for token ${fn(e)} are async, please use injectAsync() or container.getAsync() instead`),this.token=e}}class vn extends Error{constructor(e){super(`Detected circular dependency: ${e.join(" -> ")}. Please change your dependency graph or use lazy injection instead.`)}}class yn{container;constructor(e){this.container=e}run(e){const t=Cn;try{return Cn=this,e(this.container)}finally{Cn=t}}async runAsync(e){const t=Cn;try{return Cn=this,await e(this.container)}finally{Cn=t}}}let Cn=new class{run(){throw new Tn}runAsync(){throw new Tn}};function Sn(e){return new yn(e)}class Tn extends Error{constructor(){super("You can only invoke inject() or injectAsync() within an injection context")}}class En{providers=/* @__PURE__ */new Map;singletons=/* @__PURE__ */new Map;parent;factory;constructor(e){this.parent=e,this.factory=new wn(this),this.bind({provide:En,useValue:this})}bindAll(...e){return e.forEach(e=>this.bind(e)),this}bind(e){const t=bn(e);if(un(e)&&e.provide===e.useExisting)throw Error(`The provider for token ${fn(t)} with "useExisting" cannot refer to itself.`);if(!un(e)&&this.singletons.has(t))throw Error(`Cannot bind a new provider for ${fn(t)}, since the existing provider was already constructed.`);if(un(e)&&dn(e)&&this.existingProviderAlreadyProvided(t,e.useExisting))return this;const n=this.providers.get(t)??[],i=dn(e);if(i&&n.some(e=>!dn(e)))throw Error(`Cannot bind ${fn(t)} as multi-provider, since there is already a provider which is not a multi-provider.`);if(!i&&n.some(e=>dn(e))&&!n.every(un))throw Error(`Cannot bind ${fn(t)} as provider, since there are already provider(s) that are multi-providers.`);return this.providers.set(t,i?[...n,e]:[e]),gn(t)&&(cn(e)||ln(e))&&function(e,t=2){const n=[];return e.some((i,s)=>{if(s+t>e.length)return!0;n.push(e.slice(s,s+t))}),n}([t,...rn(t)]).forEach(([e,t])=>{const n={provide:t,useExisting:e,multi:!0},i=this.providers.get(t)??[];this.existingProviderAlreadyProvided(t,e)||this.providers.set(t,[...i,n])}),this}unbind(e){const t=bn(e);return this.providers.delete(t),this.singletons.delete(t),this}unbindAll(){return this.providers.clear(),this.singletons.clear(),this}get(e,t){if(t?.lazy??!1)return()=>this.get(e,{...t,lazy:!1});this.autoBindIfNeeded(e);const n=t?.optional??!1;if(!this.providers.has(e)){if(this.parent)return this.parent.get(e,{...t,lazy:!1});if(n)return;throw Error(`No provider(s) found for ${fn(e)}`)}const i=on(this.providers.get(e));this.singletons.has(e)||Sn(this).run(()=>{const t=i.flatMap(t=>this.factory.construct(t,e));this.singletons.set(e,t)});const s=on(this.singletons.get(e));return t?.multi??!1?s:an(s,()=>Error(`Requesting a single value for ${fn(e)}, but multiple values were provided. Consider passing "{ multi: true }" to inject all values, or adjust your bindings accordingly.`))}getAsync(e,t){return t?.lazy??!1?()=>this.getAsync(e,{...t,lazy:!1}):async function(e){return await new Promise(t=>t(e()))}(async()=>{this.autoBindIfNeeded(e);const n=t?.optional??!1;if(!this.providers.has(e)){if(n)return;throw Error(`No provider(s) found for ${fn(e)}`)}const i=on(this.providers.get(e));this.singletons.has(e)||await Sn(this).runAsync(async()=>{const t=await Promise.all(i.map(e=>this.factory.constructAsync(e)));this.singletons.set(e,t.flat())});const s=on(this.singletons.get(e));return t?.multi??!1?s:an(s,()=>new Error(`Requesting a single value for ${fn(e)}, but multiple values were provided. Consider passing "{ multi: true }" to inject all values, or adjust your bindings accordingly.`))})}createChild(){return new En(this)}has(e){return this.providers.has(e)||(this.parent?.has(e)??!1)}autoBindIfNeeded(e){if(!this.singletons.has(e))if(gn(e)&&e.hasOwnProperty(xn)){const t=function(e){return e[xn]}(e);t.filter(e=>!this.providers.has(e)).forEach(e=>{this.bind({provide:e,useClass:e,multi:!0})})}else if(!this.providers.has(e)&&function(e){return e instanceof mn}(e)&&e.options?.factory){const t=e.options.async;t?t&&this.bind({provide:e,async:!0,useFactory:e.options.factory}):this.bind({provide:e,async:!1,useFactory:e.options.factory})}}existingProviderAlreadyProvided(e,t){return(this.providers.get(e)??[]).some(n=>un(n)&&n.provide===e&&n.useExisting===t)}}class Mn{allModules;IO=null;onDispose=wt.makeHook(!0);onStart=wt.makeHook();onRestart=wt.makeHook();started=!1;options;container;constructor(e,t){this.container=new En,this.options=e;this.allModules=[vt,Nt,Lt,Ot,Zt,nn,...t??[]],this.allModules.forEach(e=>{this.container.bind({provide:e,useFactory:()=>new e(this.container,this.options,this.onStart,this.onDispose,this.onRestart,this.augment)})}),this.allModules.forEach(e=>{this.container.get(e)});const n=this.options.loading??"normal";"normal"===n?this.load():"lazy"===n&&(this.IO=new IntersectionObserver(this.onVisibilityCheck,{root:null,rootMargin:"50px",threshold:0}),this.IO.observe(this.options.container))}onVisibilityCheck=e=>{e.forEach(e=>{if(e.isIntersecting)return this.load(),this.IO?.disconnect(),void(this.IO=null)})};augment=e=>{Object.entries(e).forEach(([e,t])=>{this[e]=t})};load=e=>{e&&Object.assign(this.options,e),this.started?this.onRestart():(this.onStart(),this.started=!0)};dispose=()=>{this.IO?.disconnect(),this.IO=null;const e=this.options.container;for(;e.firstChild;)e.firstChild.remove();this.onDispose(),this.container.unbindAll()}}const _n=async e=>ie.sanitize(await bt(e));async function Rn(e){return await fetch(e).then(e=>e.json())}export{Kt as Controls,Jt as DebugPanel,Mn as JSONCanvasViewer,en as Minimap,tn as MistouchPreventer,Rn as fetchCanvas,_n as parser};
|
|
1
|
+
class e{constructor(e,t,n,i,s,r){this.container=e,this.augment=r,this.options=t,this.onStart=n.subscribe,this.onDispose=i.subscribe,this.onRestart=s.subscribe}onStart;onRestart;onDispose;options}const t={round:function(e,t){const n=10**t;return Math.round(e*n)/n},resizeCanvasForDPR:function(e,t,n){const i=window.devicePixelRatio??1,s=e.getContext("2d");if(!s)throw new Error("[JSONCanvasViewer] This error is unexpected, probably caused uncontrollable runtime errors. Please contact the developer and show how to reproduce.");e.width=Math.round(t*i),e.height=Math.round(n*i),s.setTransform(1,0,0,1,0,0),s.scale(i,i)},applyStyles:function(e,t){const n=document.createElement("style");n.innerHTML=t,e.appendChild(n)},drawRoundRect:function(e,t,n,i,s,r){e.beginPath(),e.moveTo(t+r,n),e.lineTo(t+i-r,n),e.quadraticCurveTo(t+i,n,t+i,n+r),e.lineTo(t+i,n+s-r),e.quadraticCurveTo(t+i,n+s,t+i-r,n+s),e.lineTo(t+r,n+s),e.quadraticCurveTo(t,n+s,t,n+s-r),e.lineTo(t,n+r),e.quadraticCurveTo(t,n,t+r,n),e.closePath()},getAnchorCoord:function(e,t){const n=e.x+e.width/2,i=e.y+e.height/2;switch(t){case"top":return{x:n,y:e.y};case"bottom":return{x:n,y:e.y+e.height};case"left":return{x:e.x,y:i};case"right":return{x:e.x+e.width,y:i};default:return{x:n,y:i}}},makeHook:function(e=!1,t=!1){const n=t?async(...t)=>{if(e){const e=Array.from(n.subs).reverse();for(const n of e)await n(...t)}else for(const e of n.subs)await e(...t)}:(...t)=>{if(e){const e=Array.from(n.subs).reverse();for(const n of e)n(...t)}else for(const e of n.subs)e(...t)};return n.subs=/* @__PURE__ */new Set,n.subscribe=e=>{n.subs.add(e)},n.unsubscribe=e=>{n.subs.delete(e)},n}},n=new Error("[JSONCanvasViewer] Resource hasn't been set up or has been disposed.");class i extends e{onToggleFullscreen=t.makeHook();data={canvasData:{nodes:[],edges:[]},nodeMap:{},edgeMap:{},canvasBaseDir:"./",nodeBounds:{maxX:0,maxY:0,minX:0,minY:0,width:0,height:0,centerX:0,centerY:0},offsetX:0,offsetY:0,scale:1,container:document.createElement("div")};constructor(...e){super(...e);const n=this.options.container;for(;n.firstElementChild;)n.firstElementChild.remove();n.innerHTML="";const i=this.options.shadowed?n.attachShadow({mode:"open"}):n;t.applyStyles(i,".JSON-Canvas-Viewer{--contentTransition: color .2s, opacity .2s, text-shadow .2s, fill .2s;--containerTransition: background .2s, opacity .2s, box-shadow .2s, border .2s, filter .2s, backdrop-filter .2s;color:var(--text);fill:var(--text);stroke:var(--text);background-color:var(--background);position:relative;width:100%;height:100%;overflow:hidden}.JSON-Canvas-Viewer.JCV-numb,.JSON-Canvas-Viewer.JCV-numb *{pointer-events:none!important}.JSON-Canvas-Viewer .JCV-full,.JSON-Canvas-Viewer .JCV-overlay-container .JCV-click-layer,.JSON-Canvas-Viewer .JCV-overlay-container .JCV-link-iframe,.JSON-Canvas-Viewer .JCV-overlay-container .JCV-audio,.JSON-Canvas-Viewer .JCV-overlay-container .JCV-video,.JSON-Canvas-Viewer .JCV-overlay-container .JCV-content{top:0;left:0;width:100%;height:100%;position:absolute}.JSON-Canvas-Viewer .JCV-flex-center,.JSON-Canvas-Viewer .JCV-overlay-container .JCV-content.JCV-markdown-content{display:flex;justify-content:center;align-items:center}.JSON-Canvas-Viewer .JCV-border-shadow-bg{background:var(--background-secondary);border:1px solid var(--border)!important;box-shadow:var(--shadow)}.JSON-Canvas-Viewer .JCV-button{cursor:pointer;font-size:18px;height:32px;border:none;transition:var(--containerTransition);background-color:var(--background-secondary);text-align:center;width:32px;padding:5px 0}.JSON-Canvas-Viewer .JCV-button svg{width:100%;height:100%}.JSON-Canvas-Viewer .JCV-button:hover{background-color:var(--border)}.JSON-Canvas-Viewer .JCV-button.JCV-collapse-button{border-radius:8px;transition:transform .2s,background-color .2s}.JSON-Canvas-Viewer .JCV-collapsed .JCV-collapse-button{transform:rotate(180deg)}.JSON-Canvas-Viewer .JCV-main-canvas{width:100%;height:100%;transform-origin:top left}.JSON-Canvas-Viewer .JCV-overlays{position:absolute;transform-origin:top left;will-change:transform}.JSON-Canvas-Viewer .JCV-overlay-container{position:absolute;box-sizing:border-box;border-radius:12px;-webkit-user-select:none;user-select:none;contain:strict;content-visibility:auto;background-color:var(--overlay-card);transition:var(--containerTransition)}.JSON-Canvas-Viewer .JCV-overlay-container .JCV-overlay-border{box-sizing:border-box;pointer-events:none;position:absolute;color:var(--overlay-border);top:0;left:0;width:100%;height:100%;border-width:1px;border-style:solid;border-radius:12px;transition:var(--containerTransition)}.JSON-Canvas-Viewer .JCV-overlay-container .JCV-content{overflow:hidden}.JSON-Canvas-Viewer .JCV-overlay-container .JCV-content.JCV-markdown-content{position:absolute;padding:0 7px}.JSON-Canvas-Viewer .JCV-overlay-container .JCV-content.JCV-markdown-content.rtl{direction:rtl;text-align:right}.JSON-Canvas-Viewer .JCV-overlay-container.JCV-active{-webkit-user-select:auto;user-select:auto;pointer-events:auto}.JSON-Canvas-Viewer .JCV-overlay-container.JCV-active .JCV-overlay-border{border:4px solid var(--overlay-active)}.JSON-Canvas-Viewer .JCV-overlay-container .JCV-link-iframe,.JSON-Canvas-Viewer .JCV-overlay-container .JCV-audio,.JSON-Canvas-Viewer .JCV-overlay-container .JCV-video{border:none;background:transparent}.JSON-Canvas-Viewer .JCV-overlay-container .JCV-click-layer{background:transparent;pointer-events:auto}.JSON-Canvas-Viewer .JCV-overlay-container.JCV-active .JCV-click-layer{pointer-events:none}.JSON-Canvas-Viewer .JCV-overlay-container .JCV-img{width:100%;height:100%;object-fit:cover;pointer-events:none}.JSON-Canvas-Viewer .JCV-overlay-container.JCV-active .JCV-img{pointer-events:auto}.JSON-Canvas-Viewer .JCV-overlay-container .JCV-parsed-content-wrapper{font-family:sans-serif;box-sizing:border-box;max-width:100%;max-height:100%;padding:10px 6px;pointer-events:none;overflow:hidden;scrollbar-gutter:stable both-edges;display:flex;flex-direction:column;gap:12px}@supports not (scrollbar-gutter: stable both-edges){.JSON-Canvas-Viewer .JCV-overlay-container .JCV-parsed-content-wrapper{padding:10px}}.JSON-Canvas-Viewer .JCV-overlay-container.JCV-active .JCV-parsed-content-wrapper{overflow:auto;pointer-events:auto}.JSON-Canvas-Viewer .JCV-markdown-content ::-webkit-scrollbar{width:4px}.JSON-Canvas-Viewer .JCV-markdown-content ::-webkit-scrollbar-track{background-color:transparent}.JSON-Canvas-Viewer .JCV-markdown-content ::-webkit-scrollbar-thumb{border-radius:2px;background:#ffffff40}.JSON-Canvas-Viewer .JCV-markdown-content ::-webkit-scrollbar-thumb:hover{background:#1e1e1ebf}.JSON-Canvas-Viewer .JCV-markdown-content p{font-size:16px;line-height:21px}.JSON-Canvas-Viewer .JCV-markdown-content img{width:100%;border-radius:8px}.JSON-Canvas-Viewer .JCV-markdown-content h1{font-size:25px}.JSON-Canvas-Viewer .JCV-markdown-content h2{font-size:23px}.JSON-Canvas-Viewer .JCV-markdown-content h3{font-size:22px}.JSON-Canvas-Viewer .JCV-markdown-content h4{font-size:20px}.JSON-Canvas-Viewer .JCV-markdown-content h5{font-size:19px}.JSON-Canvas-Viewer .JCV-markdown-content h6{font-size:17px}.JSON-Canvas-Viewer .JCV-markdown-content p,.JSON-Canvas-Viewer .JCV-markdown-content h1,.JSON-Canvas-Viewer .JCV-markdown-content h2,.JSON-Canvas-Viewer .JCV-markdown-content h3,.JSON-Canvas-Viewer .JCV-markdown-content h4,.JSON-Canvas-Viewer .JCV-markdown-content h5,.JSON-Canvas-Viewer .JCV-markdown-content h6,.JSON-Canvas-Viewer .JCV-markdown-content ol,.JSON-Canvas-Viewer .JCV-markdown-content ul{margin:0}.JSON-Canvas-Viewer .JCV-markdown-content h1,.JSON-Canvas-Viewer .JCV-markdown-content h2{font-weight:800}.JSON-Canvas-Viewer .JCV-markdown-content h3,.JSON-Canvas-Viewer .JCV-markdown-content h4{font-weight:700}.JSON-Canvas-Viewer .JCV-markdown-content h5,.JSON-Canvas-Viewer .JCV-markdown-content h6{font-weight:600}.JSON-Canvas-Viewer .JCV-markdown-content code{background:#ffffff1a;padding:2px 4px;border-radius:8px}pre .JSON-Canvas-Viewer .JCV-markdown-content code{display:block;box-sizing:border-box;width:100%}.JSON-Canvas-Viewer .JCV-markdown-content pre:has(code),.JSON-Canvas-Viewer .JCV-markdown-content table{margin:6px 0}.JSON-Canvas-Viewer .JCV-markdown-content strong{color:#fe8e7c}.JSON-Canvas-Viewer .JCV-markdown-content em{color:#5affb2}.JSON-Canvas-Viewer .JCV-markdown-content a{text-decoration:none;color:#6dadd0;font-weight:800;font-style:italic;cursor:pointer;transition:var(--contentTransition)}.JSON-Canvas-Viewer .JCV-markdown-content a:hover{color:#86d3fd}.JSON-Canvas-Viewer .JCV-markdown-content hr{height:1px;width:100%;background-color:#fff3;border:none}.JSON-Canvas-Viewer .JCV-markdown-content li{margin:5px 0}.JSON-Canvas-Viewer .JCV-markdown-content ul{padding-left:16px}.JSON-Canvas-Viewer .JCV-markdown-content ol{padding-left:15px;padding-right:7.5px}.JSON-Canvas-Viewer .JCV-markdown-content table{border-collapse:collapse;border-radius:8px;overflow:hidden;width:100%}.JSON-Canvas-Viewer .JCV-markdown-content table th,.JSON-Canvas-Viewer .JCV-markdown-content table td{border:1px solid rgba(255,255,255,.2);padding:6px 10px;background:#ffffff0f;text-align:left}.JSON-Canvas-Viewer .JCV-markdown-content table th{background:#ffffff1f;font-weight:700}"+this.options.extraCSS),this.data.container.classList.add("JSON-Canvas-Viewer"),i.appendChild(this.data.container),this.augment({resetView:this.resetView,toggleFullscreen:this.toggleFullscreen,onToggleFullscreen:this.onToggleFullscreen}),this.onStart(this.start),this.onRestart(this.start),this.onDispose(this.dispose)}start=()=>{const e=Object.assign({nodes:[],edges:[]},this.options.canvas);Object.assign(this.data,{canvasData:e,nodeMap:{},edgeMap:{},canvasBaseDir:this.processBaseDir(this.options.attachmentDir),nodeBounds:this.calculateNodeBounds(e),offsetX:0,offsetY:0,scale:1}),this.data.canvasData.nodes.forEach(e=>{const t={ref:e,box:this.getNodeBox(e)};if(this.data.nodeMap[e.id]=t,"file"===e.type){const n=e.file.split("/").pop()??"";if(t.fileName=n,!e.file.startsWith("http://")&&!e.file.startsWith("https://")){const t=this.options.attachments?.[n];t?e.file=t:this.options.noAttachmentRelocation||(e.file=this.data.canvasBaseDir+n)}}}),this.data.canvasData.edges.forEach(e=>{this.data.edgeMap[e.id]={ref:e,box:this.getEdgeBox(e)}}),this.resetView()};processBaseDir=e=>{if(!e)return"./";const t=e?.slice(-1);return"/"===t?e:`${e}/`};getNodeBox=e=>({left:e.x,top:"file"===e.type||"group"===e.type?e.y-40:e.y,right:e.width+e.x,bottom:e.y+e.height});getEdgeBox=e=>{const n=this.data.nodeMap,i=n[e.fromNode].ref,s=n[e.toNode].ref,r=t.getAnchorCoord(i,e.fromSide),o=t.getAnchorCoord(s,e.toSide),a=Math.min(r.x,o.x),l=Math.min(r.y,o.y),c=Math.max(r.x,o.x),h=Math.max(r.y,o.y),p=c-a,d=h-l,u=Math.min(p,d),m=0===u?1:u,g=Math.max(p,d),f=10*Math.log2(g/m);return{left:a-f,top:l-f,right:c+f,bottom:h+f}};calculateNodeBounds(e){let t=1/0,n=1/0,i=-1/0,s=-1/0;e.nodes.forEach(e=>{t=Math.min(t,e.x),n=Math.min(n,e.y),i=Math.max(i,e.x+e.width),s=Math.max(s,e.y+e.height)});const r=i-t,o=s-n;return{minX:t,minY:n,maxX:i,maxY:s,width:r,height:o,centerX:t+r/2,centerY:n+o/2}}toggleFullscreen=async e=>{document.fullscreenElement||e&&"enter"!==e?!document.fullscreenElement||e&&"exit"!==e||(await document.exitFullscreen(),this.onToggleFullscreen("exit")):(await this.data.container.requestFullscreen(),this.onToggleFullscreen("enter"))};resetView=()=>{const e=this.data.nodeBounds,t=this.data.container;if(!e||!t)return;const n=e.width+200,i=e.height+200,s=t.clientWidth,r=t.clientHeight,o=s/n,a=r/i,l=Math.round(1e3*Math.min(o,a))/1e3,c={scale:l,offsetX:s/2-e.centerX*l,offsetY:r/2-e.centerY*l};this.data.offsetX=c.offsetX,this.data.offsetY=c.offsetY,this.data.scale=c.scale};middleViewer=()=>{const e=this.data.container;return{x:e.clientWidth/2,y:e.clientHeight/2,width:e.clientWidth,height:e.clientHeight}};dispose=()=>{this.data.container.remove()}}const s=(e,t,n)=>e>=t&&e<=n,r=e=>{const t=e.trim();return t?t.endsWith("%")?Number(t.slice(0,-1))/100*255:Number(t):NaN},o=e=>{const{red:t,green:n,blue:i,alpha:r}=e;return s(t,0,255)&&s(n,0,255)&&s(i,0,255)&&(void 0===r||s(r,0,1))},a=e=>{const t=e.match(/^rgba?\(\s*(\d{1,3}|[\d.]+%)\s*[, ]\s*(\d{1,3}|[\d.]+%)\s*[, ]\s*(\d{1,3}|[\d.]+%)\s*(?:[,/]\s*([01]?\.?\d+%?))?\s*\)$/);if(!t)return!1;const[,n,i,o,a]=t,l=r(n),c=r(i),h=r(o);return!!(s(l,0,255)&&s(c,0,255)&&s(h,0,255))&&(void 0===a||(e=>{if("number"==typeof e)return s(e,0,1);if("string"==typeof e){const t=parseFloat(e);return!isNaN(t)&&(e.endsWith("%")?s(t/100,0,1):s(t,0,1))}return!1})(a))},l=e=>{if("number"==typeof e){if(!s(e,0,1))throw new Error("Alpha value must be between 0 and 1");return e}if("string"==typeof e){const t=e.trim();let n;if(n=t.endsWith("%")?Number(t.slice(0,-1))/100:Number(t),isNaN(n))throw new Error(`Invalid alpha value: "${e}"`);if(!s(n,0,1))throw new Error("Alpha value must be between 0 and 1");return n}throw new Error("Invalid alpha value format")},c=e=>{if("string"!=typeof e)throw new Error("Invalid HSL color format");const t=e.match(/^hsla?\(\s*(-?[\d.]+(?:deg|rad|grad|turn)?)\s*[, ]\s*(-?[\d.]+%?)\s*[, ]\s*(-?[\d.]+%?)\s*(?:[,/]\s*(-?[\d.]+%?))?\s*\)$/i);if(!t)throw new Error("Invalid HSL color format");const[,n,i,r,o]=t,a=(e=>{const t=e.trim().toLowerCase().match(/^(-?[\d.]+)(deg|rad|grad|turn)?$/);if(!t)return NaN;const n=parseFloat(t[1]),i=t[2];if(isNaN(n))return NaN;let s;switch(i){case"rad":s=180*n/Math.PI;break;case"grad":s=n/400*360;break;case"turn":s=360*n;break;default:s=n}return(s%360+360)%360})(n),c=parseFloat(i),h=parseFloat(r);if(isNaN(a)||isNaN(c)||isNaN(h)||!s(c,0,100)||!s(h,0,100))throw new Error("Invalid HSL color values");return void 0!==o?{hue:a,saturation:c,lightness:h,alpha:l(o)}:{hue:a,saturation:c,lightness:h,alpha:1}},h=e=>{if("string"!=typeof e)throw new Error("Invalid RGB color format");const t=e.match(/^rgba?\(\s*(-?[\d.]+%?)\s*[, ]\s*(-?[\d.]+%?)\s*[, ]\s*(-?[\d.]+%?)\s*(?:[,/]\s*(-?[\d.]+%?))?\s*\)$/i);if(!t)throw new Error("Invalid RGB color format");const[,n,i,o,a]=t,c=r(n),h=r(i),p=r(o);if(!s(c,0,255)||!s(h,0,255)||!s(p,0,255))throw new Error("RGB values must be between 0 and 255");return{red:c,green:h,blue:p,alpha:void 0!==a?l(a):1}},p=e=>{if("string"!=typeof e)throw new Error("Invalid Hex color format.");const t=e.match(/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i);if(!t)throw new Error("Invalid Hex color format.");let n=t[1];3!==n.length&&4!==n.length||(n=n.split("").map(e=>e+e).join(""));const i=parseInt(n.substring(0,2),16),s=parseInt(n.substring(2,4),16),r=parseInt(n.substring(4,6),16);let o=1;if(8===n.length){const e=parseInt(n.substring(6,8),16);o=Number((e/255).toFixed(2))}return{red:i,green:s,blue:r,alpha:o}},d=e=>{if(!(e=>"string"==typeof e?a(e):"object"==typeof e&&null!==e&&o(e))(e))throw new Error("Invalid RGB color format");const t="string"==typeof e?h(e):e,{red:n,green:i,blue:s,alpha:r}=t,l=n/255,c=i/255,p=s/255,d=Math.max(l,c,p),u=Math.min(l,c,p),m=d-u;let g=0,f=0;const w=(d+u)/2;if(0!==m){switch(f=w>.5?m/(2-d-u):m/(d+u),d){case l:g=(c-p)/m+(c<p?6:0);break;case c:g=(p-l)/m+2;break;case p:g=(l-c)/m+4}g*=60}return{hue:Math.round(g),saturation:Math.round(100*f),lightness:Math.round(100*w),alpha:r}},u=e=>{const t=(e=>{if("string"==typeof e){if(e.startsWith("#"))return"hex";if(e.startsWith("rgb"))return"rgbString";if(e.startsWith("hsl"))return"hslString"}if("object"==typeof e&&null!==e){if("red"in e&&"green"in e&&"blue"in e)return"rgb";if("hue"in e&&"saturation"in e&&"lightness"in e)return"hsl"}throw new Error("Invalid color format")})(e);if("hsl"===t)return e;if("rgb"===t)return d(e);if("hex"===t)return(e=>{const t=p(e);return d(t)})(e);if("hslString"===t)return c(e);if("rgbString"===t)return d(e);throw new Error("Invalid color format")},m=e=>(e=>{if("object"!=typeof e||null===e)throw new Error("Invalid color format. Expected an RGB or HSL object.");if("red"in e&&"green"in e&&"blue"in e){const{red:t,green:n,blue:i,alpha:s}=e;return void 0===s||1===s?`rgb(${t}, ${n}, ${i})`:`rgba(${t}, ${n}, ${i}, ${s})`}if("hue"in e&&"saturation"in e&&"lightness"in e){const{hue:t,saturation:n,lightness:i,alpha:s}=e;return void 0===s||1===s?`hsl(${t}, ${n}%, ${i}%)`:`hsla(${t}, ${n}%, ${i}%, ${s})`}throw new Error("Invalid color format. Expected an RGB or HSL object.")})(u(e));class g extends e{theme="light";onChangeTheme=t.makeHook();definedColors={light:{0:{hue:0,saturation:0,lightness:72},1:{hue:358,saturation:81,lightness:55},2:{hue:19,saturation:87,lightness:58},3:{hue:41,saturation:79,lightness:52},4:{hue:150,saturation:100,lightness:37},5:{hue:221,saturation:100,lightness:59},6:{hue:257,saturation:81,lightness:62}},dark:{0:{hue:0,saturation:0,lightness:40},1:{hue:358,saturation:100,lightness:65},2:{hue:23,saturation:86,lightness:63},3:{hue:39,saturation:91,lightness:70},4:{hue:153,saturation:80,lightness:45},5:{hue:217,saturation:100,lightness:62},6:{hue:259,saturation:100,lightness:75}}};namedColors={light:{dots:"hsla(0, 0%, 72%, 0.4)",text:"rgb(30, 30, 30)",background:"rgb(250, 250, 250)","background-secondary":"rgb(255, 255, 255)",shadow:"0px 0px 8px rgb(0, 0, 0, 0.1)",border:"hsla(0, 0%, 82%, 0.7)"},dark:{dots:"hsla(0, 0%, 40%, 0.3)",text:"rgb(242, 242, 242)",background:"rgb(30, 30, 30)","background-secondary":"rgb(37, 37, 40)",shadow:"0px 0px 8px rgb(0, 0, 0, 0.2)",border:"hsla(0, 0%, 30%, 0.7)"}};colorCache={dark:{},light:{}};constructor(...e){super(...e);const t=this.options.colors;if(t){["light","dark"].forEach(e=>{if(!(e in t))return;const n=t[e];n&&Object.entries(n).forEach(([t,n])=>{if(!n)return;const i=this.namedColors[e],s=this.definedColors[e];if(t in i)i[t]=n;else if(t in s){const e=this.parseColor(n);if(!e)return void console.warn(`[JSON Canvas Viewer] Color ${n} unsupported.`);s[t]=e}})})}this.changeTheme(this.options.theme??"light"),this.augment({changeTheme:this.changeTheme,onChangeTheme:this.onChangeTheme})}hslProcessor=e=>{const{hue:t,saturation:n,lightness:i}=e;let s;return s="dark"===this.theme?{active:e,card:{hue:t,saturation:n/3,lightness:i/3},border:{...e,alpha:.7},background:{...e,alpha:.1},text:e.lightness>=70?"rgb(30, 30, 30)":"rgb(242, 242, 242)"}:{active:e,card:0===t?{hue:t,saturation:n,lightness:100}:{hue:t,saturation:.4*n,lightness:90},border:{...e,alpha:.7},background:{...e,alpha:.1},text:e.lightness>=70?"rgb(30, 30, 30)":"rgb(242, 242, 242)"},{active:m(s.active),card:m(s.card),border:m(s.border),background:m(s.background),text:s.text}};parseColor=e=>e.startsWith("rgb")?d(h(e)):e.startsWith("#")?d(p(e)):e.startsWith("hsl")?c(e):void 0;getColor=(e="0")=>{const t=this.theme;let n;return this.colorCache[t][e]?this.colorCache[t][e]:(n=e in this.definedColors[t]?this.hslProcessor(this.definedColors[t][e]):this.hslProcessor(d(p(e))),this.colorCache[t][e]=n,n)};getNamedColor=e=>this.namedColors[this.theme][e];changeTheme=e=>{this.theme=e||("dark"===this.theme?"light":"dark");const t=this.container.get(i).data.container;Object.entries(this.namedColors[this.theme]).forEach(([e,n])=>{t.style.setProperty(`--${e}`,n)}),this.onChangeTheme(this.theme)}}class f extends e{animationId=null;resizeAnimationId=null;DM;SM;resizeObserver;perFrame={lastScale:1,lastOffsets:{x:0,y:0}};lastResizeCenter={x:null,y:null};onResize=t.makeHook();onRefresh=t.makeHook();constructor(...e){super(...e),this.DM=this.container.get(i),this.SM=this.container.get(g),this.resizeObserver=new ResizeObserver(this.onResizeCallback),this.SM.onChangeTheme.subscribe(this.refresh),this.augment({refresh:this.refresh,onRefresh:this.onRefresh,onResize:this.onResize}),this.onStart(this.start),this.onRestart(this.refresh),this.onDispose(this.dispose)}start=()=>{this.resizeObserver.observe(this.DM.data.container),this.animationId=requestAnimationFrame(this.draw)};draw=()=>{this.perFrame.lastScale===this.DM.data.scale&&this.perFrame.lastOffsets.x===this.DM.data.offsetX&&this.perFrame.lastOffsets.y===this.DM.data.offsetY||this.refresh(),this.animationId=requestAnimationFrame(this.draw)};refresh=()=>{this.perFrame={lastScale:this.DM.data.scale,lastOffsets:{x:this.DM.data.offsetX,y:this.DM.data.offsetY}},this.onRefresh()};onResizeCallback=()=>{this.resizeAnimationId=requestAnimationFrame(()=>{const e=this.DM.middleViewer();this.lastResizeCenter.x&&this.lastResizeCenter.y&&(this.DM.data.offsetX=this.DM.data.offsetX+e.x-this.lastResizeCenter.x,this.DM.data.offsetY=this.DM.data.offsetY+e.y-this.lastResizeCenter.y),this.lastResizeCenter.x=e.x,this.lastResizeCenter.y=e.y,this.onResize(e.width,e.height),this.refresh()})};dispose=()=>{this.animationId&&cancelAnimationFrame(this.animationId),this.resizeAnimationId&&cancelAnimationFrame(this.resizeAnimationId),this.resizeObserver.disconnect()}}const w={markdown:/\.(md|mdx|markdown|txt)$/i,image:/\.(png|jpg|jpeg|gif|svg|webp|avif|bmp|ico|heic|heif)$/i,audio:/\.(mp3|wav|ogg|opus|aac|m4a|flac)$/i,video:/\.(mp4|webm|ogv|mov|m3u8|mpd)$/i},b=["markdown","image","audio","video"];class x extends e{_overlaysLayer=document.createElement("div");overlays={};selectedId=null;aborted=!1;eventListeners={};DM;SM;parse;componentDict={text:(e,t)=>{e.classList.add("JCV-markdown-content");const n=document.createElement("div");n.innerHTML=t,n.classList.add("JCV-parsed-content-wrapper"),e.appendChild(n)},markdown:async(e,t)=>{e.classList.add("JCV-markdown-content");const n=document.createElement("div");let i;n.textContent="Loading...",n.classList.add("JCV-parsed-content-wrapper"),e.appendChild(n);try{const e=await fetch(t),n=await e.text(),s=n.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);i=s?await this.parse(s[2]):await this.parse(n)}catch(s){console.error("[JSON Canvas Viewer] Failed to load markdown:",s),i="Failed to load content."}n.innerHTML=i},link:(e,t)=>{const n=document.createElement("iframe");n.src=t,n.sandbox="allow-scripts allow-same-origin",n.className="JCV-link-iframe",n.loading="lazy",e.appendChild(n)},audio:(e,t)=>{const n=document.createElement("audio");n.className="JCV-audio",n.src=t,n.controls=!0,e.appendChild(n)},image:(e,t)=>{const n=document.createElement("img");n.className="JCV-img",n.src=t,n.loading="lazy",e.appendChild(n)},video:(e,t)=>{const n=document.createElement("video");n.className="JCV-video",n.src=t,n.controls=!0,e.appendChild(n)}};get overlaysLayer(){if(!this._overlaysLayer)throw n;return this._overlaysLayer}onInteractionStart=t.makeHook();onInteractionEnd=t.makeHook();onNodeActive=t.makeHook();onNodeLosesActive=t.makeHook();constructor(...e){super(...e),this.parse=this.options.parser||(e=>e),this.DM=this.container.get(i),this.SM=this.container.get(g);this.container.get(f).onRefresh.subscribe(this.updateOverlays),this.SM.onChangeTheme.subscribe(this.themeChanged),this._overlaysLayer=document.createElement("div"),this._overlaysLayer.className="JCV-overlays",this._overlaysLayer.id="overlays",this.DM.data.container.appendChild(this.overlaysLayer);const t=this.options.nodeComponents;t&&Object.assign(this.componentDict,t),this.augment({onNodeActive:this.onNodeActive,onNodeLosesActive:this.onNodeLosesActive}),this.onStart(this.start),this.onRestart(this.restart),this.onDispose(this.dispose)}start=()=>{this.container.get(J).onClick.subscribe(this.select),this.renderOverlays()};restart=()=>{this.clearOverlays(),this.renderOverlays()};renderOverlays=()=>{const e=async e=>{switch(e.type){case"text":this.createOverlay(e,await this.parse(e.text),"text");break;case"file":for(const t of b)if(e.file.match(w[t])){this.createOverlay(e,e.file,t);break}break;case"link":this.createOverlay(e,e.url,"link")}};Object.values(this.DM.data.nodeMap).forEach(async t=>{await e(t.ref)})};themeChanged=()=>{Object.values(this.overlays).forEach(e=>{const t=this.DM.data.nodeMap[e.id].ref,n=this.SM.getColor(t.color);this.setOverlayColor(e,n)})};select=e=>{const t=this.selectedId,n=t?this.overlays[t]:null,i=e?this.overlays[e]:null;if(n&&t){n.classList.remove("JCV-active");const e=this.DM.data.nodeMap[t];this.onNodeLosesActive(e.ref),e.onLoseActive?.()}if(i&&e){i.classList.add("JCV-active"),this.onInteractionStart();const t=this.DM.data.nodeMap[e];this.onNodeActive(t.ref),t.onActive?.()}else this.onInteractionEnd();this.selectedId=e};updateOverlays=()=>{const e=this.DM.data;this.overlaysLayer.style.transform=`translate(${e.offsetX}px, ${e.offsetY}px) scale(${e.scale})`};createOverlay=(...e)=>{if(this.aborted)return;const t=e[0];let n=this.overlays[t.id];if(!n){if(n=this.constructOverlay(...e),this.aborted)return;this.overlaysLayer.appendChild(n),this.overlays[t.id]=n,n.style.left=`${t.x}px`,n.style.top=`${t.y}px`,n.style.width=`${t.width}px`,n.style.height=`${t.height}px`}};constructOverlay=(...e)=>{const n=e[0],i=document.createElement("div");i.classList.add("JCV-overlay-container"),i.id=n.id,this.setOverlayColor(i,this.SM.getColor(n.color));const s=document.createElement("div");s.classList.add("JCV-content"),i.appendChild(s);const r=document.createElement("div");r.className="JCV-click-layer",i.appendChild(r);const o=document.createElement("div");o.className="JCV-overlay-border",i.appendChild(o);const a=this.DM.data.nodeMap[n.id];a.onActive=t.makeHook(),a.onLoseActive=t.makeHook(),a.onBeforeUnmount=t.makeHook(),this.componentDict[e[2]](s,e[1],e[0],a.onBeforeUnmount,a.onActive,a.onLoseActive);const l=()=>{n.id===this.selectedId&&this.onInteractionStart()},c=()=>{n.id===this.selectedId&&this.onInteractionEnd()};return i.addEventListener("pointerenter",l),i.addEventListener("pointerleave",c),i.addEventListener("touchstart",l),i.addEventListener("touchend",c),this.eventListeners[n.id]=[l,c],i};setOverlayColor=(e,t)=>{Object.entries(t).forEach(([t,n])=>{e.style.setProperty(`--overlay-${t}`,n)})};clearOverlays=()=>{Object.entries(this.overlays).forEach(([e,t])=>{if(this.DM.data.nodeMap[e].onBeforeUnmount?.(),this.eventListeners[e]){const i=this.eventListeners[e][0],s=this.eventListeners[e][1];if(!i||!s)throw n;t.removeEventListener("pointerenter",i),t.removeEventListener("pointerleave",s),t.removeEventListener("touchstart",i),t.removeEventListener("touchend",s),this.eventListeners[e][0]=null,this.eventListeners[e][1]=null}t.remove(),delete this.overlays[e]})};dispose=()=>{this.aborted=!0,this.clearOverlays(),this.overlaysLayer.remove(),this._overlaysLayer=null}}class v{constructor(e,t,n,i,s){this.window=t,this.pointers=n,this.element=i,this.getNthPointer=e.getNthPointer,this.toTargetCoords=e.toTargetCoords,this.augment=e.augment,this.dispatch=e.dispatch,this.options=s}getNthPointer;toTargetCoords;augment;dispatch;options;onPointerDown;onPointerUp;onPointerMove;onWheel;onStart;onStop;dispose;modifiers}function k(e,t=0){return e[e.length-1-t]}class C extends v{#e=-1/0;#t=0;onPointerDown=(e,t,n)=>{2===n.size&&(this.getNthPointer(0).interrupted=!0,t.interrupted=!0)};onPointerUp=(e,t)=>{if(t.interrupted)return;const n=this.options.moveThreshold??5;if(Math.abs(t.records[0].x-e.clientX)>=n||Math.abs(t.records[0].y-e.clientY)>=n)return;const i=k(t.records).timestamp,s=this.options.clickPreserveTime??400;i-this.#e<=s?this.#t++:this.#t=1,this.#e=i;const r=this.toTargetCoords({x:e.clientX,y:e.clientY});this.dispatch("trueClick",{...r,target:t.target,streak:this.#t})}}class y extends v{onPointerMove=(e,t,n)=>{const i=k(t.records,1);if(1===n.size){const t=e.clientX-i.x,n=e.clientY-i.y;this.dispatch("drag",{deltaX:t,deltaY:n,x:e.clientX,y:e.clientY})}}}class S extends v{#n={lastDistance:0,lastMidpoint:{x:0,y:0}};#i(){const e=k(this.getNthPointer(0).records),t=k(this.getNthPointer(1).records),n=e.x-t.x,i=e.y-t.y;return Math.sqrt(n*n+i*i)}#s(){const e=k(this.getNthPointer(0).records),t=k(this.getNthPointer(1).records);return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}onPointerDown=(e,t,n)=>{2===n.size&&(this.#n.lastDistance=this.#i(),this.#n.lastMidpoint=this.toTargetCoords(this.#s()))};onPointerMove=(e,t,n)=>{if(2===n.size){const e=this.#i(),t=this.#s(),n=e/this.#n.lastDistance;this.#n.lastDistance=e;const i=this.toTargetCoords(t),s=i.x-this.#n.lastMidpoint.x,r=i.y-this.#n.lastMidpoint.y;this.#n.lastMidpoint=i,this.#r({deltaX:s,deltaY:r}),this.#o(n,i)}};#o(e,t){this.dispatch("zoom",{x:t.x,y:t.y,factor:e})}#r(e){this.dispatch("pan",e)}}class T extends v{onWheel=e=>e.preventDefault();#a=e=>e.preventDefault();onStart=()=>{this.element.style.touchAction="none",this.element.addEventListener("gesturestart",this.#a,{passive:!1}),this.element.addEventListener("gesturechange",this.#a,{passive:!1})};onStop=()=>{this.element.style.touchAction="",this.element.removeEventListener("gesturestart",this.#a),this.element.removeEventListener("gesturechange",this.#a)};dispose=this.onStop}class E extends v{constructor(...e){super(...e),function(e,t){for(const[n,i]of Object.entries({proControlSchema:!1,zoomFactor:.1,lockControlSchema:!1}))n in t||(t[n]=i)}(0,this.options)}onWheel=e=>{const t=this.options;if(t.proControlSchema||t.lockControlSchema||!(e.ctrlKey||e.shiftKey||Math.abs(e.deltaX)>Math.abs(e.deltaY))||(t.proControlSchema=!0),t.proControlSchema)if(e.ctrlKey){const n=1-t.zoomFactor*e.deltaY,i=this.toTargetCoords({x:e.clientX,y:e.clientY});this.#o(n,i)}else e.shiftKey&&Math.abs(e.deltaX)<=Math.abs(e.deltaY)?this.#r({deltaX:-e.deltaY,deltaY:-e.deltaX}):this.#r({deltaX:-e.deltaX,deltaY:-e.deltaY});else{const n=1-t.zoomFactor/20*e.deltaY,i=this.toTargetCoords({x:e.clientX,y:e.clientY});this.#o(n,i)}};#o(e,t){this.dispatch("zoom",{x:t.x,y:t.y,factor:e})}#r(e){this.dispatch("pan",e)}}class M extends v{#l={};#c=null;constructor(...e){super(...e);const t=this.options.lubricator;t&&Object.entries(t).forEach(([e,t])=>{const n={sample:{},fields:{}};Object.keys(t.fields).forEach(e=>{n.fields[e]={catch:1,release:1}}),this.#l[e]=n,this.modifiers[e]=this.#h(n,t)})}onStart=()=>{this.#c=requestAnimationFrame(this.#p)};onStop=()=>{this.#c&&cancelAnimationFrame(this.#c),this.#c=null,Object.values(this.#l).forEach(e=>{Object.values(e.fields).forEach(e=>{e.release=1,e.catch=1})})};#h=(e,t)=>n=>!!n.lubricated||(e.sample=n,this.#d(e.fields,t.fields,n),!1);#d=(e,t,n)=>{Object.entries(e).forEach(([e,i])=>{if("number"!=typeof n[e])return;const s=t[e].countType;"sum"===s?i.catch+=n[e]:"product"===s&&(i.catch*=n[e])})};#p=()=>{const e=this.#l,t=this.options.lubricator;t&&(Object.entries(e).forEach(([e,n])=>{const i=n.sample;i.lubricated=!0;let s=!1;for(const[r,o]of Object.entries(n.fields)){if(1===o.catch)continue;const n=t[e].fields[r].countType;let a,l,c;"sum"===n?(l=o.catch-o.release,a=Math.abs(l)):(l=o.catch/o.release,a=this.#u(l)-1),a<=t[e].fields[r].diminishBoundary?(s||(s=!0),i[r]=l,o.release=1,o.catch=1):("sum"===n?(c=l*t[e].decayFactor,o.release+=c):(c=Math.pow(l,t[e].decayFactor),o.release*=c),i[r]=c,s=!0)}s&&this.dispatch(e,i)}),this.#c=requestAnimationFrame(this.#p))};#u=e=>e>1?e:1/e;modifiers={}}const V={decayFactor:.25,fields:{deltaX:{countType:"sum",diminishBoundary:.5},deltaY:{countType:"sum",diminishBoundary:.5}}},_=V,N={decayFactor:.25,fields:{factor:{countType:"product",diminishBoundary:.01}}};class O{#m;#g=/* @__PURE__ */new Map;#f={};#w={};#b;#x={};options;get#v(){if(!this.#b)throw new Error("[Pointeract] Window is not defined.");return this.#b}constructor(e,t){const n=t||[];this.#b=e.element.ownerDocument.defaultView,this.#m=e.element,e.coordinateOutput||(e.coordinateOutput="relative"),this.options=e,n.forEach(t=>{const n=new t(this.moduleUtils,this.#v,this.#g,this.#m,this.options);Object.assign(n,{options:e}),this.#f[t.name]=n})}on=(e,t)=>(this.#x[e]||(this.#x[e]=/* @__PURE__ */new Set),this.#x[e]?.add(t),this);off(e,t){return this.#x[e]?.delete(t),this}moduleUtils={getNthPointer:e=>{const t=new Error("[Pointeract] Invalid pointer index.");if(e<0||e>=this.#g.size)throw t;let n=0;for(const i of this.#g.values()){if(n===e)return i;n++}throw t},toTargetCoords:e=>{if("absolute"===this.options.coordinateOutput)return e;const t=this.#m.getBoundingClientRect();return e.x-=t.left,e.y-=t.top,"relative"===this.options.coordinateOutput||(e.x/=t.width,e.y/=t.height),e},dispatch:(...e)=>{const t=e[0],n=e[1];let i,s=!0;for(const r of Object.values(this.#f))if(r.modifiers&&t in r.modifiers&&(s=void 0===n?r.modifiers[t]():r.modifiers[t](n),!1===s))return;i=!0===s?n:s,this.#x[t]?.forEach(e=>e(i))},augment:e=>{Object.entries(e).forEach(([e,t])=>this[e]=t)}};dispatch=this.moduleUtils.dispatch;#k(e,...t){Object.values(this.#f).forEach(n=>{const i=n[e];i&&i(...t)})}#C=e=>{if(this.#g.size>=2)return;e.isPrimary&&this.#g.clear();const t={records:[{x:e.clientX,y:e.clientY,timestamp:Date.now()}],target:e.target};this.#g.set(e.pointerId,t),this.#k("onPointerDown",e,t,this.#g)};#y=e=>{const t=this.#g.get(e.pointerId);t&&(t.records.push({x:e.clientX,y:e.clientY,timestamp:Date.now()}),this.#k("onPointerMove",e,t,this.#g))};#S=e=>{const t=this.#g.get(e.pointerId);t&&(this.#g.delete(e.pointerId),this.#k("onPointerUp",e,t,this.#g))};#T=e=>this.#k("onWheel",e);stop=e=>{const t=e=>{if(!(e.name in this.#f))return;const t=this.#f[e.name];t.onStop&&t.onStop(),this.#w[e.name]=t,delete this.#f[e.name]};return e?e.forEach(e=>{t(e)}):(()=>{this.#m.removeEventListener("pointerdown",this.#C),this.#v.removeEventListener("pointermove",this.#y),this.#v.removeEventListener("pointerup",this.#S),this.#m.removeEventListener("wheel",this.#T),this.#k("onStop")})(),this};start=e=>{const t=e=>{if(!(e.name in this.#w))return;const t=this.#w[e.name];t.onStart&&t.onStart(),this.#f[e.name]=t,delete this.#w[e.name]};return e?e.forEach(e=>{t(e)}):(()=>{this.#m.addEventListener("pointerdown",this.#C),this.#v.addEventListener("pointermove",this.#y),this.#v.addEventListener("pointerup",this.#S),this.#m.addEventListener("wheel",this.#T,{passive:!1}),this.#k("onStart")})(),this};dispose=()=>{this.stop(),this.#b=null,this.#k("dispose"),this.#x={}}}class J extends e{pointeract;DM;onClick=t.makeHook();constructor(...e){super(...e),this.DM=this.container.get(i);const t=Object.assign(this.options.pointeract??{},{coordinateOutput:"relative",element:this.DM.data.container,lubricator:{pan:V,zoom:N,drag:_}});this.pointeract=new O(t,[C,y,E,T,S,M]);const n=this.container.get(x);n.onInteractionStart.subscribe(this.stopInteract),n.onInteractionEnd.subscribe(this.startInteract),this.augment({pan:this.pan,panToCoords:this.panToCoords,zoom:this.zoom,zoomToScale:this.zoomToScale}),this.onStart(this.start),this.onDispose(this.dispose)}start=()=>{this.pointeract.on("pan",this.onPan).on("drag",this.onPan).on("zoom",this.onZoom).on("trueClick",this.onTrueClick).start()};startInteract=()=>{this.pointeract.start()};stopInteract=()=>{this.pointeract.stop()};onPan=e=>{this.truePan({x:e.deltaX,y:e.deltaY})};onZoom=e=>{this.trueZoom(e.factor,e)};trueZoom=(e,t)=>{const n=Math.max(Math.min(this.DM.data.scale*e,20),.05);if(n===this.DM.data.scale)return;const i=n/this.DM.data.scale,s=this.C2C(t);this.DM.data.offsetX=t.x-s.x*i,this.DM.data.offsetY=t.y-s.y*i,this.DM.data.scale=n};truePan=({x:e,y:t})=>{this.DM.data.offsetX=this.DM.data.offsetX+e,this.DM.data.offsetY=this.DM.data.offsetY+t};zoom=(e,t)=>{this.pointeract.dispatch("zoom",{factor:e,...t})};pan=({x:e,y:t})=>{this.pointeract.dispatch("pan",{deltaX:e,deltaY:t})};zoomToScale=(e,t)=>{const n=e/this.DM.data.scale;this.pointeract.dispatch("zoom",{factor:n,...t})};panToCoords=({x:e,y:t})=>{this.pointeract.dispatch("pan",{deltaX:e-this.DM.data.offsetX,deltaY:t-this.DM.data.offsetY})};C2C=({x:e,y:t})=>({x:e-this.DM.data.offsetX,y:t-this.DM.data.offsetY});onTrueClick=e=>{const t=e.target;if(this.isUIControl(t))return;const n=this.findNodeId(t);this.onClick(n)};isUIControl=e=>!!e&&(e.closest(".controls")||e.closest("button")||e.closest("input"));findNodeId=e=>{if(!e)return null;let t=e;for(;(!t.id||""===t.id)&&t.parentElement;)t=t.parentElement;return"overlays"!==t.id&&t.id&&""!==t.id?t.id:null};dispose=()=>this.pointeract.dispose()}const R='<svg viewBox="-5.28 -5.28 34.56 34.56" fill="none"><path d="M4 9V5.6c0-.56 0-.84.109-1.054a1 1 0 0 1 .437-.437C4.76 4 5.04 4 5.6 4H9M4 15v3.4c0 .56 0 .84.109 1.054a1 1 0 0 0 .437.437C4.76 20 5.04 20 5.6 20H9m6-16h3.4c.56 0 .84 0 1.054.109a1 1 0 0 1 .437.437C20 4.76 20 5.04 20 5.6V9m0 6v3.4c0 .56 0 .84-.109 1.054a1 1 0 0 1-.437.437C19.24 20 18.96 20 18.4 20H15" stroke-width="2.4" stroke-linecap="round"/></svg>';class A extends e{_controlsPanel=null;_toggleCollapseBtn=null;_toggleFullscreenBtn=null;_zoomOutBtn=null;_zoomSlider=null;_zoomInBtn=null;_resetViewBtn=null;DM;IH;collapsed;get controlsPanel(){if(null===this._controlsPanel)throw n;return this._controlsPanel}get toggleCollapseBtn(){if(null===this._toggleCollapseBtn)throw n;return this._toggleCollapseBtn}get toggleFullscreenBtn(){if(null===this._toggleFullscreenBtn)throw n;return this._toggleFullscreenBtn}get zoomOutBtn(){if(null===this._zoomOutBtn)throw n;return this._zoomOutBtn}get zoomSlider(){if(null===this._zoomSlider)throw n;return this._zoomSlider}get zoomInBtn(){if(null===this._zoomInBtn)throw n;return this._zoomInBtn}get resetViewBtn(){if(null===this._resetViewBtn)throw n;return this._resetViewBtn}constructor(...e){super(...e),this.collapsed=this.options.controlsCollapsed??!1,this.DM=this.container.get(i),this.IH=this.container.get(J),this.DM.onToggleFullscreen.subscribe(this.updateFullscreenBtn),this.container.get(f).onRefresh.subscribe(this.updateSlider),this._controlsPanel=document.createElement("div"),this._controlsPanel.className="JCV-controls",this._controlsPanel.classList.toggle("JCV-collapsed",this.collapsed),t.applyStyles(this._controlsPanel,".JSON-Canvas-Viewer>.JCV-controls{position:absolute;top:10px;right:10px;display:flex;align-items:center;transition:transform .2s;border-radius:8px;gap:10px}.JSON-Canvas-Viewer>.JCV-controls.JCV-collapsed{transform:translate(calc(100% - 30px))}.JSON-Canvas-Viewer>.JCV-controls .JCV-controls-content{display:flex;gap:1px;align-items:center;border-radius:8px;overflow:hidden;background:var(--border);box-shadow:var(--shadow);outline:1px solid var(--border)}.JSON-Canvas-Viewer>.JCV-controls .JCV-zoom-slider{width:100px;margin:0 10px}"),this._toggleCollapseBtn=document.createElement("button"),this._toggleCollapseBtn.className="JCV-button JCV-collapse-button JCV-border-shadow-bg",this._toggleCollapseBtn.innerHTML='<svg viewBox="-3.6 -3.6 31.2 31.2" stroke-width=".4"><path d="M15.707 4.293a1 1 0 0 1 0 1.414L9.414 12l6.293 6.293a1 1 0 0 1-1.414 1.414l-7-7a1 1 0 0 1 0-1.414l7-7a1 1 0 0 1 1.414 0Z" /></svg>',this._controlsPanel.appendChild(this._toggleCollapseBtn);const n=document.createElement("div");n.className="JCV-controls-content",this._toggleFullscreenBtn=document.createElement("button"),this._toggleFullscreenBtn.className="JCV-button",this._toggleFullscreenBtn.innerHTML=R,n.appendChild(this._toggleFullscreenBtn),this._zoomOutBtn=document.createElement("button"),this.zoomOutBtn.className="JCV-button",this._zoomOutBtn.innerHTML='<svg viewBox="-1.2 -1.2 26.4 26.4"><path d="M6 12h12" stroke-width="2" stroke-linecap="round" /></svg>',n.appendChild(this._zoomOutBtn),this._zoomSlider=document.createElement("input"),this._zoomSlider.type="range",this._zoomSlider.className="JCV-zoom-slider",this._zoomSlider.min="-30",this._zoomSlider.max="30",this._zoomSlider.value="0",n.appendChild(this._zoomSlider),this._zoomInBtn=document.createElement("button"),this._zoomInBtn.className="JCV-button",this._zoomInBtn.innerHTML='<svg viewBox="-1.2 -1.2 26.4 26.4"><path d="M6 12h12m-6-6v12" stroke-width="2" stroke-linecap="round" /></svg>',n.appendChild(this._zoomInBtn),this._resetViewBtn=document.createElement("button"),this._resetViewBtn.className="JCV-button",this._resetViewBtn.innerHTML='<svg viewBox="-6 -6 30 30" stroke-width=".08"><path d="m14.955 7.986.116.01a1 1 0 0 1 .85 1.13 8 8 0 0 1-13.374 4.728l-.84.84c-.63.63-1.707.184-1.707-.707V10h3.987c.89 0 1.337 1.077.707 1.707l-.731.731a6 6 0 0 0 8.347-.264 6 6 0 0 0 1.63-3.33 1 1 0 0 1 1.131-.848zM11.514.813a8 8 0 0 1 1.942 1.336l.837-.837c.63-.63 1.707-.184 1.707.707V6h-3.981c-.89 0-1.337-1.077-.707-1.707l.728-.729a6 6 0 0 0-9.98 3.591 1 1 0 1 1-1.98-.281A8 8 0 0 1 11.514.813Z" /></svg>',n.appendChild(this._resetViewBtn),this._controlsPanel.appendChild(n),this.DM.data.container.appendChild(this._controlsPanel),this._toggleCollapseBtn.addEventListener("click",this.toggleCollapse),this._zoomInBtn.addEventListener("click",this.zoomIn),this._zoomOutBtn.addEventListener("click",this.zoomOut),this._zoomSlider.addEventListener("input",this.slide),this._resetViewBtn.addEventListener("click",this.DM.resetView),this._toggleFullscreenBtn.addEventListener("click",this.toggleFullscreen),this.augment({toggleControlsCollapse:this.toggleCollapse}),this.onDispose(this.dispose)}toggleCollapse=()=>{this.collapsed=!this.collapsed,this.controlsPanel.classList.toggle("JCV-collapsed",this.collapsed),this.collapsed||this.updateSlider()};zoomIn=()=>this.IH.zoom(1.3,this.DM.middleViewer());zoomOut=()=>this.IH.zoom(1/1.3,this.DM.middleViewer());slide=()=>this.IH.trueZoom(1.1**Number(this.zoomSlider.value)/this.DM.data.scale,this.DM.middleViewer());updateFullscreenBtn=e=>{this.toggleFullscreenBtn.innerHTML="enter"===e?'<svg viewBox="-40.32 -40.32 176.64 176.64"><path d="M30 60H6a6 6 0 0 0 0 12h18v18a6 6 0 0 0 12 0V66a5.997 5.997 0 0 0-6-6Zm60 0H66a5.997 5.997 0 0 0-6 6v24a6 6 0 0 0 12 0V72h18a6 6 0 0 0 0-12ZM66 36h24a6 6 0 0 0 0-12H72V6a6 6 0 0 0-12 0v24a5.997 5.997 0 0 0 6 6ZM30 0a5.997 5.997 0 0 0-6 6v18H6a6 6 0 0 0 0 12h24a5.997 5.997 0 0 0 6-6V6a5.997 5.997 0 0 0-6-6Z"/></svg>':R};toggleFullscreen=()=>this.DM.toggleFullscreen();updateSlider=()=>{this.collapsed||(this.zoomSlider.value=String(this.scaleToSlider(this.DM.data.scale)))};scaleToSlider=e=>Math.log(e)/Math.log(1.1);dispose=()=>{this.toggleCollapseBtn.removeEventListener("click",this.toggleCollapse),this.zoomInBtn.removeEventListener("click",this.zoomIn),this.zoomOutBtn.removeEventListener("click",this.zoomOut),this.zoomSlider.removeEventListener("input",this.slide),this.resetViewBtn.removeEventListener("click",this.DM.resetView),this.toggleFullscreenBtn.removeEventListener("click",this.toggleFullscreen),this.controlsPanel.remove(),this._controlsPanel=null,this._toggleCollapseBtn=null,this._zoomInBtn=null,this._zoomOutBtn=null,this._zoomSlider=null,this._resetViewBtn=null,this._toggleFullscreenBtn=null}}class z extends e{_debugPanel=null;DM;get debugPanel(){if(!this._debugPanel)throw n;return this._debugPanel}constructor(...e){super(...e),this.DM=this.container.get(i),this.container.get(f).onRefresh.subscribe(this.update),this._debugPanel=document.createElement("div"),this._debugPanel.className="JCV-debug-panel JCV-border-shadow-bg";const n=this.DM.data.container;t.applyStyles(n,".JSON-Canvas-Viewer>.JCV-debug-panel{position:absolute;bottom:12px;left:12px;border-radius:12px;padding:12px;color:var(--text);font-size:calc(14px + .3vw);line-height:calc(17px + .3vw);pointer-events:none}"),n.appendChild(this._debugPanel),this.onDispose(this.dispose)}update=()=>{const e=t.round,n=this.DM.data;this.debugPanel.innerHTML=`<p>Scale: ${e(n.scale,3)}</p><p>Offset: ${e(n.offsetX,1)}, ${e(n.offsetY,1)}</p>`};dispose=()=>{this.debugPanel.remove(),this._debugPanel=null}}class D extends e{_minimapCtx=null;_viewportRectangle=null;_minimap=null;_minimapContainer=null;_toggleMinimapBtn=null;minimapCache={scale:1,centerX:0,centerY:0};DM;SM;collapsed;get minimap(){if(null===this._minimap)throw n;return this._minimap}get minimapCtx(){if(null===this._minimapCtx)throw n;return this._minimapCtx}get viewportRectangle(){if(null===this._viewportRectangle)throw n;return this._viewportRectangle}get minimapContainer(){if(null===this._minimapContainer)throw n;return this._minimapContainer}get toggleMinimapBtn(){if(null===this._toggleMinimapBtn)throw n;return this._toggleMinimapBtn}constructor(...e){super(...e),this.collapsed=this.options.minimapCollapsed??!1,this.container.get(f).onRefresh.subscribe(this.updateViewportRectangle),this.DM=this.container.get(i),this.SM=this.container.get(g),this._minimapContainer=document.createElement("div"),this._minimapContainer.className="JCV-minimap-container",t.applyStyles(this._minimapContainer,".JSON-Canvas-Viewer>.JCV-minimap-container{position:absolute;bottom:10px;right:10px;display:flex;pointer-events:none;transition:transform .2s}.JSON-Canvas-Viewer>.JCV-minimap-container.JCV-collapsed{transform:translate(calc(100% - 30px))}.JSON-Canvas-Viewer>.JCV-minimap-container .JCV-toggle-minimap{margin:auto 10px 0 0;pointer-events:auto}.JSON-Canvas-Viewer>.JCV-minimap-container .JCV-minimap{position:relative;pointer-events:none;width:200px;height:150px;overflow:hidden;border-radius:12px;transform-origin:0 0}.JSON-Canvas-Viewer>.JCV-minimap-container .JCV-minimap .JCV-minimap-canvas{width:100%;height:100%}.JSON-Canvas-Viewer>.JCV-minimap-container .JCV-minimap .JCV-viewport-rectangle{position:absolute;top:0;left:0;pointer-events:none;border-radius:6px;box-sizing:border-box;border:2px dashed var(--text)}@container (max-width: 768px){.JSON-Canvas-Viewer>.JCV-minimap-container .JCV-container .JCV-minimap{transform:scale(.6)}.JSON-Canvas-Viewer>.JCV-minimap-container .JCV-container .JCV-toggle-minimap{transform:translateY(-60px)}.collapsed .JSON-Canvas-Viewer>.JCV-minimap-container .JCV-container .JCV-toggle-minimap{transform:translateY(-60px) rotate(180deg)}.JSON-Canvas-Viewer>.JCV-minimap-container .JCV-container .JCV-minimap-container{transform:translateY(60px) translate(80px)}.JSON-Canvas-Viewer>.JCV-minimap-container .JCV-container .JCV-minimap-container.JCV-collapsed{transform:translateY(60px) translate(calc(100% - 32px))}}"),this._toggleMinimapBtn=document.createElement("button"),this._toggleMinimapBtn.className="JCV-button JCV-toggle-minimap JCV-collapse-button JCV-border-shadow-bg",this._toggleMinimapBtn.innerHTML='<svg viewBox="-3.6 -3.6 31.2 31.2" stroke-width=".4"><path d="M15.707 4.293a1 1 0 0 1 0 1.414L9.414 12l6.293 6.293a1 1 0 0 1-1.414 1.414l-7-7a1 1 0 0 1 0-1.414l7-7a1 1 0 0 1 1.414 0Z" /></svg>',this._minimapContainer.appendChild(this._toggleMinimapBtn),this._minimap=document.createElement("div"),this._minimap.className="JCV-minimap JCV-border-shadow-bg";const n=document.createElement("canvas");n.className="JCV-minimap-canvas",n.width=200,n.height=150,this._minimap.appendChild(n),this._minimapCtx=n.getContext("2d"),this._viewportRectangle=document.createElement("div"),this._viewportRectangle.className="JCV-viewport-rectangle",this._minimap.appendChild(this._viewportRectangle),this._minimapContainer.appendChild(this._minimap),this.DM.data.container.appendChild(this._minimapContainer),this._minimapContainer.classList.toggle("JCV-collapsed",this.collapsed),this._toggleMinimapBtn.addEventListener("click",this.toggleCollapse),t.resizeCanvasForDPR(n,n.width,n.height),this.augment({toggleMinimapCollapse:this.toggleCollapse}),this.onStart(this.start),this.onRestart(this.start),this.onDispose(this.dispose)}toggleCollapse=()=>{this.collapsed=!this.collapsed,this.minimapContainer.classList.toggle("JCV-collapsed",this.collapsed),this.collapsed||this.updateViewportRectangle()};start=()=>{const e=this.DM.data.nodeBounds;if(!e)return;const t=this.minimap.clientWidth,n=this.minimap.clientHeight,i=t/e.width,s=n/e.height;this.minimapCache.scale=.9*Math.min(i,s),this.minimapCache.centerX=t/2,this.minimapCache.centerY=n/2,this.minimapCtx.clearRect(0,0,t,n),this.minimapCtx.save(),this.minimapCtx.translate(this.minimapCache.centerX,this.minimapCache.centerY),this.minimapCtx.scale(this.minimapCache.scale,this.minimapCache.scale),this.minimapCtx.translate(-e.centerX,-e.centerY);const r=this.DM.data.canvasData;for(const o of r.edges)this.drawMinimapEdge(o);for(const o of r.nodes)this.drawMinimapNode(o);this.minimapCtx.restore()};drawMinimapNode=e=>{const n=this.SM.getColor(e.color);this.minimapCtx.fillStyle=n.border,t.drawRoundRect(this.minimapCtx,e.x,e.y,e.width,e.height,25),this.minimapCtx.fill()};drawMinimapEdge=e=>{const n=this.DM.data.nodeMap,i=n[e.fromNode].ref,s=n[e.toNode].ref;if(!i||!s)return;const{x:r,y:o}=t.getAnchorCoord(i,e.fromSide),{x:a,y:l}=t.getAnchorCoord(s,e.toSide);this.minimapCtx.beginPath(),this.minimapCtx.moveTo(r,o),this.minimapCtx.lineTo(a,l),this.minimapCtx.strokeStyle=this.SM.getColor(e.color).active,this.minimapCtx.lineWidth=10,this.minimapCtx.stroke()};updateViewportRectangle=()=>{if(this.collapsed)return;const e=this.DM.data.nodeBounds,t=this.DM.data.container,n=this.DM.data.scale;if(!e)return;const i=t.clientWidth/n,s=t.clientHeight/n,r=-this.DM.data.offsetX/n+t.clientWidth/(2*n),o=-this.DM.data.offsetY/n+t.clientHeight/(2*n),a=this.minimapCache.centerX+(r-i/2-e.centerX)*this.minimapCache.scale,l=this.minimapCache.centerY+(o-s/2-e.centerY)*this.minimapCache.scale,c=i*this.minimapCache.scale,h=s*this.minimapCache.scale;this.viewportRectangle.style.left=`${a}px`,this.viewportRectangle.style.top=`${l}px`,this.viewportRectangle.style.width=`${c}px`,this.viewportRectangle.style.height=`${h}px`};dispose=()=>{this.toggleMinimapBtn.removeEventListener("click",this.toggleCollapse),this.minimapCtx.clearRect(0,0,this.minimap.clientWidth,this.minimap.clientHeight),this.minimapContainer.remove(),this._minimapContainer=null,this._toggleMinimapBtn=null,this._viewportRectangle=null,this._minimap=null}}class I extends e{_preventionContainer=null;preventMt=!1;DM;preventMistouch={record:!1,lastX:0,lastY:0,initialX:0,initialY:0};get preventionContainer(){if(null===this._preventionContainer)throw n;return this._preventionContainer}constructor(...e){super(...e);const n=document.createElement("div");n.className="JCV-prevention-banner JCV-border-shadow-bg",n.textContent=this.options.mistouchPreventerBannerText??"Click on to unlock.",this.DM=this.container.get(i),this._preventionContainer=document.createElement("div"),this._preventionContainer.className="JCV-prevention-container JCV-hidden JCV-full JCV-flex-center",t.applyStyles(this._preventionContainer,".JSON-Canvas-Viewer.JCV-numb,.JSON-Canvas-Viewer.JCV-numb *{pointer-events:none!important}.JSON-Canvas-Viewer .JCV-prevention-container{overflow:visible;transition:background .2s,opacity .2s,box-shadow .2s,border .2s,filter .2s,backdrop-filter .2s}.JSON-Canvas-Viewer .JCV-prevention-container.JCV-hidden{pointer-events:none;opacity:0}.JSON-Canvas-Viewer .JCV-prevention-container .JCV-prevention-banner{border-radius:12px;padding:12px;margin:12px;font-size:calc(14px + .3vw);line-height:calc(17px + .3vw);text-align:center}"),this._preventionContainer.appendChild(n),this.DM.data.container.appendChild(this._preventionContainer),this.options.preventMistouchAtStart&&this.startPrevention(),window.addEventListener("pointerdown",this.onPointerDown),window.addEventListener("pointermove",this.onPointerMove),window.addEventListener("pointerup",this.onPointerUp),this.augment({startMistouchPrevention:this.startPrevention,endMistouchPrevention:this.endPrevention}),this.onDispose(this.dispose)}onPointerDown=e=>{const t=this.DM.data.container.getBoundingClientRect();e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom?this.preventMt||this.startPrevention():this.preventMt&&(this.preventMistouch.initialX=e.clientX,this.preventMistouch.initialY=e.clientY,this.preventMistouch.lastX=e.clientX,this.preventMistouch.lastY=e.clientY,this.preventMistouch.record=!0)};onPointerMove=e=>{this.preventMistouch.record&&(this.preventMistouch.lastX=e.clientX,this.preventMistouch.lastY=e.clientY)};onPointerUp=()=>{this.preventMistouch.record&&(this.preventMistouch.record=!1,Math.abs(this.preventMistouch.lastX-this.preventMistouch.initialX)+Math.abs(this.preventMistouch.lastY-this.preventMistouch.initialY)<5&&this.endPrevention())};startPrevention=()=>{this.preventionContainer.classList.remove("JCV-hidden"),this.DM.data.container.classList.add("JCV-numb"),this.preventMt=!0};endPrevention=()=>{this.preventMt=!1,this.preventionContainer.classList.add("JCV-hidden"),setTimeout(()=>this.DM.data.container.classList.remove("JCV-numb"),50)};dispose=()=>{window.removeEventListener("pointerdown",this.onPointerDown),window.removeEventListener("pointermove",this.onPointerMove),window.removeEventListener("pointerup",this.onPointerUp),this.preventionContainer.remove(),this._preventionContainer=null}}function L(e){return"function"==typeof e}function P(e){const t=[];let n=e;for(;Object.getPrototypeOf(n).name;){const e=Object.getPrototypeOf(n);t.push(e),n=e}return t}function B(e){if(null==e)throw Error("Expected value to be not null or undefined");return e}function $(e,t){if(e.length>1)throw t();const n=e.at(0);if(void 0===n)throw t();return n}function F(e){return L(e)}function H(e){return"provide"in e&&"useClass"in e}function Y(e){return"provide"in e&&"useFactory"in e}function j(e){return Y(e)&&!0===e.async}function X(e){return"provide"in e&&"useExisting"in e}function U(e){return"provide"in e&&"multi"in e&&!0===e.multi}class q{description;options;constructor(e,t){this.description=e,this.options=t}toString(){return`InjectionToken "${String(this.description)}"`}}function W(e){return L(e)}function G(e){return L(e)?e.name:"symbol"==typeof e?e.description??String(e):e instanceof q?e.toString():e}function Z(e){return F(e)?e:e.provide}const Q=/* @__PURE__ */Symbol("injectable");class K{container;underConstruction=[];constructor(e){this.container=e}construct(e,t){if(j(e))throw new ee(t);try{if(this.underConstruction.includes(e)){const t=[...this.underConstruction,e].map(Z).map(G);throw new te(t)}return this.underConstruction.push(e),this.doConstruct(e)}finally{this.underConstruction.pop()}}async constructAsync(e){try{if(this.underConstruction.includes(e)){const t=[...this.underConstruction,e].map(Z).map(G);throw new te(t)}if(this.underConstruction.push(e),j(e))return[await e.useFactory(this.container)];if(H(e)||F(e)){const t=F(e)?()=>[new e]:()=>[new e.useClass];return async function(e,t,n){for(;;)try{return await t()}catch(i){if(!(i instanceof e))throw i;await n(i)}}(ee,async()=>t(),async e=>{await this.container.getAsync(e.token,{multi:!0,optional:!0})})}return X(e)?await this.container.getAsync(e.useExisting,{multi:!0}):this.doConstruct(e)}finally{this.underConstruction.pop()}}doConstruct(e){return F(e)?[new e]:H(e)?[new e.useClass]:function(e){return"provide"in e&&"useValue"in e}(e)?[e.useValue]:Y(e)?[e.useFactory(this.container)]:X(e)?this.container.get(e.useExisting,{multi:!0}):function(){throw new Error("invalid state")}()}}class ee extends Error{token;constructor(e){super(`Some providers for token ${G(e)} are async, please use injectAsync() or container.getAsync() instead`),this.token=e}}class te extends Error{constructor(e){super(`Detected circular dependency: ${e.join(" -> ")}. Please change your dependency graph or use lazy injection instead.`)}}class ne{container;constructor(e){this.container=e}run(e){const t=ie;try{return ie=this,e(this.container)}finally{ie=t}}async runAsync(e){const t=ie;try{return ie=this,await e(this.container)}finally{ie=t}}}let ie=new class{run(){throw new re}runAsync(){throw new re}};function se(e){return new ne(e)}class re extends Error{constructor(){super("You can only invoke inject() or injectAsync() within an injection context")}}class oe{providers=/* @__PURE__ */new Map;singletons=/* @__PURE__ */new Map;parent;factory;constructor(e){this.parent=e,this.factory=new K(this),this.bind({provide:oe,useValue:this})}bindAll(...e){return e.forEach(e=>this.bind(e)),this}bind(e){const t=Z(e);if(X(e)&&e.provide===e.useExisting)throw Error(`The provider for token ${G(t)} with "useExisting" cannot refer to itself.`);if(!X(e)&&this.singletons.has(t))throw Error(`Cannot bind a new provider for ${G(t)}, since the existing provider was already constructed.`);if(X(e)&&U(e)&&this.existingProviderAlreadyProvided(t,e.useExisting))return this;const n=this.providers.get(t)??[],i=U(e);if(i&&n.some(e=>!U(e)))throw Error(`Cannot bind ${G(t)} as multi-provider, since there is already a provider which is not a multi-provider.`);if(!i&&n.some(e=>U(e))&&!n.every(X))throw Error(`Cannot bind ${G(t)} as provider, since there are already provider(s) that are multi-providers.`);return this.providers.set(t,i?[...n,e]:[e]),W(t)&&(H(e)||F(e))&&function(e,t=2){const n=[];return e.some((i,s)=>{if(s+t>e.length)return!0;n.push(e.slice(s,s+t))}),n}([t,...P(t)]).forEach(([e,t])=>{const n={provide:t,useExisting:e,multi:!0},i=this.providers.get(t)??[];this.existingProviderAlreadyProvided(t,e)||this.providers.set(t,[...i,n])}),this}unbind(e){const t=Z(e);return this.providers.delete(t),this.singletons.delete(t),this}unbindAll(){return this.providers.clear(),this.singletons.clear(),this}get(e,t){if(t?.lazy??!1)return()=>this.get(e,{...t,lazy:!1});this.autoBindIfNeeded(e);const n=t?.optional??!1;if(!this.providers.has(e)){if(this.parent)return this.parent.get(e,{...t,lazy:!1});if(n)return;throw Error(`No provider(s) found for ${G(e)}`)}const i=B(this.providers.get(e));this.singletons.has(e)||se(this).run(()=>{const t=i.flatMap(t=>this.factory.construct(t,e));this.singletons.set(e,t)});const s=B(this.singletons.get(e));return t?.multi??!1?s:$(s,()=>Error(`Requesting a single value for ${G(e)}, but multiple values were provided. Consider passing "{ multi: true }" to inject all values, or adjust your bindings accordingly.`))}getAsync(e,t){return t?.lazy??!1?()=>this.getAsync(e,{...t,lazy:!1}):async function(e){return await new Promise(t=>t(e()))}(async()=>{this.autoBindIfNeeded(e);const n=t?.optional??!1;if(!this.providers.has(e)){if(n)return;throw Error(`No provider(s) found for ${G(e)}`)}const i=B(this.providers.get(e));this.singletons.has(e)||await se(this).runAsync(async()=>{const t=await Promise.all(i.map(e=>this.factory.constructAsync(e)));this.singletons.set(e,t.flat())});const s=B(this.singletons.get(e));return t?.multi??!1?s:$(s,()=>new Error(`Requesting a single value for ${G(e)}, but multiple values were provided. Consider passing "{ multi: true }" to inject all values, or adjust your bindings accordingly.`))})}createChild(){return new oe(this)}has(e){return this.providers.has(e)||(this.parent?.has(e)??!1)}autoBindIfNeeded(e){if(!this.singletons.has(e))if(W(e)&&e.hasOwnProperty(Q)){const t=function(e){return e[Q]}(e);t.filter(e=>!this.providers.has(e)).forEach(e=>{this.bind({provide:e,useClass:e,multi:!0})})}else if(!this.providers.has(e)&&function(e){return e instanceof q}(e)&&e.options?.factory){const t=e.options.async;t?t&&this.bind({provide:e,async:!0,useFactory:e.options.factory}):this.bind({provide:e,async:!1,useFactory:e.options.factory})}}existingProviderAlreadyProvided(e,t){return(this.providers.get(e)??[]).some(n=>X(n)&&n.provide===e&&n.useExisting===t)}}const ae=[i,g,f,x,J,class extends e{_canvas;ctx;DM;SM;zoomInOptimize={lastDrawnScale:0,lastDrawnViewport:{left:0,right:0,top:0,bottom:0},timeout:null,lastCallTime:0};get canvas(){if(!this._canvas)throw n;return this._canvas}constructor(...e){super(...e);const t=this.container.get(f);this.SM=this.container.get(g),t.onRefresh.subscribe(this.redraw),t.onResize.subscribe(this.optimizeDPR),this.DM=this.container.get(i),this._canvas=document.createElement("canvas"),this._canvas.className="JCV-main-canvas",this.ctx=this._canvas.getContext("2d"),this.DM.data.container.appendChild(this._canvas),this.onDispose(this.dispose)}optimizeDPR=()=>{const e=this.DM.data.container;t.resizeCanvasForDPR(this.canvas,e.offsetWidth,e.offsetHeight)};redraw=()=>{const e=this.DM.data.offsetX,t=this.DM.data.offsetY,n=this.DM.data.scale,i=this.getCurrentViewport(e,t,n);if(!this.options.zoomInOptimization)return void this.trueRedraw(e,t,n,i);this.zoomInOptimize.timeout&&(clearTimeout(this.zoomInOptimize.timeout),this.zoomInOptimize.timeout=null);const s=Date.now();if(this.isInside(i,this.zoomInOptimize.lastDrawnViewport)&&n!==this.zoomInOptimize.lastDrawnScale){if(s-this.zoomInOptimize.lastCallTime<500)return this.zoomInOptimize.timeout=setTimeout(()=>{this.trueRedraw(e,t,n,i),this.zoomInOptimize.lastCallTime=s,this.zoomInOptimize.timeout=null},60),void this.fakeRedraw(i,n)}this.zoomInOptimize.lastCallTime=s,this.trueRedraw(e,t,n,i)};trueRedraw(e,t,n,i){this.zoomInOptimize.lastDrawnViewport=i,this.zoomInOptimize.lastDrawnScale=n,this.canvas.style.transform="",this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height),this.ctx.save(),this.drawGridDots(n,e,t),this.ctx.translate(e,t),this.ctx.scale(n,n),Object.values(this.DM.data.nodeMap).forEach(e=>{if(this.isOutside(e.box,i))return;const t=e.ref;"file"===t.type?this.drawFile(e):"group"===t.type&&this.drawGroup(t,n)}),Object.values(this.DM.data.edgeMap).forEach(e=>{this.isOutside(e.box,i)||this.drawEdge(e)}),this.ctx.restore()}fakeRedraw(e,t){const n=t/this.zoomInOptimize.lastDrawnScale,i=(this.zoomInOptimize.lastDrawnViewport.left-e.left)*t,s=(this.zoomInOptimize.lastDrawnViewport.top-e.top)*t;this.canvas.style.transform=`translate(${i}px, ${s}px) scale(${n})`}isInside=(e,t)=>e.left>t.left&&e.top>t.top&&e.right<t.right&&e.bottom<t.bottom;isOutside=(e,t)=>e.right<t.left||e.bottom<t.top||e.left>t.right||e.top>t.bottom;getCurrentViewport=(e,t,n)=>{const i=-e/n,s=-t/n,r=this.DM.data.container;return{left:i,top:s,right:i+r.clientWidth/n,bottom:s+r.clientHeight/n}};drawLabelBar=(e,t,n,i,s,r)=>{const o=30*r,a=6*r,l=8*r,c=16*r,h=6*r;this.ctx.save(),this.ctx.translate(e,t),this.ctx.scale(1/r,1/r),this.ctx.font=`${c}px 'Inter', sans-serif`;const p=this.ctx.measureText(n).width+2*h;this.ctx.translate(0,-o-l),this.ctx.fillStyle=i,this.ctx.beginPath(),this.ctx.moveTo(a,0),this.ctx.lineTo(p-a,0),this.ctx.quadraticCurveTo(p,0,p,a),this.ctx.lineTo(p,o-a),this.ctx.quadraticCurveTo(p,o,p-a,o),this.ctx.lineTo(a,o),this.ctx.quadraticCurveTo(0,o,0,o-a),this.ctx.lineTo(0,a),this.ctx.quadraticCurveTo(0,0,a,0),this.ctx.closePath(),this.ctx.fill(),this.ctx.fillStyle=s,this.ctx.fillText(n,h,.65*o),this.ctx.restore()};drawNodeBackground=e=>{const n=this.SM.getColor(e.color);this.ctx.globalAlpha=1,this.ctx.fillStyle=n.background,t.drawRoundRect(this.ctx,e.x+1,e.y+1,e.width-2,e.height-2,12),this.ctx.fill(),this.ctx.strokeStyle=n.border,this.ctx.lineWidth=2,t.drawRoundRect(this.ctx,e.x,e.y,e.width,e.height,12),this.ctx.stroke()};drawGroup=(e,t)=>{if(this.drawNodeBackground(e),e.label){const n=this.SM.getColor(e.color);this.drawLabelBar(e.x,e.y,e.label,n.active,n.text,t)}};drawFile=e=>{this.ctx.fillStyle=this.SM.getColor().text;const t=e.ref;this.ctx.font="16px sans-serif",this.ctx.fillText(e.fileName??"",t.x+5,t.y-10)};drawEdge=e=>{const n=e.ref,i=this.DM.data.nodeMap[n.fromNode].ref,s=this.DM.data.nodeMap[n.toNode].ref,r=t.getAnchorCoord,{x:o,y:a}=r(i,n.fromSide),{x:l,y:c}=r(s,n.toSide),h=this.SM.getColor(n.color);let[p,d,u,m]=[0,0,0,0];if(e.controlPoints?[p,d,u,m]=e.controlPoints:([p,d,u,m]=this.getControlPoints(o,a,l,c,n.fromSide,n.toSide),e.controlPoints=[p,d,u,m]),this.drawCurvedPath(o,a,l,c,p,d,u,m,h.active),this.drawArrowhead(l,c,u,m,h.active),n.label){const e=.5,i=(1-e)**3*o+3*(1-e)**2*e*p+3*(1-e)*e*e*u+e**3*l,s=(1-e)**3*a+3*(1-e)**2*e*d+3*(1-e)*e*e*m+e**3*c;this.ctx.font="18px sans-serif";const r=8,g=this.ctx.measureText(n.label).width+2*r,f=20;this.ctx.fillStyle=h.active,this.ctx.beginPath(),t.drawRoundRect(this.ctx,i-g/2,s-f/2-2,g,f,4),this.ctx.fill(),this.ctx.fillStyle=h.text,this.ctx.textAlign="center",this.ctx.textBaseline="middle",this.ctx.fillText(n.label,i,s-2),this.ctx.textAlign="left",this.ctx.textBaseline="alphabetic"}};getControlPoints=(e,t,n,i,s,r)=>{const o=n-e,a=i-t,l=Math.min(Math.abs(o),Math.abs(a))+.3*Math.max(Math.abs(o),Math.abs(a)),c=(h=.5*l,p=60,d=300,Math.max(p,Math.min(d,h)));var h,p,d;let u=e,m=t,g=n,f=i;switch(s){case"top":m=t-c;break;case"bottom":m=t+c;break;case"left":u=e-c;break;case"right":u=e+c}switch(r){case"top":f=i-c;break;case"bottom":f=i+c;break;case"left":g=n-c;break;case"right":g=n+c}return[u,m,g,f]};drawGridDots=(e,t,n)=>{const i=10*2**-Math.floor(Math.log2(e))*e,s=this.canvas.width,r=this.canvas.height,o=t%i,a=n%i;this.ctx.fillStyle=this.SM.getNamedColor("dots");for(let l=o;l<=s;l+=i)for(let e=a;e<=r;e+=i)this.ctx.beginPath(),this.ctx.arc(l,e,1,0,2*Math.PI),this.ctx.fill()};drawCurvedPath=(e,t,n,i,s,r,o,a,l)=>{this.ctx.beginPath(),this.ctx.moveTo(e,t),this.ctx.bezierCurveTo(s,r,o,a,n,i),this.ctx.strokeStyle=l,this.ctx.lineWidth=2,this.ctx.stroke()};drawArrowhead=(e,t,n,i,s)=>{const r=e-n,o=t-i,a=Math.sqrt(r*r+o*o);if(0===a)return;const l=r/a,c=o/a,h=e-12*l-4*c,p=t-12*c+4*l,d=e-12*l+4*c,u=t-12*c-4*l;this.ctx.beginPath(),this.ctx.fillStyle=s,this.ctx.moveTo(e,t),this.ctx.lineTo(h,p),this.ctx.lineTo(d,u),this.ctx.closePath(),this.ctx.fill()};dispose=()=>{this.zoomInOptimize.timeout&&(clearTimeout(this.zoomInOptimize.timeout),this.zoomInOptimize.timeout=null),this.canvas.remove(),this._canvas=null}}];class le{allModules;IO=null;started=!1;disposed=!1;options;container;onDispose=t.makeHook(!0);onStart=t.makeHook();onRestart=t.makeHook();constructor(e,t){this.container=new oe,this.options=e;this.allModules=[...ae,...t??[]],this.allModules.forEach(e=>{this.container.bind({provide:e,useFactory:()=>new e(this.container,this.options,this.onStart,this.onDispose,this.onRestart,this.augment)})}),this.allModules.forEach(e=>{this.container.get(e)});const n=this.options.loading??"normal";"normal"===n?this.load():"lazy"===n&&(this.IO=new IntersectionObserver(this.onVisibilityCheck,{root:null,rootMargin:"50px",threshold:0}),this.IO.observe(this.options.container))}onVisibilityCheck=e=>{e.forEach(e=>{if(e.isIntersecting)return this.load(),this.IO?.disconnect(),void(this.IO=null)})};augment=e=>{const t=Object.getOwnPropertyDescriptors(e);Object.defineProperties(this,t)};load=e=>{this.disposed||(e&&Object.assign(this.options,e),this.started?this.onRestart():(this.onStart(),this.started=!0))};dispose=()=>{if(!this.started||this.disposed)return;this.IO?.disconnect(),this.IO=null;const e=this.options.container;for(;e.firstChild;)e.firstChild.remove();this.onDispose(),this.container.unbindAll(),this.disposed=!0}}const{entries:ce,setPrototypeOf:he,isFrozen:pe,getPrototypeOf:de,getOwnPropertyDescriptor:ue}=Object;let{freeze:me,seal:ge,create:fe}=Object,{apply:we,construct:be}="undefined"!=typeof Reflect&&Reflect;me||(me=function(e){return e}),ge||(ge=function(e){return e}),we||(we=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];return e.apply(t,i)}),be||(be=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const xe=Ae(Array.prototype.forEach),ve=Ae(Array.prototype.lastIndexOf),ke=Ae(Array.prototype.pop),Ce=Ae(Array.prototype.push),ye=Ae(Array.prototype.splice),Se=Ae(String.prototype.toLowerCase),Te=Ae(String.prototype.toString),Ee=Ae(String.prototype.match),Me=Ae(String.prototype.replace),Ve=Ae(String.prototype.indexOf),_e=Ae(String.prototype.trim),Ne=Ae(Object.prototype.hasOwnProperty),Oe=Ae(RegExp.prototype.test),Je=(Re=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return be(Re,t)});var Re;function Ae(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return we(e,t,i)}}function ze(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Se;he&&he(e,null);let i=t.length;for(;i--;){let s=t[i];if("string"==typeof s){const e=n(s);e!==s&&(pe(t)||(t[i]=e),s=e)}e[s]=!0}return e}function De(e){for(let t=0;t<e.length;t++){Ne(e,t)||(e[t]=null)}return e}function Ie(e){const t=fe(null);for(const[n,i]of ce(e)){Ne(e,n)&&(Array.isArray(i)?t[n]=De(i):i&&"object"==typeof i&&i.constructor===Object?t[n]=Ie(i):t[n]=i)}return t}function Le(e,t){for(;null!==e;){const n=ue(e,t);if(n){if(n.get)return Ae(n.get);if("function"==typeof n.value)return Ae(n.value)}e=de(e)}return function(){return null}}const Pe=me(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Be=me(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),$e=me(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Fe=me(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),He=me(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Ye=me(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),je=me(["#text"]),Xe=me(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Ue=me(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),qe=me(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),We=me(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ge=ge(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Ze=ge(/<%[\w\W]*|[\w\W]*%>/gm),Qe=ge(/\$\{[\w\W]*/gm),Ke=ge(/^data-[\-\w.\u00B7-\uFFFF]+$/),et=ge(/^aria-[\-\w]+$/),tt=ge(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),nt=ge(/^(?:\w+script|data):/i),it=ge(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),st=ge(/^html$/i),rt=ge(/^[a-z][.\w]*(-[.\w]+)+$/i);var ot=/* @__PURE__ */Object.freeze({__proto__:null,ARIA_ATTR:et,ATTR_WHITESPACE:it,CUSTOM_ELEMENT:rt,DATA_ATTR:Ke,DOCTYPE_NAME:st,ERB_EXPR:Ze,IS_ALLOWED_URI:tt,IS_SCRIPT_OR_DATA:nt,MUSTACHE_EXPR:Ge,TMPLIT_EXPR:Qe});const at=1,lt=3,ct=7,ht=8,pt=9;var dt=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"undefined"==typeof window?null:window;const n=t=>e(t);if(n.version="3.3.1",n.removed=[],!t||!t.document||t.document.nodeType!==pt||!t.Element)return n.isSupported=!1,n;let{document:i}=t;const s=i,r=s.currentScript,{DocumentFragment:o,HTMLTemplateElement:a,Node:l,Element:c,NodeFilter:h,NamedNodeMap:p=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:d,DOMParser:u,trustedTypes:m}=t,g=c.prototype,f=Le(g,"cloneNode"),w=Le(g,"remove"),b=Le(g,"nextSibling"),x=Le(g,"childNodes"),v=Le(g,"parentNode");if("function"==typeof a){const e=i.createElement("template");e.content&&e.content.ownerDocument&&(i=e.content.ownerDocument)}let k,C="";const{implementation:y,createNodeIterator:S,createDocumentFragment:T,getElementsByTagName:E}=i,{importNode:M}=s;let V={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof ce&&"function"==typeof v&&y&&void 0!==y.createHTMLDocument;const{MUSTACHE_EXPR:_,ERB_EXPR:N,TMPLIT_EXPR:O,DATA_ATTR:J,ARIA_ATTR:R,IS_SCRIPT_OR_DATA:A,ATTR_WHITESPACE:z,CUSTOM_ELEMENT:D}=ot;let{IS_ALLOWED_URI:I}=ot,L=null;const P=ze({},[...Pe,...Be,...$e,...He,...je]);let B=null;const $=ze({},[...Xe,...Ue,...qe,...We]);let F=Object.seal(fe(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}})),H=null,Y=null;const j=Object.seal(fe(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let X=!0,U=!0,q=!1,W=!0,G=!1,Z=!0,Q=!1,K=!1,ee=!1,te=!1,ne=!1,ie=!1,se=!0,re=!1,oe=!0,ae=!1,le={},he=null;const pe=ze({},["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 de=null;const ue=ze({},["audio","video","img","source","image","track"]);let ge=null;const we=ze({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),be="http://www.w3.org/1998/Math/MathML",Re="http://www.w3.org/2000/svg",Ae="http://www.w3.org/1999/xhtml";let De=Ae,Ge=!1,Ze=null;const Qe=ze({},[be,Re,Ae],Te);let Ke=ze({},["mi","mo","mn","ms","mtext"]),et=ze({},["annotation-xml"]);const nt=ze({},["title","style","font","a","script"]);let it=null;const rt=["application/xhtml+xml","text/html"];let dt=null,ut=null;const mt=i.createElement("form"),gt=function(e){return e instanceof RegExp||e instanceof Function},ft=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!ut||ut!==e){if(e&&"object"==typeof e||(e={}),e=Ie(e),it=-1===rt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,dt="application/xhtml+xml"===it?Te:Se,L=Ne(e,"ALLOWED_TAGS")?ze({},e.ALLOWED_TAGS,dt):P,B=Ne(e,"ALLOWED_ATTR")?ze({},e.ALLOWED_ATTR,dt):$,Ze=Ne(e,"ALLOWED_NAMESPACES")?ze({},e.ALLOWED_NAMESPACES,Te):Qe,ge=Ne(e,"ADD_URI_SAFE_ATTR")?ze(Ie(we),e.ADD_URI_SAFE_ATTR,dt):we,de=Ne(e,"ADD_DATA_URI_TAGS")?ze(Ie(ue),e.ADD_DATA_URI_TAGS,dt):ue,he=Ne(e,"FORBID_CONTENTS")?ze({},e.FORBID_CONTENTS,dt):pe,H=Ne(e,"FORBID_TAGS")?ze({},e.FORBID_TAGS,dt):Ie({}),Y=Ne(e,"FORBID_ATTR")?ze({},e.FORBID_ATTR,dt):Ie({}),le=!!Ne(e,"USE_PROFILES")&&e.USE_PROFILES,X=!1!==e.ALLOW_ARIA_ATTR,U=!1!==e.ALLOW_DATA_ATTR,q=e.ALLOW_UNKNOWN_PROTOCOLS||!1,W=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,G=e.SAFE_FOR_TEMPLATES||!1,Z=!1!==e.SAFE_FOR_XML,Q=e.WHOLE_DOCUMENT||!1,te=e.RETURN_DOM||!1,ne=e.RETURN_DOM_FRAGMENT||!1,ie=e.RETURN_TRUSTED_TYPE||!1,ee=e.FORCE_BODY||!1,se=!1!==e.SANITIZE_DOM,re=e.SANITIZE_NAMED_PROPS||!1,oe=!1!==e.KEEP_CONTENT,ae=e.IN_PLACE||!1,I=e.ALLOWED_URI_REGEXP||tt,De=e.NAMESPACE||Ae,Ke=e.MATHML_TEXT_INTEGRATION_POINTS||Ke,et=e.HTML_INTEGRATION_POINTS||et,F=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&>(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(F.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&>(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(F.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(F.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),G&&(U=!1),ne&&(te=!0),le&&(L=ze({},je),B=[],!0===le.html&&(ze(L,Pe),ze(B,Xe)),!0===le.svg&&(ze(L,Be),ze(B,Ue),ze(B,We)),!0===le.svgFilters&&(ze(L,$e),ze(B,Ue),ze(B,We)),!0===le.mathMl&&(ze(L,He),ze(B,qe),ze(B,We))),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?j.tagCheck=e.ADD_TAGS:(L===P&&(L=Ie(L)),ze(L,e.ADD_TAGS,dt))),e.ADD_ATTR&&("function"==typeof e.ADD_ATTR?j.attributeCheck=e.ADD_ATTR:(B===$&&(B=Ie(B)),ze(B,e.ADD_ATTR,dt))),e.ADD_URI_SAFE_ATTR&&ze(ge,e.ADD_URI_SAFE_ATTR,dt),e.FORBID_CONTENTS&&(he===pe&&(he=Ie(he)),ze(he,e.FORBID_CONTENTS,dt)),e.ADD_FORBID_CONTENTS&&(he===pe&&(he=Ie(he)),ze(he,e.ADD_FORBID_CONTENTS,dt)),oe&&(L["#text"]=!0),Q&&ze(L,["html","head","body"]),L.table&&(ze(L,["tbody"]),delete H.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw Je('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw Je('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');k=e.TRUSTED_TYPES_POLICY,C=k.createHTML("")}else void 0===k&&(k=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const s="dompurify"+(n?"#"+n:"");try{return e.createPolicy(s,{createHTML:e=>e,createScriptURL:e=>e})}catch(r){return console.warn("TrustedTypes policy "+s+" could not be created."),null}}(m,r)),null!==k&&"string"==typeof C&&(C=k.createHTML(""));me&&me(e),ut=e}},wt=ze({},[...Be,...$e,...Fe]),bt=ze({},[...He,...Ye]),xt=function(e){Ce(n.removed,{element:e});try{v(e).removeChild(e)}catch(t){w(e)}},vt=function(e,t){try{Ce(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(i){Ce(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(te||ne)try{xt(t)}catch(i){}else try{t.setAttribute(e,"")}catch(i){}},kt=function(e){let t=null,n=null;if(ee)e="<remove></remove>"+e;else{const t=Ee(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===it&&De===Ae&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const s=k?k.createHTML(e):e;if(De===Ae)try{t=(new u).parseFromString(s,it)}catch(o){}if(!t||!t.documentElement){t=y.createDocument(De,"template",null);try{t.documentElement.innerHTML=Ge?C:s}catch(o){}}const r=t.body||t.documentElement;return e&&n&&r.insertBefore(i.createTextNode(n),r.childNodes[0]||null),De===Ae?E.call(t,Q?"html":"body")[0]:Q?t.documentElement:r},Ct=function(e){return S.call(e.ownerDocument||e,e,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT|h.SHOW_PROCESSING_INSTRUCTION|h.SHOW_CDATA_SECTION,null)},yt=function(e){return e instanceof d&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof p)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},St=function(e){return"function"==typeof l&&e instanceof l};function Tt(e,t,i){xe(e,e=>{e.call(n,t,i,ut)})}const Et=function(e){let t=null;if(Tt(V.beforeSanitizeElements,e,null),yt(e))return xt(e),!0;const i=dt(e.nodeName);if(Tt(V.uponSanitizeElement,e,{tagName:i,allowedTags:L}),Z&&e.hasChildNodes()&&!St(e.firstElementChild)&&Oe(/<[/\w!]/g,e.innerHTML)&&Oe(/<[/\w!]/g,e.textContent))return xt(e),!0;if(e.nodeType===ct)return xt(e),!0;if(Z&&e.nodeType===ht&&Oe(/<[/\w]/g,e.data))return xt(e),!0;if(!(j.tagCheck instanceof Function&&j.tagCheck(i))&&(!L[i]||H[i])){if(!H[i]&&Vt(i)){if(F.tagNameCheck instanceof RegExp&&Oe(F.tagNameCheck,i))return!1;if(F.tagNameCheck instanceof Function&&F.tagNameCheck(i))return!1}if(oe&&!he[i]){const t=v(e)||e.parentNode,n=x(e)||e.childNodes;if(n&&t){for(let i=n.length-1;i>=0;--i){const s=f(n[i],!0);s.__removalCount=(e.__removalCount||0)+1,t.insertBefore(s,b(e))}}}return xt(e),!0}return e instanceof c&&!function(e){let t=v(e);t&&t.tagName||(t={namespaceURI:De,tagName:"template"});const n=Se(e.tagName),i=Se(t.tagName);return!!Ze[e.namespaceURI]&&(e.namespaceURI===Re?t.namespaceURI===Ae?"svg"===n:t.namespaceURI===be?"svg"===n&&("annotation-xml"===i||Ke[i]):Boolean(wt[n]):e.namespaceURI===be?t.namespaceURI===Ae?"math"===n:t.namespaceURI===Re?"math"===n&&et[i]:Boolean(bt[n]):e.namespaceURI===Ae?!(t.namespaceURI===Re&&!et[i])&&!(t.namespaceURI===be&&!Ke[i])&&!bt[n]&&(nt[n]||!wt[n]):!("application/xhtml+xml"!==it||!Ze[e.namespaceURI]))}(e)?(xt(e),!0):"noscript"!==i&&"noembed"!==i&&"noframes"!==i||!Oe(/<\/no(script|embed|frames)/i,e.innerHTML)?(G&&e.nodeType===lt&&(t=e.textContent,xe([_,N,O],e=>{t=Me(t,e," ")}),e.textContent!==t&&(Ce(n.removed,{element:e.cloneNode()}),e.textContent=t)),Tt(V.afterSanitizeElements,e,null),!1):(xt(e),!0)},Mt=function(e,t,n){if(se&&("id"===t||"name"===t)&&(n in i||n in mt))return!1;if(U&&!Y[t]&&Oe(J,t));else if(X&&Oe(R,t));else if(j.attributeCheck instanceof Function&&j.attributeCheck(t,e));else if(!B[t]||Y[t]){if(!(Vt(e)&&(F.tagNameCheck instanceof RegExp&&Oe(F.tagNameCheck,e)||F.tagNameCheck instanceof Function&&F.tagNameCheck(e))&&(F.attributeNameCheck instanceof RegExp&&Oe(F.attributeNameCheck,t)||F.attributeNameCheck instanceof Function&&F.attributeNameCheck(t,e))||"is"===t&&F.allowCustomizedBuiltInElements&&(F.tagNameCheck instanceof RegExp&&Oe(F.tagNameCheck,n)||F.tagNameCheck instanceof Function&&F.tagNameCheck(n))))return!1}else if(ge[t]);else if(Oe(I,Me(n,z,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==Ve(n,"data:")||!de[e]){if(q&&!Oe(A,Me(n,z,"")));else if(n)return!1}else;return!0},Vt=function(e){return"annotation-xml"!==e&&Ee(e,D)},_t=function(e){Tt(V.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||yt(e))return;const i={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:B,forceKeepAttr:void 0};let s=t.length;for(;s--;){const o=t[s],{name:a,namespaceURI:l,value:c}=o,h=dt(a),p=c;let d="value"===a?p:_e(p);if(i.attrName=h,i.attrValue=d,i.keepAttr=!0,i.forceKeepAttr=void 0,Tt(V.uponSanitizeAttribute,e,i),d=i.attrValue,!re||"id"!==h&&"name"!==h||(vt(a,e),d="user-content-"+d),Z&&Oe(/((--!?|])>)|<\/(style|title|textarea)/i,d)){vt(a,e);continue}if("attributename"===h&&Ee(d,"href")){vt(a,e);continue}if(i.forceKeepAttr)continue;if(!i.keepAttr){vt(a,e);continue}if(!W&&Oe(/\/>/i,d)){vt(a,e);continue}G&&xe([_,N,O],e=>{d=Me(d,e," ")});const u=dt(e.nodeName);if(Mt(u,h,d)){if(k&&"object"==typeof m&&"function"==typeof m.getAttributeType)if(l);else switch(m.getAttributeType(u,h)){case"TrustedHTML":d=k.createHTML(d);break;case"TrustedScriptURL":d=k.createScriptURL(d)}if(d!==p)try{l?e.setAttributeNS(l,a,d):e.setAttribute(a,d),yt(e)?xt(e):ke(n.removed)}catch(r){vt(a,e)}}else vt(a,e)}Tt(V.afterSanitizeAttributes,e,null)},Nt=function e(t){let n=null;const i=Ct(t);for(Tt(V.beforeSanitizeShadowDOM,t,null);n=i.nextNode();)Tt(V.uponSanitizeShadowNode,n,null),Et(n),_t(n),n.content instanceof o&&e(n.content);Tt(V.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=null,r=null,a=null,c=null;if(Ge=!e,Ge&&(e="\x3c!--\x3e"),"string"!=typeof e&&!St(e)){if("function"!=typeof e.toString)throw Je("toString is not a function");if("string"!=typeof(e=e.toString()))throw Je("dirty is not a string, aborting")}if(!n.isSupported)return e;if(K||ft(t),n.removed=[],"string"==typeof e&&(ae=!1),ae){if(e.nodeName){const t=dt(e.nodeName);if(!L[t]||H[t])throw Je("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof l)i=kt("\x3c!----\x3e"),r=i.ownerDocument.importNode(e,!0),r.nodeType===at&&"BODY"===r.nodeName||"HTML"===r.nodeName?i=r:i.appendChild(r);else{if(!te&&!G&&!Q&&-1===e.indexOf("<"))return k&&ie?k.createHTML(e):e;if(i=kt(e),!i)return te?null:ie?C:""}i&&ee&&xt(i.firstChild);const h=Ct(ae?e:i);for(;a=h.nextNode();)Et(a),_t(a),a.content instanceof o&&Nt(a.content);if(ae)return e;if(te){if(ne)for(c=T.call(i.ownerDocument);i.firstChild;)c.appendChild(i.firstChild);else c=i;return(B.shadowroot||B.shadowrootmode)&&(c=M.call(s,c,!0)),c}let p=Q?i.outerHTML:i.innerHTML;return Q&&L["!doctype"]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Oe(st,i.ownerDocument.doctype.name)&&(p="<!DOCTYPE "+i.ownerDocument.doctype.name+">\n"+p),G&&xe([_,N,O],e=>{p=Me(p,e," ")}),k&&ie?k.createHTML(p):p},n.setConfig=function(){ft(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),K=!0},n.clearConfig=function(){ut=null,K=!1},n.isValidAttribute=function(e,t,n){ut||ft({});const i=dt(e),s=dt(t);return Mt(i,s,n)},n.addHook=function(e,t){"function"==typeof t&&Ce(V[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=ve(V[e],t);return-1===n?void 0:ye(V[e],n,1)[0]}return ke(V[e])},n.removeHooks=function(e){V[e]=[]},n.removeAllHooks=function(){V={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();function ut(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var mt={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function gt(e){mt=e}var ft={exec:()=>null};function wt(e,t=""){let n="string"==typeof e?e:e.source,i={replace:(e,t)=>{let s="string"==typeof t?t:t.source;return s=s.replace(xt.caret,"$1"),n=n.replace(e,s),i},getRegex:()=>new RegExp(n,t)};return i}var bt=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),xt={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}>`)},vt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,kt=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Ct=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,yt=wt(Ct).replace(/bull/g,kt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),St=wt(Ct).replace(/bull/g,kt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Tt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Et=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Mt=wt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Et).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Vt=wt(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,kt).getRegex(),_t="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Nt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ot=wt("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",Nt).replace("tag",_t).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Jt=wt(Tt).replace("hr",vt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",_t).getRegex(),Rt={blockquote:wt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Jt).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:Mt,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:vt,html:Ot,lheading:yt,list:Vt,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:Jt,table:ft,text:/^[^\n]+/},At=wt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",vt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",_t).getRegex(),zt={...Rt,lheading:St,table:At,paragraph:wt(Tt).replace("hr",vt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",At).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",_t).getRegex()},Dt={...Rt,html:wt("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",Nt).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:ft,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:wt(Tt).replace("hr",vt).replace("heading"," *#{1,6} *[^\n]").replace("lheading",yt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},It=/^( {2,}|\\)\n(?!\s*$)/,Lt=/[\p{P}\p{S}]/u,Pt=/[\s\p{P}\p{S}]/u,Bt=/[^\s\p{P}\p{S}]/u,$t=wt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Pt).getRegex(),Ft=/(?!~)[\p{P}\p{S}]/u,Ht=/(?![*_])[\p{P}\p{S}]/u,Yt=wt(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",bt?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),jt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Xt=wt(jt,"u").replace(/punct/g,Lt).getRegex(),Ut=wt(jt,"u").replace(/punct/g,Ft).getRegex(),qt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Wt=wt(qt,"gu").replace(/notPunctSpace/g,Bt).replace(/punctSpace/g,Pt).replace(/punct/g,Lt).getRegex(),Gt=wt(qt,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,Ft).getRegex(),Zt=wt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,Bt).replace(/punctSpace/g,Pt).replace(/punct/g,Lt).getRegex(),Qt=wt(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Ht).getRegex(),Kt=wt("^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)","gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|[*_])/u).replace(/punctSpace/g,/(?![*_])[\s\p{P}\p{S}]/u).replace(/punct/g,Ht).getRegex(),en=wt(/\\(punct)/,"gu").replace(/punct/g,Lt).getRegex(),tn=wt(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),nn=wt(Nt).replace("(?:--\x3e|$)","--\x3e").getRegex(),sn=wt("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",nn).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),rn=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,on=wt(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",rn).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),an=wt(/^!?\[(label)\]\[(ref)\]/).replace("label",rn).replace("ref",Et).getRegex(),ln=wt(/^!?\[(ref)\](?:\[\])?/).replace("ref",Et).getRegex(),cn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,hn={_backpedal:ft,anyPunctuation:en,autolink:tn,blockSkip:Yt,br:It,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:ft,delLDelim:ft,delRDelim:ft,emStrongLDelim:Xt,emStrongRDelimAst:Wt,emStrongRDelimUnd:Zt,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:on,nolink:ln,punctuation:$t,reflink:an,reflinkSearch:wt("reflink|nolink(?!\\()","g").replace("reflink",an).replace("nolink",ln).getRegex(),tag:sn,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,url:ft},pn={...hn,link:wt(/^!?\[(label)\]\((.*?)\)/).replace("label",rn).getRegex(),reflink:wt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",rn).getRegex()},dn={...hn,emStrongRDelimAst:Gt,emStrongLDelim:Ut,delLDelim:Qt,delRDelim:Kt,url:wt(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",cn).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:wt(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",cn).getRegex()},un={...dn,br:wt(It).replace("{2,}","*").getRegex(),text:wt(dn.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},mn={normal:Rt,gfm:zt,pedantic:Dt},gn={normal:hn,gfm:dn,breaks:un,pedantic:pn},fn={"&":"&","<":"<",">":">",'"':""","'":"'"},wn=e=>fn[e];function bn(e,t){if(t){if(xt.escapeTest.test(e))return e.replace(xt.escapeReplace,wn)}else if(xt.escapeTestNoEncode.test(e))return e.replace(xt.escapeReplaceNoEncode,wn);return e}function xn(e){try{e=encodeURI(e).replace(xt.percentDecode,"%")}catch{return null}return e}function vn(e,t){let n=e.replace(xt.findPipe,(e,t,n)=>{let i=!1,s=t;for(;--s>=0&&"\\"===n[s];)i=!i;return i?"|":" |"}).split(xt.splitPipe),i=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push("");for(;i<n.length;i++)n[i]=n[i].trim().replace(xt.slashPipe,"|");return n}function kn(e,t,n){let i=e.length;if(0===i)return"";let s=0;for(;s<i;){if(e.charAt(i-s-1)!==t)break;s++}return e.slice(0,i-s)}function Cn(e,t=0){let n=t,i="";for(let s of e)if("\t"===s){let e=4-n%4;i+=" ".repeat(e),n+=e}else i+=s,n++;return i}function yn(e,t,n,i,s){let r=t.href,o=t.title||null,a=e[1].replace(s.other.outputLinkReplace,"$1");i.state.inLink=!0;let l={type:"!"===e[0].charAt(0)?"image":"link",raw:n,href:r,title:o,text:a,tokens:i.inlineTokens(a)};return i.state.inLink=!1,l}var Sn=class{options;rules;lexer;constructor(e){this.options=e||mt}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:kn(e,"\n")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let i=e.match(n.other.indentCodeCompensation);if(null===i)return t;let s=i[1];return t.split("\n").map(e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[i]=t;return i.length>=s.length?e.slice(s.length):e}).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=kn(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:kn(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=kn(t[0],"\n").split("\n"),n="",i="",s=[];for(;e.length>0;){let t,r=!1,o=[];for(t=0;t<e.length;t++)if(this.rules.other.blockquoteStart.test(e[t]))o.push(e[t]),r=!0;else{if(r)break;o.push(e[t])}e=e.slice(t);let a=o.join("\n"),l=a.replace(this.rules.other.blockquoteSetextReplace,"\n $1").replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}\n${a}`:a,i=i?`${i}\n${l}`:l;let c=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(l,s,!0),this.lexer.state.top=c,0===e.length)break;let h=s.at(-1);if("code"===h?.type)break;if("blockquote"===h?.type){let t=h,r=t.raw+"\n"+e.join("\n"),o=this.blockquote(r);s[s.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,i=i.substring(0,i.length-t.text.length)+o.text;break}if("list"===h?.type){let t=h,r=t.raw+"\n"+e.join("\n"),o=this.list(r);s[s.length-1]=o,n=n.substring(0,n.length-h.raw.length)+o.raw,i=i.substring(0,i.length-t.raw.length)+o.raw,e=r.substring(s.at(-1).raw.length).split("\n");continue}}return{type:"blockquote",raw:n,tokens:s,text:i}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),i=n.length>1,s={type:"list",raw:"",ordered:i,start:i?+n.slice(0,-1):"",loose:!1,items:[]};n=i?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=i?n:"[*+-]");let r=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,i="",a="";if(!(t=r.exec(e))||this.rules.block.hr.test(e))break;i=t[0],e=e.substring(i.length);let l=Cn(t[2].split("\n",1)[0],t[1].length),c=e.split("\n",1)[0],h=!l.trim(),p=0;if(this.options.pedantic?(p=2,a=l.trimStart()):h?p=t[1].length+1:(p=l.search(this.rules.other.nonSpaceChar),p=p>4?1:p,a=l.slice(p),p+=t[1].length),h&&this.rules.other.blankLine.test(c)&&(i+=c+"\n",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(p),n=this.rules.other.hrRegex(p),s=this.rules.other.fencesBeginRegex(p),r=this.rules.other.headingBeginRegex(p),o=this.rules.other.htmlBeginRegex(p),d=this.rules.other.blockquoteBeginRegex(p);for(;e;){let u,m=e.split("\n",1)[0];if(c=m,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),u=c):u=c.replace(this.rules.other.tabCharGlobal," "),s.test(c)||r.test(c)||o.test(c)||d.test(c)||t.test(c)||n.test(c))break;if(u.search(this.rules.other.nonSpaceChar)>=p||!c.trim())a+="\n"+u.slice(p);else{if(h||l.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||s.test(l)||r.test(l)||n.test(l))break;a+="\n"+c}h=!c.trim(),i+=m+"\n",e=e.substring(m.length+1),l=u.slice(p)}}s.loose||(o?s.loose=!0:this.rules.other.doubleBlankLine.test(i)&&(o=!0)),s.items.push({type:"list_item",raw:i,task:!!this.options.gfm&&this.rules.other.listIsTask.test(a),loose:!1,text:a,tokens:[]}),s.raw+=i}let a=s.items.at(-1);if(!a)return;a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd(),s.raw=s.raw.trimEnd();for(let e of s.items){if(this.lexer.state.top=!1,e.tokens=this.lexer.blockTokens(e.text,[]),e.task){if(e.text=e.text.replace(this.rules.other.listReplaceTask,""),"text"===e.tokens[0]?.type||"paragraph"===e.tokens[0]?.type){e.tokens[0].raw=e.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),e.tokens[0].text=e.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,"");break}}let t=this.rules.other.listTaskCheckbox.exec(e.raw);if(t){let n={type:"checkbox",raw:t[0]+" ",checked:"[ ]"!==t[0]};e.checked=n.checked,s.loose?e.tokens[0]&&["paragraph","text"].includes(e.tokens[0].type)&&"tokens"in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=n.raw+e.tokens[0].raw,e.tokens[0].text=n.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(n)):e.tokens.unshift({type:"paragraph",raw:n.raw,text:n.raw,tokens:[n]}):e.tokens.unshift(n)}}if(!s.loose){let t=e.tokens.filter(e=>"space"===e.type),n=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw));s.loose=n}}if(s.loose)for(let e of s.items){e.loose=!0;for(let t of e.tokens)"text"===t.type&&(t.type="paragraph")}return s}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:"pre"===t[1]||"script"===t[1]||"style"===t[1],text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:e,raw:t[0],href:n,title:i}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=vn(t[1]),i=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),s=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split("\n"):[],r={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===i.length){for(let e of i)this.rules.other.tableAlignRight.test(e)?r.align.push("right"):this.rules.other.tableAlignCenter.test(e)?r.align.push("center"):this.rules.other.tableAlignLeft.test(e)?r.align.push("left"):r.align.push(null);for(let e=0;e<n.length;e++)r.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:r.align[e]});for(let e of s)r.rows.push(vn(e,r.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:r.align[t]})));return r}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=kn(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let i=0;i<e.length;i++)if("\\"===e[i])i++;else if(e[i]===t[0])n++;else if(e[i]===t[1]&&(n--,n<0))return i;return n>0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],i="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],i=e[3])}else i=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),yn(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return yn(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!i[1]&&!i[2]||!n||this.rules.inline.punctuation.exec(n))){let n,s,r=[...i[0]].length-1,o=r,a=0,l="*"===i[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(l.lastIndex=0,t=t.slice(-1*e.length+r);null!=(i=l.exec(t));){if(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!n)continue;if(s=[...n].length,i[3]||i[4]){o+=s;continue}if((i[5]||i[6])&&r%3&&!((r+s)%3)){a+=s;continue}if(o-=s,o>0)continue;s=Math.min(s,s+o+a);let t=[...i[0]][0].length,l=e.slice(0,r+i.index+t+s);if(Math.min(r,s)%2){let e=l.slice(1,-1);return{type:"em",raw:l,text:e,tokens:this.lexer.inlineTokens(e)}}let c=l.slice(2,-2);return{type:"strong",raw:l,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),i=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&i&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let i=this.rules.inline.delLDelim.exec(e);if(i&&(!i[1]||!n||this.rules.inline.punctuation.exec(n))){let n,s,r=[...i[0]].length-1,o=r,a=this.rules.inline.delRDelim;for(a.lastIndex=0,t=t.slice(-1*e.length+r);null!=(i=a.exec(t));){if(n=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!n||(s=[...n].length,s!==r))continue;if(i[3]||i[4]){o+=s;continue}if(o-=s,o>0)continue;s=Math.min(s,s+o);let t=[...i[0]][0].length,a=e.slice(0,r+i.index+t+s),l=a.slice(r,-r);return{type:"del",raw:a,text:l,tokens:this.lexer.inlineTokens(l)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=t[0],n="mailto:"+e;else{let i;do{i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(i!==t[0]);e=t[0],n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},Tn=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=/* @__PURE__ */Object.create(null),this.options=e||mt,this.options.tokenizer=this.options.tokenizer||new Sn,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:xt,block:mn.normal,inline:gn.normal};this.options.pedantic?(t.block=mn.pedantic,t.inline=gn.pedantic):this.options.gfm&&(t.block=mn.gfm,this.options.breaks?t.inline=gn.breaks:t.inline=gn.gfm),this.tokenizer.rules=t}static get rules(){return{block:mn,inline:gn}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(xt.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let e=this.inlineQueue[t];this.inlineTokens(e.src,e.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(xt.tabCharGlobal," ").replace(xt.spaceLine,""));e;){let i;if(this.options.extensions?.block?.some(n=>!!(i=n.call({lexer:this},e,t))&&(e=e.substring(i.raw.length),t.push(i),!0)))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let n=t.at(-1);1===i.raw.length&&void 0!==n?n.raw+="\n":t.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+i.raw,n.text+="\n"+i.text,this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+i.raw,n.text+="\n"+i.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},t.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),t.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),t.push(i);continue}let s=e;if(this.options.extensions?.startBlock){let t,n=1/0,i=e.slice(1);this.options.extensions.startBlock.forEach(e=>{t=e.call({lexer:this},i),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(s=e.substring(0,n+1))}if(this.state.top&&(i=this.tokenizer.paragraph(s))){let r=t.at(-1);n&&"paragraph"===r?.type?(r.raw+=(r.raw.endsWith("\n")?"":"\n")+i.raw,r.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(i),n=s.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let n=t.at(-1);"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+i.raw,n.text+="\n"+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(i);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n,i=e,s=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(s=this.tokenizer.rules.inline.reflinkSearch.exec(i));)e.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(i=i.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+i.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(s=this.tokenizer.rules.inline.anyPunctuation.exec(i));)i=i.slice(0,s.index)+"++"+i.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(s=this.tokenizer.rules.inline.blockSkip.exec(i));)n=s[2]?s[2].length:0,i=i.slice(0,s.index+n)+"["+"a".repeat(s[0].length-n-2)+"]"+i.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);i=this.options.hooks?.emStrongMask?.call({lexer:this},i)??i;let r=!1,o="";for(;e;){let n;if(r||(o=""),r=!1,this.options.extensions?.inline?.some(i=>!!(n=i.call({lexer:this},e,t))&&(e=e.substring(n.raw.length),t.push(n),!0)))continue;if(n=this.tokenizer.escape(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.tag(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.link(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(n.raw.length);let i=t.at(-1);"text"===n.type&&"text"===i?.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(n=this.tokenizer.emStrong(e,i,o)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.codespan(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.br(e)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.del(e,i,o)){e=e.substring(n.raw.length),t.push(n);continue}if(n=this.tokenizer.autolink(e)){e=e.substring(n.raw.length),t.push(n);continue}if(!this.state.inLink&&(n=this.tokenizer.url(e))){e=e.substring(n.raw.length),t.push(n);continue}let s=e;if(this.options.extensions?.startInline){let t,n=1/0,i=e.slice(1);this.options.extensions.startInline.forEach(e=>{t=e.call({lexer:this},i),"number"==typeof t&&t>=0&&(n=Math.min(n,t))}),n<1/0&&n>=0&&(s=e.substring(0,n+1))}if(n=this.tokenizer.inlineText(s)){e=e.substring(n.raw.length),"_"!==n.raw.slice(-1)&&(o=n.raw.slice(-1)),r=!0;let i=t.at(-1);"text"===i?.type?(i.raw+=n.raw,i.text+=n.text):t.push(n);continue}if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return t}},En=class{options;parser;constructor(e){this.options=e||mt}space(e){return""}code({text:e,lang:t,escaped:n}){let i=(t||"").match(xt.notSpaceStart)?.[0],s=e.replace(xt.endingNewline,"")+"\n";return i?'<pre><code class="language-'+bn(i)+'">'+(n?s:bn(s,!0))+"</code></pre>\n":"<pre><code>"+(n?s:bn(s,!0))+"</code></pre>\n"}blockquote({tokens:e}){return`<blockquote>\n${this.parser.parse(e)}</blockquote>\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>\n`}hr(e){return"<hr>\n"}list(e){let t=e.ordered,n=e.start,i="";for(let r=0;r<e.items.length;r++){let t=e.items[r];i+=this.listitem(t)}let s=t?"ol":"ul";return"<"+s+(t&&1!==n?' start="'+n+'"':"")+">\n"+i+"</"+s+">\n"}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>\n`}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>\n`}table(e){let t="",n="";for(let s=0;s<e.header.length;s++)n+=this.tablecell(e.header[s]);t+=this.tablerow({text:n});let i="";for(let s=0;s<e.rows.length;s++){let t=e.rows[s];n="";for(let e=0;e<t.length;e++)n+=this.tablecell(t[e]);i+=this.tablerow({text:n})}return i&&(i=`<tbody>${i}</tbody>`),"<table>\n<thead>\n"+t+"</thead>\n"+i+"</table>\n"}tablerow({text:e}){return`<tr>\n${e}</tr>\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>\n`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${bn(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let i=this.parser.parseInline(n),s=xn(e);if(null===s)return i;let r='<a href="'+(e=s)+'"';return t&&(r+=' title="'+bn(t)+'"'),r+=">"+i+"</a>",r}image({href:e,title:t,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let s=xn(e);if(null===s)return bn(n);let r=`<img src="${e=s}" alt="${bn(n)}"`;return t&&(r+=` title="${bn(t)}"`),r+=">",r}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:bn(e.text)}},Mn=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},Vn=class e{options;renderer;textRenderer;constructor(e){this.options=e||mt,this.options.renderer=this.options.renderer||new En,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Mn}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){let t="";for(let n=0;n<e.length;n++){let i=e[n];if(this.options.extensions?.renderers?.[i.type]){let e=i,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(!1!==n||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(e.type)){t+=n||"";continue}}let s=i;switch(s.type){case"space":t+=this.renderer.space(s);break;case"hr":t+=this.renderer.hr(s);break;case"heading":t+=this.renderer.heading(s);break;case"code":t+=this.renderer.code(s);break;case"table":t+=this.renderer.table(s);break;case"blockquote":t+=this.renderer.blockquote(s);break;case"list":t+=this.renderer.list(s);break;case"checkbox":t+=this.renderer.checkbox(s);break;case"html":t+=this.renderer.html(s);break;case"def":t+=this.renderer.def(s);break;case"paragraph":t+=this.renderer.paragraph(s);break;case"text":t+=this.renderer.text(s);break;default:{let e='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return t}parseInline(e,t=this.renderer){let n="";for(let i=0;i<e.length;i++){let s=e[i];if(this.options.extensions?.renderers?.[s.type]){let e=this.options.extensions.renderers[s.type].call({parser:this},s);if(!1!==e||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){n+=e||"";continue}}let r=s;switch(r.type){case"escape":case"text":n+=t.text(r);break;case"html":n+=t.html(r);break;case"link":n+=t.link(r);break;case"image":n+=t.image(r);break;case"checkbox":n+=t.checkbox(r);break;case"strong":n+=t.strong(r);break;case"em":n+=t.em(r);break;case"codespan":n+=t.codespan(r);break;case"br":n+=t.br(r);break;case"del":n+=t.del(r);break;default:{let e='Token with "'+r.type+'" type was not found.';if(this.options.silent)return console.error(e),"";throw new Error(e)}}}return n}},_n=class{options;block;constructor(e){this.options=e||mt}static passThroughHooks=/* @__PURE__ */new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=/* @__PURE__ */new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Tn.lex:Tn.lexInline}provideParser(){return this.block?Vn.parse:Vn.parseInline}},Nn=new class{defaults={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Vn;Renderer=En;TextRenderer=Mn;Lexer=Tn;Tokenizer=Sn;Hooks=_n;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let i of e)switch(n=n.concat(t.call(this,i)),i.type){case"table":{let e=i;for(let i of e.header)n=n.concat(this.walkTokens(i.tokens,t));for(let i of e.rows)for(let e of i)n=n.concat(this.walkTokens(e.tokens,t));break}case"list":{let e=i;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=i;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(i=>{let s=e[i].flat(1/0);n=n.concat(this.walkTokens(s,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let i=e.renderer.apply(this,t);return!1===i&&(i=n.apply(this,t)),i}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new En(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let i=n,s=e.renderer[i],r=t[i];t[i]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=r.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Sn(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let i=n,s=e.tokenizer[i],r=t[i];t[i]=(...e)=>{let n=s.apply(t,e);return!1===n&&(n=r.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new _n;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let i=n,s=e.hooks[i],r=t[i];_n.passThroughHooks.has(n)?t[i]=e=>{if(this.defaults.async&&_n.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await s.call(t,e);return r.call(t,n)})();let i=s.call(t,e);return r.call(t,i)}:t[i]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await s.apply(t,e);return!1===n&&(n=await r.apply(t,e)),n})();let n=s.apply(t,e);return!1===n&&(n=r.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,i=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(i.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Tn.lex(e,t??this.defaults)}parser(e,t){return Vn.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let i={...n},s={...this.defaults,...i},r=this.onError(!!s.silent,!!s.async);if(!0===this.defaults.async&&!1===i.async)return r(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return r(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return r(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(s.hooks&&(s.hooks.options=s,s.hooks.block=e),s.async)return(async()=>{let n=s.hooks?await s.hooks.preprocess(t):t,i=await(s.hooks?await s.hooks.provideLexer():e?Tn.lex:Tn.lexInline)(n,s),r=s.hooks?await s.hooks.processAllTokens(i):i;s.walkTokens&&await Promise.all(this.walkTokens(r,s.walkTokens));let o=await(s.hooks?await s.hooks.provideParser():e?Vn.parse:Vn.parseInline)(r,s);return s.hooks?await s.hooks.postprocess(o):o})().catch(r);try{s.hooks&&(t=s.hooks.preprocess(t));let n=(s.hooks?s.hooks.provideLexer():e?Tn.lex:Tn.lexInline)(t,s);s.hooks&&(n=s.hooks.processAllTokens(n)),s.walkTokens&&this.walkTokens(n,s.walkTokens);let i=(s.hooks?s.hooks.provideParser():e?Vn.parse:Vn.parseInline)(n,s);return s.hooks&&(i=s.hooks.postprocess(i)),i}catch(o){return r(o)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="<p>An error occurred:</p><pre>"+bn(n.message+"",!0)+"</pre>";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function On(e,t){return Nn.parse(e,t)}async function Jn(e){return dt.sanitize(await On(e))}async function Rn(e){return await fetch(e).then(e=>e.json())}On.options=On.setOptions=function(e){return Nn.setOptions(e),On.defaults=Nn.defaults,gt(On.defaults),On},On.getDefaults=ut,On.defaults=mt,On.use=function(...e){return Nn.use(...e),On.defaults=Nn.defaults,gt(On.defaults),On},On.walkTokens=function(e,t){return Nn.walkTokens(e,t)},On.parseInline=Nn.parseInline,On.Parser=Vn,On.parser=Vn.parse,On.Renderer=En,On.TextRenderer=Mn,On.Lexer=Tn,On.lexer=Tn.lex,On.Tokenizer=Sn,On.Hooks=_n,On.parse=On,On.options,On.setOptions,On.use,On.walkTokens,On.parseInline,Vn.parse,Tn.lex;export{A as Controls,z as DebugPanel,le as JSONCanvasViewer,D as Minimap,I as MistouchPreventer,Rn as fetchCanvas,Jn as parser};
|