UNPKG

apexcharts

Version:

A JavaScript Chart Library

6 lines (5 loc) 14.4 kB
/*! * ApexCharts v6.6.1 * (c) 2018-2026 ApexCharts */ "use strict";var e=Object.defineProperty,t=(t,n,i)=>((t,n,i)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i)(t,"symbol"!=typeof n?n+"":n,i);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("apexcharts/core");function i(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const n in e)if("default"!==n){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:()=>e[n]})}return t.default=e,Object.freeze(t)}const s=i(n),r=s.__apex_Utils,a=s.__apex_Environment_Environment;function o(e,t){const n=null!=e,i=null!=t;return n||i?{min:n?e:null,max:i?t:null}:null}function l(e){return Array.isArray(e)?e.map(e=>Array.isArray(e)?e.slice():e):[]}function c(e,t){return"function"==typeof e&&t?e===t.addXaxisAnnotation?"xaxis":e===t.addYaxisAnnotation?"yaxis":e===t.addPointAnnotation?"point":null:null}function d(e,t){const n=e.config.annotations?r.clone(e.config.annotations):null,i=[],s=e.globals.memory&&e.globals.memory.methodsToExec||[];for(const e of s){if(!e||"addAnnotation"!==e.label)continue;const n=c(e.method,t);n&&i.push({kind:n,params:r.clone(e.params)})}return{static:n,dynamic:i}}function u(e){const t=e&&e.measure;if(!t||"function"!=typeof t.getPins)return null;const n=t.getPins();return Array.isArray(n)&&n.length?{pins:n}:null}function f(e,t,{animate:n=!0,mergeOptions:i}={}){var s,a;if(!e||!t)return;"number"==typeof t.v&&t.v,e.clearAnnotations();const o=i?r.clone(i):{},c=t.window&&t.window.xaxis;o.xaxis=Object.assign({},o.xaxis,c?{min:null!=(s=c.min)?s:void 0,max:null!=(a=c.max)?a:void 0}:{min:void 0,max:void 0});const d=t.window&&t.window.yaxis;if(Array.isArray(d)&&(o.yaxis=d.map(e=>{var t,n;return e?{min:null!=(t=e.min)?t:void 0,max:null!=(n=e.max)?n:void 0}:{}})),t.theme){const e={};null!=t.theme.mode&&(e.mode=t.theme.mode),null!=t.theme.palette&&(e.palette=t.theme.palette),Object.keys(e).length&&(o.theme=Object.assign({},o.theme,e))}t.annotations&&t.annotations.static&&(o.annotations=r.clone(t.annotations.static)),e.updateOptions(o,!1,n,!1,!1),function(e,t){if(!e||!t)return;const n=e.w;n.interact.zoomed=!!t.zoomed,function(e,t,n){const i=e.w;if(null==t&&null==n)return;const s=i.globals.seriesNames||[],r=new Set([...t||[],...n||[]]),a=new Set([...i.globals.collapsedSeriesIndices||[],...i.globals.ancillaryCollapsedSeriesIndices||[]]);for(let t=0;t<s.length;t++){const n=s[t];if(null==n)continue;const i=r.has(t),o=a.has(t);i&&!o?e.hideSeries(n):!i&&o&&e.showSeries(n)}}(e,t.collapsed,t.ancillaryCollapsed),t.annotations&&Array.isArray(t.annotations.dynamic)&&t.annotations.dynamic.forEach(t=>{const n=function(e){switch(e){case"xaxis":return"addXaxisAnnotation";case"yaxis":return"addYaxisAnnotation";case"point":return"addPointAnnotation";default:return null}}(t.kind);n&&"function"==typeof e[n]&&e[n](t.params,!0)});(function(e,t){Array.isArray(t)&&(e.w.interact.selectedDataPoints=l(t))})(e,t.selectedDataPoints),t.locale&&t.locale!==n.config.chart.defaultLocale&&e.setLocale(t.locale);e.measure&&"function"==typeof e.measure.setPins&&e.measure.setPins(t.measure&&t.measure.pins||[])}(e,t)}const p=new Date("2027-07-31T00:00:00Z"),m="APEX-",h=new Map,y=new Set,g=new Set;let v=!1;function w(e){if("function"==typeof atob)return atob(e);if("undefined"!=typeof Buffer)return Buffer.from(e,"base64").toString("binary");throw new Error("no base64 decoder available")}function b(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=w(t.padEnd(4*Math.ceil(t.length/4),"=")),i=new Uint8Array(n.length);for(let e=0;e<n.length;e++)i[e]=n.charCodeAt(e);return i}function x(e,t,n){return i=this,s=null,r=function*(){if(y.has(e)||h.has(e))return;y.add(e);const i=globalThis.crypto?globalThis.crypto.subtle:void 0,s=S.publicKeysSpki;if(!i||0===s.length)return y.delete(e),void(v||(v=!0));const r=(new TextEncoder).encode(function(e){const t=e.domains&&e.domains.length>0?e.domains.join(","):"";return`v1|${e.issueDate}|${e.expiryDate}|${e.plan}|${t}`}(t));let a=!1;for(const e of s){try{const t=yield i.importKey("spki",b(e),{name:"ECDSA",namedCurve:"P-256"},!1,["verify"]);a=yield i.verify({hash:"SHA-256",name:"ECDSA"},t,b(n),r)}catch(e){a=!1}if(a)break}var o;y.delete(e),h.set(e,a),o=S.validateKey(e),g.forEach(e=>{try{e(o)}catch(e){}})},new Promise((e,t)=>{var n=e=>{try{o(r.next(e))}catch(e){t(e)}},a=e=>{try{o(r.throw(e))}catch(e){t(e)}},o=t=>t.done?e(t.value):Promise.resolve(t.value).then(n,a);o((r=r.apply(i,s)).next())});var i,s,r}class S{static decodeLicenseData(e){try{const t=JSON.parse(w(e));return t.issueDate&&t.expiryDate&&t.plan?{domains:Array.isArray(t.domains)?t.domains:void 0,expiryDate:t.expiryDate,issueDate:t.issueDate,plan:t.plan,valid:!0}:null}catch(e){return null}}static getKey(){return this.licenseKey}static getLicenseStatus(){return this.licenseKey?(this.validationResult=this.validateKey(this.licenseKey),this.validationResult):{expired:!1,valid:!1}}static isKeyValid(e){return!!e&&this.validateKey(e).valid}static isLicenseValid(){return!!this.licenseKey&&this.getLicenseStatus().valid}static onChange(e){return g.add(e),()=>{g.delete(e)}}static setLicense(e){this.licenseKey=e,this.validationResult=this.validateKey(e),this.validationResult.valid}static validateKey(e){try{if("string"!=typeof e||!e.startsWith(m))return{expired:!1,message:'Invalid license key format. License key must start with "APEX-".',signatureVerified:!1,valid:!1};const t=e.slice(5);if(!t)return{expired:!1,message:"Invalid license key format. Expected format: APEX-{encoded-data}.",signatureVerified:!1,valid:!1};const n=this.decodeLicenseData(t);if(!n)return{expired:!1,message:"Invalid license key. Unable to decode license data.",signatureVerified:!1,valid:!1};const i=function(e){try{const t=JSON.parse(w(e));return"string"==typeof t.sig&&t.sig?t.sig:null}catch(e){return null}}(t);if(!i&&new Date>=p)return{data:n,expired:!1,message:"This license key is in the old unsigned format, which is no longer accepted. Please request a replacement key.",signatureVerified:!1,valid:!1};const s=new Date;if(new Date(n.expiryDate)<s)return{data:n,expired:!0,message:`License expired on ${n.expiryDate}. Please renew your license.`,signatureVerified:!1,valid:!1};if(n.domains&&n.domains.length>0){const e="undefined"!=typeof window&&window.location?window.location.hostname:"";if(!n.domains.some(t=>e===t||e.endsWith(`.${t}`)))return{data:n,expired:!1,message:`License is not valid for this domain (${e}). Allowed domains: ${n.domains.join(", ")}.`,signatureVerified:!1,valid:!1}}if(i){const t=h.get(e);return!1===t?{data:n,expired:!1,message:"Invalid license key. The license signature does not verify.",signatureVerified:!0,valid:!1}:(void 0===t&&x(e,n,i),{data:n,expired:!1,signatureVerified:!0===t,valid:!0})}return{data:n,expired:!1,signatureVerified:!1,valid:!0}}catch(e){return{expired:!1,message:"Invalid license key format or corrupted data.",signatureVerified:!1,valid:!1}}}static _resetSignatureState(){h.clear(),y.clear(),v=!1}}t(S,"licenseKey",null),t(S,"publicKeysSpki",["MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEQIaK9UMD6n0oR/FIy8QdL0uSzKMQlf1BB+tOrji4/WuHsyRNxeDhVykoSsNURozMi1xhmqWvBH1L//xIfugTPA=="]),t(S,"validationResult",null);const A="data-apexcharts-watermark",_={position:"absolute",top:"0",right:"0",bottom:"0",left:"0",pointerEvents:"none",userSelect:"none",webkitUserSelect:"none",msUserSelect:"none",zIndex:"10000",display:"block",visibility:"visible",opacity:"1"};class O{static applyStyles(e){Object.assign(e.style,_,{backgroundImage:`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 >APEXCHARTS</text>\n </svg>\n '.trim())}")`,backgroundRepeat:"repeat"})}static add(e){if(!e||"undefined"==typeof document)return null;let t=this.node(e);return t||(t=document.createElement("div"),t.setAttribute(A,""),e.appendChild(t)),this.applyStyles(t),"function"==typeof getComputedStyle&&"static"===getComputedStyle(e).position&&(e.style.position="relative"),t}static node(e){return e?e.querySelector(`[${A}]`):null}static exists(e){return!!this.node(e)}static remove(e){const t=this.node(e);t&&t.remove()}}t(O,"ATTR",A);let k=!1;const D=new Set;function E(){k=!0,C()}function P(e,t){const n=O.add(t);if(!n||"undefined"==typeof MutationObserver)return;if(e._wmNodeObserver&&e._wmObservedNode===n)return;e._wmNodeObserver&&e._wmNodeObserver.disconnect();const i=new MutationObserver(()=>{const e=O.node(t);e&&(i.disconnect(),O.applyStyles(e),i.takeRecords(),i.observe(e,{attributes:!0,attributeFilter:["style"]}))});i.observe(n,{attributes:!0,attributeFilter:["style"]}),e._wmNodeObserver=i,e._wmObservedNode=n}function K(e,t){e._wmWrapObserver&&(e._wmWrapObserver.disconnect(),e._wmWrapObserver=null),e._wmNodeObserver&&(e._wmNodeObserver.disconnect(),e._wmNodeObserver=null),e._wmObservedNode=null;const n=t||e.w&&e.w.dom&&e.w.dom.elWrap;n&&O.remove(n)}function L(e,t){try{if(!a.isBrowser())return;if(e&&e.globals&&e.globals.isDestroyed)return void D.delete(t);const n=e&&e.dom&&e.dom.elWrap;if(!n)return;const i=function(e,t){const n=e&&e.config&&e.config.chart||{},i=[];"unit"===n.type&&i.push("unit"),t.storyboard&&t.storyboard._used&&i.push("storyboard");const s=n.link;return t.linkedViews&&s&&(!0===s.enabled||"function"==typeof s.dimension)&&i.push("link"),t.ink&&n.ink&&!0===n.ink.enabled&&i.push("ink"),t.measure&&n.measure&&!0===n.measure.enabled&&i.push("measure"),t.contextMenu&&n.contextMenu&&!0===n.contextMenu.enabled&&i.push("context-menu"),t.perspectives&&(t.perspectives._used||k)&&i.push("perspectives"),t.history&&n.history&&!0===n.history.enabled&&i.push("history"),i}(e,t);if(0===i.length)return D.delete(t),void K(t,n);D.add(t);const s=function(e){const t=e&&e.config&&e.config.chart&&e.config.chart.license;if(t)return t;const n=S.getKey();if(n)return n;const i=a.getApex();return i&&i.license?i.license:null}(e);if(S.isKeyValid(s))return void K(t,n);!function(e,t){if(P(e,t),"undefined"==typeof MutationObserver||e._wmWrapObserver)return;const n=new MutationObserver(()=>{O.node(t)||P(e,t)});n.observe(t,{childList:!0}),e._wmWrapObserver=n}(t,n),function(e,t){e._premiumLicenseNotified||(e._premiumLicenseNotified=!0,t&&S.getKey())}(t,s)}catch(e){}}function C(){if(!a.isBrowser())return;const e=new Set,t=a.getApex(),n=t&&t._chartInstances;Array.isArray(n)&&n.forEach(t=>{const n=t&&t.chart;n&&n.w&&!n.w.globals.isDestroyed&&(e.add(n),L(n.w,n))}),Array.from(D).forEach(t=>{const n=t&&t.w,i=n&&n.dom&&n.dom.elWrap;n&&!n.globals.isDestroyed&&i&&!1!==i.isConnected?e.has(t)||L(n,t):D.delete(t)})}S.onChange(C);const I="apex";function N(e){return function(e){if("undefined"!=typeof Buffer)return Buffer.from(e,"utf-8").toString("base64");const t=(new TextEncoder).encode(e);let n="";for(let e=0;e<t.length;e++)n+=String.fromCharCode(t[e]);return btoa(n)}(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function R(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");for(;t.length%4;)t+="=";return function(e){if("undefined"!=typeof Buffer)return Buffer.from(e,"base64").toString("utf-8");const t=atob(e),n=new Uint8Array(t.length);for(let e=0;e<t.length;e++)n[e]=t.charCodeAt(e);return(new TextDecoder).decode(n)}(t)}class j{constructor(e,t){this.w=e,this.ctx=t,this._saved=[],this._counter=0,this._used=!1}capture(){const e={v:1,view:function(e,t){var n,i;const s=e.config.xaxis||{},r=(Array.isArray(e.config.yaxis)?e.config.yaxis:e.config.yaxis?[e.config.yaxis]:[]).map(e=>o(e&&e.min,e&&e.max)),a=r.some(e=>null!==e),c=e.config.theme,f=t&&t.drilldown;return{v:1,window:{xaxis:o(s.min,s.max),yaxis:a?r:null},zoomed:!!e.interact.zoomed,collapsed:(e.globals.collapsedSeriesIndices||[]).slice(),ancillaryCollapsed:(e.globals.ancillaryCollapsedSeriesIndices||[]).slice(),selectedDataPoints:l(e.interact.selectedDataPoints),theme:c?{mode:null!=(n=c.mode)?n:null,palette:null!=(i=c.palette)?i:null}:null,locale:e.config.chart&&e.config.chart.defaultLocale||null,annotations:d(e,t),drill:f&&f.depth>0?{path:f.path.slice()}:null,measure:u(t)}}(this.w,this.ctx)},t=this._serializableDelta();return t&&Object.keys(t).length&&(e.options=t),e}_serializableDelta(){const e=this.w.config,t=e.chart&&e.chart.perspectives&&e.chart.perspectives.serializeOptions||["theme","xaxis","yaxis","title","subtitle"],n={};return t.forEach(t=>{if(void 0!==e[t]){const i=function(e){try{return JSON.parse(JSON.stringify(e))}catch(e){return}}(e[t]);void 0!==i&&(n[t]=i)}}),n}encode(e){const t=e||this.capture();return N(JSON.stringify(t))}decode(e){return j.decode(e)}toURL(){if(!a.isBrowser())return"";const e=this.encode(this.capture()),t=new URL(window.location.href);return t.hash=`${I}=${e}`,t.toString()}apply(e,t={}){const n="string"==typeof e?j.decode(e):e;if(!n||!n.view)return;this._used=!0,L(this.w,this.ctx);const i=void 0===t.animate||t.animate,s=r.extend(n.options?r.clone(n.options):{},t.mergeOptions||{}),a=Object.keys(s).length?s:void 0;(this.w.config.chart.group?this.ctx.getSyncedCharts():[this.ctx]).forEach(e=>{f(e,n.view,{animate:i,mergeOptions:a})})}save(e){const t="perspective-"+ ++this._counter;return this._saved.push({id:t,name:e||t,token:this.capture()}),this._used=!0,L(this.w,this.ctx),t}list(){return this._saved.map(e=>({id:e.id,name:e.name,token:e.token}))}delete(e){const t=this._saved.findIndex(t=>t.id===e);t>-1&&this._saved.splice(t,1)}teardown(){this._saved=[],this._counter=0}static decode(e){if("string"!=typeof e||!e)return null;try{const t=JSON.parse(R(e));return t&&"object"==typeof t?1!==t.v?null:t:null}catch(e){return null}}static fromURL(e){try{const t=e||(a.isBrowser()?window.location.href:"");if(!t)return null;const n=new URL(t).hash.replace(/^#/,"");if(!n)return null;const i=n.split("&").map(e=>e.split("=")).find(e=>e[0]===I);return i&&null!=i[1]?j.decode(decodeURIComponent(i[1])):null}catch(e){return null}}}n.registerFeatures({perspectives:j}),n.perspectives={decode:e=>(E(),j.decode(e)),fromURL:e=>(E(),j.fromURL(e))},exports.default=n;