json-canvas-viewer 4.1.0 → 4.1.1
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/dist/chimp.js +395 -1
- package/dist/index.d.ts +29 -618
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/kernel/BaseModule.d.ts +28 -0
- package/dist/kernel/BaseModule.js +2 -2
- package/dist/kernel/BaseModule.js.map +1 -1
- package/dist/kernel/Controller.d.ts +30 -0
- package/dist/kernel/Controller.js +2 -2
- package/dist/kernel/Controller.js.map +1 -1
- package/dist/kernel/DataManager.d.ts +67 -0
- package/dist/kernel/DataManager.js +2 -2
- package/dist/kernel/DataManager.js.map +1 -1
- package/dist/kernel/InteractionHandler.d.ts +51 -0
- package/dist/kernel/InteractionHandler.js +2 -2
- package/dist/kernel/InteractionHandler.js.map +1 -1
- package/dist/kernel/OverlayManager.d.ts +55 -0
- package/dist/kernel/OverlayManager.js +2 -2
- package/dist/kernel/OverlayManager.js.map +1 -1
- package/dist/kernel/Renderer.d.ts +36 -0
- package/dist/kernel/Renderer.js +2 -2
- package/dist/kernel/Renderer.js.map +1 -1
- package/dist/kernel/StyleManager.d.ts +135 -0
- package/dist/kernel/StyleManager.js +2 -2
- package/dist/kernel/StyleManager.js.map +1 -1
- package/dist/kernel/index.d.ts +46 -0
- package/dist/kernel/index.js +2 -2
- package/dist/kernel/index.js.map +1 -1
- package/dist/kernel/styles.js +285 -0
- package/dist/kernel/styles.js.map +1 -0
- package/dist/kernel/types.d.ts +33 -0
- package/dist/kernel/utilities.d.ts +39 -0
- package/dist/kernel/utilities.js +2 -2
- package/dist/kernel/utilities.js.map +1 -1
- package/dist/modules/Controls/index.d.ts +42 -0
- package/dist/modules/Controls/index.js +2 -2
- package/dist/modules/Controls/index.js.map +1 -1
- package/dist/modules/Controls/styles.js +29 -0
- package/dist/modules/Controls/styles.js.map +1 -0
- package/dist/modules/DebugPanel/index.d.ts +14 -0
- package/dist/modules/DebugPanel/index.js +2 -2
- package/dist/modules/DebugPanel/index.js.map +1 -1
- package/dist/modules/DebugPanel/styles.js +13 -0
- package/dist/modules/DebugPanel/styles.js.map +1 -0
- package/dist/modules/Minimap/index.d.ts +36 -0
- package/dist/modules/Minimap/index.js +2 -2
- package/dist/modules/Minimap/index.js.map +1 -1
- package/dist/modules/Minimap/styles.js +56 -0
- package/dist/modules/Minimap/styles.js.map +1 -0
- package/dist/modules/MistouchPreventer/index.d.ts +29 -0
- package/dist/modules/MistouchPreventer/index.js +2 -2
- package/dist/modules/MistouchPreventer/index.js.map +1 -1
- package/dist/modules/MistouchPreventer/styles.js +21 -0
- package/dist/modules/MistouchPreventer/styles.js.map +1 -0
- package/dist/shared/index.d.ts +50 -0
- package/dist/utilities/fetchCanvas.d.ts +7 -0
- package/dist/utilities/fetchCanvas.js +2 -2
- package/dist/utilities/fetchCanvas.js.map +1 -1
- package/dist/utilities/parser.d.ts +5 -0
- package/dist/utilities/parser.js +2 -2
- package/dist/utilities/parser.js.map +1 -1
- package/dist/utilities/renderToString.d.ts +12 -0
- package/dist/utilities/renderToString.js +2 -2
- package/dist/utilities/renderToString.js.map +1 -1
- package/package.json +8 -7
- package/dist/kernel/styles.scss.js +0 -2
- package/dist/kernel/styles.scss.js.map +0 -1
- package/dist/modules/Controls/styles.scss.js +0 -2
- package/dist/modules/Controls/styles.scss.js.map +0 -1
- package/dist/modules/DebugPanel/styles.scss.js +0 -2
- package/dist/modules/DebugPanel/styles.scss.js.map +0 -1
- package/dist/modules/Minimap/styles.scss.js +0 -2
- package/dist/modules/Minimap/styles.scss.js.map +0 -1
- package/dist/modules/MistouchPreventer/styles.scss.js +0 -2
- package/dist/modules/MistouchPreventer/styles.scss.js.map +0 -1
package/dist/chimp.js
CHANGED
|
@@ -1 +1,395 @@
|
|
|
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};
|
|
1
|
+
import{parseHex as e,parseHsl as t,parseRgb as n,rgbToHsl as r,toHslString as i}from"@ahmedsemih/color-fns";import{Click as a,Drag as o,Lubricator as s,MultitouchPanZoom as c,Pointeract as l,PreventDefault as u,WheelPanZoom as d,lubricatorDragPreset as f,lubricatorPanPreset as p,lubricatorZoomPreset as m}from"pointeract";import{Container as h}from"@needle-di/core";import g from"dompurify";import{marked as _}from"marked";var v=class{onStart;onRestart;onDispose;constructor(e,t,n,r,i,a){this.container=e,this.augment=a,this.options=t,this.onStart=n.subscribe,this.onDispose=r.subscribe,this.onRestart=i.subscribe}options},y=`.JSON-Canvas-Viewer {
|
|
2
|
+
--contentTransition: color 200ms, opacity 200ms, text-shadow 200ms, fill 200ms;
|
|
3
|
+
--containerTransition:
|
|
4
|
+
background 200ms, opacity 200ms, box-shadow 200ms, border 200ms, filter 200ms,
|
|
5
|
+
backdrop-filter 200ms;
|
|
6
|
+
color: var(--text);
|
|
7
|
+
fill: var(--text);
|
|
8
|
+
stroke: var(--text);
|
|
9
|
+
background-color: var(--background);
|
|
10
|
+
position: relative;
|
|
11
|
+
width: 100%;
|
|
12
|
+
height: 100%;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
}
|
|
15
|
+
.JSON-Canvas-Viewer.JCV-numb, .JSON-Canvas-Viewer.JCV-numb * {
|
|
16
|
+
pointer-events: none !important;
|
|
17
|
+
}
|
|
18
|
+
.JSON-Canvas-Viewer .JCV-full, .JSON-Canvas-Viewer .JCV-overlay-container .JCV-click-layer, .JSON-Canvas-Viewer .JCV-overlay-container .JCV-link-iframe,
|
|
19
|
+
.JSON-Canvas-Viewer .JCV-overlay-container .JCV-audio,
|
|
20
|
+
.JSON-Canvas-Viewer .JCV-overlay-container .JCV-video, .JSON-Canvas-Viewer .JCV-overlay-container .JCV-content {
|
|
21
|
+
top: 0;
|
|
22
|
+
left: 0;
|
|
23
|
+
width: 100%;
|
|
24
|
+
height: 100%;
|
|
25
|
+
position: absolute;
|
|
26
|
+
}
|
|
27
|
+
.JSON-Canvas-Viewer .JCV-flex-center, .JSON-Canvas-Viewer .JCV-overlay-container .JCV-content.JCV-markdown-content {
|
|
28
|
+
display: flex;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
align-items: center;
|
|
31
|
+
}
|
|
32
|
+
.JSON-Canvas-Viewer .JCV-border-shadow-bg {
|
|
33
|
+
background: var(--background-secondary);
|
|
34
|
+
border: 1px solid var(--border) !important;
|
|
35
|
+
box-shadow: var(--shadow);
|
|
36
|
+
}
|
|
37
|
+
.JSON-Canvas-Viewer .JCV-button {
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
font-size: 18px;
|
|
40
|
+
height: 32px;
|
|
41
|
+
border: none;
|
|
42
|
+
transition: var(--containerTransition);
|
|
43
|
+
background-color: var(--background-secondary);
|
|
44
|
+
text-align: center;
|
|
45
|
+
width: 32px;
|
|
46
|
+
padding: 5px 0px;
|
|
47
|
+
}
|
|
48
|
+
.JSON-Canvas-Viewer .JCV-button svg {
|
|
49
|
+
width: 100%;
|
|
50
|
+
height: 100%;
|
|
51
|
+
}
|
|
52
|
+
.JSON-Canvas-Viewer .JCV-button:hover {
|
|
53
|
+
background-color: var(--border);
|
|
54
|
+
}
|
|
55
|
+
.JSON-Canvas-Viewer .JCV-button.JCV-collapse-button {
|
|
56
|
+
border-radius: 8px;
|
|
57
|
+
transition: transform 200ms, background-color 200ms;
|
|
58
|
+
}
|
|
59
|
+
.JSON-Canvas-Viewer .JCV-collapsed .JCV-collapse-button {
|
|
60
|
+
transform: rotate(180deg);
|
|
61
|
+
}
|
|
62
|
+
.JSON-Canvas-Viewer .JCV-main-canvas {
|
|
63
|
+
width: 100%;
|
|
64
|
+
height: 100%;
|
|
65
|
+
transform-origin: top left;
|
|
66
|
+
}
|
|
67
|
+
.JSON-Canvas-Viewer .JCV-overlays {
|
|
68
|
+
position: absolute;
|
|
69
|
+
transform-origin: top left;
|
|
70
|
+
will-change: transform;
|
|
71
|
+
}
|
|
72
|
+
.JSON-Canvas-Viewer .JCV-overlay-container {
|
|
73
|
+
position: absolute;
|
|
74
|
+
box-sizing: border-box;
|
|
75
|
+
border-radius: 12px;
|
|
76
|
+
user-select: none;
|
|
77
|
+
contain: strict;
|
|
78
|
+
content-visibility: auto;
|
|
79
|
+
background-color: var(--overlay-card);
|
|
80
|
+
transition: var(--containerTransition);
|
|
81
|
+
}
|
|
82
|
+
.JSON-Canvas-Viewer .JCV-overlay-container .JCV-overlay-border {
|
|
83
|
+
box-sizing: border-box;
|
|
84
|
+
pointer-events: none;
|
|
85
|
+
position: absolute;
|
|
86
|
+
color: var(--overlay-border);
|
|
87
|
+
top: 0;
|
|
88
|
+
left: 0;
|
|
89
|
+
width: 100%;
|
|
90
|
+
height: 100%;
|
|
91
|
+
border-width: var(--overlay-border-width);
|
|
92
|
+
border-style: solid;
|
|
93
|
+
border-radius: 12px;
|
|
94
|
+
transition: var(--containerTransition);
|
|
95
|
+
}
|
|
96
|
+
.JSON-Canvas-Viewer .JCV-overlay-container .JCV-content {
|
|
97
|
+
overflow: hidden;
|
|
98
|
+
}
|
|
99
|
+
.JSON-Canvas-Viewer .JCV-overlay-container .JCV-content.JCV-markdown-content {
|
|
100
|
+
position: absolute;
|
|
101
|
+
padding: 0 7px;
|
|
102
|
+
}
|
|
103
|
+
.JSON-Canvas-Viewer .JCV-overlay-container .JCV-content.JCV-markdown-content.rtl {
|
|
104
|
+
direction: rtl;
|
|
105
|
+
text-align: right;
|
|
106
|
+
}
|
|
107
|
+
.JSON-Canvas-Viewer .JCV-overlay-container.JCV-active {
|
|
108
|
+
user-select: auto;
|
|
109
|
+
pointer-events: auto;
|
|
110
|
+
}
|
|
111
|
+
.JSON-Canvas-Viewer .JCV-overlay-container.JCV-active .JCV-overlay-border {
|
|
112
|
+
border: 4px solid var(--overlay-active);
|
|
113
|
+
}
|
|
114
|
+
.JSON-Canvas-Viewer .JCV-overlay-container .JCV-link-iframe,
|
|
115
|
+
.JSON-Canvas-Viewer .JCV-overlay-container .JCV-audio,
|
|
116
|
+
.JSON-Canvas-Viewer .JCV-overlay-container .JCV-video {
|
|
117
|
+
border: none;
|
|
118
|
+
background: transparent;
|
|
119
|
+
}
|
|
120
|
+
.JSON-Canvas-Viewer .JCV-overlay-container .JCV-click-layer {
|
|
121
|
+
background: transparent;
|
|
122
|
+
pointer-events: auto;
|
|
123
|
+
}
|
|
124
|
+
.JSON-Canvas-Viewer .JCV-overlay-container.JCV-active .JCV-click-layer {
|
|
125
|
+
pointer-events: none;
|
|
126
|
+
}
|
|
127
|
+
.JSON-Canvas-Viewer .JCV-overlay-container .JCV-img {
|
|
128
|
+
width: 100%;
|
|
129
|
+
height: 100%;
|
|
130
|
+
object-fit: cover;
|
|
131
|
+
pointer-events: none;
|
|
132
|
+
}
|
|
133
|
+
.JSON-Canvas-Viewer .JCV-overlay-container.JCV-active .JCV-img {
|
|
134
|
+
pointer-events: auto;
|
|
135
|
+
}
|
|
136
|
+
.JSON-Canvas-Viewer .JCV-overlay-container .JCV-parsed-content-wrapper {
|
|
137
|
+
font-family: sans-serif;
|
|
138
|
+
box-sizing: border-box;
|
|
139
|
+
max-width: 100%;
|
|
140
|
+
max-height: 100%;
|
|
141
|
+
padding: 10px 6px;
|
|
142
|
+
pointer-events: none;
|
|
143
|
+
overflow: hidden;
|
|
144
|
+
scrollbar-gutter: stable both-edges;
|
|
145
|
+
display: flex;
|
|
146
|
+
flex-direction: column;
|
|
147
|
+
gap: 12px;
|
|
148
|
+
}
|
|
149
|
+
@supports not (scrollbar-gutter: stable both-edges) {
|
|
150
|
+
.JSON-Canvas-Viewer .JCV-overlay-container .JCV-parsed-content-wrapper {
|
|
151
|
+
padding: 10px;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
.JSON-Canvas-Viewer .JCV-overlay-container.JCV-active .JCV-parsed-content-wrapper {
|
|
155
|
+
overflow: auto;
|
|
156
|
+
pointer-events: auto;
|
|
157
|
+
}
|
|
158
|
+
.JSON-Canvas-Viewer .JCV-markdown-content ::-webkit-scrollbar {
|
|
159
|
+
width: 4px;
|
|
160
|
+
}
|
|
161
|
+
.JSON-Canvas-Viewer .JCV-markdown-content ::-webkit-scrollbar-track {
|
|
162
|
+
background-color: transparent;
|
|
163
|
+
}
|
|
164
|
+
.JSON-Canvas-Viewer .JCV-markdown-content ::-webkit-scrollbar-thumb {
|
|
165
|
+
border-radius: 2px;
|
|
166
|
+
background: rgba(255, 255, 255, 0.25);
|
|
167
|
+
}
|
|
168
|
+
.JSON-Canvas-Viewer .JCV-markdown-content ::-webkit-scrollbar-thumb:hover {
|
|
169
|
+
background: rgba(30, 30, 30, 0.75);
|
|
170
|
+
}
|
|
171
|
+
.JSON-Canvas-Viewer .JCV-markdown-content p {
|
|
172
|
+
font-size: 16px;
|
|
173
|
+
line-height: 21px;
|
|
174
|
+
}
|
|
175
|
+
.JSON-Canvas-Viewer .JCV-markdown-content img {
|
|
176
|
+
width: 100%;
|
|
177
|
+
border-radius: 8px;
|
|
178
|
+
}
|
|
179
|
+
.JSON-Canvas-Viewer .JCV-markdown-content h1 {
|
|
180
|
+
font-size: 25px;
|
|
181
|
+
}
|
|
182
|
+
.JSON-Canvas-Viewer .JCV-markdown-content h2 {
|
|
183
|
+
font-size: 23px;
|
|
184
|
+
}
|
|
185
|
+
.JSON-Canvas-Viewer .JCV-markdown-content h3 {
|
|
186
|
+
font-size: 22px;
|
|
187
|
+
}
|
|
188
|
+
.JSON-Canvas-Viewer .JCV-markdown-content h4 {
|
|
189
|
+
font-size: 20px;
|
|
190
|
+
}
|
|
191
|
+
.JSON-Canvas-Viewer .JCV-markdown-content h5 {
|
|
192
|
+
font-size: 19px;
|
|
193
|
+
}
|
|
194
|
+
.JSON-Canvas-Viewer .JCV-markdown-content h6 {
|
|
195
|
+
font-size: 17px;
|
|
196
|
+
}
|
|
197
|
+
.JSON-Canvas-Viewer .JCV-markdown-content p,
|
|
198
|
+
.JSON-Canvas-Viewer .JCV-markdown-content h1,
|
|
199
|
+
.JSON-Canvas-Viewer .JCV-markdown-content h2,
|
|
200
|
+
.JSON-Canvas-Viewer .JCV-markdown-content h3,
|
|
201
|
+
.JSON-Canvas-Viewer .JCV-markdown-content h4,
|
|
202
|
+
.JSON-Canvas-Viewer .JCV-markdown-content h5,
|
|
203
|
+
.JSON-Canvas-Viewer .JCV-markdown-content h6,
|
|
204
|
+
.JSON-Canvas-Viewer .JCV-markdown-content ol,
|
|
205
|
+
.JSON-Canvas-Viewer .JCV-markdown-content ul {
|
|
206
|
+
margin: 0;
|
|
207
|
+
}
|
|
208
|
+
.JSON-Canvas-Viewer .JCV-markdown-content h1,
|
|
209
|
+
.JSON-Canvas-Viewer .JCV-markdown-content h2 {
|
|
210
|
+
font-weight: 800;
|
|
211
|
+
}
|
|
212
|
+
.JSON-Canvas-Viewer .JCV-markdown-content h3,
|
|
213
|
+
.JSON-Canvas-Viewer .JCV-markdown-content h4 {
|
|
214
|
+
font-weight: 700;
|
|
215
|
+
}
|
|
216
|
+
.JSON-Canvas-Viewer .JCV-markdown-content h5,
|
|
217
|
+
.JSON-Canvas-Viewer .JCV-markdown-content h6 {
|
|
218
|
+
font-weight: 600;
|
|
219
|
+
}
|
|
220
|
+
.JSON-Canvas-Viewer .JCV-markdown-content code {
|
|
221
|
+
background: rgba(255, 255, 255, 0.1);
|
|
222
|
+
padding: 2px 4px;
|
|
223
|
+
border-radius: 8px;
|
|
224
|
+
}
|
|
225
|
+
pre .JSON-Canvas-Viewer .JCV-markdown-content code {
|
|
226
|
+
display: block;
|
|
227
|
+
box-sizing: border-box;
|
|
228
|
+
width: 100%;
|
|
229
|
+
}
|
|
230
|
+
.JSON-Canvas-Viewer .JCV-markdown-content pre:has(code),
|
|
231
|
+
.JSON-Canvas-Viewer .JCV-markdown-content table {
|
|
232
|
+
margin: 6px 0;
|
|
233
|
+
}
|
|
234
|
+
.JSON-Canvas-Viewer .JCV-markdown-content strong {
|
|
235
|
+
color: rgb(254, 142, 124);
|
|
236
|
+
}
|
|
237
|
+
.JSON-Canvas-Viewer .JCV-markdown-content em {
|
|
238
|
+
color: rgb(90, 255, 178);
|
|
239
|
+
}
|
|
240
|
+
.JSON-Canvas-Viewer .JCV-markdown-content a {
|
|
241
|
+
text-decoration: none;
|
|
242
|
+
color: rgb(109, 173, 208);
|
|
243
|
+
font-weight: 800;
|
|
244
|
+
font-style: italic;
|
|
245
|
+
cursor: pointer;
|
|
246
|
+
transition: var(--contentTransition);
|
|
247
|
+
}
|
|
248
|
+
.JSON-Canvas-Viewer .JCV-markdown-content a:hover {
|
|
249
|
+
color: rgb(134, 211, 253);
|
|
250
|
+
}
|
|
251
|
+
.JSON-Canvas-Viewer .JCV-markdown-content hr {
|
|
252
|
+
height: 1px;
|
|
253
|
+
width: 100%;
|
|
254
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
255
|
+
border: none;
|
|
256
|
+
}
|
|
257
|
+
.JSON-Canvas-Viewer .JCV-markdown-content li {
|
|
258
|
+
margin: 5px 0;
|
|
259
|
+
}
|
|
260
|
+
.JSON-Canvas-Viewer .JCV-markdown-content ul {
|
|
261
|
+
padding-left: 16px;
|
|
262
|
+
}
|
|
263
|
+
.JSON-Canvas-Viewer .JCV-markdown-content ol {
|
|
264
|
+
padding-left: 15px;
|
|
265
|
+
padding-right: 7.5px;
|
|
266
|
+
}
|
|
267
|
+
.JSON-Canvas-Viewer .JCV-markdown-content table {
|
|
268
|
+
border-collapse: collapse;
|
|
269
|
+
border-radius: 8px;
|
|
270
|
+
overflow: hidden;
|
|
271
|
+
width: 100%;
|
|
272
|
+
}
|
|
273
|
+
.JSON-Canvas-Viewer .JCV-markdown-content table th,
|
|
274
|
+
.JSON-Canvas-Viewer .JCV-markdown-content table td {
|
|
275
|
+
border: 1px solid rgba(255, 255, 255, 0.2);
|
|
276
|
+
padding: 6px 10px;
|
|
277
|
+
background: rgba(255, 255, 255, 0.06);
|
|
278
|
+
text-align: left;
|
|
279
|
+
}
|
|
280
|
+
.JSON-Canvas-Viewer .JCV-markdown-content table th {
|
|
281
|
+
background: rgba(255, 255, 255, 0.12);
|
|
282
|
+
font-weight: bold;
|
|
283
|
+
}
|
|
284
|
+
`,b={round:E,resizeCanvasForDPR:T,applyStyles:S,drawRoundRect:C,getAnchorCoord:w,makeHook:D};const x=Error(`[JSONCanvasViewer] Resource hasn't been set up or has been disposed.`);function S(e,t){let n=document.createElement(`style`);n.innerHTML=t,e.appendChild(n)}function C(e,t,n,r,i,a){e.beginPath(),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+i-a),e.quadraticCurveTo(t+r,n+i,t+r-a,n+i),e.lineTo(t+a,n+i),e.quadraticCurveTo(t,n+i,t,n+i-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n),e.closePath()}function w(e,t){let n=e.x+e.width/2,r=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:r};case`right`:return{x:e.x+e.width,y:r};default:return{x:n,y:r}}}function T(e,t,n){let r=window.devicePixelRatio??1,i=e.getContext(`2d`);if(!i)throw 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*r),e.height=Math.round(n*r),i.setTransform(1,0,0,1,0,0),i.scale(r,r)}function E(e,t){let n=10**t;return Math.round(e*n)/n}function D(e=!1,t=!1){let n=t?async(...t)=>{if(e){let e=Array.from(n.subs).reverse();for(let n of e)await n(...t)}else for(let e of n.subs)await e(...t)}:(...t)=>{if(e){let e=Array.from(n.subs).reverse();for(let n of e)n(...t)}else for(let e of n.subs)e(...t)};return n.subs=new Set,n.subscribe=e=>{n.subs.add(e)},n.unsubscribe=e=>{n.subs.delete(e)},n}var O=class extends v{onToggleFullscreen=b.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);let t=this.options.container;for(;t.firstElementChild;)t.firstElementChild.remove();t.innerHTML=``;let n=this.options.shadowed?t.attachShadow({mode:`open`}):t;b.applyStyles(n,y+this.options.extraCSS),this.data.container.classList.add(`JSON-Canvas-Viewer`),n.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=()=>{let 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=>{let t={ref:e,box:this.getNodeBox(e)};if(this.data.nodeMap[e.id]=t,e.type===`file`){let n=e.file.split(`/`).pop()??``;if(t.fileName=n,!e.file.startsWith(`http://`)&&!e.file.startsWith(`https://`)){let 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=>e?e?.slice(-1)===`/`?e:`${e}/`:`./`;getNodeBox=e=>({left:e.x,top:e.type===`file`||e.type===`group`?e.y-40:e.y,right:e.width+e.x,bottom:e.y+e.height});getEdgeBox=e=>{let t=this.data.nodeMap,n=t[e.fromNode].ref,r=t[e.toNode].ref,i=b.getAnchorCoord(n,e.fromSide),a=b.getAnchorCoord(r,e.toSide),o={left:Math.min(i.x,a.x),top:Math.min(i.y,a.y),right:Math.max(i.x,a.x),bottom:Math.max(i.y,a.y)},s=o.right-o.left,c=o.bottom-o.top,l=Math.min(s,c),u=Math.log2(Math.max(s,c)/(l===0?1:l))*10;return{left:o.left-u,top:o.top-u,right:o.right+u,bottom:o.bottom+u}};calculateNodeBounds(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;e.nodes.forEach(e=>{t=Math.min(t,e.x),n=Math.min(n,e.y),r=Math.max(r,e.x+e.width),i=Math.max(i,e.y+e.height)});let a=r-t,o=i-n,s=t+a/2,c=n+o/2;return{minX:t,minY:n,maxX:r,maxY:i,width:a,height:o,centerX:s,centerY:c}}toggleFullscreen=async e=>{!document.fullscreenElement&&(!e||e===`enter`)?(await this.data.container.requestFullscreen(),this.onToggleFullscreen(`enter`)):document.fullscreenElement&&(!e||e===`exit`)&&(await document.exitFullscreen(),this.onToggleFullscreen(`exit`))};resetView=()=>{let e=this.data.nodeBounds,t=this.data.container;if(!e||!t)return;let n=e.width+200,r=e.height+200,i=t.clientWidth,a=t.clientHeight,o=i/n,s=a/r,c=Math.round(Math.min(o,s)*1e3)/1e3,l=e.centerX,u=e.centerY,d={scale:c,offsetX:i/2-l*c,offsetY:a/2-u*c};this.data.offsetX=d.offsetX,this.data.offsetY=d.offsetY,this.data.scale=d.scale};middleViewer=()=>{let e=this.data.container;return{x:e.clientWidth/2,y:e.clientHeight/2,width:e.clientWidth,height:e.clientHeight}};dispose=()=>{this.data.container.remove()}},k=class extends v{theme=`light`;onChangeTheme=b.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);let t=this.options.colors;t&&[`light`,`dark`].forEach(e=>{if(!(e in t))return;let n=t[e];n&&Object.entries(n).forEach(([t,n])=>{if(!n)return;let r=this.namedColors[e],i=this.definedColors[e];if(t in r)r[t]=n;else if(t in i){let e=this.parseColor(n);if(!e){console.warn(`[JSON Canvas Viewer] Color ${n} unsupported.`);return}i[t]=e}})}),this.changeTheme(this.options.theme??`light`),this.augment({changeTheme:this.changeTheme,onChangeTheme:this.onChangeTheme})}hslProcessor=e=>{let{hue:t,saturation:n,lightness:r}=e,a;return a=this.theme===`dark`?{active:e,card:{hue:t,saturation:n/3,lightness:r/3},border:{...e,alpha:.7},background:{...e,alpha:.1},text:e.lightness>=70?`rgb(30, 30, 30)`:`rgb(242, 242, 242)`}:{active:e,card:t===0?{hue:t,saturation:n,lightness:100}:{hue:t,saturation:n*.4,lightness:90},border:{...e,alpha:.7},background:{...e,alpha:.1},text:e.lightness>=70?`rgb(30, 30, 30)`:`rgb(242, 242, 242)`},{active:i(a.active),card:i(a.card),border:i(a.border),background:i(a.background),text:a.text}};parseColor=i=>{if(i.startsWith(`rgb`))return r(n(i));if(i.startsWith(`#`))return r(e(i));if(i.startsWith(`hsl`))return t(i)};getColor=(t=`0`)=>{let n=this.theme,i;if(this.colorCache[n][t])return this.colorCache[n][t];i=t in this.definedColors[n]?this.hslProcessor(this.definedColors[n][t]):this.hslProcessor(r(e(t)));let a={...i,"border-width":t===`0`?`1px`:`2px`};return this.colorCache[n][t]=a,a};getNamedColor=e=>this.namedColors[this.theme][e];changeTheme=e=>{this.theme=e||(this.theme===`dark`?`light`:`dark`);let t=this.container.get(O).data.container;Object.entries(this.namedColors[this.theme]).forEach(([e,n])=>{t.style.setProperty(`--${e}`,n)}),this.onChangeTheme(this.theme)}},A=class extends v{animationId=null;resizeAnimationId=null;DM;SM;resizeObserver;perFrame={lastScale:1,lastOffsets:{x:0,y:0}};lastResizeCenter={x:null,y:null};onResize=b.makeHook();onRefresh=b.makeHook();constructor(...e){super(...e),this.DM=this.container.get(O),this.SM=this.container.get(k),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(()=>{let 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 j={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},M=[`markdown`,`image`,`audio`,`video`];var N=class extends v{_overlaysLayer=document.createElement(`div`);overlays={};selectedId=null;aborted=!1;eventListeners={};DM;SM;parse;componentDict={text:(e,t)=>{e.classList.add(`JCV-markdown-content`);let 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`);let n=document.createElement(`div`);n.textContent=`Loading...`,n.classList.add(`JCV-parsed-content-wrapper`),e.appendChild(n);let r;try{let e=await(await fetch(t)).text(),n=e.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);r=n?await this.parse(n[2]):await this.parse(e)}catch(e){console.error(`[JSON Canvas Viewer] Failed to load markdown:`,e),r=`Failed to load content.`}n.innerHTML=r},link:(e,t)=>{let 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)=>{let n=document.createElement(`audio`);n.className=`JCV-audio`,n.src=t,n.controls=!0,e.appendChild(n)},image:(e,t)=>{let n=document.createElement(`img`);n.className=`JCV-img`,n.src=t,n.loading=`lazy`,e.appendChild(n)},video:(e,t)=>{let n=document.createElement(`video`);n.className=`JCV-video`,n.src=t,n.controls=!0,e.appendChild(n)}};get overlaysLayer(){if(!this._overlaysLayer)throw x;return this._overlaysLayer}onInteractionStart=b.makeHook();onInteractionEnd=b.makeHook();onNodeActive=b.makeHook();onNodeLosesActive=b.makeHook();constructor(...e){super(...e),this.parse=this.options.parser||(e=>e),this.DM=this.container.get(O),this.SM=this.container.get(k),this.container.get(A).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);let 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(P).onClick.subscribe(this.select),this.renderOverlays()};restart=()=>{this.clearOverlays(),this.renderOverlays()};renderOverlays=()=>{let e=async e=>{switch(e.type){case`text`:this.createOverlay(e,await this.parse(e.text),`text`);break;case`file`:for(let t of M)if(e.file.match(j[t])){this.createOverlay(e,e.file,t);break}break;case`link`:this.createOverlay(e,e.url,`link`);break}};Object.values(this.DM.data.nodeMap).forEach(async t=>{await e(t.ref)})};themeChanged=()=>{Object.values(this.overlays).forEach(e=>{let t=this.DM.data.nodeMap[e.id].ref,n=this.SM.getColor(t.color);this.setOverlayColor(e,n)})};select=e=>{let t=this.selectedId,n=t?this.overlays[t]:null,r=e?this.overlays[e]:null;if(n&&t){n.classList.remove(`JCV-active`);let e=this.DM.data.nodeMap[t];this.onNodeLosesActive(e.ref),e.onLoseActive?.()}if(r&&e){r.classList.add(`JCV-active`),this.onInteractionStart();let t=this.DM.data.nodeMap[e];this.onNodeActive(t.ref),t.onActive?.()}else this.onInteractionEnd();this.selectedId=e};updateOverlays=()=>{let e=this.DM.data;this.overlaysLayer.style.transform=`translate(${e.offsetX}px, ${e.offsetY}px) scale(${e.scale})`};createOverlay=(...e)=>{if(this.aborted)return;let t=e[0],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)=>{let t=e[0],n=document.createElement(`div`);n.classList.add(`JCV-overlay-container`),n.id=t.id,this.setOverlayColor(n,this.SM.getColor(t.color));let r=document.createElement(`div`);r.classList.add(`JCV-content`),n.appendChild(r);let i=document.createElement(`div`);i.className=`JCV-click-layer`,n.appendChild(i);let a=document.createElement(`div`);a.className=`JCV-overlay-border`,n.appendChild(a);let o=this.DM.data.nodeMap[t.id];o.onActive=b.makeHook(),o.onLoseActive=b.makeHook(),o.onBeforeUnmount=b.makeHook(),this.componentDict[e[2]](r,e[1],e[0],o.onBeforeUnmount,o.onActive,o.onLoseActive);let s=()=>{t.id===this.selectedId&&this.onInteractionStart()},c=()=>{t.id===this.selectedId&&this.onInteractionEnd()};return n.addEventListener(`pointerenter`,s),n.addEventListener(`pointerleave`,c),n.addEventListener(`touchstart`,s),n.addEventListener(`touchend`,c),this.eventListeners[t.id]=[s,c],n};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]){let n=this.eventListeners[e][0],r=this.eventListeners[e][1];if(!n||!r)throw x;t.removeEventListener(`pointerenter`,n),t.removeEventListener(`pointerleave`,r),t.removeEventListener(`touchstart`,n),t.removeEventListener(`touchend`,r),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}},P=class extends v{pointeract;DM;onClick=b.makeHook();constructor(...e){super(...e),this.DM=this.container.get(O);let t=Object.assign(this.options.pointeract??{},{coordinateOutput:`relative`,element:this.DM.data.container,lubricator:{pan:p,zoom:m,drag:f}});this.pointeract=new l(t,[a,o,d,u,c,s]);let n=this.container.get(N);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)=>{let n=Math.max(Math.min(this.DM.data.scale*e,20),.05);if(n===this.DM.data.scale)return;let r=n/this.DM.data.scale,i=this.C2C(t);this.DM.data.offsetX=t.x-i.x*r,this.DM.data.offsetY=t.y-i.y*r,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)=>{let 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=>{let t=e.target;if(this.isUIControl(t))return;let n=this.findNodeId(t);this.onClick(n)};isUIControl=e=>e?e.closest(`.controls`)||e.closest(`button`)||e.closest(`input`):!1;findNodeId=e=>{if(!e)return null;let t=e;for(;(!t.id||t.id===``)&&t.parentElement;)t=t.parentElement;return t.id===`overlays`||!t.id||t.id===``?null:t.id};dispose=()=>this.pointeract.dispose()},F=`.JSON-Canvas-Viewer > .JCV-controls {
|
|
285
|
+
position: absolute;
|
|
286
|
+
top: 10px;
|
|
287
|
+
right: 10px;
|
|
288
|
+
display: flex;
|
|
289
|
+
align-items: center;
|
|
290
|
+
transition: transform 200ms;
|
|
291
|
+
border-radius: 8px;
|
|
292
|
+
gap: 10px;
|
|
293
|
+
}
|
|
294
|
+
.JSON-Canvas-Viewer > .JCV-controls.JCV-collapsed {
|
|
295
|
+
transform: translateX(calc(100% - 30px));
|
|
296
|
+
}
|
|
297
|
+
.JSON-Canvas-Viewer > .JCV-controls .JCV-controls-content {
|
|
298
|
+
display: flex;
|
|
299
|
+
gap: 1px;
|
|
300
|
+
align-items: center;
|
|
301
|
+
border-radius: 8px;
|
|
302
|
+
overflow: hidden;
|
|
303
|
+
background: var(--border);
|
|
304
|
+
box-shadow: var(--shadow);
|
|
305
|
+
outline: 1px solid var(--border);
|
|
306
|
+
}
|
|
307
|
+
.JSON-Canvas-Viewer > .JCV-controls .JCV-zoom-slider {
|
|
308
|
+
width: 100px;
|
|
309
|
+
margin: 0 10px;
|
|
310
|
+
}
|
|
311
|
+
`;const I=`<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>`;var L=class extends v{_controlsPanel=null;_toggleCollapseBtn=null;_toggleFullscreenBtn=null;_zoomOutBtn=null;_zoomSlider=null;_zoomInBtn=null;_resetViewBtn=null;DM;IH;collapsed;get controlsPanel(){if(this._controlsPanel===null)throw x;return this._controlsPanel}get toggleCollapseBtn(){if(this._toggleCollapseBtn===null)throw x;return this._toggleCollapseBtn}get toggleFullscreenBtn(){if(this._toggleFullscreenBtn===null)throw x;return this._toggleFullscreenBtn}get zoomOutBtn(){if(this._zoomOutBtn===null)throw x;return this._zoomOutBtn}get zoomSlider(){if(this._zoomSlider===null)throw x;return this._zoomSlider}get zoomInBtn(){if(this._zoomInBtn===null)throw x;return this._zoomInBtn}get resetViewBtn(){if(this._resetViewBtn===null)throw x;return this._resetViewBtn}constructor(...e){super(...e),this.collapsed=this.options.controlsCollapsed??!1,this.DM=this.container.get(O),this.IH=this.container.get(P),this.DM.onToggleFullscreen.subscribe(this.updateFullscreenBtn),this.container.get(A).onRefresh.subscribe(this.updateSlider),this._controlsPanel=document.createElement(`div`),this._controlsPanel.className=`JCV-controls`,this._controlsPanel.classList.toggle(`JCV-collapsed`,this.collapsed),b.applyStyles(this._controlsPanel,F),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);let t=document.createElement(`div`);t.className=`JCV-controls-content`,this._toggleFullscreenBtn=document.createElement(`button`),this._toggleFullscreenBtn.className=`JCV-button`,this._toggleFullscreenBtn.innerHTML=I,t.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>`,t.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`,t.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>`,t.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>`,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(`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=>{e===`enter`?this.toggleFullscreenBtn.innerHTML=`<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>`:this.toggleFullscreenBtn.innerHTML=I};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}},R=`.JSON-Canvas-Viewer > .JCV-debug-panel {
|
|
312
|
+
position: absolute;
|
|
313
|
+
bottom: 12px;
|
|
314
|
+
left: 12px;
|
|
315
|
+
border-radius: 12px;
|
|
316
|
+
padding: 12px;
|
|
317
|
+
color: var(--text);
|
|
318
|
+
font-size: calc(14px + 0.3vw);
|
|
319
|
+
line-height: calc(17px + 0.3vw);
|
|
320
|
+
pointer-events: none;
|
|
321
|
+
}
|
|
322
|
+
`,z=class extends v{_debugPanel=null;DM;get debugPanel(){if(!this._debugPanel)throw x;return this._debugPanel}constructor(...e){super(...e),this.DM=this.container.get(O),this.container.get(A).onRefresh.subscribe(this.update),this._debugPanel=document.createElement(`div`),this._debugPanel.className=`JCV-debug-panel JCV-border-shadow-bg`;let t=this.DM.data.container;b.applyStyles(t,R),t.appendChild(this._debugPanel),this.onDispose(this.dispose)}update=()=>{let e=b.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}},B=`.JSON-Canvas-Viewer > .JCV-minimap-container {
|
|
323
|
+
position: absolute;
|
|
324
|
+
bottom: 10px;
|
|
325
|
+
right: 10px;
|
|
326
|
+
display: flex;
|
|
327
|
+
pointer-events: none;
|
|
328
|
+
transition: transform 200ms;
|
|
329
|
+
}
|
|
330
|
+
.JSON-Canvas-Viewer > .JCV-minimap-container.JCV-collapsed {
|
|
331
|
+
transform: translateX(calc(100% - 30px));
|
|
332
|
+
}
|
|
333
|
+
.JSON-Canvas-Viewer > .JCV-minimap-container .JCV-toggle-minimap {
|
|
334
|
+
margin: auto 10px 0 0;
|
|
335
|
+
pointer-events: auto;
|
|
336
|
+
}
|
|
337
|
+
.JSON-Canvas-Viewer > .JCV-minimap-container .JCV-minimap {
|
|
338
|
+
position: relative;
|
|
339
|
+
pointer-events: none;
|
|
340
|
+
width: 200px;
|
|
341
|
+
height: 150px;
|
|
342
|
+
overflow: hidden;
|
|
343
|
+
border-radius: 12px;
|
|
344
|
+
transform-origin: 0 0;
|
|
345
|
+
}
|
|
346
|
+
.JSON-Canvas-Viewer > .JCV-minimap-container .JCV-minimap .JCV-minimap-canvas {
|
|
347
|
+
width: 100%;
|
|
348
|
+
height: 100%;
|
|
349
|
+
}
|
|
350
|
+
.JSON-Canvas-Viewer > .JCV-minimap-container .JCV-minimap .JCV-viewport-rectangle {
|
|
351
|
+
position: absolute;
|
|
352
|
+
top: 0;
|
|
353
|
+
left: 0;
|
|
354
|
+
pointer-events: none;
|
|
355
|
+
border-radius: 6px;
|
|
356
|
+
box-sizing: border-box;
|
|
357
|
+
border: 2px dashed var(--text);
|
|
358
|
+
}
|
|
359
|
+
@container (max-width: 768px) {
|
|
360
|
+
.JSON-Canvas-Viewer > .JCV-minimap-container .JCV-container .JCV-minimap {
|
|
361
|
+
transform: scale(0.6);
|
|
362
|
+
}
|
|
363
|
+
.JSON-Canvas-Viewer > .JCV-minimap-container .JCV-container .JCV-toggle-minimap {
|
|
364
|
+
transform: translateY(-60px);
|
|
365
|
+
}
|
|
366
|
+
.collapsed .JSON-Canvas-Viewer > .JCV-minimap-container .JCV-container .JCV-toggle-minimap {
|
|
367
|
+
transform: translateY(-60px) rotate(180deg);
|
|
368
|
+
}
|
|
369
|
+
.JSON-Canvas-Viewer > .JCV-minimap-container .JCV-container .JCV-minimap-container {
|
|
370
|
+
transform: translateY(60px) translateX(80px);
|
|
371
|
+
}
|
|
372
|
+
.JSON-Canvas-Viewer > .JCV-minimap-container .JCV-container .JCV-minimap-container.JCV-collapsed {
|
|
373
|
+
transform: translateY(60px) translateX(calc(100% - 32px));
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
`,V=class extends v{_minimapCtx=null;_viewportRectangle=null;_minimap=null;_minimapContainer=null;_toggleMinimapBtn=null;minimapCache={scale:1,centerX:0,centerY:0};DM;SM;collapsed;get minimap(){if(this._minimap===null)throw x;return this._minimap}get minimapCtx(){if(this._minimapCtx===null)throw x;return this._minimapCtx}get viewportRectangle(){if(this._viewportRectangle===null)throw x;return this._viewportRectangle}get minimapContainer(){if(this._minimapContainer===null)throw x;return this._minimapContainer}get toggleMinimapBtn(){if(this._toggleMinimapBtn===null)throw x;return this._toggleMinimapBtn}constructor(...e){super(...e),this.collapsed=this.options.minimapCollapsed??!1,this.container.get(A).onRefresh.subscribe(this.updateViewportRectangle),this.DM=this.container.get(O),this.SM=this.container.get(k),this._minimapContainer=document.createElement(`div`),this._minimapContainer.className=`JCV-minimap-container`,b.applyStyles(this._minimapContainer,B),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`;let t=document.createElement(`canvas`);t.className=`JCV-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=`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),b.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(`JCV-collapsed`,this.collapsed),this.collapsed||this.updateViewportRectangle()};start=()=>{let e=this.DM.data.nodeBounds;if(!e)return;let t=this.minimap.clientWidth,n=this.minimap.clientHeight,r=t/e.width,i=n/e.height;this.minimapCache.scale=Math.min(r,i)*.9,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);let a=this.DM.data.canvasData;for(let e of a.edges)this.drawMinimapEdge(e);for(let e of a.nodes)this.drawMinimapNode(e);this.minimapCtx.restore()};drawMinimapNode=e=>{let t=this.SM.getColor(e.color);this.minimapCtx.fillStyle=t.border,b.drawRoundRect(this.minimapCtx,e.x,e.y,e.width,e.height,25),this.minimapCtx.fill()};drawMinimapEdge=e=>{let t=this.DM.data.nodeMap,n=t[e.fromNode].ref,r=t[e.toNode].ref;if(!n||!r)return;let{x:i,y:a}=b.getAnchorCoord(n,e.fromSide),{x:o,y:s}=b.getAnchorCoord(r,e.toSide);this.minimapCtx.beginPath(),this.minimapCtx.moveTo(i,a),this.minimapCtx.lineTo(o,s),this.minimapCtx.strokeStyle=this.SM.getColor(e.color).active,this.minimapCtx.lineWidth=10,this.minimapCtx.stroke()};updateViewportRectangle=()=>{if(this.collapsed)return;let e=this.DM.data.nodeBounds,t=this.DM.data.container,n=this.DM.data.scale;if(!e)return;let r=t.clientWidth/n,i=t.clientHeight/n,a=-this.DM.data.offsetX/n+t.clientWidth/(2*n),o=-this.DM.data.offsetY/n+t.clientHeight/(2*n),s=this.minimapCache.centerX+(a-r/2-e.centerX)*this.minimapCache.scale,c=this.minimapCache.centerY+(o-i/2-e.centerY)*this.minimapCache.scale,l=r*this.minimapCache.scale,u=i*this.minimapCache.scale;this.viewportRectangle.style.left=`${s}px`,this.viewportRectangle.style.top=`${c}px`,this.viewportRectangle.style.width=`${l}px`,this.viewportRectangle.style.height=`${u}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}},H=`.JSON-Canvas-Viewer.JCV-numb, .JSON-Canvas-Viewer.JCV-numb * {
|
|
377
|
+
pointer-events: none !important;
|
|
378
|
+
}
|
|
379
|
+
.JSON-Canvas-Viewer .JCV-prevention-container {
|
|
380
|
+
overflow: visible;
|
|
381
|
+
transition: background 200ms, opacity 200ms, box-shadow 200ms, border 200ms, filter 200ms, backdrop-filter 200ms;
|
|
382
|
+
}
|
|
383
|
+
.JSON-Canvas-Viewer .JCV-prevention-container.JCV-hidden {
|
|
384
|
+
pointer-events: none;
|
|
385
|
+
opacity: 0;
|
|
386
|
+
}
|
|
387
|
+
.JSON-Canvas-Viewer .JCV-prevention-container .JCV-prevention-banner {
|
|
388
|
+
border-radius: 12px;
|
|
389
|
+
padding: 12px;
|
|
390
|
+
margin: 12px;
|
|
391
|
+
font-size: calc(14px + 0.3vw);
|
|
392
|
+
line-height: calc(17px + 0.3vw);
|
|
393
|
+
text-align: center;
|
|
394
|
+
}
|
|
395
|
+
`,U=class extends v{_preventionContainer=null;preventMt=!1;DM;preventMistouch={record:!1,lastX:0,lastY:0,initialX:0,initialY:0};get preventionContainer(){if(this._preventionContainer===null)throw x;return this._preventionContainer}constructor(...e){super(...e);let t=document.createElement(`div`);t.className=`JCV-prevention-banner JCV-border-shadow-bg`,t.textContent=this.options.mistouchPreventerBannerText??`Click on to unlock.`,this.DM=this.container.get(O),this._preventionContainer=document.createElement(`div`),this._preventionContainer.className=`JCV-prevention-container JCV-hidden JCV-full JCV-flex-center`,b.applyStyles(this._preventionContainer,H),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=>{let 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}};const W=[O,k,A,N,P,class extends v{_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 x;return this._canvas}constructor(...e){super(...e);let t=this.container.get(A);this.SM=this.container.get(k),t.onRefresh.subscribe(this.redraw),t.onResize.subscribe(this.optimizeDPR),this.DM=this.container.get(O),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=()=>{let e=this.DM.data.container;b.resizeCanvasForDPR(this.canvas,e.offsetWidth,e.offsetHeight)};redraw=()=>{let e=this.DM.data.offsetX,t=this.DM.data.offsetY,n=this.DM.data.scale,r=this.getCurrentViewport(e,t,n);if(!this.options.zoomInOptimization){this.trueRedraw(e,t,n,r);return}this.zoomInOptimize.timeout&&(clearTimeout(this.zoomInOptimize.timeout),this.zoomInOptimize.timeout=null);let i=Date.now();if(this.isInside(r,this.zoomInOptimize.lastDrawnViewport)&&n!==this.zoomInOptimize.lastDrawnScale&&i-this.zoomInOptimize.lastCallTime<500){this.zoomInOptimize.timeout=window.setTimeout(()=>{this.trueRedraw(e,t,n,r),this.zoomInOptimize.lastCallTime=i,this.zoomInOptimize.timeout=null},60),this.fakeRedraw(r,n);return}this.zoomInOptimize.lastCallTime=i,this.trueRedraw(e,t,n,r)};trueRedraw(e,t,n,r){this.zoomInOptimize.lastDrawnViewport=r,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,r))return;let t=e.ref;t.type===`file`?this.drawFile(e):t.type===`group`&&this.drawGroup(t,n)}),Object.values(this.DM.data.edgeMap).forEach(e=>{this.isOutside(e.box,r)||this.drawEdge(e)}),this.ctx.restore()}fakeRedraw(e,t){let n=t/this.zoomInOptimize.lastDrawnScale,r=(this.zoomInOptimize.lastDrawnViewport.left-e.left)*t,i=(this.zoomInOptimize.lastDrawnViewport.top-e.top)*t;this.canvas.style.transform=`translate(${r}px, ${i}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)=>{let r=-e/n,i=-t/n,a=this.DM.data.container;return{left:r,top:i,right:r+a.clientWidth/n,bottom:i+a.clientHeight/n}};drawLabelBar=(e,t,n,r,i,a)=>{let o=30*a,s=6*a,c=8*a,l=16*a,u=6*a;this.ctx.save(),this.ctx.translate(e,t),this.ctx.scale(1/a,1/a),this.ctx.font=`${l}px 'Inter', sans-serif`;let d=this.ctx.measureText(n).width+2*u;this.ctx.translate(0,-o-c),this.ctx.fillStyle=r,this.ctx.beginPath(),this.ctx.moveTo(s,0),this.ctx.lineTo(d-s,0),this.ctx.quadraticCurveTo(d,0,d,s),this.ctx.lineTo(d,o-s),this.ctx.quadraticCurveTo(d,o,d-s,o),this.ctx.lineTo(s,o),this.ctx.quadraticCurveTo(0,o,0,o-s),this.ctx.lineTo(0,s),this.ctx.quadraticCurveTo(0,0,s,0),this.ctx.closePath(),this.ctx.fill(),this.ctx.fillStyle=i,this.ctx.fillText(n,u,o*.65),this.ctx.restore()};drawNodeBackground=e=>{let t=this.SM.getColor(e.color);this.ctx.globalAlpha=1,this.ctx.fillStyle=t.background,b.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,b.drawRoundRect(this.ctx,e.x,e.y,e.width,e.height,12),this.ctx.stroke()};drawGroup=(e,t)=>{if(this.drawNodeBackground(e),e.label){let 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;let t=e.ref;this.ctx.font=`16px sans-serif`,this.ctx.fillText(e.fileName??``,t.x+5,t.y-10)};drawEdge=e=>{let t=e.ref,n=this.DM.data.nodeMap[t.fromNode].ref,r=this.DM.data.nodeMap[t.toNode].ref,i=b.getAnchorCoord,{x:a,y:o}=i(n,t.fromSide),{x:s,y:c}=i(r,t.toSide),l=this.SM.getColor(t.color),[u,d,f,p]=[0,0,0,0];if(e.controlPoints?[u,d,f,p]=e.controlPoints:([u,d,f,p]=this.getControlPoints(a,o,s,c,t.fromSide,t.toSide),e.controlPoints=[u,d,f,p]),this.drawCurvedPath(a,o,s,c,u,d,f,p,l.active),this.drawArrowhead(s,c,f,p,l.active),t.label){let e=.5,n=(1-e)**3*a+3*(1-e)**2*e*u+3*(1-e)*e*e*f+e**3*s,r=(1-e)**3*o+3*(1-e)**2*e*d+3*(1-e)*e*e*p+e**3*c;this.ctx.font=`18px sans-serif`;let i=this.ctx.measureText(t.label).width+16;this.ctx.fillStyle=l.active,this.ctx.beginPath(),b.drawRoundRect(this.ctx,n-i/2,r-20/2-2,i,20,4),this.ctx.fill(),this.ctx.fillStyle=l.text,this.ctx.textAlign=`center`,this.ctx.textBaseline=`middle`,this.ctx.fillText(t.label,n,r-2),this.ctx.textAlign=`left`,this.ctx.textBaseline=`alphabetic`}};getControlPoints=(e,t,n,r,i,a)=>{let o=n-e,s=r-t,c=((e,t,n)=>Math.max(t,Math.min(n,e)))((Math.min(Math.abs(o),Math.abs(s))+.3*Math.max(Math.abs(o),Math.abs(s)))*.5,60,300),l=e,u=t,d=n,f=r;switch(i){case`top`:u=t-c;break;case`bottom`:u=t+c;break;case`left`:l=e-c;break;case`right`:l=e+c;break}switch(a){case`top`:f=r-c;break;case`bottom`:f=r+c;break;case`left`:d=n-c;break;case`right`:d=n+c;break}return[l,u,d,f]};drawGridDots=(e,t,n)=>{let r=10*2**-Math.floor(Math.log2(e))*e,i=this.canvas.width,a=this.canvas.height,o=t%r,s=n%r;this.ctx.fillStyle=this.SM.getNamedColor(`dots`);for(let e=o;e<=i;e+=r)for(let t=s;t<=a;t+=r)this.ctx.beginPath(),this.ctx.arc(e,t,1,0,2*Math.PI),this.ctx.fill()};drawCurvedPath=(e,t,n,r,i,a,o,s,c)=>{this.ctx.beginPath(),this.ctx.moveTo(e,t),this.ctx.bezierCurveTo(i,a,o,s,n,r),this.ctx.strokeStyle=c,this.ctx.lineWidth=2,this.ctx.stroke()};drawArrowhead=(e,t,n,r,i)=>{let a=e-n,o=t-r,s=Math.sqrt(a*a+o*o);if(s===0)return;let c=a/s,l=o/s,u=e-c*12-l*4,d=t-l*12+c*4,f=e-c*12+l*4,p=t-l*12-c*4;this.ctx.beginPath(),this.ctx.fillStyle=i,this.ctx.moveTo(e,t),this.ctx.lineTo(u,d),this.ctx.lineTo(f,p),this.ctx.closePath(),this.ctx.fill()};dispose=()=>{this.zoomInOptimize.timeout&&(clearTimeout(this.zoomInOptimize.timeout),this.zoomInOptimize.timeout=null),this.canvas.remove(),this._canvas=null}}];var G=class{allModules;IO=null;started=!1;disposed=!1;options;container;onDispose=b.makeHook(!0);onStart=b.makeHook();onRestart=b.makeHook();constructor(e,t){this.container=new h,this.options=e;let n=e=>{this.container.bind({provide:e,useFactory:()=>new e(this.container,this.options,this.onStart,this.onDispose,this.onRestart,this.augment)})};this.allModules=[...W,...t??[]],this.allModules.forEach(n),this.allModules.forEach(e=>{this.container.get(e)});let r=this.options.loading??`normal`;r===`normal`?this.load():r===`lazy`&&(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){this.load(),this.IO?.disconnect(),this.IO=null;return}})};augment=e=>{let 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;let e=this.options.container;for(;e.firstChild;)e.firstChild.remove();this.onDispose(),this.container.unbindAll(),this.disposed=!0}};async function K(e){return g.sanitize(await _(e))}async function q(e){return await fetch(e).then(e=>e.json())}export{L as Controls,z as DebugPanel,G as JSONCanvasViewer,V as Minimap,U as MistouchPreventer,q as fetchCanvas,K as parser};
|