apexsankey 1.12.3 → 1.12.4

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/apexsankey.min.js CHANGED
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ApexSankey={})}(this,(function(t){"use strict";const e=()=>{};class n{constructor(t,e){this.injectedStyles=new Set,this.trackedTooltips=new Set,this.instanceId=e||Math.random().toString(36).substr(2,9),this.context=this.detectContext(t),this.chartContainer=t}getChartContainer(){return this.chartContainer}getChartScopedContainer(){return this.context===document?document.body||document.getElementsByTagName("body")[0]:this.chartContainer||this.context}detectContext(t){const e=t.getRootNode();return e instanceof ShadowRoot?e:document}getContext(){return this.context}getInstanceId(){return this.instanceId}isShadowDOM(){return this.context instanceof ShadowRoot}createElement(t){return document.createElement(t)}createElementNS(t,e){return document.createElementNS(t,e)}createTextNode(t){return document.createTextNode(t)}getElementById(t){return this.context===document?document.getElementById(t):this.context.querySelector(`#${t}`)}getElementsByClassName(t){if(this.context===document)return document.getElementsByClassName(t);const e=this.context.querySelectorAll(`.${t}`),n=Array.from(e);return{item:t=>n[t]||null,get length(){return n.length},[Symbol.iterator]:()=>n[Symbol.iterator](),...Object.fromEntries(n.map(((t,e)=>[e,t])))}}querySelector(t){return this.context.querySelector(t)}querySelectorAll(t){return this.context.querySelectorAll(t)}getAppendContainer(){return this.context===document?document.body||document.getElementsByTagName("body")[0]:this.context}getChartBounds(){var t;return(null==(t=this.chartContainer)?void 0:t.getBoundingClientRect())||new DOMRect}getBody(){if(this.context===document)return document.body||document.getElementsByTagName("body")[0];return this.context.host}dispatchEvent(t){this.context===document?document.dispatchEvent(t):this.context.dispatchEvent(t)}addEventListener(t,e,n){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.addEventListener(t,e,n):this.context.addEventListener(t,e,n)}removeEventListener(t,e,n){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.removeEventListener(t,e,n):this.context.removeEventListener(t,e,n)}injectStyles(t,e,n={}){const{force:o=!1,priority:i="normal"}=n;if(!o&&this.injectedStyles.has(e))return;if(o){const t=this.context.querySelector(`#${e}`);t&&(t.remove(),this.injectedStyles.delete(e))}if(this.context.querySelector(`#${e}`)&&!o)return void this.injectedStyles.add(e);const s=document.createElement("style");if(s.id=e,s.textContent=t,"normal"!==i&&s.setAttribute("data-priority",i),this.context===document)document.head.appendChild(s);else{const t=this.context;"high"===i?t.insertBefore(s,t.firstChild):t.appendChild(s)}this.injectedStyles.add(e)}injectStylesheets(t){t.forEach((({content:t,id:e,options:n})=>{this.injectStyles(t,e,n)}))}hasInjectedStyles(t){return this.injectedStyles.has(t)}removeStyles(t){const e=this.context.querySelector(`#${t}`);e&&(e.remove(),this.injectedStyles.delete(t))}removeAllStyles(){this.injectedStyles.forEach((t=>{const e=this.context.querySelector(`#${t}`);e&&e.remove()})),this.injectedStyles.clear()}getInjectedStyleIds(){return Array.from(this.injectedStyles)}getActiveElement(){if(this.context===document)return document.activeElement;return this.context.activeElement||document.activeElement}trackTooltip(t){this.trackedTooltips.add(t)}destroy(){this.removeAllStyles(),this.injectedStyles.clear(),this.trackedTooltips.forEach((t=>t.remove())),this.trackedTooltips.clear()}}class o{constructor(t,e){if(!t)throw new Error("Container element is required");this.element=t,this.chartContext=new n(t,e)}getContext(){return this.chartContext}isShadowDOM(){return this.chartContext.isShadowDOM()}getTooltipContainer(){return this.chartContext.getAppendContainer()}injectStyles(t,e){this.chartContext.injectStyles(t,e)}createElement(t){return this.chartContext.createElement(t)}querySelector(t){return this.chartContext.querySelector(t)}addEventListener(t,e,n){this.chartContext.addEventListener(t,e,n)}removeEventListener(t,e,n){this.chartContext.removeEventListener(t,e,n)}dispatchEvent(t){this.chartContext.dispatchEvent(t)}destroy(){this.chartContext.destroy()}getInstanceId(){return this.chartContext.getInstanceId()}}class i{constructor(t,e="apex"){this.canvas=t,this.prefix=e}getSvgString(){const t=this.canvas.node.cloneNode(!0),e=this.canvas.node.viewBox.baseVal;e.width&&e.height&&(t.setAttribute("width",String(e.width)),t.setAttribute("height",String(e.height)));return(new XMLSerializer).serializeToString(t)}svgUrl(){const t=this.getSvgString(),e=new Blob([t],{type:"image/svg+xml;charset=utf-8"});return URL.createObjectURL(e)}triggerDownload(t,e){const n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}exportToSVG(){this.triggerDownload(this.svgUrl(),`${this.prefix}-${(new Date).getTime()}.svg`)}}const s="http://www.w3.org/2000/svg";let r=0;class a{constructor(t){this.node=t}attr(t,e){if("string"==typeof t)return void 0!==e?(this.node.setAttribute(t,String(e)),this):this.node.getAttribute(t);for(const[e,n]of Object.entries(t))null!=n&&this.node.setAttribute(e,String(n));return this}id(t){return this.node.setAttribute("id",t),this}fill(t){if(!t)return this;if(t instanceof SVGElement){const e=t.id;this.node.setAttribute("fill",`url(#${e})`)}else this.node.setAttribute("fill",t);return this}stroke({color:t,width:e,dasharray:n}={}){return void 0!==t&&this.node.setAttribute("stroke",t),void 0!==e&&this.node.setAttribute("stroke-width",String(e)),void 0!==n&&this.node.setAttribute("stroke-dasharray",String(n)),this}opacity(t){return this.node.setAttribute("opacity",String(t)),this}add(t){const e=t instanceof a?t.node:t;return this.node.appendChild(e),this}on(t,e){return this.node.addEventListener(t,e),this}findOne(t){const e=this.node.querySelector(t);return e?new a(e):null}first(){const t=this.node.firstElementChild;return t?new a(t):null}}class d extends a{constructor(t){super(document.createElementNS(s,"g")),t&&this.attr(t)}}class l extends a{constructor(){super(document.createElementNS(s,"rect"))}}class c extends a{constructor(t){super(document.createElementNS(s,"path")),t&&this.attr(t)}}class h extends a{constructor(){super(document.createElementNS(s,"text"))}font({fill:t,size:e}){return void 0!==t&&this.node.setAttribute("fill",t),void 0!==e&&this.node.setAttribute("font-size",String(e)),this}tspan(t){const e=document.createElementNS(s,"tspan");return e.textContent=t,this.node.appendChild(e),this}move(t,e){return this.node.setAttribute("x",String(t)),this.node.setAttribute("y",String(e)),this}}class u{constructor(t){this.gradient=t}stop(t,e){const n=document.createElementNS(s,"stop");n.setAttribute("offset",String(t)),n.setAttribute("stop-color",e??"transparent"),this.gradient.appendChild(n)}}function p(t,e){t.setAttribute("viewBox",`${e.x} ${e.y} ${e.w} ${e.h}`)}class g{constructor(t){this._defs=null,this._panZoomState=null,this.node=t}addTo(t){return t.appendChild(this.node),this}size(t,e){return this.node.setAttribute("width",String(t)),this.node.setAttribute("height",String(e)),this}viewbox(t){if(void 0===t){const t=this.node.viewBox.baseVal;return{x:t.x,y:t.y,width:t.width,height:t.height}}if(this.node.setAttribute("viewBox",t),this._panZoomState){const t=this.node.viewBox.baseVal;this._panZoomState.vb={x:t.x,y:t.y,w:t.width,h:t.height}}return this}attr(t){for(const[e,n]of Object.entries(t))null!=n&&this.node.setAttribute(e,String(n));return this}add(t){return this.node.appendChild(t instanceof a?t.node:t),this}clear(){const t=this._defs;return this.node.innerHTML="",t&&(this.node.appendChild(t),this._defs=t),this}svg(){return this.node.innerHTML}gradient(t,e){this._defs||(this._defs=document.createElementNS(s,"defs"),this.node.insertBefore(this._defs,this.node.firstChild));const n=document.createElementNS(s,"linearGradient"),o="apx-grad-"+ ++r;return n.setAttribute("id",o),n.setAttribute("x1","0%"),n.setAttribute("y1","0%"),n.setAttribute("x2","100%"),n.setAttribute("y2","0%"),e(new u(n)),this._defs.appendChild(n),n}panZoom(t={}){return this._panZoomState=function(t,e){const n=function(t){const e=t.viewBox.baseVal;return{x:e.x,y:e.y,w:e.width,h:e.height}}(t),o={zoomMin:e.zoomMin??.1,currentZoom:1,baseVb:{...n},vb:{...n}};t.addEventListener("wheel",(e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const n=1+Math.max(-.12,Math.min(.12,.0025*e.deltaY)),i=o.currentZoom/n;if(i<o.zoomMin)return;const s=t.getBoundingClientRect(),r=(e.clientX-s.left)/s.width,a=(e.clientY-s.top)/s.height,{vb:d}=o,l=d.w*n,c=d.h*n,h=d.x+r*(d.w-l),u=d.y+a*(d.h-c);o.vb={x:h,y:u,w:l,h:c},o.currentZoom=i,p(t,o.vb)}),{passive:!1});let i=!1,s=!1,r=-1,a=0,d=0;t.addEventListener("pointerdown",(t=>{0===t.button&&(t.preventDefault(),i=!0,s=!1,r=t.pointerId,a=t.clientX,d=t.clientY)})),t.addEventListener("pointermove",(e=>{if(!i||e.pointerId!==r)return;if(!s){const n=e.clientX-a,o=e.clientY-d;if(Math.abs(n)<4&&Math.abs(o)<4)return;s=!0,t.setPointerCapture(e.pointerId),t.style.cursor="grabbing",t.style.userSelect="none"}const n=t.getBoundingClientRect(),l=o.vb.w/n.width,c=o.vb.h/n.height,h=(e.clientX-a)*l,u=(e.clientY-d)*c;o.vb={x:o.vb.x-h,y:o.vb.y-u,w:o.vb.w,h:o.vb.h},p(t,o.vb),a=e.clientX,d=e.clientY}));const l=e=>{i&&e.pointerId===r&&(s&&(t.releasePointerCapture(e.pointerId),t.style.cursor="",t.style.userSelect=""),i=!1,s=!1,r=-1)};return t.addEventListener("pointerup",l),t.addEventListener("pointercancel",l),o}(this.node,t),this}resetPanZoomBase(){if(!this._panZoomState)return;const t=this.node.viewBox.baseVal;this._panZoomState.baseVb={x:t.x,y:t.y,w:t.width,h:t.height},this._panZoomState.vb={x:t.x,y:t.y,w:t.width,h:t.height},this._panZoomState.currentZoom=1}zoom(t){var e;if(void 0===t)return(null==(e=this._panZoomState)?void 0:e.currentZoom)??1;if(!this._panZoomState)return this;const n=this._panZoomState;if(t<n.zoomMin)return this;const o=n.currentZoom/t,{vb:i}=n,s=i.w*o,r=i.h*o,a=i.x+.5*(i.w-s),d=i.y+.5*(i.h-r);return n.vb={x:a,y:d,w:s,h:r},n.currentZoom=t,p(this.node,n.vb),this}}function f({borderColor:t="#caced0",color:e="#97cbe6",height:n=0,opacity:o=1,radius:i=0,width:s=0,x:r=0,y:a=0}={}){const d=new l;return d.attr({height:n,opacity:o,rx:i,ry:i,width:s,x:r,y:a}),d.fill(e),d.stroke({color:t,width:1}),d}function v(t="",{fontColor:e="#666767",pointerEvents:n="all",textAnchor:o="start",x:i,y:s}={}){const r=new h;return r.font({fill:e}),r.tspan(t),void 0!==i&&void 0!==s&&r.move(i,s),r.attr({"pointer-events":n,"text-anchor":o}),r}function m(t,e,n,o){const i=new d;return i.attr({"data-parent":o,"data-self":n,transform:void 0!==t&&void 0!==e?`translate(${t}, ${e})`:void 0}),i}function y(t,{edgeColor:e,id:n="",opacity:o=1}={}){const i=new c({d:t});return i.id(n),i.fill(e).opacity(o),i}const b={export:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>\n <polyline points="7 10 12 15 17 10"/>\n <line x1="12" y1="15" x2="12" y2="3"/>\n </svg>',"zoom-in":'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <circle cx="11" cy="11" r="8"/>\n <path d="m21 21-4.35-4.35"/>\n <line x1="11" y1="8" x2="11" y2="14"/>\n <line x1="8" y1="11" x2="14" y2="11"/>\n </svg>',"zoom-out":'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <circle cx="11" cy="11" r="8"/>\n <path d="m21 21-4.35-4.35"/>\n <line x1="8" y1="11" x2="14" y2="11"/>\n </svg>',"fit-screen":'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <path d="M8 3H5a2 2 0 0 0-2 2v3"/>\n <path d="M21 8V5a2 2 0 0 0-2-2h-3"/>\n <path d="M3 16v3a2 2 0 0 0 2 2h3"/>\n <path d="M16 21h3a2 2 0 0 0 2-2v-3"/>\n </svg>'};class x{constructor(t,e){this.element=t,t&&(this.chartContext=e||new n(t),this.injectStyles())}injectStyles(){const t=`toolbar-styles-${this.chartContext.getInstanceId()}`;this.chartContext.injectStyles("\n #toolbar {\n display: flex;\n gap: 2px;\n position: absolute;\n /* Logical inset: stays on the right in LTR, mirrors to the left in RTL\n (so it never collides with RTL-flipped chrome such as the search box). */\n inset-inline-end: 12px;\n top: 12px;\n z-index: 100;\n user-select: none;\n background: var(--toolbar-bg-color, rgba(255, 255, 255, 0.92));\n border: 1px solid var(--toolbar-border-color, rgba(0, 0, 0, 0.08));\n border-radius: 10px;\n padding: 4px;\n box-shadow:\n 0 1px 3px rgba(0, 0, 0, 0.08),\n 0 4px 12px rgba(0, 0, 0, 0.06);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n }\n\n .toolbar-item {\n align-items: center;\n background-color: transparent;\n border: none;\n border-radius: 6px;\n color: var(--toolbar-icon-color, #444);\n cursor: pointer;\n display: flex;\n height: 30px;\n justify-content: center;\n width: 30px;\n transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;\n position: relative;\n flex-shrink: 0;\n }\n\n .toolbar-item:hover {\n background-color: var(--toolbar-hover-bg-color, rgba(0, 0, 0, 0.06));\n color: var(--toolbar-icon-hover-color, #111);\n transform: translateY(-1px);\n box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);\n }\n\n .toolbar-item:active {\n transform: translateY(0);\n box-shadow: none;\n background-color: var(--toolbar-active-bg-color, rgba(0, 0, 0, 0.1));\n }\n\n .toolbar-item:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--button-bg-color, #0066cc);\n }\n\n .toolbar-item svg {\n width: 15px;\n height: 15px;\n pointer-events: none;\n flex-shrink: 0;\n }\n\n .toolbar-item[disabled] {\n opacity: 0.4;\n cursor: not-allowed;\n pointer-events: none;\n }\n\n /* Tooltip */\n .toolbar-item::after {\n content: attr(data-tooltip);\n position: absolute;\n bottom: calc(100% + 8px);\n left: 50%;\n transform: translateX(-50%);\n background: var(--tooltip-bg-color, rgba(30, 30, 30, 0.92));\n color: var(--tooltip-text-color, #fff);\n padding: 5px 9px;\n border-radius: 6px;\n font-size: 11.5px;\n font-weight: 500;\n white-space: nowrap;\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s ease;\n z-index: 1000;\n letter-spacing: 0.01em;\n }\n\n .toolbar-item::before {\n content: '';\n position: absolute;\n bottom: calc(100% + 3px);\n left: 50%;\n transform: translateX(-50%);\n border: 4px solid transparent;\n border-top-color: var(--tooltip-bg-color, rgba(30, 30, 30, 0.92));\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s ease;\n z-index: 1000;\n }\n\n .toolbar-item:hover::after,\n .toolbar-item:hover::before {\n opacity: 1;\n }\n\n /* Shadow DOM specific adjustments */\n :host #toolbar {\n display: flex;\n gap: 2px;\n position: absolute;\n inset-inline-end: 12px;\n top: 12px;\n z-index: 100;\n }\n",t)}createToolbarItem(t,e,n){const o=this.chartContext.createElement("div");return o.id=t,o.className="toolbar-item",o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.innerHTML=e,n&&(o.setAttribute("data-tooltip",n),o.setAttribute("aria-label",n)),o.addEventListener("keydown",(t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),o.click())})),o}render({enableExport:t=!1,enableFitscreen:n=!1,enableZoom:o=!1,onExport:i=e,onFitscreen:s=e,onZoom:r=e}){if(!this.element)return;const a=this.chartContext.querySelector("#toolbar");null==a||a.remove();const d=this.chartContext.createElement("div");if(d.id="toolbar",d.setAttribute("role","toolbar"),d.setAttribute("aria-label","Chart controls"),t){const t=this.createToolbarItem("export",b.export,"Export chart");t.addEventListener("click",(()=>{i()})),d.append(t)}if(o){const t=this.createToolbarItem("zoom-in",b["zoom-in"],"Zoom in"),e=this.createToolbarItem("zoom-out",b["zoom-out"],"Zoom out");t.addEventListener("click",(()=>{r(.1)})),e.addEventListener("click",(()=>{r(-.1)})),d.append(t,e)}if(n){const t=this.createToolbarItem("fit-screen",b["fit-screen"],"Fit to screen");t.addEventListener("click",(()=>{s()})),d.append(t)}this.element.append(d)}destroy(){const t=this.chartContext.querySelector("#toolbar");null==t||t.remove()}}const w="aria-hidden",E=(t,e="apex-tooltip-container")=>{let n=t.getElementById(e);if(!n){n=t.createElement("div"),n.id=e,n.setAttribute("role","tooltip"),n.setAttribute(w,"true");t.getAppendContainer().appendChild(n),t.trackTooltip(n)}return n},A=(t,e="",n,o="",i=!1)=>{const s=t.getElementById(e);if(!s)return E(t,e),A(t,e,n,o,i);if(n&&o){const e=o.includes("tooltip-content"),r=n.match(/background-color:\s*([^;]+);?/),a=n.match(/color:\s*([^;]+);?/);if(e||!r)s.innerHTML=o;else{const t=r[1],e=a?a[1]:"white";s.innerHTML=`<div class="tooltip-content" style="background-color: ${t}; color: ${e};">${o}</div>`}const d=n+"; display: block !important; visibility: visible !important; opacity: 1 !important;";if(s.setAttribute("style",d),s.classList.add("visible"),s.setAttribute(w,"false"),i&&"undefined"!=typeof window){const e=s.offsetWidth,n=parseFloat(s.style.left),o=t.getChartBounds();if(e>0&&!Number.isNaN(n)&&o.width>0){const t=window.scrollX||document.documentElement.scrollLeft||0,i=o.left+t,r=((t,e,n,o,i=8)=>{if(t+e<=n-i)return t;const s=t-e;return s<o+i?Math.max(o+i,n-e-i):s})(n,e,o.right+t,i);r!==n&&(s.style.left=`${r}px`)}}}else s.removeAttribute("style"),s.classList.remove("visible"),s.setAttribute(w,"true"),s.innerHTML=""},C=(t={})=>{const e=[];for(const o in t){const i=`${n=o,n.replace(/([A-Z])/g,(t=>`-${t.toLowerCase()}`))}: ${t[o]};`;e.push(i)}var n;return e.join(" ")},S=({bgColor:t,borderColor:e,fontColor:n,fontFamily:o,fontSize:i,fontWeight:s,maxWidth:r,padding:a,placement:d="top",x:l,y:c})=>{const h=["position: absolute;","z-index: 1000;","pointer-events: none;"];return h.push("box-sizing: border-box;"),h.push("word-wrap: break-word;"),h.push("overflow-wrap: break-word;"),h.push(`left: ${l}px;`),h.push(`top: ${c}px;`),h.push(`data-placement: ${d};`),r&&(h.push(`width: ${r}px;`),h.push(`max-width: ${r}px;`)),e&&h.push(`border: 1px solid ${e};`),n&&h.push(`color: ${n};`),o&&h.push(`font-family: ${o};`),s&&h.push(`font-weight: ${s};`),i&&h.push(`font-size: ${i};`),t&&(h.push(`background-color: ${t};`),h.push("border-radius: 6px;"),h.push("box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);")),void 0!==a&&h.push(`padding: ${a}px;`),h.join(" ")},k=globalThis.console;function M(t,...e){k.error(t,...e)}function $(t){k.warn(t)}const T="APEX-",L=new Date("2027-07-31T00:00:00Z"),N="__apex_license_v1__";function F(){const t=globalThis;let e=t[N];return e||(e={key:null,listeners:new Set,result:null},t[N]=e),e}const R=class{static get licenseKey(){return F().key}static set licenseKey(t){F().key=t}static get listeners(){return F().listeners}static get validationResult(){return F().result}static set validationResult(t){F().result=t}static getKey(){return this.licenseKey}static getLicenseStatus(){return this.licenseKey?(this.validationResult=this.validateKey(this.licenseKey),this.validationResult):{expired:!1,signatureVerified:!1,valid:!1}}static isKeyValid(t){return!!t&&this.validateKey(t).valid}static isLicenseValid(){return this.getLicenseStatus().valid}static onChange(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}static setLicense(t){var e;if(!t)return this.licenseKey=null,void this.publish({expired:!1,signatureVerified:!1,valid:!1});const n=this.validateKey(t);n.valid||t===this.licenseKey||!(null==(e=this.validationResult)?void 0:e.valid)?(this.licenseKey=t,this.publish(n),n.valid||M(`[Apex] ${n.message}`)):$(`[Apex] Ignoring license key: ${n.message??"it is not valid"} A valid license is already active on this page.`)}static validateKey(t){const e=this.parseKey(t),n=this.validateStructure(t,e);if(!n.valid||!(null==e?void 0:e.signature))return n;const o=this.verdicts.get(t);return!1===o?{data:e.data,expired:!1,message:"Invalid license key. The license signature does not verify.",signatureVerified:!0,valid:!1}:(void 0===o&&this.verifySignature(t,e,n),{...n,signatureVerified:!0===o})}static _resetSignatureState(){this.verdicts.clear(),this.verifying.clear(),this.warnedUnverifiable=!1,this.epoch++}static base64ToBytes(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),n=e.padEnd(4*Math.ceil(e.length/4),"="),o=globalThis.atob;if("function"!=typeof o)throw new Error("no base64 decoder available");const i=o(n),s=new Uint8Array(i.length);for(let t=0;t<i.length;t++)s[t]=i.charCodeAt(t);return s}static canonicalPayload(t){const e=t.domains&&t.domains.length>0?t.domains.join(","):"";return`v1|${t.issueDate}|${t.expiryDate}|${t.plan}|${e}`}static notify(t){for(const e of this.listeners)try{e(t)}catch{}}static parseKey(t){if("string"!=typeof t||!t.startsWith(T))return null;const e=t.slice(5);if(!e)return null;try{const t=(new TextDecoder).decode(this.base64ToBytes(e)),n=JSON.parse(t);return n.issueDate&&n.expiryDate&&n.plan?{data:{domains:Array.isArray(n.domains)?n.domains:void 0,expiryDate:n.expiryDate,issueDate:n.issueDate,plan:n.plan,valid:!0},signature:"string"==typeof n.sig&&n.sig?n.sig:null}:null}catch{return null}}static publish(t){this.validationResult=t,this.notify(t)}static validateStructure(t,e){const n=t=>({expired:!1,message:t,signatureVerified:!1,valid:!1});if("string"!=typeof t||!t.startsWith(T))return n('Invalid license key format. License key must start with "APEX-".');if(!e)return n("Invalid license key. Unable to decode license data.");const{data:o,signature:i}=e;if(!i&&new Date>=L)return n("This license key is in the old unsigned format, which is no longer accepted. Please request a replacement key.");if(new Date(o.expiryDate)<new Date)return{data:o,expired:!0,message:`License expired on ${o.expiryDate}. Please renew your license.`,signatureVerified:!1,valid:!1};if(o.domains&&o.domains.length>0){const t="undefined"==typeof location?"":location.hostname;if(!o.domains.some((e=>t===e||t.endsWith(`.${e}`))))return{data:o,expired:!1,message:`License is not valid for this domain (${t}). Allowed domains: ${o.domains.join(", ")}.`,signatureVerified:!1,valid:!1}}return{data:o,expired:!1,signatureVerified:!1,valid:!0}}static async verifySignature(t,e,n){var o;if(this.verifying.has(t)||this.verdicts.has(t))return;this.verifying.add(t);const i=this.epoch,s=null==(o=globalThis.crypto)?void 0:o.subtle;if(!s||0===this.publicKeysSpki.length)return this.verifying.delete(t),void(this.warnedUnverifiable||(this.warnedUnverifiable=!0,$(s?"[Apex] No license signing key is configured in this build, so license signatures cannot be verified.":"[Apex] Web Crypto is unavailable (a secure context is required), so the license signature cannot be verified.")));const r=(new TextEncoder).encode(this.canonicalPayload(e.data));let a=!1;for(const t of this.publicKeysSpki){try{const n=await s.importKey("spki",this.base64ToBytes(t),{name:"ECDSA",namedCurve:"P-256"},!1,["verify"]);a=await s.verify({hash:"SHA-256",name:"ECDSA"},n,this.base64ToBytes(e.signature),r)}catch{a=!1}if(a)break}if(this.verifying.delete(t),this.epoch!==i)return;if(this.verdicts.set(t,a),a){const e={...n,signatureVerified:!0};return void(this.licenseKey===t?this.publish(e):this.notify(e))}const d="Invalid license key. The license signature does not verify.",l={data:e.data,expired:!1,message:d,signatureVerified:!0,valid:!1};this.licenseKey===t?this.publish(l):this.notify(l),M(`[Apex] ${d}`)}};R.publicKeysSpki=["MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEQIaK9UMD6n0oR/FIy8QdL0uSzKMQlf1BB+tOrji4/WuHsyRNxeDhVykoSsNURozMi1xhmqWvBH1L//xIfugTPA=="],R.verdicts=new Map,R.verifying=new Set,R.warnedUnverifiable=!1,R.epoch=0;let B=R;const _=class{static applyStyles(t){Object.assign(t.style,this.CRITICAL_STYLES,{backgroundImage:this.createWatermarkPattern(),backgroundRepeat:"repeat"})}static node(t){return t?t.querySelector(`[${this.WATERMARK_ATTR}]`):null}static add(t,e){return t&&"undefined"!=typeof document?(this.setManaged(t,e),this.paint(t)):null}static exists(t){return!!this.node(t)}static remove(t,e){t&&(this.setManaged(t,e),this.erase(t))}static untrack(t){this.managed.delete(t)}static createWatermarkPattern(){const t=this.WATERMARK_TEXT;return`url("data:image/svg+xml,${encodeURIComponent(`\n <svg xmlns="http://www.w3.org/2000/svg" width="300" height="200">\n <text\n x="50%"\n y="50%"\n dominant-baseline="middle"\n text-anchor="middle"\n font-family="-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Arial, sans-serif"\n font-size="18"\n font-weight="600"\n fill="rgba(134, 134, 134, 0.1)"\n transform="rotate(-35, 100, 60)"\n >${t}</text>\n </svg>\n `.trim())}")`}static erase(t){var e;null==(e=this.node(t))||e.remove()}static paint(t){let e=this.node(t);return e||(e=document.createElement("div"),e.setAttribute(this.WATERMARK_ATTR,""),t.appendChild(e)),this.applyStyles(e),"function"==typeof getComputedStyle&&"static"===getComputedStyle(t).position&&(t.style.position="relative"),e}static reconcile(){const t=B.isLicenseValid();for(const e of this.managed)e.isConnected?t?this.erase(e):this.paint(e):this.managed.delete(e)}static setManaged(t,e){!1!==(null==e?void 0:e.manage)?this.track(t):this.managed.delete(t)}static track(t){this.managed.add(t),this.subscribed||(this.subscribed=!0,B.onChange((()=>{this.reconcile()})))}};_.WATERMARK_ATTR="data-apexcharts-watermark",_.WATERMARK_TEXT="APEXCHARTS",_.ATTR="data-apexcharts-watermark",_.CRITICAL_STYLES={bottom:"0",display:"block",left:"0",msUserSelect:"none",opacity:"1",pointerEvents:"none",position:"absolute",right:"0",top:"0",userSelect:"none",visibility:"visible",webkitUserSelect:"none",zIndex:"10000"},_.managed=new Set,_.subscribed=!1;let I=_;function O(t,e){t&&("ltr"===e?t.removeAttribute("dir"):t.setAttribute("dir",e))}const D=.05,G=.05,P=1/45,j={velocity:.01,displacement:.001};function z(t,e,n,o){const i={value:t,velocity:0,target:t,stiffness:e,damping:n};return void 0!==(null==o?void 0:o.velocity)&&(i.restVelocity=o.velocity),void 0!==(null==o?void 0:o.displacement)&&(i.restDisplacement=o.displacement),i}function q(t,e){if(e<=0)return W(t);let n=e;for(;n>0;){const e=Math.min(n,P),o=-t.stiffness*(t.value-t.target)-t.damping*t.velocity;t.velocity+=o*e,t.value+=t.velocity*e,n-=e}return!!W(t)&&(t.value=t.target,t.velocity=0,!0)}function H(t,e){t.value=e,t.target=e,t.velocity=0}function W(t){const e=t.restVelocity??D,n=t.restDisplacement??G;return Math.abs(t.velocity)<e&&Math.abs(t.value-t.target)<n}const V={crisp:[210,26],gentle:[120,20],snappy:[320,30]};class Y{constructor(t={}){this.mql=null,this.handler=null,this.ownsClass=!1,this.element=t.element??null,this.className=t.className??"",this.onChange=t.onChange,"undefined"!=typeof window&&"function"==typeof window.matchMedia&&(this.mql=window.matchMedia("(prefers-reduced-motion: reduce)"),this.applyClass(this.mql.matches),this.handler=t=>{var e;this.applyClass(t.matches),null==(e=this.onChange)||e.call(this,t.matches)},"function"==typeof this.mql.addEventListener?this.mql.addEventListener("change",this.handler):"function"==typeof this.mql.addListener&&this.mql.addListener(this.handler))}get matches(){var t;return!!(null==(t=this.mql)?void 0:t.matches)||!(!this.className||!this.element)&&this.element.classList.contains(this.className)}dispose(){this.mql&&this.handler&&("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",this.handler):"function"==typeof this.mql.removeListener&&this.mql.removeListener(this.handler),this.mql=null,this.handler=null)}applyClass(t){this.element&&this.className&&(t?this.element.classList.contains(this.className)||(this.element.classList.add(this.className),this.ownsClass=!0):this.ownsClass&&(this.element.classList.remove(this.className),this.ownsClass=!1))}}class K{constructor(t={}){this.objects=new Map,this.frameHandle=null,this.lastTime=null,this.disposed=!1,this.opts=t;const[e,n]=t.spring??(V["crisp"]??V.crisp);this.stiffness=e,this.damping=n,this.rest=t.rest;const o=t.clock??{};this.now=o.now??(()=>"undefined"!=typeof performance?performance.now():Date.now()),this.raf=o.raf??(t=>requestAnimationFrame(t)),this.caf=o.caf??(t=>cancelAnimationFrame(t)),this.reducedMotionOverride=t.reducedMotion,this.reducedMotionWatcher=void 0===t.reducedMotion?new Y({element:t.element,className:t.reducedMotionClass,onChange:t=>{t&&null!==this.frameHandle&&this.snapAll()}}):null}get reducedMotion(){var t;return this.reducedMotionOverride??(null==(t=this.reducedMotionWatcher)?void 0:t.matches)??!1}has(t){return this.objects.has(t)}get size(){return this.objects.size}ids(){return this.objects.keys()}dataOf(t){var e;return null==(e=this.objects.get(t))?void 0:e.data}valuesOf(t){const e=this.objects.get(t);return e?U(e):void 0}channelValue(t,e){var n,o;return null==(o=null==(n=this.objects.get(t))?void 0:n.channels.get(e))?void 0:o.value}targetOf(t,e){var n,o;return null==(o=null==(n=this.objects.get(t))?void 0:n.channels.get(e))?void 0:o.target}add(t,e,n,o={}){var i;const s=this.objects.get(t);if(s)return s.data=n,s.delayMs=o.delayMs??0,s.paused=!1,void(s.settled=!1);const[r,a]=o.spring??[this.stiffness,this.damping],d=o.rest??this.rest,l=new Map;for(const t of Object.keys(e))l.set(t,z(e[t],r,a,(null==(i=o.channelRest)?void 0:i[t])??d));this.objects.set(t,{id:t,data:n,channels:l,delayMs:o.delayMs??0,pauseOnSettle:o.pauseOnSettle??!1,paused:!1,settled:!1})}setData(t,e){const n=this.objects.get(t);n&&(n.data=e)}retarget(t,e,n={}){const o=this.objects.get(t);if(!o)return;o.paused=!1,o.settled=!1,void 0!==n.delayMs&&(o.delayMs=n.delayMs);const i=this.reducedMotion;for(const t of Object.keys(e)){const n=o.channels.get(t);n&&(i?(H(n,e[t]),o.delayMs=0):n.target=e[t])}}snap(t,e){const n=this.objects.get(t);if(n){for(const t of Object.keys(e)){const o=n.channels.get(t);o&&H(o,e[t])}n.delayMs=0}}pause(t){const e=this.objects.get(t);e&&(e.paused=!0)}remove(t){this.objects.delete(t)}clear(){this.stop(),this.objects.clear()}atRest(){for(const t of this.objects.values())if(!t.paused){if(t.delayMs>0)return!1;for(const e of t.channels.values())if(e.value!==e.target||0!==e.velocity)return!1}return!0}writeAll(t){var e,n;for(const e of this.objects.values())e.paused||t&&!t(e.id,e.data)||this.write(e);null==(n=(e=this.opts).onFrame)||n.call(e)}step(t){var e,n;let o=!0;for(const e of Array.from(this.objects.values())){if(e.paused||!this.objects.has(e.id))continue;if(e.delayMs>0){e.delayMs-=1e3*t,o=!1;continue}let n=!0;for(const o of e.channels.values())q(o,t)||(n=!1);this.write(e),n?e.settled||(e.settled=!0,this.settle(e)||e.pauseOnSettle&&(e.paused=!0)):(e.settled=!1,o=!1)}return null==(n=(e=this.opts).onFrame)||n.call(e),o}start(){if(this.disposed)return;if(null!==this.frameHandle)return;this.lastTime=null;const t=e=>{if(this.frameHandle=null,this.disposed)return;if(this.reducedMotion)return void this.snapAll();const n=this.lastTime??e;this.lastTime=e;const o=Math.min(Math.max(0,(e-n)/1e3),.05);this.step(o)?this.lastTime=null:this.frameHandle=this.raf(t)};this.frameHandle=this.raf(t)}settleNow(){this.disposed||this.snapAll()}stop(){null!==this.frameHandle&&(this.caf(this.frameHandle),this.frameHandle=null),this.lastTime=null}get running(){return null!==this.frameHandle}dispose(){var t;this.disposed||(this.disposed=!0,this.stop(),this.objects.clear(),null==(t=this.reducedMotionWatcher)||t.dispose())}get isDisposed(){return this.disposed}snapAll(){var t,e;this.stop();for(const t of Array.from(this.objects.values()))if(!t.paused&&this.objects.has(t.id)){for(const e of t.channels.values())H(e,e.target);t.delayMs=0,this.write(t),t.settled||(t.settled=!0,this.settle(t)||t.pauseOnSettle&&(t.paused=!0))}null==(e=(t=this.opts).onFrame)||e.call(t)}settle(t){var e,n;return!0===(null==(n=(e=this.opts).onSettle)?void 0:n.call(e,t.id,t.data))&&(this.objects.delete(t.id),!0)}write(t){var e,n;null==(n=(e=this.opts).write)||n.call(e,t.id,U(t),t.data)}}function U(t){const e={};for(const[n,o]of t.channels)e[n]=o.value;return e}const X="__apexcharts_themes__";function Z(t){return t?function(){const t=globalThis,e=t[X];if(e)return e;const n={};return t[X]=n,n}()[t]??null:null}const Q={accent:"--apx-accent",fore:"--apx-fore",grid:"--apx-grid",surface:"--apx-surface"},J="--apx-series-",tt=24;function et(t,e){var n;const o=function(t){if(!t||"function"!=typeof getComputedStyle)return{};let e;try{e=getComputedStyle(t)}catch{return{}}if(!e||"function"!=typeof e.getPropertyValue)return{};const n=t=>{const n=e.getPropertyValue(t);return n?String(n).trim():""},o={};for(const[t,e]of Object.entries(Q)){const i=n(e);i&&(o[t]=i)}const i=[];for(let t=1;t<=tt;t++){const e=n(`${J}${t}`);if(!e)break;i.push(e)}return i.length&&(o.series=i),o}(t),i=e?null==(n=Z(e))?void 0:n.tokens:void 0;return i?{...i,...o}:o}function nt(t,e){let n=null;for(let o=0;o<t.length;++o)if(e(t[o])){n=o;break}return n}function ot(t,e){if(0===t.length)return;let n,o=0;for(let i=t.length-1;i>=0;--i)n=(t[i].dy??0)/2,(t[i][e]??0)-n<o&&(t[i][e]=Math.min(t[i].Rmax??0,o+n)),o=(t[i][e]??0)+n;let i=(t[0].Rmax??0)+(t[0].dy??0)/2;for(let o=0;o<t.length;++o)n=(t[o].dy??0)/2,(t[o][e]??0)+n>i&&(t[o][e]=Math.max(n,i-n)),i=(t[o][e]??0)-n}function it(t){const e=t.edgeGap||0;return function(n){!function(t,e,n){t.nodes().forEach((o=>{const i=t.node(o),s=st(t,i.outgoing||[],"outgoing"),r=st(t,i.incoming||[],"incoming"),a=s.length,d=r.length,l=s.reduce(((e,n)=>e+(t.edge(n).dy??0)),0),c=r.reduce(((e,n)=>e+(t.edge(n).dy??0)),0),h=l+Math.max(0,a-1)*n,u=c+Math.max(0,d-1)*n;let p=((i.dy??0)-h)/2,g=((i.dy??0)-u)/2;p=Math.max(0,p),g=Math.max(0,g),s.forEach(((o,s)=>{const r=t.edge(o);r.x0=(i.x??0)+(e.nodeWidth??0)/2,r.y0=(i.y??0)+p+(r.dy??0)/2,r.d0=i.direction||"r",p+=r.dy??0,s<a-1&&(p+=n)})),r.forEach(((o,s)=>{const r=t.edge(o);r.x1=(i.x??0)-(e.nodeWidth??0)/2,r.y1=(i.y??0)+g+(r.dy??0)/2,r.d1=i.direction||"r",g+=r.dy??0,s<d-1&&(g+=n)}))}))}(n,t,e),function(t){t.nodes().forEach((e=>{const n=t.node(e),o=(n.outgoing||[]).map((e=>t.edge(e))),i=(n.incoming||[]).map((e=>t.edge(e)));o.sort(((t,e)=>(t.y0??0)-(e.y0??0))),i.sort(((t,e)=>(t.y1??0)-(e.y1??0))),rt(o,"r0"),rt(i,"r1")}))}(n);const o=[];return n.edges().forEach((t=>{const e=n.edge(t);e.id=`${t.v}-${t.w}-${t.name}`,o.push(e)})),o}}function st(t,e,n){return e.slice().sort(((e,o)=>{let i,s;if("outgoing"===n){const n=t.node(e.w),r=t.node(o.w);i=(null==n?void 0:n.y)??0,s=(null==r?void 0:r.y)??0}else{const n=t.node(e.v),r=t.node(o.v);i=(null==n?void 0:n.y)??0,s=(null==r?void 0:r.y)??0}if(Math.abs(i-s)>.001)return i-s;if(e.name!==o.name){if("number"==typeof e.name&&"number"==typeof o.name)return e.name-o.name;if("string"==typeof e.name&&"string"==typeof o.name)return e.name.localeCompare(o.name)}return 0}))}function rt(t,e){t.forEach((t=>{t.Rmax=function(t){const e=(t.x1??0)-(t.x0??0),n=(t.y1??0)-(t.y0??0);return t.d0!==t.d1?Math.abs(n)/2.1:0!==n?(e*e+n*n)/Math.abs(4*n):1/0}(t),t[e]=Math.max((t.dy??0)/2,t.d0===t.d1?.6*(t.Rmax??0):5+(t.dy??0)/2)}));let n=nt(t,"r0"===e?t=>(t.y1??0)>(t.y0??0):t=>(t.y0??0)>(t.y1??0));if(null===n&&(n=t.length),ot(t.slice(n),e),n>0){const o=[];for(let e=n-1;e>=0;e--)o.push(t[e]);ot(o,e)}}function at(t,e,n,o,i){if(0===o.length)return;const s=o.map((n=>{const o=`__${e.v}_${e.w}_${n}`;return t.setNode(o,{data:null,direction:i,dummy:!0,rank:n}),o})),r=[e.v,...s,e.w];r.forEach(((o,i)=>{i+1<r.length&&t.setEdge(r[i],r[i+1],{data:t.edge(e).data,origEdge:e,origLabel:n,source:t.node(e.v),target:t.node(e.w),value:t.edge(e).value},e.name)})),t.removeEdge(e)}function dt(t,e,n){return function(t,e,n){let o,i;e.length>n.length?(o=e,i=n):(o=n,i=e);const s=i.length,r=[];o.forEach((e=>{i.forEach(((n,o)=>{(t.hasEdge(e,n)||t.hasEdge(n,e))&&r.push(o)}))}));let a=1;for(;a<s;)a*=2;const d=2*a-1;a-=1;const l=new Array(d).fill(0);let c=0;return r.forEach((t=>{let e=t+a;for(l[e]++;e>0;)e%2&&(c+=l[e+1]),e=Math.floor((e-1)/2),l[e]++})),c}(t,e,n)}function lt(t){const e=[];let n=t.nodes().filter((e=>0===t.node(e).rank)).concat(t.sources());return 0===n.length&&(n=t.nodes().slice(0,1)),function(t,e){const n=new Set,o=[];function i(e){if(!n.has(e)){n.add(e),o.push(e);for(const n of t.successors(e))i(n)}}for(const t of e)i(t);return o}(t,n).forEach((n=>{const o=t.node(n).rank;if(void 0!==o){for(;o>=e.length;)e.push([]);e[o].push(n)}})),e}function ct(t,e){let n=!0;for(;n;){n=!1;for(let o=0;o<e.length;++o)for(let i=0;i<e[o].length-1;++i){const s=ht(t,e,o);ut(e[o],i,i+1);ht(t,e,o)<s?n=!0:ut(e[o],i,i+1)}}}function ht(t,e,n){let o=0;return n>0&&(o+=dt(t,e[n-1],e[n])),n+1<e.length&&(o+=dt(t,e[n],e[n+1])),o}function ut(t,e,n){const o=t[e];t[e]=t[n],t[n]=o}function pt(t){const e=Math.floor(t.length/2);if(0===t.length)return-1;if(t.length%2==1)return t[e];if(2===t.length)return(t[0]+t[1])/2;const n=t[e-1]-t[0],o=t[t.length-1]-t[e];return(t[e-1]*o+t[e]*n)/(n+o)}function gt(t,e,n=1,o=!1){if(n>0)for(let n=1;n<e.length;++n){const i=new Map;e[n].forEach((s=>{const r=pt(ft(t,e,n,n-1,s,o));i.set(s,r)})),vt(e[n],i)}else for(let n=e.length-2;n>=0;--n){const i=new Map;e[n].forEach((s=>{const r=pt(ft(t,e,n,n+1,s,o));i.set(s,r)})),vt(e[n],i)}}function ft(t,e,n,o,i,s=!1){const r=e[n],a=e[o],d=[];return a.forEach(((e,n)=>{t.nodeEdges(e,i).length>0&&d.push(n)})),0===d.length&&s&&r.forEach(((e,n)=>{t.nodeEdges(e,i).length>0&&d.push(n+.5)})),d.sort(((t,e)=>t-e)),d}function vt(t,e){const n=new Map(t.map(((t,e)=>[t,e])));for(let o=1;o<t.length;++o)for(let i=o;i>0;--i){let o=i-1,s=e.get(t[o]),r=e.get(t[i]);for(;-1===(s=e.get(t[o]))&&o>0;)o--;if(void 0===r||void 0===s||-1===r||-1===s)break;if(s===r&&(s=n.get(t[o])??s,r=n.get(t[i])??r),r>=s)break;[t[i],t[o]]=[t[o],t[i]]}}function mt(t,e){let n=0;for(let o=0;o<e.length-1;++o)n+=dt(t,e[o],e[o+1]);return n}function yt(t){const e=[];for(const n of t){const t=[];e.push(t);for(const e of n)t.push(e)}return e}const bt=(t,e)=>(t||[]).reduce(((t,n)=>t+(e?e(n):n)),0);function xt(){let t=[100,100],e=null,n=.18,o=function(t,e,n){return 1};const i=function(t){return t.data.value},s=function(t){return t.data?t.data.direction??"r":"r"};function r(a,d,l=0){null===e&&r.scaleToFit(a,d,l),wt(a,i,s),function(t,e,n,o=0){t.nodes().forEach((e=>{const i=t.node(e),s=t.inEdges(e)||[],r=t.outEdges(e)||[],a=Math.max(0,s.length-1),d=Math.max(0,r.length-1),l=Math.max(a,d);i.dy=i.value*n+l*o})),t.edges().forEach((o=>{const i=t.edge(o);i.value=e(i),i.dy=i.value*n}))}(a,i,e,l);const c=Et(a,d,l,e),h=[];for(let e=0;e<d.length;e++){const i=d[e],s=i.length;let r=0;h[e]=[];for(let d=0;d<i.length;d++){const l=i[d],u=c[d]/bt(c)*t[1],p=0===r?0:n*u/5,g=u-2*p,f=l.map(((t,e)=>a.node(t).value&&l[e+1]?o(l[e],l[e+1],a):0)),v=bt(l,(t=>a.node(t).dy)),m=Math.max(0,g-v),y=bt(f)?m/bt(f):0;let b=r+p;1===l.length&&(b+=(g-a.node(l[0]).dy)/2),h[e][d]={margin:p,height:g,gaps:f,kg:y,isFirst:0===d,isLast:d===s-1,startYY:b},r+=u}}let u,p,g=-1,f=-1,v=0,m=0;(function(t){const e=[];for(let n=0;n<t.length;n++){const o=t[n];for(let t=0;t<o.length;t++){const i=o[t];for(let o=0;o<i.length;o++)e.push({rankIndex:n,bandIndex:t,nodeIndex:o,nodeId:i[o]})}}return e})(d).forEach((({rankIndex:t,bandIndex:e,nodeIndex:n,nodeId:o})=>{var i;t===g&&e===f||(g=t,f=e,u=h[t][e],p=d[t][e],v=u.startYY,m=u.isFirst?Number.MAX_VALUE:0);const s=a.node(o);s.y=v,s.spaceAbove=m,s.spaceBelow=u.gaps[n]*u.kg,v+=s.dy+s.spaceBelow,m=s.spaceBelow,void 0!==(null==(i=s.data)?void 0:i.forceY)&&(s.y=u.margin+s.data.forceY*(u.height-s.dy)),n===p.length-1&&(s.spaceBelow=u.isLast?Number.MAX_VALUE:0)}));const y=function(t,e){const n=[];return e.forEach(((o,i)=>{if(i===e.length-1)return;let s=0;o.forEach((e=>{e.forEach((e=>{t.outEdges(e).forEach((e=>{const n=t.edge(e).dy,o=t.node(e.w).y-t.node(e.v).y,i=Math.abs(o)-n,r=n*n-i*i,a=r>=0?Math.sqrt(r):n;a>s&&(s=a)}))}))})),n.push(s)})),n}(a,d);!function(t,e,n,o){const i=o.reduce(((t,e)=>t+e),0);let s;if(i>n)s=o.map((t=>n*t/i));else{const t=n-i;s=o.map((n=>n+t/(e.length-1)))}let r=0;e.forEach(((e,n)=>{e.forEach((e=>{e.forEach((e=>{t.node(e).x=r}))})),r+=s[n]}))}(a,d,t[0],y);const b=[];return a.nodes().forEach((t=>{const e=a.node(t);e.id=t,b.push(e)})),b}return r.scaleToFit=function(o,r,a=0){wt(o,i,s);let d=0;a>0&&o.nodes().forEach((t=>{d=Math.max(d,function(t,e,n){if(n<=0)return 0;const o=t.inEdges(e)||[],i=t.outEdges(e)||[],s=Math.max(0,o.length-1),r=Math.max(0,i.length-1);return Math.max(s,r)*n}(o,t,a))}));const l=bt(Et(o,r,0,1));if(l<=0)return void(e=1);const c=t[1]-d;e=c/l,1!==n&&(e*=1-n)},r.size=function(e){return arguments.length?(t=e,r):t},r.separation=function(t){return arguments.length?(o="function"==typeof t?t:()=>t,r):o},r.whitespace=function(t){return arguments.length?(n=t,r):n},r.scale=function(t){return arguments.length?(e=t,r):e},r}function wt(t,e,n){t.nodes().forEach((o=>{const i=bt(t.inEdges(o),(n=>e(t.edge(n)))),s=bt(t.outEdges(o),(n=>e(t.edge(n))));let r=t.node(o);r||t.setNode(o,r={}),r.value=Math.max(i,s),void 0===r.direction&&(r.direction=n(r)||"r")}))}function Et(t,e,n=0,o=1){if(0===e.length||0===e[0].length)return[];const i=e[0].length,s=new Array(i).fill(0);return e.forEach((e=>{e.forEach(((e,i)=>{const r=bt(e,(e=>{const i=t.node(e),s=t.inEdges(e)||[],r=t.outEdges(e)||[],a=Math.max(0,s.length-1),d=Math.max(0,r.length-1),l=Math.max(a,d);return i.value+l*n/o}));s[i]=Math.max(s[i],r)}))})),s}function At(t,e,n){return void 0!==n?`${t}${e}${n}`:`${t}${e}`}class Ct{constructor(t={}){this._nodes=new Map,this._edges=new Map,this._graphLabel={},this._out=new Map,this._in=new Map,this._isMultigraph=t.multigraph??!1}graph(){return this._graphLabel}setGraph(t){return this._graphLabel=t,this}setNode(t,e){return this._nodes.has(t)?void 0!==e&&this._nodes.set(t,e):(this._nodes.set(t,void 0!==e?e:{}),this._out.set(t,new Set),this._in.set(t,new Set)),this}node(t){return this._nodes.get(t)}hasNode(t){return this._nodes.has(t)}nodes(){return Array.from(this._nodes.keys())}removeNode(t){var e,n;if(!this._nodes.has(t))return this;this._nodes.delete(t);const o=Array.from(this._out.get(t)??[]),i=Array.from(this._in.get(t)??[]);for(const t of o){const n=this._edges.get(t);n&&(null==(e=this._in.get(n.w))||e.delete(t)),this._edges.delete(t)}for(const t of i){const e=this._edges.get(t);e&&(null==(n=this._out.get(e.v))||n.delete(t)),this._edges.delete(t)}return this._out.delete(t),this._in.delete(t),this}sources(){return this.nodes().filter((t=>{var e;return 0===((null==(e=this._in.get(t))?void 0:e.size)??0)}))}successors(t){return this.outEdges(t).map((t=>t.w))}setEdge(t,e,n,o){var i,s;let r,a;"object"==typeof t?(r=t.v,a=t.w,o=t.name,n=e):(r=t,a=e),this.setNode(r),this.setNode(a);const d=this._isMultigraph?At(r,a,o):At(r,a),l=this._edges.get(d);if(l)void 0!==n&&(l.label=n);else{const t={v:r,w:a,name:o,label:void 0!==n?n:{}};this._edges.set(d,t),null==(i=this._out.get(r))||i.add(d),null==(s=this._in.get(a))||s.add(d)}return this}edge(t,e,n){var o;let i;return i="string"==typeof t?this._isMultigraph?At(t,e,n):At(t,e):this._isMultigraph?At(t.v,t.w,t.name):At(t.v,t.w),null==(o=this._edges.get(i))?void 0:o.label}hasEdge(t,e,n){const o=this._isMultigraph?At(t,e,n):At(t,e);return this._edges.has(o)}edges(){return Array.from(this._edges.values()).map((({v:t,w:e,name:n})=>({v:t,w:e,name:n})))}removeEdge(t){var e,n;const o=this._isMultigraph?At(t.v,t.w,t.name):At(t.v,t.w),i=this._edges.get(o);return i?(null==(e=this._out.get(i.v))||e.delete(o),null==(n=this._in.get(i.w))||n.delete(o),this._edges.delete(o),this):this}outEdges(t){const e=this._out.get(t);return e?Array.from(e).flatMap((t=>{const e=this._edges.get(t);return e?[{v:e.v,w:e.w,name:e.name}]:[]})):[]}inEdges(t){const e=this._in.get(t);return e?Array.from(e).flatMap((t=>{const e=this._edges.get(t);return e?[{v:e.v,w:e.w,name:e.name}]:[]})):[]}nodeEdges(t,e){const n=[],o=new Set;for(const i of[...this.inEdges(t),...this.outEdges(t)])if(i.v===e||i.w===e){const t=At(i.v,i.w,i.name);o.has(t)||(o.add(t),n.push(i))}return n}}function St(t){return void 0!==t.name?`${t.v}${t.w}${t.name}`:`${t.v}${t.w}`}function kt(t,e){const n=function(t,e){const n=new Set,o=new Ct({directed:!0}),i=[];if(!t.hasNode(e))throw Error("node not in graph");return Mt(t,e,n,o,i),t.nodes().forEach((e=>{n.has(e)||Mt(t,e,n,o,i)})),i.forEach(((t,e)=>{o.node(t).thread=e+1<i.length?i[e+1]:i[0]})),o}(t,e);return t.edges().forEach((e=>{const o=function(t,e,n){const o=t.node(e),i=t.node(n);if((o.depth??0)<(i.depth??0)){let e=o.thread;for(;void 0!==e&&(t.node(e).depth??0)>(o.depth??0);){if(e===n)return 1;e=t.node(e).thread}}else if((i.depth??0)<(o.depth??0)){let n=i.thread;for(;void 0!==n&&(t.node(n).depth??0)>(i.depth??0);){if(n===e)return-1;n=t.node(n).thread}}return 0}(n,e.v,e.w);if(o<0){const n=t.edge(e)||{};n.reversed=!0,t.removeEdge(e),t.setEdge(e.w,e.v,n)}})),t}function Mt(t,e,n,o,i,s=0){if(!n.has(e)){n.add(e),i.push(e),o.setNode(e,{depth:s});t.outEdges(e).map((t=>t.w)).forEach((r=>{n.has(r)||o.setEdge(e,r,{delta:1}),Mt(t,r,n,o,i,s+1)}))}}function $t(t,e){if(0===t.nodes().length)return;const n=function(t,e){const n=new Ct({directed:!0});let o=!1;for(const t of e)if("min"===t.type){o=!0;break}if(!o){const n=t.sources();e=n.length>0?[{nodes:[n[0]],type:"min"},...e]:[{nodes:[t.nodes()[0]],type:"min"},...e]}const i=new Map;let s=0;return e.forEach((t=>{if(!t.nodes||0===t.nodes.length)return;const e=""+s++;t.nodes.forEach((t=>{i.set(t,e)})),n.setNode(e,{nodes:t.nodes,type:t.type})})),t.nodes().forEach((t=>{if(!i.has(t)){const e=""+s++,o={nodes:[t],type:"same"};i.set(t,e),n.setNode(e,o)}})),t.edges().forEach((e=>{const o=i.get(e.v)??e.v,s=i.get(e.w)??e.w,r=t.node(e.v)||{},a=t.node(e.w)||{},d=n.edge(o,s)||{delta:0};o===s?(d.delta=0,n.setEdge(o,s,d)):"l"===r.direction?(d.delta=Math.max(d.delta??0,"l"===a.direction?1:0),n.setEdge(s,o,d)):(d.delta=Math.max(d.delta??0,"l"===a.direction?0:1),n.setEdge(o,s,d))})),n}(t,e);!function(t){t.sources().forEach((e=>{"0"!==e&&t.setEdge("0",e,{delta:0,temp:!0})}))}(n),kt(n,"0"),function(t){var e;const n=t.sources(),o=new Set,i=new Set;for(t.edges().forEach((t=>{t.v===t.w&&i.add(St(t))}));n.length>0;){const s=n.shift();if(void 0===s)break;o.add(s);let r=t.node(s);r||t.setNode(s,r={}),r.rank=0;for(const n of t.inEdges(s)){const o=(null==(e=t.edge(n)||{})?void 0:e.delta)??1;r.rank=Math.max(r.rank,(t.node(n.v).rank??0)+o)}for(const e of t.outEdges(s))i.add(St(e));for(const e of t.nodes())n.indexOf(e)<0&&!o.has(e)&&!t.inEdges(e).some((t=>!i.has(St(t))))&&n.push(e)}}(n),function(t){function e(e){const n=t.node(e),o=Math.min(...t.outEdges(e).map((e=>(t.node(e.w).rank??0)-(t.edge(e).delta??0))));void 0!==o&&(n.rank=o)}t.edges().forEach((n=>{t.edge(n).temp&&e(n.w)}))}(n),t.nodes().forEach((e=>{t.node(e)||t.setNode(e,{})})),n.nodes().forEach((e=>{var o;const i=n.node(e);null==(o=i.nodes)||o.forEach((e=>{t.node(e).rank=i.rank}))}))}function Tt(t){const e=xt(),n=it(t);let o=[],i=[],s=null;function r(r=[],a=[],d={}){const l=function(t=[],e=[]){const n=new Ct({directed:!0,multigraph:!0});return e.forEach((t=>{n.setEdge(t.source,t.target,{data:t,points:[]},t.type)})),n.nodes().forEach((t=>n.setNode(t,{data:{}}))),t.forEach((t=>{n.hasNode(t.id)&&(n.node(t.id).data=t,void 0!==t.direction&&(n.node(t.id).direction=t.direction))})),n.edges().forEach((t=>{n.edge(t).source=n.node(t.v),n.edge(t).target=n.node(t.w)})),n}(a,r);var c;return d.order?($t(l,d.rankSets||[]),s=d.order,s.length>0&&s[0].length>0&&!Array.isArray(s[0][0])&&(s=s.map((t=>[t]))),s=s.map((t=>t.map((t=>t.filter((t=>void 0!==l.node(t)))))))):($t(l,d.rankSets||[]),(c=l).edges().forEach((t=>{const e=c.node(t.v),n=c.node(t.w),o=c.edge(t);let i=e.rank;const s=[];if(void 0!==i&&void 0!==n.rank&&i+1<=n.rank){for("l"===e.direction&&s.push(i);++i<n.rank;)s.push(i);"l"===n.direction&&s.push(i),at(c,t,o,s,"r")}else if(void 0!==i&&void 0!==n.rank&&i>n.rank){for("l"!==e.direction&&s.push(i);i-- >n.rank+1;)s.push(i);"l"!==n.direction&&s.push(i),at(c,t,o,s,"l")}})),s=function(t,e=25){const n=lt(t);let o=n,i=mt(t,n),s=0;for(;s++<e;){gt(t,n,s%2==0?1:0),ct(t,n);const e=mt(t,n);if(e<i&&(o=yt(n),i=e),0===i)break}return o.map((t=>[t]))}(l)),o=e(l,s,t.edgeGap||0),function(t){t.nodes().forEach((e=>{const n=t.node(e);n.incoming=t.inEdges(e),n.outgoing=t.outEdges(e)}))}(l),i=n(l),function(t){t.nodes().filter((t=>t.startsWith("__"))).forEach((e=>{var n;let o=t.node(e);if(!o)return;let i=(null==(n=t.inEdges(e))?void 0:n.map((e=>t.edge(e))))||[];i.forEach((e=>{e.origLabel&&e.origEdge&&(e.origLabel.dy=e.dy,e.origLabel.x0=e.x0,e.origLabel.y0=e.y0,e.origLabel.r0=e.r0,e.origLabel.d0=e.d0,e.origLabel.value=e.value,t.setEdge(e.origEdge,e.origLabel))}));let s,r=i.map((t=>t.r1));for(;o.dummy;)i=t.outEdges(e).map((e=>t.edge(e))),i.forEach(((t,e)=>{t.origLabel&&(t.origLabel.points||(t.origLabel.points=[]),t.origLabel.points.push({d:t.d0,r0:t.r0,r1:r[e],x:o.x,y:t.y0}))})),r=i.map((t=>t.r1)),s=t.successors(e)[0],t.removeNode(e),o=t.node(e=s);i.forEach((t=>{t.origLabel&&(t.origLabel.x1=t.x1,t.origLabel.y1=t.y1,t.origLabel.r1=t.r1,t.origLabel.d1=t.d1)}))}))}(l),function(t){t.edges().forEach((e=>{const n=t.edge(e);n.points||(n.points=[]),n.points.unshift({d:n.d0,ro:n.r0,x:n.x0,y:n.y0}),n.points.push({d:n.d1,ri:n.r1,x:n.x1,y:n.y1})}))}(l),l}return void 0!==t.whitespace&&e.whitespace(t.whitespace),r.nodes=function(){return o},r.links=function(){return i},r.order=function(){return s},r.size=function(t){return arguments.length?(e.size(t),r):e.size()},r.separation=function(t){return arguments.length?(e.separation(t),r):e.separation()},r.whitespace=function(t){return arguments.length?(e.whitespace(t),r):e.whitespace()},r.edgeValue=function(t){return r},r.scale=function(t){return arguments.length?(e.scale(t),r):e.scale()},r}const Lt=["#6b9ece","#e07b7b","#7dba8f","#b09ed1","#e0b678","#6dbaba","#d17da8","#b5b56d","#c49a6d","#8fa4b8","#c98aa0","#94bf7d","#e0a08a","#7b9eb5","#a988a8"],Nt={canvasStyle:"border: 1px solid #caced0; box-sizing: border-box",edgeGap:0,edgeGradientFill:!0,edgeOpacity:.4,particleFlow:!1,enableToolbar:!0,type:"sankey",arcCornerRadius:6,enableTooltip:!0,fontColor:"#212121",fontFamily:"",fontSize:"14px",fontWeight:"400",height:"auto",locale:{direction:"ltr"},nodeBorderColor:null,nodeBorderWidth:1,nodeWidth:20,nodePalette:void 0,theme:void 0,draggableNodes:!1,onNodeClick:void 0,spacing:20,tooltipBGColor:"#FFFFFF",tooltipBorderColor:"#E2E8F0",tooltipFontColor:"#1a1a1a",tooltipId:"apexsankey-tooltip-container",tooltipTemplate:({source:t,target:e,value:n})=>`\n <div style='display:flex;align-items:center;gap:6px;padding:7px 10px;'>\n <div style='width:10px;height:10px;border-radius:2px;background-color:${null==t?void 0:t.color};flex-shrink:0;'></div>\n <span style='font-weight:500;'>${null==t?void 0:t.title}</span>\n <svg width='14' height='14' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg' style='opacity:0.5;flex-shrink:0;'><path d='M5 12h14M13 6l6 6-6 6' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>\n <div style='width:10px;height:10px;border-radius:2px;background-color:${null==e?void 0:e.color};flex-shrink:0;'></div>\n <span style='font-weight:500;'>${null==e?void 0:e.title}</span>\n <span style='opacity:0.6;margin-left:2px;'>·</span>\n <span style='font-weight:600;'>${n}</span>\n </div>\n `,nodeTooltipTemplate:({node:t,value:e})=>`\n <div style='display:flex;align-items:center;gap:6px;padding:7px 10px;'>\n <div style='width:10px;height:10px;border-radius:2px;background-color:${null==t?void 0:t.color};flex-shrink:0;'></div>\n <span style='font-weight:500;'>${null==t?void 0:t.title}</span>\n <span style='opacity:0.6;'>·</span>\n <span style='font-weight:600;'>${e}</span>\n </div>\n `,viewPortHeight:500,viewPortWidth:800,whitespace:.18,orientation:"horizontal",axisTitles:void 0,width:"100%",highlightConnectedPath:!0,dimOpacity:.2,animation:{enabled:!0,duration:800},a11y:{enabled:!0}},Ft={diagramLabel:({flowCount:t,largestFlow:e,nodeCount:n})=>{let o=`Sankey flow diagram: ${n} nodes, ${t} flows.`;return e&&(o+=` Largest flow: ${e.source} (${e.value} units) to ${e.target}.`),o},edgeAriaLabel:({source:t,target:e,value:n})=>`Flow from ${t} to ${e}: ${n} units`,nodeAriaLabel:({incoming:t,name:e,outgoing:n})=>{let o=e;if(t&&(o+=`: receives ${t.total} units from ${t.sources.join(", ")}`),n){o+=`${t?"; ":": "}flows ${n.total} units to ${n.targets.join(", ")}`}return o},nodesGroupLabel:"Sankey nodes"};function Rt(t){var e;return function(t,e){if(!e)return{...t};const n={...t};for(const t of Object.keys(e)){const o=e[t];void 0!==o&&(n[t]=o)}return n}(Ft,null==(e=t.locale)?void 0:e.messages)}class Bt{constructor(t,e,n){this.element=t,this.options=e,this.chartContext=n,t.innerHTML="",this.canvas=function(){const t=document.createElementNS(s,"svg");return new g(t)}().addTo(t).size("100%","100%").viewbox(`-${this.spacing} -${this.spacing+this.getYShift()} ${this.width+2*this.spacing} ${this.height+this.spacing+this.getYShift()}`).attr({style:this.options.canvasStyle})}getYShift(){return this.options.enableToolbar?30:0}add(t){this.canvas.add(t)}clear(){this.canvas.clear().viewbox(`-${this.spacing} -${this.spacing+this.getYShift()} ${this.width+2*this.spacing} ${this.height+this.spacing+this.getYShift()}`)}exportToSvg(){new i(this.canvas,"apexsankey").exportToSVG()}resetViewBox(){this.canvas.viewbox(`-${this.spacing} -${this.spacing+this.getYShift()} ${this.width+2*this.spacing} ${this.height+this.spacing+this.getYShift()}`)}updateViewBox(t,e,n,o){this.canvas.viewbox(`${t} ${e} ${n} ${o}`)}get height(){return this.options.viewPortHeight}get spacing(){return this.options.spacing}get width(){return this.options.viewPortWidth}}class _t{constructor(t,e,n){this.svgRoot=t,this.graph=e,this.dimOpacity=n,this.pinnedNode=null,this.pinnedEdge=null}highlightNode(t){const e=this.prefersReducedMotion(),n=[...this.graph.inEdges(t)??[],...this.graph.outEdges(t)??[]],o=new Set([t]);n.forEach((t=>{var e,n,i,s;const r=this.graph.edge(t.v,t.w,t.name),a=null==(n=null==(e=null==r?void 0:r.source)?void 0:e.data)?void 0:n.id,d=null==(s=null==(i=null==r?void 0:r.target)?void 0:i.data)?void 0:s.id;a&&o.add(a),d&&o.add(d)})),this.dimAll(e),n.forEach((t=>{const n=this.svgRoot.querySelector(`[data-edge-source="${t.v}"][data-edge-target="${t.w}"]`);n&&this.setOpacity(n,1,e)})),o.forEach((t=>{const n=this.svgRoot.querySelector(`[data-node-id="${t}"]`);n&&this.setOpacity(n,1,e)}))}highlightEdge(t,e){var n,o,i,s;const r=this.prefersReducedMotion(),a=this.graph.edge(t,e),d=(null==(o=null==(n=null==a?void 0:a.source)?void 0:n.data)?void 0:o.id)??t,l=(null==(s=null==(i=null==a?void 0:a.target)?void 0:i.data)?void 0:s.id)??e;this.dimAll(r),this.svgRoot.querySelectorAll(`[data-edge-source="${t}"][data-edge-target="${e}"]`).forEach((t=>this.setOpacity(t,1,r)));const c=this.svgRoot.querySelector(`[data-node-id="${d}"]`),h=this.svgRoot.querySelector(`[data-node-id="${l}"]`);c&&this.setOpacity(c,1,r),h&&this.setOpacity(h,1,r)}focusNode(t){const e=new Set([t]),n=[];this.walk(t,"down",e,n),this.walk(t,"up",e,n),this.applySets(e,n)}focusEdge(t,e){var n,o,i,s;const r=this.graph.edge(t,e),a=(null==(o=null==(n=null==r?void 0:r.source)?void 0:n.data)?void 0:o.id)??t,d=(null==(s=null==(i=null==r?void 0:r.target)?void 0:i.data)?void 0:s.id)??e,l=new Set([a,d]),c=[{v:t,w:e}];this.walk(a,"up",l,c),this.walk(d,"down",l,c),this.applySets(l,c)}togglePinFocusNode(t){this.pinnedNode!==t?(this.pinnedNode=t,this.pinnedEdge=null,this.focusNode(t)):this.clearPin()}togglePinFocusEdge(t,e){this.pinnedEdge&&this.pinnedEdge.source===t&&this.pinnedEdge.target===e?this.clearPin():(this.pinnedEdge={source:t,target:e},this.pinnedNode=null,this.focusEdge(t,e))}isPinned(){return null!==this.pinnedNode||null!==this.pinnedEdge}clearPin(){this.pinnedNode=null,this.pinnedEdge=null,this.clear()}reset(){this.pinnedNode?this.focusNode(this.pinnedNode):this.pinnedEdge?this.focusEdge(this.pinnedEdge.source,this.pinnedEdge.target):this.clear()}walk(t,e,n,o){const i=new Set([t]);let s=[t];for(;s.length;){const t=[];for(const r of s){const s="down"===e?this.graph.outEdges(r)??[]:this.graph.inEdges(r)??[];for(const r of s){o.push({v:r.v,w:r.w});const s="down"===e?r.w:r.v;n.add(s),i.has(s)||(i.add(s),t.push(s))}}s=t}}applySets(t,e){const n=this.prefersReducedMotion();this.dimAll(n),e.forEach((({v:t,w:e})=>{this.svgRoot.querySelectorAll(`[data-edge-source="${t}"][data-edge-target="${e}"]`).forEach((t=>this.setOpacity(t,1,n)))})),t.forEach((t=>{const e=this.svgRoot.querySelector(`[data-node-id="${t}"]`);e&&this.setOpacity(e,1,n)}))}clear(){const t=this.prefersReducedMotion()?"none":"";this.svgRoot.querySelectorAll("[data-edge-source]").forEach((e=>{e.style.transition=t,e.style.opacity=""})),this.svgRoot.querySelectorAll("[data-node-id]").forEach((e=>{e.style.transition=t,e.style.opacity=""}))}dimAll(t){this.svgRoot.querySelectorAll("[data-edge-source]").forEach((e=>{this.setOpacity(e,this.dimOpacity,t)})),this.svgRoot.querySelectorAll("[data-node-id]").forEach((e=>{this.setOpacity(e,this.dimOpacity,t)}))}setOpacity(t,e,n){t.style.transition=n?"none":"opacity 0.2s ease",t.style.opacity=String(e)}prefersReducedMotion(){return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}}function It(t,e){const n=e=>function(t,e){return getComputedStyle(t).getPropertyValue(e).trim()}(t,e),o=n("--apex-sankey-edge-opacity"),i=""!==o?Number(o):e.edgeOpacity,s=n("--apex-sankey-node-width"),r=""!==s?Number(s):e.nodeWidth,a=n("--apex-sankey-node-border-width"),d=""!==a?Number(a):e.nodeBorderWidth,l=n("--apex-sankey-edge-gradient"),c=""!==l?"true"===l:e.edgeGradientFill,h=et(t,"string"==typeof e.theme?e.theme:void 0),u=(t,o,i)=>function({cssVar:t,fallback:e,option:n,token:o}){return t||(n&&n!==e?n:o||(n??""))}({cssVar:n(t),fallback:Nt[o],option:e[o],token:i}),p=n("--apex-sankey-node-border-color")||(e.nodeBorderColor!==Nt.nodeBorderColor?e.nodeBorderColor:h.grid??e.nodeBorderColor),g=u("--apex-sankey-tooltip-bg","tooltipBGColor",h.surface),f=u("--apex-sankey-tooltip-border-color","tooltipBorderColor",h.grid),v=u("--apex-sankey-tooltip-font-color","tooltipFontColor",h.fore),m=h.series&&((y=e.nodePalette)===(b=Nt.nodePalette)||y&&b&&y.length===b.length&&y.every(((t,e)=>t===b[e])))?[...h.series]:e.nodePalette;var y,b;const x=n("--apex-sankey-tooltip-theme"),w="dark"===x||"light"===x?x:e.tooltipTheme;return{...e,edgeGradientFill:c,edgeOpacity:Number.isFinite(i)?i:e.edgeOpacity,fontColor:u("--apex-sankey-label-color","fontColor",h.fore),fontSize:n("--apex-sankey-label-font-size")||e.fontSize,fontFamily:n("--apex-sankey-font-family")||e.fontFamily,nodeBorderColor:p,nodePalette:m,nodeBorderWidth:Number.isFinite(d)?d:e.nodeBorderWidth,nodeWidth:Number.isFinite(r)?r:e.nodeWidth,tooltipBGColor:g,tooltipBorderColor:f,tooltipFontColor:v,tooltipTheme:w}}const Ot="#005FCC",Dt="role",Gt="aria-label",Pt="data-node-id",jt="data-orig-stroke",zt="data-orig-stroke-width",qt="stroke",Ht="stroke-width",Wt="forced-colors",Vt="apexsankey-desc",Yt="data-edge-target";const Kt="apexsankey-a11y-styles";class Ut{constructor(t,e,n={},o,i,s=Ft){this.svgEl=t,this.graph=e,this.options=n,this.tooltipId=o,this.pathHighlighter=i,this.messages=s,this.nodeGroups=[],this.edgePaths=[],this.nodeOutEdges=new Map,this.edgeSourceNode=new Map,this.mediaQuery=null,this.forcedColorsHandler=null,this.isKeyboardUser=!1}apply(){!1!==this.options.enabled&&(this.injectAriaAttributes(),this.setupKeyboardNavigation(),function(){if(document.getElementById(Kt))return;const t=document.createElement("style");t.id=Kt,t.textContent=`\n /* ApexSankey: keyboard focus ring */\n .node:focus,\n svg path[data-edge-source]:focus { outline: none; }\n .node:focus-visible rect {\n stroke: ${Ot};\n stroke-width: 2;\n }\n\n /* High-contrast (Windows Forced Colors) */\n @media (forced-colors: active) {\n .node rect {\n fill: ButtonFace;\n stroke: ButtonText;\n }\n .node text {\n fill: ButtonText;\n }\n .node:focus-visible rect {\n stroke: Highlight;\n stroke-width: 2;\n }\n }\n\n /* Reduced motion */\n @media (prefers-reduced-motion: reduce) {\n .node rect,\n svg path {\n transition: none !important;\n animation: none !important;\n }\n }\n `,document.head.appendChild(t)}(),this.setupHighContrastMode())}destroy(){this.mediaQuery&&this.forcedColorsHandler&&(this.mediaQuery.removeEventListener("change",this.forcedColorsHandler),this.mediaQuery=null,this.forcedColorsHandler=null)}injectAriaAttributes(){const{svgEl:t,graph:e,messages:n,options:o}=this,i=e.nodes().filter((t=>!e.node(t).dummy)),s=e.edges(),r=function(t,e,n,o,i){var s,r,a,d;if(i)return i;let l=0,c="",h="";for(const e of n)try{const n=t.edge(e.v,e.w,e.name).value??0;if(n>l){const o=t.node(e.v),i=t.node(e.w);o.dummy||i.dummy||(l=n,c=(null==(s=o.data)?void 0:s.title)??(null==(r=o.data)?void 0:r.id)??e.v,h=(null==(a=i.data)?void 0:a.title)??(null==(d=i.data)?void 0:d.id)??e.w)}}catch{}const u=c&&h?{source:c,target:h,value:l}:void 0;return o.diagramLabel({flowCount:n.length,largestFlow:u,nodeCount:e.length})}(e,i,s,n,o.diagramLabel);t.setAttribute(Dt,"img"),t.setAttribute(Gt,r),t.removeAttribute("aria-labelledby");const a=t.querySelector("title");if(a&&a.remove(),o.description){let e=t.querySelector("desc");if(!e){const n=document.createElementNS("http://www.w3.org/2000/svg","desc");n.id=Vt,t.insertBefore(n,t.firstChild),e=n}e.textContent=o.description,t.setAttribute("aria-describedby",Vt)}const d=Array.from(t.querySelectorAll(`[${Pt}]`));d.forEach((t=>{const o=t.getAttribute(Pt);o&&(t.setAttribute(Dt,"listitem"),t.setAttribute(Gt,function(t,e,n){var o,i,s,r,a,d;const l=e.node(t),c=(null==(o=l.data)?void 0:o.title)??(null==(i=l.data)?void 0:i.id)??t,h=[];let u=0;for(const n of e.inEdges(t))try{const t=e.edge(n.v,n.w,n.name),o=e.node(n.v);o.dummy||(h.push((null==(s=o.data)?void 0:s.title)??(null==(r=o.data)?void 0:r.id)??n.v),u+=t.value??0)}catch{}const p=[];let g=0;for(const n of e.outEdges(t))try{const t=e.edge(n.v,n.w,n.name),o=e.node(n.w);o.dummy||(p.push((null==(a=o.data)?void 0:a.title)??(null==(d=o.data)?void 0:d.id)??n.w),g+=t.value??0)}catch{}return n.nodeAriaLabel({incoming:h.length>0?{sources:h,total:u}:void 0,name:c,outgoing:p.length>0?{targets:p,total:g}:void 0})}(o,e,n)),t.setAttribute("tabindex","0"))})),this.nodeGroups=d;const l=[],c=new Map,h=new Map;t.querySelectorAll("[data-edge-source]").forEach((t=>{var o,i,s,r;const a=t.getAttribute("data-edge-source"),d=t.getAttribute("data-edge-target"),u=t.getAttribute("data-edge-name")??void 0;if(a&&d)try{const p=e.edge(a,d,u),g=p.source,f=p.target;if(!g||!f)return;const v=(null==(o=g.data)?void 0:o.title)??(null==(i=g.data)?void 0:i.id)??a,m=(null==(s=f.data)?void 0:s.title)??(null==(r=f.data)?void 0:r.id)??d,y=p.value??0;t.setAttribute("role","img"),t.setAttribute("aria-label",n.edgeAriaLabel({source:v,target:m,value:y})),t.setAttribute("focusable","true"),t.setAttribute("tabindex","-1"),l.push(t),h.set(t,a),c.has(a)||c.set(a,[]);const b=c.get(a);b&&b.push(t)}catch{}})),this.edgePaths=l,this.nodeOutEdges=c,this.edgeSourceNode=h}setupKeyboardNavigation(){this.svgEl.addEventListener("pointerdown",(()=>{this.isKeyboardUser=!1})),this.svgEl.addEventListener("keydown",(()=>{this.isKeyboardUser=!0})),this.nodeGroups.forEach(((t,e)=>{t.addEventListener("keydown",(n=>{const o=n.key;if("Enter"===o||" "===o){n.preventDefault();const e=t.querySelector("rect");e&&e.dispatchEvent(new MouseEvent("click",{bubbles:!0}))}else if("Escape"===o)n.preventDefault(),this.restoreFocusRing(t),t.blur(),this.hideTooltip();else if("ArrowRight"===o||"ArrowDown"===o){n.preventDefault();const o=t.getAttribute(Pt),i=o?this.nodeOutEdges.get(o)??[]:[];if(i.length>0)i[0].focus();else{this.nodeGroups[(e+1)%this.nodeGroups.length].focus()}}else if("ArrowLeft"===o||"ArrowUp"===o){n.preventDefault();this.nodeGroups[(e-1+this.nodeGroups.length)%this.nodeGroups.length].focus()}})),t.addEventListener("focus",(()=>{var e;if(this.isKeyboardUser){this.applyFocusRing(t);const n=t.getAttribute(Pt);n&&(null==(e=this.pathHighlighter)||e.highlightNode(n))}if(this.tooltipId){const e=t.querySelector("rect");if(e){const t=e.getBoundingClientRect();e.dispatchEvent(new MouseEvent("mouseover",{clientX:t.left+t.width/2,clientY:t.top,bubbles:!0}))}}})),t.addEventListener("blur",(()=>{var e;this.restoreFocusRing(t),null==(e=this.pathHighlighter)||e.reset(),this.hideTooltip()}))}));for(const t of this.edgePaths){const e=()=>{const e=this.edgeSourceNode.get(t);return e?this.nodeOutEdges.get(e)??[]:[]},n=()=>{const e=this.edgeSourceNode.get(t),n=e?this.nodeGroups.find((t=>t.getAttribute(Pt)===e)):void 0;n&&n.focus()};t.addEventListener("keydown",(o=>{const i=o.key;if("Enter"===i||" "===i)o.preventDefault(),t.dispatchEvent(new MouseEvent("click",{bubbles:!0}));else if("Escape"===i||"ArrowLeft"===i)o.preventDefault(),n();else if("ArrowDown"===i){o.preventDefault();const n=e(),i=n.indexOf(t);n[(i+1)%n.length].focus()}else if("ArrowUp"===i){o.preventDefault();const n=e(),i=n.indexOf(t);n[(i-1+n.length)%n.length].focus()}else if("ArrowRight"===i){o.preventDefault();const e=t.getAttribute(Yt),n=e?this.nodeGroups.find((t=>t.getAttribute(Pt)===e)):void 0;n&&n.focus()}else if("Tab"===i){const e=this.edgeSourceNode.get(t),n=this.nodeGroups.findIndex((t=>t.getAttribute(Pt)===e));if(-1!==n){const t=o.shiftKey?(n-1+this.nodeGroups.length)%this.nodeGroups.length:(n+1)%this.nodeGroups.length;o.preventDefault(),this.nodeGroups[t].focus()}}})),t.addEventListener("focus",(()=>{var e;if(this.isKeyboardUser){const n=t.getAttribute("data-edge-source"),o=t.getAttribute(Yt);n&&o&&(null==(e=this.pathHighlighter)||e.highlightEdge(n,o))}if(this.tooltipId){const e=t.getBoundingClientRect();t.dispatchEvent(new MouseEvent("mouseover",{clientX:e.left+e.width/2,clientY:e.top+e.height/2,bubbles:!0}))}})),t.addEventListener("blur",(t=>{var e;const n=t.relatedTarget;n&&this.edgePaths.includes(n)||(null==(e=this.pathHighlighter)||e.reset(),this.hideTooltip())}))}}hideTooltip(){if(this.tooltipId){const t=document.getElementById(this.tooltipId);t&&(t.style.display="none")}}applyFocusRing(t){const e=t.querySelector("rect");e&&(e.setAttribute(jt,e.getAttribute(qt)??""),e.setAttribute(zt,e.getAttribute(Ht)??""),e.setAttribute(qt,Ot),e.setAttribute(Ht,"2"))}restoreFocusRing(t){const e=t.querySelector("rect");if(!e)return;const n=e.getAttribute(jt),o=e.getAttribute(zt);null!==n&&(e.setAttribute(qt,n),e.removeAttribute(jt)),null!==o&&(e.setAttribute(Ht,o),e.removeAttribute(zt))}setupHighContrastMode(){if("undefined"!=typeof window&&"function"==typeof window.matchMedia)try{const t=window.matchMedia("(forced-colors: active)");this.mediaQuery=t,t.matches&&this.svgEl.classList.add(Wt),this.forcedColorsHandler=t=>{t.matches?this.svgEl.classList.add(Wt):this.svgEl.classList.remove(Wt)},t.addEventListener("change",this.forcedColorsHandler)}catch{}}}const Xt="http://www.w3.org/2000/svg";const Zt=t=>0===t.dy?0:2;function Qt(t,e,n=.5){return t+(e-t)*n}function Jt(t,e=!1){const n=(t,n)=>e?`${n},${t}`:`${t},${n}`,o=Math.max(Zt(t),t.dy)/2;let{x0:i}=t,{x1:s}=t,{y0:r}=t,{y1:a}=t;s<i&&([i,s]=[s,i],[r,a]=[a,r]);const d=Qt(i,s);return`M${n(i,r-o)} C${n(d,r-o)} ${n(d,a-o)} ${n(s,a-o)} L${n(s,a+o)} C${n(d,a+o)} ${n(d,r+o)} ${n(i,r+o)} Z`}function te(t,e=!1){const n=(t,n)=>e?`${n},${t}`:`${t},${n}`;let{x0:o}=t,{x1:i}=t,{y0:s}=t,{y1:r}=t;i<o&&([o,i]=[i,o],[s,r]=[r,s]);const a=Qt(o,i);return`M${n(o,s)} C${n(a,s)} ${n(a,r)} ${n(i,r)}`}function ee(t,e=!1){if(!t.points||t.points.length<2)return null;let n="";for(let o=0;o<t.points.length-1;++o){const i=t.points[o],s=t.points[o+1];n+=`${te({dy:t.dy??0,r0:i.ro,r1:s.ri,x0:i.x??0,x1:s.x??0,y0:i.y??0,y1:s.y??0},e)} `}return n.trim()}function ne(t,e=!1){var n;if(1===(null==(n=t.points)?void 0:n.length))return function(t,e=!1){if(!t.points)return null;const n=t.points[0],o=Math.max(Zt(t),t.dy??0)/2,i=(t,n)=>e?`${n},${t}`:`${t},${n}`;return"down-right"===n.style?`M${i((n.x??0)-20,(n.y??0)-o)} L${i(n.x??0,(n.y??0)-o)} L${i(n.x??0,(n.y??0)+o)} L${i((n.x??0)-20,(n.y??0)+o)} Z`:"right-down"===n.style?`M${i(n.x??0,(n.y??0)-o)} L${i((n.x??0)+20,(n.y??0)-o)} L${i((n.x??0)+20,(n.y??0)+o)} L${i(n.x??0,(n.y??0)+o)} Z`:null}(t,e);if(!t.points)return null;let o,i="";for(let n=0;n<t.points.length-1;++n){const s=t.points[n],r=t.points[n+1];o={d0:s.d,d1:r.d,dy:t.dy??0,r0:s.ro,r1:r.ri,x0:s.x??0,x1:r.x??0,y0:s.y??0,y1:r.y??0},i+=Jt(o,e)}return i}const oe=(t,e)=>{const n=(null==t?void 0:t.title)??(null==t?void 0:t.id)??"";return e&&n.length>e?`${n.substr(0,15)}...`:n};function ie(t,e,n){var o,i;const{dy:s,x:r,y:a}=t,{fontColor:l="#212121",fontSize:c="14px",fontFamily:h,fontWeight:u,isRtl:p=!1,vertical:g=!1,nodeBorderColor:m,nodeBorderWidth:y,nodeWidth:b=0,onNodeClick:x,nodeTooltip:w}=n,C=new d({class:"node"}),k=f(g?{height:b,width:s,x:a??0,y:(r??0)-b/2}:{height:s,width:b,x:(r??0)-b/2,y:a});if(k.fill(null==(o=t.data)?void 0:o.color),k.stroke({color:m??(null==(i=t.data)?void 0:i.color),width:y}),k.on("click",(()=>{"function"==typeof x&&x(t)})),w){const{chartContext:e,isCustomTooltip:n,nodeValue:o,tooltipBGColor:i,tooltipBorderColor:s,tooltipFontColor:r,tooltipId:a,nodeTooltipTemplate:d}=w,p=d({node:t.data,value:o});k.on("mouseover",(t=>{const{pageX:o,pageY:d}=t,g=S({bgColor:n?void 0:i,borderColor:n?void 0:s,fontColor:n?void 0:r||l,fontFamily:n?void 0:h??"",fontSize:n?void 0:c??"14px",fontWeight:n?void 0:u??"400",x:o,y:d});A(e,a,g,p,!0)})),k.on("mousemove",(t=>{const{pageX:o,pageY:d}=t,g=S({bgColor:n?void 0:i,borderColor:n?void 0:s,fontColor:n?void 0:r||l,fontFamily:n?void 0:h??"",fontSize:n?void 0:c??"14px",fontWeight:n?void 0:u??"400",x:o,y:d});A(e,a,g,p,!0)})),k.on("mouseout",(()=>{E(e,a).style.display="none"}))}if(C.add(k),t.data&&(s??0)>Number.parseInt(c,10)){const n=function(t,{fontColor:e,isRtl:n,maxRank:o,nodeWidth:i,vertical:s}){const{data:r}=t;if(!r)return null;if(s){const n=(t.y??0)+(t.dy??0)/2,s=t.x??0,a=(t.rank??0)<o/2?s+i/2+14:s-i/2-8;return v(oe(r,18),{fontColor:e,pointerEvents:"none",textAnchor:"middle",x:n,y:a})}const a=function(t,e,n){let o=!1,i=!1;return(t.rank??0)<e/2&&(i=!0,o=!1),n&&(i=!i),{right:i,top:o}}(t,o,n),{x:d,y:l}=function(t,e,n){const o=e.top?-25:(t.dy??0)/2-10;let i;return i=e.top?e.right?4:-4:e.right?10+n/2:-n/2-10,{x:(t.x??0)+i,y:(t.y??0)+o}}(t,a,i);return v(oe(r,a.top?25:15),{fontColor:e,pointerEvents:"none",textAnchor:a.top?"middle":a.right?"start":"end",x:d,y:l})}(t,{fontColor:l,isRtl:p,maxRank:e,nodeWidth:b,vertical:g});n&&C.add(n)}return C}class se{build(t){const{chartContext:e,events:n,graph:o,isRtl:i,maxRank:s,messages:r,options:a,pathHighlighter:d}=t,{enableTooltip:l,fontColor:c,fontFamily:h,fontSize:u,fontWeight:p,nodeBorderColor:g,nodeBorderWidth:f,nodeWidth:v,nodeTooltipTemplate:y,onNodeClick:b,tooltipBGColor:x,tooltipBorderColor:w,tooltipFontColor:E,tooltipId:A}=a,S=C({color:c,fontFamily:h,fontSize:u,fontWeight:p}),k="vertical"===a.orientation,M=k?m(0,v/2):m(v/2,0);M.attr("style",S);const $=(null==o?void 0:o.nodes())||[],T=(null==o?void 0:o.edges())||[],L=m();T.forEach((e=>{this.buildEdge(t,e,L)})),M.add(L);const N=m();N.node.setAttribute("role","list"),N.node.setAttribute("aria-label",r.nodesGroupLabel),$.forEach((t=>{const r=o.node(t);if(r.dummy)return;let a;if(l&&y){const n=o.inEdges(t)??[],i=o.outEdges(t)??[],s=n.reduce(((t,e)=>{var n;return t+((null==(n=o.edge(e.v,e.w,e.name))?void 0:n.value)??0)}),0),r=i.reduce(((t,e)=>{var n;return t+((null==(n=o.edge(e.v,e.w,e.name))?void 0:n.value)??0)}),0),d=Math.max(s,r);a={chartContext:e,isCustomTooltip:y!==Nt.nodeTooltipTemplate,nodeTooltipTemplate:y,nodeValue:d,tooltipBGColor:x,tooltipBorderColor:w,tooltipFontColor:E,tooltipId:A}}const m=ie(r,s,{fontColor:c,fontFamily:h,fontSize:u,fontWeight:p,isRtl:i,vertical:k,nodeBorderColor:g,nodeBorderWidth:f,nodeWidth:v,nodeTooltip:a,onNodeClick:b});if(m.node.setAttribute("data-node-id",t),m.node.setAttribute("data-node-rank",String(r.rank??0)),d&&(m.node.addEventListener("mouseenter",(()=>{d.isPinned()||d.highlightNode(t)})),m.node.addEventListener("mouseleave",(()=>d.reset())),m.node.addEventListener("click",(()=>d.togglePinFocusNode(t)))),n){const e=e=>o=>n.emit(e,{id:t,node:r,originalEvent:o});m.node.addEventListener("click",e("node:click")),m.node.addEventListener("mouseenter",e("node:mouseenter")),m.node.addEventListener("mouseleave",e("node:mouseleave"))}N.add(m)})),M.add(N);const F=this.buildAxisTitles(t);return F&&M.add(F),{mainGroup:M,edgesGroup:L,nodesGroup:N}}buildAxisTitles(t){const{graph:e,options:n}=t,o=n.axisTitles;if(!o||0===o.length)return null;const i="vertical"===n.orientation,s=((null==e?void 0:e.nodes())??[]).map((t=>e.node(t))).filter((t=>!t.dummy&&null!=t.x&&null!=t.y));if(0===s.length)return null;const r=Math.min(...s.map((t=>t.y??0))),a=new Map;for(const t of s){const e=t.rank??0;a.has(e)||a.set(e,{x:t.x??0,y:t.y??0})}const d=m();d.node.setAttribute("class","axis-titles"),d.node.setAttribute("aria-hidden","true");for(const[t,e]of a){const s=o[t];if(null==s||""===s)continue;const a=i?r-18:e.x,l=i?e.x:r-18,c=v(s,{fontColor:n.fontColor,pointerEvents:"none",textAnchor:i?"end":"middle",x:a,y:l});c.node.setAttribute("font-weight","600"),d.add(c)}return d}buildEdge(t,e,n){const{canvas:o,chartContext:i,events:s,graph:r,isRtl:a,options:d,pathHighlighter:l}=t,{edgeGradientFill:c,edgeOpacity:h,enableTooltip:u,fontFamily:p,fontSize:g,fontWeight:f,nodeWidth:v,tooltipBGColor:m,tooltipBorderColor:b,tooltipFontColor:x,tooltipId:w,tooltipTemplate:C}=d,k=r.edge(e.v,e.w,e.name),M=r.node(e.v),$=r.node(e.w),T=k.source,L=k.target;if(!T||!L)return;const N=a?-1:1;M.dummy&&(k.x0=(k.x0??0)-v/2*N),$.dummy&&(k.x1=(k.x1??0)+v/2*N);const F=ne(k,"vertical"===d.orientation);if(!F)return;const R=y(F,{edgeColor:o.gradient("linear",(t=>{var e,n,o;t.stop(0,(null==(e=T.data)?void 0:e.color)??""),t.stop(1,c?(null==(n=L.data)?void 0:n.color)??"":(null==(o=T.data)?void 0:o.color)??"")})),id:`${e.v}-${e.w}`,opacity:h});R.node.setAttribute("data-edge-source",e.v),R.node.setAttribute("data-edge-target",e.w),void 0!==e.name&&R.node.setAttribute("data-edge-name",e.name);if(($.rank??0)<(M.rank??0)&&(R.node.setAttribute("data-edge-reversed","true"),R.node.style.opacity="1",R.node.setAttribute("fill-opacity",String(h)),R.node.setAttribute("stroke","#475569"),R.node.setAttribute("stroke-width","1.5"),R.node.setAttribute("stroke-opacity","0.85"),R.node.setAttribute("stroke-dasharray","7 5")),l){const t=e.v,n=e.w;R.on("mouseenter",(()=>{l.isPinned()||l.highlightEdge(t,n)})),R.on("mouseleave",(()=>l.reset())),R.on("click",(()=>l.togglePinFocusEdge(t,n)))}if(s){const t=t=>n=>s.emit(t,{source:e.v,target:e.w,value:k.value??0,originalEvent:n});R.on("click",t("edge:click")),R.on("mouseenter",t("edge:mouseenter")),R.on("mouseleave",t("edge:mouseleave"))}if(u&&T.data&&L.data){const t=C?C({source:T.data,target:L.data,value:k.value}):`${T.data.title} → ${L.data.title}: ${k.value}`,e=C!==Nt.tooltipTemplate;R.on("mouseover",(n=>{const{pageX:o,pageY:s}=n,r=S({bgColor:e?void 0:m,borderColor:e?void 0:b,fontColor:e?void 0:x,fontFamily:e?void 0:p,fontSize:e?void 0:g,fontWeight:e?void 0:f,x:o,y:s});A(i,w,r,t,!0)})),R.on("mousemove",(n=>{const{pageX:o,pageY:s}=n,r=S({bgColor:e?void 0:m,borderColor:e?void 0:b,fontColor:e?void 0:x,fontFamily:e?void 0:p,fontSize:e?void 0:g,fontWeight:e?void 0:f,x:o,y:s});A(i,w,r,t,!0)})),R.on("mouseout",(()=>{E(i,w).style.display="none"}))}n.add(R)}}class re{constructor(t,e,n){this.svg=t,this.graph=e,this.options=n,this.baseline=new Map,this.downHandlers=new Map,this.active=null}attach(){for(const t of this.graph.nodes()){const e=this.graph.node(t);e.dummy||this.baseline.set(t,{x:e.x??0,y:e.y??0})}this.svg.querySelectorAll("[data-node-id]").forEach((t=>{const e=t.getAttribute("data-node-id");if(!e)return;t.style.cursor="grab",t.style.touchAction="none";const n=n=>this.onDown(n,e,t);this.downHandlers.set(t,n),t.addEventListener("pointerdown",n)}))}destroy(){this.active&&this.endDrag(this.active,!1),this.downHandlers.forEach(((t,e)=>e.removeEventListener("pointerdown",t))),this.downHandlers.clear(),this.baseline.clear()}onDown(t,e,n){if(this.active)return;if(0!==t.button)return;t.stopPropagation(),t.preventDefault();const o="function"==typeof this.svg.getScreenCTM?this.svg.getScreenCTM():null,i=(null==o?void 0:o.a)||1,s=(null==o?void 0:o.d)||1;"function"==typeof n.getAnimations&&n.getAnimations().forEach((t=>t.cancel())),n.style.opacity="",n.style.transform="";const r=this.collectConnections(e),a=this.graph.node(e),d={id:e,el:n,pointerId:t.pointerId,scaleX:i,scaleY:s,clientX:t.clientX,clientY:t.clientY,nodeStartX:a.x??0,nodeStartY:a.y??0,conns:r,moved:!1,onMove:t=>this.onMove(t),onUp:t=>this.onUp(t)};this.active=d;try{n.setPointerCapture(t.pointerId)}catch{}n.style.cursor="grabbing",n.addEventListener("pointermove",d.onMove),n.addEventListener("pointerup",d.onUp),n.addEventListener("pointercancel",d.onUp)}collectConnections(t){const e=[],n=(t,n,o,i)=>{const s=this.graph.edge(t,n,o),r=null==s?void 0:s.points;if(!r||0===r.length)return;const a="first"===i?r[0]:r[r.length-1],d=this.findEdgeEl(t,n,o);d&&e.push({el:d,label:s,point:a,startX:a.x??0,startY:a.y??0})};for(const e of this.graph.outEdges(t)??[])n(e.v,e.w,e.name,"first");for(const e of this.graph.inEdges(t)??[])n(e.v,e.w,e.name,"last");return e}findEdgeEl(t,e,n){const o=`[data-edge-source="${t}"][data-edge-target="${e}"]`,i=void 0===n?o:`${o}[data-edge-name="${n}"]`;return this.svg.querySelector(i)}onMove(t){var e,n;const o=this.active;if(!o||t.pointerId!==o.pointerId)return;const i=(t.clientX-o.clientX)/o.scaleX,s=(t.clientY-o.clientY)/o.scaleY;!o.moved&&Math.abs(t.clientX-o.clientX)+Math.abs(t.clientY-o.clientY)>3&&(o.moved=!0);const{gx:r,gy:a}=function(t,e,n){return t?{gx:n,gy:e}:{gx:e,gy:n}}(this.options.vertical,i,s),d=this.graph.node(o.id);d.x=o.nodeStartX+r,d.y=o.nodeStartY+a;for(const t of o.conns)t.point.x=t.startX+r,t.point.y=t.startY+a,t.el.setAttribute("d",ne(t.label,this.options.vertical)??"");const l=this.baseline.get(o.id)??{x:0,y:0},c=this.options.vertical?(d.y??0)-l.y:(d.x??0)-l.x,h=this.options.vertical?(d.x??0)-l.x:(d.y??0)-l.y;o.el.setAttribute("transform",`translate(${c} ${h})`),null==(n=(e=this.options).onNodeDrag)||n.call(e,o.id,d,"move")}onUp(t){var e,n;const o=this.active;o&&t.pointerId===o.pointerId&&(this.endDrag(o,o.moved),o.moved&&(null==(n=(e=this.options).onNodeDrag)||n.call(e,o.id,this.graph.node(o.id),"end")))}endDrag(t,e){t.el.removeEventListener("pointermove",t.onMove),t.el.removeEventListener("pointerup",t.onUp),t.el.removeEventListener("pointercancel",t.onUp);try{t.el.releasePointerCapture(t.pointerId)}catch{}if(t.el.style.cursor="grab",e){const e=t=>{t.stopImmediatePropagation(),t.preventDefault()};t.el.addEventListener("click",e,{capture:!0,once:!0})}this.active=null}}const ae="http://www.w3.org/2000/svg";function de(t,e){const n=t.length-1;if(n<=0)return t[0]??{x:0,y:0};const o=e*n;let i=Math.floor(o);i>=n&&(i=n-1),i<0&&(i=0);const s=o-i,r=t[i],a=t[i+1];return{x:r.x+(a.x-r.x)*s,y:r.y+(a.y-r.y)*s}}class le{constructor(t,e,n){this.mainGroup=t,this.graph=e,this.options=n,this.group=null,this.edges=[],this.raf=0,this.lastTs=null}start(){if(this.prefersReducedMotion())return;const t=this.mainGroup.ownerSVGElement;if(!t)return;const e=document.createElementNS(ae,"path");if(e.setAttribute("fill","none"),e.setAttribute("stroke","none"),"function"!=typeof e.getTotalLength||"function"!=typeof e.getPointAtLength)return;t.appendChild(e);const n=document.createElementNS(ae,"g");n.setAttribute("class","apexsankey-particles"),n.setAttribute("aria-hidden","true"),n.style.pointerEvents="none",this.group=n;let o=0;for(const t of this.graph.edges()){if(o>=600)break;const i=this.graph.edge(t.v,t.w,t.name),s=(null==i?void 0:i.dy)??0;if(s<=0)continue;const r=ee(i,this.options.vertical);if(!r)continue;e.setAttribute("d",r);const a=e.getTotalLength();if(!a||!Number.isFinite(a))continue;const d=Math.max(10,Math.min(80,Math.round(a/10))),l=[];for(let t=0;t<=d;t++){const n=e.getPointAtLength(a*t/d);l.push({x:n.x,y:n.y})}const c=Math.max(1,Math.min(16,Math.round(s/9))),h=[],u=[];for(let t=0;t<c&&o<600;t++,o++){const e=document.createElementNS(ae,"circle");e.setAttribute("r",String(1.9)),e.setAttribute("fill","rgba(255,255,255,0.9)"),n.appendChild(e),h.push(e),u.push((t+.6*Math.random())/c)}this.edges.push({pts:l,length:a,circles:h,t:u})}t.removeChild(e),this.edges.length?(this.paint(),this.mainGroup.appendChild(n),this.raf=requestAnimationFrame((t=>this.tick(t)))):this.group=null}destroy(){var t;this.raf&&cancelAnimationFrame(this.raf),this.raf=0,null==(t=this.group)||t.remove(),this.group=null,this.edges=[],this.lastTs=null}tick(t){if(!this.group)return;const e=null===this.lastTs?0:Math.min(.05,(t-this.lastTs)/1e3);this.lastTs=t;for(const t of this.edges){const n=t.length>0?63*e/t.length:0;for(let e=0;e<t.t.length;e++){let o=t.t[e]+n;o>=1&&(o-=Math.floor(o)),t.t[e]=o}}this.paint(),this.raf=requestAnimationFrame((t=>this.tick(t)))}paint(){for(const t of this.edges)for(let e=0;e<t.circles.length;e++){const n=de(t.pts,t.t[e]);t.circles[e].setAttribute("cx",String(n.x)),t.circles[e].setAttribute("cy",String(n.y))}}prefersReducedMotion(){return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}}function ce(t,e,n,o){return[t+n*Math.cos(o),e+n*Math.sin(o)]}const he=t=>(Math.round(100*t)/100).toString();function ue(t,e,n,o,i,s,r=0){const a=s-i>Math.PI?1:0,d=Math.max(0,Math.min(r,o-n,o*(s-i)/2));if(d<=0){const[r,d]=ce(t,e,o,i),[l,c]=ce(t,e,o,s),[h,u]=ce(t,e,n,s),[p,g]=ce(t,e,n,i);return`M${he(r)},${he(d)} A${he(o)},${he(o)} 0 ${a} 1 ${he(l)},${he(c)} L${he(h)},${he(u)} A${he(n)},${he(n)} 0 ${a} 0 ${he(p)},${he(g)} Z`}const l=d/o,c=s-l-(i+l)>Math.PI?1:0,[h,u]=ce(t,e,o,i+l),[p,g]=ce(t,e,o,s-l),[f,v]=ce(t,e,o-d,s),[m,y]=ce(t,e,n,s),[b,x]=ce(t,e,n,i),[w,E]=ce(t,e,o-d,i),A=he(d);return`M${he(h)},${he(u)} A${he(o)},${he(o)} 0 ${c} 1 ${he(p)},${he(g)} A${A},${A} 0 0 1 ${he(f)},${he(v)} L${he(m)},${he(y)} A${he(n)},${he(n)} 0 ${a} 0 ${he(b)},${he(x)} L${he(w)},${he(E)} A${A},${A} 0 0 1 ${he(h)},${he(u)} Z`}function pe(t,e,n,o,i,s,r){const a=i-o>Math.PI?1:0,d=r-s>Math.PI?1:0,[l,c]=ce(t,e,n,o),[h,u]=ce(t,e,n,i),[p,g]=ce(t,e,n,s),[f,v]=ce(t,e,n,r);return`M${he(l)},${he(c)} A${he(n)},${he(n)} 0 ${a} 1 ${he(h)},${he(u)} Q${he(t)},${he(e)} ${he(p)},${he(g)} A${he(n)},${he(n)} 0 ${d} 1 ${he(f)},${he(v)} Q${he(t)},${he(e)} ${he(l)},${he(c)} Z`}class ge{build(t){const{chartContext:e,events:n,layout:o,options:i}=t,{center:s,innerRadius:r,outerRadius:a,arcs:d,ribbons:l}=o,{fontColor:c,fontFamily:h,fontSize:u,fontWeight:p,edgeOpacity:g,dimOpacity:f,enableTooltip:b,arcCornerRadius:x}=i,w=m();w.attr("style",C({color:c,fontFamily:h,fontSize:u,fontWeight:p}));const E=new Map(d.map((t=>[t.id,{title:t.title,color:t.color}]))),A=new Map(d.map((t=>[t.id,0])));for(const t of l)A.set(t.source,(A.get(t.source)??0)+t.value),A.set(t.target,(A.get(t.target)??0)+t.value);const S=[],k=m();for(const e of l){const o=y(pe(s.x,s.y,r,e.s0,e.s1,e.t0,e.t1),{opacity:g,id:`${e.source}-${e.target}`});o.node.setAttribute("fill",e.sourceColor),o.node.setAttribute("data-edge-source",e.source),o.node.setAttribute("data-edge-target",e.target),k.add(o),S.push({source:e.source,target:e.target,el:o.node}),b&&this.wireTooltip(t,o.node,(()=>this.edgeTooltip(t,e.source,e.target,e.value,E))),n&&o.node.addEventListener("click",(t=>n.emit("edge:click",{source:e.source,target:e.target,value:e.value,originalEvent:t})))}w.add(k);const M=[],$=m();for(const e of d){const o=y(ue(s.x,s.y,r,a,e.startAngle,e.endAngle,x??0),{opacity:1});o.node.setAttribute("fill",e.color),o.node.setAttribute("data-node-id",e.id),$.add(o),M.push({id:e.id,el:o.node}),b&&this.wireTooltip(t,o.node,(()=>this.nodeTooltip(t,e.id,E,A.get(e.id)??0))),n&&o.node.addEventListener("click",(t=>n.emit("node:click",{id:e.id,node:{data:{id:e.id,title:e.title,color:e.color}},originalEvent:t})));const i=(e.startAngle+e.endAngle)/2;if(e.endAngle-e.startAngle>=.06){const[t,n]=(T=s.x,L=s.y,ce(T,L,a+10,i)),o=Math.cos(i)>=0,r=v(e.title,{fontColor:c,pointerEvents:"none",textAnchor:o?"start":"end",x:t,y:n});r.node.setAttribute("dominant-baseline","central"),$.add(r)}}var T,L;return w.add($),this.wireHoverFocus(S,M,g,f),{mainGroup:w}}wireHoverFocus(t,e,n,o){const i=(t,e)=>{t.style.transition="opacity 0.15s ease",t.style.opacity=String(e)},s=()=>{t.forEach((t=>i(t.el,n))),e.forEach((t=>i(t.el,1)))};e.forEach((r=>{r.el.addEventListener("mouseenter",(()=>(s=>{const r=new Set([s]);t.forEach((t=>{const e=t.source===s||t.target===s;i(t.el,e?Math.min(1,n+.35):o*n),e&&r.add(t.source).add(t.target)})),e.forEach((t=>i(t.el,r.has(t.id)?1:o)))})(r.id))),r.el.addEventListener("mouseleave",s)})),t.forEach((r=>{r.el.addEventListener("mouseenter",(()=>{t.forEach((t=>i(t.el,t===r?Math.min(1,n+.35):o*n))),e.forEach((t=>i(t.el,t.id===r.source||t.id===r.target?1:o)))})),r.el.addEventListener("mouseleave",s)}))}edgeTooltip(t,e,n,o,i){const{tooltipTemplate:s}=t.options,r=i.get(e),a=i.get(n);return s?s({source:{id:e,...r},target:{id:n,...a},value:o}):`${(null==r?void 0:r.title)??e} → ${(null==a?void 0:a.title)??n}: ${o}`}nodeTooltip(t,e,n,o){const{nodeTooltipTemplate:i}=t.options,s=n.get(e);return i?i({node:{id:e,...s},value:o}):`${(null==s?void 0:s.title)??e}: ${o}`}wireTooltip(t,e,n){const{chartContext:o,options:i}=t,{fontFamily:s,fontSize:r,fontWeight:a,tooltipBGColor:d,tooltipBorderColor:l,tooltipFontColor:c,tooltipId:h,tooltipTemplate:u,nodeTooltipTemplate:p}=i,g=u!==Nt.tooltipTemplate||p!==Nt.nodeTooltipTemplate,f=t=>{const{pageX:e,pageY:i}=t,u=S({bgColor:g?void 0:d,borderColor:g?void 0:l,fontColor:g?void 0:c,fontFamily:g?void 0:s,fontSize:g?void 0:r,fontWeight:g?void 0:a,x:e,y:i});A(o,h,u,n(),!0)};e.addEventListener("mouseover",f),e.addEventListener("mousemove",f),e.addEventListener("mouseout",(()=>{E(o,h).style.display="none"}))}}const fe=-Math.PI/2;class ve{constructor(t={}){this.onFrame=null,this.reducedMotion=t.reducedMotion??!1,this.scene=new K({spring:t.spring,rest:t.rest,reducedMotion:this.reducedMotion,clock:{now:t.now,raf:t.raf,caf:t.caf},onFrame:()=>this.emit()})}has(t){return this.scene.has(t)}positionOf(t){const e=this.scene.valuesOf(t);return e?me(e):void 0}retarget(t,e,n){if(this.scene.has(t))n&&this.scene.snap(t,{x:n.x,y:n.y});else{const o=n??e;this.scene.add(t,{x:o.x,y:o.y},void 0)}this.scene.retarget(t,{x:e.x,y:e.y})}snap(t,e){this.scene.has(t)?this.scene.snap(t,{x:e.x,y:e.y}):this.scene.add(t,{x:e.x,y:e.y},void 0)}remove(t){this.scene.remove(t)}reset(){this.scene.clear()}dispose(){this.scene.dispose()}atRest(){return this.scene.atRest()}step(t){return this.scene.step(t)}start(t){t&&(this.onFrame=t),this.reducedMotion?this.scene.writeAll():this.scene.start()}stop(){this.scene.stop()}emit(){if(!this.onFrame)return;const t=new Map;for(const e of this.scene.ids()){const n=this.scene.valuesOf(e);n&&t.set(e,me(n))}this.onFrame(t)}}function me(t){const{x:e,y:n}=t;return{x:e,y:n}}function ye(t,e,n){return void 0===n?`${t}\0${e}`:`${t}\0${e}\0${n}`}function be(t){const e=new Map;for(const n of t.nodes()){const o=t.node(n);e.set(n,{x:o.x??0,y:o.y??0,dy:o.dy??0})}const n=new Map;for(const e of t.edges()){const o=t.edge(e.v,e.w,e.name);n.set(ye(e.v,e.w,e.name),{v:e.v,w:e.w,x0:o.x0??0,y0:o.y0??0,x1:o.x1??0,y1:o.y1??0,dy:o.dy??0,points:(o.points??[]).map((t=>({x:t.x??0,y:t.y??0})))})}return{nodes:e,edges:n}}function xe(t,e,n){const o=new Map;for(const[i,s]of t.nodes)o.set(i,e.has(i)?{x:n.x,y:n.y,dy:s.dy}:{x:s.x,y:s.y,dy:s.dy});const i=new Map;for(const[o,s]of t.edges){const t=e.has(s.v),r=e.has(s.w),a=s.points.map((t=>({x:t.x,y:t.y})));(t||r)&&a.length&&(t&&(a[0]={x:n.x,y:n.y}),r&&(a[a.length-1]={x:n.x,y:n.y})),i.set(o,{v:s.v,w:s.w,x0:t?n.x:s.x0,y0:t?n.y:s.y0,x1:r?n.x:s.x1,y1:r?n.y:s.y1,dy:s.dy,points:a})}return{nodes:o,edges:i}}const we=(t,e,n)=>t+(e-t)*n;function Ee(t,e,n,o){for(const i of t.nodes()){const s=e.nodes.get(i),r=n.nodes.get(i);if(!s||!r)continue;const a=t.node(i);a.x=we(s.x,r.x,o),a.y=we(s.y,r.y,o),a.dy=we(s.dy,r.dy,o)}for(const i of t.edges()){const s=ye(i.v,i.w,i.name),r=e.edges.get(s),a=n.edges.get(s);if(!r||!a)continue;const d=t.edge(i.v,i.w,i.name);if(d.x0=we(r.x0,a.x0,o),d.y0=we(r.y0,a.y0,o),d.x1=we(r.x1,a.x1,o),d.y1=we(r.y1,a.y1,o),d.dy=we(r.dy,a.dy,o),d.points)for(let t=0;t<d.points.length;t++){const e=r.points[t],n=a.points[t];e&&n&&(d.points[t].x=we(e.x,n.x,o),d.points[t].y=we(e.y,n.y,o))}}}const Ae=[120,20];class Ce extends Bt{constructor(t,e,n,o){super(t,e,n),this.events=o,this.a11yHelper=null,this.pathHighlighter=null,this.nodeDrag=null,this.particleFlow=null,this._hasAnimated=!1,this.renderer=new se,this.lastGeometry=null,this.relayoutMotion=null,this.currentMainGroup=null,this.chordRenderer=new ge,this.chordData=null,this.renderOptions=e,this.messages=Rt(e)}getMessages(){return this.messages}get isRtl(){var t;return function(t,e){var n;if("rtl"===t)return!0;if("ltr"===t)return!1;if("undefined"==typeof window||"undefined"==typeof document)return!1;if(e){const t=e.closest('[dir="rtl"], [dir="ltr"]');return t?"rtl"===t.getAttribute("dir"):"rtl"===window.getComputedStyle(e).direction}return"rtl"===((null==(n=document.documentElement)?void 0:n.getAttribute("dir"))??document.dir)}((null==(t=this.options.locale)?void 0:t.direction)??"ltr",this.element)}construct(t){var e;if("chord"===this.options.type)return void this.constructChord(t);const{edgeGap:n,nodeWidth:o,spacing:i,viewPortHeight:s,viewPortWidth:r,whitespace:a}=this.options,d=Tt({edgeGap:n,nodeWidth:o,whitespace:a}),l="vertical"===this.options.orientation;d.size(l?[s-o,r-i]:[r-o,s-i]);const c=(null==(e=this.options.nodePalette)?void 0:e.length)?this.options.nodePalette:Lt,h=t.nodes.map(((t,e)=>{const n=e%c.length;return{...t,color:t.color??c[n],colorIndex:n}})),u=d(t.edges,h);this.maxRank=(d.order()??[]).length-1,this.graph=u,this.isRtl&&!l&&this.mirrorLayoutForRtl()}constructChord(t){var e;const n=(null==(e=this.options.nodePalette)?void 0:e.length)?this.options.nodePalette:Lt,o=t.nodes.map(((t,e)=>({id:t.id,title:t.title??t.id,color:t.color??n[e%n.length]}))),i=t.edges.map((t=>({source:t.source,target:t.target,value:t.value})));this.chordData={nodes:o,edges:i}}mirrorLayoutForRtl(){const t=this.graph.nodes();let e=1/0,n=-1/0;for(const o of t){const t=this.graph.node(o).x;void 0!==t&&(e=Math.min(e,t),n=Math.max(n,t))}if(!Number.isFinite(e))return;const o=e+n;for(const e of t){const t=this.graph.node(e);void 0!==t.x&&(t.x=o-t.x)}for(const t of this.graph.edges()){const e=this.graph.edge(t.v,t.w,t.name);if(void 0!==e.x0&&(e.x0=o-e.x0),void 0!==e.x1&&(e.x1=o-e.x1),e.points)for(const t of e.points)void 0!==t.x&&(t.x=o-t.x)}}render({keepOldPosition:t=!1}={}){var e,n,o;if("chord"===this.options.type)return void this.renderChord();this.renderOptions=It(this.element,this.options);const{tooltipTheme:i,tooltipBGColor:s,tooltipBorderColor:r,tooltipFontColor:a}=this.renderOptions;"dark"===i?this.renderOptions={...this.renderOptions,tooltipBGColor:"#1e2433",tooltipBorderColor:"#374151",tooltipFontColor:"#e5e7eb"}:"light"===i&&(this.renderOptions={...this.renderOptions,tooltipBGColor:s,tooltipBorderColor:r,tooltipFontColor:a});const{dimOpacity:d,enableTooltip:l,highlightConnectedPath:c,tooltipId:h}=this.renderOptions,u=this.canvas.viewbox();this.clear(),this.pathHighlighter=c?new _t(this.canvas.node,this.graph,d):null;const{mainGroup:p,edgesGroup:g,nodesGroup:f}=this.renderer.build({canvas:this.canvas,chartContext:this.chartContext,events:this.events,graph:this.graph,isRtl:this.isRtl,maxRank:this.maxRank,messages:this.messages,options:this.renderOptions,pathHighlighter:this.pathHighlighter});this.add(p),this.currentMainGroup=p;const{animation:v}=this.renderOptions;if((null==v?void 0:v.enabled)&&!this._hasAnimated&&(this._hasAnimated=!0,function(t,e,n,o,i){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const s=t.viewBox.baseVal,r=s.width,a=s.x,d=t.querySelector("defs")??(()=>{const e=document.createElementNS(Xt,"defs");return t.insertBefore(e,t.firstChild),e})(),l=`sankey-flow-clip-${Math.random().toString(36).slice(2,9)}`,c=document.createElementNS(Xt,"clipPath");c.setAttribute("id",l);const h=document.createElementNS(Xt,"rect");h.setAttribute("x",String(a)),h.setAttribute("y","-9999"),h.setAttribute("height","99999"),h.setAttribute("width","0"),c.appendChild(h),d.appendChild(c),e.setAttribute("clip-path",`url(#${l})`);let u=null;requestAnimationFrame((function t(n){null===u&&(u=n);const o=n-u,s=Math.min(o/i,1),a=((d=s)<.5?2*d*d:(4-2*d)*d-1)*r;var d;h.setAttribute("width",String(a)),s<1?requestAnimationFrame(t):(e.removeAttribute("clip-path"),c.remove())}));const p=n.querySelectorAll("[data-node-rank]"),g=.1*i,f=.7*i-g,v=.45*i;p.forEach((t=>{const e=parseInt(t.getAttribute("data-node-rank")??"0",10),n=g+(o>0?e/o:0)*f;t.style.opacity="0";const i=t.animate([{opacity:"0",transform:"translateY(6px)"},{opacity:"1",transform:"translateY(0px)"}],{duration:v,delay:n,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"forwards"});i.onfinish=()=>{t.style.opacity="",t.style.transform="",i.cancel()}}))}(this.canvas.node,g.node,f.node,this.maxRank,v.duration)),t&&this.updateViewBox(u.x,u.y,u.width,u.height),l){const t=E(this.chartContext,h);this.chartContext.getAppendContainer().appendChild(t)}this.a11yHelper&&this.a11yHelper.destroy();const m=this.renderOptions.a11y;!1!==(null==m?void 0:m.enabled)&&(this.a11yHelper=new Ut(this.canvas.node,this.graph,m,h,this.pathHighlighter,this.messages),this.a11yHelper.apply()),null==(e=this.nodeDrag)||e.destroy(),this.nodeDrag=null,this.renderOptions.draggableNodes&&(this.nodeDrag=new re(this.canvas.node,this.graph,{vertical:"vertical"===this.renderOptions.orientation}),this.nodeDrag.attach()),null==(n=this.particleFlow)||n.destroy(),this.particleFlow=null,this.renderOptions.particleFlow&&(this.particleFlow=new le(p.node,this.graph,{vertical:"vertical"===this.renderOptions.orientation}),this.particleFlow.start()),this.lastGeometry=be(this.graph),null==(o=this.events)||o.emit("rendered")}renderChord(){var t;if(this.renderOptions=It(this.element,this.options),"dark"===this.renderOptions.tooltipTheme&&(this.renderOptions={...this.renderOptions,tooltipBGColor:"#1e2433",tooltipBorderColor:"#374151",tooltipFontColor:"#e5e7eb"}),this.clear(),!this.chordData)return;const{enableTooltip:e,nodeWidth:n,tooltipId:o,viewPortHeight:i,viewPortWidth:s}=this.renderOptions,r=function(t,e,n){const{width:o,height:i,nodeWidth:s}=n,r=n.padAngle??.04,a={x:o/2,y:i/2},d=Math.max(10,Math.min(o,i)/2-56),l=Math.max(5,d-Math.max(12,s)),c=e.filter((t=>t.source!==t.target&&t.value>0)),h=new Map(t.map(((t,e)=>[t.id,e]))),u=new Map(t.map((t=>[t.id,t.color]))),p=new Map(t.map((t=>[t.id,0])));for(const t of c)p.set(t.source,(p.get(t.source)??0)+t.value),p.set(t.target,(p.get(t.target)??0)+t.value);const g=t.filter((t=>(p.get(t.id)??0)>0)),f=g.reduce(((t,e)=>t+(p.get(e.id)??0)),0)||1,v=Math.max(0,2*Math.PI-g.length*r)/f,m=[],y=new Map;let b=fe;for(const t of g){const e=(p.get(t.id)??0)*v;m.push({id:t.id,title:t.title,color:t.color,startAngle:b,endAngle:b+e}),y.set(t.id,b),b+=e+r}const x=new Map;for(const t of g)x.set(t.id,[]);c.forEach(((t,e)=>{var n,o;null==(n=x.get(t.source))||n.push({edge:e,role:"s",other:h.get(t.target)??0}),null==(o=x.get(t.target))||o.push({edge:e,role:"t",other:h.get(t.source)??0})}));const w=[],E=[];for(const t of g){const e=(x.get(t.id)??[]).sort(((t,e)=>t.other-e.other||t.edge-e.edge));let n=y.get(t.id)??fe;for(const t of e){const e=c[t.edge].value*v,o=[n,n+e];"s"===t.role?w[t.edge]=o:E[t.edge]=o,n+=e}}return{center:a,outerRadius:d,innerRadius:l,arcs:m,ribbons:c.map(((t,e)=>{var n,o,i,s;return{index:e,source:t.source,target:t.target,value:t.value,sourceColor:u.get(t.source)??"#888888",targetColor:u.get(t.target)??"#888888",s0:(null==(n=w[e])?void 0:n[0])??0,s1:(null==(o=w[e])?void 0:o[1])??0,t0:(null==(i=E[e])?void 0:i[0])??0,t1:(null==(s=E[e])?void 0:s[1])??0}}))}}(this.chordData.nodes,this.chordData.edges,{width:s,height:i,nodeWidth:n}),{mainGroup:a}=this.chordRenderer.build({chartContext:this.chartContext,layout:r,options:this.renderOptions,events:this.events});if(this.add(a),this.currentMainGroup=a,e){const t=E(this.chartContext,o);this.chartContext.getAppendContainer().appendChild(t)}null==(t=this.events)||t.emit("rendered")}destroy(){var t,e,n,o;null==(t=this.relayoutMotion)||t.dispose(),this.relayoutMotion=null,null==(e=this.particleFlow)||e.destroy(),this.particleFlow=null,null==(n=this.nodeDrag)||n.destroy(),this.nodeDrag=null,null==(o=this.a11yHelper)||o.destroy(),this.a11yHelper=null}update(t,e){var n,o;if("chord"===this.options.type)return this.construct(t),void this.render();null==(n=this.particleFlow)||n.destroy(),this.particleFlow=null;const i=!1===(null==(o=this.renderOptions.animation)?void 0:o.enabled),s=null!==this.lastGeometry&&!i&&!this.prefersReducedMotion();if((null==e?void 0:e.shrinkInto)&&s){const n=be(this.graph),o=xe(n,new Set(e.shrinkInto.nodes),e.shrinkInto.anchor);return void this.animateGeometry(n,o,(()=>{this.construct(t),this.render()}),Ae)}const r=null!==this.lastGeometry?be(this.graph):null;this.construct(t);const a=be(this.graph),d=this.currentMainGroup;if(null===r||null===d||i||this.prefersReducedMotion())this.render();else if(null==e?void 0:e.growFrom){const t=xe(a,new Set(e.growFrom.nodes),e.growFrom.anchor);this.animateGeometry(t,a,(()=>{Ee(this.graph,t,a,1),this.render()}),Ae)}else!function(t,e){if(t.nodes.size!==e.nodes.size||t.edges.size!==e.edges.size)return!1;for(const n of t.nodes.keys())if(!e.nodes.has(n))return!1;for(const[n,o]of t.edges){const t=e.edges.get(n);if(!t||t.points.length!==o.points.length)return!1}return!0}(r,a)?this.morphGrow(r,a,d):this.animateRelayout(r,a)}animateRelayout(t,e){this.animateGeometry(t,e,(()=>{Ee(this.graph,t,e,1),this.render()}))}animateGeometry(t,e,n,o){var i;null==(i=this.relayoutMotion)||i.dispose();const s=new ve(o?{rest:j,spring:o}:{rest:j});this.relayoutMotion=s;let r=!1;s.retarget("t",{x:1,y:0},{x:0,y:0}),s.start((o=>{var i;if(s.atRest()){if(r)return;return r=!0,void n()}const a=(null==(i=o.get("t"))?void 0:i.x)??0;Ee(this.graph,t,e,a),this.drawGeometry()}))}buildLayer(){const{mainGroup:t}=this.renderer.build({canvas:this.canvas,chartContext:this.chartContext,graph:this.graph,isRtl:this.isRtl,maxRank:this.maxRank,messages:this.messages,options:this.renderOptions,pathHighlighter:null});return this.currentMainGroup=t,this.add(t),t}drawGeometry(){this.clear(),this.buildLayer()}morphGrow(t,e,n){var o;null==(o=this.relayoutMotion)||o.dispose(),this.hideSurvivorsOnOldLayer(n,e);const i=function(t,e){const n=new Map;for(const[o,i]of e.nodes){const e=t.nodes.get(o);n.set(o,e?{x:e.x,y:e.y,dy:e.dy}:{x:i.x,y:i.y,dy:0})}const o=new Map;for(const[i,s]of e.edges){const e=t.edges.get(i);if(e&&e.points.length===s.points.length)o.set(i,{v:s.v,w:s.w,x0:e.x0,y0:e.y0,x1:e.x1,y1:e.y1,dy:e.dy,points:e.points.map((t=>({x:t.x,y:t.y})))});else{const t=n.get(s.v),e=(null==t?void 0:t.x)??s.x0,r=(null==t?void 0:t.y)??s.y0;o.set(i,{v:s.v,w:s.w,x0:e,y0:r,x1:e,y1:r,dy:0,points:s.points.map((()=>({x:e,y:r})))})}}return{nodes:n,edges:o}}(t,e);Ee(this.graph,i,e,0);let s=this.buildLayer();const r=new ve({rest:j});this.relayoutMotion=r;let a=!1;r.retarget("t",{x:1,y:0},{x:0,y:0}),r.start((t=>{var o;if(r.atRest()){if(a)return;return a=!0,Ee(this.graph,i,e,1),void this.render()}const d=(null==(o=t.get("t"))?void 0:o.x)??0,l=d<0?0:d>1?1:d;n.node.setAttribute("opacity",String(1-l)),Ee(this.graph,i,e,l),s.node.remove(),s=this.buildLayer()}))}hideSurvivorsOnOldLayer(t,e){const n=t.node;n.querySelectorAll("[data-node-id]").forEach((t=>{e.nodes.has(t.getAttribute("data-node-id")??"")&&(t.style.opacity="0")})),n.querySelectorAll("[data-edge-source]").forEach((t=>{const n=t.getAttribute("data-edge-source")??"",o=t.getAttribute("data-edge-target")??"",i=t.getAttribute("data-edge-name"),s=null===i?ye(n,o):ye(n,o,i);e.edges.has(s)&&(t.style.opacity="0")}))}prefersReducedMotion(){return"undefined"==typeof window||"function"!=typeof window.matchMedia||window.matchMedia("(prefers-reduced-motion: reduce)").matches}}const Se={...{light:{nodePalette:["#6b9ece","#e07b7b","#7dba8f","#b09ed1","#e0b678","#6dbaba","#d17da8","#b5b56d","#c49a6d","#8fa4b8","#c98aa0","#94bf7d","#e0a08a","#7b9eb5","#a988a8"],fontColor:"#212121",edgeOpacity:.4,edgeGradientFill:!0,nodeBorderColor:null,canvasStyle:"border: 1px solid #caced0; box-sizing: border-box",tooltipTheme:"light"},dark:{nodePalette:["#2dd4bf","#7c83f0","#fb6f92","#38bdf8","#fbbf24","#a78bfa","#34d399","#f472b6","#5eead4","#93a6ff","#fca5a5","#fcd34d"],fontColor:"#e7eff4",edgeOpacity:.5,edgeGradientFill:!0,nodeBorderColor:null,canvasStyle:"background: #0e1a23; border: 1px solid #1f2f3a; box-sizing: border-box;",tooltipTheme:"dark"},midnight:{nodePalette:["#818cf8","#a78bfa","#c084fc","#f0abfc","#60a5fa","#38bdf8","#34d399","#fbbf24"],fontColor:"#c7d2fe",edgeOpacity:.55,edgeGradientFill:!0,nodeBorderColor:null,canvasStyle:"background: #0b1020; border: 1px solid #1e2749; box-sizing: border-box;",tooltipTheme:"dark"},mint:{nodePalette:["#10b981","#14b8a6","#0ea5e9","#34d399","#5eead4","#6ee7b7","#22d3ee","#84cc16"],fontColor:"#0f3d33",edgeOpacity:.4,edgeGradientFill:!0,nodeBorderColor:null,canvasStyle:"background: #f2fbf7; border: 1px solid #cbeee0; box-sizing: border-box;",tooltipTheme:"light"},sunset:{nodePalette:["#fb7185","#f97316","#f59e0b","#ef4444","#ec4899","#fbbf24","#fb923c","#e11d48"],fontColor:"#7c2d12",edgeOpacity:.42,edgeGradientFill:!0,nodeBorderColor:null,canvasStyle:"background: #fff7f0; border: 1px solid #f6d9c4; box-sizing: border-box;",tooltipTheme:"light"}}};const ke=["nodePalette","fontColor","edgeOpacity","edgeGradientFill","nodeBorderColor","canvasStyle","tooltipTheme"];function Me(t){if(!t)return{};const e="string"==typeof t?Se[t]:t;if(!e)return{};const n={};for(const t of ke){const o=e[t];void 0!==o&&(n[t]=o)}return n}class $e{constructor(){this.handlers=new Map}on(t,e){let n=this.handlers.get(t);return n||(n=new Set,this.handlers.set(t,n)),n.add(e),()=>this.off(t,e)}off(t,e){const n=this.handlers.get(t);n&&(n.delete(e),0===n.size&&this.handlers.delete(t))}emit(t,e){const n=this.handlers.get(t);if(n)for(const o of[...n])try{o(e)}catch(e){console.error(`ApexSankey: an event handler for "${t}" threw`,e)}}clear(){this.handlers.clear()}}const Te="http://www.w3.org/2000/svg",Le=250;const Ne=[[3.6,1,0],[2.8,.55,.05],[2,.3,.1]];function Fe(t={}){const e=t.trigger??"click",n=t.direction??"downstream",o=t.color??"#ffffff",i=t.duration??700,s=t.stagger??220;return{name:"path-trace",install(t){const r=t.chart;let a=null,d=0,l=0;const c=()=>{d&&cancelAnimationFrame(d),d=0,null==a||a.remove(),a=null},h=t=>{var e;if(c(),"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const h=r.graph,u=null==h?void 0:h.graph,p=null==(e=null==h?void 0:h.canvas)?void 0:e.node;if(!u||!p)return;const g=p.querySelector("[data-edge-source]"),f=null==g?void 0:g.parentNode;if(!f)return;const v=document.createElementNS(Te,"path");if("function"!=typeof v.getTotalLength)return;p.appendChild(v);const m="vertical"===r.options.orientation,y=function(t,e,n){const o=[],i=n=>{const i=new Set([e]);let s=[e],r=0;for(;s.length&&o.length<Le;){const e=[];for(const a of s){const s=n?t.outEdges(a)??[]:t.inEdges(a)??[];for(const t of s){o.push({v:t.v,w:t.w,name:t.name,depth:r,dir:n?1:-1});const s=n?t.w:t.v;i.has(s)||(i.add(s),e.push(s))}}s=e,r++}};return"upstream"!==n&&i(!0),"upstream"!==n&&"both"!==n||i(!1),o}(u,t,n),b=document.createElementNS(Te,"g");b.setAttribute("class","apexsankey-path-trace"),b.setAttribute("aria-hidden","true"),b.style.pointerEvents="none";const x=[];for(const t of y){const e=u.edge(t.v,t.w,t.name),n=e&&ee(e,m);if(!n)continue;v.setAttribute("d",n);const i=v.getTotalLength();if(!i||!Number.isFinite(i))continue;const r=Math.max(8,Math.min(60,Math.round(i/12))),a=[];for(let t=0;t<=r;t++){const e=v.getPointAtLength(i*t/r);a.push({x:e.x,y:e.y})}const d=Ne.map((([t,e])=>{const n=document.createElementNS(Te,"circle");return n.setAttribute("r",String(t)),n.setAttribute("fill",o),n.setAttribute("opacity","0"),n.dataset.opacity=String(e),t>3&&n.setAttribute("stroke","rgba(0,0,0,0.2)"),b.appendChild(n),n}));x.push({pts:a,startAt:t.depth*s,dir:t.dir,circles:d})}if(p.removeChild(v),!x.length)return;f.appendChild(b),a=b;const w=x.reduce(((t,e)=>Math.max(t,e.startAt+i)),0)+250,E=t=>{l||(l=t);const e=t-l;for(const t of x){const n=(e-t.startAt)/i;t.circles.forEach(((e,o)=>{const i=n-Ne[o][2];if(i<0||i>1)return void e.setAttribute("opacity","0");const s=de(t.pts,t.dir>0?i:1-i);e.setAttribute("cx",String(s.x)),e.setAttribute("cy",String(s.y)),e.setAttribute("opacity",e.dataset.opacity??"1")}))}if(e>=w)return c(),void(l=0);d=requestAnimationFrame(E)};l=0,d=requestAnimationFrame(E)},u="hover"===e?"node:mouseenter":"node:click";return t.on(u,(({id:t})=>h(t))),t.on("rendered",c),c}}}function Re(t){const{frames:e}=t,n=t.interval??1600,o=!1!==t.controls;return{name:"time-playback",install(i){var s,r;const a=i.chart,d=e.length-1;let l=0,c=!1,h=0,u=null;const p=()=>{const t=e[l];t&&a.update({nodes:t.nodes,edges:t.edges,options:a.options})},g=()=>{var t;u&&(u.slider.value=String(l),u.label.textContent=(null==(t=e[l])?void 0:t.label)??`Frame ${l+1} / ${e.length}`,u.button.textContent=c?"⏸":"▶",u.button.setAttribute("aria-label",c?"Pause":"Play"))},f=t=>{l=Math.max(0,Math.min(d,t)),p(),g()},v=()=>{h="undefined"!=typeof window?window.setTimeout(y,n):0};function m(){c=!1,h&&clearTimeout(h),h=0,g()}function y(){if(c){if(l>=d){if(!t.loop)return void m();l=0}else l++;p(),g(),v()}}const b=()=>{c||e.length<2||(l>=d&&!t.loop&&f(0),c=!0,g(),v())};if(o){u=function(t){const e=document.createElement("div");e.className="apexsankey-playback",e.style.cssText="display:flex;align-items:center;gap:10px;padding:8px 4px;font:inherit;font-size:13px;color:#334155;";const n=document.createElement("button");n.type="button",n.style.cssText="cursor:pointer;width:34px;height:28px;border:1px solid #cbd5e1;border-radius:6px;background:#fff;font-size:13px;line-height:1;";const o=document.createElement("input");o.type="range",o.min="0",o.max=String(Math.max(0,t-1)),o.step="1",o.value="0",o.setAttribute("aria-label","Time frame"),o.style.cssText="flex:1;cursor:pointer;";const i=document.createElement("span");return i.style.cssText="min-width:110px;text-align:right;font-variant-numeric:tabular-nums;",e.append(n,o,i),{bar:e,button:n,slider:o,label:i}}(e.length),u.button.addEventListener("click",(()=>c?m():b())),u.slider.addEventListener("input",(()=>{const t=Number((null==u?void 0:u.slider.value)??0);m(),f(t)}));const n=null==(r=null==(s=a.graph)?void 0:s.canvas)?void 0:r.node,o=(null==n?void 0:n.parentElement)??null;t.mount?t.mount.appendChild(u.bar):(null==o?void 0:o.parentElement)?o.parentElement.insertBefore(u.bar,o.nextSibling):null==o||o.appendChild(u.bar)}return g(),t.autoplay&&b(),()=>{m(),null==u||u.bar.remove()}}}}function Be(t,e,n){const o=new Set(n),i=new Map(e.map((t=>[t.id,t]))),s=new Map;for(const t of e)if(o.has(t.id))for(const e of t.children)s.set(e,t.id);const r=[],a=new Set;for(const e of t.nodes){const t=s.get(e.id);if(void 0===t){r.push(e);continue}if(a.has(t))continue;a.add(t);const n=i.get(t);n&&r.push(void 0!==n.color?{id:n.id,title:n.title,color:n.color}:{id:n.id,title:n.title})}const d=new Map;for(const e of t.edges){const t=s.get(e.source)??e.source,n=s.get(e.target)??e.target;if(t===n)continue;const o=`${t}\0${n}\0${e.type??""}`,i=d.get(o);i?d.set(o,{...i,value:i.value+e.value}):d.set(o,{...e,source:t,target:n})}return{nodes:r,edges:[...d.values()]}}function _e(t){const{edges:e,groups:n,nodes:o}=t,i={nodes:o,edges:e};return{name:"drill-down",install(e){const o=e.chart,s=new Set(n.map((t=>t.id))),r=new Map;for(const t of n)for(const e of t.children)r.set(e,t.id);const a=new Set(t.expanded??[]),d=()=>{const t=n.filter((t=>!a.has(t.id))).map((t=>t.id));return Be(i,n,t)},l=t=>{o.update({...d(),options:o.options},t)},c=t=>{var e;return(null==(e=n.find((e=>e.id===t)))?void 0:e.children)??[]},h=t=>{var e;const n=null==(e=o.graph)?void 0:e.graph,i=null==n?void 0:n.node(t);return void 0===(null==i?void 0:i.x)||void 0===i.y?null:{x:i.x,y:i.y}},u=()=>{var t,e;const n=null==(e=null==(t=o.graph)?void 0:t.canvas)?void 0:e.node;n&&n.querySelectorAll("[data-node-id]").forEach((t=>{t.style.cursor=(t=>{if(s.has(t))return!a.has(t);const e=r.get(t);return void 0!==e&&a.has(e)})(t.getAttribute("data-node-id")??"")?"pointer":""}))};e.on("rendered",u),e.on("node:click",(({id:t})=>{let e;if(s.has(t)&&!a.has(t)){const n=h(t),o=c(t);a.add(t),n&&o.length&&(e={growFrom:{anchor:n,nodes:o}})}else{const n=r.get(t);if(void 0===n||!a.has(n))return;const o=c(n),i=(t=>{const e=t.map(h).filter((t=>null!==t));if(!e.length)return null;const n=e.reduce(((t,e)=>({x:t.x+e.x,y:t.y+e.y})),{x:0,y:0});return{x:n.x/e.length,y:n.y/e.length}})(o);a.delete(n),i&&o.length&&(e={shrinkInto:{anchor:i,nodes:o}})}l(e)})),l(),u()}}}function Ie(t){var e;const{dimensions:n,records:o}=t,i=(null==(e=t.palette)?void 0:e.length)?t.palette:Lt,s=[],r=new Map,a=new Map;let d=0,l=0;const c=t=>{let e=a.get(t);return e||(e=i[d%i.length],d++,a.set(t,e)),e},h=(t,e)=>{const n=`${t}\0${e}`;let o=r.get(n);return o||(o="alluvial-"+l++,r.set(n,o),s.push({id:o,title:e,color:c(e)})),o},u=new Map;for(const t of o){const e=t.value??1;for(let o=0;o<n.length-1;o++){const i=t.values[n[o]],s=t.values[n[o+1]];if(null==i||null==s)continue;const r=h(o,i),a=h(o+1,s),d=`${r}${a}`,l=u.get(d);l?l.value+=e:u.set(d,{source:r,target:a,value:e,type:i})}}return{nodes:s,edges:[...u.values()]}}const Oe=(t,e,n)=>`${t}\0${e}\0${n}`;function De(t,e){const n=new Map(t.edges.map((t=>[Oe(t.source,t.target,t.type??""),t]))),o=new Map(e.edges.map((t=>[Oe(t.source,t.target,t.type??""),t]))),i=[];for(const t of e.edges){const e=Oe(t.source,t.target,t.type??""),o=n.get(e);i.push({source:t.source,target:t.target,type:t.type??"",status:void 0===o?"added":o.value===t.value?"unchanged":"changed",beforeValue:null==o?void 0:o.value,afterValue:t.value})}for(const e of t.edges){const t=Oe(e.source,e.target,e.type??"");o.has(t)||i.push({source:e.source,target:e.target,type:e.type??"",status:"removed",beforeValue:e.value})}const s=new Set(t.nodes.map((t=>t.id))),r=new Set(e.nodes.map((t=>t.id)));return{edges:i,addedNodes:e.nodes.filter((t=>!s.has(t.id))).map((t=>t.id)),removedNodes:t.nodes.filter((t=>!r.has(t.id))).map((t=>t.id))}}const Ge={added:"#16a34a",removed:"#dc2626",changed:"#d97706"};class Pe{constructor(t,e){this.element=t,this.config=e,this.root=null,this.teardowns=[],this.syncing=!1,this.entered=new Map,this.diff=De(e.before,e.after)}render(){const{after:t,before:e,options:n}=this.config,o={...Ge,...this.config.diffColors};this.element.innerHTML="";const i=document.createElement("div");i.className="apexsankey-comparison",i.style.cssText="display:flex;flex-direction:column;gap:12px;";const s=document.createElement("div");s.className="apexsankey-comparison-panels",s.style.cssText="display:flex;gap:16px;align-items:flex-start;",i.appendChild(s);const r=this.buildPanel(s,e.title),a=this.buildPanel(s,t.title);!1!==this.config.showLegend&&i.appendChild(this.buildLegend(o)),this.element.appendChild(i),this.root=i;const d={...n,width:"100%",height:(null==n?void 0:n.height)??420};if(this.before=new ze(r,{...d,tooltipId:"apexsankey-cmp-before"}),this.after=new ze(a,{...d,tooltipId:"apexsankey-cmp-after"}),this.before.render({nodes:e.nodes,edges:e.edges,options:this.before.options}),this.after.render({nodes:t.nodes,edges:t.edges,options:this.after.options}),!1!==this.config.showDiff){const t=(null==n?void 0:n.edgeOpacity)??.4;this.applyDiff(this.before,"before",o,t),this.applyDiff(this.after,"after",o,t)}return!1!==this.config.syncHighlight&&(this.link(this.before,this.after),this.link(this.after,this.before)),this}destroy(){var t,e,n;for(const t of this.teardowns.splice(0))t();null==(t=this.before)||t.destroy(),null==(e=this.after)||e.destroy(),this.before=void 0,this.after=void 0,this.entered.clear(),null==(n=this.root)||n.remove(),this.root=null}buildPanel(t,e){const n=document.createElement("div");if(n.style.cssText="flex:1;min-width:0;",e){const t=document.createElement("div");t.className="apexsankey-comparison-title",t.textContent=e,t.style.cssText="font-weight:600;font-size:13px;margin-bottom:6px;color:#334155;",n.appendChild(t)}const o=document.createElement("div");return n.appendChild(o),t.appendChild(n),o}buildLegend(t){const e=document.createElement("div");e.className="apexsankey-comparison-legend",e.style.cssText="display:flex;gap:16px;font-size:12px;color:#475569;align-items:center;flex-wrap:wrap;";const n=[["Added",t.added,!0],["Removed",t.removed,!0],["Changed",t.changed,!1]];for(const[t,o,i]of n){const n=document.createElement("span");n.style.cssText="display:inline-flex;align-items:center;gap:6px;";const s=document.createElement("span");s.style.cssText=`display:inline-block;width:20px;height:0;border-top:2px ${i?"dashed":"solid"} ${o};`,n.append(s,document.createTextNode(t)),e.appendChild(n)}return e}applyDiff(t,e,n,o){var i,s;const r=null==(s=null==(i=t.graph)?void 0:i.canvas)?void 0:s.node;if(r)for(const t of this.diff.edges){if(!("changed"===t.status||("before"===e?"removed"===t.status:"added"===t.status)))continue;const i=this.findEdge(r,t.source,t.target);if(!i)continue;const s=n[t.status];i.style.opacity="1",i.setAttribute("fill-opacity",String(o)),i.setAttribute("stroke",s),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-opacity","0.9"),"changed"!==t.status&&i.setAttribute("stroke-dasharray","6 4"),i.setAttribute("data-diff",t.status)}}link(t,e){this.teardowns.push(t.on("node:mouseenter",(({id:t})=>this.syncEnter(e,(e=>this.findNode(e,t)))))),this.teardowns.push(t.on("node:mouseleave",(()=>this.syncLeave(e)))),this.teardowns.push(t.on("edge:mouseenter",(({source:t,target:n})=>this.syncEnter(e,(e=>this.findEdge(e,t,n)))))),this.teardowns.push(t.on("edge:mouseleave",(()=>this.syncLeave(e))))}syncEnter(t,e){var n,o;if(this.syncing)return;const i=null==(o=null==(n=t.graph)?void 0:n.canvas)?void 0:o.node,s=i&&e(i);if(s){this.syncLeave(t),this.syncing=!0;try{s.dispatchEvent(new MouseEvent("mouseenter"))}finally{this.syncing=!1}this.entered.set(t,s)}}syncLeave(t){const e=this.entered.get(t);if(e){this.entered.delete(t),this.syncing=!0;try{e.dispatchEvent(new MouseEvent("mouseleave"))}finally{this.syncing=!1}}}findNode(t,e){for(const n of Array.from(t.querySelectorAll("[data-node-id]")))if(n.getAttribute("data-node-id")===e)return n;return null}findEdge(t,e,n){for(const o of Array.from(t.querySelectorAll("[data-edge-source]")))if(o.getAttribute("data-edge-source")===e&&o.getAttribute("data-edge-target")===n)return o;return null}}const je=class extends o{constructor(t,e={}){super(t,"sankey_"+crypto.randomUUID().replace(/-/g,"").substring(0,9)),this.events=new $e,this.pluginTeardowns=[],this.isDestroyed=!1,this.options={...Nt,...Me(e.theme),...e};const{height:n,width:o}=this.options;this.graph=new Ce(this.element,this.options,this.chartContext,this.events),this.setupElementDimensions(o,n),this.handleWatermark()}static setLicense(t){B.setLicense(t)}static registerTheme(t,e){!function(t,e){Se[t]=e}(t,e)}static buildAlluvialData(t){return Ie(t)}static collapseGroups(t,e,n){return Be(t,e,n)}static compare(t,e){return new Pe(t,e).render()}setupElementDimensions(t,e){let n=!1,o=0;"string"==typeof t&&/^\d+(\.\d+)?%$/.test(t)?(o=Number(t.substring(0,t.length-1)),n=!0):o=Number(t);const i="auto"===e?o/1.6:e;this.element.style.width=`${o}${n?"%":"px"}`,this.element.style.height=`${i}${n?"%":"px"}`,this.element.style.position="relative"}handleWatermark(){this.element&&(B.isLicenseValid()?I.remove(this.element):I.add(this.element))}render(t){var e;if(!this.element)throw new Error("Element not found");if(O(this.element,(null==(e=this.options.locale)?void 0:e.direction)??"ltr"),this.graph.construct(t),this.graph.render(),this.options.enableToolbar){new x(this.element,this.chartContext).render({enableExport:!0,onExport:this.graph.exportToSvg.bind(this.graph)})}return this.graph}update(t,e){var n;if(!this.element)throw new Error("Element not found");return O(this.element,(null==(n=this.options.locale)?void 0:n.direction)??"ltr"),this.graph.update(t,e),this.graph}on(t,e){return this.events.on(t,e)}off(t,e){this.events.off(t,e)}use(t){const e={chart:this,on:(t,e)=>this.on(t,e)},n=t.install(e);return"function"==typeof n&&this.pluginTeardowns.push(n),this}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;for(const t of this.pluginTeardowns.splice(0))try{t()}catch(t){console.error("ApexSankey: a plugin teardown threw",t)}this.events.emit("destroyed"),this.events.clear(),this.graph.destroy(),super.destroy()}}};je.plugins={pathTrace:Fe,timePlayback:Re,drillDown:_e};let ze=je;"undefined"!=typeof window&&(window.ApexSankey=ze),t.ApexSankey=ze,t.DEFAULT_SANKEY_MESSAGES=Ft,t.SankeyComparison=Pe,t.buildAlluvialData=Ie,t.collapseGroups=Be,t.default=ze,t.diffGraphs=De,t.drillDown=_e,t.pathTrace=Fe,t.timePlayback=Re,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ApexSankey={})}(this,(function(t){"use strict";const e=()=>{};class n{constructor(t,e){this.injectedStyles=new Set,this.trackedTooltips=new Set,this.instanceId=e||Math.random().toString(36).substr(2,9),this.context=this.detectContext(t),this.chartContainer=t}getChartContainer(){return this.chartContainer}getChartScopedContainer(){return this.context===document?document.body||document.getElementsByTagName("body")[0]:this.chartContainer||this.context}detectContext(t){const e=t.getRootNode();return e instanceof ShadowRoot?e:document}getContext(){return this.context}getInstanceId(){return this.instanceId}isShadowDOM(){return this.context instanceof ShadowRoot}createElement(t){return document.createElement(t)}createElementNS(t,e){return document.createElementNS(t,e)}createTextNode(t){return document.createTextNode(t)}getElementById(t){return this.context===document?document.getElementById(t):this.context.querySelector(`#${t}`)}getElementsByClassName(t){if(this.context===document)return document.getElementsByClassName(t);const e=this.context.querySelectorAll(`.${t}`),n=Array.from(e);return{item:t=>n[t]||null,get length(){return n.length},[Symbol.iterator]:()=>n[Symbol.iterator](),...Object.fromEntries(n.map(((t,e)=>[e,t])))}}querySelector(t){return this.context.querySelector(t)}querySelectorAll(t){return this.context.querySelectorAll(t)}getAppendContainer(){return this.context===document?document.body||document.getElementsByTagName("body")[0]:this.context}getChartBounds(){var t;return(null==(t=this.chartContainer)?void 0:t.getBoundingClientRect())||new DOMRect}getBody(){if(this.context===document)return document.body||document.getElementsByTagName("body")[0];return this.context.host}dispatchEvent(t){this.context===document?document.dispatchEvent(t):this.context.dispatchEvent(t)}addEventListener(t,e,n){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.addEventListener(t,e,n):this.context.addEventListener(t,e,n)}removeEventListener(t,e,n){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.removeEventListener(t,e,n):this.context.removeEventListener(t,e,n)}injectStyles(t,e,n={}){const{force:o=!1,priority:i="normal"}=n;if(!o&&this.injectedStyles.has(e))return;if(o){const t=this.context.querySelector(`#${e}`);t&&(t.remove(),this.injectedStyles.delete(e))}if(this.context.querySelector(`#${e}`)&&!o)return void this.injectedStyles.add(e);const s=document.createElement("style");if(s.id=e,s.textContent=t,"normal"!==i&&s.setAttribute("data-priority",i),this.context===document)document.head.appendChild(s);else{const t=this.context;"high"===i?t.insertBefore(s,t.firstChild):t.appendChild(s)}this.injectedStyles.add(e)}injectStylesheets(t){t.forEach((({content:t,id:e,options:n})=>{this.injectStyles(t,e,n)}))}hasInjectedStyles(t){return this.injectedStyles.has(t)}removeStyles(t){const e=this.context.querySelector(`#${t}`);e&&(e.remove(),this.injectedStyles.delete(t))}removeAllStyles(){this.injectedStyles.forEach((t=>{const e=this.context.querySelector(`#${t}`);e&&e.remove()})),this.injectedStyles.clear()}getInjectedStyleIds(){return Array.from(this.injectedStyles)}getActiveElement(){if(this.context===document)return document.activeElement;return this.context.activeElement||document.activeElement}trackTooltip(t){this.trackedTooltips.add(t)}destroy(){this.removeAllStyles(),this.injectedStyles.clear(),this.trackedTooltips.forEach((t=>t.remove())),this.trackedTooltips.clear()}}class o{constructor(t,e){if(!t)throw new Error("Container element is required");this.element=t,this.chartContext=new n(t,e)}getContext(){return this.chartContext}isShadowDOM(){return this.chartContext.isShadowDOM()}getTooltipContainer(){return this.chartContext.getAppendContainer()}injectStyles(t,e){this.chartContext.injectStyles(t,e)}createElement(t){return this.chartContext.createElement(t)}querySelector(t){return this.chartContext.querySelector(t)}addEventListener(t,e,n){this.chartContext.addEventListener(t,e,n)}removeEventListener(t,e,n){this.chartContext.removeEventListener(t,e,n)}dispatchEvent(t){this.chartContext.dispatchEvent(t)}destroy(){this.chartContext.destroy()}getInstanceId(){return this.chartContext.getInstanceId()}}class i{constructor(t,e="apex"){this.canvas=t,this.prefix=e}getSvgString(){const t=this.canvas.node.cloneNode(!0),e=this.canvas.node.viewBox.baseVal;e.width&&e.height&&(t.setAttribute("width",String(e.width)),t.setAttribute("height",String(e.height)));return(new XMLSerializer).serializeToString(t)}svgUrl(){const t=this.getSvgString(),e=new Blob([t],{type:"image/svg+xml;charset=utf-8"});return URL.createObjectURL(e)}triggerDownload(t,e){const n=document.createElement("a");n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}exportToSVG(){this.triggerDownload(this.svgUrl(),`${this.prefix}-${(new Date).getTime()}.svg`)}}const s="http://www.w3.org/2000/svg";let r=0;class a{constructor(t){this.node=t}attr(t,e){if("string"==typeof t)return void 0!==e?(this.node.setAttribute(t,String(e)),this):this.node.getAttribute(t);for(const[e,n]of Object.entries(t))null!=n&&this.node.setAttribute(e,String(n));return this}id(t){return this.node.setAttribute("id",t),this}fill(t){if(!t)return this;if(t instanceof SVGElement){const e=t.id;this.node.setAttribute("fill",`url(#${e})`)}else this.node.setAttribute("fill",t);return this}stroke({color:t,width:e,dasharray:n}={}){return void 0!==t&&this.node.setAttribute("stroke",t),void 0!==e&&this.node.setAttribute("stroke-width",String(e)),void 0!==n&&this.node.setAttribute("stroke-dasharray",String(n)),this}opacity(t){return this.node.setAttribute("opacity",String(t)),this}add(t){const e=t instanceof a?t.node:t;return this.node.appendChild(e),this}on(t,e){return this.node.addEventListener(t,e),this}findOne(t){const e=this.node.querySelector(t);return e?new a(e):null}first(){const t=this.node.firstElementChild;return t?new a(t):null}}class d extends a{constructor(t){super(document.createElementNS(s,"g")),t&&this.attr(t)}}class l extends a{constructor(){super(document.createElementNS(s,"rect"))}}class c extends a{constructor(t){super(document.createElementNS(s,"path")),t&&this.attr(t)}}class h extends a{constructor(){super(document.createElementNS(s,"text"))}font({fill:t,size:e}){return void 0!==t&&this.node.setAttribute("fill",t),void 0!==e&&this.node.setAttribute("font-size",String(e)),this}tspan(t){const e=document.createElementNS(s,"tspan");return e.textContent=t,this.node.appendChild(e),this}move(t,e){return this.node.setAttribute("x",String(t)),this.node.setAttribute("y",String(e)),this}}class u{constructor(t){this.gradient=t}stop(t,e){const n=document.createElementNS(s,"stop");n.setAttribute("offset",String(t)),n.setAttribute("stop-color",e??"transparent"),this.gradient.appendChild(n)}}function p(t,e){t.setAttribute("viewBox",`${e.x} ${e.y} ${e.w} ${e.h}`)}class g{constructor(t){this._defs=null,this._panZoomState=null,this.node=t}addTo(t){return t.appendChild(this.node),this}size(t,e){return this.node.setAttribute("width",String(t)),this.node.setAttribute("height",String(e)),this}viewbox(t){if(void 0===t){const t=this.node.viewBox.baseVal;return{x:t.x,y:t.y,width:t.width,height:t.height}}if(this.node.setAttribute("viewBox",t),this._panZoomState){const t=this.node.viewBox.baseVal;this._panZoomState.vb={x:t.x,y:t.y,w:t.width,h:t.height}}return this}attr(t){for(const[e,n]of Object.entries(t))null!=n&&this.node.setAttribute(e,String(n));return this}add(t){return this.node.appendChild(t instanceof a?t.node:t),this}clear(){const t=this._defs;return this.node.innerHTML="",t&&(this.node.appendChild(t),this._defs=t),this}svg(){return this.node.innerHTML}gradient(t,e){this._defs||(this._defs=document.createElementNS(s,"defs"),this.node.insertBefore(this._defs,this.node.firstChild));const n=document.createElementNS(s,"linearGradient"),o="apx-grad-"+ ++r;return n.setAttribute("id",o),n.setAttribute("x1","0%"),n.setAttribute("y1","0%"),n.setAttribute("x2","100%"),n.setAttribute("y2","0%"),e(new u(n)),this._defs.appendChild(n),n}panZoom(t={}){return this._panZoomState=function(t,e){const n=function(t){const e=t.viewBox.baseVal;return{x:e.x,y:e.y,w:e.width,h:e.height}}(t),o={zoomMin:e.zoomMin??.1,currentZoom:1,baseVb:{...n},vb:{...n}};t.addEventListener("wheel",(e=>{if(!e.ctrlKey&&!e.metaKey)return;e.preventDefault();const n=1+Math.max(-.12,Math.min(.12,.0025*e.deltaY)),i=o.currentZoom/n;if(i<o.zoomMin)return;const s=t.getBoundingClientRect(),r=(e.clientX-s.left)/s.width,a=(e.clientY-s.top)/s.height,{vb:d}=o,l=d.w*n,c=d.h*n,h=d.x+r*(d.w-l),u=d.y+a*(d.h-c);o.vb={x:h,y:u,w:l,h:c},o.currentZoom=i,p(t,o.vb)}),{passive:!1});let i=!1,s=!1,r=-1,a=0,d=0;t.addEventListener("pointerdown",(t=>{0===t.button&&(t.preventDefault(),i=!0,s=!1,r=t.pointerId,a=t.clientX,d=t.clientY)})),t.addEventListener("pointermove",(e=>{if(!i||e.pointerId!==r)return;if(!s){const n=e.clientX-a,o=e.clientY-d;if(Math.abs(n)<4&&Math.abs(o)<4)return;s=!0,t.setPointerCapture(e.pointerId),t.style.cursor="grabbing",t.style.userSelect="none"}const n=t.getBoundingClientRect(),l=o.vb.w/n.width,c=o.vb.h/n.height,h=(e.clientX-a)*l,u=(e.clientY-d)*c;o.vb={x:o.vb.x-h,y:o.vb.y-u,w:o.vb.w,h:o.vb.h},p(t,o.vb),a=e.clientX,d=e.clientY}));const l=e=>{i&&e.pointerId===r&&(s&&(t.releasePointerCapture(e.pointerId),t.style.cursor="",t.style.userSelect=""),i=!1,s=!1,r=-1)};return t.addEventListener("pointerup",l),t.addEventListener("pointercancel",l),o}(this.node,t),this}resetPanZoomBase(){if(!this._panZoomState)return;const t=this.node.viewBox.baseVal;this._panZoomState.baseVb={x:t.x,y:t.y,w:t.width,h:t.height},this._panZoomState.vb={x:t.x,y:t.y,w:t.width,h:t.height},this._panZoomState.currentZoom=1}zoom(t){var e;if(void 0===t)return(null==(e=this._panZoomState)?void 0:e.currentZoom)??1;if(!this._panZoomState)return this;const n=this._panZoomState;if(t<n.zoomMin)return this;const o=n.currentZoom/t,{vb:i}=n,s=i.w*o,r=i.h*o,a=i.x+.5*(i.w-s),d=i.y+.5*(i.h-r);return n.vb={x:a,y:d,w:s,h:r},n.currentZoom=t,p(this.node,n.vb),this}}function f({borderColor:t="#caced0",color:e="#97cbe6",height:n=0,opacity:o=1,radius:i=0,width:s=0,x:r=0,y:a=0}={}){const d=new l;return d.attr({height:n,opacity:o,rx:i,ry:i,width:s,x:r,y:a}),d.fill(e),d.stroke({color:t,width:1}),d}function v(t="",{fontColor:e="#666767",pointerEvents:n="all",textAnchor:o="start",x:i,y:s}={}){const r=new h;return r.font({fill:e}),r.tspan(t),void 0!==i&&void 0!==s&&r.move(i,s),r.attr({"pointer-events":n,"text-anchor":o}),r}function m(t,e,n,o){const i=new d;return i.attr({"data-parent":o,"data-self":n,transform:void 0!==t&&void 0!==e?`translate(${t}, ${e})`:void 0}),i}function y(t,{edgeColor:e,id:n="",opacity:o=1}={}){const i=new c({d:t});return i.id(n),i.fill(e).opacity(o),i}const b={export:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>\n <polyline points="7 10 12 15 17 10"/>\n <line x1="12" y1="15" x2="12" y2="3"/>\n </svg>',"zoom-in":'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <circle cx="11" cy="11" r="8"/>\n <path d="m21 21-4.35-4.35"/>\n <line x1="11" y1="8" x2="11" y2="14"/>\n <line x1="8" y1="11" x2="14" y2="11"/>\n </svg>',"zoom-out":'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <circle cx="11" cy="11" r="8"/>\n <path d="m21 21-4.35-4.35"/>\n <line x1="8" y1="11" x2="14" y2="11"/>\n </svg>',"fit-screen":'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">\n <path d="M8 3H5a2 2 0 0 0-2 2v3"/>\n <path d="M21 8V5a2 2 0 0 0-2-2h-3"/>\n <path d="M3 16v3a2 2 0 0 0 2 2h3"/>\n <path d="M16 21h3a2 2 0 0 0 2-2v-3"/>\n </svg>'};class x{constructor(t,e){this.element=t,t&&(this.chartContext=e||new n(t),this.injectStyles())}injectStyles(){const t=`toolbar-styles-${this.chartContext.getInstanceId()}`;this.chartContext.injectStyles("\n #toolbar {\n display: flex;\n gap: 2px;\n position: absolute;\n /* Logical inset: stays on the right in LTR, mirrors to the left in RTL\n (so it never collides with RTL-flipped chrome such as the search box). */\n inset-inline-end: 12px;\n top: 12px;\n z-index: 100;\n user-select: none;\n background: var(--toolbar-bg-color, rgba(255, 255, 255, 0.92));\n border: 1px solid var(--toolbar-border-color, rgba(0, 0, 0, 0.08));\n border-radius: 10px;\n padding: 4px;\n box-shadow:\n 0 1px 3px rgba(0, 0, 0, 0.08),\n 0 4px 12px rgba(0, 0, 0, 0.06);\n backdrop-filter: blur(8px);\n -webkit-backdrop-filter: blur(8px);\n }\n\n .toolbar-item {\n align-items: center;\n background-color: transparent;\n border: none;\n border-radius: 6px;\n color: var(--toolbar-icon-color, #444);\n cursor: pointer;\n display: flex;\n height: 30px;\n justify-content: center;\n width: 30px;\n transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;\n position: relative;\n flex-shrink: 0;\n }\n\n .toolbar-item:hover {\n background-color: var(--toolbar-hover-bg-color, rgba(0, 0, 0, 0.06));\n color: var(--toolbar-icon-hover-color, #111);\n transform: translateY(-1px);\n box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);\n }\n\n .toolbar-item:active {\n transform: translateY(0);\n box-shadow: none;\n background-color: var(--toolbar-active-bg-color, rgba(0, 0, 0, 0.1));\n }\n\n .toolbar-item:focus-visible {\n outline: none;\n box-shadow: 0 0 0 2px var(--button-bg-color, #0066cc);\n }\n\n .toolbar-item svg {\n width: 15px;\n height: 15px;\n pointer-events: none;\n flex-shrink: 0;\n }\n\n .toolbar-item[disabled] {\n opacity: 0.4;\n cursor: not-allowed;\n pointer-events: none;\n }\n\n /* Tooltip */\n .toolbar-item::after {\n content: attr(data-tooltip);\n position: absolute;\n bottom: calc(100% + 8px);\n left: 50%;\n transform: translateX(-50%);\n background: var(--tooltip-bg-color, rgba(30, 30, 30, 0.92));\n color: var(--tooltip-text-color, #fff);\n padding: 5px 9px;\n border-radius: 6px;\n font-size: 11.5px;\n font-weight: 500;\n white-space: nowrap;\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s ease;\n z-index: 1000;\n letter-spacing: 0.01em;\n }\n\n .toolbar-item::before {\n content: '';\n position: absolute;\n bottom: calc(100% + 3px);\n left: 50%;\n transform: translateX(-50%);\n border: 4px solid transparent;\n border-top-color: var(--tooltip-bg-color, rgba(30, 30, 30, 0.92));\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s ease;\n z-index: 1000;\n }\n\n .toolbar-item:hover::after,\n .toolbar-item:hover::before {\n opacity: 1;\n }\n\n /* Shadow DOM specific adjustments */\n :host #toolbar {\n display: flex;\n gap: 2px;\n position: absolute;\n inset-inline-end: 12px;\n top: 12px;\n z-index: 100;\n }\n",t)}createToolbarItem(t,e,n){const o=this.chartContext.createElement("div");return o.id=t,o.className="toolbar-item",o.setAttribute("role","button"),o.setAttribute("tabindex","0"),o.innerHTML=e,n&&(o.setAttribute("data-tooltip",n),o.setAttribute("aria-label",n)),o.addEventListener("keydown",(t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),o.click())})),o}render({enableExport:t=!1,enableFitscreen:n=!1,enableZoom:o=!1,onExport:i=e,onFitscreen:s=e,onZoom:r=e}){if(!this.element)return;const a=this.chartContext.querySelector("#toolbar");null==a||a.remove();const d=this.chartContext.createElement("div");if(d.id="toolbar",d.setAttribute("role","toolbar"),d.setAttribute("aria-label","Chart controls"),t){const t=this.createToolbarItem("export",b.export,"Export chart");t.addEventListener("click",(()=>{i()})),d.append(t)}if(o){const t=this.createToolbarItem("zoom-in",b["zoom-in"],"Zoom in"),e=this.createToolbarItem("zoom-out",b["zoom-out"],"Zoom out");t.addEventListener("click",(()=>{r(.1)})),e.addEventListener("click",(()=>{r(-.1)})),d.append(t,e)}if(n){const t=this.createToolbarItem("fit-screen",b["fit-screen"],"Fit to screen");t.addEventListener("click",(()=>{s()})),d.append(t)}this.element.append(d)}destroy(){const t=this.chartContext.querySelector("#toolbar");null==t||t.remove()}}const w="aria-hidden",E=(t,e="apex-tooltip-container")=>{let n=t.getElementById(e);if(!n){n=t.createElement("div"),n.id=e,n.setAttribute("role","tooltip"),n.setAttribute(w,"true");t.getAppendContainer().appendChild(n),t.trackTooltip(n)}return n},A=(t,e="",n,o="",i=!1)=>{const s=t.getElementById(e);if(!s)return E(t,e),A(t,e,n,o,i);if(n&&o){const e=o.includes("tooltip-content"),r=n.match(/background-color:\s*([^;]+);?/),a=n.match(/color:\s*([^;]+);?/);if(e||!r)s.innerHTML=o;else{const t=r[1],e=a?a[1]:"white";s.innerHTML=`<div class="tooltip-content" style="background-color: ${t}; color: ${e};">${o}</div>`}const d=n+"; display: block !important; visibility: visible !important; opacity: 1 !important;";if(s.setAttribute("style",d),s.classList.add("visible"),s.setAttribute(w,"false"),i&&"undefined"!=typeof window){const e=s.offsetWidth,n=parseFloat(s.style.left),o=t.getChartBounds();if(e>0&&!Number.isNaN(n)&&o.width>0){const t=window.scrollX||document.documentElement.scrollLeft||0,i=o.left+t,r=((t,e,n,o,i=8)=>{if(t+e<=n-i)return t;const s=t-e;return s<o+i?Math.max(o+i,n-e-i):s})(n,e,o.right+t,i);r!==n&&(s.style.left=`${r}px`)}}}else s.removeAttribute("style"),s.classList.remove("visible"),s.setAttribute(w,"true"),s.innerHTML=""},C=(t={})=>{const e=[];for(const o in t){const i=`${n=o,n.replace(/([A-Z])/g,(t=>`-${t.toLowerCase()}`))}: ${t[o]};`;e.push(i)}var n;return e.join(" ")},S=({bgColor:t,borderColor:e,fontColor:n,fontFamily:o,fontSize:i,fontWeight:s,maxWidth:r,padding:a,placement:d="top",x:l,y:c})=>{const h=["position: absolute;","z-index: 1000;","pointer-events: none;"];return h.push("box-sizing: border-box;"),h.push("word-wrap: break-word;"),h.push("overflow-wrap: break-word;"),h.push(`left: ${l}px;`),h.push(`top: ${c}px;`),h.push(`data-placement: ${d};`),r&&(h.push(`width: ${r}px;`),h.push(`max-width: ${r}px;`)),e&&h.push(`border: 1px solid ${e};`),n&&h.push(`color: ${n};`),o&&h.push(`font-family: ${o};`),s&&h.push(`font-weight: ${s};`),i&&h.push(`font-size: ${i};`),t&&(h.push(`background-color: ${t};`),h.push("border-radius: 6px;"),h.push("box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);")),void 0!==a&&h.push(`padding: ${a}px;`),h.join(" ")},k=globalThis.console;function M(t,...e){k.error(t,...e)}function $(t){k.warn(t)}const T="APEX-",L=new Date("2027-07-31T00:00:00Z"),N="__apex_license_v1__";function F(){const t=globalThis;let e=t[N];return e||(e={key:null,listeners:new Set,result:null},t[N]=e),e}const R=class{static get licenseKey(){return F().key}static set licenseKey(t){F().key=t}static get listeners(){return F().listeners}static get validationResult(){return F().result}static set validationResult(t){F().result=t}static getKey(){return this.licenseKey}static getLicenseStatus(){return this.licenseKey?(this.validationResult=this.validateKey(this.licenseKey),this.validationResult):{expired:!1,signatureVerified:!1,valid:!1}}static isKeyValid(t){return!!t&&this.validateKey(t).valid}static isLicenseValid(){return this.getLicenseStatus().valid}static onChange(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}static setLicense(t){var e;if(!t)return this.licenseKey=null,void this.publish({expired:!1,signatureVerified:!1,valid:!1});const n=this.validateKey(t);n.valid||t===this.licenseKey||!(null==(e=this.validationResult)?void 0:e.valid)?(this.licenseKey=t,this.publish(n),n.valid||M(`[Apex] ${n.message}`)):$(`[Apex] Ignoring license key: ${n.message??"it is not valid"} A valid license is already active on this page.`)}static validateKey(t){const e=this.parseKey(t),n=this.validateStructure(t,e);if(!n.valid||!(null==e?void 0:e.signature))return n;const o=this.verdicts.get(t);return!1===o?{data:e.data,expired:!1,message:"Invalid license key. The license signature does not verify.",signatureVerified:!0,valid:!1}:(void 0===o&&this.verifySignature(t,e,n),{...n,signatureVerified:!0===o})}static _resetSignatureState(){this.verdicts.clear(),this.verifying.clear(),this.warnedUnverifiable=!1,this.epoch++}static base64ToBytes(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),n=e.padEnd(4*Math.ceil(e.length/4),"="),o=globalThis.atob;if("function"!=typeof o)throw new Error("no base64 decoder available");const i=o(n),s=new Uint8Array(i.length);for(let t=0;t<i.length;t++)s[t]=i.charCodeAt(t);return s}static canonicalPayload(t){const e=t.domains&&t.domains.length>0?t.domains.join(","):"";return`v1|${t.issueDate}|${t.expiryDate}|${t.plan}|${e}`}static notify(t){for(const e of this.listeners)try{e(t)}catch{}}static parseKey(t){if("string"!=typeof t||!t.startsWith(T))return null;const e=t.slice(5);if(!e)return null;try{const t=(new TextDecoder).decode(this.base64ToBytes(e)),n=JSON.parse(t);return n.issueDate&&n.expiryDate&&n.plan?{data:{domains:Array.isArray(n.domains)?n.domains:void 0,expiryDate:n.expiryDate,issueDate:n.issueDate,plan:n.plan,valid:!0},signature:"string"==typeof n.sig&&n.sig?n.sig:null}:null}catch{return null}}static publish(t){this.validationResult=t,this.notify(t)}static validateStructure(t,e){const n=t=>({expired:!1,message:t,signatureVerified:!1,valid:!1});if("string"!=typeof t||!t.startsWith(T))return n('Invalid license key format. License key must start with "APEX-".');if(!e)return n("Invalid license key. Unable to decode license data.");const{data:o,signature:i}=e;if(!i&&new Date>=L)return n("This license key is in the old unsigned format, which is no longer accepted. Please request a replacement key.");if(new Date(o.expiryDate)<new Date)return{data:o,expired:!0,message:`License expired on ${o.expiryDate}. Please renew your license.`,signatureVerified:!1,valid:!1};if(o.domains&&o.domains.length>0){const t="undefined"==typeof location?"":location.hostname;if(!o.domains.some((e=>t===e||t.endsWith(`.${e}`))))return{data:o,expired:!1,message:`License is not valid for this domain (${t}). Allowed domains: ${o.domains.join(", ")}.`,signatureVerified:!1,valid:!1}}return{data:o,expired:!1,signatureVerified:!1,valid:!0}}static async verifySignature(t,e,n){var o;if(this.verifying.has(t)||this.verdicts.has(t))return;this.verifying.add(t);const i=this.epoch,s=null==(o=globalThis.crypto)?void 0:o.subtle;if(!s||0===this.publicKeysSpki.length)return this.verifying.delete(t),void(this.warnedUnverifiable||(this.warnedUnverifiable=!0,$(s?"[Apex] No license signing key is configured in this build, so license signatures cannot be verified.":"[Apex] Web Crypto is unavailable (a secure context is required), so the license signature cannot be verified.")));const r=(new TextEncoder).encode(this.canonicalPayload(e.data));let a=!1;for(const t of this.publicKeysSpki){try{const n=await s.importKey("spki",this.base64ToBytes(t),{name:"ECDSA",namedCurve:"P-256"},!1,["verify"]);a=await s.verify({hash:"SHA-256",name:"ECDSA"},n,this.base64ToBytes(e.signature),r)}catch{a=!1}if(a)break}if(this.verifying.delete(t),this.epoch!==i)return;if(this.verdicts.set(t,a),a){const e={...n,signatureVerified:!0};return void(this.licenseKey===t?this.publish(e):this.notify(e))}const d="Invalid license key. The license signature does not verify.",l={data:e.data,expired:!1,message:d,signatureVerified:!0,valid:!1};this.licenseKey===t?this.publish(l):this.notify(l),M(`[Apex] ${d}`)}};R.publicKeysSpki=["MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEQIaK9UMD6n0oR/FIy8QdL0uSzKMQlf1BB+tOrji4/WuHsyRNxeDhVykoSsNURozMi1xhmqWvBH1L//xIfugTPA=="],R.verdicts=new Map,R.verifying=new Set,R.warnedUnverifiable=!1,R.epoch=0;let B=R;const _=class{static applyStyles(t){Object.assign(t.style,this.CRITICAL_STYLES,{backgroundImage:this.createWatermarkPattern(),backgroundRepeat:"repeat"})}static node(t){return t?t.querySelector(`[${this.WATERMARK_ATTR}]`):null}static add(t,e){return t&&"undefined"!=typeof document?(this.setManaged(t,e),this.paint(t)):null}static exists(t){return!!this.node(t)}static remove(t,e){t&&(this.setManaged(t,e),this.erase(t))}static untrack(t){this.managed.delete(t)}static createWatermarkPattern(){const t=this.WATERMARK_TEXT;return`url("data:image/svg+xml,${encodeURIComponent(`\n <svg xmlns="http://www.w3.org/2000/svg" width="300" height="200">\n <text\n x="50%"\n y="50%"\n dominant-baseline="middle"\n text-anchor="middle"\n font-family="-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Arial, sans-serif"\n font-size="18"\n font-weight="600"\n fill="rgba(134, 134, 134, 0.1)"\n transform="rotate(-35, 100, 60)"\n >${t}</text>\n </svg>\n `.trim())}")`}static erase(t){var e;null==(e=this.node(t))||e.remove()}static paint(t){let e=this.node(t);return e||(e=document.createElement("div"),e.setAttribute(this.WATERMARK_ATTR,""),t.appendChild(e)),this.applyStyles(e),"function"==typeof getComputedStyle&&"static"===getComputedStyle(t).position&&(t.style.position="relative"),e}static reconcile(){const t=B.isLicenseValid();for(const e of this.managed)e.isConnected?t?this.erase(e):this.paint(e):this.managed.delete(e)}static setManaged(t,e){!1!==(null==e?void 0:e.manage)?this.track(t):this.managed.delete(t)}static track(t){this.managed.add(t),this.subscribed||(this.subscribed=!0,B.onChange((()=>{this.reconcile()})))}};_.WATERMARK_ATTR="data-apexcharts-watermark",_.WATERMARK_TEXT="APEXCHARTS",_.ATTR="data-apexcharts-watermark",_.CRITICAL_STYLES={bottom:"0",display:"block",left:"0",msUserSelect:"none",opacity:"1",pointerEvents:"none",position:"absolute",right:"0",top:"0",userSelect:"none",visibility:"visible",webkitUserSelect:"none",zIndex:"10000"},_.managed=new Set,_.subscribed=!1;let I=_;function O(t,e){t&&("ltr"===e?t.removeAttribute("dir"):t.setAttribute("dir",e))}const D=.05,G=.05,P=1/45,j={velocity:.01,displacement:.001};function z(t,e,n,o){const i={value:t,velocity:0,target:t,stiffness:e,damping:n};return void 0!==(null==o?void 0:o.velocity)&&(i.restVelocity=o.velocity),void 0!==(null==o?void 0:o.displacement)&&(i.restDisplacement=o.displacement),i}function q(t,e){if(e<=0)return W(t);let n=e;for(;n>0;){const e=Math.min(n,P),o=-t.stiffness*(t.value-t.target)-t.damping*t.velocity;t.velocity+=o*e,t.value+=t.velocity*e,n-=e}return!!W(t)&&(t.value=t.target,t.velocity=0,!0)}function H(t,e){t.value=e,t.target=e,t.velocity=0}function W(t){const e=t.restVelocity??D,n=t.restDisplacement??G;return Math.abs(t.velocity)<e&&Math.abs(t.value-t.target)<n}const V={crisp:[210,26],gentle:[120,20],snappy:[320,30]};class Y{constructor(t={}){this.mql=null,this.handler=null,this.ownsClass=!1,this.element=t.element??null,this.className=t.className??"",this.onChange=t.onChange,"undefined"!=typeof window&&"function"==typeof window.matchMedia&&(this.mql=window.matchMedia("(prefers-reduced-motion: reduce)"),this.applyClass(this.mql.matches),this.handler=t=>{var e;this.applyClass(t.matches),null==(e=this.onChange)||e.call(this,t.matches)},"function"==typeof this.mql.addEventListener?this.mql.addEventListener("change",this.handler):"function"==typeof this.mql.addListener&&this.mql.addListener(this.handler))}get matches(){var t;return!!(null==(t=this.mql)?void 0:t.matches)||!(!this.className||!this.element)&&this.element.classList.contains(this.className)}dispose(){this.mql&&this.handler&&("function"==typeof this.mql.removeEventListener?this.mql.removeEventListener("change",this.handler):"function"==typeof this.mql.removeListener&&this.mql.removeListener(this.handler),this.mql=null,this.handler=null)}applyClass(t){this.element&&this.className&&(t?this.element.classList.contains(this.className)||(this.element.classList.add(this.className),this.ownsClass=!0):this.ownsClass&&(this.element.classList.remove(this.className),this.ownsClass=!1))}}class K{constructor(t={}){this.objects=new Map,this.frameHandle=null,this.lastTime=null,this.disposed=!1,this.opts=t;const[e,n]=t.spring??(V["crisp"]??V.crisp);this.stiffness=e,this.damping=n,this.rest=t.rest;const o=t.clock??{};this.now=o.now??(()=>"undefined"!=typeof performance?performance.now():Date.now()),this.raf=o.raf??(t=>requestAnimationFrame(t)),this.caf=o.caf??(t=>cancelAnimationFrame(t)),this.reducedMotionOverride=t.reducedMotion,this.reducedMotionWatcher=void 0===t.reducedMotion?new Y({element:t.element,className:t.reducedMotionClass,onChange:t=>{t&&null!==this.frameHandle&&this.snapAll()}}):null}get reducedMotion(){var t;return this.reducedMotionOverride??(null==(t=this.reducedMotionWatcher)?void 0:t.matches)??!1}has(t){return this.objects.has(t)}get size(){return this.objects.size}ids(){return this.objects.keys()}dataOf(t){var e;return null==(e=this.objects.get(t))?void 0:e.data}valuesOf(t){const e=this.objects.get(t);return e?U(e):void 0}channelValue(t,e){var n,o;return null==(o=null==(n=this.objects.get(t))?void 0:n.channels.get(e))?void 0:o.value}targetOf(t,e){var n,o;return null==(o=null==(n=this.objects.get(t))?void 0:n.channels.get(e))?void 0:o.target}add(t,e,n,o={}){var i;const s=this.objects.get(t);if(s)return s.data=n,s.delayMs=o.delayMs??0,s.paused=!1,void(s.settled=!1);const[r,a]=o.spring??[this.stiffness,this.damping],d=o.rest??this.rest,l=new Map;for(const t of Object.keys(e))l.set(t,z(e[t],r,a,(null==(i=o.channelRest)?void 0:i[t])??d));this.objects.set(t,{id:t,data:n,channels:l,delayMs:o.delayMs??0,pauseOnSettle:o.pauseOnSettle??!1,paused:!1,settled:!1})}setData(t,e){const n=this.objects.get(t);n&&(n.data=e)}retarget(t,e,n={}){const o=this.objects.get(t);if(!o)return;o.paused=!1,o.settled=!1,void 0!==n.delayMs&&(o.delayMs=n.delayMs);const i=this.reducedMotion;for(const t of Object.keys(e)){const n=o.channels.get(t);n&&(i?(H(n,e[t]),o.delayMs=0):n.target=e[t])}}snap(t,e){const n=this.objects.get(t);if(n){for(const t of Object.keys(e)){const o=n.channels.get(t);o&&H(o,e[t])}n.delayMs=0}}pause(t){const e=this.objects.get(t);e&&(e.paused=!0)}remove(t){this.objects.delete(t)}clear(){this.stop(),this.objects.clear()}atRest(){for(const t of this.objects.values())if(!t.paused){if(t.delayMs>0)return!1;for(const e of t.channels.values())if(e.value!==e.target||0!==e.velocity)return!1}return!0}writeAll(t){var e,n;for(const e of this.objects.values())e.paused||t&&!t(e.id,e.data)||this.write(e);null==(n=(e=this.opts).onFrame)||n.call(e)}step(t){var e,n;let o=!0;for(const e of Array.from(this.objects.values())){if(e.paused||!this.objects.has(e.id))continue;if(e.delayMs>0){e.delayMs-=1e3*t,o=!1;continue}let n=!0;for(const o of e.channels.values())q(o,t)||(n=!1);this.write(e),n?e.settled||(e.settled=!0,this.settle(e)||e.pauseOnSettle&&(e.paused=!0)):(e.settled=!1,o=!1)}return null==(n=(e=this.opts).onFrame)||n.call(e),o}start(){if(this.disposed)return;if(null!==this.frameHandle)return;this.lastTime=null;const t=e=>{if(this.frameHandle=null,this.disposed)return;if(this.reducedMotion)return void this.snapAll();const n=this.lastTime??e;this.lastTime=e;const o=Math.min(Math.max(0,(e-n)/1e3),.05);this.step(o)?this.lastTime=null:this.frameHandle=this.raf(t)};this.frameHandle=this.raf(t)}settleNow(){this.disposed||this.snapAll()}stop(){null!==this.frameHandle&&(this.caf(this.frameHandle),this.frameHandle=null),this.lastTime=null}get running(){return null!==this.frameHandle}dispose(){var t;this.disposed||(this.disposed=!0,this.stop(),this.objects.clear(),null==(t=this.reducedMotionWatcher)||t.dispose())}get isDisposed(){return this.disposed}snapAll(){var t,e;this.stop();for(const t of Array.from(this.objects.values()))if(!t.paused&&this.objects.has(t.id)){for(const e of t.channels.values())H(e,e.target);t.delayMs=0,this.write(t),t.settled||(t.settled=!0,this.settle(t)||t.pauseOnSettle&&(t.paused=!0))}null==(e=(t=this.opts).onFrame)||e.call(t)}settle(t){var e,n;return!0===(null==(n=(e=this.opts).onSettle)?void 0:n.call(e,t.id,t.data))&&(this.objects.delete(t.id),!0)}write(t){var e,n;null==(n=(e=this.opts).write)||n.call(e,t.id,U(t),t.data)}}function U(t){const e={};for(const[n,o]of t.channels)e[n]=o.value;return e}const X="__apexcharts_themes__";function Z(t){return t?function(){const t=globalThis,e=t[X];if(e)return e;const n={};return t[X]=n,n}()[t]??null:null}const Q={accent:"--apx-accent",fore:"--apx-fore",grid:"--apx-grid",surface:"--apx-surface"},J="--apx-series-",tt=24;function et(t,e){var n;const o=function(t){if(!t||"function"!=typeof getComputedStyle)return{};let e;try{e=getComputedStyle(t)}catch{return{}}if(!e||"function"!=typeof e.getPropertyValue)return{};const n=t=>{const n=e.getPropertyValue(t);return n?String(n).trim():""},o={};for(const[t,e]of Object.entries(Q)){const i=n(e);i&&(o[t]=i)}const i=[];for(let t=1;t<=tt;t++){const e=n(`${J}${t}`);if(!e)break;i.push(e)}return i.length&&(o.series=i),o}(t),i=e?null==(n=Z(e))?void 0:n.tokens:void 0;return i?{...i,...o}:o}function nt(t,e){let n=null;for(let o=0;o<t.length;++o)if(e(t[o])){n=o;break}return n}function ot(t,e){if(0===t.length)return;let n,o=0;for(let i=t.length-1;i>=0;--i)n=(t[i].dy??0)/2,(t[i][e]??0)-n<o&&(t[i][e]=Math.min(t[i].Rmax??0,o+n)),o=(t[i][e]??0)+n;let i=(t[0].Rmax??0)+(t[0].dy??0)/2;for(let o=0;o<t.length;++o)n=(t[o].dy??0)/2,(t[o][e]??0)+n>i&&(t[o][e]=Math.max(n,i-n)),i=(t[o][e]??0)-n}function it(t){const e=t.edgeGap||0;return function(n){!function(t,e,n){t.nodes().forEach((o=>{const i=t.node(o),s=st(t,i.outgoing||[],"outgoing"),r=st(t,i.incoming||[],"incoming"),a=s.length,d=r.length,l=s.reduce(((e,n)=>e+(t.edge(n).dy??0)),0),c=r.reduce(((e,n)=>e+(t.edge(n).dy??0)),0),h=l+Math.max(0,a-1)*n,u=c+Math.max(0,d-1)*n;let p=((i.dy??0)-h)/2,g=((i.dy??0)-u)/2;p=Math.max(0,p),g=Math.max(0,g),s.forEach(((o,s)=>{const r=t.edge(o);r.x0=(i.x??0)+(e.nodeWidth??0)/2,r.y0=(i.y??0)+p+(r.dy??0)/2,r.d0=i.direction||"r",p+=r.dy??0,s<a-1&&(p+=n)})),r.forEach(((o,s)=>{const r=t.edge(o);r.x1=(i.x??0)-(e.nodeWidth??0)/2,r.y1=(i.y??0)+g+(r.dy??0)/2,r.d1=i.direction||"r",g+=r.dy??0,s<d-1&&(g+=n)}))}))}(n,t,e),function(t){t.nodes().forEach((e=>{const n=t.node(e),o=(n.outgoing||[]).map((e=>t.edge(e))),i=(n.incoming||[]).map((e=>t.edge(e)));o.sort(((t,e)=>(t.y0??0)-(e.y0??0))),i.sort(((t,e)=>(t.y1??0)-(e.y1??0))),rt(o,"r0"),rt(i,"r1")}))}(n);const o=[];return n.edges().forEach((t=>{const e=n.edge(t);e.id=`${t.v}-${t.w}-${t.name}`,o.push(e)})),o}}function st(t,e,n){return e.slice().sort(((e,o)=>{let i,s;if("outgoing"===n){const n=t.node(e.w),r=t.node(o.w);i=(null==n?void 0:n.y)??0,s=(null==r?void 0:r.y)??0}else{const n=t.node(e.v),r=t.node(o.v);i=(null==n?void 0:n.y)??0,s=(null==r?void 0:r.y)??0}if(Math.abs(i-s)>.001)return i-s;if(e.name!==o.name){if("number"==typeof e.name&&"number"==typeof o.name)return e.name-o.name;if("string"==typeof e.name&&"string"==typeof o.name)return e.name.localeCompare(o.name)}return 0}))}function rt(t,e){t.forEach((t=>{t.Rmax=function(t){const e=(t.x1??0)-(t.x0??0),n=(t.y1??0)-(t.y0??0);return t.d0!==t.d1?Math.abs(n)/2.1:0!==n?(e*e+n*n)/Math.abs(4*n):1/0}(t),t[e]=Math.max((t.dy??0)/2,t.d0===t.d1?.6*(t.Rmax??0):5+(t.dy??0)/2)}));let n=nt(t,"r0"===e?t=>(t.y1??0)>(t.y0??0):t=>(t.y0??0)>(t.y1??0));if(null===n&&(n=t.length),ot(t.slice(n),e),n>0){const o=[];for(let e=n-1;e>=0;e--)o.push(t[e]);ot(o,e)}}function at(t,e,n,o,i){if(0===o.length)return;const s=o.map((n=>{const o=`__${e.v}_${e.w}_${n}`;return t.setNode(o,{data:null,direction:i,dummy:!0,rank:n}),o})),r=[e.v,...s,e.w];r.forEach(((o,i)=>{i+1<r.length&&t.setEdge(r[i],r[i+1],{data:t.edge(e).data,origEdge:e,origLabel:n,source:t.node(e.v),target:t.node(e.w),value:t.edge(e).value},e.name)})),t.removeEdge(e)}function dt(t,e,n){return function(t,e,n){let o,i;e.length>n.length?(o=e,i=n):(o=n,i=e);const s=i.length,r=[];o.forEach((e=>{i.forEach(((n,o)=>{(t.hasEdge(e,n)||t.hasEdge(n,e))&&r.push(o)}))}));let a=1;for(;a<s;)a*=2;const d=2*a-1;a-=1;const l=new Array(d).fill(0);let c=0;return r.forEach((t=>{let e=t+a;for(l[e]++;e>0;)e%2&&(c+=l[e+1]),e=Math.floor((e-1)/2),l[e]++})),c}(t,e,n)}function lt(t){const e=[];let n=t.nodes().filter((e=>0===t.node(e).rank)).concat(t.sources());return 0===n.length&&(n=t.nodes().slice(0,1)),function(t,e){const n=new Set,o=[];function i(e){if(!n.has(e)){n.add(e),o.push(e);for(const n of t.successors(e))i(n)}}for(const t of e)i(t);return o}(t,n).forEach((n=>{const o=t.node(n).rank;if(void 0!==o){for(;o>=e.length;)e.push([]);e[o].push(n)}})),e}function ct(t,e){let n=!0;for(;n;){n=!1;for(let o=0;o<e.length;++o)for(let i=0;i<e[o].length-1;++i){const s=ht(t,e,o);ut(e[o],i,i+1);ht(t,e,o)<s?n=!0:ut(e[o],i,i+1)}}}function ht(t,e,n){let o=0;return n>0&&(o+=dt(t,e[n-1],e[n])),n+1<e.length&&(o+=dt(t,e[n],e[n+1])),o}function ut(t,e,n){const o=t[e];t[e]=t[n],t[n]=o}function pt(t){const e=Math.floor(t.length/2);if(0===t.length)return-1;if(t.length%2==1)return t[e];if(2===t.length)return(t[0]+t[1])/2;const n=t[e-1]-t[0],o=t[t.length-1]-t[e];return(t[e-1]*o+t[e]*n)/(n+o)}function gt(t,e,n=1,o=!1){if(n>0)for(let n=1;n<e.length;++n){const i=new Map;e[n].forEach((s=>{const r=pt(ft(t,e,n,n-1,s,o));i.set(s,r)})),vt(e[n],i)}else for(let n=e.length-2;n>=0;--n){const i=new Map;e[n].forEach((s=>{const r=pt(ft(t,e,n,n+1,s,o));i.set(s,r)})),vt(e[n],i)}}function ft(t,e,n,o,i,s=!1){const r=e[n],a=e[o],d=[];return a.forEach(((e,n)=>{t.nodeEdges(e,i).length>0&&d.push(n)})),0===d.length&&s&&r.forEach(((e,n)=>{t.nodeEdges(e,i).length>0&&d.push(n+.5)})),d.sort(((t,e)=>t-e)),d}function vt(t,e){const n=new Map(t.map(((t,e)=>[t,e])));for(let o=1;o<t.length;++o)for(let i=o;i>0;--i){let o=i-1,s=e.get(t[o]),r=e.get(t[i]);for(;-1===(s=e.get(t[o]))&&o>0;)o--;if(void 0===r||void 0===s||-1===r||-1===s)break;if(s===r&&(s=n.get(t[o])??s,r=n.get(t[i])??r),r>=s)break;[t[i],t[o]]=[t[o],t[i]]}}function mt(t,e){let n=0;for(let o=0;o<e.length-1;++o)n+=dt(t,e[o],e[o+1]);return n}function yt(t){const e=[];for(const n of t){const t=[];e.push(t);for(const e of n)t.push(e)}return e}const bt=(t,e)=>(t||[]).reduce(((t,n)=>t+(e?e(n):n)),0);function xt(){let t=[100,100],e=null,n=.18,o=function(t,e,n){return 1};const i=function(t){return t.data.value},s=function(t){return t.data?t.data.direction??"r":"r"};function r(a,d,l=0){null===e&&r.scaleToFit(a,d,l),wt(a,i,s),function(t,e,n,o=0){t.nodes().forEach((e=>{const i=t.node(e),s=t.inEdges(e)||[],r=t.outEdges(e)||[],a=Math.max(0,s.length-1),d=Math.max(0,r.length-1),l=Math.max(a,d);i.dy=i.value*n+l*o})),t.edges().forEach((o=>{const i=t.edge(o);i.value=e(i),i.dy=i.value*n}))}(a,i,e,l);const c=Et(a,d,l,e),h=[];for(let e=0;e<d.length;e++){const i=d[e],s=i.length;let r=0;h[e]=[];for(let d=0;d<i.length;d++){const l=i[d],u=c[d]/bt(c)*t[1],p=0===r?0:n*u/5,g=u-2*p,f=l.map(((t,e)=>a.node(t).value&&l[e+1]?o(l[e],l[e+1],a):0)),v=bt(l,(t=>a.node(t).dy)),m=Math.max(0,g-v),y=bt(f)?m/bt(f):0;let b=r+p;1===l.length&&(b+=(g-a.node(l[0]).dy)/2),h[e][d]={margin:p,height:g,gaps:f,kg:y,isFirst:0===d,isLast:d===s-1,startYY:b},r+=u}}let u,p,g=-1,f=-1,v=0,m=0;(function(t){const e=[];for(let n=0;n<t.length;n++){const o=t[n];for(let t=0;t<o.length;t++){const i=o[t];for(let o=0;o<i.length;o++)e.push({rankIndex:n,bandIndex:t,nodeIndex:o,nodeId:i[o]})}}return e})(d).forEach((({rankIndex:t,bandIndex:e,nodeIndex:n,nodeId:o})=>{var i;t===g&&e===f||(g=t,f=e,u=h[t][e],p=d[t][e],v=u.startYY,m=u.isFirst?Number.MAX_VALUE:0);const s=a.node(o);s.y=v,s.spaceAbove=m,s.spaceBelow=u.gaps[n]*u.kg,v+=s.dy+s.spaceBelow,m=s.spaceBelow,void 0!==(null==(i=s.data)?void 0:i.forceY)&&(s.y=u.margin+s.data.forceY*(u.height-s.dy)),n===p.length-1&&(s.spaceBelow=u.isLast?Number.MAX_VALUE:0)}));const y=function(t,e){const n=[];return e.forEach(((o,i)=>{if(i===e.length-1)return;let s=0;o.forEach((e=>{e.forEach((e=>{t.outEdges(e).forEach((e=>{const n=t.edge(e).dy,o=t.node(e.w).y-t.node(e.v).y,i=Math.abs(o)-n,r=n*n-i*i,a=r>=0?Math.sqrt(r):n;a>s&&(s=a)}))}))})),n.push(s)})),n}(a,d);!function(t,e,n,o){const i=o.reduce(((t,e)=>t+e),0);let s;if(i>n)s=o.map((t=>n*t/i));else{const t=n-i;s=o.map((n=>n+t/(e.length-1)))}let r=0;e.forEach(((e,n)=>{e.forEach((e=>{e.forEach((e=>{t.node(e).x=r}))})),r+=s[n]}))}(a,d,t[0],y);const b=[];return a.nodes().forEach((t=>{const e=a.node(t);e.id=t,b.push(e)})),b}return r.scaleToFit=function(o,r,a=0){wt(o,i,s);let d=0;a>0&&o.nodes().forEach((t=>{d=Math.max(d,function(t,e,n){if(n<=0)return 0;const o=t.inEdges(e)||[],i=t.outEdges(e)||[],s=Math.max(0,o.length-1),r=Math.max(0,i.length-1);return Math.max(s,r)*n}(o,t,a))}));const l=bt(Et(o,r,0,1));if(l<=0)return void(e=1);const c=t[1]-d;e=c/l,1!==n&&(e*=1-n)},r.size=function(e){return arguments.length?(t=e,r):t},r.separation=function(t){return arguments.length?(o="function"==typeof t?t:()=>t,r):o},r.whitespace=function(t){return arguments.length?(n=t,r):n},r.scale=function(t){return arguments.length?(e=t,r):e},r}function wt(t,e,n){t.nodes().forEach((o=>{const i=bt(t.inEdges(o),(n=>e(t.edge(n)))),s=bt(t.outEdges(o),(n=>e(t.edge(n))));let r=t.node(o);r||t.setNode(o,r={}),r.value=Math.max(i,s),void 0===r.direction&&(r.direction=n(r)||"r")}))}function Et(t,e,n=0,o=1){if(0===e.length||0===e[0].length)return[];const i=e[0].length,s=new Array(i).fill(0);return e.forEach((e=>{e.forEach(((e,i)=>{const r=bt(e,(e=>{const i=t.node(e),s=t.inEdges(e)||[],r=t.outEdges(e)||[],a=Math.max(0,s.length-1),d=Math.max(0,r.length-1),l=Math.max(a,d);return i.value+l*n/o}));s[i]=Math.max(s[i],r)}))})),s}function At(t,e,n){return void 0!==n?`${t}${e}${n}`:`${t}${e}`}class Ct{constructor(t={}){this._nodes=new Map,this._edges=new Map,this._graphLabel={},this._out=new Map,this._in=new Map,this._isMultigraph=t.multigraph??!1}graph(){return this._graphLabel}setGraph(t){return this._graphLabel=t,this}setNode(t,e){return this._nodes.has(t)?void 0!==e&&this._nodes.set(t,e):(this._nodes.set(t,void 0!==e?e:{}),this._out.set(t,new Set),this._in.set(t,new Set)),this}node(t){return this._nodes.get(t)}hasNode(t){return this._nodes.has(t)}nodes(){return Array.from(this._nodes.keys())}removeNode(t){var e,n;if(!this._nodes.has(t))return this;this._nodes.delete(t);const o=Array.from(this._out.get(t)??[]),i=Array.from(this._in.get(t)??[]);for(const t of o){const n=this._edges.get(t);n&&(null==(e=this._in.get(n.w))||e.delete(t)),this._edges.delete(t)}for(const t of i){const e=this._edges.get(t);e&&(null==(n=this._out.get(e.v))||n.delete(t)),this._edges.delete(t)}return this._out.delete(t),this._in.delete(t),this}sources(){return this.nodes().filter((t=>{var e;return 0===((null==(e=this._in.get(t))?void 0:e.size)??0)}))}successors(t){return this.outEdges(t).map((t=>t.w))}setEdge(t,e,n,o){var i,s;let r,a;"object"==typeof t?(r=t.v,a=t.w,o=t.name,n=e):(r=t,a=e),this.setNode(r),this.setNode(a);const d=this._isMultigraph?At(r,a,o):At(r,a),l=this._edges.get(d);if(l)void 0!==n&&(l.label=n);else{const t={v:r,w:a,name:o,label:void 0!==n?n:{}};this._edges.set(d,t),null==(i=this._out.get(r))||i.add(d),null==(s=this._in.get(a))||s.add(d)}return this}edge(t,e,n){var o;let i;return i="string"==typeof t?this._isMultigraph?At(t,e,n):At(t,e):this._isMultigraph?At(t.v,t.w,t.name):At(t.v,t.w),null==(o=this._edges.get(i))?void 0:o.label}hasEdge(t,e,n){const o=this._isMultigraph?At(t,e,n):At(t,e);return this._edges.has(o)}edges(){return Array.from(this._edges.values()).map((({v:t,w:e,name:n})=>({v:t,w:e,name:n})))}removeEdge(t){var e,n;const o=this._isMultigraph?At(t.v,t.w,t.name):At(t.v,t.w),i=this._edges.get(o);return i?(null==(e=this._out.get(i.v))||e.delete(o),null==(n=this._in.get(i.w))||n.delete(o),this._edges.delete(o),this):this}outEdges(t){const e=this._out.get(t);return e?Array.from(e).flatMap((t=>{const e=this._edges.get(t);return e?[{v:e.v,w:e.w,name:e.name}]:[]})):[]}inEdges(t){const e=this._in.get(t);return e?Array.from(e).flatMap((t=>{const e=this._edges.get(t);return e?[{v:e.v,w:e.w,name:e.name}]:[]})):[]}nodeEdges(t,e){const n=[],o=new Set;for(const i of[...this.inEdges(t),...this.outEdges(t)])if(i.v===e||i.w===e){const t=At(i.v,i.w,i.name);o.has(t)||(o.add(t),n.push(i))}return n}}function St(t){return void 0!==t.name?`${t.v}${t.w}${t.name}`:`${t.v}${t.w}`}function kt(t,e){const n=function(t,e){const n=new Set,o=new Ct({directed:!0}),i=[];if(!t.hasNode(e))throw Error("node not in graph");return Mt(t,e,n,o,i),t.nodes().forEach((e=>{n.has(e)||Mt(t,e,n,o,i)})),i.forEach(((t,e)=>{o.node(t).thread=e+1<i.length?i[e+1]:i[0]})),o}(t,e);return t.edges().forEach((e=>{const o=function(t,e,n){const o=t.node(e),i=t.node(n);if((o.depth??0)<(i.depth??0)){let e=o.thread;for(;void 0!==e&&(t.node(e).depth??0)>(o.depth??0);){if(e===n)return 1;e=t.node(e).thread}}else if((i.depth??0)<(o.depth??0)){let n=i.thread;for(;void 0!==n&&(t.node(n).depth??0)>(i.depth??0);){if(n===e)return-1;n=t.node(n).thread}}return 0}(n,e.v,e.w);if(o<0){const n=t.edge(e)||{};n.reversed=!0,t.removeEdge(e),t.setEdge(e.w,e.v,n)}})),t}function Mt(t,e,n,o,i,s=0){if(!n.has(e)){n.add(e),i.push(e),o.setNode(e,{depth:s});t.outEdges(e).map((t=>t.w)).forEach((r=>{n.has(r)||o.setEdge(e,r,{delta:1}),Mt(t,r,n,o,i,s+1)}))}}function $t(t){if(0===t.nodes().length)return;const e=function(t,e){const n=new Ct({directed:!0});let o=!1;for(const t of e)if("min"===t.type){o=!0;break}if(!o){const n=t.sources();e=n.length>0?[{nodes:[n[0]],type:"min"},...e]:[{nodes:[t.nodes()[0]],type:"min"},...e]}const i=new Map;let s=0;return e.forEach((t=>{if(!t.nodes||0===t.nodes.length)return;const e=""+s++;t.nodes.forEach((t=>{i.set(t,e)})),n.setNode(e,{nodes:t.nodes,type:t.type})})),t.nodes().forEach((t=>{if(!i.has(t)){const e=""+s++,o={nodes:[t],type:"same"};i.set(t,e),n.setNode(e,o)}})),t.edges().forEach((e=>{const o=i.get(e.v)??e.v,s=i.get(e.w)??e.w,r=t.node(e.v)||{},a=t.node(e.w)||{},d=n.edge(o,s)||{delta:0};o===s?(d.delta=0,n.setEdge(o,s,d)):"l"===r.direction?(d.delta=Math.max(d.delta??0,"l"===a.direction?1:0),n.setEdge(s,o,d)):(d.delta=Math.max(d.delta??0,"l"===a.direction?0:1),n.setEdge(o,s,d))})),n}(t,[]);!function(t){t.sources().forEach((e=>{"0"!==e&&t.setEdge("0",e,{delta:0,temp:!0})}))}(e),kt(e,"0"),function(t){var e;const n=t.sources(),o=new Set,i=new Set;for(t.edges().forEach((t=>{t.v===t.w&&i.add(St(t))}));n.length>0;){const s=n.shift();if(void 0===s)break;o.add(s);let r=t.node(s);r||t.setNode(s,r={}),r.rank=0;for(const n of t.inEdges(s)){const o=(null==(e=t.edge(n)||{})?void 0:e.delta)??1;r.rank=Math.max(r.rank,(t.node(n.v).rank??0)+o)}for(const e of t.outEdges(s))i.add(St(e));for(const e of t.nodes())n.indexOf(e)<0&&!o.has(e)&&!t.inEdges(e).some((t=>!i.has(St(t))))&&n.push(e)}}(e),function(t){function e(e){const n=t.node(e),o=Math.min(...t.outEdges(e).map((e=>(t.node(e.w).rank??0)-(t.edge(e).delta??0))));void 0!==o&&(n.rank=o)}t.edges().forEach((n=>{t.edge(n).temp&&e(n.w)}))}(e),t.nodes().forEach((e=>{t.node(e)||t.setNode(e,{})})),e.nodes().forEach((n=>{var o;const i=e.node(n);null==(o=i.nodes)||o.forEach((e=>{t.node(e).rank=i.rank}))}))}function Tt(t){const e=xt(),n=it(t);let o=[],i=[],s=null;function r(r=[],a=[]){const d=function(t=[],e=[]){const n=new Ct({directed:!0,multigraph:!0});return e.forEach((t=>{n.setEdge(t.source,t.target,{data:t,points:[]},t.type)})),n.nodes().forEach((t=>n.setNode(t,{data:{}}))),t.forEach((t=>{n.hasNode(t.id)&&(n.node(t.id).data=t,void 0!==t.direction&&(n.node(t.id).direction=t.direction))})),n.edges().forEach((t=>{n.edge(t).source=n.node(t.v),n.edge(t).target=n.node(t.w)})),n}(a,r);var l;return $t(d),(l=d).edges().forEach((t=>{const e=l.node(t.v),n=l.node(t.w),o=l.edge(t);let i=e.rank;const s=[];if(void 0!==i&&void 0!==n.rank&&i+1<=n.rank){for("l"===e.direction&&s.push(i);++i<n.rank;)s.push(i);"l"===n.direction&&s.push(i),at(l,t,o,s,"r")}else if(void 0!==i&&void 0!==n.rank&&i>n.rank){for("l"!==e.direction&&s.push(i);i-- >n.rank+1;)s.push(i);"l"!==n.direction&&s.push(i),at(l,t,o,s,"l")}})),s=function(t,e=25){const n=lt(t);let o=n,i=mt(t,n),s=0;for(;s++<e;){gt(t,n,s%2==0?1:0),ct(t,n);const e=mt(t,n);if(e<i&&(o=yt(n),i=e),0===i)break}return o.map((t=>[t]))}(d),o=e(d,s,t.edgeGap||0),function(t){t.nodes().forEach((e=>{const n=t.node(e);n.incoming=t.inEdges(e),n.outgoing=t.outEdges(e)}))}(d),i=n(d),function(t){t.nodes().filter((t=>t.startsWith("__"))).forEach((e=>{var n;let o=t.node(e);if(!o)return;let i=(null==(n=t.inEdges(e))?void 0:n.map((e=>t.edge(e))))||[];i.forEach((e=>{e.origLabel&&e.origEdge&&(e.origLabel.dy=e.dy,e.origLabel.x0=e.x0,e.origLabel.y0=e.y0,e.origLabel.r0=e.r0,e.origLabel.d0=e.d0,e.origLabel.value=e.value,t.setEdge(e.origEdge,e.origLabel))}));let s,r=i.map((t=>t.r1));for(;o.dummy;)i=t.outEdges(e).map((e=>t.edge(e))),i.forEach(((t,e)=>{t.origLabel&&(t.origLabel.points||(t.origLabel.points=[]),t.origLabel.points.push({d:t.d0,r0:t.r0,r1:r[e],x:o.x,y:t.y0}))})),r=i.map((t=>t.r1)),s=t.successors(e)[0],t.removeNode(e),o=t.node(e=s);i.forEach((t=>{t.origLabel&&(t.origLabel.x1=t.x1,t.origLabel.y1=t.y1,t.origLabel.r1=t.r1,t.origLabel.d1=t.d1)}))}))}(d),function(t){t.edges().forEach((e=>{const n=t.edge(e);n.points||(n.points=[]),n.points.unshift({d:n.d0,ro:n.r0,x:n.x0,y:n.y0}),n.points.push({d:n.d1,ri:n.r1,x:n.x1,y:n.y1})}))}(d),d}return void 0!==t.whitespace&&e.whitespace(t.whitespace),r.nodes=function(){return o},r.links=function(){return i},r.order=function(){return s},r.size=function(t){return arguments.length?(e.size(t),r):e.size()},r.separation=function(t){return arguments.length?(e.separation(t),r):e.separation()},r.whitespace=function(t){return arguments.length?(e.whitespace(t),r):e.whitespace()},r.edgeValue=function(t){return r},r.scale=function(t){return arguments.length?(e.scale(t),r):e.scale()},r}const Lt=["#6b9ece","#e07b7b","#7dba8f","#b09ed1","#e0b678","#6dbaba","#d17da8","#b5b56d","#c49a6d","#8fa4b8","#c98aa0","#94bf7d","#e0a08a","#7b9eb5","#a988a8"],Nt={canvasStyle:"border: 1px solid #caced0; box-sizing: border-box",edgeGap:0,edgeGradientFill:!0,edgeOpacity:.4,particleFlow:!1,enableToolbar:!0,type:"sankey",arcCornerRadius:6,enableTooltip:!0,fontColor:"#212121",fontFamily:"",fontSize:"14px",fontWeight:"400",height:"auto",locale:{direction:"ltr"},nodeBorderColor:null,nodeBorderWidth:1,nodeWidth:20,nodePalette:void 0,theme:void 0,draggableNodes:!1,onNodeClick:void 0,spacing:20,tooltipBGColor:"#FFFFFF",tooltipBorderColor:"#E2E8F0",tooltipFontColor:"#1a1a1a",tooltipId:"apexsankey-tooltip-container",tooltipTemplate:({source:t,target:e,value:n})=>`\n <div style='display:flex;align-items:center;gap:6px;padding:7px 10px;'>\n <div style='width:10px;height:10px;border-radius:2px;background-color:${null==t?void 0:t.color};flex-shrink:0;'></div>\n <span style='font-weight:500;'>${null==t?void 0:t.title}</span>\n <svg width='14' height='14' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg' style='opacity:0.5;flex-shrink:0;'><path d='M5 12h14M13 6l6 6-6 6' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>\n <div style='width:10px;height:10px;border-radius:2px;background-color:${null==e?void 0:e.color};flex-shrink:0;'></div>\n <span style='font-weight:500;'>${null==e?void 0:e.title}</span>\n <span style='opacity:0.6;margin-left:2px;'>·</span>\n <span style='font-weight:600;'>${n}</span>\n </div>\n `,nodeTooltipTemplate:({node:t,value:e})=>`\n <div style='display:flex;align-items:center;gap:6px;padding:7px 10px;'>\n <div style='width:10px;height:10px;border-radius:2px;background-color:${null==t?void 0:t.color};flex-shrink:0;'></div>\n <span style='font-weight:500;'>${null==t?void 0:t.title}</span>\n <span style='opacity:0.6;'>·</span>\n <span style='font-weight:600;'>${e}</span>\n </div>\n `,viewPortHeight:500,viewPortWidth:800,whitespace:.18,orientation:"horizontal",axisTitles:void 0,width:"100%",highlightConnectedPath:!0,dimOpacity:.2,animation:{enabled:!0,duration:800},a11y:{enabled:!0}},Ft={diagramLabel:({flowCount:t,largestFlow:e,nodeCount:n})=>{let o=`Sankey flow diagram: ${n} nodes, ${t} flows.`;return e&&(o+=` Largest flow: ${e.source} (${e.value} units) to ${e.target}.`),o},edgeAriaLabel:({source:t,target:e,value:n})=>`Flow from ${t} to ${e}: ${n} units`,nodeAriaLabel:({incoming:t,name:e,outgoing:n})=>{let o=e;if(t&&(o+=`: receives ${t.total} units from ${t.sources.join(", ")}`),n){o+=`${t?"; ":": "}flows ${n.total} units to ${n.targets.join(", ")}`}return o},nodesGroupLabel:"Sankey nodes"};function Rt(t){var e;return function(t,e){if(!e)return{...t};const n={...t};for(const t of Object.keys(e)){const o=e[t];void 0!==o&&(n[t]=o)}return n}(Ft,null==(e=t.locale)?void 0:e.messages)}class Bt{constructor(t,e,n){this.element=t,this.options=e,this.chartContext=n,t.innerHTML="",this.canvas=function(){const t=document.createElementNS(s,"svg");return new g(t)}().addTo(t).size("100%","100%").viewbox(`-${this.spacing} -${this.spacing+this.getYShift()} ${this.width+2*this.spacing} ${this.height+this.spacing+this.getYShift()}`).attr({style:this.options.canvasStyle})}getYShift(){return this.options.enableToolbar?30:0}add(t){this.canvas.add(t)}clear(){this.canvas.clear().viewbox(`-${this.spacing} -${this.spacing+this.getYShift()} ${this.width+2*this.spacing} ${this.height+this.spacing+this.getYShift()}`)}exportToSvg(){new i(this.canvas,"apexsankey").exportToSVG()}resetViewBox(){this.canvas.viewbox(`-${this.spacing} -${this.spacing+this.getYShift()} ${this.width+2*this.spacing} ${this.height+this.spacing+this.getYShift()}`)}updateViewBox(t,e,n,o){this.canvas.viewbox(`${t} ${e} ${n} ${o}`)}get height(){return this.options.viewPortHeight}get spacing(){return this.options.spacing}get width(){return this.options.viewPortWidth}}class _t{constructor(t,e,n){this.svgRoot=t,this.graph=e,this.dimOpacity=n,this.pinnedNode=null,this.pinnedEdge=null}highlightNode(t){const e=this.prefersReducedMotion(),n=[...this.graph.inEdges(t)??[],...this.graph.outEdges(t)??[]],o=new Set([t]);n.forEach((t=>{var e,n,i,s;const r=this.graph.edge(t.v,t.w,t.name),a=null==(n=null==(e=null==r?void 0:r.source)?void 0:e.data)?void 0:n.id,d=null==(s=null==(i=null==r?void 0:r.target)?void 0:i.data)?void 0:s.id;a&&o.add(a),d&&o.add(d)})),this.dimAll(e),n.forEach((t=>{const n=this.svgRoot.querySelector(`[data-edge-source="${t.v}"][data-edge-target="${t.w}"]`);n&&this.setOpacity(n,1,e)})),o.forEach((t=>{const n=this.svgRoot.querySelector(`[data-node-id="${t}"]`);n&&this.setOpacity(n,1,e)}))}highlightEdge(t,e){var n,o,i,s;const r=this.prefersReducedMotion(),a=this.graph.edge(t,e),d=(null==(o=null==(n=null==a?void 0:a.source)?void 0:n.data)?void 0:o.id)??t,l=(null==(s=null==(i=null==a?void 0:a.target)?void 0:i.data)?void 0:s.id)??e;this.dimAll(r),this.svgRoot.querySelectorAll(`[data-edge-source="${t}"][data-edge-target="${e}"]`).forEach((t=>this.setOpacity(t,1,r)));const c=this.svgRoot.querySelector(`[data-node-id="${d}"]`),h=this.svgRoot.querySelector(`[data-node-id="${l}"]`);c&&this.setOpacity(c,1,r),h&&this.setOpacity(h,1,r)}focusNode(t){const e=new Set([t]),n=[];this.walk(t,"down",e,n),this.walk(t,"up",e,n),this.applySets(e,n)}focusEdge(t,e){var n,o,i,s;const r=this.graph.edge(t,e),a=(null==(o=null==(n=null==r?void 0:r.source)?void 0:n.data)?void 0:o.id)??t,d=(null==(s=null==(i=null==r?void 0:r.target)?void 0:i.data)?void 0:s.id)??e,l=new Set([a,d]),c=[{v:t,w:e}];this.walk(a,"up",l,c),this.walk(d,"down",l,c),this.applySets(l,c)}togglePinFocusNode(t){this.pinnedNode!==t?(this.pinnedNode=t,this.pinnedEdge=null,this.focusNode(t)):this.clearPin()}togglePinFocusEdge(t,e){this.pinnedEdge&&this.pinnedEdge.source===t&&this.pinnedEdge.target===e?this.clearPin():(this.pinnedEdge={source:t,target:e},this.pinnedNode=null,this.focusEdge(t,e))}isPinned(){return null!==this.pinnedNode||null!==this.pinnedEdge}clearPin(){this.pinnedNode=null,this.pinnedEdge=null,this.clear()}reset(){this.pinnedNode?this.focusNode(this.pinnedNode):this.pinnedEdge?this.focusEdge(this.pinnedEdge.source,this.pinnedEdge.target):this.clear()}walk(t,e,n,o){const i=new Set([t]);let s=[t];for(;s.length;){const t=[];for(const r of s){const s="down"===e?this.graph.outEdges(r)??[]:this.graph.inEdges(r)??[];for(const r of s){o.push({v:r.v,w:r.w});const s="down"===e?r.w:r.v;n.add(s),i.has(s)||(i.add(s),t.push(s))}}s=t}}applySets(t,e){const n=this.prefersReducedMotion();this.dimAll(n),e.forEach((({v:t,w:e})=>{this.svgRoot.querySelectorAll(`[data-edge-source="${t}"][data-edge-target="${e}"]`).forEach((t=>this.setOpacity(t,1,n)))})),t.forEach((t=>{const e=this.svgRoot.querySelector(`[data-node-id="${t}"]`);e&&this.setOpacity(e,1,n)}))}clear(){const t=this.prefersReducedMotion()?"none":"";this.svgRoot.querySelectorAll("[data-edge-source]").forEach((e=>{e.style.transition=t,e.style.opacity=""})),this.svgRoot.querySelectorAll("[data-node-id]").forEach((e=>{e.style.transition=t,e.style.opacity=""}))}dimAll(t){this.svgRoot.querySelectorAll("[data-edge-source]").forEach((e=>{this.setOpacity(e,this.dimOpacity,t)})),this.svgRoot.querySelectorAll("[data-node-id]").forEach((e=>{this.setOpacity(e,this.dimOpacity,t)}))}setOpacity(t,e,n){t.style.transition=n?"none":"opacity 0.2s ease",t.style.opacity=String(e)}prefersReducedMotion(){return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}}function It(t,e){const n=e=>function(t,e){return getComputedStyle(t).getPropertyValue(e).trim()}(t,e),o=n("--apex-sankey-edge-opacity"),i=""!==o?Number(o):e.edgeOpacity,s=n("--apex-sankey-node-width"),r=""!==s?Number(s):e.nodeWidth,a=n("--apex-sankey-node-border-width"),d=""!==a?Number(a):e.nodeBorderWidth,l=n("--apex-sankey-edge-gradient"),c=""!==l?"true"===l:e.edgeGradientFill,h=et(t,"string"==typeof e.theme?e.theme:void 0),u=(t,o,i)=>function({cssVar:t,fallback:e,option:n,token:o}){return t||(n&&n!==e?n:o||(n??""))}({cssVar:n(t),fallback:Nt[o],option:e[o],token:i}),p=n("--apex-sankey-node-border-color")||(e.nodeBorderColor!==Nt.nodeBorderColor?e.nodeBorderColor:h.grid??e.nodeBorderColor),g=u("--apex-sankey-tooltip-bg","tooltipBGColor",h.surface),f=u("--apex-sankey-tooltip-border-color","tooltipBorderColor",h.grid),v=u("--apex-sankey-tooltip-font-color","tooltipFontColor",h.fore),m=h.series&&((y=e.nodePalette)===(b=Nt.nodePalette)||y&&b&&y.length===b.length&&y.every(((t,e)=>t===b[e])))?[...h.series]:e.nodePalette;var y,b;const x=n("--apex-sankey-tooltip-theme"),w="dark"===x||"light"===x?x:e.tooltipTheme;return{...e,edgeGradientFill:c,edgeOpacity:Number.isFinite(i)?i:e.edgeOpacity,fontColor:u("--apex-sankey-label-color","fontColor",h.fore),fontSize:n("--apex-sankey-label-font-size")||e.fontSize,fontFamily:n("--apex-sankey-font-family")||e.fontFamily,nodeBorderColor:p,nodePalette:m,nodeBorderWidth:Number.isFinite(d)?d:e.nodeBorderWidth,nodeWidth:Number.isFinite(r)?r:e.nodeWidth,tooltipBGColor:g,tooltipBorderColor:f,tooltipFontColor:v,tooltipTheme:w}}const Ot="#005FCC",Dt="role",Gt="aria-label",Pt="data-node-id",jt="data-orig-stroke",zt="data-orig-stroke-width",qt="stroke",Ht="stroke-width",Wt="forced-colors",Vt="apexsankey-desc",Yt="data-edge-target";const Kt="apexsankey-a11y-styles";class Ut{constructor(t,e,n={},o,i,s=Ft){this.svgEl=t,this.graph=e,this.options=n,this.tooltipId=o,this.pathHighlighter=i,this.messages=s,this.nodeGroups=[],this.edgePaths=[],this.nodeOutEdges=new Map,this.edgeSourceNode=new Map,this.mediaQuery=null,this.forcedColorsHandler=null,this.isKeyboardUser=!1}apply(){!1!==this.options.enabled&&(this.injectAriaAttributes(),this.setupKeyboardNavigation(),function(){if(document.getElementById(Kt))return;const t=document.createElement("style");t.id=Kt,t.textContent=`\n /* ApexSankey: keyboard focus ring */\n .node:focus,\n svg path[data-edge-source]:focus { outline: none; }\n .node:focus-visible rect {\n stroke: ${Ot};\n stroke-width: 2;\n }\n\n /* High-contrast (Windows Forced Colors) */\n @media (forced-colors: active) {\n .node rect {\n fill: ButtonFace;\n stroke: ButtonText;\n }\n .node text {\n fill: ButtonText;\n }\n .node:focus-visible rect {\n stroke: Highlight;\n stroke-width: 2;\n }\n }\n\n /* Reduced motion */\n @media (prefers-reduced-motion: reduce) {\n .node rect,\n svg path {\n transition: none !important;\n animation: none !important;\n }\n }\n `,document.head.appendChild(t)}(),this.setupHighContrastMode())}destroy(){this.mediaQuery&&this.forcedColorsHandler&&(this.mediaQuery.removeEventListener("change",this.forcedColorsHandler),this.mediaQuery=null,this.forcedColorsHandler=null)}injectAriaAttributes(){const{svgEl:t,graph:e,messages:n,options:o}=this,i=e.nodes().filter((t=>!e.node(t).dummy)),s=e.edges(),r=function(t,e,n,o,i){var s,r,a,d;if(i)return i;let l=0,c="",h="";for(const e of n)try{const n=t.edge(e.v,e.w,e.name).value??0;if(n>l){const o=t.node(e.v),i=t.node(e.w);o.dummy||i.dummy||(l=n,c=(null==(s=o.data)?void 0:s.title)??(null==(r=o.data)?void 0:r.id)??e.v,h=(null==(a=i.data)?void 0:a.title)??(null==(d=i.data)?void 0:d.id)??e.w)}}catch{}const u=c&&h?{source:c,target:h,value:l}:void 0;return o.diagramLabel({flowCount:n.length,largestFlow:u,nodeCount:e.length})}(e,i,s,n,o.diagramLabel);t.setAttribute(Dt,"img"),t.setAttribute(Gt,r),t.removeAttribute("aria-labelledby");const a=t.querySelector("title");if(a&&a.remove(),o.description){let e=t.querySelector("desc");if(!e){const n=document.createElementNS("http://www.w3.org/2000/svg","desc");n.id=Vt,t.insertBefore(n,t.firstChild),e=n}e.textContent=o.description,t.setAttribute("aria-describedby",Vt)}const d=Array.from(t.querySelectorAll(`[${Pt}]`));d.forEach((t=>{const o=t.getAttribute(Pt);o&&(t.setAttribute(Dt,"listitem"),t.setAttribute(Gt,function(t,e,n){var o,i,s,r,a,d;const l=e.node(t),c=(null==(o=l.data)?void 0:o.title)??(null==(i=l.data)?void 0:i.id)??t,h=[];let u=0;for(const n of e.inEdges(t))try{const t=e.edge(n.v,n.w,n.name),o=e.node(n.v);o.dummy||(h.push((null==(s=o.data)?void 0:s.title)??(null==(r=o.data)?void 0:r.id)??n.v),u+=t.value??0)}catch{}const p=[];let g=0;for(const n of e.outEdges(t))try{const t=e.edge(n.v,n.w,n.name),o=e.node(n.w);o.dummy||(p.push((null==(a=o.data)?void 0:a.title)??(null==(d=o.data)?void 0:d.id)??n.w),g+=t.value??0)}catch{}return n.nodeAriaLabel({incoming:h.length>0?{sources:h,total:u}:void 0,name:c,outgoing:p.length>0?{targets:p,total:g}:void 0})}(o,e,n)),t.setAttribute("tabindex","0"))})),this.nodeGroups=d;const l=[],c=new Map,h=new Map;t.querySelectorAll("[data-edge-source]").forEach((t=>{var o,i,s,r;const a=t.getAttribute("data-edge-source"),d=t.getAttribute("data-edge-target"),u=t.getAttribute("data-edge-name")??void 0;if(a&&d)try{const p=e.edge(a,d,u),g=p.source,f=p.target;if(!g||!f)return;const v=(null==(o=g.data)?void 0:o.title)??(null==(i=g.data)?void 0:i.id)??a,m=(null==(s=f.data)?void 0:s.title)??(null==(r=f.data)?void 0:r.id)??d,y=p.value??0;t.setAttribute("role","img"),t.setAttribute("aria-label",n.edgeAriaLabel({source:v,target:m,value:y})),t.setAttribute("focusable","true"),t.setAttribute("tabindex","-1"),l.push(t),h.set(t,a),c.has(a)||c.set(a,[]);const b=c.get(a);b&&b.push(t)}catch{}})),this.edgePaths=l,this.nodeOutEdges=c,this.edgeSourceNode=h}setupKeyboardNavigation(){this.svgEl.addEventListener("pointerdown",(()=>{this.isKeyboardUser=!1})),this.svgEl.addEventListener("keydown",(()=>{this.isKeyboardUser=!0})),this.nodeGroups.forEach(((t,e)=>{t.addEventListener("keydown",(n=>{const o=n.key;if("Enter"===o||" "===o){n.preventDefault();const e=t.querySelector("rect");e&&e.dispatchEvent(new MouseEvent("click",{bubbles:!0}))}else if("Escape"===o)n.preventDefault(),this.restoreFocusRing(t),t.blur(),this.hideTooltip();else if("ArrowRight"===o||"ArrowDown"===o){n.preventDefault();const o=t.getAttribute(Pt),i=o?this.nodeOutEdges.get(o)??[]:[];if(i.length>0)i[0].focus();else{this.nodeGroups[(e+1)%this.nodeGroups.length].focus()}}else if("ArrowLeft"===o||"ArrowUp"===o){n.preventDefault();this.nodeGroups[(e-1+this.nodeGroups.length)%this.nodeGroups.length].focus()}})),t.addEventListener("focus",(()=>{var e;if(this.isKeyboardUser){this.applyFocusRing(t);const n=t.getAttribute(Pt);n&&(null==(e=this.pathHighlighter)||e.highlightNode(n))}if(this.tooltipId){const e=t.querySelector("rect");if(e){const t=e.getBoundingClientRect();e.dispatchEvent(new MouseEvent("mouseover",{clientX:t.left+t.width/2,clientY:t.top,bubbles:!0}))}}})),t.addEventListener("blur",(()=>{var e;this.restoreFocusRing(t),null==(e=this.pathHighlighter)||e.reset(),this.hideTooltip()}))}));for(const t of this.edgePaths){const e=()=>{const e=this.edgeSourceNode.get(t);return e?this.nodeOutEdges.get(e)??[]:[]},n=()=>{const e=this.edgeSourceNode.get(t),n=e?this.nodeGroups.find((t=>t.getAttribute(Pt)===e)):void 0;n&&n.focus()};t.addEventListener("keydown",(o=>{const i=o.key;if("Enter"===i||" "===i)o.preventDefault(),t.dispatchEvent(new MouseEvent("click",{bubbles:!0}));else if("Escape"===i||"ArrowLeft"===i)o.preventDefault(),n();else if("ArrowDown"===i){o.preventDefault();const n=e(),i=n.indexOf(t);n[(i+1)%n.length].focus()}else if("ArrowUp"===i){o.preventDefault();const n=e(),i=n.indexOf(t);n[(i-1+n.length)%n.length].focus()}else if("ArrowRight"===i){o.preventDefault();const e=t.getAttribute(Yt),n=e?this.nodeGroups.find((t=>t.getAttribute(Pt)===e)):void 0;n&&n.focus()}else if("Tab"===i){const e=this.edgeSourceNode.get(t),n=this.nodeGroups.findIndex((t=>t.getAttribute(Pt)===e));if(-1!==n){const t=o.shiftKey?(n-1+this.nodeGroups.length)%this.nodeGroups.length:(n+1)%this.nodeGroups.length;o.preventDefault(),this.nodeGroups[t].focus()}}})),t.addEventListener("focus",(()=>{var e;if(this.isKeyboardUser){const n=t.getAttribute("data-edge-source"),o=t.getAttribute(Yt);n&&o&&(null==(e=this.pathHighlighter)||e.highlightEdge(n,o))}if(this.tooltipId){const e=t.getBoundingClientRect();t.dispatchEvent(new MouseEvent("mouseover",{clientX:e.left+e.width/2,clientY:e.top+e.height/2,bubbles:!0}))}})),t.addEventListener("blur",(t=>{var e;const n=t.relatedTarget;n&&this.edgePaths.includes(n)||(null==(e=this.pathHighlighter)||e.reset(),this.hideTooltip())}))}}hideTooltip(){if(this.tooltipId){const t=document.getElementById(this.tooltipId);t&&(t.style.display="none")}}applyFocusRing(t){const e=t.querySelector("rect");e&&(e.setAttribute(jt,e.getAttribute(qt)??""),e.setAttribute(zt,e.getAttribute(Ht)??""),e.setAttribute(qt,Ot),e.setAttribute(Ht,"2"))}restoreFocusRing(t){const e=t.querySelector("rect");if(!e)return;const n=e.getAttribute(jt),o=e.getAttribute(zt);null!==n&&(e.setAttribute(qt,n),e.removeAttribute(jt)),null!==o&&(e.setAttribute(Ht,o),e.removeAttribute(zt))}setupHighContrastMode(){if("undefined"!=typeof window&&"function"==typeof window.matchMedia)try{const t=window.matchMedia("(forced-colors: active)");this.mediaQuery=t,t.matches&&this.svgEl.classList.add(Wt),this.forcedColorsHandler=t=>{t.matches?this.svgEl.classList.add(Wt):this.svgEl.classList.remove(Wt)},t.addEventListener("change",this.forcedColorsHandler)}catch{}}}const Xt="http://www.w3.org/2000/svg";const Zt=t=>0===t.dy?0:2;function Qt(t,e,n=.5){return t+(e-t)*n}function Jt(t,e=!1){const n=(t,n)=>e?`${n},${t}`:`${t},${n}`,o=Math.max(Zt(t),t.dy)/2;let{x0:i}=t,{x1:s}=t,{y0:r}=t,{y1:a}=t;s<i&&([i,s]=[s,i],[r,a]=[a,r]);const d=Qt(i,s);return`M${n(i,r-o)} C${n(d,r-o)} ${n(d,a-o)} ${n(s,a-o)} L${n(s,a+o)} C${n(d,a+o)} ${n(d,r+o)} ${n(i,r+o)} Z`}function te(t,e=!1){const n=(t,n)=>e?`${n},${t}`:`${t},${n}`;let{x0:o}=t,{x1:i}=t,{y0:s}=t,{y1:r}=t;i<o&&([o,i]=[i,o],[s,r]=[r,s]);const a=Qt(o,i);return`M${n(o,s)} C${n(a,s)} ${n(a,r)} ${n(i,r)}`}function ee(t,e=!1){if(!t.points||t.points.length<2)return null;let n="";for(let o=0;o<t.points.length-1;++o){const i=t.points[o],s=t.points[o+1];n+=`${te({dy:t.dy??0,r0:i.ro,r1:s.ri,x0:i.x??0,x1:s.x??0,y0:i.y??0,y1:s.y??0},e)} `}return n.trim()}function ne(t,e=!1){var n;if(1===(null==(n=t.points)?void 0:n.length))return function(t,e=!1){if(!t.points)return null;const n=t.points[0],o=Math.max(Zt(t),t.dy??0)/2,i=(t,n)=>e?`${n},${t}`:`${t},${n}`;return"down-right"===n.style?`M${i((n.x??0)-20,(n.y??0)-o)} L${i(n.x??0,(n.y??0)-o)} L${i(n.x??0,(n.y??0)+o)} L${i((n.x??0)-20,(n.y??0)+o)} Z`:"right-down"===n.style?`M${i(n.x??0,(n.y??0)-o)} L${i((n.x??0)+20,(n.y??0)-o)} L${i((n.x??0)+20,(n.y??0)+o)} L${i(n.x??0,(n.y??0)+o)} Z`:null}(t,e);if(!t.points)return null;let o,i="";for(let n=0;n<t.points.length-1;++n){const s=t.points[n],r=t.points[n+1];o={d0:s.d,d1:r.d,dy:t.dy??0,r0:s.ro,r1:r.ri,x0:s.x??0,x1:r.x??0,y0:s.y??0,y1:r.y??0},i+=Jt(o,e)}return i}const oe=(t,e)=>{const n=(null==t?void 0:t.title)??(null==t?void 0:t.id)??"";return e&&n.length>e?`${n.substr(0,15)}...`:n};function ie(t,e,n){var o,i;const{dy:s,x:r,y:a}=t,{fontColor:l="#212121",fontSize:c="14px",fontFamily:h,fontWeight:u,isRtl:p=!1,vertical:g=!1,nodeBorderColor:m,nodeBorderWidth:y,nodeWidth:b=0,onNodeClick:x,nodeTooltip:w}=n,C=new d({class:"node"}),k=f(g?{height:b,width:s,x:a??0,y:(r??0)-b/2}:{height:s,width:b,x:(r??0)-b/2,y:a});if(k.fill(null==(o=t.data)?void 0:o.color),k.stroke({color:m??(null==(i=t.data)?void 0:i.color),width:y}),k.on("click",(()=>{"function"==typeof x&&x(t)})),w){const{chartContext:e,isCustomTooltip:n,nodeValue:o,tooltipBGColor:i,tooltipBorderColor:s,tooltipFontColor:r,tooltipId:a,nodeTooltipTemplate:d}=w,p=d({node:t.data,value:o});k.on("mouseover",(t=>{const{pageX:o,pageY:d}=t,g=S({bgColor:n?void 0:i,borderColor:n?void 0:s,fontColor:n?void 0:r||l,fontFamily:n?void 0:h??"",fontSize:n?void 0:c??"14px",fontWeight:n?void 0:u??"400",x:o,y:d});A(e,a,g,p,!0)})),k.on("mousemove",(t=>{const{pageX:o,pageY:d}=t,g=S({bgColor:n?void 0:i,borderColor:n?void 0:s,fontColor:n?void 0:r||l,fontFamily:n?void 0:h??"",fontSize:n?void 0:c??"14px",fontWeight:n?void 0:u??"400",x:o,y:d});A(e,a,g,p,!0)})),k.on("mouseout",(()=>{E(e,a).style.display="none"}))}if(C.add(k),t.data&&(s??0)>Number.parseInt(c,10)){const n=function(t,{fontColor:e,isRtl:n,maxRank:o,nodeWidth:i,vertical:s}){const{data:r}=t;if(!r)return null;if(s){const n=(t.y??0)+(t.dy??0)/2,s=t.x??0,a=(t.rank??0)<o/2?s+i/2+14:s-i/2-8;return v(oe(r,18),{fontColor:e,pointerEvents:"none",textAnchor:"middle",x:n,y:a})}const a=function(t,e,n){let o=!1,i=!1;return(t.rank??0)<e/2&&(i=!0,o=!1),n&&(i=!i),{right:i,top:o}}(t,o,n),{x:d,y:l}=function(t,e,n){const o=e.top?-25:(t.dy??0)/2-10;let i;return i=e.top?e.right?4:-4:e.right?10+n/2:-n/2-10,{x:(t.x??0)+i,y:(t.y??0)+o}}(t,a,i);return v(oe(r,a.top?25:15),{fontColor:e,pointerEvents:"none",textAnchor:a.top?"middle":a.right?"start":"end",x:d,y:l})}(t,{fontColor:l,isRtl:p,maxRank:e,nodeWidth:b,vertical:g});n&&C.add(n)}return C}class se{build(t){const{chartContext:e,events:n,graph:o,isRtl:i,maxRank:s,messages:r,options:a,pathHighlighter:d}=t,{enableTooltip:l,fontColor:c,fontFamily:h,fontSize:u,fontWeight:p,nodeBorderColor:g,nodeBorderWidth:f,nodeWidth:v,nodeTooltipTemplate:y,onNodeClick:b,tooltipBGColor:x,tooltipBorderColor:w,tooltipFontColor:E,tooltipId:A}=a,S=C({color:c,fontFamily:h,fontSize:u,fontWeight:p}),k="vertical"===a.orientation,M=k?m(0,v/2):m(v/2,0);M.attr("style",S);const $=(null==o?void 0:o.nodes())||[],T=(null==o?void 0:o.edges())||[],L=m();T.forEach((e=>{this.buildEdge(t,e,L)})),M.add(L);const N=m();N.node.setAttribute("role","list"),N.node.setAttribute("aria-label",r.nodesGroupLabel),$.forEach((t=>{const r=o.node(t);if(r.dummy)return;let a;if(l&&y){const n=o.inEdges(t)??[],i=o.outEdges(t)??[],s=n.reduce(((t,e)=>{var n;return t+((null==(n=o.edge(e.v,e.w,e.name))?void 0:n.value)??0)}),0),r=i.reduce(((t,e)=>{var n;return t+((null==(n=o.edge(e.v,e.w,e.name))?void 0:n.value)??0)}),0),d=Math.max(s,r);a={chartContext:e,isCustomTooltip:y!==Nt.nodeTooltipTemplate,nodeTooltipTemplate:y,nodeValue:d,tooltipBGColor:x,tooltipBorderColor:w,tooltipFontColor:E,tooltipId:A}}const m=ie(r,s,{fontColor:c,fontFamily:h,fontSize:u,fontWeight:p,isRtl:i,vertical:k,nodeBorderColor:g,nodeBorderWidth:f,nodeWidth:v,nodeTooltip:a,onNodeClick:b});if(m.node.setAttribute("data-node-id",t),m.node.setAttribute("data-node-rank",String(r.rank??0)),d&&(m.node.addEventListener("mouseenter",(()=>{d.isPinned()||d.highlightNode(t)})),m.node.addEventListener("mouseleave",(()=>d.reset())),m.node.addEventListener("click",(()=>d.togglePinFocusNode(t)))),n){const e=e=>o=>n.emit(e,{id:t,node:r,originalEvent:o});m.node.addEventListener("click",e("node:click")),m.node.addEventListener("mouseenter",e("node:mouseenter")),m.node.addEventListener("mouseleave",e("node:mouseleave"))}N.add(m)})),M.add(N);const F=this.buildAxisTitles(t);return F&&M.add(F),{mainGroup:M,edgesGroup:L,nodesGroup:N}}buildAxisTitles(t){const{graph:e,options:n}=t,o=n.axisTitles;if(!o||0===o.length)return null;const i="vertical"===n.orientation,s=((null==e?void 0:e.nodes())??[]).map((t=>e.node(t))).filter((t=>!t.dummy&&null!=t.x&&null!=t.y));if(0===s.length)return null;const r=Math.min(...s.map((t=>t.y??0))),a=new Map;for(const t of s){const e=t.rank??0;a.has(e)||a.set(e,{x:t.x??0,y:t.y??0})}const d=m();d.node.setAttribute("class","axis-titles"),d.node.setAttribute("aria-hidden","true");for(const[t,e]of a){const s=o[t];if(null==s||""===s)continue;const a=i?r-18:e.x,l=i?e.x:r-18,c=v(s,{fontColor:n.fontColor,pointerEvents:"none",textAnchor:i?"end":"middle",x:a,y:l});c.node.setAttribute("font-weight","600"),d.add(c)}return d}buildEdge(t,e,n){const{canvas:o,chartContext:i,events:s,graph:r,isRtl:a,options:d,pathHighlighter:l}=t,{edgeGradientFill:c,edgeOpacity:h,enableTooltip:u,fontFamily:p,fontSize:g,fontWeight:f,nodeWidth:v,tooltipBGColor:m,tooltipBorderColor:b,tooltipFontColor:x,tooltipId:w,tooltipTemplate:C}=d,k=r.edge(e.v,e.w,e.name),M=r.node(e.v),$=r.node(e.w),T=k.source,L=k.target;if(!T||!L)return;const N=a?-1:1;M.dummy&&(k.x0=(k.x0??0)-v/2*N),$.dummy&&(k.x1=(k.x1??0)+v/2*N);const F=ne(k,"vertical"===d.orientation);if(!F)return;const R=y(F,{edgeColor:o.gradient("linear",(t=>{var e,n,o;t.stop(0,(null==(e=T.data)?void 0:e.color)??""),t.stop(1,c?(null==(n=L.data)?void 0:n.color)??"":(null==(o=T.data)?void 0:o.color)??"")})),id:`${e.v}-${e.w}`,opacity:h});R.node.setAttribute("data-edge-source",e.v),R.node.setAttribute("data-edge-target",e.w),void 0!==e.name&&R.node.setAttribute("data-edge-name",e.name);if(($.rank??0)<(M.rank??0)&&(R.node.setAttribute("data-edge-reversed","true"),R.node.style.opacity="1",R.node.setAttribute("fill-opacity",String(h)),R.node.setAttribute("stroke","#475569"),R.node.setAttribute("stroke-width","1.5"),R.node.setAttribute("stroke-opacity","0.85"),R.node.setAttribute("stroke-dasharray","7 5")),l){const t=e.v,n=e.w;R.on("mouseenter",(()=>{l.isPinned()||l.highlightEdge(t,n)})),R.on("mouseleave",(()=>l.reset())),R.on("click",(()=>l.togglePinFocusEdge(t,n)))}if(s){const t=t=>n=>s.emit(t,{source:e.v,target:e.w,value:k.value??0,originalEvent:n});R.on("click",t("edge:click")),R.on("mouseenter",t("edge:mouseenter")),R.on("mouseleave",t("edge:mouseleave"))}if(u&&T.data&&L.data){const t=C?C({source:T.data,target:L.data,value:k.value}):`${T.data.title} → ${L.data.title}: ${k.value}`,e=C!==Nt.tooltipTemplate;R.on("mouseover",(n=>{const{pageX:o,pageY:s}=n,r=S({bgColor:e?void 0:m,borderColor:e?void 0:b,fontColor:e?void 0:x,fontFamily:e?void 0:p,fontSize:e?void 0:g,fontWeight:e?void 0:f,x:o,y:s});A(i,w,r,t,!0)})),R.on("mousemove",(n=>{const{pageX:o,pageY:s}=n,r=S({bgColor:e?void 0:m,borderColor:e?void 0:b,fontColor:e?void 0:x,fontFamily:e?void 0:p,fontSize:e?void 0:g,fontWeight:e?void 0:f,x:o,y:s});A(i,w,r,t,!0)})),R.on("mouseout",(()=>{E(i,w).style.display="none"}))}n.add(R)}}class re{constructor(t,e,n){this.svg=t,this.graph=e,this.options=n,this.baseline=new Map,this.downHandlers=new Map,this.active=null}attach(){for(const t of this.graph.nodes()){const e=this.graph.node(t);e.dummy||this.baseline.set(t,{x:e.x??0,y:e.y??0})}this.svg.querySelectorAll("[data-node-id]").forEach((t=>{const e=t.getAttribute("data-node-id");if(!e)return;t.style.cursor="grab",t.style.touchAction="none";const n=n=>this.onDown(n,e,t);this.downHandlers.set(t,n),t.addEventListener("pointerdown",n)}))}destroy(){this.active&&this.endDrag(this.active,!1),this.downHandlers.forEach(((t,e)=>e.removeEventListener("pointerdown",t))),this.downHandlers.clear(),this.baseline.clear()}onDown(t,e,n){if(this.active)return;if(0!==t.button)return;t.stopPropagation(),t.preventDefault();const o="function"==typeof this.svg.getScreenCTM?this.svg.getScreenCTM():null,i=(null==o?void 0:o.a)||1,s=(null==o?void 0:o.d)||1;"function"==typeof n.getAnimations&&n.getAnimations().forEach((t=>t.cancel())),n.style.opacity="",n.style.transform="";const r=this.collectConnections(e),a=this.graph.node(e),d={id:e,el:n,pointerId:t.pointerId,scaleX:i,scaleY:s,clientX:t.clientX,clientY:t.clientY,nodeStartX:a.x??0,nodeStartY:a.y??0,conns:r,moved:!1,onMove:t=>this.onMove(t),onUp:t=>this.onUp(t)};this.active=d;try{n.setPointerCapture(t.pointerId)}catch{}n.style.cursor="grabbing",n.addEventListener("pointermove",d.onMove),n.addEventListener("pointerup",d.onUp),n.addEventListener("pointercancel",d.onUp)}collectConnections(t){const e=[],n=(t,n,o,i)=>{const s=this.graph.edge(t,n,o),r=null==s?void 0:s.points;if(!r||0===r.length)return;const a="first"===i?r[0]:r[r.length-1],d=this.findEdgeEl(t,n,o);d&&e.push({el:d,label:s,point:a,startX:a.x??0,startY:a.y??0})};for(const e of this.graph.outEdges(t)??[])n(e.v,e.w,e.name,"first");for(const e of this.graph.inEdges(t)??[])n(e.v,e.w,e.name,"last");return e}findEdgeEl(t,e,n){const o=`[data-edge-source="${t}"][data-edge-target="${e}"]`,i=void 0===n?o:`${o}[data-edge-name="${n}"]`;return this.svg.querySelector(i)}onMove(t){var e,n;const o=this.active;if(!o||t.pointerId!==o.pointerId)return;const i=(t.clientX-o.clientX)/o.scaleX,s=(t.clientY-o.clientY)/o.scaleY;!o.moved&&Math.abs(t.clientX-o.clientX)+Math.abs(t.clientY-o.clientY)>3&&(o.moved=!0);const{gx:r,gy:a}=function(t,e,n){return t?{gx:n,gy:e}:{gx:e,gy:n}}(this.options.vertical,i,s),d=this.graph.node(o.id);d.x=o.nodeStartX+r,d.y=o.nodeStartY+a;for(const t of o.conns)t.point.x=t.startX+r,t.point.y=t.startY+a,t.el.setAttribute("d",ne(t.label,this.options.vertical)??"");const l=this.baseline.get(o.id)??{x:0,y:0},c=this.options.vertical?(d.y??0)-l.y:(d.x??0)-l.x,h=this.options.vertical?(d.x??0)-l.x:(d.y??0)-l.y;o.el.setAttribute("transform",`translate(${c} ${h})`),null==(n=(e=this.options).onNodeDrag)||n.call(e,o.id,d,"move")}onUp(t){var e,n;const o=this.active;o&&t.pointerId===o.pointerId&&(this.endDrag(o,o.moved),o.moved&&(null==(n=(e=this.options).onNodeDrag)||n.call(e,o.id,this.graph.node(o.id),"end")))}endDrag(t,e){t.el.removeEventListener("pointermove",t.onMove),t.el.removeEventListener("pointerup",t.onUp),t.el.removeEventListener("pointercancel",t.onUp);try{t.el.releasePointerCapture(t.pointerId)}catch{}if(t.el.style.cursor="grab",e){const e=t=>{t.stopImmediatePropagation(),t.preventDefault()};t.el.addEventListener("click",e,{capture:!0,once:!0})}this.active=null}}const ae="http://www.w3.org/2000/svg";function de(t,e){const n=t.length-1;if(n<=0)return t[0]??{x:0,y:0};const o=e*n;let i=Math.floor(o);i>=n&&(i=n-1),i<0&&(i=0);const s=o-i,r=t[i],a=t[i+1];return{x:r.x+(a.x-r.x)*s,y:r.y+(a.y-r.y)*s}}class le{constructor(t,e,n){this.mainGroup=t,this.graph=e,this.options=n,this.group=null,this.edges=[],this.raf=0,this.lastTs=null}start(){if(this.prefersReducedMotion())return;const t=this.mainGroup.ownerSVGElement;if(!t)return;const e=document.createElementNS(ae,"path");if(e.setAttribute("fill","none"),e.setAttribute("stroke","none"),"function"!=typeof e.getTotalLength||"function"!=typeof e.getPointAtLength)return;t.appendChild(e);const n=document.createElementNS(ae,"g");n.setAttribute("class","apexsankey-particles"),n.setAttribute("aria-hidden","true"),n.style.pointerEvents="none",this.group=n;let o=0;for(const t of this.graph.edges()){if(o>=600)break;const i=this.graph.edge(t.v,t.w,t.name),s=(null==i?void 0:i.dy)??0;if(s<=0)continue;const r=ee(i,this.options.vertical);if(!r)continue;e.setAttribute("d",r);const a=e.getTotalLength();if(!a||!Number.isFinite(a))continue;const d=Math.max(10,Math.min(80,Math.round(a/10))),l=[];for(let t=0;t<=d;t++){const n=e.getPointAtLength(a*t/d);l.push({x:n.x,y:n.y})}const c=Math.max(1,Math.min(16,Math.round(s/9))),h=[],u=[];for(let t=0;t<c&&o<600;t++,o++){const e=document.createElementNS(ae,"circle");e.setAttribute("r",String(1.9)),e.setAttribute("fill","rgba(255,255,255,0.9)"),n.appendChild(e),h.push(e),u.push((t+.6*Math.random())/c)}this.edges.push({pts:l,length:a,circles:h,t:u})}t.removeChild(e),this.edges.length?(this.paint(),this.mainGroup.appendChild(n),this.raf=requestAnimationFrame((t=>this.tick(t)))):this.group=null}destroy(){var t;this.raf&&cancelAnimationFrame(this.raf),this.raf=0,null==(t=this.group)||t.remove(),this.group=null,this.edges=[],this.lastTs=null}tick(t){if(!this.group)return;const e=null===this.lastTs?0:Math.min(.05,(t-this.lastTs)/1e3);this.lastTs=t;for(const t of this.edges){const n=t.length>0?63*e/t.length:0;for(let e=0;e<t.t.length;e++){let o=t.t[e]+n;o>=1&&(o-=Math.floor(o)),t.t[e]=o}}this.paint(),this.raf=requestAnimationFrame((t=>this.tick(t)))}paint(){for(const t of this.edges)for(let e=0;e<t.circles.length;e++){const n=de(t.pts,t.t[e]);t.circles[e].setAttribute("cx",String(n.x)),t.circles[e].setAttribute("cy",String(n.y))}}prefersReducedMotion(){return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}}function ce(t,e,n,o){return[t+n*Math.cos(o),e+n*Math.sin(o)]}const he=t=>(Math.round(100*t)/100).toString();function ue(t,e,n,o,i,s,r=0){const a=s-i>Math.PI?1:0,d=Math.max(0,Math.min(r,o-n,o*(s-i)/2));if(d<=0){const[r,d]=ce(t,e,o,i),[l,c]=ce(t,e,o,s),[h,u]=ce(t,e,n,s),[p,g]=ce(t,e,n,i);return`M${he(r)},${he(d)} A${he(o)},${he(o)} 0 ${a} 1 ${he(l)},${he(c)} L${he(h)},${he(u)} A${he(n)},${he(n)} 0 ${a} 0 ${he(p)},${he(g)} Z`}const l=d/o,c=s-l-(i+l)>Math.PI?1:0,[h,u]=ce(t,e,o,i+l),[p,g]=ce(t,e,o,s-l),[f,v]=ce(t,e,o-d,s),[m,y]=ce(t,e,n,s),[b,x]=ce(t,e,n,i),[w,E]=ce(t,e,o-d,i),A=he(d);return`M${he(h)},${he(u)} A${he(o)},${he(o)} 0 ${c} 1 ${he(p)},${he(g)} A${A},${A} 0 0 1 ${he(f)},${he(v)} L${he(m)},${he(y)} A${he(n)},${he(n)} 0 ${a} 0 ${he(b)},${he(x)} L${he(w)},${he(E)} A${A},${A} 0 0 1 ${he(h)},${he(u)} Z`}function pe(t,e,n,o,i,s,r){const a=i-o>Math.PI?1:0,d=r-s>Math.PI?1:0,[l,c]=ce(t,e,n,o),[h,u]=ce(t,e,n,i),[p,g]=ce(t,e,n,s),[f,v]=ce(t,e,n,r);return`M${he(l)},${he(c)} A${he(n)},${he(n)} 0 ${a} 1 ${he(h)},${he(u)} Q${he(t)},${he(e)} ${he(p)},${he(g)} A${he(n)},${he(n)} 0 ${d} 1 ${he(f)},${he(v)} Q${he(t)},${he(e)} ${he(l)},${he(c)} Z`}class ge{build(t){const{chartContext:e,events:n,layout:o,options:i}=t,{center:s,innerRadius:r,outerRadius:a,arcs:d,ribbons:l}=o,{fontColor:c,fontFamily:h,fontSize:u,fontWeight:p,edgeOpacity:g,dimOpacity:f,enableTooltip:b,arcCornerRadius:x}=i,w=m();w.attr("style",C({color:c,fontFamily:h,fontSize:u,fontWeight:p}));const E=new Map(d.map((t=>[t.id,{title:t.title,color:t.color}]))),A=new Map(d.map((t=>[t.id,0])));for(const t of l)A.set(t.source,(A.get(t.source)??0)+t.value),A.set(t.target,(A.get(t.target)??0)+t.value);const S=[],k=m();for(const e of l){const o=y(pe(s.x,s.y,r,e.s0,e.s1,e.t0,e.t1),{opacity:g,id:`${e.source}-${e.target}`});o.node.setAttribute("fill",e.sourceColor),o.node.setAttribute("data-edge-source",e.source),o.node.setAttribute("data-edge-target",e.target),k.add(o),S.push({source:e.source,target:e.target,el:o.node}),b&&this.wireTooltip(t,o.node,(()=>this.edgeTooltip(t,e.source,e.target,e.value,E))),n&&o.node.addEventListener("click",(t=>n.emit("edge:click",{source:e.source,target:e.target,value:e.value,originalEvent:t})))}w.add(k);const M=[],$=m();for(const e of d){const o=y(ue(s.x,s.y,r,a,e.startAngle,e.endAngle,x??0),{opacity:1});o.node.setAttribute("fill",e.color),o.node.setAttribute("data-node-id",e.id),$.add(o),M.push({id:e.id,el:o.node}),b&&this.wireTooltip(t,o.node,(()=>this.nodeTooltip(t,e.id,E,A.get(e.id)??0))),n&&o.node.addEventListener("click",(t=>n.emit("node:click",{id:e.id,node:{data:{id:e.id,title:e.title,color:e.color}},originalEvent:t})));const i=(e.startAngle+e.endAngle)/2;if(e.endAngle-e.startAngle>=.06){const[t,n]=(T=s.x,L=s.y,ce(T,L,a+10,i)),o=Math.cos(i)>=0,r=v(e.title,{fontColor:c,pointerEvents:"none",textAnchor:o?"start":"end",x:t,y:n});r.node.setAttribute("dominant-baseline","central"),$.add(r)}}var T,L;return w.add($),this.wireHoverFocus(S,M,g,f),{mainGroup:w}}wireHoverFocus(t,e,n,o){const i=(t,e)=>{t.style.transition="opacity 0.15s ease",t.style.opacity=String(e)},s=()=>{t.forEach((t=>i(t.el,n))),e.forEach((t=>i(t.el,1)))};e.forEach((r=>{r.el.addEventListener("mouseenter",(()=>(s=>{const r=new Set([s]);t.forEach((t=>{const e=t.source===s||t.target===s;i(t.el,e?Math.min(1,n+.35):o*n),e&&r.add(t.source).add(t.target)})),e.forEach((t=>i(t.el,r.has(t.id)?1:o)))})(r.id))),r.el.addEventListener("mouseleave",s)})),t.forEach((r=>{r.el.addEventListener("mouseenter",(()=>{t.forEach((t=>i(t.el,t===r?Math.min(1,n+.35):o*n))),e.forEach((t=>i(t.el,t.id===r.source||t.id===r.target?1:o)))})),r.el.addEventListener("mouseleave",s)}))}edgeTooltip(t,e,n,o,i){const{tooltipTemplate:s}=t.options,r=i.get(e),a=i.get(n);return s?s({source:{id:e,...r},target:{id:n,...a},value:o}):`${(null==r?void 0:r.title)??e} → ${(null==a?void 0:a.title)??n}: ${o}`}nodeTooltip(t,e,n,o){const{nodeTooltipTemplate:i}=t.options,s=n.get(e);return i?i({node:{id:e,...s},value:o}):`${(null==s?void 0:s.title)??e}: ${o}`}wireTooltip(t,e,n){const{chartContext:o,options:i}=t,{fontFamily:s,fontSize:r,fontWeight:a,tooltipBGColor:d,tooltipBorderColor:l,tooltipFontColor:c,tooltipId:h,tooltipTemplate:u,nodeTooltipTemplate:p}=i,g=u!==Nt.tooltipTemplate||p!==Nt.nodeTooltipTemplate,f=t=>{const{pageX:e,pageY:i}=t,u=S({bgColor:g?void 0:d,borderColor:g?void 0:l,fontColor:g?void 0:c,fontFamily:g?void 0:s,fontSize:g?void 0:r,fontWeight:g?void 0:a,x:e,y:i});A(o,h,u,n(),!0)};e.addEventListener("mouseover",f),e.addEventListener("mousemove",f),e.addEventListener("mouseout",(()=>{E(o,h).style.display="none"}))}}const fe=-Math.PI/2;class ve{constructor(t={}){this.onFrame=null,this.reducedMotion=t.reducedMotion??!1,this.scene=new K({spring:t.spring,rest:t.rest,reducedMotion:this.reducedMotion,clock:{now:t.now,raf:t.raf,caf:t.caf},onFrame:()=>this.emit()})}has(t){return this.scene.has(t)}positionOf(t){const e=this.scene.valuesOf(t);return e?me(e):void 0}retarget(t,e,n){if(this.scene.has(t))n&&this.scene.snap(t,{x:n.x,y:n.y});else{const o=n??e;this.scene.add(t,{x:o.x,y:o.y},void 0)}this.scene.retarget(t,{x:e.x,y:e.y})}snap(t,e){this.scene.has(t)?this.scene.snap(t,{x:e.x,y:e.y}):this.scene.add(t,{x:e.x,y:e.y},void 0)}remove(t){this.scene.remove(t)}reset(){this.scene.clear()}dispose(){this.scene.dispose()}atRest(){return this.scene.atRest()}step(t){return this.scene.step(t)}start(t){t&&(this.onFrame=t),this.reducedMotion?this.scene.writeAll():this.scene.start()}stop(){this.scene.stop()}emit(){if(!this.onFrame)return;const t=new Map;for(const e of this.scene.ids()){const n=this.scene.valuesOf(e);n&&t.set(e,me(n))}this.onFrame(t)}}function me(t){const{x:e,y:n}=t;return{x:e,y:n}}function ye(t,e,n){return void 0===n?`${t}\0${e}`:`${t}\0${e}\0${n}`}function be(t){const e=new Map;for(const n of t.nodes()){const o=t.node(n);e.set(n,{x:o.x??0,y:o.y??0,dy:o.dy??0})}const n=new Map;for(const e of t.edges()){const o=t.edge(e.v,e.w,e.name);n.set(ye(e.v,e.w,e.name),{v:e.v,w:e.w,x0:o.x0??0,y0:o.y0??0,x1:o.x1??0,y1:o.y1??0,dy:o.dy??0,points:(o.points??[]).map((t=>({x:t.x??0,y:t.y??0})))})}return{nodes:e,edges:n}}function xe(t,e,n){const o=new Map;for(const[i,s]of t.nodes)o.set(i,e.has(i)?{x:n.x,y:n.y,dy:s.dy}:{x:s.x,y:s.y,dy:s.dy});const i=new Map;for(const[o,s]of t.edges){const t=e.has(s.v),r=e.has(s.w),a=s.points.map((t=>({x:t.x,y:t.y})));(t||r)&&a.length&&(t&&(a[0]={x:n.x,y:n.y}),r&&(a[a.length-1]={x:n.x,y:n.y})),i.set(o,{v:s.v,w:s.w,x0:t?n.x:s.x0,y0:t?n.y:s.y0,x1:r?n.x:s.x1,y1:r?n.y:s.y1,dy:s.dy,points:a})}return{nodes:o,edges:i}}const we=(t,e,n)=>t+(e-t)*n;function Ee(t,e,n,o){for(const i of t.nodes()){const s=e.nodes.get(i),r=n.nodes.get(i);if(!s||!r)continue;const a=t.node(i);a.x=we(s.x,r.x,o),a.y=we(s.y,r.y,o),a.dy=we(s.dy,r.dy,o)}for(const i of t.edges()){const s=ye(i.v,i.w,i.name),r=e.edges.get(s),a=n.edges.get(s);if(!r||!a)continue;const d=t.edge(i.v,i.w,i.name);if(d.x0=we(r.x0,a.x0,o),d.y0=we(r.y0,a.y0,o),d.x1=we(r.x1,a.x1,o),d.y1=we(r.y1,a.y1,o),d.dy=we(r.dy,a.dy,o),d.points)for(let t=0;t<d.points.length;t++){const e=r.points[t],n=a.points[t];e&&n&&(d.points[t].x=we(e.x,n.x,o),d.points[t].y=we(e.y,n.y,o))}}}const Ae=[120,20];class Ce extends Bt{constructor(t,e,n,o){super(t,e,n),this.events=o,this.a11yHelper=null,this.pathHighlighter=null,this.nodeDrag=null,this.particleFlow=null,this._hasAnimated=!1,this.renderer=new se,this.lastGeometry=null,this.relayoutMotion=null,this.currentMainGroup=null,this.chordRenderer=new ge,this.chordData=null,this.renderOptions=e,this.messages=Rt(e)}getMessages(){return this.messages}get isRtl(){var t;return function(t,e){var n;if("rtl"===t)return!0;if("ltr"===t)return!1;if("undefined"==typeof window||"undefined"==typeof document)return!1;if(e){const t=e.closest('[dir="rtl"], [dir="ltr"]');return t?"rtl"===t.getAttribute("dir"):"rtl"===window.getComputedStyle(e).direction}return"rtl"===((null==(n=document.documentElement)?void 0:n.getAttribute("dir"))??document.dir)}((null==(t=this.options.locale)?void 0:t.direction)??"ltr",this.element)}construct(t){var e;if("chord"===this.options.type)return void this.constructChord(t);const{edgeGap:n,nodeWidth:o,spacing:i,viewPortHeight:s,viewPortWidth:r,whitespace:a}=this.options,d=Tt({edgeGap:n,nodeWidth:o,whitespace:a}),l="vertical"===this.options.orientation;d.size(l?[s-o,r-i]:[r-o,s-i]);const c=(null==(e=this.options.nodePalette)?void 0:e.length)?this.options.nodePalette:Lt,h=t.nodes.map(((t,e)=>{const n=e%c.length;return{...t,color:t.color??c[n],colorIndex:n}})),u=d(t.edges,h);this.maxRank=(d.order()??[]).length-1,this.graph=u,this.isRtl&&!l&&this.mirrorLayoutForRtl()}constructChord(t){var e;const n=(null==(e=this.options.nodePalette)?void 0:e.length)?this.options.nodePalette:Lt,o=t.nodes.map(((t,e)=>({id:t.id,title:t.title??t.id,color:t.color??n[e%n.length]}))),i=t.edges.map((t=>({source:t.source,target:t.target,value:t.value})));this.chordData={nodes:o,edges:i}}mirrorLayoutForRtl(){const t=this.graph.nodes();let e=1/0,n=-1/0;for(const o of t){const t=this.graph.node(o).x;void 0!==t&&(e=Math.min(e,t),n=Math.max(n,t))}if(!Number.isFinite(e))return;const o=e+n;for(const e of t){const t=this.graph.node(e);void 0!==t.x&&(t.x=o-t.x)}for(const t of this.graph.edges()){const e=this.graph.edge(t.v,t.w,t.name);if(void 0!==e.x0&&(e.x0=o-e.x0),void 0!==e.x1&&(e.x1=o-e.x1),e.points)for(const t of e.points)void 0!==t.x&&(t.x=o-t.x)}}render({keepOldPosition:t=!1}={}){var e,n,o;if("chord"===this.options.type)return void this.renderChord();this.renderOptions=It(this.element,this.options);const{tooltipTheme:i,tooltipBGColor:s,tooltipBorderColor:r,tooltipFontColor:a}=this.renderOptions;"dark"===i?this.renderOptions={...this.renderOptions,tooltipBGColor:"#1e2433",tooltipBorderColor:"#374151",tooltipFontColor:"#e5e7eb"}:"light"===i&&(this.renderOptions={...this.renderOptions,tooltipBGColor:s,tooltipBorderColor:r,tooltipFontColor:a});const{dimOpacity:d,enableTooltip:l,highlightConnectedPath:c,tooltipId:h}=this.renderOptions,u=this.canvas.viewbox();this.clear(),this.pathHighlighter=c?new _t(this.canvas.node,this.graph,d):null;const{mainGroup:p,edgesGroup:g,nodesGroup:f}=this.renderer.build({canvas:this.canvas,chartContext:this.chartContext,events:this.events,graph:this.graph,isRtl:this.isRtl,maxRank:this.maxRank,messages:this.messages,options:this.renderOptions,pathHighlighter:this.pathHighlighter});this.add(p),this.currentMainGroup=p;const{animation:v}=this.renderOptions;if((null==v?void 0:v.enabled)&&!this._hasAnimated&&(this._hasAnimated=!0,function(t,e,n,o,i){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const s=t.viewBox.baseVal,r=s.width,a=s.x,d=t.querySelector("defs")??(()=>{const e=document.createElementNS(Xt,"defs");return t.insertBefore(e,t.firstChild),e})(),l=`sankey-flow-clip-${Math.random().toString(36).slice(2,9)}`,c=document.createElementNS(Xt,"clipPath");c.setAttribute("id",l);const h=document.createElementNS(Xt,"rect");h.setAttribute("x",String(a)),h.setAttribute("y","-9999"),h.setAttribute("height","99999"),h.setAttribute("width","0"),c.appendChild(h),d.appendChild(c),e.setAttribute("clip-path",`url(#${l})`);let u=null;requestAnimationFrame((function t(n){null===u&&(u=n);const o=n-u,s=Math.min(o/i,1),a=((d=s)<.5?2*d*d:(4-2*d)*d-1)*r;var d;h.setAttribute("width",String(a)),s<1?requestAnimationFrame(t):(e.removeAttribute("clip-path"),c.remove())}));const p=n.querySelectorAll("[data-node-rank]"),g=.1*i,f=.7*i-g,v=.45*i;p.forEach((t=>{const e=parseInt(t.getAttribute("data-node-rank")??"0",10),n=g+(o>0?e/o:0)*f;t.style.opacity="0";const i=t.animate([{opacity:"0",transform:"translateY(6px)"},{opacity:"1",transform:"translateY(0px)"}],{duration:v,delay:n,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"forwards"});i.onfinish=()=>{t.style.opacity="",t.style.transform="",i.cancel()}}))}(this.canvas.node,g.node,f.node,this.maxRank,v.duration)),t&&this.updateViewBox(u.x,u.y,u.width,u.height),l){const t=E(this.chartContext,h);this.chartContext.getAppendContainer().appendChild(t)}this.a11yHelper&&this.a11yHelper.destroy();const m=this.renderOptions.a11y;!1!==(null==m?void 0:m.enabled)&&(this.a11yHelper=new Ut(this.canvas.node,this.graph,m,h,this.pathHighlighter,this.messages),this.a11yHelper.apply()),null==(e=this.nodeDrag)||e.destroy(),this.nodeDrag=null,this.renderOptions.draggableNodes&&(this.nodeDrag=new re(this.canvas.node,this.graph,{vertical:"vertical"===this.renderOptions.orientation}),this.nodeDrag.attach()),null==(n=this.particleFlow)||n.destroy(),this.particleFlow=null,this.renderOptions.particleFlow&&(this.particleFlow=new le(p.node,this.graph,{vertical:"vertical"===this.renderOptions.orientation}),this.particleFlow.start()),this.lastGeometry=be(this.graph),null==(o=this.events)||o.emit("rendered")}renderChord(){var t;if(this.renderOptions=It(this.element,this.options),"dark"===this.renderOptions.tooltipTheme&&(this.renderOptions={...this.renderOptions,tooltipBGColor:"#1e2433",tooltipBorderColor:"#374151",tooltipFontColor:"#e5e7eb"}),this.clear(),!this.chordData)return;const{enableTooltip:e,nodeWidth:n,tooltipId:o,viewPortHeight:i,viewPortWidth:s}=this.renderOptions,r=function(t,e,n){const{width:o,height:i,nodeWidth:s}=n,r=n.padAngle??.04,a={x:o/2,y:i/2},d=Math.max(10,Math.min(o,i)/2-56),l=Math.max(5,d-Math.max(12,s)),c=e.filter((t=>t.source!==t.target&&t.value>0)),h=new Map(t.map(((t,e)=>[t.id,e]))),u=new Map(t.map((t=>[t.id,t.color]))),p=new Map(t.map((t=>[t.id,0])));for(const t of c)p.set(t.source,(p.get(t.source)??0)+t.value),p.set(t.target,(p.get(t.target)??0)+t.value);const g=t.filter((t=>(p.get(t.id)??0)>0)),f=g.reduce(((t,e)=>t+(p.get(e.id)??0)),0)||1,v=Math.max(0,2*Math.PI-g.length*r)/f,m=[],y=new Map;let b=fe;for(const t of g){const e=(p.get(t.id)??0)*v;m.push({id:t.id,title:t.title,color:t.color,startAngle:b,endAngle:b+e}),y.set(t.id,b),b+=e+r}const x=new Map;for(const t of g)x.set(t.id,[]);c.forEach(((t,e)=>{var n,o;null==(n=x.get(t.source))||n.push({edge:e,role:"s",other:h.get(t.target)??0}),null==(o=x.get(t.target))||o.push({edge:e,role:"t",other:h.get(t.source)??0})}));const w=[],E=[];for(const t of g){const e=(x.get(t.id)??[]).sort(((t,e)=>t.other-e.other||t.edge-e.edge));let n=y.get(t.id)??fe;for(const t of e){const e=c[t.edge].value*v,o=[n,n+e];"s"===t.role?w[t.edge]=o:E[t.edge]=o,n+=e}}return{center:a,outerRadius:d,innerRadius:l,arcs:m,ribbons:c.map(((t,e)=>{var n,o,i,s;return{index:e,source:t.source,target:t.target,value:t.value,sourceColor:u.get(t.source)??"#888888",targetColor:u.get(t.target)??"#888888",s0:(null==(n=w[e])?void 0:n[0])??0,s1:(null==(o=w[e])?void 0:o[1])??0,t0:(null==(i=E[e])?void 0:i[0])??0,t1:(null==(s=E[e])?void 0:s[1])??0}}))}}(this.chordData.nodes,this.chordData.edges,{width:s,height:i,nodeWidth:n}),{mainGroup:a}=this.chordRenderer.build({chartContext:this.chartContext,layout:r,options:this.renderOptions,events:this.events});if(this.add(a),this.currentMainGroup=a,e){const t=E(this.chartContext,o);this.chartContext.getAppendContainer().appendChild(t)}null==(t=this.events)||t.emit("rendered")}destroy(){var t,e,n,o;null==(t=this.relayoutMotion)||t.dispose(),this.relayoutMotion=null,null==(e=this.particleFlow)||e.destroy(),this.particleFlow=null,null==(n=this.nodeDrag)||n.destroy(),this.nodeDrag=null,null==(o=this.a11yHelper)||o.destroy(),this.a11yHelper=null}update(t,e){var n,o;if("chord"===this.options.type)return this.construct(t),void this.render();null==(n=this.particleFlow)||n.destroy(),this.particleFlow=null;const i=!1===(null==(o=this.renderOptions.animation)?void 0:o.enabled),s=null!==this.lastGeometry&&!i&&!this.prefersReducedMotion();if((null==e?void 0:e.shrinkInto)&&s){const n=be(this.graph),o=xe(n,new Set(e.shrinkInto.nodes),e.shrinkInto.anchor);return void this.animateGeometry(n,o,(()=>{this.construct(t),this.render()}),Ae)}const r=null!==this.lastGeometry?be(this.graph):null;this.construct(t);const a=be(this.graph),d=this.currentMainGroup;if(null===r||null===d||i||this.prefersReducedMotion())this.render();else if(null==e?void 0:e.growFrom){const t=xe(a,new Set(e.growFrom.nodes),e.growFrom.anchor);this.animateGeometry(t,a,(()=>{Ee(this.graph,t,a,1),this.render()}),Ae)}else!function(t,e){if(t.nodes.size!==e.nodes.size||t.edges.size!==e.edges.size)return!1;for(const n of t.nodes.keys())if(!e.nodes.has(n))return!1;for(const[n,o]of t.edges){const t=e.edges.get(n);if(!t||t.points.length!==o.points.length)return!1}return!0}(r,a)?this.morphGrow(r,a,d):this.animateRelayout(r,a)}animateRelayout(t,e){this.animateGeometry(t,e,(()=>{Ee(this.graph,t,e,1),this.render()}))}animateGeometry(t,e,n,o){var i;null==(i=this.relayoutMotion)||i.dispose();const s=new ve(o?{rest:j,spring:o}:{rest:j});this.relayoutMotion=s;let r=!1;s.retarget("t",{x:1,y:0},{x:0,y:0}),s.start((o=>{var i;if(s.atRest()){if(r)return;return r=!0,void n()}const a=(null==(i=o.get("t"))?void 0:i.x)??0;Ee(this.graph,t,e,a),this.drawGeometry()}))}buildLayer(){const{mainGroup:t}=this.renderer.build({canvas:this.canvas,chartContext:this.chartContext,graph:this.graph,isRtl:this.isRtl,maxRank:this.maxRank,messages:this.messages,options:this.renderOptions,pathHighlighter:null});return this.currentMainGroup=t,this.add(t),t}drawGeometry(){this.clear(),this.buildLayer()}morphGrow(t,e,n){var o;null==(o=this.relayoutMotion)||o.dispose(),this.hideSurvivorsOnOldLayer(n,e);const i=function(t,e){const n=new Map;for(const[o,i]of e.nodes){const e=t.nodes.get(o);n.set(o,e?{x:e.x,y:e.y,dy:e.dy}:{x:i.x,y:i.y,dy:0})}const o=new Map;for(const[i,s]of e.edges){const e=t.edges.get(i);if(e&&e.points.length===s.points.length)o.set(i,{v:s.v,w:s.w,x0:e.x0,y0:e.y0,x1:e.x1,y1:e.y1,dy:e.dy,points:e.points.map((t=>({x:t.x,y:t.y})))});else{const t=n.get(s.v),e=(null==t?void 0:t.x)??s.x0,r=(null==t?void 0:t.y)??s.y0;o.set(i,{v:s.v,w:s.w,x0:e,y0:r,x1:e,y1:r,dy:0,points:s.points.map((()=>({x:e,y:r})))})}}return{nodes:n,edges:o}}(t,e);Ee(this.graph,i,e,0);let s=this.buildLayer();const r=new ve({rest:j});this.relayoutMotion=r;let a=!1;r.retarget("t",{x:1,y:0},{x:0,y:0}),r.start((t=>{var o;if(r.atRest()){if(a)return;return a=!0,Ee(this.graph,i,e,1),void this.render()}const d=(null==(o=t.get("t"))?void 0:o.x)??0,l=d<0?0:d>1?1:d;n.node.setAttribute("opacity",String(1-l)),Ee(this.graph,i,e,l),s.node.remove(),s=this.buildLayer()}))}hideSurvivorsOnOldLayer(t,e){const n=t.node;n.querySelectorAll("[data-node-id]").forEach((t=>{e.nodes.has(t.getAttribute("data-node-id")??"")&&(t.style.opacity="0")})),n.querySelectorAll("[data-edge-source]").forEach((t=>{const n=t.getAttribute("data-edge-source")??"",o=t.getAttribute("data-edge-target")??"",i=t.getAttribute("data-edge-name"),s=null===i?ye(n,o):ye(n,o,i);e.edges.has(s)&&(t.style.opacity="0")}))}prefersReducedMotion(){return"undefined"==typeof window||"function"!=typeof window.matchMedia||window.matchMedia("(prefers-reduced-motion: reduce)").matches}}const Se={...{light:{nodePalette:["#6b9ece","#e07b7b","#7dba8f","#b09ed1","#e0b678","#6dbaba","#d17da8","#b5b56d","#c49a6d","#8fa4b8","#c98aa0","#94bf7d","#e0a08a","#7b9eb5","#a988a8"],fontColor:"#212121",edgeOpacity:.4,edgeGradientFill:!0,nodeBorderColor:null,canvasStyle:"border: 1px solid #caced0; box-sizing: border-box",tooltipTheme:"light"},dark:{nodePalette:["#2dd4bf","#7c83f0","#fb6f92","#38bdf8","#fbbf24","#a78bfa","#34d399","#f472b6","#5eead4","#93a6ff","#fca5a5","#fcd34d"],fontColor:"#e7eff4",edgeOpacity:.5,edgeGradientFill:!0,nodeBorderColor:null,canvasStyle:"background: #0e1a23; border: 1px solid #1f2f3a; box-sizing: border-box;",tooltipTheme:"dark"},midnight:{nodePalette:["#818cf8","#a78bfa","#c084fc","#f0abfc","#60a5fa","#38bdf8","#34d399","#fbbf24"],fontColor:"#c7d2fe",edgeOpacity:.55,edgeGradientFill:!0,nodeBorderColor:null,canvasStyle:"background: #0b1020; border: 1px solid #1e2749; box-sizing: border-box;",tooltipTheme:"dark"},mint:{nodePalette:["#10b981","#14b8a6","#0ea5e9","#34d399","#5eead4","#6ee7b7","#22d3ee","#84cc16"],fontColor:"#0f3d33",edgeOpacity:.4,edgeGradientFill:!0,nodeBorderColor:null,canvasStyle:"background: #f2fbf7; border: 1px solid #cbeee0; box-sizing: border-box;",tooltipTheme:"light"},sunset:{nodePalette:["#fb7185","#f97316","#f59e0b","#ef4444","#ec4899","#fbbf24","#fb923c","#e11d48"],fontColor:"#7c2d12",edgeOpacity:.42,edgeGradientFill:!0,nodeBorderColor:null,canvasStyle:"background: #fff7f0; border: 1px solid #f6d9c4; box-sizing: border-box;",tooltipTheme:"light"}}};const ke=["nodePalette","fontColor","edgeOpacity","edgeGradientFill","nodeBorderColor","canvasStyle","tooltipTheme"];function Me(t){if(!t)return{};const e="string"==typeof t?Se[t]:t;if(!e)return{};const n={};for(const t of ke){const o=e[t];void 0!==o&&(n[t]=o)}return n}class $e{constructor(){this.handlers=new Map}on(t,e){let n=this.handlers.get(t);return n||(n=new Set,this.handlers.set(t,n)),n.add(e),()=>this.off(t,e)}off(t,e){const n=this.handlers.get(t);n&&(n.delete(e),0===n.size&&this.handlers.delete(t))}emit(t,e){const n=this.handlers.get(t);if(n)for(const o of[...n])try{o(e)}catch(e){console.error(`ApexSankey: an event handler for "${t}" threw`,e)}}clear(){this.handlers.clear()}}const Te="http://www.w3.org/2000/svg",Le=250;const Ne=[[3.6,1,0],[2.8,.55,.05],[2,.3,.1]];function Fe(t={}){const e=t.trigger??"click",n=t.direction??"downstream",o=t.color??"#ffffff",i=t.duration??700,s=t.stagger??220;return{name:"path-trace",install(t){const r=t.chart;let a=null,d=0,l=0;const c=()=>{d&&cancelAnimationFrame(d),d=0,null==a||a.remove(),a=null},h=t=>{var e;if(c(),"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const h=r.graph,u=null==h?void 0:h.graph,p=null==(e=null==h?void 0:h.canvas)?void 0:e.node;if(!u||!p)return;const g=p.querySelector("[data-edge-source]"),f=null==g?void 0:g.parentNode;if(!f)return;const v=document.createElementNS(Te,"path");if("function"!=typeof v.getTotalLength)return;p.appendChild(v);const m="vertical"===r.options.orientation,y=function(t,e,n){const o=[],i=n=>{const i=new Set([e]);let s=[e],r=0;for(;s.length&&o.length<Le;){const e=[];for(const a of s){const s=n?t.outEdges(a)??[]:t.inEdges(a)??[];for(const t of s){o.push({v:t.v,w:t.w,name:t.name,depth:r,dir:n?1:-1});const s=n?t.w:t.v;i.has(s)||(i.add(s),e.push(s))}}s=e,r++}};return"upstream"!==n&&i(!0),"upstream"!==n&&"both"!==n||i(!1),o}(u,t,n),b=document.createElementNS(Te,"g");b.setAttribute("class","apexsankey-path-trace"),b.setAttribute("aria-hidden","true"),b.style.pointerEvents="none";const x=[];for(const t of y){const e=u.edge(t.v,t.w,t.name),n=e&&ee(e,m);if(!n)continue;v.setAttribute("d",n);const i=v.getTotalLength();if(!i||!Number.isFinite(i))continue;const r=Math.max(8,Math.min(60,Math.round(i/12))),a=[];for(let t=0;t<=r;t++){const e=v.getPointAtLength(i*t/r);a.push({x:e.x,y:e.y})}const d=Ne.map((([t,e])=>{const n=document.createElementNS(Te,"circle");return n.setAttribute("r",String(t)),n.setAttribute("fill",o),n.setAttribute("opacity","0"),n.dataset.opacity=String(e),t>3&&n.setAttribute("stroke","rgba(0,0,0,0.2)"),b.appendChild(n),n}));x.push({pts:a,startAt:t.depth*s,dir:t.dir,circles:d})}if(p.removeChild(v),!x.length)return;f.appendChild(b),a=b;const w=x.reduce(((t,e)=>Math.max(t,e.startAt+i)),0)+250,E=t=>{l||(l=t);const e=t-l;for(const t of x){const n=(e-t.startAt)/i;t.circles.forEach(((e,o)=>{const i=n-Ne[o][2];if(i<0||i>1)return void e.setAttribute("opacity","0");const s=de(t.pts,t.dir>0?i:1-i);e.setAttribute("cx",String(s.x)),e.setAttribute("cy",String(s.y)),e.setAttribute("opacity",e.dataset.opacity??"1")}))}if(e>=w)return c(),void(l=0);d=requestAnimationFrame(E)};l=0,d=requestAnimationFrame(E)},u="hover"===e?"node:mouseenter":"node:click";return t.on(u,(({id:t})=>h(t))),t.on("rendered",c),c}}}function Re(t){const{frames:e}=t,n=t.interval??1600,o=!1!==t.controls;return{name:"time-playback",install(i){var s,r;const a=i.chart,d=e.length-1;let l=0,c=!1,h=0,u=null;const p=()=>{const t=e[l];t&&a.update({nodes:t.nodes,edges:t.edges,options:a.options})},g=()=>{var t;u&&(u.slider.value=String(l),u.label.textContent=(null==(t=e[l])?void 0:t.label)??`Frame ${l+1} / ${e.length}`,u.button.textContent=c?"⏸":"▶",u.button.setAttribute("aria-label",c?"Pause":"Play"))},f=t=>{l=Math.max(0,Math.min(d,t)),p(),g()},v=()=>{h="undefined"!=typeof window?window.setTimeout(y,n):0};function m(){c=!1,h&&clearTimeout(h),h=0,g()}function y(){if(c){if(l>=d){if(!t.loop)return void m();l=0}else l++;p(),g(),v()}}const b=()=>{c||e.length<2||(l>=d&&!t.loop&&f(0),c=!0,g(),v())};if(o){u=function(t){const e=document.createElement("div");e.className="apexsankey-playback",e.style.cssText="display:flex;align-items:center;gap:10px;padding:8px 4px;font:inherit;font-size:13px;color:#334155;";const n=document.createElement("button");n.type="button",n.style.cssText="cursor:pointer;width:34px;height:28px;border:1px solid #cbd5e1;border-radius:6px;background:#fff;font-size:13px;line-height:1;";const o=document.createElement("input");o.type="range",o.min="0",o.max=String(Math.max(0,t-1)),o.step="1",o.value="0",o.setAttribute("aria-label","Time frame"),o.style.cssText="flex:1;cursor:pointer;";const i=document.createElement("span");return i.style.cssText="min-width:110px;text-align:right;font-variant-numeric:tabular-nums;",e.append(n,o,i),{bar:e,button:n,slider:o,label:i}}(e.length),u.button.addEventListener("click",(()=>c?m():b())),u.slider.addEventListener("input",(()=>{const t=Number((null==u?void 0:u.slider.value)??0);m(),f(t)}));const n=null==(r=null==(s=a.graph)?void 0:s.canvas)?void 0:r.node,o=(null==n?void 0:n.parentElement)??null;t.mount?t.mount.appendChild(u.bar):(null==o?void 0:o.parentElement)?o.parentElement.insertBefore(u.bar,o.nextSibling):null==o||o.appendChild(u.bar)}return g(),t.autoplay&&b(),()=>{m(),null==u||u.bar.remove()}}}}function Be(t,e,n){const o=new Set(n),i=new Map(e.map((t=>[t.id,t]))),s=new Map;for(const t of e)if(o.has(t.id))for(const e of t.children)s.set(e,t.id);const r=[],a=new Set;for(const e of t.nodes){const t=s.get(e.id);if(void 0===t){r.push(e);continue}if(a.has(t))continue;a.add(t);const n=i.get(t);n&&r.push(void 0!==n.color?{id:n.id,title:n.title,color:n.color}:{id:n.id,title:n.title})}const d=new Map;for(const e of t.edges){const t=s.get(e.source)??e.source,n=s.get(e.target)??e.target;if(t===n)continue;const o=`${t}\0${n}\0${e.type??""}`,i=d.get(o);i?d.set(o,{...i,value:i.value+e.value}):d.set(o,{...e,source:t,target:n})}return{nodes:r,edges:[...d.values()]}}function _e(t){const{edges:e,groups:n,nodes:o}=t,i={nodes:o,edges:e};return{name:"drill-down",install(e){const o=e.chart,s=new Set(n.map((t=>t.id))),r=new Map;for(const t of n)for(const e of t.children)r.set(e,t.id);const a=new Set(t.expanded??[]),d=()=>{const t=n.filter((t=>!a.has(t.id))).map((t=>t.id));return Be(i,n,t)},l=t=>{o.update({...d(),options:o.options},t)},c=t=>{var e;return(null==(e=n.find((e=>e.id===t)))?void 0:e.children)??[]},h=t=>{var e;const n=null==(e=o.graph)?void 0:e.graph,i=null==n?void 0:n.node(t);return void 0===(null==i?void 0:i.x)||void 0===i.y?null:{x:i.x,y:i.y}},u=()=>{var t,e;const n=null==(e=null==(t=o.graph)?void 0:t.canvas)?void 0:e.node;n&&n.querySelectorAll("[data-node-id]").forEach((t=>{t.style.cursor=(t=>{if(s.has(t))return!a.has(t);const e=r.get(t);return void 0!==e&&a.has(e)})(t.getAttribute("data-node-id")??"")?"pointer":""}))};e.on("rendered",u),e.on("node:click",(({id:t})=>{let e;if(s.has(t)&&!a.has(t)){const n=h(t),o=c(t);a.add(t),n&&o.length&&(e={growFrom:{anchor:n,nodes:o}})}else{const n=r.get(t);if(void 0===n||!a.has(n))return;const o=c(n),i=(t=>{const e=t.map(h).filter((t=>null!==t));if(!e.length)return null;const n=e.reduce(((t,e)=>({x:t.x+e.x,y:t.y+e.y})),{x:0,y:0});return{x:n.x/e.length,y:n.y/e.length}})(o);a.delete(n),i&&o.length&&(e={shrinkInto:{anchor:i,nodes:o}})}l(e)})),l(),u()}}}function Ie(t){var e;const{dimensions:n,records:o}=t,i=(null==(e=t.palette)?void 0:e.length)?t.palette:Lt,s=[],r=new Map,a=new Map;let d=0,l=0;const c=t=>{let e=a.get(t);return e||(e=i[d%i.length],d++,a.set(t,e)),e},h=(t,e)=>{const n=`${t}\0${e}`;let o=r.get(n);return o||(o="alluvial-"+l++,r.set(n,o),s.push({id:o,title:e,color:c(e)})),o},u=new Map;for(const t of o){const e=t.value??1;for(let o=0;o<n.length-1;o++){const i=t.values[n[o]],s=t.values[n[o+1]];if(null==i||null==s)continue;const r=h(o,i),a=h(o+1,s),d=`${r}${a}`,l=u.get(d);l?l.value+=e:u.set(d,{source:r,target:a,value:e,type:i})}}return{nodes:s,edges:[...u.values()]}}const Oe=(t,e,n)=>`${t}\0${e}\0${n}`;function De(t,e){const n=new Map(t.edges.map((t=>[Oe(t.source,t.target,t.type??""),t]))),o=new Map(e.edges.map((t=>[Oe(t.source,t.target,t.type??""),t]))),i=[];for(const t of e.edges){const e=Oe(t.source,t.target,t.type??""),o=n.get(e);i.push({source:t.source,target:t.target,type:t.type??"",status:void 0===o?"added":o.value===t.value?"unchanged":"changed",beforeValue:null==o?void 0:o.value,afterValue:t.value})}for(const e of t.edges){const t=Oe(e.source,e.target,e.type??"");o.has(t)||i.push({source:e.source,target:e.target,type:e.type??"",status:"removed",beforeValue:e.value})}const s=new Set(t.nodes.map((t=>t.id))),r=new Set(e.nodes.map((t=>t.id)));return{edges:i,addedNodes:e.nodes.filter((t=>!s.has(t.id))).map((t=>t.id)),removedNodes:t.nodes.filter((t=>!r.has(t.id))).map((t=>t.id))}}const Ge={added:"#16a34a",removed:"#dc2626",changed:"#d97706"};class Pe{constructor(t,e){this.element=t,this.config=e,this.root=null,this.teardowns=[],this.syncing=!1,this.entered=new Map,this.diff=De(e.before,e.after)}render(){const{after:t,before:e,options:n}=this.config,o={...Ge,...this.config.diffColors};this.element.innerHTML="";const i=document.createElement("div");i.className="apexsankey-comparison",i.style.cssText="display:flex;flex-direction:column;gap:12px;";const s=document.createElement("div");s.className="apexsankey-comparison-panels",s.style.cssText="display:flex;gap:16px;align-items:flex-start;",i.appendChild(s);const r=this.buildPanel(s,e.title),a=this.buildPanel(s,t.title);!1!==this.config.showLegend&&i.appendChild(this.buildLegend(o)),this.element.appendChild(i),this.root=i;const d={...n,width:"100%",height:(null==n?void 0:n.height)??420};if(this.before=new ze(r,{...d,tooltipId:"apexsankey-cmp-before"}),this.after=new ze(a,{...d,tooltipId:"apexsankey-cmp-after"}),this.before.render({nodes:e.nodes,edges:e.edges,options:this.before.options}),this.after.render({nodes:t.nodes,edges:t.edges,options:this.after.options}),!1!==this.config.showDiff){const t=(null==n?void 0:n.edgeOpacity)??.4;this.applyDiff(this.before,"before",o,t),this.applyDiff(this.after,"after",o,t)}return!1!==this.config.syncHighlight&&(this.link(this.before,this.after),this.link(this.after,this.before)),this}destroy(){var t,e,n;for(const t of this.teardowns.splice(0))t();null==(t=this.before)||t.destroy(),null==(e=this.after)||e.destroy(),this.before=void 0,this.after=void 0,this.entered.clear(),null==(n=this.root)||n.remove(),this.root=null}buildPanel(t,e){const n=document.createElement("div");if(n.style.cssText="flex:1;min-width:0;",e){const t=document.createElement("div");t.className="apexsankey-comparison-title",t.textContent=e,t.style.cssText="font-weight:600;font-size:13px;margin-bottom:6px;color:#334155;",n.appendChild(t)}const o=document.createElement("div");return n.appendChild(o),t.appendChild(n),o}buildLegend(t){const e=document.createElement("div");e.className="apexsankey-comparison-legend",e.style.cssText="display:flex;gap:16px;font-size:12px;color:#475569;align-items:center;flex-wrap:wrap;";const n=[["Added",t.added,!0],["Removed",t.removed,!0],["Changed",t.changed,!1]];for(const[t,o,i]of n){const n=document.createElement("span");n.style.cssText="display:inline-flex;align-items:center;gap:6px;";const s=document.createElement("span");s.style.cssText=`display:inline-block;width:20px;height:0;border-top:2px ${i?"dashed":"solid"} ${o};`,n.append(s,document.createTextNode(t)),e.appendChild(n)}return e}applyDiff(t,e,n,o){var i,s;const r=null==(s=null==(i=t.graph)?void 0:i.canvas)?void 0:s.node;if(r)for(const t of this.diff.edges){if(!("changed"===t.status||("before"===e?"removed"===t.status:"added"===t.status)))continue;const i=this.findEdge(r,t.source,t.target);if(!i)continue;const s=n[t.status];i.style.opacity="1",i.setAttribute("fill-opacity",String(o)),i.setAttribute("stroke",s),i.setAttribute("stroke-width","2"),i.setAttribute("stroke-opacity","0.9"),"changed"!==t.status&&i.setAttribute("stroke-dasharray","6 4"),i.setAttribute("data-diff",t.status)}}link(t,e){this.teardowns.push(t.on("node:mouseenter",(({id:t})=>this.syncEnter(e,(e=>this.findNode(e,t)))))),this.teardowns.push(t.on("node:mouseleave",(()=>this.syncLeave(e)))),this.teardowns.push(t.on("edge:mouseenter",(({source:t,target:n})=>this.syncEnter(e,(e=>this.findEdge(e,t,n)))))),this.teardowns.push(t.on("edge:mouseleave",(()=>this.syncLeave(e))))}syncEnter(t,e){var n,o;if(this.syncing)return;const i=null==(o=null==(n=t.graph)?void 0:n.canvas)?void 0:o.node,s=i&&e(i);if(s){this.syncLeave(t),this.syncing=!0;try{s.dispatchEvent(new MouseEvent("mouseenter"))}finally{this.syncing=!1}this.entered.set(t,s)}}syncLeave(t){const e=this.entered.get(t);if(e){this.entered.delete(t),this.syncing=!0;try{e.dispatchEvent(new MouseEvent("mouseleave"))}finally{this.syncing=!1}}}findNode(t,e){for(const n of Array.from(t.querySelectorAll("[data-node-id]")))if(n.getAttribute("data-node-id")===e)return n;return null}findEdge(t,e,n){for(const o of Array.from(t.querySelectorAll("[data-edge-source]")))if(o.getAttribute("data-edge-source")===e&&o.getAttribute("data-edge-target")===n)return o;return null}}const je=class extends o{constructor(t,e={}){super(t,"sankey_"+crypto.randomUUID().replace(/-/g,"").substring(0,9)),this.events=new $e,this.pluginTeardowns=[],this.isDestroyed=!1,this.options={...Nt,...Me(e.theme),...e};const{height:n,width:o}=this.options;this.graph=new Ce(this.element,this.options,this.chartContext,this.events),this.setupElementDimensions(o,n),this.handleWatermark()}static setLicense(t){B.setLicense(t)}static registerTheme(t,e){!function(t,e){Se[t]=e}(t,e)}static buildAlluvialData(t){return Ie(t)}static collapseGroups(t,e,n){return Be(t,e,n)}static compare(t,e){return new Pe(t,e).render()}setupElementDimensions(t,e){let n=!1,o=0;"string"==typeof t&&/^\d+(\.\d+)?%$/.test(t)?(o=Number(t.substring(0,t.length-1)),n=!0):o=Number(t);const i="auto"===e?o/1.6:e;this.element.style.width=`${o}${n?"%":"px"}`,this.element.style.height=`${i}${n?"%":"px"}`,this.element.style.position="relative"}handleWatermark(){this.element&&(B.isLicenseValid()?I.remove(this.element):I.add(this.element))}render(t){var e;if(!this.element)throw new Error("Element not found");if(O(this.element,(null==(e=this.options.locale)?void 0:e.direction)??"ltr"),this.graph.construct(t),this.graph.render(),this.options.enableToolbar){new x(this.element,this.chartContext).render({enableExport:!0,onExport:this.graph.exportToSvg.bind(this.graph)})}return this.graph}update(t,e){var n;if(!this.element)throw new Error("Element not found");return O(this.element,(null==(n=this.options.locale)?void 0:n.direction)??"ltr"),this.graph.update(t,e),this.graph}on(t,e){return this.events.on(t,e)}off(t,e){this.events.off(t,e)}use(t){const e={chart:this,on:(t,e)=>this.on(t,e)},n=t.install(e);return"function"==typeof n&&this.pluginTeardowns.push(n),this}destroy(){if(!this.isDestroyed){this.isDestroyed=!0;for(const t of this.pluginTeardowns.splice(0))try{t()}catch(t){console.error("ApexSankey: a plugin teardown threw",t)}this.events.emit("destroyed"),this.events.clear(),this.graph.destroy(),super.destroy()}}};je.plugins={pathTrace:Fe,timePlayback:Re,drillDown:_e};let ze=je;"undefined"!=typeof window&&(window.ApexSankey=ze),t.ApexSankey=ze,t.DEFAULT_SANKEY_MESSAGES=Ft,t.SankeyComparison=Pe,t.buildAlluvialData=Ie,t.collapseGroups=Be,t.default=ze,t.diffGraphs=De,t.drillDown=_e,t.pathTrace=Fe,t.timePlayback=Re,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));