UNPKG

apexcharts

Version:

A JavaScript Chart Library

6 lines (5 loc) 26.9 kB
/*! * ApexCharts v7.0.0 * (c) 2018-2026 ApexCharts */ "use strict";var t=Object.defineProperty,e=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,i=Object.prototype.propertyIsEnumerable,n=(e,r,i)=>r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[r]=i,a=(t,a)=>{for(var s in a||(a={}))r.call(a,s)&&n(t,s,a[s]);if(e)for(var s of e(a))i.call(a,s)&&n(t,s,a[s]);return t};Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function s(t){if(t&&t.__esModule)return t;const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t)for(const r in t)if("default"!==r){const i=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,i.get?i:{enumerable:!0,get:()=>t[r]})}return e.default=t,Object.freeze(e)}const l=s(require("apexcharts/core")),o=l.__apex_Environment_Environment,h=l.__apex_BrowserAPIs_BrowserAPIs,u=l.__apex_Animations_prefersReducedMotion,c=l.__apex_PathMorphing_parsePath;function p(t,e){if(!(e>0))return[];if(1===e)return[a({},t)];const r=t.width>=t.height,i=r?t.width:t.height,n=r?t.height:t.width,s=n>0?i/n:e;let l=Math.max(1,Math.ceil(Math.sqrt(s*e)));l>e&&(l=e);const o=Math.floor(e/l);let h=e-o*l;const u=[],c=i/l;let p=0;for(let e=0;e<l;e++){const e=o+(h>0?1:0);h>0&&h--;const i=e>0?n/e:0;for(let n=0;n<e;n++)u.push(r?{x:t.x+p,y:t.y+n*i,width:c,height:i}:{x:t.x+n*i,y:t.y+p,width:i,height:c});p+=c}return u}function d(t,e,r){if(!(e>0))return[];const i=t.width>=t.height,n=i?t.width:t.height,a=i?t.height:t.width,s=i?t.y:t.x,l=s+a,o=a>0?n/a:e;let h=Math.max(Math.ceil(Math.sqrt(o*e)),Math.ceil(n/16));h>=1||(h=1),h>e&&(h=e);const u=Math.floor(e/h);let c=e-u*h;const p=[],d=n/h;let f=i?t.x:t.y;for(let t=0;t<h;t++){const t=u+(c>0?1:0);c>0&&c--;const e=[],n=r(f,f+d,i);if(Array.isArray(n))for(let t=0;t<n.length;t++){const r=n[t];if(!r)continue;const i=Math.max(s,Math.min(r[0],r[1])),a=Math.min(l,Math.max(r[0],r[1]));a>i&&e.push([i,a])}e.length||e.push([s,l]);const a=e.reduce((t,e)=>t+(e[1]-e[0]),0),o=e.map(r=>a>0?(r[1]-r[0])/a*t:t/e.length),h=o.map(t=>Math.floor(t));let g=h.reduce((t,e)=>t+e,0);const y=o.map((t,e)=>({i:e,frac:t-Math.floor(t)})).sort((t,e)=>e.frac-t.frac);for(let e=0;g<t;e++,g++)h[y[e%y.length].i]++;for(let t=0;t<e.length;t++){const r=h[t];if(r<=0)continue;const n=e[t][0],a=(e[t][1]-n)/r;for(let t=0;t<r;t++)p.push(i?{x:f,y:n+t*a,width:d,height:a}:{x:n+t*a,y:f,width:a,height:d})}f+=d}return p}function f(t,e,r,i,n,a){let s=n===r?0:Math.round((t-r)/(n-r)*32767),l=a===i?0:Math.round((e-i)/(a-i)*32767),o=0;for(let t=32768;t>=1;t/=2){const e=(s&t)>0?1:0,r=(l&t)>0?1:0;if(o+=t*t*(3*e^r),0===r){1===e&&(s=t-1-s,l=t-1-l);const r=s;s=l,l=r}}return o}function g(t,e){let r=1/0,i=1/0,n=-1/0,a=-1/0;const s=t.map(t=>{const[s,l]=e(t);return s<r&&(r=s),s>n&&(n=s),l<i&&(i=l),l>a&&(a=l),[s,l]});return t.map((t,e)=>({item:t,d:f(s[e][0],s[e][1],r,i,n,a)})).sort((t,e)=>t.d-e.d).map(t=>t.item)}function y(t){if(!t||"string"!=typeof t)return null;const e=t.trim();if("#"===e[0]){const t=e.slice(1);return 3===t.length?[parseInt(t[0]+t[0],16),parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16),1]:6===t.length||8===t.length?[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16),8===t.length?parseInt(t.slice(6,8),16)/255:1]:null}const r=e.match(/^rgba?\(([^)]+)\)$/i);if(r){const t=r[1].split(",").map(t=>parseFloat(t));return t.length<3||t.some(t=>!isFinite(t))?null:[t[0],t[1],t[2],t.length>3?t[3]:1]}return null}function m(t,e){const r=y(t),i=y(e);return r&&i?t=>{const e=Math.round(r[0]+(i[0]-r[0])*t),n=Math.round(r[1]+(i[1]-r[1])*t),a=Math.round(r[2]+(i[2]-r[2])*t),s=r[3]+(i[3]-r[3])*t;return s>=1?`rgb(${e},${n},${a})`:`rgba(${e},${n},${a},${s})`}:null}function b(t){return t<.5?4*t*t*t:1-Math.pow(-2*t+2,3)/2}const x=new Set(["bar","funnel","pyramid","histogram"]),A=new Set(["pie","donut","polarArea","radialBar","gauge"]),_=new Set(["unit","waffle"]),w=new Set(["treemap","sunburst"]),$=new Set(["boxPlot","violin"]),v=1500;function M(t){return x.has(t)?"bar":A.has(t)?"radial":_.has(t)?"unit":w.has(t)?"partition":$.has(t)?"summary":null}l.default.registerFeatures({morphTypeChange:class{constructor(t,e){this.w=t,this.ctx=e,this._snapshot=null,this._ghost=null,this._pieceLayer=null,this._pieceCancel=null}canMorphTypes(t,e){if(t===e)return!1;const r=M(t),i=M(e);return!(!r||!i)&&("partition"===r==("partition"===i)||"unit"!==r&&"unit"!==i)}isCompatibleSeriesShape(t,e,r){if(!Array.isArray(r)||0===r.length)return!1;const i=M(t),n=M(e);return"unit"===n?!!r.every(t=>"number"==typeof t)||r.every(t=>t&&"object"==typeof t&&Array.isArray(t.data)):"partition"===n||("radial"===n?!!r.every(t=>"number"==typeof t)||1===r.length&&r[0]&&"object"==typeof r[0]&&Array.isArray(r[0].data):"bar"===n||"summary"===n?r.every(t=>t&&"object"==typeof t&&Array.isArray(t.data)):null!==i&&null!==n)}captureBeforeDestroy({fromType:t,toType:e,newSeries:r}){if(this._snapshot=null,this._removeGhost(),this._cancelPieces(),!o.isBrowser())return!1;const i=this.w.config.chart.animations;if(!i||!1===i.enabled)return!1;if(i.chartTypeMorph&&!1===i.chartTypeMorph.enabled)return!1;if(i.respectReducedMotion&&u())return!1;if(!this.canMorphTypes(t,e))return!1;if(!this.isCompatibleSeriesShape(t,e,r))return!1;const{marks:n,branches:a,unitDots:s}=this._captureFromDOM(t);if(!n.length)return!1;const l=this._buildMapping(n,t,e,r,a);if(0===l.size)return!1;this._snapshot={fromType:t,toType:e,mapping:l,oldLayout:{translateX:this.w.layout.translateX||0,translateY:this.w.layout.translateY||0}};const h=M(t),c=M(e),p=this._canProbePaths();if("unit"===c&&("bar"===h||"summary"===h||"radial"===h&&p)){const t=this._countUnitSeries(r);this._snapshot.pieceOut=t>0&&t<=v}else if("unit"===h&&("bar"===c||"summary"===c||"radial"===c&&p)){let t=0;if(s.forEach(e=>{t+=e.length}),t>0&&t<=v){this._snapshot.pieceIn=!0,this._snapshot.sourceDots=s;const t=[];"radial"===c?(Array.isArray(r)?r:[]).forEach((e,r)=>{t.push(`${r}:0`)}):(Array.isArray(r)?r:[]).forEach((e,r)=>{const i=e&&Array.isArray(e.data)?e.data:[];for(let e=0;e<i.length;e++)t.push(`${r}:${e}`)}),this._snapshot.keyOrder=t}}return!this._needsGhost(t,e)||this._snapshot.pieceOut||this._snapshot.pieceIn||this._captureGhost(),this.w.globals.previousPaths=[],!0}_needsGhost(t,e){return"unit"===M(t)||"unit"===M(e)}_captureGhost(){var t,e;const r=null==(t=this.w.dom)?void 0:t.Paper,i=r&&r.node;if(!i||"function"!=typeof i.cloneNode)return;const n=i.cloneNode(!0),a=[".apexcharts-xaxis",".apexcharts-yaxis",".apexcharts-grid",".apexcharts-gridlines-horizontal",".apexcharts-gridlines-vertical",".apexcharts-legend",".apexcharts-title-text",".apexcharts-subtitle-text",".apexcharts-annotations",".apexcharts-zoom-rect",".apexcharts-selection-rect",".apexcharts-xcrosshairs",".apexcharts-ycrosshairs"];"function"==typeof n.querySelectorAll&&a.forEach(t=>{n.querySelectorAll(t).forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)})}),"function"==typeof n.querySelectorAll&&n.querySelectorAll("[id]").forEach(t=>{t.removeAttribute("id")}),null==(e=n.removeAttribute)||e.call(n,"id"),this._ghost=n}_mountGhost(){var t,e,r;const i=this._ghost;if(!i||!o.isBrowser())return;const n=null==(t=this.w.dom)?void 0:t.elWrap;if(!n||"function"!=typeof n.appendChild)return void(this._ghost=null);const a=i.style;a&&(a.position="absolute",a.left="0",a.top="0",a.background="transparent",a.pointerEvents="none",a.opacity="1"),null==(e=i.setAttribute)||e.call(i,"aria-hidden","true"),null==(r=i.setAttribute)||r.call(i,"class","apexcharts-morph-ghost"),n.appendChild(i);const s=this.getSpeed(),l=Math.max(120,Math.round(.55*s));h.requestAnimationFrame(()=>{a&&(a.transition=`opacity ${l}ms ease-in`,a.opacity="0")}),setTimeout(()=>this._removeGhost(),l+60)}_removeGhost(){const t=this._ghost;this._ghost=null,t&&t.parentNode&&t.parentNode.removeChild(t)}_countUnitSeries(t){if(!Array.isArray(t))return 0;let e=0;for(const r of t){if(!r||"object"!=typeof r||!Array.isArray(r.data))return 0;e+=r.data.length}return e}usesPieceTakeover(){return!(!this._snapshot||!this._snapshot.pieceOut)}claimsTargetMark(t,e){return!!(this._snapshot&&this._snapshot.pieceIn&&this._snapshot.mapping.has(`${t}:${e}`))}_makePieceLayer(){var t,e;const r=null==(t=this.w.dom)?void 0:t.elGraphical,i=r&&r.node;if(!i||"function"!=typeof i.appendChild)return null;const n=h.createElementNS("http://www.w3.org/2000/svg","g");if(!n)return null;n.setAttribute("class","apexcharts-morph-pieces"),n.setAttribute("pointer-events","none");const a=null==(e=this.w.globals)?void 0:e.cuid;return a&&n.setAttribute("clip-path",`url(#gridRectBarMask${a})`),i.appendChild(n),this._pieceLayer=n,n}_revealPieceHidden(){var t;const e=null==(t=this.w.globals.dom)?void 0:t.baseEl;e&&"function"==typeof e.querySelectorAll&&e.querySelectorAll("[data-piece-hidden]").forEach(t=>{t.removeAttribute("opacity"),t.removeAttribute("data-piece-hidden")})}_cancelPieces(){this._pieceCancel&&(this._pieceCancel(),this._pieceCancel=null);const t=this._pieceLayer;this._pieceLayer=null,t&&t.parentNode&&t.parentNode.removeChild(t),this._revealPieceHidden()}_canProbePaths(){if(!o.isBrowser())return!1;const t=h.createElementNS("http://www.w3.org/2000/svg","path");return!!t&&"function"==typeof t.isPointInFill}_makeExtentProber(t,e,r){const i=r.ownerDocument.createElementNS("http://www.w3.org/2000/svg","path");i.setAttribute("d",t),i.setAttribute("fill","#000"),i.setAttribute("stroke","#000"),i.setAttribute("stroke-width","3"),i.setAttribute("visibility","hidden"),r.appendChild(i);const n=i.ownerSVGElement;if("function"!=typeof i.isPointInFill||!n||"function"!=typeof n.createSVGPoint)return r.removeChild(i),null;const a=n.createSVGPoint(),s=(t,e)=>{a.x=t,a.y=e;const r=i;return r.isPointInFill(a)||"function"==typeof r.isPointInStroke&&r.isPointInStroke(a)},l=48;return{intervalsAt:(t,r,i)=>{const n=i?e.y:e.x,a=n+(i?e.height:e.width);if(!(a>n))return null;const o=(t,e)=>i?s(e,t):s(t,e),h=[t+.1*(r-t),(t+r)/2,r-.1*(r-t)],u=(t,e,r)=>{let i=e,n=t;for(let t=0;t<6;t++){const t=(i+n)/2;o(t,r)?n=t:i=t}return(i+n)/2},c=(a-n)/l,p=new Array(49).fill(null);let d=!1;for(const t of h)for(let e=0;e<=l;e++)null===p[e]&&o(n+e*c,t)&&(p[e]=t,d=!0);if(!d)return null;const f=[];let g=-1;for(let t=0;t<=49;t++){const e=t<=l&&null!==p[t];if(e&&g<0&&(g=t),!e&&g>=0){const e=t-1,r=p[g],i=0===g?n:u(n+g*c,n+(g-1)*c,r),s=e===l?a:u(n+e*c,n+(e+1)*c,p[e]);s>i&&f.push([i,s]),g=-1}}return f.length?f:null},dispose:()=>{i.parentNode&&i.parentNode.removeChild(i)}}}_separatePieces(){var t;const e=this._snapshot,r=null==(t=this.w.globals.dom)?void 0:t.baseEl;if(!e||!r)return this._revealPieceHidden();const i=new Map;let n=0;if(r.querySelectorAll(".apexcharts-unit-area").forEach(t=>{var e,r,a,s,l,o,h;const u=parseInt(null!=(e=t.getAttribute("i"))?e:"",10);if(isNaN(u))return;const c=t.getAttribute("cx");let p,d,f=3;if(null!=c)p=parseFloat(c),d=parseFloat(null!=(r=t.getAttribute("cy"))?r:""),f=parseFloat(null!=(a=t.getAttribute("r"))?a:"3")||3;else{const e=parseFloat(null!=(s=t.getAttribute("width"))?s:"0")||0,r=parseFloat(null!=(l=t.getAttribute("height"))?l:"0")||0;p=parseFloat(null!=(o=t.getAttribute("x"))?o:"")+e/2,d=parseFloat(null!=(h=t.getAttribute("y"))?h:"")+r/2,f=Math.max(e,r)/2||3}if(!isFinite(p)||!isFinite(d))return;let g=i.get(u);g||(g=[],i.set(u,g)),g.push({el:t,x:p,y:d,r:f,fill:t.getAttribute("fill")}),n++}),0===n||n>v)return this._revealPieceHidden();const a=this._makePieceLayer();if(!a)return this._revealPieceHidden();const s=[],l=a.ownerDocument,o=M(e.fromType),h="summary"===o||"radial"===o;if(Array.from(i.keys()).sort((t,e)=>t-e).forEach(t=>{var r;const n=i.get(t),o=this.getInitialBBoxFor(t),u=e.mapping.get(`${t}:0`);if(!o||!u)return void n.forEach(t=>{t.el.removeAttribute("opacity"),t.el.removeAttribute("data-piece-hidden")});const c=u.fill&&0!==u.fill.indexOf("url(")?u.fill:(null==(r=this.w.globals.colors)?void 0:r[t])||n[0].fill;let f=null;if(h){const e=this.getInitialPathFor(t,0);e&&(f=this._makeExtentProber(e,o,a))}const y=f?d(o,n.length,f.intervalsAt):p(o,n.length);f&&f.dispose();const b=g(y,t=>[t.x+t.width/2,t.y+t.height/2]),x=g(n,t=>[t.x,t.y]);for(let e=0;e<x.length;e++){const r=b[e],i=x[e],n=l.createElementNS("http://www.w3.org/2000/svg","rect");n.setAttribute("data-i",String(t)),n.setAttribute("x",String(r.x)),n.setAttribute("y",String(r.y)),n.setAttribute("width",String(r.width)),n.setAttribute("height",String(r.height)),n.setAttribute("rx","0"),n.setAttribute("fill",String(c)),a.appendChild(n),s.push({el:n,from:{x:r.x,y:r.y,width:r.width,height:r.height,rx:0},to:{x:i.x-i.r,y:i.y-i.r,width:2*i.r,height:2*i.r,rx:i.r},fill:m(c,i.fill),fillEnd:i.fill,delay:0,meta:{dotEl:i.el}})}}),!s.length)return this._cancelPieces();this._runPieces(s,t=>{const e=t.meta.dotEl;e.removeAttribute("opacity"),e.removeAttribute("data-piece-hidden"),t.el.parentNode&&t.el.parentNode.removeChild(t.el)})}_combinePieces(){var t,e;const r=this._snapshot,i=null==(t=this.w.globals.dom)?void 0:t.baseEl;if(!(r&&r.sourceDots&&r.keyOrder&&i))return this._revealPieceHidden();const n=this._collectTargetMarks(r.toType);if(!n.size)return this._revealPieceHidden();const a=r.oldLayout.translateX-(this.w.layout.translateX||0),s=r.oldLayout.translateY-(this.w.layout.translateY||0),l=Array.from(r.sourceDots.keys()).sort((t,e)=>t-e),o=this._makePieceLayer();if(!o)return this._revealPieceHidden();const h=o.ownerDocument,u=[],c=M(r.toType),f="summary"===c||"radial"===c;for(let t=0;t<l.length;t++){const i=r.sourceDots.get(l[t]),c=r.keyOrder[t],y=c?n.get(c):null;if(!y||!i||!i.length){y&&y.els.forEach(t=>{t.removeAttribute("opacity"),t.removeAttribute("data-piece-hidden")});continue}const b=y.fill&&0!==y.fill.indexOf("url(")?y.fill:(null==(e=this.w.globals.colors)?void 0:e[y.realIndex])||i[0].fill;let x=null;if(f){const t=y.d||y.els.map(t=>t.getAttribute("pathTo")||t.getAttribute("d")).filter(Boolean).join(" ");t&&(x=this._makeExtentProber(t,y.bbox,o))}const A=x?d(y.bbox,i.length,x.intervalsAt):p(y.bbox,i.length);x&&x.dispose();const _=g(A,t=>[t.x+t.width/2,t.y+t.height/2]),w=g(i,t=>[t.x,t.y]),$={remaining:w.length,els:y.els,tiles:[]};for(let t=0;t<w.length;t++){const e=w[t],r=_[t],i=h.createElementNS("http://www.w3.org/2000/svg","rect"),n=e.x+a-e.r,l=e.y+s-e.r;i.setAttribute("data-key",c),i.setAttribute("x",String(n)),i.setAttribute("y",String(l)),i.setAttribute("width",String(2*e.r)),i.setAttribute("height",String(2*e.r)),i.setAttribute("rx",String(e.r)),i.setAttribute("fill",String(e.fill||b)),o.appendChild(i),$.tiles.push(i),u.push({el:i,from:{x:n,y:l,width:2*e.r,height:2*e.r,rx:e.r},to:{x:r.x,y:r.y,width:r.width,height:r.height,rx:0},fill:m(e.fill,b),fillEnd:String(b),delay:0,meta:{markState:$}})}}if(!u.length)return this._cancelPieces();this._runPieces(u,t=>{const e=t.meta.markState;e.remaining--,0===e.remaining&&(e.els.forEach(t=>{t.removeAttribute("opacity"),t.removeAttribute("data-piece-hidden")}),e.tiles.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}))})}_runPieces(t,e){const r=this.getSpeed(),i=Math.min(300,.35*r),n=Math.max(180,r-i);for(let e=0;e<t.length;e++)t[e].delay=t.length>1?e/(t.length-1)*i:0;this._pieceCancel=function({pieces:t,duration:e,onPieceDone:r,onAllDone:i}){let n=!1;const a=Date.now(),s=Math.max(1,e),l=(t,e)=>{const r=t.from,i=t.to,n=t.el;n.setAttribute("x",String(r.x+(i.x-r.x)*e)),n.setAttribute("y",String(r.y+(i.y-r.y)*e)),n.setAttribute("width",String(Math.max(0,r.width+(i.width-r.width)*e))),n.setAttribute("height",String(Math.max(0,r.height+(i.height-r.height)*e))),n.setAttribute("rx",String(Math.max(0,r.rx+(i.rx-r.rx)*e))),t.fill?n.setAttribute("fill",t.fill(e)):e>=1&&t.fillEnd&&n.setAttribute("fill",t.fillEnd)},o=()=>{if(n)return;const e=Date.now()-a;let u=!1;for(let i=0;i<t.length;i++){const n=t[i];if(n._done)continue;const a=(e-n.delay)/s;if(a<1&&(u=!0),a<=0)continue;const o=Math.min(1,a);l(n,b(o)),o>=1&&(n._done=!0,r&&r(n))}u?h.requestAnimationFrame(o):i&&i()};return h.requestAnimationFrame(o),()=>{n=!0}}({pieces:t,duration:n,onPieceDone:e,onAllDone:()=>{this._pieceCancel=null,this._cancelPieces()}})}_collectTargetMarks(t){var e;const r=null==(e=this.w.globals.dom)?void 0:e.baseEl,i=new Map;if(!r)return i;const n=M(t);if("radial"===n)return r.querySelectorAll(".apexcharts-pie-series .apexcharts-pie-area").forEach((t,e)=>{const r=t.getAttribute("data:pathFinal")||t.getAttribute("d");if(!r||!r.trim())return;const n=this._pathBBox(r);n&&i.set(`${e}:0`,{realIndex:e,j:0,d:r,bbox:{x:n.minX,y:n.minY,width:n.maxX-n.minX,height:n.maxY-n.minY},fill:t.getAttribute("fill"),els:[t]})}),i;const a="summary"===n?`.apexcharts-${t}-series`:".apexcharts-bar-series";return r.querySelectorAll(`${a} .apexcharts-series`).forEach(t=>{var e;const r=parseInt(null!=(e=t.getAttribute("data:realIndex"))?e:"0",10)||0;let n=0;t.querySelectorAll("path[pathTo]").forEach(t=>{var e;const a=t.getAttribute("pathTo")||t.getAttribute("d");if(!a||!a.trim())return;const s=parseInt(null!=(e=t.getAttribute("j"))?e:"",10),l=isNaN(s)?n++:s,o=this._pathBBox(a);if(!o)return;const h=`${r}:${l}`,u=i.get(h);u?(u.els.push(t),u.bbox={x:Math.min(u.bbox.x,o.minX),y:Math.min(u.bbox.y,o.minY),width:Math.max(u.bbox.x+u.bbox.width,o.maxX)-Math.min(u.bbox.x,o.minX),height:Math.max(u.bbox.y+u.bbox.height,o.maxY)-Math.min(u.bbox.y,o.minY)}):i.set(h,{realIndex:r,j:l,bbox:{x:o.minX,y:o.minY,width:o.maxX-o.minX,height:o.maxY-o.minY},fill:t.getAttribute("fill"),els:[t]})})}),i}_captureFromDOM(t){var e;const r=null==(e=this.w.globals.dom)?void 0:e.baseEl;if(!r)return{marks:[],branches:[],unitDots:new Map};const i=[],n=[],a=new Map,s=M(t);if("bar"===s){r.querySelectorAll(".apexcharts-bar-series .apexcharts-series").forEach(t=>{var e;const r=parseInt(null!=(e=t.getAttribute("data:realIndex"))?e:"0",10);t.querySelectorAll("path[pathTo]").forEach((t,e)=>{const n=t.getAttribute("pathTo")||t.getAttribute("d");n&&i.push({realIndex:r,j:e,d:n,fill:t.getAttribute("fill")})})})}else if("summary"===s){const e=new Map;r.querySelectorAll(`.apexcharts-${t}-area`).forEach(t=>{var r,i;const n=parseInt(null!=(r=t.getAttribute("j"))?r:"",10);if(isNaN(n))return;const a=t.getAttribute("pathTo")||t.getAttribute("d");if(!a||!a.trim())return;const s="function"==typeof t.closest?t.closest(".apexcharts-series"):null,l=parseInt(null!=(i=null==s?void 0:s.getAttribute("data:realIndex"))?i:"0",10)||0,o=`${l}:${n}`,h=e.get(o);h?h.d+=` ${a}`:e.set(o,{realIndex:l,j:n,d:a,fill:t.getAttribute("fill")})}),Array.from(e.values()).sort((t,e)=>t.realIndex-e.realIndex||t.j-e.j).forEach(t=>i.push(t))}else if("partition"===s)if("treemap"===t){const t=t=>{var e,r,i,n;const a=parseFloat(null!=(e=t.getAttribute("x"))?e:""),s=parseFloat(null!=(r=t.getAttribute("y"))?r:""),l=parseFloat(null!=(i=t.getAttribute("width"))?i:""),o=parseFloat(null!=(n=t.getAttribute("height"))?n:"");return[a,s,l,o].every(t=>isFinite(t))?`M ${a} ${s} L ${a+l} ${s} L ${a+l} ${s+o} L ${a} ${s+o} Z`:null};r.querySelectorAll(".apexcharts-treemap-rect").forEach(e=>{var r,n;const a=t(e);a&&i.push({realIndex:parseInt(null!=(r=e.getAttribute("i"))?r:"0",10)||0,j:parseInt(null!=(n=e.getAttribute("j"))?n:"0",10)||0,d:a,fill:e.getAttribute("fill"),key:e.getAttribute("data:key")||null})});r.querySelectorAll(".apexcharts-treemap-parent-rect").forEach(e=>{const r=t(e),i=e.getAttribute("data:key");r&&i&&n.push({key:i,d:r,fill:e.getAttribute("fill")})})}else{const t=r.querySelectorAll(".apexcharts-sunburst-arc"),e=[];t.forEach(t=>{"true"===t.getAttribute("data:leaf")&&e.push(t)});(e.length?e:Array.from(t)).forEach((t,e)=>{const r=t.getAttribute("d");r&&r.trim()&&i.push({realIndex:e,j:0,d:r,fill:t.getAttribute("fill"),key:t.getAttribute("data:key")||null})}),t.forEach(t=>{if("true"===t.getAttribute("data:leaf"))return;const e=t.getAttribute("d"),r=t.getAttribute("data:key");e&&e.trim()&&r&&n.push({key:r,d:e,fill:t.getAttribute("fill")})})}else if("unit"===s){const t=r.querySelectorAll(".apexcharts-unit-area"),e=new Map;t.forEach(t=>{var r,i,n,s,l,o,h;const u=parseInt(null!=(r=t.getAttribute("i"))?r:"",10);if(isNaN(u))return;const c=t.getAttribute("cx");let p,d,f=3;if(null!=c)p=parseFloat(c),d=parseFloat(null!=(i=t.getAttribute("cy"))?i:""),f=parseFloat(null!=(n=t.getAttribute("r"))?n:"3")||3;else{const e=parseFloat(null!=(s=t.getAttribute("width"))?s:"0")||0,r=parseFloat(null!=(l=t.getAttribute("height"))?l:"0")||0;p=parseFloat(null!=(o=t.getAttribute("x"))?o:"")+e/2,d=parseFloat(null!=(h=t.getAttribute("y"))?h:"")+r/2,f=Math.max(e,r)/2||3}if(!isFinite(p)||!isFinite(d))return;let g=a.get(u);g||(g=[],a.set(u,g)),g.push({x:p,y:d,r:f,fill:t.getAttribute("fill")});const y=e.get(u);y?(p<y.minX&&(y.minX=p),p>y.maxX&&(y.maxX=p),d<y.minY&&(y.minY=d),d>y.maxY&&(y.maxY=d)):e.set(u,{minX:p,minY:d,maxX:p,maxY:d,fill:t.getAttribute("fill")})}),Array.from(e.keys()).sort((t,e)=>t-e).forEach(t=>{const r=e.get(t),n=r.minX-2,a=r.minY-2,s=r.maxX+2,l=r.maxY+2;i.push({realIndex:t,j:0,d:`M ${n} ${a} L ${s} ${a} L ${s} ${l} L ${n} ${l} Z`,fill:r.fill})})}else if("radial"===s)if("radialBar"===t||"gauge"===t){const t=this.w.layout.gridWidth/2,e=Math.min(this.w.layout.gridWidth,this.w.layout.gridHeight)/2;r.querySelectorAll(".apexcharts-radial-series .apexcharts-radialbar-area").forEach(r=>{var n;const a=r.parentElement,s=parseInt(null!=(n=null==a?void 0:a.getAttribute("data:realIndex"))?n:"0",10),l=r.getAttribute("d");if(!l)return;const o=parseFloat(r.getAttribute("stroke-width")||"0"),h=o>1&&this._radialArcToFilledSegment(l,o,t,e)||l;i.push({realIndex:s,j:0,d:h,fill:r.getAttribute("stroke")})})}else{r.querySelectorAll(".apexcharts-pie-series .apexcharts-pie-area").forEach((t,e)=>{const r=t.getAttribute("d");r&&i.push({realIndex:e,j:0,d:r,fill:t.getAttribute("fill")})})}return{marks:i,branches:n,unitDots:a}}_radialArcToFilledSegment(t,e,r,i){const n=t.match(/M\s*(-?[\d.]+)\s+(-?[\d.]+)\s+A\s*(-?[\d.]+)\s+(?:-?[\d.]+)\s+(?:-?[\d.]+)\s+(\d)\s+(\d)\s+(-?[\d.]+)\s+(-?[\d.]+)/);if(!n)return null;const a=parseFloat(n[1]),s=parseFloat(n[2]),l=parseFloat(n[3]),o=parseInt(n[4],10),h=parseInt(n[5],10),u=parseFloat(n[6]),c=parseFloat(n[7]);if(!isFinite(l)||l<=0)return null;const p=e/2,d=l+p,f=Math.max(0,l-p),g=(t,e,n)=>{const a=t-r,s=e-i,l=Math.sqrt(a*a+s*s);if(0===l)return{x:r,y:i};const o=n/l;return{x:r+a*o,y:i+s*o}},y=g(a,s,d),m=g(u,c,d),b=g(a,s,f),x=g(u,c,f),A=h?0:1;return`M ${y.x} ${y.y} A ${d} ${d} 0 ${o} ${h} ${m.x} ${m.y} L ${x.x} ${x.y} A ${f} ${f} 0 ${o} ${A} ${b.x} ${b.y} Z`}buildRingSegmentPath(t,e,r,i,n,a){const s=i/2,l=r+s,o=Math.max(0,r-s),h=(n-90)*Math.PI/180,u=(a-90)*Math.PI/180,c=t+l*Math.cos(h),p=e+l*Math.sin(h),d=t+l*Math.cos(u),f=e+l*Math.sin(u),g=t+o*Math.cos(h),y=e+o*Math.sin(h),m=t+o*Math.cos(u),b=e+o*Math.sin(u),x=a>n?1:0,A=Math.abs(a-n)>180?1:0;return`M ${c} ${p} A ${l} ${l} 0 ${A} ${x} ${d} ${f} L ${m} ${b} A ${o} ${o} 0 ${A} ${1-x} ${g} ${y} Z`}getFromType(){return this._snapshot?this._snapshot.fromType:null}_buildMapping(t,e,r,i,n){const a=new Map,s=M(r),l=t.slice().sort((t,e)=>t.realIndex-e.realIndex||t.j-e.j);if("partition"===s&&n&&n.length){const t=l.filter(t=>t.key);t.length===l.length&&(t.forEach(t=>{a.set(`key:${t.key}`,{d:t.d,fill:t.fill})}),n.forEach(t=>{a.set(`key:${t.key}`,{d:t.d,fill:t.fill})}))}if("radial"===s||"unit"===s||"partition"===s)return l.forEach((t,e)=>{a.set(`${e}:0`,{d:t.d,fill:t.fill})}),a;if("bar"===s||"summary"===s){const t=[];return(Array.isArray(i)?i:[]).forEach((e,r)=>{const i=e&&Array.isArray(e.data)?e.data:[];for(let e=0;e<i.length;e++)t.push({realIndex:r,j:e})}),l.forEach((e,r)=>{const i=t[r];i&&a.set(`${i.realIndex}:${i.j}`,{d:e.d,fill:e.fill})}),a}return a}isActive(){return null!==this._snapshot}getInitialPathFor(t,e){if(!this._snapshot)return null;const r=this._snapshot.mapping.get(`${t}:${e}`);if(!r)return null;const i=this._snapshot.oldLayout.translateX-(this.w.layout.translateX||0),n=this._snapshot.oldLayout.translateY-(this.w.layout.translateY||0);return 0===i&&0===n?r.d:this._translatePathD(r.d,i,n)}_translatePathD(t,e,r){if(0===e&&0===r)return t;return c(t).map(t=>{const i=t[0];return"Z"===i?"Z":"M"===i||"L"===i||"T"===i?`${i} ${t[1]+e} ${t[2]+r}`:"H"===i?`${i} ${t[1]+e}`:"V"===i?`${i} ${t[1]+r}`:"C"===i?`${i} ${t[1]+e} ${t[2]+r} ${t[3]+e} ${t[4]+r} ${t[5]+e} ${t[6]+r}`:"S"===i||"Q"===i?`${i} ${t[1]+e} ${t[2]+r} ${t[3]+e} ${t[4]+r}`:"A"===i?`${i} ${t[1]} ${t[2]} ${t[3]} ${t[4]} ${t[5]} ${t[6]+e} ${t[7]+r}`:t.join(" ")}).join(" ")}getInitialCenterFor(t){const e=this.getInitialBBoxFor(t);return e?{x:e.x+e.width/2,y:e.y+e.height/2}:null}getInitialPathAt(t){return this.getInitialPathFor(t,0)}getInitialPathForKey(t){return this._snapshot&&t?this.getInitialPathFor("key",t):null}hasKeyedMarks(){if(!this._snapshot)return!1;for(const t of this._snapshot.mapping.keys())if("string"==typeof t&&t.startsWith("key:"))return!0;return!1}getInitialSlotFor(t,e,r){const i=this.getInitialBBoxFor(t);if(!i)return null;const n=i.x+i.width/2,a=i.y+i.height/2;if(!(r>1&&e>=0))return{x:n,y:a};const s=(Math.min(e,r-1)+.5)/r;return i.height>=i.width?{x:n,y:i.y+i.height*(1-s)}:{x:i.x+i.width*s,y:a}}getInitialBBoxFor(t){if(!this._snapshot)return null;const e=this._snapshot.mapping.get(`${t}:0`);if(!e)return null;const r=this._pathBBox(e.d);if(!r)return null;const i=this._snapshot.oldLayout.translateX-(this.w.layout.translateX||0),n=this._snapshot.oldLayout.translateY-(this.w.layout.translateY||0);return{x:r.minX+i,y:r.minY+n,width:r.maxX-r.minX,height:r.maxY-r.minY}}_pathBBox(t){const e=c(t);let r=1/0,i=1/0,n=-1/0,a=-1/0,s=!1;return e.forEach(t=>{const e=t[0];if("Z"===e)return;let l=[];if("H"===e)l=[[t[1],(i+a)/2||t[1]]];else if("V"===e)l=[[(r+n)/2||t[1],t[1]]];else if("A"===e)l=[[t[6],t[7]]];else for(let e=1;e+1<t.length;e+=2)l.push([t[e],t[e+1]]);l.forEach(([t,e])=>{isFinite(t)&&isFinite(e)&&(s=!0,t<r&&(r=t),t>n&&(n=t),e<i&&(i=e),e>a&&(a=e))})}),s?{minX:r,minY:i,maxX:n,maxY:a}:null}getInitialFillFor(t,e){if(!this._snapshot)return null;const r=this._snapshot.mapping.get(`${t}:${e}`);return r?r.fill:null}getSpeed(){const t=this.w.config.chart.animations;return t.chartTypeMorph&&t.chartTypeMorph.speed||t.speed||600}applyChromeFade(){var t;if(!this._snapshot||!o.isBrowser())return;const e=null==(t=this.w.globals.dom)?void 0:t.baseEl;if(!e)return;this._snapshot.pieceOut?this._separatePieces():this._snapshot.pieceIn?this._combinePieces():this._mountGhost();const r=this.getSpeed();[".apexcharts-xaxis",".apexcharts-yaxis",".apexcharts-grid",".apexcharts-gridlines-horizontal",".apexcharts-gridlines-vertical",".apexcharts-legend",".apexcharts-title-text",".apexcharts-subtitle-text"].forEach(t=>{e.querySelectorAll(t).forEach(t=>{t.style&&(t.style.opacity="0",t.style.transition=`opacity ${r}ms ease-out`,h.requestAnimationFrame(()=>{t.style.opacity="1"}),setTimeout(()=>{t.style.transition="",t.style.opacity=""},r+80))})}),setTimeout(()=>this.cleanup(),r+100)}cleanup(){this._snapshot=null,this._removeGhost(),this._cancelPieces()}}}),Object.defineProperty(exports,"default",{enumerable:!0,get:()=>l.default});