apexsankey 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +65 -2
- package/README.md +5 -8
- package/apexsankey.d.ts +24 -24
- package/apexsankey.es.min.js +1 -1
- package/apexsankey.min.js +1 -1
- package/demo/basic-sankey.html +81 -64
- package/demo/css-theming.html +33 -17
- package/demo/sankey-alternate-node.html +93 -81
- package/demo/sankey-custom-fonts.html +78 -146
- package/demo/sankey-edge-options.html +205 -88
- package/demo/sankey-node-customization.html +83 -90
- package/demo/sankey-node-overlapping.html +158 -409
- package/demo/sankey-path-highlight.html +4 -4
- package/package.json +2 -2
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.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 r=document.createElement("style");if(r.id=e,r.textContent=t,"normal"!==i&&r.setAttribute("data-priority",i),this.context===document)document.head.appendChild(r);else{const t=this.context;"high"===i?t.insertBefore(r,t.firstChild):t.appendChild(r)}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}destroy(){this.removeAllStyles(),this.injectedStyles.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(){return this.canvas.svg().replace(/(<img [\w\W]+?)(>)/g,"$1 />").replace(/(<br)(>)/g,"$1 />").replace(/(<hr)(>)/g,"$1 />")}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 r=globalThis.console;const s=class{static decodeLicenseData(t){try{const e=window.atob(t),n=JSON.parse(e);return n.issueDate&&n.expiryDate&&n.plan?{domains:Array.isArray(n.domains)?n.domains:void 0,expiryDate:n.expiryDate,issueDate:n.issueDate,plan:n.plan,valid:!0}:null}catch{return null}}static generateLicenseKey(t,e,n="standard",o){const i={expiryDate:e,issueDate:t,plan:n};o&&o.length>0&&(i.domains=o);return`APEX-${window.btoa(JSON.stringify(i))}`}static getLicenseStatus(){return this.licenseKey?(this.validationResult||(this.validationResult=this.validateLicense(this.licenseKey)),this.validationResult):{expired:!1,valid:!1}}static isLicenseValid(){return!!this.licenseKey&&(this.validationResult||(this.validationResult=this.validateLicense(this.licenseKey)),this.validationResult.valid)}static setLicense(t){var e;this.licenseKey=t,this.validationResult=this.validateLicense(t),this.validationResult.valid||(e=`[Apex] ${this.validationResult.message}`,r.error(e))}static validateLicense(t){try{if(!t.startsWith("APEX-"))return{expired:!1,message:'Invalid license key format. License key must start with "APEX-".',valid:!1};const e=t.split("-");if(2!==e.length)return{expired:!1,message:"Invalid license key format. Expected format: APEX-{encoded-data}.",valid:!1};const n=e[1],o=this.decodeLicenseData(n);if(!o)return{expired:!1,message:"Invalid license key. Unable to decode license data.",valid:!1};const i=new Date;if(new Date(o.expiryDate)<i)return{data:o,expired:!0,message:`License expired on ${o.expiryDate}. Please renew your license.`,valid:!1};if(o.domains&&o.domains.length>0){const t="undefined"!=typeof window?window.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(", ")}.`,valid:!1}}return{data:o,expired:!1,valid:!0}}catch{return{expired:!1,message:"Invalid license key format or corrupted data.",valid:!1}}}};s.licenseKey=null,s.validationResult=null;let a=s;const d="http://www.w3.org/2000/svg";let l=0;class c{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 c?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 c(e):null}first(){const t=this.node.firstElementChild;return t?new c(t):null}}class h extends c{constructor(t){super(document.createElementNS(d,"g")),t&&this.attr(t)}}class u extends c{constructor(){super(document.createElementNS(d,"rect"))}}class p extends c{constructor(t){super(document.createElementNS(d,"path")),t&&this.attr(t)}}class g extends c{constructor(){super(document.createElementNS(d,"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(d,"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 f{constructor(t){this.gradient=t}stop(t,e){const n=document.createElementNS(d,"stop");n.setAttribute("offset",String(t)),n.setAttribute("stop-color",e??"transparent"),this.gradient.appendChild(n)}}function m(t,e){t.setAttribute("viewBox",`${e.x} ${e.y} ${e.w} ${e.h}`)}class v{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 c?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(d,"defs"),this.node.insertBefore(this._defs,this.node.firstChild));const n=document.createElementNS(d,"linearGradient"),o="apx-grad-"+ ++l;return n.setAttribute("id",o),n.setAttribute("x1","0%"),n.setAttribute("y1","0%"),n.setAttribute("x2","100%"),n.setAttribute("y2","0%"),e(new f(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={zoomFactor:e.zoomFactor??.2,zoomMin:e.zoomMin??.1,currentZoom:1,baseVb:{...n},vb:{...n}};t.addEventListener("wheel",(e=>{let n;if(e.preventDefault(),e.ctrlKey){const t=.005;n=1+Math.max(-.15,Math.min(.15,e.deltaY*t))}else n=e.deltaY<0?1-o.zoomFactor:1+o.zoomFactor;const i=o.currentZoom/n;if(i<o.zoomMin)return;const r=t.getBoundingClientRect(),s=(e.clientX-r.left)/r.width,a=(e.clientY-r.top)/r.height,{vb:d}=o,l=d.w*n,c=d.h*n,h=d.x+s*(d.w-l),u=d.y+a*(d.h-c);o.vb={x:h,y:u,w:l,h:c},o.currentZoom=i,m(t,o.vb)}),{passive:!1});let i=!1,r=!1,s=-1,a=0,d=0;t.addEventListener("pointerdown",(t=>{0===t.button&&(i=!0,r=!1,s=t.pointerId,a=t.clientX,d=t.clientY)})),t.addEventListener("pointermove",(e=>{if(!i||e.pointerId!==s)return;if(!r){const n=e.clientX-a,o=e.clientY-d;if(Math.abs(n)<4&&Math.abs(o)<4)return;r=!0,t.setPointerCapture(e.pointerId),t.style.cursor="grabbing"}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},m(t,o.vb),a=e.clientX,d=e.clientY}));const l=e=>{i&&e.pointerId===s&&(r&&(t.releasePointerCapture(e.pointerId),t.style.cursor=""),i=!1,r=!1,s=-1)};return t.addEventListener("pointerup",l),t.addEventListener("pointercancel",l),o}(this.node,t),this}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=1/t,i=n.baseVb.w*o,r=n.baseVb.h*o,s=n.baseVb.x+(n.baseVb.w-i)/2,a=n.baseVb.y+(n.baseVb.h-r)/2;return n.vb={x:s,y:a,w:i,h:r},n.currentZoom=t,m(this.node,n.vb),this}}function y(t,e,n,o){const i=new h;return i.attr({"data-parent":o,"data-self":n,transform:void 0!==t&&void 0!==e?`translate(${t}, ${e})`:void 0}),i}const b={export:"data:image/svg+xml,%3csvg%20fill='%23000000'%20width='20px'%20height='20px'%20viewBox='0%200%2024%2024'%20id='export-2'%20xmlns='http://www.w3.org/2000/svg'%20class='icon%20line'%3e%3cpolyline%20id='primary'%20points='15%203%2021%203%2021%209'%20style='fill:%20none;%20stroke:%20rgb(0,%200,%200);%20stroke-linecap:%20round;%20stroke-linejoin:%20round;%20stroke-width:%201.5;'%3e%3c/polyline%3e%3cpath%20id='primary-2'%20data-name='primary'%20d='M21,13v7a1,1,0,0,1-1,1H4a1,1,0,0,1-1-1V4A1,1,0,0,1,4,3h7'%20style='fill:%20none;%20stroke:%20rgb(0,%200,%200);%20stroke-linecap:%20round;%20stroke-linejoin:%20round;%20stroke-width:%201.5;'%3e%3c/path%3e%3cline%20id='primary-3'%20data-name='primary'%20x1='11'%20y1='13'%20x2='21'%20y2='3'%20style='fill:%20none;%20stroke:%20rgb(0,%200,%200);%20stroke-linecap:%20round;%20stroke-linejoin:%20round;%20stroke-width:%201.5;'%3e%3c/line%3e%3c/svg%3e","fit-screen":"data:image/svg+xml,%3csvg%20width='20px'%20height='20px'%20viewBox='0%200%2032%2032'%20id='icon'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpolygon%20points='8%202%202%202%202%208%204%208%204%204%208%204%208%202'/%3e%3cpolygon%20points='24%202%2030%202%2030%208%2028%208%2028%204%2024%204%2024%202'/%3e%3cpolygon%20points='8%2030%202%2030%202%2024%204%2024%204%2028%208%2028%208%2030'/%3e%3cpolygon%20points='24%2030%2030%2030%2030%2024%2028%2024%2028%2028%2024%2028%2024%2030'/%3e%3cpath%20d='M24,24H8a2.0023,2.0023,0,0,1-2-2V10A2.0023,2.0023,0,0,1,8,8H24a2.0023,2.0023,0,0,1,2,2V22A2.0023,2.0023,0,0,1,24,24ZM8,10V22H24V10Z'/%3e%3crect%20fill='none'%20width='32'%20height='32'/%3e%3c/svg%3e","zoom-in":"data:image/svg+xml,%3csvg%20width='20px'%20height='20px'%20viewBox='0%200%2032%2032'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20xmlns:sketch='http://www.bohemiancoding.com/sketch/ns'%3e%3cg%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%3e%3cg%20transform='translate(-308.000000,%20-1139.000000)'%20fill='%23000000'%3e%3cpath%20d='M321.46,1163.45%20C315.17,1163.45%20310.07,1158.44%20310.07,1152.25%20C310.07,1146.06%20315.17,1141.04%20321.46,1141.04%20C327.75,1141.04%20332.85,1146.06%20332.85,1152.25%20C332.85,1158.44%20327.75,1163.45%20321.46,1163.45%20L321.46,1163.45%20Z%20M339.688,1169.25%20L331.429,1161.12%20C333.592,1158.77%20334.92,1155.67%20334.92,1152.25%20C334.92,1144.93%20328.894,1139%20321.46,1139%20C314.026,1139%20308,1144.93%20308,1152.25%20C308,1159.56%20314.026,1165.49%20321.46,1165.49%20C324.672,1165.49%20327.618,1164.38%20329.932,1162.53%20L338.225,1170.69%20C338.629,1171.09%20339.284,1171.09%20339.688,1170.69%20C340.093,1170.3%20340.093,1169.65%20339.688,1169.25%20L339.688,1169.25%20Z%20M326.519,1151.41%20L322.522,1151.41%20L322.522,1147.41%20C322.522,1146.85%20322.075,1146.41%20321.523,1146.41%20C320.972,1146.41%20320.524,1146.85%20320.524,1147.41%20L320.524,1151.41%20L316.529,1151.41%20C315.978,1151.41%20315.53,1151.59%20315.53,1152.14%20C315.53,1152.7%20315.978,1153.41%20316.529,1153.41%20L320.524,1153.41%20L320.524,1157.41%20C320.524,1157.97%20320.972,1158.41%20321.523,1158.41%20C322.075,1158.41%20322.522,1157.97%20322.522,1157.41%20L322.522,1153.41%20L326.519,1153.41%20C327.07,1153.41%20327.518,1152.96%20327.518,1152.41%20C327.518,1151.86%20327.07,1151.41%20326.519,1151.41%20L326.519,1151.41%20Z'%20/%3e%3c/g%3e%3c/g%3e%3c/svg%3e","zoom-out":"data:image/svg+xml,%3csvg%20width='20px'%20height='20px'%20viewBox='0%200%2032%2032'%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cg%20stroke='none'%20stroke-width='1'%20fill='none'%20fill-rule='evenodd'%20%3e%3cg%20transform='translate(-360.000000,%20-1139.000000)'%20fill='%23000000'%3e%3cpath%20d='M373.46,1163.45%20C367.17,1163.45%20362.071,1158.44%20362.071,1152.25%20C362.071,1146.06%20367.17,1141.04%20373.46,1141.04%20C379.75,1141.04%20384.85,1146.06%20384.85,1152.25%20C384.85,1158.44%20379.75,1163.45%20373.46,1163.45%20L373.46,1163.45%20Z%20M391.688,1169.25%20L383.429,1161.12%20C385.592,1158.77%20386.92,1155.67%20386.92,1152.25%20C386.92,1144.93%20380.894,1139%20373.46,1139%20C366.026,1139%20360,1144.93%20360,1152.25%20C360,1159.56%20366.026,1165.49%20373.46,1165.49%20C376.672,1165.49%20379.618,1164.38%20381.932,1162.53%20L390.225,1170.69%20C390.629,1171.09%20391.284,1171.09%20391.688,1170.69%20C392.093,1170.3%20392.093,1169.65%20391.688,1169.25%20L391.688,1169.25%20Z%20M378.689,1151.41%20L368.643,1151.41%20C368.102,1151.41%20367.663,1151.84%20367.663,1152.37%20C367.663,1152.9%20368.102,1153.33%20368.643,1153.33%20L378.689,1153.33%20C379.23,1153.33%20379.669,1152.9%20379.669,1152.37%20C379.669,1151.84%20379.23,1151.41%20378.689,1151.41%20L378.689,1151.41%20Z'%20/%3e%3c/g%3e%3c/g%3e%3c/svg%3e"};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: 5px;\n position: absolute;\n right: 10px;\n top: 10px;\n z-index: 100;\n }\n \n .toolbar-item {\n align-items: center;\n background-color: var(--toolbar-bg-color, #FFFFFF);\n border: 1px solid var(--toolbar-border-color, #BCBCBC);\n cursor: pointer;\n display: flex;\n height: 30px;\n justify-content: center;\n width: 30px;\n border-radius: 3px;\n transition: all 0.2s ease;\n position: relative;\n }\n \n .toolbar-item:hover {\n background-color: var(--toolbar-hover-bg-color, #f8f9fa);\n border-color: var(--toolbar-border-color, #999);\n transform: translateY(-1px);\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\n }\n \n .toolbar-item:active {\n transform: translateY(0);\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);\n }\n \n .toolbar-item:focus {\n outline: none;\n border-color: var(--button-bg-color, #0066cc);\n box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.2);\n }\n \n .toolbar-item img {\n width: 16px;\n height: 16px;\n pointer-events: none;\n filter: var(--toolbar-icon-filter, none);\n }\n \n .toolbar-item[disabled] {\n opacity: 0.5;\n cursor: not-allowed;\n pointer-events: none;\n }\n \n /* Tooltip styles */\n .toolbar-item::after {\n content: attr(data-tooltip);\n position: absolute;\n bottom: -35px;\n left: 50%;\n transform: translateX(-50%);\n background: var(--tooltip-bg-color, #333);\n color: var(--tooltip-text-color, white);\n padding: 4px 8px;\n border-radius: 4px;\n font-size: 12px;\n white-space: nowrap;\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.2s ease;\n z-index: 1000;\n }\n \n .toolbar-item::before {\n content: '';\n position: absolute;\n bottom: -25px;\n left: 50%;\n transform: translateX(-50%);\n border: 5px solid transparent;\n border-bottom-color: var(--tooltip-bg-color, #333);\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.2s 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: 5px;\n position: absolute;\n right: 10px;\n top: 10px;\n z-index: 100;\n }\n",t)}createToolbarItem(t,e,n){const o=this.chartContext.createElement("div"),i=new Image;return i.src=e,i.alt=n||t,o.id=t,o.className="toolbar-item",o.setAttribute("role","button"),o.setAttribute("tabindex","0"),n&&(o.setAttribute("data-tooltip",n),o.setAttribute("aria-label",n)),o.append(i),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:r=e,onZoom:s=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",(()=>{s(.1)})),e.addEventListener("click",(()=>{s(-.1)})),d.append(t,e)}if(n){const t=this.createToolbarItem("fit-screen",b["fit-screen"],"Fit to screen");t.addEventListener("click",(()=>{r()})),d.append(t)}this.element.append(d)}destroy(){const t=this.chartContext.querySelector("#toolbar");null==t||t.remove()}}const w=class{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 add(t){this.remove(t);const e=document.createElement("div");e.setAttribute(this.WATERMARK_ATTR,""),Object.assign(e.style,{backgroundImage:this.createWatermarkPattern(),backgroundRepeat:"repeat",bottom:"0",left:"0",msUserSelect:"none",pointerEvents:"none",position:"absolute",right:"0",top:"0",userSelect:"none",webkitUserSelect:"none",zIndex:"10000"}),"static"===getComputedStyle(t).position&&(t.style.position="relative"),t.appendChild(e)}static exists(t){return!!t.querySelector(`[${this.WATERMARK_ATTR}]`)}static remove(t){const e=t.querySelector(`[${this.WATERMARK_ATTR}]`);e&&e.remove()}};w.WATERMARK_ATTR="data-apexcharts-watermark",w.WATERMARK_TEXT="APEXCHARTS";let E=w;const C="aria-hidden",A=(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(C,"true");t.getAppendContainer().appendChild(n)}return n},S=(t,e="",n,o="")=>{const i=t.getElementById(e);if(!i)return A(t,e),S(t,e,n,o);if(n&&o){const t=o.includes("tooltip-content"),e=n.match(/background-color:\s*([^;]+);?/),r=n.match(/color:\s*([^;]+);?/),s=e?e[1]:"#333",a=r?r[1]:"white";i.innerHTML=t?o:`<div class="tooltip-content" style="background-color: ${s}; color: ${a};">${o}</div>`;const d=n+"; display: block !important; visibility: visible !important; opacity: 1 !important;";i.setAttribute("style",d),i.classList.add("visible"),i.setAttribute(C,"false")}else i.removeAttribute("style"),i.classList.remove("visible"),i.setAttribute(C,"true"),i.innerHTML=""},k=({bgColor:t,borderColor:e,fontColor:n,fontFamily:o,fontSize:i,fontWeight:r,maxWidth:s,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};`),s&&(h.push(`width: ${s}px;`),h.push(`max-width: ${s}px;`)),e&&h.push(`border: 1px solid ${e};`),h.push("border-radius: 6px;"),h.push("box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);"),n&&h.push(`color: ${n};`),o&&h.push(`font-family: ${o};`),r&&h.push(`font-weight: ${r};`),i&&h.push(`font-size: ${i};`),t&&h.push(`background-color: ${t};`),void 0!==a&&h.push(`padding: ${a}px;`),h.join(" ")};function $(t,e){let n=null;for(let o=0;o<t.length;++o)if(e(t[o])){n=o;break}return n}function M(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 L(t){const e=t.edgeGap||0;return function(n){!function(t,e,n){t.nodes().forEach((o=>{const i=t.node(o),r=_(t,i.outgoing||[],"outgoing"),s=_(t,i.incoming||[],"incoming"),a=r.length,d=s.length,l=r.reduce(((e,n)=>e+(t.edge(n).dy??0)),0),c=s.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),r.forEach(((o,r)=>{const s=t.edge(o);s.x0=(i.x??0)+(e.nodeWidth??0)/2,s.y0=(i.y??0)+p+(s.dy??0)/2,s.d0=i.direction||"r",p+=s.dy??0,r<a-1&&(p+=n)})),s.forEach(((o,r)=>{const s=t.edge(o);s.x1=(i.x??0)-(e.nodeWidth??0)/2,s.y1=(i.y??0)+g+(s.dy??0)/2,s.d1=i.direction||"r",g+=s.dy??0,r<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))),B(o,"r0"),B(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 _(t,e,n){return e.slice().sort(((e,o)=>{let i,r;if("outgoing"===n){const n=t.node(e.w),s=t.node(o.w);i=(null==n?void 0:n.y)??0,r=(null==s?void 0:s.y)??0}else{const n=t.node(e.v),s=t.node(o.v);i=(null==n?void 0:n.y)??0,r=(null==s?void 0:s.y)??0}if(Math.abs(i-r)>.001)return i-r;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 B(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=$(t,"r0"===e?t=>(t.y1??0)>(t.y0??0):t=>(t.y0??0)>(t.y1??0));if(null===n&&(n=t.length),M(t.slice(n),e),n>0){const o=[];for(let e=n-1;e>=0;e--)o.push(t[e]);M(o,e)}}function T(t,e,n,o,i){if(0===o.length)return;const r=o.map((n=>{const o=`__${e.v}_${e.w}_${n}`;return t.setNode(o,{data:null,direction:i,dummy:!0,rank:n}),o})),s=[e.v,...r,e.w];s.forEach(((o,i)=>{i+1<s.length&&t.setEdge(s[i],s[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 R(t,e,n){return function(t,e,n){let o,i;e.length>n.length?(o=e,i=n):(o=n,i=e);const r=i.length,s=[];o.forEach((e=>{i.forEach(((n,o)=>{(t.hasEdge(e,n)||t.hasEdge(n,e))&&s.push(o)}))}));let a=1;for(;a<r;)a*=2;const d=2*a-1;a-=1;const l=new Array(d).fill(0);let c=0;return s.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 N(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 F(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 r=I(t,e,o);z(e[o],i,i+1);I(t,e,o)<r?n=!0:z(e[o],i,i+1)}}}function I(t,e,n){let o=0;return n>0&&(o+=R(t,e[n-1],e[n])),n+1<e.length&&(o+=R(t,e[n],e[n+1])),o}function z(t,e,n){const o=t[e];t[e]=t[n],t[n]=o}function O(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 W(t,e,n=1,o=!1){if(n>0)for(let n=1;n<e.length;++n){const i=new Map;e[n].forEach((r=>{const s=O(j(t,e,n,n-1,r,o));i.set(r,s)})),q(e[n],i)}else for(let n=e.length-2;n>=0;--n){const i=new Map;e[n].forEach((r=>{const s=O(j(t,e,n,n+1,r,o));i.set(r,s)})),q(e[n],i)}}function j(t,e,n,o,i,r=!1){const s=e[n],a=e[o],d=[];return a.forEach(((e,n)=>{t.nodeEdges(e,i).length>0&&d.push(n)})),0===d.length&&r&&s.forEach(((e,n)=>{t.nodeEdges(e,i).length>0&&d.push(n+.5)})),d.sort(((t,e)=>t-e)),d}function q(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,r=e.get(t[o]),s=e.get(t[i]);for(;-1===(r=e.get(t[o]))&&o>0;)o--;if(void 0===s||void 0===r||-1===s||-1===r)break;if(r===s&&(r=n.get(t[o])??r,s=n.get(t[i])??s),s>=r)break;[t[i],t[o]]=[t[o],t[i]]}}function H(t,e){let n=0;for(let o=0;o<e.length-1;++o)n+=R(t,e[o],e[o+1]);return n}function D(t){const e=[];for(const n of t){const t=[];e.push(t);for(const e of n)t.push(e)}return e}const G=(t,e)=>(t||[]).reduce(((t,n)=>t+(e?e(n):n)),0);function V(){let t=[100,100],e=null,n=.18,o=function(t,e,n){return 1};const i=function(t){return t.data.value},r=function(t){return t.data?t.data.direction??"r":"r"};function s(a,d,l=0){null===e&&s.scaleToFit(a,d,l),Y(a,i,r),function(t,e,n,o=0){t.nodes().forEach((e=>{const i=t.node(e),r=t.inEdges(e)||[],s=t.outEdges(e)||[],a=Math.max(0,r.length-1),d=Math.max(0,s.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=Z(a,d,l,e),h=[];for(let e=0;e<d.length;e++){const i=d[e],r=i.length;let s=0;h[e]=[];for(let d=0;d<i.length;d++){const l=i[d],u=c[d]/G(c)*t[1],p=0===s?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)),m=G(l,(t=>a.node(t).dy)),v=Math.max(0,g-m),y=G(f)?v/G(f):0;let b=s+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===r-1,startYY:b},s+=u}}let u,p,g=-1,f=-1,m=0,v=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],m=u.startYY,v=u.isFirst?Number.MAX_VALUE:0);const r=a.node(o);r.y=m,r.spaceAbove=v,r.spaceBelow=u.gaps[n]*u.kg,m+=r.dy+r.spaceBelow,v=r.spaceBelow,void 0!==(null==(i=r.data)?void 0:i.forceY)&&(r.y=u.margin+r.data.forceY*(u.height-r.dy)),n===p.length-1&&(r.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 r=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,s=n*n-i*i,a=s>=0?Math.sqrt(s):n;a>r&&(r=a)}))}))})),n.push(r)})),n}(a,d);!function(t,e,n,o){const i=o.reduce(((t,e)=>t+e),0);let r;if(i>n)r=o.map((t=>n*t/i));else{const t=n-i;r=o.map((n=>n+t/(e.length-1)))}let s=0;e.forEach(((e,n)=>{e.forEach((e=>{e.forEach((e=>{t.node(e).x=s}))})),s+=r[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 s.scaleToFit=function(o,s,a=0){Y(o,i,r);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)||[],r=Math.max(0,o.length-1),s=Math.max(0,i.length-1);return Math.max(r,s)*n}(o,t,a))}));const l=G(Z(o,s,0,1));if(l<=0)return void(e=1);const c=t[1]-d;e=c/l,1!==n&&(e*=1-n)},s.size=function(e){return arguments.length?(t=e,s):t},s.separation=function(t){return arguments.length?(o="function"==typeof t?t:()=>t,s):o},s.whitespace=function(t){return arguments.length?(n=t,s):n},s.scale=function(t){return arguments.length?(e=t,s):e},s}function Y(t,e,n){t.nodes().forEach((o=>{const i=G(t.inEdges(o),(n=>e(t.edge(n)))),r=G(t.outEdges(o),(n=>e(t.edge(n))));let s=t.node(o);s||t.setNode(o,s={}),s.value=Math.max(i,r),void 0===s.direction&&(s.direction=n(s)||"r")}))}function Z(t,e,n=0,o=1){if(0===e.length||0===e[0].length)return[];const i=e[0].length,r=new Array(i).fill(0);return e.forEach((e=>{e.forEach(((e,i)=>{const s=G(e,(e=>{const i=t.node(e),r=t.inEdges(e)||[],s=t.outEdges(e)||[],a=Math.max(0,r.length-1),d=Math.max(0,s.length-1),l=Math.max(a,d);return i.value+l*n/o}));r[i]=Math.max(r[i],s)}))})),r}function P(t,e,n){return void 0!==n?`${t}${e}${n}`:`${t}${e}`}class K{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,r;let s,a;"object"==typeof t?(s=t.v,a=t.w,o=t.name,n=e):(s=t,a=e),this.setNode(s),this.setNode(a);const d=this._isMultigraph?P(s,a,o):P(s,a),l=this._edges.get(d);if(l)void 0!==n&&(l.label=n);else{const t={v:s,w:a,name:o,label:void 0!==n?n:{}};this._edges.set(d,t),null==(i=this._out.get(s))||i.add(d),null==(r=this._in.get(a))||r.add(d)}return this}edge(t,e,n){var o;let i;return i="string"==typeof t?this._isMultigraph?P(t,e,n):P(t,e):this._isMultigraph?P(t.v,t.w,t.name):P(t.v,t.w),null==(o=this._edges.get(i))?void 0:o.label}hasEdge(t,e,n){const o=this._isMultigraph?P(t,e,n):P(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?P(t.v,t.w,t.name):P(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=P(i.v,i.w,i.name);o.has(t)||(o.add(t),n.push(i))}return n}}function X(t){return void 0!==t.name?`${t.v}${t.w}${t.name}`:`${t.v}${t.w}`}function U(t,e){const n=function(t,e){const n=new Set,o=new K({directed:!0}),i=[];if(!t.hasNode(e))throw Error("node not in graph");return Q(t,e,n,o,i),t.nodes().forEach((e=>{n.has(e)||Q(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 Q(t,e,n,o,i,r=0){if(!n.has(e)){n.add(e),i.push(e),o.setNode(e,{depth:r});t.outEdges(e).map((t=>t.w)).forEach((s=>{n.has(s)||o.setEdge(e,s,{delta:1}),Q(t,s,n,o,i,r+1)}))}}function J(t,e){if(0===t.nodes().length)return;const n=function(t,e){const n=new K({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 r=0;return e.forEach((t=>{if(!t.nodes||0===t.nodes.length)return;const e=""+r++;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=""+r++,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,r=i.get(e.w)??e.w,s=t.node(e.v)||{},a=t.node(e.w)||{},d=n.edge(o,r)||{delta:0};o===r?(d.delta=0,n.setEdge(o,r,d)):"l"===s.direction?(d.delta=Math.max(d.delta??0,"l"===a.direction?1:0),n.setEdge(r,o,d)):(d.delta=Math.max(d.delta??0,"l"===a.direction?0:1),n.setEdge(o,r,d))})),n}(t,e);!function(t){t.sources().forEach((e=>{"0"!==e&&t.setEdge("0",e,{delta:0,temp:!0})}))}(n),U(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(X(t))}));n.length>0;){const r=n.shift();if(void 0===r)break;o.add(r);let s=t.node(r);s||t.setNode(r,s={}),s.rank=0;for(const n of t.inEdges(r)){const o=(null==(e=t.edge(n)||{})?void 0:e.delta)??1;s.rank=Math.max(s.rank,(t.node(n.v).rank??0)+o)}for(const e of t.outEdges(r))i.add(X(e));for(const e of t.nodes())n.indexOf(e)<0&&!o.has(e)&&!t.inEdges(e).some((t=>!i.has(X(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=V(),n=L(t);let o=[],i=[],r=null;function s(s=[],a=[],d={}){const l=function(t=[],e=[]){const n=new K({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,s);var c;return d.order?(J(l,d.rankSets||[]),r=d.order,r.length>0&&r[0].length>0&&!Array.isArray(r[0][0])&&(r=r.map((t=>[t]))),r=r.map((t=>t.map((t=>t.filter((t=>void 0!==l.node(t)))))))):(J(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 r=[];if(void 0!==i&&void 0!==n.rank&&i+1<=n.rank){for("l"===e.direction&&r.push(i);++i<n.rank;)r.push(i);"l"===n.direction&&r.push(i),T(c,t,o,r,"r")}else if(void 0!==i&&void 0!==n.rank&&i>n.rank){for("l"!==e.direction&&r.push(i);i-- >n.rank+1;)r.push(i);"l"!==n.direction&&r.push(i),T(c,t,o,r,"l")}})),r=function(t,e=25){const n=N(t);let o=n,i=H(t,n),r=0;for(;r++<e;){W(t,n,r%2==0?1:0),F(t,n);const e=H(t,n);if(e<i&&(o=D(n),i=e),0===i)break}return o.map((t=>[t]))}(l)),o=e(l,r,t.edgeGap||0),function(t,{alignLinkTypes:e=!1}={}){t.nodes().forEach((e=>{const n=t.node(e);n.incoming=t.inEdges(e),n.outgoing=t.outEdges(e)}))}(l,{alignLinkTypes:d.alignLinkTypes||!1}),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 r,s=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:s[e],x:o.x,y:t.y0}))})),s=i.map((t=>t.r1)),r=t.successors(e)[0],t.removeNode(e),o=t.node(e=r);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),s.nodes=function(){return o},s.links=function(){return i},s.order=function(){return r},s.size=function(t){return arguments.length?(e.size(t),s):e.size()},s.separation=function(t){return arguments.length?(e.separation(t),s):e.separation()},s.whitespace=function(t){return arguments.length?(e.whitespace(t),s):e.whitespace()},s.edgeValue=function(t){return s},s.scale=function(t){return arguments.length?(e.scale(t),s):e.scale()},s}const et=["#6b9ece","#e07b7b","#7dba8f","#b09ed1","#e0b678","#6dbaba","#d17da8","#b5b56d","#c49a6d","#8fa4b8","#c98aa0","#94bf7d","#e0a08a","#7b9eb5","#a988a8"],nt=t=>0===t.dy?0:2;function ot(t){const e=Math.max(nt(t),t.dy)/2;let{x0:n}=t,{x1:o}=t,{y0:i}=t,{y1:r}=t;o<n&&([n,o]=[o,n],[i,r]=[r,i]);const s=r>i?1:-1,a=function(t){const e=t.x1-t.x0,n=t.y1-t.y0;return[t.dy/2,(e*e+n*n)/Math.abs(4*n)]}(t),d=Math.max(a[0],Math.min(a[1],(o-n)/3));let l=Math.max(a[0],Math.min(a[1],t.r0||d)),c=Math.max(a[0],Math.min(a[1],t.r1||d));const h=o-n,u=r-i-s*(l+c),p=Math.sqrt(h*h+u*u),g=-s*Math.acos(Math.min(1,(l+c)/p)),f=Math.atan2(u,h);let m=Math.PI/2+s*(f+g),v=e*s*Math.sin(m),y=e*Math.cos(m),b=n+1*l*Math.sin(Math.abs(m)),x=o-1*c*Math.sin(Math.abs(m)),w=i+l*s*(1-Math.cos(m)),E=r-c*s*(1-Math.cos(m));function C(t,n){const o=t*(r-i)>0?1:0;let s=1*t*(r-i)>0?n+e:n-e;return 0===m&&(s=n),`A${s} ${s} ${Math.abs(m)} 0 ${o} `}return(Number.isNaN(m)||Math.abs(m)<.001)&&(m=0,l=0,c=0,b=n,x=o,w=i,E=r,v=0,y=e),`M${[n,i-e]} ${C(1,l)}${[b+v,w-y]} L${[x+v,E-y]} ${C(-1,c)}${[o,r-e]} L${[o,r+e]} ${C(1,c)}${[x-v,E+y]} L${[b-v,w+y]} ${C(-1,l)}${[n,i+e]} Z`}function it(t){var e;if(1===(null==(e=t.points)?void 0:e.length))return function(t){if(!t.points)return null;const e=t.points[0],n=Math.max(nt(t),t.dy??0)/2;return"down-right"===e.style?`M${[(e.x??0)-20,(e.y??0)-n]} L${[e.x??0,(e.y??0)-n]} L${[e.x??0,(e.y??0)+n]} L${[(e.x??0)-20,(e.y??0)+n]} Z`:"right-down"===e.style?`M${[e.x??0,(e.y??0)-n]} L${[(e.x??0)+20,(e.y??0)-n]} L${[(e.x??0)+20,(e.y??0)+n]} L${[e.x??0,(e.y??0)+n]} Z`:null}(t);if(!t.points)return null;let n,o="";for(let e=0;e<t.points.length-1;++e){const i=t.points[e],r=t.points[e+1];n={d0:i.d,d1:r.d,dy:t.dy??0,r0:i.ro,r1:r.ri,x0:i.x??0,x1:r.x??0,y0:i.y??0,y1:r.y??0},o+=ot(n)}return o}const rt=(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 st(t,{fontColor:e,maxRank:n,nodeWidth:o}){const{data:i}=t;if(!i)return null;const r=function(t,e){let n=!1,o=!1;return(t.rank??0)<e/2&&(o=!0,n=!1),{right:o,top:n}}(t,n),{x:s,y:a}=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,r,o);return function(t="",{fontColor:e="#666767",pointerEvents:n="all",textAnchor:o="start",x:i,y:r}={}){const s=new g;return s.font({fill:e}),s.tspan(t),void 0!==i&&void 0!==r&&s.move(i,r),s.attr({"pointer-events":n,"text-anchor":o}),s}(rt(i,r.top?25:15),{fontColor:e,pointerEvents:"none",textAnchor:r.top?"middle":r.right?"start":"end",x:s,y:a})}function at(t,e,n){var o,i;const{dy:r,x:s,y:a}=t,{fontColor:d="#212121",fontSize:l="14px",fontFamily:c,fontWeight:p,nodeBorderColor:g,nodeBorderWidth:f,nodeWidth:m=0,onNodeClick:v,nodeTooltip:y}=n,b=new h({class:"node"}),x=function({borderColor:t="#caced0",color:e="#97cbe6",height:n=0,opacity:o=1,radius:i=0,width:r=0,x:s=0,y:a=0}={}){const d=new u;return d.attr({height:n,opacity:o,rx:i,ry:i,width:r,x:s,y:a}),d.fill(e),d.stroke({color:t,width:1}),d}({height:r,width:m,x:(s??0)-m/2,y:a});if(x.fill(null==(o=t.data)?void 0:o.color),x.stroke({color:g??(null==(i=t.data)?void 0:i.color),width:f}),x.on("click",(()=>{"function"==typeof v&&v(t)})),y){const{chartContext:e,nodeValue:n,tooltipBGColor:o,tooltipBorderColor:i,tooltipFontColor:r,tooltipId:s,nodeTooltipTemplate:a}=y,h=a({node:t.data,value:n});x.on("mouseover",(t=>{const{pageX:n,pageY:a}=t,u=k({bgColor:o,borderColor:i,fontColor:r||d,fontFamily:c??"",fontSize:l??"14px",fontWeight:p??"400",x:n,y:a});S(e,s,u,h)})),x.on("mousemove",(t=>{const{pageX:n,pageY:a}=t,u=k({bgColor:o,borderColor:i,fontColor:r||d,fontFamily:c??"",fontSize:l??"14px",fontWeight:p??"400",x:n,y:a});S(e,s,u,h)})),x.on("mouseout",(()=>{A(e,s).style.display="none"}))}if(b.add(x),t.data&&(r??0)>Number.parseInt(l,10)){const n=st(t,{fontColor:d,maxRank:e,nodeWidth:m});n&&b.add(n)}return b}class dt{constructor(t,e,n){this.element=t,this.options=e,this.chartContext=n,t.innerHTML="",this.canvas=function(){const t=document.createElementNS(d,"svg");return new v(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 lt{constructor(t,e,n){this.svgRoot=t,this.graph=e,this.dimOpacity=n}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,r;const s=this.graph.edge(t.v,t.w,t.name),a=null==(n=null==(e=null==s?void 0:s.source)?void 0:e.data)?void 0:n.id,d=null==(r=null==(i=null==s?void 0:s.target)?void 0:i.data)?void 0:r.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,r;const s=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==(r=null==(i=null==a?void 0:a.target)?void 0:i.data)?void 0:r.id)??e;this.dimAll(s),this.svgRoot.querySelectorAll(`[data-edge-source="${t}"][data-edge-target="${e}"]`).forEach((t=>this.setOpacity(t,1,s)));const c=this.svgRoot.querySelector(`[data-node-id="${d}"]`),h=this.svgRoot.querySelector(`[data-node-id="${l}"]`);c&&this.setOpacity(c,1,s),h&&this.setOpacity(h,1,s)}reset(){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 ct(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,r=n("--apex-sankey-node-width"),s=""!==r?Number(r):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=n("--apex-sankey-node-border-color")||e.nodeBorderColor,u=n("--apex-sankey-tooltip-bg")||e.tooltipBGColor,p=n("--apex-sankey-tooltip-border-color")||e.tooltipBorderColor,g=n("--apex-sankey-tooltip-font-color")||e.tooltipFontColor,f=n("--apex-sankey-tooltip-theme"),m="dark"===f||"light"===f?f:e.tooltipTheme;return{...e,edgeGradientFill:c,edgeOpacity:Number.isFinite(i)?i:e.edgeOpacity,fontColor:n("--apex-sankey-label-color")||e.fontColor,fontSize:n("--apex-sankey-label-font-size")||e.fontSize,fontFamily:n("--apex-sankey-font-family")||e.fontFamily,nodeBorderColor:h,nodeBorderWidth:Number.isFinite(d)?d:e.nodeBorderWidth,nodeWidth:Number.isFinite(s)?s:e.nodeWidth,tooltipBGColor:u,tooltipBorderColor:p,tooltipFontColor:g,tooltipTheme:m}}const ht="#005FCC",ut="role",pt="aria-label",gt="data-node-id",ft="data-orig-stroke",mt="data-orig-stroke-width",vt="stroke",yt="stroke-width",bt="forced-colors",xt="apexsankey-desc",wt="data-edge-target";const Et="apexsankey-a11y-styles";class Ct{constructor(t,e,n={},o,i){this.svgEl=t,this.graph=e,this.options=n,this.tooltipId=o,this.pathHighlighter=i,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(Et))return;const t=document.createElement("style");t.id=Et,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: ${ht};\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,options:n}=this,o=e.nodes().filter((t=>!e.node(t).dummy)),i=e.edges(),r=function(t,e,n,o){var i,r,s,a;if(o)return o;let d=0,l="",c="";for(const e of n)try{const n=t.edge(e.v,e.w,e.name).value??0;if(n>d){const o=t.node(e.v),h=t.node(e.w);o.dummy||h.dummy||(d=n,l=(null==(i=o.data)?void 0:i.title)??(null==(r=o.data)?void 0:r.id)??e.v,c=(null==(s=h.data)?void 0:s.title)??(null==(a=h.data)?void 0:a.id)??e.w)}}catch{}let h=`Sankey flow diagram: ${e.length} nodes, ${n.length} flows.`;return l&&c&&(h+=` Largest flow: ${l} (${d} units) to ${c}.`),h}(e,o,i,n.diagramLabel);t.setAttribute(ut,"img"),t.setAttribute(pt,r),t.removeAttribute("aria-labelledby");const s=t.querySelector("title");if(s&&s.remove(),n.description){let e=t.querySelector("desc");if(!e){const n=document.createElementNS("http://www.w3.org/2000/svg","desc");n.id=xt,t.insertBefore(n,t.firstChild),e=n}e.textContent=n.description,t.setAttribute("aria-describedby",xt)}const a=Array.from(t.querySelectorAll(`[${gt}]`));a.forEach((t=>{const n=t.getAttribute(gt);n&&(t.setAttribute(ut,"listitem"),t.setAttribute(pt,function(t,e){var n,o,i,r,s,a;const d=e.node(t),l=(null==(n=d.data)?void 0:n.title)??(null==(o=d.data)?void 0:o.id)??t,c=[];let h=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||(c.push((null==(i=o.data)?void 0:i.title)??(null==(r=o.data)?void 0:r.id)??n.v),h+=t.value??0)}catch{}const u=[];let p=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||(u.push((null==(s=o.data)?void 0:s.title)??(null==(a=o.data)?void 0:a.id)??n.w),p+=t.value??0)}catch{}let g=l;c.length>0&&(g+=`: receives ${h} units from ${c.join(", ")}`),u.length>0&&(g+=`${c.length>0?"; ":": "}flows ${p} units to ${u.join(", ")}`);return g}(n,e)),t.setAttribute("tabindex","0"))})),this.nodeGroups=a;const d=[],l=new Map,c=new Map;t.querySelectorAll("[data-edge-source]").forEach((t=>{var n,o,i,r;const s=t.getAttribute("data-edge-source"),a=t.getAttribute("data-edge-target"),h=t.getAttribute("data-edge-name")??void 0;if(s&&a)try{const u=e.edge(s,a,h),p=u.source,g=u.target;if(!p||!g)return;const f=(null==(n=p.data)?void 0:n.title)??(null==(o=p.data)?void 0:o.id)??s,m=(null==(i=g.data)?void 0:i.title)??(null==(r=g.data)?void 0:r.id)??a,v=u.value??0;t.setAttribute("role","img"),t.setAttribute("aria-label",`Flow from ${f} to ${m}: ${v} units`),t.setAttribute("focusable","true"),t.setAttribute("tabindex","-1"),d.push(t),c.set(t,s),l.has(s)||l.set(s,[]);const y=l.get(s);y&&y.push(t)}catch{}})),this.edgePaths=d,this.nodeOutEdges=l,this.edgeSourceNode=c}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(gt),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(gt);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(gt)===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(wt),n=e?this.nodeGroups.find((t=>t.getAttribute(gt)===e)):void 0;n&&n.focus()}else if("Tab"===i){const e=this.edgeSourceNode.get(t),n=this.nodeGroups.findIndex((t=>t.getAttribute(gt)===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(wt);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(ft,e.getAttribute(vt)??""),e.setAttribute(mt,e.getAttribute(yt)??""),e.setAttribute(vt,ht),e.setAttribute(yt,"2"))}restoreFocusRing(t){const e=t.querySelector("rect");if(!e)return;const n=e.getAttribute(ft),o=e.getAttribute(mt);null!==n&&(e.setAttribute(vt,n),e.removeAttribute(ft)),null!==o&&(e.setAttribute(yt,o),e.removeAttribute(mt))}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(bt),this.forcedColorsHandler=t=>{t.matches?this.svgEl.classList.add(bt):this.svgEl.classList.remove(bt)},t.addEventListener("change",this.forcedColorsHandler)}catch{}}}const At="http://www.w3.org/2000/svg";class St extends dt{constructor(t,e,n){super(t,e,n),this.a11yHelper=null,this.pathHighlighter=null,this._hasAnimated=!1,this.renderOptions=e}construct(t){const{edgeGap:e,nodeWidth:n,spacing:o,viewPortHeight:i,viewPortWidth:r,whitespace:s}=this.options,a=tt({edgeGap:e,nodeWidth:n,whitespace:s});a.size([r-n,i-o]);const d=t.nodes.map(((t,e)=>{const n=e%et.length;return{...t,color:t.color??et[n],colorIndex:n}})),l=a(t.edges,d);this.maxRank=(a.order()??[]).length-1,this.graph=l}render({keepOldPosition:t=!1}={}){var e,n;this.renderOptions=ct(this.element,this.options);const{tooltipTheme:o,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s}=this.renderOptions;"dark"===o?this.renderOptions={...this.renderOptions,tooltipBGColor:"#1e2433",tooltipBorderColor:"#374151",tooltipFontColor:"#e5e7eb"}:"light"===o&&(this.renderOptions={...this.renderOptions,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s});const{enableTooltip:a,fontColor:d,fontFamily:l,fontSize:c,fontWeight:h,highlightConnectedPath:u,dimOpacity:p,nodeBorderColor:g,nodeBorderWidth:f,nodeWidth:m,nodeTooltipTemplate:v,onNodeClick:b,tooltipBGColor:x,tooltipBorderColor:w,tooltipFontColor:E,tooltipId:C}=this.renderOptions,S=this.canvas.viewbox();this.clear(),this.pathHighlighter=u?new lt(this.canvas.node,this.graph,p):null;const k=((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(" ")})({color:d,fontFamily:l,fontSize:c,fontWeight:h}),$=y(m/2,0);$.attr("style",k);const M=(null==(e=this.graph)?void 0:e.nodes())||[],L=(null==(n=this.graph)?void 0:n.edges())||[],_=y();L.forEach((t=>{this.renderEdge(t,_)})),$.add(_);const B=y();B.node.setAttribute("role","list"),B.node.setAttribute("aria-label","Sankey nodes"),M.forEach((t=>{const e=this.graph.node(t);if(e.dummy)return;let n;if(a&&v){const e=this.graph.inEdges(t)??[],o=this.graph.outEdges(t)??[],i=e.reduce(((t,e)=>{var n;return t+((null==(n=this.graph.edge(e.v,e.w,e.name))?void 0:n.value)??0)}),0),r=o.reduce(((t,e)=>{var n;return t+((null==(n=this.graph.edge(e.v,e.w,e.name))?void 0:n.value)??0)}),0),s=Math.max(i,r);n={chartContext:this.chartContext,nodeTooltipTemplate:v,nodeValue:s,tooltipBGColor:x,tooltipBorderColor:w,tooltipFontColor:E,tooltipId:C}}const o=at(e,this.maxRank,{fontColor:d,fontFamily:l,fontSize:c,fontWeight:h,nodeBorderColor:g,nodeBorderWidth:f,nodeWidth:m,nodeTooltip:n,onNodeClick:b});if(o.node.setAttribute("data-node-id",t),o.node.setAttribute("data-node-rank",String(e.rank??0)),this.pathHighlighter){const e=this.pathHighlighter;o.node.addEventListener("mouseenter",(()=>e.highlightNode(t))),o.node.addEventListener("mouseleave",(()=>e.reset()))}B.add(o)})),$.add(B),this.add($);const{animation:T}=this.renderOptions;if((null==T?void 0:T.enabled)&&!this._hasAnimated&&(this._hasAnimated=!0,function(t,e,n,o,i){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const r=t.viewBox.baseVal,s=r.width,a=r.x,d=t.querySelector("defs")??(()=>{const e=document.createElementNS(At,"defs");return t.insertBefore(e,t.firstChild),e})(),l=`sankey-flow-clip-${Math.random().toString(36).slice(2,9)}`,c=document.createElementNS(At,"clipPath");c.setAttribute("id",l);const h=document.createElementNS(At,"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,r=Math.min(o/i,1),a=((d=r)<.5?2*d*d:(4-2*d)*d-1)*s;var d;h.setAttribute("width",String(a)),r<1?requestAnimationFrame(t):(e.removeAttribute("clip-path"),c.remove())}));const p=n.querySelectorAll("[data-node-rank]"),g=.1*i,f=.7*i-g,m=.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",t.animate([{opacity:"0",transform:"translateY(6px)"},{opacity:"1",transform:"translateY(0px)"}],{duration:m,delay:n,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"forwards"}).onfinish=()=>{t.style.opacity="",t.style.transform=""}}))}(this.canvas.node,_.node,B.node,this.maxRank,T.duration)),t&&this.updateViewBox(S.x,S.y,S.width,S.height),a){const t=A(this.chartContext,C);this.chartContext.getAppendContainer().appendChild(t)}this.a11yHelper&&this.a11yHelper.destroy();const R=this.renderOptions.a11y;!1!==(null==R?void 0:R.enabled)&&(this.a11yHelper=new Ct(this.canvas.node,this.graph,R,C,this.pathHighlighter),this.a11yHelper.apply())}renderEdge(t,e){const{edgeGradientFill:n,edgeOpacity:o,enableTooltip:i,fontFamily:r,fontSize:s,fontWeight:a,nodeWidth:d,tooltipBGColor:l,tooltipBorderColor:c,tooltipFontColor:h,tooltipId:u,tooltipTemplate:g}=this.renderOptions,f=this.graph.edge(t.v,t.w,t.name),m=this.graph.node(t.v),v=this.graph.node(t.w),y=f.source,b=f.target;if(!y||!b)return;m.dummy&&(f.x0=(f.x0??0)-d/2),v.dummy&&(f.x1=(f.x1??0)+d/2);const x=it(f);if(!x)return;const w=function(t,{edgeColor:e,id:n="",opacity:o=1}={}){const i=new p({d:t});return i.id(n),i.fill(e).opacity(o),i}(x,{edgeColor:this.canvas.gradient("linear",(t=>{var e,o,i;t.stop(0,(null==(e=y.data)?void 0:e.color)??""),t.stop(1,n?(null==(o=b.data)?void 0:o.color)??"":(null==(i=y.data)?void 0:i.color)??"")})),id:`${t.v}-${t.w}`,opacity:o});if(w.node.setAttribute("data-edge-source",t.v),w.node.setAttribute("data-edge-target",t.w),void 0!==t.name&&w.node.setAttribute("data-edge-name",t.name),this.pathHighlighter){const e=this.pathHighlighter,n=t.v,o=t.w;w.on("mouseenter",(()=>e.highlightEdge(n,o))),w.on("mouseleave",(()=>e.reset()))}if(i&&y.data&&b.data){const t=g?g({source:y.data,target:b.data,value:f.value}):`${y.data.title} → ${b.data.title}: ${f.value}`;w.on("mouseover",(e=>{const{pageX:n,pageY:o}=e,i=k({bgColor:l,borderColor:c,fontColor:h,fontFamily:r,fontSize:s,fontWeight:a,x:n,y:o});S(this.chartContext,u,i,t)})),w.on("mousemove",(e=>{const{pageX:n,pageY:o}=e,i=k({bgColor:l,borderColor:c,fontColor:h,fontFamily:r,fontSize:s,fontWeight:a,x:n,y:o});S(this.chartContext,u,i,t)})),w.on("mouseout",(()=>{A(this.chartContext,u).style.display="none"}))}e.add(w)}}const kt={canvasStyle:"border: 1px solid #caced0; box-sizing: border-box",edgeGap:2,edgeGradientFill:!0,edgeOpacity:.4,enableToolbar:!0,enableTooltip:!0,fontColor:"#212121",fontFamily:"",fontSize:"14px",fontWeight:"400",height:"auto",nodeBorderColor:null,nodeBorderWidth:1,nodeWidth:20,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,width:"100%",highlightConnectedPath:!0,dimOpacity:.2,animation:{enabled:!0,duration:800},a11y:{enabled:!0}};class $t extends o{constructor(t,e={}){super(t,"sankey_"+crypto.randomUUID().replace(/-/g,"").substring(0,9)),this.options={...kt,...e};const{height:n,width:o}=this.options;this.graph=new St(this.element,this.options,this.chartContext),this.setupElementDimensions(o,n),this.handleWatermark()}static setLicense(t){a.setLicense(t)}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&&(a.isLicenseValid()?E.remove(this.element):E.add(this.element))}render(t){if(!this.element)throw new Error("Element not found");if(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}}"undefined"!=typeof window&&(window.ApexSankey=$t),t.ApexSankey=$t,t.default=$t,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 o{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}`),o=Array.from(e);return{item:t=>o[t]||null,get length(){return o.length},[Symbol.iterator]:()=>o[Symbol.iterator](),...Object.fromEntries(o.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,o){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.addEventListener(t,e,o):this.context.addEventListener(t,e,o)}removeEventListener(t,e,o){this.context===document||"mousemove"===t||"mouseup"===t||"keydown"===t?document.removeEventListener(t,e,o):this.context.removeEventListener(t,e,o)}injectStyles(t,e,o={}){const{force:n=!1,priority:i="normal"}=o;if(!n&&this.injectedStyles.has(e))return;if(n){const t=this.context.querySelector(`#${e}`);t&&(t.remove(),this.injectedStyles.delete(e))}if(this.context.querySelector(`#${e}`)&&!n)return void this.injectedStyles.add(e);const r=document.createElement("style");if(r.id=e,r.textContent=t,"normal"!==i&&r.setAttribute("data-priority",i),this.context===document)document.head.appendChild(r);else{const t=this.context;"high"===i?t.insertBefore(r,t.firstChild):t.appendChild(r)}this.injectedStyles.add(e)}injectStylesheets(t){t.forEach((({content:t,id:e,options:o})=>{this.injectStyles(t,e,o)}))}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 n{constructor(t,e){if(!t)throw new Error("Container element is required");this.element=t,this.chartContext=new o(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,o){this.chartContext.addEventListener(t,e,o)}removeEventListener(t,e,o){this.chartContext.removeEventListener(t,e,o)}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 o=document.createElement("a");o.href=t,o.download=e,document.body.appendChild(o),o.click(),document.body.removeChild(o)}exportToSVG(){this.triggerDownload(this.svgUrl(),`${this.prefix}-${(new Date).getTime()}.svg`)}}const r="http://www.w3.org/2000/svg";let s=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,o]of Object.entries(t))null!=o&&this.node.setAttribute(e,String(o));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:o}={}){return void 0!==t&&this.node.setAttribute("stroke",t),void 0!==e&&this.node.setAttribute("stroke-width",String(e)),void 0!==o&&this.node.setAttribute("stroke-dasharray",String(o)),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(r,"g")),t&&this.attr(t)}}class l extends a{constructor(){super(document.createElementNS(r,"rect"))}}class h extends a{constructor(t){super(document.createElementNS(r,"path")),t&&this.attr(t)}}class c extends a{constructor(){super(document.createElementNS(r,"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(r,"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 o=document.createElementNS(r,"stop");o.setAttribute("offset",String(t)),o.setAttribute("stop-color",e??"transparent"),this.gradient.appendChild(o)}}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,o]of Object.entries(t))null!=o&&this.node.setAttribute(e,String(o));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(r,"defs"),this.node.insertBefore(this._defs,this.node.firstChild));const o=document.createElementNS(r,"linearGradient"),n="apx-grad-"+ ++s;return o.setAttribute("id",n),o.setAttribute("x1","0%"),o.setAttribute("y1","0%"),o.setAttribute("x2","100%"),o.setAttribute("y2","0%"),e(new u(o)),this._defs.appendChild(o),o}panZoom(t={}){return this._panZoomState=function(t,e){const o=function(t){const e=t.viewBox.baseVal;return{x:e.x,y:e.y,w:e.width,h:e.height}}(t),n={zoomFactor:e.zoomFactor??.2,zoomMin:e.zoomMin??.1,currentZoom:1,baseVb:{...o},vb:{...o}};t.addEventListener("wheel",(e=>{let o;if(e.preventDefault(),e.ctrlKey){const t=.005;o=1+Math.max(-.15,Math.min(.15,e.deltaY*t))}else o=e.deltaY<0?1-n.zoomFactor:1+n.zoomFactor;const i=n.currentZoom/o;if(i<n.zoomMin)return;const r=t.getBoundingClientRect(),s=(e.clientX-r.left)/r.width,a=(e.clientY-r.top)/r.height,{vb:d}=n,l=d.w*o,h=d.h*o,c=d.x+s*(d.w-l),u=d.y+a*(d.h-h);n.vb={x:c,y:u,w:l,h:h},n.currentZoom=i,p(t,n.vb)}),{passive:!1});let i=!1,r=!1,s=-1,a=0,d=0;t.addEventListener("pointerdown",(t=>{0===t.button&&(t.preventDefault(),i=!0,r=!1,s=t.pointerId,a=t.clientX,d=t.clientY)})),t.addEventListener("pointermove",(e=>{if(!i||e.pointerId!==s)return;if(!r){const o=e.clientX-a,n=e.clientY-d;if(Math.abs(o)<4&&Math.abs(n)<4)return;r=!0,t.setPointerCapture(e.pointerId),t.style.cursor="grabbing",t.style.userSelect="none"}const o=t.getBoundingClientRect(),l=n.vb.w/o.width,h=n.vb.h/o.height,c=(e.clientX-a)*l,u=(e.clientY-d)*h;n.vb={x:n.vb.x-c,y:n.vb.y-u,w:n.vb.w,h:n.vb.h},p(t,n.vb),a=e.clientX,d=e.clientY}));const l=e=>{i&&e.pointerId===s&&(r&&(t.releasePointerCapture(e.pointerId),t.style.cursor="",t.style.userSelect=""),i=!1,r=!1,s=-1)};return t.addEventListener("pointerup",l),t.addEventListener("pointercancel",l),n}(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 o=this._panZoomState;if(t<o.zoomMin)return this;const n=o.currentZoom/t,{vb:i}=o,r=i.w*n,s=i.h*n,a=i.x+.5*(i.w-r),d=i.y+.5*(i.h-s);return o.vb={x:a,y:d,w:r,h:s},o.currentZoom=t,p(this.node,o.vb),this}}function f(t,e,o,n){const i=new d;return i.attr({"data-parent":n,"data-self":o,transform:void 0!==t&&void 0!==e?`translate(${t}, ${e})`:void 0}),i}const m={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 v{constructor(t,e){this.element=t,t&&(this.chartContext=e||new o(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 right: 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 right: 12px;\n top: 12px;\n z-index: 100;\n }\n",t)}createToolbarItem(t,e,o){const n=this.chartContext.createElement("div");return n.id=t,n.className="toolbar-item",n.setAttribute("role","button"),n.setAttribute("tabindex","0"),n.innerHTML=e,o&&(n.setAttribute("data-tooltip",o),n.setAttribute("aria-label",o)),n.addEventListener("keydown",(t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n.click())})),n}render({enableExport:t=!1,enableFitscreen:o=!1,enableZoom:n=!1,onExport:i=e,onFitscreen:r=e,onZoom:s=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",m.export,"Export chart");t.addEventListener("click",(()=>{i()})),d.append(t)}if(n){const t=this.createToolbarItem("zoom-in",m["zoom-in"],"Zoom in"),e=this.createToolbarItem("zoom-out",m["zoom-out"],"Zoom out");t.addEventListener("click",(()=>{s(.1)})),e.addEventListener("click",(()=>{s(-.1)})),d.append(t,e)}if(o){const t=this.createToolbarItem("fit-screen",m["fit-screen"],"Fit to screen");t.addEventListener("click",(()=>{r()})),d.append(t)}this.element.append(d)}destroy(){const t=this.chartContext.querySelector("#toolbar");null==t||t.remove()}}const y="aria-hidden",b=(t,e="apex-tooltip-container")=>{let o=t.getElementById(e);if(!o){o=t.createElement("div"),o.id=e,o.setAttribute("role","tooltip"),o.setAttribute(y,"true");t.getAppendContainer().appendChild(o),t.trackTooltip(o)}return o},x=(t,e="",o,n="",i=!1)=>{const r=t.getElementById(e);if(!r)return b(t,e),x(t,e,o,n,i);if(o&&n){const e=n.includes("tooltip-content"),s=o.match(/background-color:\s*([^;]+);?/),a=o.match(/color:\s*([^;]+);?/);if(e||!s)r.innerHTML=n;else{const t=s[1],e=a?a[1]:"white";r.innerHTML=`<div class="tooltip-content" style="background-color: ${t}; color: ${e};">${n}</div>`}const d=o+"; display: block !important; visibility: visible !important; opacity: 1 !important;";if(r.setAttribute("style",d),r.classList.add("visible"),r.setAttribute(y,"false"),i&&"undefined"!=typeof window){const e=r.offsetWidth,o=parseFloat(r.style.left),n=t.getChartBounds();if(e>0&&!Number.isNaN(o)&&n.width>0){const t=window.scrollX||document.documentElement.scrollLeft||0,i=n.left+t,s=((t,e,o,n,i=8)=>{if(t+e<=o-i)return t;const r=t-e;return r<n+i?Math.max(n+i,o-e-i):r})(o,e,n.right+t,i);s!==o&&(r.style.left=`${s}px`)}}}else r.removeAttribute("style"),r.classList.remove("visible"),r.setAttribute(y,"true"),r.innerHTML=""},w=({bgColor:t,borderColor:e,fontColor:o,fontFamily:n,fontSize:i,fontWeight:r,maxWidth:s,padding:a,placement:d="top",x:l,y:h})=>{const c=["position: absolute;","z-index: 1000;","pointer-events: none;"];return c.push("box-sizing: border-box;"),c.push("word-wrap: break-word;"),c.push("overflow-wrap: break-word;"),c.push(`left: ${l}px;`),c.push(`top: ${h}px;`),c.push(`data-placement: ${d};`),s&&(c.push(`width: ${s}px;`),c.push(`max-width: ${s}px;`)),e&&c.push(`border: 1px solid ${e};`),o&&c.push(`color: ${o};`),n&&c.push(`font-family: ${n};`),r&&c.push(`font-weight: ${r};`),i&&c.push(`font-size: ${i};`),t&&(c.push(`background-color: ${t};`),c.push("border-radius: 6px;"),c.push("box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);")),void 0!==a&&c.push(`padding: ${a}px;`),c.join(" ")},E=globalThis.console;const S=class{static decodeLicenseData(t){try{const e=window.atob(t),o=JSON.parse(e);return o.issueDate&&o.expiryDate&&o.plan?{domains:Array.isArray(o.domains)?o.domains:void 0,expiryDate:o.expiryDate,issueDate:o.issueDate,plan:o.plan,valid:!0}:null}catch{return null}}static generateLicenseKey(t,e,o="standard",n){const i={expiryDate:e,issueDate:t,plan:o};n&&n.length>0&&(i.domains=n);return`APEX-${window.btoa(JSON.stringify(i))}`}static getLicenseStatus(){return this.licenseKey?(this.validationResult||(this.validationResult=this.validateLicense(this.licenseKey)),this.validationResult):{expired:!1,valid:!1}}static isLicenseValid(){return!!this.licenseKey&&(this.validationResult||(this.validationResult=this.validateLicense(this.licenseKey)),this.validationResult.valid)}static setLicense(t){var e;this.licenseKey=t,this.validationResult=this.validateLicense(t),this.validationResult.valid||(e=`[Apex] ${this.validationResult.message}`,E.error(e))}static validateLicense(t){try{if(!t.startsWith("APEX-"))return{expired:!1,message:'Invalid license key format. License key must start with "APEX-".',valid:!1};const e=t.indexOf("-"),o=-1!==e?t.slice(e+1):"";if(!o)return{expired:!1,message:"Invalid license key format. Expected format: APEX-{encoded-data}.",valid:!1};const n=this.decodeLicenseData(o);if(!n)return{expired:!1,message:"Invalid license key. Unable to decode license data.",valid:!1};const i=new Date;if(new Date(n.expiryDate)<i)return{data:n,expired:!0,message:`License expired on ${n.expiryDate}. Please renew your license.`,valid:!1};if(n.domains&&n.domains.length>0){const t="undefined"!=typeof window?window.location.hostname:"";if(!n.domains.some((e=>t===e||t.endsWith(`.${e}`))))return{data:n,expired:!1,message:`License is not valid for this domain (${t}). Allowed domains: ${n.domains.join(", ")}.`,valid:!1}}return{data:n,expired:!1,valid:!0}}catch{return{expired:!1,message:"Invalid license key format or corrupted data.",valid:!1}}}};S.licenseKey=null,S.validationResult=null;let A=S;const C=class{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 add(t){this.remove(t);const e=document.createElement("div");e.setAttribute(this.WATERMARK_ATTR,""),Object.assign(e.style,{backgroundImage:this.createWatermarkPattern(),backgroundRepeat:"repeat",bottom:"0",left:"0",msUserSelect:"none",pointerEvents:"none",position:"absolute",right:"0",top:"0",userSelect:"none",webkitUserSelect:"none",zIndex:"10000"}),"static"===getComputedStyle(t).position&&(t.style.position="relative"),t.appendChild(e)}static exists(t){return!!t.querySelector(`[${this.WATERMARK_ATTR}]`)}static remove(t){const e=t.querySelector(`[${this.WATERMARK_ATTR}]`);e&&e.remove()}};C.WATERMARK_ATTR="data-apexcharts-watermark",C.WATERMARK_TEXT="APEXCHARTS";let k=C;function $(t,e){let o=null;for(let n=0;n<t.length;++n)if(e(t[n])){o=n;break}return o}function M(t,e){if(0===t.length)return;let o,n=0;for(let i=t.length-1;i>=0;--i)o=(t[i].dy??0)/2,(t[i][e]??0)-o<n&&(t[i][e]=Math.min(t[i].Rmax??0,n+o)),n=(t[i][e]??0)+o;let i=(t[0].Rmax??0)+(t[0].dy??0)/2;for(let n=0;n<t.length;++n)o=(t[n].dy??0)/2,(t[n][e]??0)+o>i&&(t[n][e]=Math.max(o,i-o)),i=(t[n][e]??0)-o}function L(t){const e=t.edgeGap||0;return function(o){!function(t,e,o){t.nodes().forEach((n=>{const i=t.node(n),r=T(t,i.outgoing||[],"outgoing"),s=T(t,i.incoming||[],"incoming"),a=r.length,d=s.length,l=r.reduce(((e,o)=>e+(t.edge(o).dy??0)),0),h=s.reduce(((e,o)=>e+(t.edge(o).dy??0)),0),c=l+Math.max(0,a-1)*o,u=h+Math.max(0,d-1)*o;let p=((i.dy??0)-c)/2,g=((i.dy??0)-u)/2;p=Math.max(0,p),g=Math.max(0,g),r.forEach(((n,r)=>{const s=t.edge(n);s.x0=(i.x??0)+(e.nodeWidth??0)/2,s.y0=(i.y??0)+p+(s.dy??0)/2,s.d0=i.direction||"r",p+=s.dy??0,r<a-1&&(p+=o)})),s.forEach(((n,r)=>{const s=t.edge(n);s.x1=(i.x??0)-(e.nodeWidth??0)/2,s.y1=(i.y??0)+g+(s.dy??0)/2,s.d1=i.direction||"r",g+=s.dy??0,r<d-1&&(g+=o)}))}))}(o,t,e),function(t){t.nodes().forEach((e=>{const o=t.node(e),n=(o.outgoing||[]).map((e=>t.edge(e))),i=(o.incoming||[]).map((e=>t.edge(e)));n.sort(((t,e)=>(t.y0??0)-(e.y0??0))),i.sort(((t,e)=>(t.y1??0)-(e.y1??0))),_(n,"r0"),_(i,"r1")}))}(o);const n=[];return o.edges().forEach((t=>{const e=o.edge(t);e.id=`${t.v}-${t.w}-${t.name}`,n.push(e)})),n}}function T(t,e,o){return e.slice().sort(((e,n)=>{let i,r;if("outgoing"===o){const o=t.node(e.w),s=t.node(n.w);i=(null==o?void 0:o.y)??0,r=(null==s?void 0:s.y)??0}else{const o=t.node(e.v),s=t.node(n.v);i=(null==o?void 0:o.y)??0,r=(null==s?void 0:s.y)??0}if(Math.abs(i-r)>.001)return i-r;if(e.name!==n.name){if("number"==typeof e.name&&"number"==typeof n.name)return e.name-n.name;if("string"==typeof e.name&&"string"==typeof n.name)return e.name.localeCompare(n.name)}return 0}))}function _(t,e){t.forEach((t=>{t.Rmax=function(t){const e=(t.x1??0)-(t.x0??0),o=(t.y1??0)-(t.y0??0);return t.d0!==t.d1?Math.abs(o)/2.1:0!==o?(e*e+o*o)/Math.abs(4*o):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 o=$(t,"r0"===e?t=>(t.y1??0)>(t.y0??0):t=>(t.y0??0)>(t.y1??0));if(null===o&&(o=t.length),M(t.slice(o),e),o>0){const n=[];for(let e=o-1;e>=0;e--)n.push(t[e]);M(n,e)}}function B(t,e,o,n,i){if(0===n.length)return;const r=n.map((o=>{const n=`__${e.v}_${e.w}_${o}`;return t.setNode(n,{data:null,direction:i,dummy:!0,rank:o}),n})),s=[e.v,...r,e.w];s.forEach(((n,i)=>{i+1<s.length&&t.setEdge(s[i],s[i+1],{data:t.edge(e).data,origEdge:e,origLabel:o,source:t.node(e.v),target:t.node(e.w),value:t.edge(e).value},e.name)})),t.removeEdge(e)}function N(t,e,o){return function(t,e,o){let n,i;e.length>o.length?(n=e,i=o):(n=o,i=e);const r=i.length,s=[];n.forEach((e=>{i.forEach(((o,n)=>{(t.hasEdge(e,o)||t.hasEdge(o,e))&&s.push(n)}))}));let a=1;for(;a<r;)a*=2;const d=2*a-1;a-=1;const l=new Array(d).fill(0);let h=0;return s.forEach((t=>{let e=t+a;for(l[e]++;e>0;)e%2&&(h+=l[e+1]),e=Math.floor((e-1)/2),l[e]++})),h}(t,e,o)}function R(t){const e=[];let o=t.nodes().filter((e=>0===t.node(e).rank)).concat(t.sources());return 0===o.length&&(o=t.nodes().slice(0,1)),function(t,e){const o=new Set,n=[];function i(e){if(!o.has(e)){o.add(e),n.push(e);for(const o of t.successors(e))i(o)}}for(const t of e)i(t);return n}(t,o).forEach((o=>{const n=t.node(o).rank;if(void 0!==n){for(;n>=e.length;)e.push([]);e[n].push(o)}})),e}function F(t,e){let o=!0;for(;o;){o=!1;for(let n=0;n<e.length;++n)for(let i=0;i<e[n].length-1;++i){const r=I(t,e,n);z(e[n],i,i+1);I(t,e,n)<r?o=!0:z(e[n],i,i+1)}}}function I(t,e,o){let n=0;return o>0&&(n+=N(t,e[o-1],e[o])),o+1<e.length&&(n+=N(t,e[o],e[o+1])),n}function z(t,e,o){const n=t[e];t[e]=t[o],t[o]=n}function O(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 o=t[e-1]-t[0],n=t[t.length-1]-t[e];return(t[e-1]*n+t[e]*o)/(o+n)}function W(t,e,o=1,n=!1){if(o>0)for(let o=1;o<e.length;++o){const i=new Map;e[o].forEach((r=>{const s=O(j(t,e,o,o-1,r,n));i.set(r,s)})),q(e[o],i)}else for(let o=e.length-2;o>=0;--o){const i=new Map;e[o].forEach((r=>{const s=O(j(t,e,o,o+1,r,n));i.set(r,s)})),q(e[o],i)}}function j(t,e,o,n,i,r=!1){const s=e[o],a=e[n],d=[];return a.forEach(((e,o)=>{t.nodeEdges(e,i).length>0&&d.push(o)})),0===d.length&&r&&s.forEach(((e,o)=>{t.nodeEdges(e,i).length>0&&d.push(o+.5)})),d.sort(((t,e)=>t-e)),d}function q(t,e){const o=new Map(t.map(((t,e)=>[t,e])));for(let n=1;n<t.length;++n)for(let i=n;i>0;--i){let n=i-1,r=e.get(t[n]),s=e.get(t[i]);for(;-1===(r=e.get(t[n]))&&n>0;)n--;if(void 0===s||void 0===r||-1===s||-1===r)break;if(r===s&&(r=o.get(t[n])??r,s=o.get(t[i])??s),s>=r)break;[t[i],t[n]]=[t[n],t[i]]}}function D(t,e){let o=0;for(let n=0;n<e.length-1;++n)o+=N(t,e[n],e[n+1]);return o}function H(t){const e=[];for(const o of t){const t=[];e.push(t);for(const e of o)t.push(e)}return e}const G=(t,e)=>(t||[]).reduce(((t,o)=>t+(e?e(o):o)),0);function Y(){let t=[100,100],e=null,o=.18,n=function(t,e,o){return 1};const i=function(t){return t.data.value},r=function(t){return t.data?t.data.direction??"r":"r"};function s(a,d,l=0){null===e&&s.scaleToFit(a,d,l),P(a,i,r),function(t,e,o,n=0){t.nodes().forEach((e=>{const i=t.node(e),r=t.inEdges(e)||[],s=t.outEdges(e)||[],a=Math.max(0,r.length-1),d=Math.max(0,s.length-1),l=Math.max(a,d);i.dy=i.value*o+l*n})),t.edges().forEach((n=>{const i=t.edge(n);i.value=e(i),i.dy=i.value*o}))}(a,i,e,l);const h=Z(a,d,l,e),c=[];for(let e=0;e<d.length;e++){const i=d[e],r=i.length;let s=0;c[e]=[];for(let d=0;d<i.length;d++){const l=i[d],u=h[d]/G(h)*t[1],p=0===s?0:o*u/5,g=u-2*p,f=l.map(((t,e)=>a.node(t).value&&l[e+1]?n(l[e],l[e+1],a):0)),m=G(l,(t=>a.node(t).dy)),v=Math.max(0,g-m),y=G(f)?v/G(f):0;let b=s+p;1===l.length&&(b+=(g-a.node(l[0]).dy)/2),c[e][d]={margin:p,height:g,gaps:f,kg:y,isFirst:0===d,isLast:d===r-1,startYY:b},s+=u}}let u,p,g=-1,f=-1,m=0,v=0;(function(t){const e=[];for(let o=0;o<t.length;o++){const n=t[o];for(let t=0;t<n.length;t++){const i=n[t];for(let n=0;n<i.length;n++)e.push({rankIndex:o,bandIndex:t,nodeIndex:n,nodeId:i[n]})}}return e})(d).forEach((({rankIndex:t,bandIndex:e,nodeIndex:o,nodeId:n})=>{var i;t===g&&e===f||(g=t,f=e,u=c[t][e],p=d[t][e],m=u.startYY,v=u.isFirst?Number.MAX_VALUE:0);const r=a.node(n);r.y=m,r.spaceAbove=v,r.spaceBelow=u.gaps[o]*u.kg,m+=r.dy+r.spaceBelow,v=r.spaceBelow,void 0!==(null==(i=r.data)?void 0:i.forceY)&&(r.y=u.margin+r.data.forceY*(u.height-r.dy)),o===p.length-1&&(r.spaceBelow=u.isLast?Number.MAX_VALUE:0)}));const y=function(t,e){const o=[];return e.forEach(((n,i)=>{if(i===e.length-1)return;let r=0;n.forEach((e=>{e.forEach((e=>{t.outEdges(e).forEach((e=>{const o=t.edge(e).dy,n=t.node(e.w).y-t.node(e.v).y,i=Math.abs(n)-o,s=o*o-i*i,a=s>=0?Math.sqrt(s):o;a>r&&(r=a)}))}))})),o.push(r)})),o}(a,d);!function(t,e,o,n){const i=n.reduce(((t,e)=>t+e),0);let r;if(i>o)r=n.map((t=>o*t/i));else{const t=o-i;r=n.map((o=>o+t/(e.length-1)))}let s=0;e.forEach(((e,o)=>{e.forEach((e=>{e.forEach((e=>{t.node(e).x=s}))})),s+=r[o]}))}(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 s.scaleToFit=function(n,s,a=0){P(n,i,r);let d=0;a>0&&n.nodes().forEach((t=>{d=Math.max(d,function(t,e,o){if(o<=0)return 0;const n=t.inEdges(e)||[],i=t.outEdges(e)||[],r=Math.max(0,n.length-1),s=Math.max(0,i.length-1);return Math.max(r,s)*o}(n,t,a))}));const l=G(Z(n,s,0,1));if(l<=0)return void(e=1);const h=t[1]-d;e=h/l,1!==o&&(e*=1-o)},s.size=function(e){return arguments.length?(t=e,s):t},s.separation=function(t){return arguments.length?(n="function"==typeof t?t:()=>t,s):n},s.whitespace=function(t){return arguments.length?(o=t,s):o},s.scale=function(t){return arguments.length?(e=t,s):e},s}function P(t,e,o){t.nodes().forEach((n=>{const i=G(t.inEdges(n),(o=>e(t.edge(o)))),r=G(t.outEdges(n),(o=>e(t.edge(o))));let s=t.node(n);s||t.setNode(n,s={}),s.value=Math.max(i,r),void 0===s.direction&&(s.direction=o(s)||"r")}))}function Z(t,e,o=0,n=1){if(0===e.length||0===e[0].length)return[];const i=e[0].length,r=new Array(i).fill(0);return e.forEach((e=>{e.forEach(((e,i)=>{const s=G(e,(e=>{const i=t.node(e),r=t.inEdges(e)||[],s=t.outEdges(e)||[],a=Math.max(0,r.length-1),d=Math.max(0,s.length-1),l=Math.max(a,d);return i.value+l*o/n}));r[i]=Math.max(r[i],s)}))})),r}function X(t,e,o){return void 0!==o?`${t}${e}${o}`:`${t}${e}`}class V{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,o;if(!this._nodes.has(t))return this;this._nodes.delete(t);const n=Array.from(this._out.get(t)??[]),i=Array.from(this._in.get(t)??[]);for(const t of n){const o=this._edges.get(t);o&&(null==(e=this._in.get(o.w))||e.delete(t)),this._edges.delete(t)}for(const t of i){const e=this._edges.get(t);e&&(null==(o=this._out.get(e.v))||o.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,o,n){var i,r;let s,a;"object"==typeof t?(s=t.v,a=t.w,n=t.name,o=e):(s=t,a=e),this.setNode(s),this.setNode(a);const d=this._isMultigraph?X(s,a,n):X(s,a),l=this._edges.get(d);if(l)void 0!==o&&(l.label=o);else{const t={v:s,w:a,name:n,label:void 0!==o?o:{}};this._edges.set(d,t),null==(i=this._out.get(s))||i.add(d),null==(r=this._in.get(a))||r.add(d)}return this}edge(t,e,o){var n;let i;return i="string"==typeof t?this._isMultigraph?X(t,e,o):X(t,e):this._isMultigraph?X(t.v,t.w,t.name):X(t.v,t.w),null==(n=this._edges.get(i))?void 0:n.label}hasEdge(t,e,o){const n=this._isMultigraph?X(t,e,o):X(t,e);return this._edges.has(n)}edges(){return Array.from(this._edges.values()).map((({v:t,w:e,name:o})=>({v:t,w:e,name:o})))}removeEdge(t){var e,o;const n=this._isMultigraph?X(t.v,t.w,t.name):X(t.v,t.w),i=this._edges.get(n);return i?(null==(e=this._out.get(i.v))||e.delete(n),null==(o=this._in.get(i.w))||o.delete(n),this._edges.delete(n),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 o=[],n=new Set;for(const i of[...this.inEdges(t),...this.outEdges(t)])if(i.v===e||i.w===e){const t=X(i.v,i.w,i.name);n.has(t)||(n.add(t),o.push(i))}return o}}function K(t){return void 0!==t.name?`${t.v}${t.w}${t.name}`:`${t.v}${t.w}`}function U(t,e){const o=function(t,e){const o=new Set,n=new V({directed:!0}),i=[];if(!t.hasNode(e))throw Error("node not in graph");return Q(t,e,o,n,i),t.nodes().forEach((e=>{o.has(e)||Q(t,e,o,n,i)})),i.forEach(((t,e)=>{n.node(t).thread=e+1<i.length?i[e+1]:i[0]})),n}(t,e);return t.edges().forEach((e=>{const n=function(t,e,o){const n=t.node(e),i=t.node(o);if((n.depth??0)<(i.depth??0)){let e=n.thread;for(;void 0!==e&&(t.node(e).depth??0)>(n.depth??0);){if(e===o)return 1;e=t.node(e).thread}}else if((i.depth??0)<(n.depth??0)){let o=i.thread;for(;void 0!==o&&(t.node(o).depth??0)>(i.depth??0);){if(o===e)return-1;o=t.node(o).thread}}return 0}(o,e.v,e.w);if(n<0){const o=t.edge(e)||{};o.reversed=!0,t.removeEdge(e),t.setEdge(e.w,e.v,o)}})),t}function Q(t,e,o,n,i,r=0){if(!o.has(e)){o.add(e),i.push(e),n.setNode(e,{depth:r});t.outEdges(e).map((t=>t.w)).forEach((s=>{o.has(s)||n.setEdge(e,s,{delta:1}),Q(t,s,o,n,i,r+1)}))}}function J(t,e){if(0===t.nodes().length)return;const o=function(t,e){const o=new V({directed:!0});let n=!1;for(const t of e)if("min"===t.type){n=!0;break}if(!n){const o=t.sources();e=o.length>0?[{nodes:[o[0]],type:"min"},...e]:[{nodes:[t.nodes()[0]],type:"min"},...e]}const i=new Map;let r=0;return e.forEach((t=>{if(!t.nodes||0===t.nodes.length)return;const e=""+r++;t.nodes.forEach((t=>{i.set(t,e)})),o.setNode(e,{nodes:t.nodes,type:t.type})})),t.nodes().forEach((t=>{if(!i.has(t)){const e=""+r++,n={nodes:[t],type:"same"};i.set(t,e),o.setNode(e,n)}})),t.edges().forEach((e=>{const n=i.get(e.v)??e.v,r=i.get(e.w)??e.w,s=t.node(e.v)||{},a=t.node(e.w)||{},d=o.edge(n,r)||{delta:0};n===r?(d.delta=0,o.setEdge(n,r,d)):"l"===s.direction?(d.delta=Math.max(d.delta??0,"l"===a.direction?1:0),o.setEdge(r,n,d)):(d.delta=Math.max(d.delta??0,"l"===a.direction?0:1),o.setEdge(n,r,d))})),o}(t,e);!function(t){t.sources().forEach((e=>{"0"!==e&&t.setEdge("0",e,{delta:0,temp:!0})}))}(o),U(o,"0"),function(t){var e;const o=t.sources(),n=new Set,i=new Set;for(t.edges().forEach((t=>{t.v===t.w&&i.add(K(t))}));o.length>0;){const r=o.shift();if(void 0===r)break;n.add(r);let s=t.node(r);s||t.setNode(r,s={}),s.rank=0;for(const o of t.inEdges(r)){const n=(null==(e=t.edge(o)||{})?void 0:e.delta)??1;s.rank=Math.max(s.rank,(t.node(o.v).rank??0)+n)}for(const e of t.outEdges(r))i.add(K(e));for(const e of t.nodes())o.indexOf(e)<0&&!n.has(e)&&!t.inEdges(e).some((t=>!i.has(K(t))))&&o.push(e)}}(o),function(t){function e(e){const o=t.node(e),n=Math.min(...t.outEdges(e).map((e=>(t.node(e.w).rank??0)-(t.edge(e).delta??0))));void 0!==n&&(o.rank=n)}t.edges().forEach((o=>{t.edge(o).temp&&e(o.w)}))}(o),t.nodes().forEach((e=>{t.node(e)||t.setNode(e,{})})),o.nodes().forEach((e=>{var n;const i=o.node(e);null==(n=i.nodes)||n.forEach((e=>{t.node(e).rank=i.rank}))}))}function tt(t){const e=Y(),o=L(t);let n=[],i=[],r=null;function s(s=[],a=[],d={}){const l=function(t=[],e=[]){const o=new V({directed:!0,multigraph:!0});return e.forEach((t=>{o.setEdge(t.source,t.target,{data:t,points:[]},t.type)})),o.nodes().forEach((t=>o.setNode(t,{data:{}}))),t.forEach((t=>{o.hasNode(t.id)&&(o.node(t.id).data=t,void 0!==t.direction&&(o.node(t.id).direction=t.direction))})),o.edges().forEach((t=>{o.edge(t).source=o.node(t.v),o.edge(t).target=o.node(t.w)})),o}(a,s);var h;return d.order?(J(l,d.rankSets||[]),r=d.order,r.length>0&&r[0].length>0&&!Array.isArray(r[0][0])&&(r=r.map((t=>[t]))),r=r.map((t=>t.map((t=>t.filter((t=>void 0!==l.node(t)))))))):(J(l,d.rankSets||[]),(h=l).edges().forEach((t=>{const e=h.node(t.v),o=h.node(t.w),n=h.edge(t);let i=e.rank;const r=[];if(void 0!==i&&void 0!==o.rank&&i+1<=o.rank){for("l"===e.direction&&r.push(i);++i<o.rank;)r.push(i);"l"===o.direction&&r.push(i),B(h,t,n,r,"r")}else if(void 0!==i&&void 0!==o.rank&&i>o.rank){for("l"!==e.direction&&r.push(i);i-- >o.rank+1;)r.push(i);"l"!==o.direction&&r.push(i),B(h,t,n,r,"l")}})),r=function(t,e=25){const o=R(t);let n=o,i=D(t,o),r=0;for(;r++<e;){W(t,o,r%2==0?1:0),F(t,o);const e=D(t,o);if(e<i&&(n=H(o),i=e),0===i)break}return n.map((t=>[t]))}(l)),n=e(l,r,t.edgeGap||0),function(t){t.nodes().forEach((e=>{const o=t.node(e);o.incoming=t.inEdges(e),o.outgoing=t.outEdges(e)}))}(l),i=o(l),function(t){t.nodes().filter((t=>t.startsWith("__"))).forEach((e=>{var o;let n=t.node(e);if(!n)return;let i=(null==(o=t.inEdges(e))?void 0:o.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 r,s=i.map((t=>t.r1));for(;n.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:s[e],x:n.x,y:t.y0}))})),s=i.map((t=>t.r1)),r=t.successors(e)[0],t.removeNode(e),n=t.node(e=r);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 o=t.edge(e);o.points||(o.points=[]),o.points.unshift({d:o.d0,ro:o.r0,x:o.x0,y:o.y0}),o.points.push({d:o.d1,ri:o.r1,x:o.x1,y:o.y1})}))}(l),l}return void 0!==t.whitespace&&e.whitespace(t.whitespace),s.nodes=function(){return n},s.links=function(){return i},s.order=function(){return r},s.size=function(t){return arguments.length?(e.size(t),s):e.size()},s.separation=function(t){return arguments.length?(e.separation(t),s):e.separation()},s.whitespace=function(t){return arguments.length?(e.whitespace(t),s):e.whitespace()},s.edgeValue=function(t){return s},s.scale=function(t){return arguments.length?(e.scale(t),s):e.scale()},s}const et=["#6b9ece","#e07b7b","#7dba8f","#b09ed1","#e0b678","#6dbaba","#d17da8","#b5b56d","#c49a6d","#8fa4b8","#c98aa0","#94bf7d","#e0a08a","#7b9eb5","#a988a8"],ot=t=>0===t.dy?0:2;function nt(t){const e=Math.max(ot(t),t.dy)/2;let{x0:o}=t,{x1:n}=t,{y0:i}=t,{y1:r}=t;n<o&&([o,n]=[n,o],[i,r]=[r,i]);const s=r>i?1:-1,a=function(t){const e=t.x1-t.x0,o=t.y1-t.y0;return[t.dy/2,(e*e+o*o)/Math.abs(4*o)]}(t),d=Math.max(a[0],Math.min(a[1],(n-o)/3));let l=Math.max(a[0],Math.min(a[1],t.r0||d)),h=Math.max(a[0],Math.min(a[1],t.r1||d));const c=n-o,u=r-i-s*(l+h),p=Math.sqrt(c*c+u*u),g=-s*Math.acos(Math.min(1,(l+h)/p)),f=Math.atan2(u,c);let m=Math.PI/2+s*(f+g),v=e*s*Math.sin(m),y=e*Math.cos(m),b=o+1*l*Math.sin(Math.abs(m)),x=n-1*h*Math.sin(Math.abs(m)),w=i+l*s*(1-Math.cos(m)),E=r-h*s*(1-Math.cos(m));function S(t,o){const n=t*(r-i)>0?1:0;let s=1*t*(r-i)>0?o+e:o-e;return 0===m&&(s=o),`A${s} ${s} ${Math.abs(m)} 0 ${n} `}return(Number.isNaN(m)||Math.abs(m)<.001)&&(m=0,l=0,h=0,b=o,x=n,w=i,E=r,v=0,y=e),`M${[o,i-e]} ${S(1,l)}${[b+v,w-y]} L${[x+v,E-y]} ${S(-1,h)}${[n,r-e]} L${[n,r+e]} ${S(1,h)}${[x-v,E+y]} L${[b-v,w+y]} ${S(-1,l)}${[o,i+e]} Z`}function it(t){var e;if(1===(null==(e=t.points)?void 0:e.length))return function(t){if(!t.points)return null;const e=t.points[0],o=Math.max(ot(t),t.dy??0)/2;return"down-right"===e.style?`M${[(e.x??0)-20,(e.y??0)-o]} L${[e.x??0,(e.y??0)-o]} L${[e.x??0,(e.y??0)+o]} L${[(e.x??0)-20,(e.y??0)+o]} Z`:"right-down"===e.style?`M${[e.x??0,(e.y??0)-o]} L${[(e.x??0)+20,(e.y??0)-o]} L${[(e.x??0)+20,(e.y??0)+o]} L${[e.x??0,(e.y??0)+o]} Z`:null}(t);if(!t.points)return null;let o,n="";for(let e=0;e<t.points.length-1;++e){const i=t.points[e],r=t.points[e+1];o={d0:i.d,d1:r.d,dy:t.dy??0,r0:i.ro,r1:r.ri,x0:i.x??0,x1:r.x??0,y0:i.y??0,y1:r.y??0},n+=nt(o)}return n}const rt=(t,e)=>{const o=(null==t?void 0:t.title)??(null==t?void 0:t.id)??"";return e&&o.length>e?`${o.substr(0,15)}...`:o};function st(t,{fontColor:e,maxRank:o,nodeWidth:n}){const{data:i}=t;if(!i)return null;const r=function(t,e){let o=!1,n=!1;return(t.rank??0)<e/2&&(n=!0,o=!1),{right:n,top:o}}(t,o),{x:s,y:a}=function(t,e,o){const n=e.top?-25:(t.dy??0)/2-10;let i;return i=e.top?e.right?4:-4:e.right?10+o/2:-o/2-10,{x:(t.x??0)+i,y:(t.y??0)+n}}(t,r,n);return function(t="",{fontColor:e="#666767",pointerEvents:o="all",textAnchor:n="start",x:i,y:r}={}){const s=new c;return s.font({fill:e}),s.tspan(t),void 0!==i&&void 0!==r&&s.move(i,r),s.attr({"pointer-events":o,"text-anchor":n}),s}(rt(i,r.top?25:15),{fontColor:e,pointerEvents:"none",textAnchor:r.top?"middle":r.right?"start":"end",x:s,y:a})}function at(t,e,o){var n,i;const{dy:r,x:s,y:a}=t,{fontColor:h="#212121",fontSize:c="14px",fontFamily:u,fontWeight:p,nodeBorderColor:g,nodeBorderWidth:f,nodeWidth:m=0,onNodeClick:v,nodeTooltip:y}=o,E=new d({class:"node"}),S=function({borderColor:t="#caced0",color:e="#97cbe6",height:o=0,opacity:n=1,radius:i=0,width:r=0,x:s=0,y:a=0}={}){const d=new l;return d.attr({height:o,opacity:n,rx:i,ry:i,width:r,x:s,y:a}),d.fill(e),d.stroke({color:t,width:1}),d}({height:r,width:m,x:(s??0)-m/2,y:a});if(S.fill(null==(n=t.data)?void 0:n.color),S.stroke({color:g??(null==(i=t.data)?void 0:i.color),width:f}),S.on("click",(()=>{"function"==typeof v&&v(t)})),y){const{chartContext:e,isCustomTooltip:o,nodeValue:n,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s,tooltipId:a,nodeTooltipTemplate:d}=y,l=d({node:t.data,value:n});S.on("mouseover",(t=>{const{pageX:n,pageY:d}=t,g=w({bgColor:o?void 0:i,borderColor:o?void 0:r,fontColor:o?void 0:s||h,fontFamily:o?void 0:u??"",fontSize:o?void 0:c??"14px",fontWeight:o?void 0:p??"400",x:n,y:d});x(e,a,g,l,!0)})),S.on("mousemove",(t=>{const{pageX:n,pageY:d}=t,g=w({bgColor:o?void 0:i,borderColor:o?void 0:r,fontColor:o?void 0:s||h,fontFamily:o?void 0:u??"",fontSize:o?void 0:c??"14px",fontWeight:o?void 0:p??"400",x:n,y:d});x(e,a,g,l,!0)})),S.on("mouseout",(()=>{b(e,a).style.display="none"}))}if(E.add(S),t.data&&(r??0)>Number.parseInt(c,10)){const o=st(t,{fontColor:h,maxRank:e,nodeWidth:m});o&&E.add(o)}return E}const dt={canvasStyle:"border: 1px solid #caced0; box-sizing: border-box",edgeGap:0,edgeGradientFill:!0,edgeOpacity:.4,enableToolbar:!0,enableTooltip:!0,fontColor:"#212121",fontFamily:"",fontSize:"14px",fontWeight:"400",height:"auto",nodeBorderColor:null,nodeBorderWidth:1,nodeWidth:20,onNodeClick:void 0,spacing:20,tooltipBGColor:"#FFFFFF",tooltipBorderColor:"#E2E8F0",tooltipFontColor:"#1a1a1a",tooltipId:"apexsankey-tooltip-container",tooltipTemplate:({source:t,target:e,value:o})=>`\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;'>${o}</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,width:"100%",highlightConnectedPath:!0,dimOpacity:.2,animation:{enabled:!0,duration:800},a11y:{enabled:!0}};class lt{constructor(t,e,o){this.element=t,this.options=e,this.chartContext=o,t.innerHTML="",this.canvas=function(){const t=document.createElementNS(r,"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,o,n){this.canvas.viewbox(`${t} ${e} ${o} ${n}`)}get height(){return this.options.viewPortHeight}get spacing(){return this.options.spacing}get width(){return this.options.viewPortWidth}}class ht{constructor(t,e,o){this.svgRoot=t,this.graph=e,this.dimOpacity=o}highlightNode(t){const e=this.prefersReducedMotion(),o=[...this.graph.inEdges(t)??[],...this.graph.outEdges(t)??[]],n=new Set([t]);o.forEach((t=>{var e,o,i,r;const s=this.graph.edge(t.v,t.w,t.name),a=null==(o=null==(e=null==s?void 0:s.source)?void 0:e.data)?void 0:o.id,d=null==(r=null==(i=null==s?void 0:s.target)?void 0:i.data)?void 0:r.id;a&&n.add(a),d&&n.add(d)})),this.dimAll(e),o.forEach((t=>{const o=this.svgRoot.querySelector(`[data-edge-source="${t.v}"][data-edge-target="${t.w}"]`);o&&this.setOpacity(o,1,e)})),n.forEach((t=>{const o=this.svgRoot.querySelector(`[data-node-id="${t}"]`);o&&this.setOpacity(o,1,e)}))}highlightEdge(t,e){var o,n,i,r;const s=this.prefersReducedMotion(),a=this.graph.edge(t,e),d=(null==(n=null==(o=null==a?void 0:a.source)?void 0:o.data)?void 0:n.id)??t,l=(null==(r=null==(i=null==a?void 0:a.target)?void 0:i.data)?void 0:r.id)??e;this.dimAll(s),this.svgRoot.querySelectorAll(`[data-edge-source="${t}"][data-edge-target="${e}"]`).forEach((t=>this.setOpacity(t,1,s)));const h=this.svgRoot.querySelector(`[data-node-id="${d}"]`),c=this.svgRoot.querySelector(`[data-node-id="${l}"]`);h&&this.setOpacity(h,1,s),c&&this.setOpacity(c,1,s)}reset(){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,o){t.style.transition=o?"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 ct(t,e){const o=e=>function(t,e){return getComputedStyle(t).getPropertyValue(e).trim()}(t,e),n=o("--apex-sankey-edge-opacity"),i=""!==n?Number(n):e.edgeOpacity,r=o("--apex-sankey-node-width"),s=""!==r?Number(r):e.nodeWidth,a=o("--apex-sankey-node-border-width"),d=""!==a?Number(a):e.nodeBorderWidth,l=o("--apex-sankey-edge-gradient"),h=""!==l?"true"===l:e.edgeGradientFill,c=o("--apex-sankey-node-border-color")||e.nodeBorderColor,u=o("--apex-sankey-tooltip-bg")||e.tooltipBGColor,p=o("--apex-sankey-tooltip-border-color")||e.tooltipBorderColor,g=o("--apex-sankey-tooltip-font-color")||e.tooltipFontColor,f=o("--apex-sankey-tooltip-theme"),m="dark"===f||"light"===f?f:e.tooltipTheme;return{...e,edgeGradientFill:h,edgeOpacity:Number.isFinite(i)?i:e.edgeOpacity,fontColor:o("--apex-sankey-label-color")||e.fontColor,fontSize:o("--apex-sankey-label-font-size")||e.fontSize,fontFamily:o("--apex-sankey-font-family")||e.fontFamily,nodeBorderColor:c,nodeBorderWidth:Number.isFinite(d)?d:e.nodeBorderWidth,nodeWidth:Number.isFinite(s)?s:e.nodeWidth,tooltipBGColor:u,tooltipBorderColor:p,tooltipFontColor:g,tooltipTheme:m}}const ut="#005FCC",pt="role",gt="aria-label",ft="data-node-id",mt="data-orig-stroke",vt="data-orig-stroke-width",yt="stroke",bt="stroke-width",xt="forced-colors",wt="apexsankey-desc",Et="data-edge-target";const St="apexsankey-a11y-styles";class At{constructor(t,e,o={},n,i){this.svgEl=t,this.graph=e,this.options=o,this.tooltipId=n,this.pathHighlighter=i,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(St))return;const t=document.createElement("style");t.id=St,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: ${ut};\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,options:o}=this,n=e.nodes().filter((t=>!e.node(t).dummy)),i=e.edges(),r=function(t,e,o,n){var i,r,s,a;if(n)return n;let d=0,l="",h="";for(const e of o)try{const o=t.edge(e.v,e.w,e.name).value??0;if(o>d){const n=t.node(e.v),c=t.node(e.w);n.dummy||c.dummy||(d=o,l=(null==(i=n.data)?void 0:i.title)??(null==(r=n.data)?void 0:r.id)??e.v,h=(null==(s=c.data)?void 0:s.title)??(null==(a=c.data)?void 0:a.id)??e.w)}}catch{}let c=`Sankey flow diagram: ${e.length} nodes, ${o.length} flows.`;return l&&h&&(c+=` Largest flow: ${l} (${d} units) to ${h}.`),c}(e,n,i,o.diagramLabel);t.setAttribute(pt,"img"),t.setAttribute(gt,r),t.removeAttribute("aria-labelledby");const s=t.querySelector("title");if(s&&s.remove(),o.description){let e=t.querySelector("desc");if(!e){const o=document.createElementNS("http://www.w3.org/2000/svg","desc");o.id=wt,t.insertBefore(o,t.firstChild),e=o}e.textContent=o.description,t.setAttribute("aria-describedby",wt)}const a=Array.from(t.querySelectorAll(`[${ft}]`));a.forEach((t=>{const o=t.getAttribute(ft);o&&(t.setAttribute(pt,"listitem"),t.setAttribute(gt,function(t,e){var o,n,i,r,s,a;const d=e.node(t),l=(null==(o=d.data)?void 0:o.title)??(null==(n=d.data)?void 0:n.id)??t,h=[];let c=0;for(const o of e.inEdges(t))try{const t=e.edge(o.v,o.w,o.name),n=e.node(o.v);n.dummy||(h.push((null==(i=n.data)?void 0:i.title)??(null==(r=n.data)?void 0:r.id)??o.v),c+=t.value??0)}catch{}const u=[];let p=0;for(const o of e.outEdges(t))try{const t=e.edge(o.v,o.w,o.name),n=e.node(o.w);n.dummy||(u.push((null==(s=n.data)?void 0:s.title)??(null==(a=n.data)?void 0:a.id)??o.w),p+=t.value??0)}catch{}let g=l;h.length>0&&(g+=`: receives ${c} units from ${h.join(", ")}`),u.length>0&&(g+=`${h.length>0?"; ":": "}flows ${p} units to ${u.join(", ")}`);return g}(o,e)),t.setAttribute("tabindex","0"))})),this.nodeGroups=a;const d=[],l=new Map,h=new Map;t.querySelectorAll("[data-edge-source]").forEach((t=>{var o,n,i,r;const s=t.getAttribute("data-edge-source"),a=t.getAttribute("data-edge-target"),c=t.getAttribute("data-edge-name")??void 0;if(s&&a)try{const u=e.edge(s,a,c),p=u.source,g=u.target;if(!p||!g)return;const f=(null==(o=p.data)?void 0:o.title)??(null==(n=p.data)?void 0:n.id)??s,m=(null==(i=g.data)?void 0:i.title)??(null==(r=g.data)?void 0:r.id)??a,v=u.value??0;t.setAttribute("role","img"),t.setAttribute("aria-label",`Flow from ${f} to ${m}: ${v} units`),t.setAttribute("focusable","true"),t.setAttribute("tabindex","-1"),d.push(t),h.set(t,s),l.has(s)||l.set(s,[]);const y=l.get(s);y&&y.push(t)}catch{}})),this.edgePaths=d,this.nodeOutEdges=l,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",(o=>{const n=o.key;if("Enter"===n||" "===n){o.preventDefault();const e=t.querySelector("rect");e&&e.dispatchEvent(new MouseEvent("click",{bubbles:!0}))}else if("Escape"===n)o.preventDefault(),this.restoreFocusRing(t),t.blur(),this.hideTooltip();else if("ArrowRight"===n||"ArrowDown"===n){o.preventDefault();const n=t.getAttribute(ft),i=n?this.nodeOutEdges.get(n)??[]:[];if(i.length>0)i[0].focus();else{this.nodeGroups[(e+1)%this.nodeGroups.length].focus()}}else if("ArrowLeft"===n||"ArrowUp"===n){o.preventDefault();this.nodeGroups[(e-1+this.nodeGroups.length)%this.nodeGroups.length].focus()}})),t.addEventListener("focus",(()=>{var e;if(this.isKeyboardUser){this.applyFocusRing(t);const o=t.getAttribute(ft);o&&(null==(e=this.pathHighlighter)||e.highlightNode(o))}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)??[]:[]},o=()=>{const e=this.edgeSourceNode.get(t),o=e?this.nodeGroups.find((t=>t.getAttribute(ft)===e)):void 0;o&&o.focus()};t.addEventListener("keydown",(n=>{const i=n.key;if("Enter"===i||" "===i)n.preventDefault(),t.dispatchEvent(new MouseEvent("click",{bubbles:!0}));else if("Escape"===i||"ArrowLeft"===i)n.preventDefault(),o();else if("ArrowDown"===i){n.preventDefault();const o=e(),i=o.indexOf(t);o[(i+1)%o.length].focus()}else if("ArrowUp"===i){n.preventDefault();const o=e(),i=o.indexOf(t);o[(i-1+o.length)%o.length].focus()}else if("ArrowRight"===i){n.preventDefault();const e=t.getAttribute(Et),o=e?this.nodeGroups.find((t=>t.getAttribute(ft)===e)):void 0;o&&o.focus()}else if("Tab"===i){const e=this.edgeSourceNode.get(t),o=this.nodeGroups.findIndex((t=>t.getAttribute(ft)===e));if(-1!==o){const t=n.shiftKey?(o-1+this.nodeGroups.length)%this.nodeGroups.length:(o+1)%this.nodeGroups.length;n.preventDefault(),this.nodeGroups[t].focus()}}})),t.addEventListener("focus",(()=>{var e;if(this.isKeyboardUser){const o=t.getAttribute("data-edge-source"),n=t.getAttribute(Et);o&&n&&(null==(e=this.pathHighlighter)||e.highlightEdge(o,n))}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 o=t.relatedTarget;o&&this.edgePaths.includes(o)||(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(mt,e.getAttribute(yt)??""),e.setAttribute(vt,e.getAttribute(bt)??""),e.setAttribute(yt,ut),e.setAttribute(bt,"2"))}restoreFocusRing(t){const e=t.querySelector("rect");if(!e)return;const o=e.getAttribute(mt),n=e.getAttribute(vt);null!==o&&(e.setAttribute(yt,o),e.removeAttribute(mt)),null!==n&&(e.setAttribute(bt,n),e.removeAttribute(vt))}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(xt),this.forcedColorsHandler=t=>{t.matches?this.svgEl.classList.add(xt):this.svgEl.classList.remove(xt)},t.addEventListener("change",this.forcedColorsHandler)}catch{}}}const Ct="http://www.w3.org/2000/svg";class kt extends lt{constructor(t,e,o){super(t,e,o),this.a11yHelper=null,this.pathHighlighter=null,this._hasAnimated=!1,this.renderOptions=e}construct(t){const{edgeGap:e,nodeWidth:o,spacing:n,viewPortHeight:i,viewPortWidth:r,whitespace:s}=this.options,a=tt({edgeGap:e,nodeWidth:o,whitespace:s});a.size([r-o,i-n]);const d=t.nodes.map(((t,e)=>{const o=e%et.length;return{...t,color:t.color??et[o],colorIndex:o}})),l=a(t.edges,d);this.maxRank=(a.order()??[]).length-1,this.graph=l}render({keepOldPosition:t=!1}={}){var e,o;this.renderOptions=ct(this.element,this.options);const{tooltipTheme:n,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s}=this.renderOptions;"dark"===n?this.renderOptions={...this.renderOptions,tooltipBGColor:"#1e2433",tooltipBorderColor:"#374151",tooltipFontColor:"#e5e7eb"}:"light"===n&&(this.renderOptions={...this.renderOptions,tooltipBGColor:i,tooltipBorderColor:r,tooltipFontColor:s});const{enableTooltip:a,fontColor:d,fontFamily:l,fontSize:h,fontWeight:c,highlightConnectedPath:u,dimOpacity:p,nodeBorderColor:g,nodeBorderWidth:m,nodeWidth:v,nodeTooltipTemplate:y,onNodeClick:x,tooltipBGColor:w,tooltipBorderColor:E,tooltipFontColor:S,tooltipId:A}=this.renderOptions,C=this.canvas.viewbox();this.clear(),this.pathHighlighter=u?new ht(this.canvas.node,this.graph,p):null;const k=((t={})=>{const e=[];for(const n in t){const i=`${o=n,o.replace(/([A-Z])/g,(t=>`-${t.toLowerCase()}`))}: ${t[n]};`;e.push(i)}var o;return e.join(" ")})({color:d,fontFamily:l,fontSize:h,fontWeight:c}),$=f(v/2,0);$.attr("style",k);const M=(null==(e=this.graph)?void 0:e.nodes())||[],L=(null==(o=this.graph)?void 0:o.edges())||[],T=f();L.forEach((t=>{this.renderEdge(t,T)})),$.add(T);const _=f();_.node.setAttribute("role","list"),_.node.setAttribute("aria-label","Sankey nodes"),M.forEach((t=>{const e=this.graph.node(t);if(e.dummy)return;let o;if(a&&y){const e=this.graph.inEdges(t)??[],n=this.graph.outEdges(t)??[],i=e.reduce(((t,e)=>{var o;return t+((null==(o=this.graph.edge(e.v,e.w,e.name))?void 0:o.value)??0)}),0),r=n.reduce(((t,e)=>{var o;return t+((null==(o=this.graph.edge(e.v,e.w,e.name))?void 0:o.value)??0)}),0),s=Math.max(i,r);o={chartContext:this.chartContext,isCustomTooltip:y!==dt.nodeTooltipTemplate,nodeTooltipTemplate:y,nodeValue:s,tooltipBGColor:w,tooltipBorderColor:E,tooltipFontColor:S,tooltipId:A}}const n=at(e,this.maxRank,{fontColor:d,fontFamily:l,fontSize:h,fontWeight:c,nodeBorderColor:g,nodeBorderWidth:m,nodeWidth:v,nodeTooltip:o,onNodeClick:x});if(n.node.setAttribute("data-node-id",t),n.node.setAttribute("data-node-rank",String(e.rank??0)),this.pathHighlighter){const e=this.pathHighlighter;n.node.addEventListener("mouseenter",(()=>e.highlightNode(t))),n.node.addEventListener("mouseleave",(()=>e.reset()))}_.add(n)})),$.add(_),this.add($);const{animation:B}=this.renderOptions;if((null==B?void 0:B.enabled)&&!this._hasAnimated&&(this._hasAnimated=!0,function(t,e,o,n,i){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const r=t.viewBox.baseVal,s=r.width,a=r.x,d=t.querySelector("defs")??(()=>{const e=document.createElementNS(Ct,"defs");return t.insertBefore(e,t.firstChild),e})(),l=`sankey-flow-clip-${Math.random().toString(36).slice(2,9)}`,h=document.createElementNS(Ct,"clipPath");h.setAttribute("id",l);const c=document.createElementNS(Ct,"rect");c.setAttribute("x",String(a)),c.setAttribute("y","-9999"),c.setAttribute("height","99999"),c.setAttribute("width","0"),h.appendChild(c),d.appendChild(h),e.setAttribute("clip-path",`url(#${l})`);let u=null;requestAnimationFrame((function t(o){null===u&&(u=o);const n=o-u,r=Math.min(n/i,1),a=((d=r)<.5?2*d*d:(4-2*d)*d-1)*s;var d;c.setAttribute("width",String(a)),r<1?requestAnimationFrame(t):(e.removeAttribute("clip-path"),h.remove())}));const p=o.querySelectorAll("[data-node-rank]"),g=.1*i,f=.7*i-g,m=.45*i;p.forEach((t=>{const e=parseInt(t.getAttribute("data-node-rank")??"0",10),o=g+(n>0?e/n:0)*f;t.style.opacity="0",t.animate([{opacity:"0",transform:"translateY(6px)"},{opacity:"1",transform:"translateY(0px)"}],{duration:m,delay:o,easing:"cubic-bezier(0.4, 0, 0.2, 1)",fill:"forwards"}).onfinish=()=>{t.style.opacity="",t.style.transform=""}}))}(this.canvas.node,T.node,_.node,this.maxRank,B.duration)),t&&this.updateViewBox(C.x,C.y,C.width,C.height),a){const t=b(this.chartContext,A);this.chartContext.getAppendContainer().appendChild(t)}this.a11yHelper&&this.a11yHelper.destroy();const N=this.renderOptions.a11y;!1!==(null==N?void 0:N.enabled)&&(this.a11yHelper=new At(this.canvas.node,this.graph,N,A,this.pathHighlighter),this.a11yHelper.apply())}renderEdge(t,e){const{edgeGradientFill:o,edgeOpacity:n,enableTooltip:i,fontFamily:r,fontSize:s,fontWeight:a,nodeWidth:d,tooltipBGColor:l,tooltipBorderColor:c,tooltipFontColor:u,tooltipId:p,tooltipTemplate:g}=this.renderOptions,f=this.graph.edge(t.v,t.w,t.name),m=this.graph.node(t.v),v=this.graph.node(t.w),y=f.source,E=f.target;if(!y||!E)return;m.dummy&&(f.x0=(f.x0??0)-d/2),v.dummy&&(f.x1=(f.x1??0)+d/2);const S=it(f);if(!S)return;const A=function(t,{edgeColor:e,id:o="",opacity:n=1}={}){const i=new h({d:t});return i.id(o),i.fill(e).opacity(n),i}(S,{edgeColor:this.canvas.gradient("linear",(t=>{var e,n,i;t.stop(0,(null==(e=y.data)?void 0:e.color)??""),t.stop(1,o?(null==(n=E.data)?void 0:n.color)??"":(null==(i=y.data)?void 0:i.color)??"")})),id:`${t.v}-${t.w}`,opacity:n});if(A.node.setAttribute("data-edge-source",t.v),A.node.setAttribute("data-edge-target",t.w),void 0!==t.name&&A.node.setAttribute("data-edge-name",t.name),this.pathHighlighter){const e=this.pathHighlighter,o=t.v,n=t.w;A.on("mouseenter",(()=>e.highlightEdge(o,n))),A.on("mouseleave",(()=>e.reset()))}if(i&&y.data&&E.data){const t=g?g({source:y.data,target:E.data,value:f.value}):`${y.data.title} → ${E.data.title}: ${f.value}`,e=g!==dt.tooltipTemplate;A.on("mouseover",(o=>{const{pageX:n,pageY:i}=o,d=w({bgColor:e?void 0:l,borderColor:e?void 0:c,fontColor:e?void 0:u,fontFamily:e?void 0:r,fontSize:e?void 0:s,fontWeight:e?void 0:a,x:n,y:i});x(this.chartContext,p,d,t,!0)})),A.on("mousemove",(o=>{const{pageX:n,pageY:i}=o,d=w({bgColor:e?void 0:l,borderColor:e?void 0:c,fontColor:e?void 0:u,fontFamily:e?void 0:r,fontSize:e?void 0:s,fontWeight:e?void 0:a,x:n,y:i});x(this.chartContext,p,d,t,!0)})),A.on("mouseout",(()=>{b(this.chartContext,p).style.display="none"}))}e.add(A)}}class $t extends n{constructor(t,e={}){super(t,"sankey_"+crypto.randomUUID().replace(/-/g,"").substring(0,9)),this.options={...dt,...e};const{height:o,width:n}=this.options;this.graph=new kt(this.element,this.options,this.chartContext),this.setupElementDimensions(n,o),this.handleWatermark()}static setLicense(t){A.setLicense(t)}setupElementDimensions(t,e){let o=!1,n=0;"string"==typeof t&&/^\d+(\.\d+)?%$/.test(t)?(n=Number(t.substring(0,t.length-1)),o=!0):n=Number(t);const i="auto"===e?n/1.6:e;this.element.style.width=`${n}${o?"%":"px"}`,this.element.style.height=`${i}${o?"%":"px"}`,this.element.style.position="relative"}handleWatermark(){this.element&&(A.isLicenseValid()?k.remove(this.element):k.add(this.element))}render(t){if(!this.element)throw new Error("Element not found");if(this.graph.construct(t),this.graph.render(),this.options.enableToolbar){new v(this.element,this.chartContext).render({enableExport:!0,onExport:this.graph.exportToSvg.bind(this.graph)})}return this.graph}}"undefined"!=typeof window&&(window.ApexSankey=$t),t.ApexSankey=$t,t.default=$t,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|
package/demo/basic-sankey.html
CHANGED
|
@@ -3,82 +3,99 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>
|
|
7
|
-
<link href="https://fonts.googleapis.com
|
|
6
|
+
<title>Basic Sankey - Household Budget</title>
|
|
7
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
8
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
9
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet" />
|
|
8
10
|
<script src="../apexsankey.min.js"></script>
|
|
11
|
+
<style>
|
|
12
|
+
body {
|
|
13
|
+
max-width: 1000px;
|
|
14
|
+
margin: 0 auto;
|
|
15
|
+
font-family: 'Inter', sans-serif;
|
|
16
|
+
background: #fff;
|
|
17
|
+
padding: 20px 0;
|
|
18
|
+
}
|
|
19
|
+
h2 {
|
|
20
|
+
font-size: 22px;
|
|
21
|
+
font-weight: 700;
|
|
22
|
+
color: #1a1a2e;
|
|
23
|
+
margin: 0 0 4px 0;
|
|
24
|
+
line-height: 1.3;
|
|
25
|
+
}
|
|
26
|
+
.subtitle {
|
|
27
|
+
font-size: 13px;
|
|
28
|
+
color: #6e6e6e;
|
|
29
|
+
margin-bottom: 16px;
|
|
30
|
+
}
|
|
31
|
+
</style>
|
|
9
32
|
</head>
|
|
10
33
|
<body>
|
|
11
|
-
<
|
|
34
|
+
<h2>Household Monthly Budget</h2>
|
|
35
|
+
<p class="subtitle">
|
|
36
|
+
A simple Sankey showing how income flows through budget categories to specific expenses (<code
|
|
37
|
+
>edgeGradientFill: true</code
|
|
38
|
+
>, <code>enableToolbar: true</code>)
|
|
39
|
+
</p>
|
|
40
|
+
<div id="svg-sankey"></div>
|
|
12
41
|
<script>
|
|
13
42
|
const data = {
|
|
14
43
|
nodes: [
|
|
15
|
-
{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
id: 'Electricity',
|
|
33
|
-
title: 'Electricity',
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
id: 'Energy',
|
|
37
|
-
title: 'Energy',
|
|
38
|
-
},
|
|
44
|
+
{id: 'Salary', title: 'Salary', color: '#6366F1'},
|
|
45
|
+
{id: 'Freelance', title: 'Freelance', color: '#8B5CF6'},
|
|
46
|
+
{id: 'Housing', title: 'Housing', color: '#F43F5E'},
|
|
47
|
+
{id: 'Food', title: 'Food', color: '#F97316'},
|
|
48
|
+
{id: 'Transport', title: 'Transport', color: '#0EA5E9'},
|
|
49
|
+
{id: 'Savings', title: 'Savings', color: '#10B981'},
|
|
50
|
+
{id: 'Entertainment', title: 'Entertainment', color: '#EC4899'},
|
|
51
|
+
{id: 'Rent', title: 'Rent', color: '#FB7185'},
|
|
52
|
+
{id: 'Utilities', title: 'Utilities', color: '#FDA4AF'},
|
|
53
|
+
{id: 'Groceries', title: 'Groceries', color: '#FDBA74'},
|
|
54
|
+
{id: 'Dining Out', title: 'Dining Out', color: '#FB923C'},
|
|
55
|
+
{id: 'Car Payment', title: 'Car Payment', color: '#38BDF8'},
|
|
56
|
+
{id: 'Gas & Transit', title: 'Gas & Transit', color: '#7DD3FC'},
|
|
57
|
+
{id: 'Emergency Fund', title: 'Emergency Fund', color: '#34D399'},
|
|
58
|
+
{id: 'Investments', title: 'Investments', color: '#6EE7B7'},
|
|
59
|
+
{id: 'Streaming', title: 'Streaming', color: '#F9A8D4'},
|
|
60
|
+
{id: 'Hobbies', title: 'Hobbies', color: '#F472B6'},
|
|
39
61
|
],
|
|
40
62
|
edges: [
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
value: 25,
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
source: 'Fossil Fuels',
|
|
63
|
-
target: 'Energy',
|
|
64
|
-
value: 60,
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
source: 'Electricity',
|
|
68
|
-
target: 'Energy',
|
|
69
|
-
value: 25,
|
|
70
|
-
},
|
|
63
|
+
{source: 'Salary', target: 'Housing', value: 1800},
|
|
64
|
+
{source: 'Salary', target: 'Food', value: 900},
|
|
65
|
+
{source: 'Salary', target: 'Transport', value: 600},
|
|
66
|
+
{source: 'Salary', target: 'Savings', value: 1200},
|
|
67
|
+
{source: 'Salary', target: 'Entertainment', value: 300},
|
|
68
|
+
{source: 'Freelance', target: 'Food', value: 200},
|
|
69
|
+
{source: 'Freelance', target: 'Savings', value: 500},
|
|
70
|
+
{source: 'Freelance', target: 'Entertainment', value: 300},
|
|
71
|
+
{source: 'Housing', target: 'Rent', value: 1500},
|
|
72
|
+
{source: 'Housing', target: 'Utilities', value: 300},
|
|
73
|
+
{source: 'Food', target: 'Groceries', value: 750},
|
|
74
|
+
{source: 'Food', target: 'Dining Out', value: 350},
|
|
75
|
+
{source: 'Transport', target: 'Car Payment', value: 400},
|
|
76
|
+
{source: 'Transport', target: 'Gas & Transit', value: 200},
|
|
77
|
+
{source: 'Savings', target: 'Emergency Fund', value: 700},
|
|
78
|
+
{source: 'Savings', target: 'Investments', value: 1000},
|
|
79
|
+
{source: 'Entertainment', target: 'Streaming', value: 200},
|
|
80
|
+
{source: 'Entertainment', target: 'Hobbies', value: 400},
|
|
71
81
|
],
|
|
72
82
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
83
|
+
|
|
84
|
+
const options = {
|
|
85
|
+
nodeWidth: 18,
|
|
86
|
+
fontFamily: 'Inter, sans-serif',
|
|
87
|
+
fontWeight: '500',
|
|
88
|
+
fontSize: '12px',
|
|
89
|
+
fontColor: '#334155',
|
|
90
|
+
width: '100%',
|
|
91
|
+
height: 520,
|
|
92
|
+
edgeGradientFill: true,
|
|
93
|
+
edgeOpacity: 0.35,
|
|
79
94
|
enableToolbar: true,
|
|
95
|
+
canvasStyle: 'border: 1px solid #e2e8f0; border-radius: 8px; background: #fafafa; box-sizing: border-box;',
|
|
80
96
|
};
|
|
81
|
-
|
|
97
|
+
|
|
98
|
+
const s = new ApexSankey(document.getElementById('svg-sankey'), options);
|
|
82
99
|
s.render(data);
|
|
83
100
|
</script>
|
|
84
101
|
</body>
|
package/demo/css-theming.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>ApexSankey
|
|
6
|
+
<title>ApexSankey - CSS Custom Property Theming</title>
|
|
7
7
|
<script src="../apexsankey.min.js"></script>
|
|
8
8
|
<style>
|
|
9
9
|
*,
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
.content {
|
|
79
|
-
max-width:
|
|
79
|
+
max-width: 1000px;
|
|
80
80
|
margin: 32px auto;
|
|
81
81
|
padding: 0 24px;
|
|
82
82
|
display: flex;
|
|
@@ -207,15 +207,15 @@
|
|
|
207
207
|
--apex-sankey-node-width: 16;
|
|
208
208
|
--apex-sankey-node-border-color: transparent;
|
|
209
209
|
--apex-sankey-node-border-width: 0;
|
|
210
|
-
|
|
211
|
-
--apex-sankey-tooltip-
|
|
210
|
+
/* tooltipTheme shortcut sets bg + border + text color together */
|
|
211
|
+
--apex-sankey-tooltip-theme: light;
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
body[data-theme='dark'] #sankey-live {
|
|
215
215
|
--apex-sankey-edge-opacity: 0.4;
|
|
216
216
|
--apex-sankey-label-color: #c9d1d9;
|
|
217
|
-
|
|
218
|
-
--apex-sankey-tooltip-
|
|
217
|
+
/* one token flips the whole tooltip to a readable dark preset */
|
|
218
|
+
--apex-sankey-tooltip-theme: dark;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
/* ── prefers-color-scheme: dark (no JS required) ────────────── */
|
|
@@ -229,8 +229,7 @@
|
|
|
229
229
|
--apex-sankey-node-width: 16;
|
|
230
230
|
--apex-sankey-node-border-color: transparent;
|
|
231
231
|
--apex-sankey-node-border-width: 0;
|
|
232
|
-
--apex-sankey-tooltip-
|
|
233
|
-
--apex-sankey-tooltip-border-color: #30363d;
|
|
232
|
+
--apex-sankey-tooltip-theme: dark;
|
|
234
233
|
}
|
|
235
234
|
}
|
|
236
235
|
</style>
|
|
@@ -282,13 +281,13 @@
|
|
|
282
281
|
>/* Light mode tokens on the container */ #my-sankey { --apex-sankey-edge-opacity: 0.5;
|
|
283
282
|
--apex-sankey-edge-gradient: true; --apex-sankey-label-color: #2d3748; --apex-sankey-label-font-size: 12px;
|
|
284
283
|
--apex-sankey-font-family: system-ui, sans-serif; --apex-sankey-node-width: 16;
|
|
285
|
-
--apex-sankey-node-border-color: transparent; --apex-sankey-node-border-width: 0;
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
#
|
|
289
|
-
via a manual [data-theme] toggle */
|
|
290
|
-
|
|
291
|
-
|
|
284
|
+
--apex-sankey-node-border-color: transparent; --apex-sankey-node-border-width: 0; /* tooltipTheme sets the
|
|
285
|
+
tooltip bg + border + text color together */ --apex-sankey-tooltip-theme: light; } /* Dark mode — via OS
|
|
286
|
+
preference (no JS required). One token flips the whole tooltip to a readable dark preset. */ @media
|
|
287
|
+
(prefers-color-scheme: dark) { #my-sankey { --apex-sankey-edge-opacity: 0.4; --apex-sankey-label-color:
|
|
288
|
+
#c9d1d9; --apex-sankey-tooltip-theme: dark; } } /* Dark mode — via a manual [data-theme] toggle */
|
|
289
|
+
[data-theme="dark"] #my-sankey { --apex-sankey-edge-opacity: 0.4; --apex-sankey-label-color: #c9d1d9;
|
|
290
|
+
--apex-sankey-tooltip-theme: dark; }</code
|
|
292
291
|
>
|
|
293
292
|
</section>
|
|
294
293
|
|
|
@@ -301,7 +300,7 @@
|
|
|
301
300
|
<div class="token-swatch" style="background: rgba(100, 160, 255, 0.5)"></div>
|
|
302
301
|
<div>
|
|
303
302
|
<div class="token-name">--apex-sankey-edge-opacity</div>
|
|
304
|
-
<div>Flow edge opacity (0
|
|
303
|
+
<div>Flow edge opacity (0-1, default 0.4)</div>
|
|
305
304
|
</div>
|
|
306
305
|
</div>
|
|
307
306
|
<div class="token-item">
|
|
@@ -367,6 +366,23 @@
|
|
|
367
366
|
<div>Tooltip border color (default #BCBCBC)</div>
|
|
368
367
|
</div>
|
|
369
368
|
</div>
|
|
369
|
+
<div class="token-item">
|
|
370
|
+
<div class="token-swatch" style="background: #1a1a1a"></div>
|
|
371
|
+
<div>
|
|
372
|
+
<div class="token-name">--apex-sankey-tooltip-font-color</div>
|
|
373
|
+
<div>Tooltip text color (default #1a1a1a)</div>
|
|
374
|
+
</div>
|
|
375
|
+
</div>
|
|
376
|
+
<div class="token-item">
|
|
377
|
+
<div
|
|
378
|
+
class="token-swatch"
|
|
379
|
+
style="background: linear-gradient(135deg, #ffffff 0 50%, #1e2433 50% 100%)"
|
|
380
|
+
></div>
|
|
381
|
+
<div>
|
|
382
|
+
<div class="token-name">--apex-sankey-tooltip-theme</div>
|
|
383
|
+
<div>'light' | 'dark' — shortcut that sets tooltip bg + border + text together</div>
|
|
384
|
+
</div>
|
|
385
|
+
</div>
|
|
370
386
|
</div>
|
|
371
387
|
</section>
|
|
372
388
|
</main>
|
|
@@ -403,7 +419,7 @@
|
|
|
403
419
|
};
|
|
404
420
|
|
|
405
421
|
const sankeyOptions = {
|
|
406
|
-
width:
|
|
422
|
+
width: '100%',
|
|
407
423
|
height: 420,
|
|
408
424
|
nodeWidth: 14,
|
|
409
425
|
edgeGradientFill: true,
|