UNPKG

highcharts

Version:
11 lines 51.9 kB
!/** * Highcharts JS v12.1.2 (2024-12-21) * @module highcharts/modules/data-tools * @requires highcharts * * Highcharts * * (c) 2010-2024 Highsoft AS * * License: www.highcharts.com/license */function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(e._Highcharts):"function"==typeof define&&define.amd?define("highcharts/modules/data-tools",["highcharts/highcharts"],function(e){return t(e)}):"object"==typeof exports?exports["highcharts/modules/data-tools"]=t(e._Highcharts):e.Highcharts=t(e.Highcharts)}("undefined"==typeof window?this:window,e=>(()=>{"use strict";var t={944:t=>{t.exports=e}},s={};function r(e){var n=s[e];if(void 0!==n)return n.exports;var i=s[e]={exports:{}};return t[e](i,i.exports,r),i.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var n={};r.d(n,{default:()=>tu});var i=r(944),o=r.n(i);let{addEvent:l,fireEvent:a,merge:u}=o();class h{benchmark(e,t){let s=[],r=this,n=()=>{r.modifyTable(e),r.emit({type:"afterBenchmarkIteration"})},{iterations:i}=u({iterations:1},t);r.on("afterBenchmarkIteration",()=>{if(s.length===i){r.emit({type:"afterBenchmark",results:s});return}n()});let o={startTime:0,endTime:0};return r.on("modify",()=>{o.startTime=window.performance.now()}),r.on("afterModify",()=>{o.endTime=window.performance.now(),s.push(o.endTime-o.startTime)}),n(),s}emit(e){a(this,e.type,e)}modify(e,t){let s=this;return new Promise((r,n)=>{e.modified===e&&(e.modified=e.clone(!1,t));try{r(s.modifyTable(e,t))}catch(r){s.emit({type:"error",detail:t,table:e}),n(r)}})}modifyCell(e,t,s,r,n){return this.modifyTable(e)}modifyColumns(e,t,s,r){return this.modifyTable(e)}modifyRows(e,t,s,r){return this.modifyTable(e)}on(e,t){return l(this,e,t)}}!function(e){e.types={},e.registerType=function(t,s){return!!t&&!e.types[t]&&!!(e.types[t]=s)}}(h||(h={}));let m=h,{fireEvent:f,isArray:c,objectEach:d,uniqueKey:p}=o(),g=class{constructor(e={}){this.autoId=!e.id,this.columns={},this.id=e.id||p(),this.modified=this,this.rowCount=0,this.versionTag=p();let t=0;d(e.columns||{},(e,s)=>{this.columns[s]=e.slice(),t=Math.max(t,e.length)}),this.applyRowCount(t)}applyRowCount(e){this.rowCount=e,d(this.columns,t=>{c(t)&&(t.length=e)})}getColumn(e,t){return this.columns[e]}getColumns(e,t){return(e||Object.keys(this.columns)).reduce((e,t)=>(e[t]=this.columns[t],e),{})}getRow(e,t){return(t||Object.keys(this.columns)).map(t=>this.columns[t]?.[e])}setColumn(e,t=[],s=0,r){this.setColumns({[e]:t},s,r)}setColumns(e,t,s){let r=this.rowCount;d(e,(e,t)=>{this.columns[t]=e.slice(),r=e.length}),this.applyRowCount(r),s?.silent||(f(this,"afterSetColumns"),this.versionTag=p())}setRow(e,t=this.rowCount,s,r){let{columns:n}=this,i=s?this.rowCount+1:t+1;d(e,(e,o)=>{let l=n[o]||r?.addColumns!==!1&&Array(i);l&&(s?l.splice(t,0,e):l[t]=e,n[o]=l)}),i>this.rowCount&&this.applyRowCount(i),r?.silent||(f(this,"afterSetRows"),this.versionTag=p())}},{addEvent:y,defined:b,fireEvent:w,extend:C,uniqueKey:R}=o();class N extends g{static isNull(e){if(e===N.NULL)return!0;if(e instanceof Array){if(!e.length)return!1;for(let t=0,s=e.length;t<s;++t)if(null!==e[t])return!1}else{let t=Object.keys(e);if(!t.length)return!1;for(let s=0,r=t.length;s<r;++s)if(null!==e[t[s]])return!1}return!0}constructor(e={}){super(e),this.modified=this}clone(e,t){let s={};this.emit({type:"cloneTable",detail:t}),e||(s.columns=this.columns),this.autoId||(s.id=this.id);let r=new N(s);return e||(r.versionTag=this.versionTag,r.originalRowIndexes=this.originalRowIndexes,r.localRowIndexes=this.localRowIndexes),this.emit({type:"afterCloneTable",detail:t,tableClone:r}),r}deleteColumns(e,t){let s=this.columns,r={},n={},i=this.modifier,o=this.rowCount;if((e=e||Object.keys(s)).length){this.emit({type:"deleteColumns",columnNames:e,detail:t});for(let t=0,i=e.length,l,a;t<i;++t)(l=s[a=e[t]])&&(r[a]=l,n[a]=Array(o)),delete s[a];return Object.keys(s).length||(this.rowCount=0,this.deleteRowIndexReferences()),i&&i.modifyColumns(this,n,0,t),this.emit({type:"afterDeleteColumns",columns:r,columnNames:e,detail:t}),r}}deleteRowIndexReferences(){delete this.originalRowIndexes,delete this.localRowIndexes}deleteRows(e,t=1,s){let r=[],n=[],i=this.modifier;if(this.emit({type:"deleteRows",detail:s,rowCount:t,rowIndex:e||0}),void 0===e&&(e=0,t=this.rowCount),t>0&&e<this.rowCount){let s=this.columns,i=Object.keys(s);for(let o=0,l=i.length,a,u;o<l;++o){u=(a=s[i[o]]).splice(e,t),o||(this.rowCount=a.length);for(let e=0,t=u.length;e<t;++e)r[e]=r[e]||[],r[e][o]=u[e];n.push(Array(l))}}return i&&i.modifyRows(this,n,e||0,s),this.emit({type:"afterDeleteRows",detail:s,rowCount:t,rowIndex:e||0,rows:r}),r}emit(e){["afterDeleteColumns","afterDeleteRows","afterSetCell","afterSetColumns","afterSetRows"].includes(e.type)&&(this.versionTag=R()),w(this,e.type,e)}getCell(e,t){let s=this.columns[e];if(s)return s[t]}getCellAsBoolean(e,t){let s=this.columns[e];return!!(s&&s[t])}getCellAsNumber(e,t,s){let r=this.columns[e],n=r&&r[t];switch(typeof n){case"boolean":return n?1:0;case"number":return isNaN(n)&&!s?null:n}return isNaN(n=parseFloat(`${n??""}`))&&!s?null:n}getCellAsString(e,t){let s=this.columns[e];return`${s&&s[t]}`}getColumn(e,t){return this.getColumns([e],t)[e]}getColumnAsNumbers(e,t){let s=this.columns[e],r=[];if(s){let n=s.length;if(t)for(let t=0;t<n;++t)r.push(this.getCellAsNumber(e,t,!0));else{for(let e=0,t;e<n;++e){if("number"==typeof(t=s[e]))return s.slice();if(null!=t)break}for(let t=0;t<n;++t)r.push(this.getCellAsNumber(e,t))}}return r}getColumnNames(){return Object.keys(this.columns)}getColumns(e,t){let s=this.columns,r={};e=e||Object.keys(s);for(let n=0,i=e.length,o,l;n<i;++n)(o=s[l=e[n]])&&(r[l]=t?o:o.slice());return r}getLocalRowIndex(e){let{localRowIndexes:t}=this;return t?t[e]:e}getModifier(){return this.modifier}getOriginalRowIndex(e){let{originalRowIndexes:t}=this;return t?t[e]:e}getRow(e,t){return this.getRows(e,1,t)[0]}getRowCount(){return this.rowCount}getRowIndexBy(e,t,s){let r=this.columns[e];if(r){let e=r.indexOf(t,s);if(-1!==e)return e}}getRowObject(e,t){return this.getRowObjects(e,1,t)[0]}getRowObjects(e=0,t=this.rowCount-e,s){let r=this.columns,n=Array(t);s=s||Object.keys(r);for(let i=e,o=0,l=Math.min(this.rowCount,e+t),a,u;i<l;++i,++o)for(let e of(u=n[o]={},s))a=r[e],u[e]=a?a[i]:void 0;return n}getRows(e=0,t=this.rowCount-e,s){let r=this.columns,n=Array(t);s=s||Object.keys(r);for(let i=e,o=0,l=Math.min(this.rowCount,e+t),a,u;i<l;++i,++o)for(let e of(u=n[o]=[],s))a=r[e],u.push(a?a[i]:void 0);return n}getVersionTag(){return this.versionTag}hasColumns(e){let t=this.columns;for(let s=0,r=e.length;s<r;++s)if(!t[e[s]])return!1;return!0}hasRowWith(e,t){let s=this.columns[e];return!!s&&-1!==s.indexOf(t)}on(e,t){return y(this,e,t)}renameColumn(e,t){let s=this.columns;return!!s[e]&&(e!==t&&(s[t]=s[e],delete s[e]),!0)}setCell(e,t,s,r){let n=this.columns,i=this.modifier,o=n[e];o&&o[t]===s||(this.emit({type:"setCell",cellValue:s,columnName:e,detail:r,rowIndex:t}),o||(o=n[e]=Array(this.rowCount)),t>=this.rowCount&&(this.rowCount=t+1),o[t]=s,i&&i.modifyCell(this,e,t,s),this.emit({type:"afterSetCell",cellValue:s,columnName:e,detail:r,rowIndex:t}))}setColumns(e,t,s){let r=this.columns,n=this.modifier,i=Object.keys(e),o=this.rowCount;if(this.emit({type:"setColumns",columns:e,columnNames:i,detail:s,rowIndex:t}),void 0===t)super.setColumns(e,t,C(s,{silent:!0}));else{for(let s=0,n=i.length,l,a;s<n;++s){l=e[a=i[s]];let n=r[a]?r[a]:r[a]=Array(this.rowCount);for(let e=t||0,s=l.length;e<s;++e)n[e]=l[e];o=Math.max(o,n.length)}this.applyRowCount(o)}n&&n.modifyColumns(this,e,t||0),this.emit({type:"afterSetColumns",columns:e,columnNames:i,detail:s,rowIndex:t})}setModifier(e,t){let s=this;return s.emit({type:"setModifier",detail:t,modifier:e,modified:s.modified}),s.modified=s,s.modifier=e,(e?e.modify(s):Promise.resolve(s)).then(s=>(s.emit({type:"afterSetModifier",detail:t,modifier:e,modified:s.modified}),s)).catch(t=>{throw s.emit({type:"setModifierError",error:t,modifier:e,modified:s.modified}),t})}setOriginalRowIndexes(e,t=!1){if(this.originalRowIndexes=e,t)return;let s=this.localRowIndexes=[];for(let t=0,r=e.length,n;t<r;++t)b(n=e[t])&&(s[n]=t)}setRow(e,t,s,r){this.setRows([e],t,s,r)}setRows(e,t=this.rowCount,s,r){let n=this.columns,i=Object.keys(n),o=this.modifier,l=e.length;this.emit({type:"setRows",detail:r,rowCount:l,rowIndex:t,rows:e});for(let r=0,o=t,a;r<l;++r,++o)if((a=e[r])===N.NULL)for(let e=0,t=i.length;e<t;++e)s?n[i[e]].splice(o,0,null):n[i[e]][o]=null;else if(a instanceof Array)for(let e=0,t=i.length;e<t;++e)n[i[e]][o]=a[e];else super.setRow(a,o,void 0,{silent:!0});let a=s?l+e.length:t+l;if(a>this.rowCount){this.rowCount=a;for(let e=0,t=i.length;e<t;++e)n[i[e]].length=a}o&&o.modifyRows(this,e,t),this.emit({type:"afterSetRows",detail:r,rowCount:l,rowIndex:t,rows:e})}}N.NULL={},N.version="1.0.0";let{addEvent:T,fireEvent:v,merge:O,pick:x}=o();class A{constructor(e={}){this.table=new N(e.dataTable),this.metadata=e.metadata||{columns:{}}}get polling(){return!!this.polling}describeColumn(e,t){let s=this.metadata.columns;s[e]=O(s[e]||{},t)}describeColumns(e){let t;let s=Object.keys(e);for(;"string"==typeof(t=s.pop());)this.describeColumn(t,e[t])}emit(e){v(this,e.type,e)}getColumnOrder(e){let t=this.metadata.columns,s=Object.keys(t||{});if(s.length)return s.sort((e,s)=>x(t[e].index,0)-x(t[s].index,0))}getSortedColumns(e){return this.table.getColumns(this.getColumnOrder(e))}load(){return v(this,"afterLoad",{table:this.table}),Promise.resolve(this)}on(e,t){return T(this,e,t)}save(){return v(this,"saveError",{table:this.table}),Promise.reject(Error("Not implemented"))}setColumnOrder(e){for(let t=0,s=e.length;t<s;++t)this.describeColumn(e[t],{index:t})}setModifierOptions(e){let t=e&&m.types[e.type];return this.table.setModifier(t?new t(e):void 0).then(()=>this)}startPolling(e=1e3){let t=this;window.clearTimeout(t._polling),t._polling=window.setTimeout(()=>t.load().catch(e=>t.emit({type:"loadError",error:e,table:t.table})).then(()=>{t._polling&&t.startPolling(e)}),e)}stopPolling(){window.clearTimeout(this._polling),delete this._polling}whatIs(e){return this.metadata.columns[e]}}!function(e){e.types={},e.registerType=function(t,s){return!!t&&!e.types[t]&&!!(e.types[t]=s)}}(A||(A={}));let F=A,{addEvent:M,fireEvent:E,isNumber:I,merge:D}=o();class P{constructor(e){this.dateFormats={"YYYY/mm/dd":{regex:/^(\d{4})([\-\.\/])(\d{1,2})\2(\d{1,2})$/,parser:function(e){return e?Date.UTC(+e[1],e[3]-1,+e[4]):NaN}},"dd/mm/YYYY":{regex:/^(\d{1,2})([\-\.\/])(\d{1,2})\2(\d{4})$/,parser:function(e){return e?Date.UTC(+e[4],e[3]-1,+e[1]):NaN},alternative:"mm/dd/YYYY"},"mm/dd/YYYY":{regex:/^(\d{1,2})([\-\.\/])(\d{1,2})\2(\d{4})$/,parser:function(e){return e?Date.UTC(+e[4],e[1]-1,+e[3]):NaN}},"dd/mm/YY":{regex:/^(\d{1,2})([\-\.\/])(\d{1,2})\2(\d{2})$/,parser:function(e){let t=new Date;if(!e)return NaN;let s=+e[4];return s>t.getFullYear()-2e3?s+=1900:s+=2e3,Date.UTC(s,e[3]-1,+e[1])},alternative:"mm/dd/YY"},"mm/dd/YY":{regex:/^(\d{1,2})([\-\.\/])(\d{1,2})\2(\d{2})$/,parser:function(e){return e?Date.UTC(+e[4]+2e3,e[1]-1,+e[3]):NaN}}};let t=D(P.defaultOptions,e),s=t.decimalPoint;("."===s||","===s)&&(s="."===s?"\\.":",",this.decimalRegExp=RegExp("^(-?[0-9]+)"+s+"([0-9]+)$")),this.options=t}asBoolean(e){return"boolean"==typeof e?e:"string"==typeof e?""!==e&&"0"!==e&&"false"!==e:!!this.asNumber(e)}asDate(e){let t;if("string"==typeof e)t=this.parseDate(e);else if("number"==typeof e)t=e;else{if(e instanceof Date)return e;t=this.parseDate(this.asString(e))}return new Date(t)}asGuessedType(e){return({number:this.asNumber,Date:this.asDate,string:this.asString})[this.guessType(e)].call(this,e)}asNumber(e){if("number"==typeof e)return e;if("boolean"==typeof e)return e?1:0;if("string"==typeof e){let t=this.decimalRegExp;if(e.indexOf(" ")>-1&&(e=e.replace(/\s+/g,"")),t){if(!t.test(e))return NaN;e=e.replace(t,"$1.$2")}return parseFloat(e)}return e instanceof Date?e.getDate():e?e.getRowCount():NaN}asString(e){return""+e}deduceDateFormat(e,t,s){let r=[],n=[],i="YYYY/mm/dd",o,l=[],a=0,u=!1,h,m;for((!t||t>e.length)&&(t=e.length);a<t;a++)if(void 0!==e[a]&&e[a]&&e[a].length)for(m=0,o=e[a].trim().replace(/[\-\.\/]/g," ").split(" "),l=["","",""];m<o.length;m++)m<l.length&&(h=parseInt(o[m],10))&&(n[m]=!n[m]||n[m]<h?h:n[m],void 0!==r[m]?r[m]!==h&&(r[m]=!1):r[m]=h,h>31?h<100?l[m]="YY":l[m]="YYYY":h>12&&h<=31?(l[m]="dd",u=!0):l[m].length||(l[m]="mm"));if(u){for(m=0;m<r.length;m++)!1!==r[m]?n[m]>12&&"YY"!==l[m]&&"YYYY"!==l[m]&&(l[m]="YY"):n[m]>12&&"mm"===l[m]&&(l[m]="dd");3===l.length&&"dd"===l[1]&&"dd"===l[2]&&(l[2]="YY"),i=l.join("/")}return s&&(this.options.dateFormat=i),i}emit(e){E(this,e.type,e)}export(e,t){throw this.emit({type:"exportError",columns:[],headers:[]}),Error("Not implemented")}getTable(){throw Error("Not implemented")}guessType(e){let t="string";if("string"==typeof e){let s=this.trim(`${e}`),r=this.decimalRegExp,n=this.trim(s,!0);r&&(n=r.test(n)?n.replace(r,"$1.$2"):"");let i=parseFloat(n);+n===i?e=i:t=I(this.parseDate(e))?"Date":"string"}return"number"==typeof e&&(t=e>31536e6?"Date":"number"),t}on(e,t){return M(this,e,t)}parse(e){throw this.emit({type:"parseError",columns:[],headers:[]}),Error("Not implemented")}parseDate(e,t){let s=this.options,r=t||s.dateFormat,n=NaN,i,o,l;if(s.parseDate)n=s.parseDate(e);else{if(r)(o=this.dateFormats[r])||(o=this.dateFormats["YYYY/mm/dd"]),(l=e.match(o.regex))&&(n=o.parser(l));else for(i in this.dateFormats)if(o=this.dateFormats[i],l=e.match(o.regex)){r=i,n=o.parser(l);break}!l&&("object"==typeof(l=Date.parse(e))&&null!==l&&l.getTime?n=l.getTime()-6e4*l.getTimezoneOffset():I(l)&&(n=l-6e4*new Date(l).getTimezoneOffset(),-1===e.indexOf("2001")&&2001===new Date(n).getFullYear()&&(n=NaN)))}return n}trim(e,t){return"string"==typeof e&&(e=e.replace(/^\s+|\s+$/g,""),t&&/^[\d\s]+$/.test(e)&&(e=e.replace(/\s/g,""))),e}}P.defaultOptions={dateFormat:"",alternativeFormat:"",startColumn:0,endColumn:Number.MAX_VALUE,startRow:0,endRow:Number.MAX_VALUE,firstRowAsNames:!0,switchRowsAndColumns:!1},function(e){e.types={},e.registerType=function(t,s){return!!t&&!e.types[t]&&!!(e.types[t]=s)},e.getTableFromColumns=function(e=[],t=[]){let s=new N;for(let r=0,n=Math.max(t.length,e.length);r<n;++r)s.setColumn(t[r]||`${r}`,e[r]);return s}}(P||(P={}));let j=P;class S{constructor(e={}){this.emittingRegister=[],this.listenerMap={},this.stateMap=e}addListener(e,t,s){let r=this.listenerMap[e]=this.listenerMap[e]||{};return(r[t]=r[t]||[]).push(s),this}buildEmittingTag(e){return("position"===e.cursor.type?[e.table.id,e.cursor.column,e.cursor.row,e.cursor.state,e.cursor.type]:[e.table.id,e.cursor.columns,e.cursor.firstRow,e.cursor.lastRow,e.cursor.state,e.cursor.type]).join("\0")}emitCursor(e,t,s,r){let n=e.id,i=t.state,o=this.listenerMap[n]&&this.listenerMap[n][i];if(o){let i=this.stateMap[n]=this.stateMap[n]??{},l=i[t.state]||[];r&&(l.length||(i[t.state]=l),-1===S.getIndex(t,l)&&l.push(t));let a={cursor:t,cursors:l,table:e};s&&(a.event=s);let u=this.emittingRegister,h=this.buildEmittingTag(a);if(u.indexOf(h)>=0)return this;try{this.emittingRegister.push(h);for(let e=0,t=o.length;e<t;++e)o[e].call(this,a)}finally{let e=this.emittingRegister.indexOf(h);e>=0&&this.emittingRegister.splice(e,1)}}return this}remitCursor(e,t){let s=this.stateMap[e]&&this.stateMap[e][t.state];if(s){let e=S.getIndex(t,s);e>=0&&s.splice(e,1)}return this}removeListener(e,t,s){let r=this.listenerMap[e]&&this.listenerMap[e][t];if(r){let e=r.indexOf(s);e>=0&&r.splice(e,1)}return this}}S.version="1.0.0",function(e){function t(e,t){if("range"===e.type)return e;let s={type:"range",firstRow:e.row??(t&&t.firstRow)??0,lastRow:e.row??(t&&t.lastRow)??Number.MAX_VALUE,state:e.state};return void 0!==e.column&&(s.columns=[e.column]),s}e.getIndex=function(e,t){if("position"===e.type){for(let s,r=0,n=t.length;r<n;++r)if("position"===(s=t[r]).type&&s.state===e.state&&s.column===e.column&&s.row===e.row)return r}else{let s=JSON.stringify(e.columns);for(let r,n=0,i=t.length;n<i;++n)if("range"===(r=t[n]).type&&r.state===e.state&&r.firstRow===e.firstRow&&r.lastRow===e.lastRow&&JSON.stringify(r.columns)===s)return n}return -1},e.isEqual=function(e,t){return"position"===e.type&&"position"===t.type?e.column===t.column&&e.row===t.row&&e.state===t.state:"range"===e.type&&"range"===t.type&&e.firstRow===t.firstRow&&e.lastRow===t.lastRow&&JSON.stringify(e.columns)===JSON.stringify(t.columns)},e.isInRange=function(e,s){"position"===s.type&&(s=t(s)),"position"===e.type&&(e=t(e,s));let r=e.columns,n=s.columns;return e.firstRow>=s.firstRow&&e.lastRow<=s.lastRow&&(!r||!n||r.every(e=>n.indexOf(e)>=0))},e.toPositions=function(e){if("position"===e.type)return[e];let t=e.columns||[],s=[],r=e.state;for(let n=e.firstRow,i=e.lastRow;n<i;++n){if(!t.length){s.push({type:"position",row:n,state:r});continue}for(let e=0,i=t.length;e<i;++e)s.push({type:"position",column:t[e],row:n,state:r})}return s},e.toRange=t}(S||(S={}));let L=S,Y={connectors:[]};class V{constructor(e=Y){e.connectors=e.connectors||[],this.connectors={},this.options=e,this.waiting={}}emit(e){o().fireEvent(this,e.type,e)}getConnector(e){let t=this.connectors[e];if(t)return Promise.resolve(t);let s=this.waiting[e];if(!s){s=this.waiting[e]=[];let t=this.getConnectorOptions(e);if(!t)throw Error(`Connector '${e}' not found.`);this.loadConnector(t).then(t=>{delete this.waiting[e];for(let e=0,r=s.length;e<r;++e)s[e][0](t)}).catch(t=>{delete this.waiting[e];for(let e=0,r=s.length;e<r;++e)s[e][1](t)})}return new Promise((e,t)=>{s.push([e,t])})}getConnectorIds(){let e=this.options.connectors,t=[];for(let s=0,r=e.length;s<r;++s)t.push(e[s].id);return t}getConnectorOptions(e){let t=this.options.connectors;for(let s=0,r=t.length;s<r;++s)if(t[s].id===e)return t[s]}getConnectorTable(e){return this.getConnector(e).then(e=>e.table)}isNewConnector(e){return!this.connectors[e]}loadConnector(e){return new Promise((t,s)=>{this.emit({type:"load",options:e});let r=F.types[e.type];if(!r)throw Error(`Connector type not found. (${e.type})`);new r(e.options).load().then(s=>{this.connectors[e.id]=s,this.emit({type:"afterLoad",options:e}),t(s)}).catch(s)})}on(e,t){return o().addEvent(this,e,t)}setConnectorOptions(e){let t=this.options.connectors,s=this.connectors;this.emit({type:"setConnectorOptions",options:e});for(let s=0,r=t.length;s<r;++s)if(t[s].id===e.id){t.splice(s,1);break}s[e.id]&&(s[e.id].stopPolling(),delete s[e.id]),t.push(e),this.emit({type:"afterSetConnectorOptions",options:e})}}V.version="1.0.0";let k=/^(?:FALSE|TRUE)/,$=/^[+\-]?\d+(?:\.\d+)?(?:e[+\-]\d+)?/,U=/^[+\-]?\d+(?:,\d+)?(?:e[+\-]\d+)?/,H=/^([A-Z][A-Z\d\.]*)\(/,_=/^(?:[+\-*\/^<=>]|<=|=>)/,B=/^(\$?[A-Z]+)(\$?\d+)\:(\$?[A-Z]+)(\$?\d+)/,G=/^R(\d*|\[\d+\])C(\d*|\[\d+\])\:R(\d*|\[\d+\])C(\d*|\[\d+\])/,Z=/^(\$?[A-Z]+)(\$?\d+)(?![\:C])/,J=/^R(\d*|\[\d+\])C(\d*|\[\d+\])(?!\:)/;function X(e){let t=0;for(let s=0,r=e.length,n,i=1;s<r;++s){if("("===(n=e[s])){t||(i=s+1),++t;continue}if(")"===n&&!--t)return e.substring(i,s)}if(t>0){let e=Error("Incomplete parantheses.");throw e.name="FormulaParseError",e}return""}function K(e){let t=-1;for(let s=0,r=e.length,n,i=!1;s<r;++s){if("\\"===(n=e[s])){i=!i;continue}if(i){i=!1;continue}if('"'===n){if(!(t<0))return e.substring(t+1,s);t=s}}let s=Error("Incomplete string.");throw s.name="FormulaParseError",s}function q(e,t){let s;if(s=e.match(G)){let e=""===s[2]||"["===s[2][0],t=""===s[1]||"["===s[1][0],r=""===s[4]||"["===s[4][0],n=""===s[3]||"["===s[3][0],i={type:"range",beginColumn:e?parseInt(s[2].substring(1,-1)||"0",10):parseInt(s[2],10)-1,beginRow:t?parseInt(s[1].substring(1,-1)||"0",10):parseInt(s[1],10)-1,endColumn:r?parseInt(s[4].substring(1,-1)||"0",10):parseInt(s[4],10)-1,endRow:n?parseInt(s[3].substring(1,-1)||"0",10):parseInt(s[3],10)-1};return e&&(i.beginColumnRelative=!0),t&&(i.beginRowRelative=!0),r&&(i.endColumnRelative=!0),n&&(i.endRowRelative=!0),i}if(s=e.match(B)){let e="$"!==s[1][0],t="$"!==s[2][0],r="$"!==s[3][0],n="$"!==s[4][0],i={type:"range",beginColumn:Q(e?s[1]:s[1].substring(1))-1,beginRow:parseInt(t?s[2]:s[2].substring(1),10)-1,endColumn:Q(r?s[3]:s[3].substring(1))-1,endRow:parseInt(n?s[4]:s[4].substring(1),10)-1};return e&&(i.beginColumnRelative=!0),t&&(i.beginRowRelative=!0),r&&(i.endColumnRelative=!0),n&&(i.endRowRelative=!0),i}let r=z(e,t);return 1===r.length&&"string"!=typeof r[0]?r[0]:r}function z(e,t){let s=t?U:$,r=[],n,i=("="===e[0]?e.substring(1):e).trim();for(;i;){if(n=i.match(J)){let e=""===n[2]||"["===n[2][0],t=""===n[1]||"["===n[1][0],s={type:"reference",column:e?parseInt(n[2].substring(1,-1)||"0",10):parseInt(n[2],10)-1,row:t?parseInt(n[1].substring(1,-1)||"0",10):parseInt(n[1],10)-1};e&&(s.columnRelative=!0),t&&(s.rowRelative=!0),r.push(s),i=i.substring(n[0].length).trim();continue}if(n=i.match(Z)){let e="$"!==n[1][0],t="$"!==n[2][0],s={type:"reference",column:Q(e?n[1]:n[1].substring(1))-1,row:parseInt(t?n[2]:n[2].substring(1),10)-1};e&&(s.columnRelative=!0),t&&(s.rowRelative=!0),r.push(s),i=i.substring(n[0].length).trim();continue}if(n=i.match(_)){r.push(n[0]),i=i.substring(n[0].length).trim();continue}if(n=i.match(k)){r.push("TRUE"===n[0]),i=i.substring(n[0].length).trim();continue}if(n=i.match(s)){r.push(parseFloat(n[0])),i=i.substring(n[0].length).trim();continue}if('"'===i[0]){let e=K(i);r.push(e.substring(1,-1)),i=i.substring(e.length+2).trim();continue}if(n=i.match(H)){let e=X(i=i.substring(n[1].length).trim());r.push({type:"function",name:n[1],args:function(e,t){let s=[],r=t?";":",",n=0,i="";for(let o=0,l=e.length,a;o<l;++o)if((a=e[o])===r&&!n&&i)s.push(q(i,t)),i="";else if('"'!==a||n||i)" "!==a&&(i+=a,"("===a?++n:")"===a&&--n);else{let t=K(e.substring(o));s.push(t),o+=t.length+1}return!n&&i&&s.push(q(i,t)),s}(e,t)}),i=i.substring(e.length+2).trim();continue}if("("===i[0]){let e=X(i);if(e){r.push(z(e,t)),i=i.substring(e.length+2).trim();continue}}let o=e.length-i.length,l=Error("Unexpected character `"+e.substring(o,o+1)+"` at position "+(o+1)+". (`..."+e.substring(o-5,o+6)+"...`)");throw l.name="FormulaParseError",l}return r}function Q(e){let t=0;for(let s=0,r=e.length,n,i=e.length-1;s<r;++s)(n=e.charCodeAt(s))>=65&&n<=90&&(t+=(n-64)*Math.pow(26,i)),--i;return t}let W={parseFormula:z},ee=["+","-","*","/","^","=","<","<=",">",">="],et={isFormula:function(e){return e instanceof Array},isFunction:function(e){return"object"==typeof e&&!(e instanceof Array)&&"function"===e.type},isOperator:function(e){return"string"==typeof e&&ee.indexOf(e)>=0},isRange:function(e){return"object"==typeof e&&!(e instanceof Array)&&"range"===e.type},isReference:function(e){return"object"==typeof e&&!(e instanceof Array)&&"reference"===e.type},isValue:function(e){return"boolean"==typeof e||"number"==typeof e||"string"==typeof e}},{isFormula:es,isFunction:er,isOperator:en,isRange:ei,isReference:eo,isValue:el}=et,ea=/ */,eu=Number.MAX_VALUE/1.000000000001,eh=Number.MAX_VALUE/1.000000000002,em=Number.MAX_VALUE,ef={"^":3,"*":2,"/":2,"+":1,"-":1,"=":0,"<":0,"<=":0,">":0,">=":0},ec={},ed=/^[A-Z][A-Z\.]*$/;function ep(e){switch(typeof e){case"boolean":return e?em:eu;case"string":return eh;case"number":return e;default:return NaN}}function eg(e){return"string"==typeof e?e.toLowerCase().replace(ea,"\0"):e}function ey(e){switch(typeof e){case"boolean":return e?1:0;case"string":return parseFloat(e.replace(",","."));case"number":return e;default:return NaN}}function eb(e,t,s){let r;switch(e){case"=":return eg(t)===eg(s);case"<":if(typeof t==typeof s)return eg(t)<eg(s);return ep(t)<ep(s);case"<=":if(typeof t==typeof s)return eg(t)<=eg(s);return ep(t)<=ep(s);case">":if(typeof t==typeof s)return eg(t)>eg(s);return ep(t)>ep(s);case">=":if(typeof t==typeof s)return eg(t)>=eg(s);return ep(t)>=ep(s)}switch(t=ey(t),s=ey(s),e){case"+":r=t+s;break;case"-":r=t-s;break;case"*":r=t*s;break;case"/":r=t/s;break;case"^":r=Math.pow(t,s);break;default:return NaN}return r%1?Math.round(1e9*r)/1e9:r}function ew(e,t){return el(e)?e:ei(e)?t&&eC(e,t)||[]:er(e)?eT(e,t):eN(es(e)?e:[e],t)}function eC(e,t){let s=t.getColumnNames().slice(e.beginColumn,e.endColumn+1),r=[];for(let n=0,i=s.length,o;n<i;++n){let i=t.getColumn(s[n],!0)||[];for(let l=e.beginRow,a=e.endRow+1;l<a;++l)"string"==typeof(o=i[l])&&"="===o[0]&&t!==t.modified&&(o=t.modified.getCell(s[n],l)),r.push(el(o)?o:NaN)}return r}function eR(e,t){let s=t.getColumnNames()[e.column];if(s){let r=t.getCell(s,e.row);if("string"==typeof r&&"="===r[0]&&t!==t.modified){let r=t.modified.getCell(s,e.row);return el(r)?r:NaN}return el(r)?r:NaN}return NaN}function eN(e,t){let s;for(let r=0,n=e.length,i,o,l,a;r<n;++r){if(en(i=e[r])){o=i;continue}if(el(i)?a=i:es(i)?a=eN(e,t):er(i)?a=el(l=eT(i,t))?l:NaN:eo(i)&&(a=t&&eR(i,t)),void 0!==a){if(void 0===s)s=o?eb(o,0,a):a;else{if(!o)return NaN;let t=e[r+1];en(t)&&ef[t]>ef[o]&&(a=eb(t,a,eN(e.slice(r+2))),r=n),s=eb(o,s,a)}o=void 0,a=void 0}}return el(s)?s:NaN}function eT(e,t,s){let r=ec[e.name];if(r)try{return r(e.args,t)}catch{return NaN}let n=Error(`Function "${e.name}" not found.`);throw n.name="FormulaProcessError",n}let ev={asNumber:ey,getArgumentValue:ew,getArgumentsValues:function(e,t){let s=[];for(let r=0,n=e.length;r<n;++r)s.push(ew(e[r],t));return s},getRangeValues:eC,getReferenceValue:eR,processFormula:eN,processorFunctions:ec,registerProcessorFunction:function(e,t){return ed.test(e)&&!ec[e]&&!!(ec[e]=t)},translateReferences:function e(t,s=0,r=0){for(let n=0,i=t.length,o;n<i;++n)(o=t[n])instanceof Array?e(o,s,r):er(o)?e(o.args,s,r):ei(o)?(o.beginColumnRelative&&(o.beginColumn+=s),o.beginRowRelative&&(o.beginRow+=r),o.endColumnRelative&&(o.endColumn+=s),o.endRowRelative&&(o.endRow+=r)):eo(o)&&(o.columnRelative&&(o.column+=s),o.rowRelative&&(o.row+=r));return t}},{getArgumentValue:eO}=ev;ev.registerProcessorFunction("ABS",function(e,t){let s=eO(e[0],t);switch(typeof s){case"number":return Math.abs(s);case"object":{let e=[];for(let t=0,r=s.length,n;t<r;++t){if("number"!=typeof(n=s[t]))return NaN;e.push(Math.abs(n))}return e}default:return NaN}});let{getArgumentValue:ex}=ev;ev.registerProcessorFunction("AND",function e(t,s){for(let r=0,n=t.length,i;r<n;++r)if(!(i=ex(t[r],s))||"object"==typeof i&&!e(i,s))return!1;return!0});let{getArgumentsValues:eA}=ev;ev.registerProcessorFunction("AVERAGE",function(e,t){let s=eA(e,t),r=0,n=0;for(let e=0,t=s.length,i;e<t;++e)switch(typeof(i=s[e])){case"number":isNaN(i)||(++r,n+=i);break;case"object":for(let e=0,t=i.length,s;e<t;++e)"number"!=typeof(s=i[e])||isNaN(s)||(++r,n+=s)}return r?n/r:0});let{getArgumentValue:eF}=ev;ev.registerProcessorFunction("AVERAGEA",function(e,t){let s=0,r=0;for(let n=0,i=e.length,o;n<i;++n)switch(typeof(o=eF(e[n],t))){case"boolean":++s,r+=o?1:0;continue;case"number":isNaN(o)||(++s,r+=o);continue;case"string":++s;continue;default:for(let e=0,t=o.length,n;e<t;++e)switch(typeof(n=o[e])){case"boolean":++s,r+=n?1:0;continue;case"number":isNaN(n)||(++s,r+=n);continue;case"string":++s;continue}continue}return s?r/s:0}),ev.registerProcessorFunction("COUNT",function e(t,s){let r=ev.getArgumentsValues(t,s),n=0;for(let t=0,i=r.length,o;t<i;++t)switch(typeof(o=r[t])){case"number":!isNaN(o)&&++n;break;case"object":n+=e(o,s)}return n}),ev.registerProcessorFunction("COUNTA",function e(t,s){let r=ev.getArgumentsValues(t,s),n=0;for(let t=0,i=r.length,o;t<i;++t){switch(typeof(o=r[t])){case"number":if(isNaN(o))continue;break;case"object":n+=e(o,s);continue;case"string":if(!o)continue}++n}return n});let{getArgumentValue:eM}=ev;ev.registerProcessorFunction("IF",function(e,t){return eM(e[0],t)?eM(e[1],t):eM(e[2],t)});let{getArgumentValue:eE}=ev;ev.registerProcessorFunction("ISNA",function(e,t){let s=eE(e[0],t);return"number"!=typeof s||isNaN(s)});let{getArgumentsValues:eI}=ev;ev.registerProcessorFunction("MAX",function e(t,s){let r=eI(t,s),n=Number.NEGATIVE_INFINITY;for(let t=0,s=r.length,i;t<s;++t)switch(typeof(i=r[t])){case"number":i>n&&(n=i);break;case"object":(i=e(i))>n&&(n=i)}return isFinite(n)?n:0}),ev.registerProcessorFunction("MEDIAN",function(e,t){let s=[],r=ev.getArgumentsValues(e,t);for(let e=0,t=r.length,n;e<t;++e)switch(typeof(n=r[e])){case"number":isNaN(n)||s.push(n);break;case"object":for(let e=0,t=n.length,r;e<t;++e)"number"!=typeof(r=n[e])||isNaN(r)||s.push(r)}let n=s.length;if(!n)return NaN;let i=Math.floor(n/2);return n%2?s[i]:(s[i-1]+s[i])/2});let{getArgumentsValues:eD}=ev;ev.registerProcessorFunction("MIN",function e(t,s){let r=eD(t,s),n=Number.POSITIVE_INFINITY;for(let t=0,s=r.length,i;t<s;++t)switch(typeof(i=r[t])){case"number":i<n&&(n=i);break;case"object":(i=e(i))<n&&(n=i)}return isFinite(n)?n:0});let{getArgumentValue:eP}=ev;function ej(e,t){let s={},r=ev.getArgumentsValues(e,t);for(let e=0,t=r.length,n;e<t;++e)switch(typeof(n=r[e])){case"number":isNaN(n)||(s[n]=(s[n]||0)+1);break;case"object":for(let e=0,t=n.length,r;e<t;++e)"number"!=typeof(r=n[e])||isNaN(r)||(s[r]=(s[r]||0)+1)}return s}function eS(e,t){let s=ej(e,t),r=Object.keys(s);if(!r.length)return NaN;let n=parseFloat(r[0]),i=s[r[0]];for(let e=1,t=r.length,o,l,a;e<t;++e)i<(a=s[o=r[e]])?(n=parseFloat(o),i=a):i===a&&n>(l=parseFloat(o))&&(n=l,i=a);return i>1?n:NaN}ev.registerProcessorFunction("MOD",function(e,t){let s=eP(e[0],t),r=eP(e[1],t);return("object"==typeof s&&(s=s[0]),"object"==typeof r&&(r=r[0]),"number"!=typeof s||"number"!=typeof r||0===r)?NaN:s%r}),ev.registerProcessorFunction("MODE",eS),ev.registerProcessorFunction("MODE.MULT",function(e,t){let s=ej(e,t),r=Object.keys(s);if(!r.length)return NaN;let n=[parseFloat(r[0])],i=s[r[0]];for(let e=1,t=r.length,o,l;e<t;++e)i<(l=s[o=r[e]])?(n=[parseFloat(o)],i=l):i===l&&n.push(parseFloat(o));return i>1?n:NaN}),ev.registerProcessorFunction("MODE.SNGL",eS);let{getArgumentValue:eL}=ev;ev.registerProcessorFunction("NOT",function(e,t){let s=eL(e[0],t);switch("object"==typeof s&&(s=s[0]),typeof s){case"boolean":case"number":return!s}return NaN});let{getArgumentValue:eY}=ev;ev.registerProcessorFunction("OR",function e(t,s){for(let r=0,n=t.length,i;r<n;++r)if("object"==typeof(i=eY(t[r],s))){if(e(i,s))return!0}else if(i)return!0;return!1});let{getArgumentsValues:eV}=ev;ev.registerProcessorFunction("PRODUCT",function e(t,s){let r=eV(t,s),n=1,i=!1;for(let t=0,o=r.length,l;t<o;++t)switch(typeof(l=r[t])){case"number":isNaN(l)||(i=!0,n*=l);break;case"object":i=!0,n*=e(l,s)}return i?n:0}),ev.registerProcessorFunction("SUM",function e(t,s){let r=ev.getArgumentsValues(t,s),n=0;for(let t=0,i=r.length,o;t<i;++t)switch(typeof(o=r[t])){case"number":isNaN(o)||(n+=o);break;case"object":n+=e(o,s)}return n});let{getArgumentValue:ek}=ev;ev.registerProcessorFunction("XOR",function(e,t){for(let s=0,r=e.length,n,i;s<r;++s)switch(typeof(i=ek(e[s],t))){case"boolean":case"number":if(void 0===n)n=!!i;else if(!!i!==n)return!0;break;case"object":for(let e=0,t=i.length,s;e<t;++e)switch(typeof(s=i[e])){case"boolean":case"number":if(void 0===n)n=!!s;else if(!!s!==n)return!0}}return!1});let e$={...W,...ev,...et},{merge:eU}=o();class eH extends j{constructor(e){let t=eU(eH.defaultOptions,e);super(t),this.columns=[],this.headers=[],this.dataTypes=[],this.options=t}export(e,t=this.options){let{useLocalDecimalPoint:s,lineDelimiter:r}=t,n=!1!==this.options.firstRowAsNames,{decimalPoint:i,itemDelimiter:o}=t;i||(i=","!==o&&s?1.1.toLocaleString()[1]:"."),o||(o=","===i?";":",");let l=e.getSortedColumns(t.usePresentationOrder),a=Object.keys(l),u=[],h=a.length,m=[];n&&u.push(a.map(e=>`"${e}"`).join(o));for(let t=0;t<h;t++){let s;let r=a[t],n=l[r],f=n.length,c=e.whatIs(r);c&&(s=c.dataType);for(let e=0;e<f;e++){let r=n[e];if(m[e]||(m[e]=[]),"string"===s?r='"'+r+'"':"number"==typeof r?r=String(r).replace(".",i):"string"==typeof r&&(r=`"${r}"`),m[e][t]=r,t===h-1){let s=t;for(;m[e].length>2&&void 0===m[e][s];)m[e].pop(),s--;u.push(m[e].join(o))}}}return u.join(r)}parse(e,t){let s=this.dataTypes,r=eU(this.options,e),{beforeParse:n,lineDelimiter:i,firstRowAsNames:o,itemDelimiter:l}=r,a,u=0,{csv:h,startRow:m,endRow:f}=r,c;if(this.columns=[],this.emit({type:"parse",columns:this.columns,detail:t,headers:this.headers}),h&&n&&(h=n(h)),h){if(a=h.replace(/\r\n|\r/g,"\n").split(i||"\n"),(!m||m<0)&&(m=0),(!f||f>=a.length)&&(f=a.length-1),l||(this.guessedItemDelimiter=this.guessDelimiter(a)),o){let e=a[0].split(l||this.guessedItemDelimiter||",");for(let t=0;t<e.length;t++)e[t]=e[t].trim().replace(/^["']|["']$/g,"");this.headers=e,m++}let e=0;for(u=m;u<=f;u++)"#"===a[u][0]?e++:this.parseCSVRow(a[u],u-m-e);s.length&&s[0].length&&"date"===s[0][1]&&!this.options.dateFormat&&this.deduceDateFormat(this.columns[0],null,!0);for(let e=0,t=this.columns.length;e<t;++e){c=this.columns[e];for(let t=0,s=c.length;t<s;++t)if(c[t]&&"string"==typeof c[t]){let s=this.asGuessedType(c[t]);s instanceof Date&&(s=s.getTime()),this.columns[e][t]=s}}}this.emit({type:"afterParse",columns:this.columns,detail:t,headers:this.headers})}parseCSVRow(e,t){let s=this,r=s.columns||[],n=s.dataTypes,{startColumn:i,endColumn:o}=s.options,l=s.options.itemDelimiter||s.guessedItemDelimiter,{decimalPoint:a}=s.options;a&&a!==l||(a=s.guessedDecimalPoint||".");let u=0,h="",m="",f=0,c=0,d=t=>{h=e[t]},p=e=>{n.length<c+1&&n.push([e]),n[c][n[c].length-1]!==e&&n[c].push(e)},g=()=>{if(i>f||f>o){++f,m="";return}if("string"==typeof m?!isNaN(parseFloat(m))&&isFinite(m)?(m=parseFloat(m),p("number")):isNaN(Date.parse(m))?p("string"):(m=m.replace(/\//g,"-"),p("date")):p("number"),r.length<c+1&&r.push([]),"number"!=typeof m&&"number"!==s.guessType(m)&&a){let e=m;m=m.replace(a,"."),"number"!==s.guessType(m)&&(m=e)}r[c][t]=m,m="",++c,++f};if(e.trim().length&&"#"!==e.trim()[0]){for(;u<e.length;u++){if(d(u),"#"===h&&!/^#[A-F\d]{3,3}|[A-F\d]{6,6}/i.test(e.substring(u))){g();return}if('"'===h)for(d(++u);u<e.length&&'"'!==h;)m+=h,d(++u);else h===l?g():m+=h}g()}}guessDelimiter(e){let t=0,s=0,r,n={",":0,";":0," ":0},i=e.length;for(let r=0;r<i;r++){let i=!1,o,l,a,u="";if(r>13)break;let h=e[r];for(let e=0;e<h.length&&(o=h[e],l=h[e+1],a=h[e-1],"#"!==o);e++){if('"'===o){if(i){if('"'!==a&&'"'!==l){for(;" "===l&&e<h.length;)l=h[++e];void 0!==n[l]&&n[l]++,i=!1}}else i=!0}else void 0!==n[o]?(isNaN(Date.parse(u=u.trim()))?(isNaN(Number(u))||!isFinite(Number(u)))&&n[o]++:n[o]++,u=""):u+=o;","===o&&s++,"."===o&&t++}}return n[";"]>n[","]?r=";":(n[","],n[";"],r=","),t>s?this.guessedDecimalPoint=".":this.guessedDecimalPoint=",",r}getTable(){return j.getTableFromColumns(this.columns,this.headers)}}eH.defaultOptions={...j.defaultOptions,lineDelimiter:"\n"},j.registerType("CSV",eH);let{merge:e_}=o();class eB extends F{constructor(e){let t=e_(eB.defaultOptions,e);super(t),this.converter=new eH(t),this.options=t,t.enablePolling&&this.startPolling(1e3*Math.max(t.dataRefreshRate||0,1))}load(e){let t=this,s=t.converter,r=t.table,{csv:n,csvURL:i,dataModifier:o}=t.options;return t.emit({type:"load",csv:n,detail:e,table:r}),Promise.resolve(i?fetch(i).then(e=>e.text()):n||"").then(e=>(e&&(r.deleteColumns(),s.parse({csv:e}),r.setColumns(s.getTable().getColumns())),t.setModifierOptions(o).then(()=>e))).then(s=>(t.emit({type:"afterLoad",csv:s,detail:e,table:r}),t)).catch(s=>{throw t.emit({type:"loadError",detail:e,error:s,table:r}),s})}}eB.defaultOptions={csv:"",csvURL:"",enablePolling:!1,dataRefreshRate:1,firstRowAsNames:!0},F.registerType("CSV",eB);let{error:eG,isArray:eZ,merge:eJ,objectEach:eX}=o();class eK extends j{constructor(e){let t=eJ(eK.defaultOptions,e);super(t),this.columns=[],this.headers=[],this.options=t,this.table=new N}parse(e,t){let{beforeParse:s,orientation:r,firstRowAsNames:n,columnNames:i}=e=eJ(this.options,e),o=e.data;if(o){if(this.columns=[],this.emit({type:"parse",columns:this.columns,detail:t,headers:this.headers}),s&&(o=s(o)),o=o.slice(),"columns"===r)for(let e=0,t=o.length;e<t;e++){let t=o[e];if(!(t instanceof Array))return;this.headers instanceof Array?(n?this.headers.push(`${t.shift()}`):i&&i instanceof Array&&this.headers.push(i[e]),this.table.setColumn(this.headers[e]||e.toString(),t)):eG("JSONConverter: Invalid `columnNames` option.",!1)}else if("rows"===r){n?this.headers=o.shift():i&&(this.headers=i);for(let e=0,t=o.length;e<t;e++){let t=o[e];if(eZ(t))for(let e=0,s=t.length;e<s;e++)this.columns.length<e+1&&this.columns.push([]),this.columns[e].push(t[e]),this.headers instanceof Array?this.table.setColumn(this.headers[e]||e.toString(),this.columns[e]):eG("JSONConverter: Invalid `columnNames` option.",!1);else{let s=this.headers;if(s&&!(s instanceof Array)){let e={};eX(s,(s,r)=>{e[r]=s.reduce((e,t)=>e[t],t)}),t=e}this.table.setRows([t],e)}}}this.emit({type:"afterParse",columns:this.columns,detail:t,headers:this.headers})}}getTable(){return this.table}}eK.defaultOptions={...j.defaultOptions,data:[],orientation:"rows"},j.registerType("JSON",eK);let{merge:eq}=o();class ez extends F{constructor(e){let t=eq(ez.defaultOptions,e);super(t),this.converter=new eK(t),this.options=t,t.enablePolling&&this.startPolling(1e3*Math.max(t.dataRefreshRate||0,1))}load(e){let t=this,s=t.converter,r=t.table,{data:n,dataUrl:i,dataModifier:o}=t.options;return t.emit({type:"load",data:n,detail:e,table:r}),Promise.resolve(i?fetch(i).then(e=>e.json()):n||[]).then(e=>(e&&(r.deleteColumns(),s.parse({data:e}),r.setColumns(s.getTable().getColumns())),t.setModifierOptions(o).then(()=>e))).then(s=>(t.emit({type:"afterLoad",data:s,detail:e,table:r}),t)).catch(s=>{throw t.emit({type:"loadError",detail:e,error:s,table:r}),s})}}ez.defaultOptions={data:[],enablePolling:!1,dataRefreshRate:0,firstRowAsNames:!0,orientation:"rows"},F.registerType("JSON",ez);let{merge:eQ,uniqueKey:eW}=o();class e0 extends j{constructor(e){let t=eQ(e0.defaultOptions,e);super(t),this.columns=[],this.header=[],this.options=t}parse(e,t){let s;let r=eQ(this.options,e),n=(r.json?.values||[]).map(e=>e.slice());if(0===n.length)return!1;this.header=[],this.columns=[],this.emit({type:"parse",columns:this.columns,detail:t,headers:this.header});let{beforeParse:i,json:o}=r;i&&o&&(n=i(o.values)),this.columns=n;for(let e=0,t=n.length;e<t;e++){s=n[e],this.header[e]=r.firstRowAsNames?`${s.shift()}`:eW();for(let t=0,r=s.length;t<r;++t)if(s[t]&&"string"==typeof s[t]){let r=this.asGuessedType(s[t]);r instanceof Date&&(r=r.getTime()),this.columns[e][t]=r}}this.emit({type:"afterParse",columns:this.columns,detail:t,headers:this.header})}getTable(){return j.getTableFromColumns(this.columns,this.header)}}e0.defaultOptions={...j.defaultOptions},j.registerType("GoogleSheets",e0);let{merge:e1,pick:e2}=o();class e3 extends F{constructor(e){let t=e1(e3.defaultOptions,e);super(t),this.converter=new e0(t),this.options=t}load(e){let t=this,s=t.converter,r=t.table,{dataModifier:n,dataRefreshRate:i,enablePolling:o,firstRowAsNames:l,googleAPIKey:a,googleSpreadsheetKey:u}=t.options,h=e3.buildFetchURL(a,u,t.options);if(t.emit({type:"load",detail:e,table:r,url:h}),!URL.canParse(h))throw Error("Invalid URL: "+h);return fetch(h).then(e=>e.json()).then(e=>{if("object"==typeof e&&e&&"object"==typeof e.error&&e.error&&"number"==typeof e.error.code&&"string"==typeof e.error.message&&"string"==typeof e.error.status)throw Error(e.error.message);return s.parse({firstRowAsNames:l,json:e}),r.deleteColumns(),r.setColumns(s.getTable().getColumns()),t.setModifierOptions(n)}).then(()=>(t.emit({type:"afterLoad",detail:e,table:r,url:h}),o&&setTimeout(()=>t.load(),1e3*Math.max(i||0,1)),t)).catch(s=>{throw t.emit({type:"loadError",detail:e,error:s,table:r}),s})}}e3.defaultOptions={googleAPIKey:"",googleSpreadsheetKey:"",enablePolling:!1,dataRefreshRate:2,firstRowAsNames:!0},function(e){let t="ABCDEFGHIJKLMNOPQRSTUVWXYZ";function s(e={}){let{endColumn:r,endRow:n,googleSpreadsheetRange:i,startColumn:o,startRow:l}=e;return i||(t[o||0]||"A")+(Math.max(l||0,0)+1)+":"+(t[e2(r,25)]||"Z")+(n?Math.max(n,0):"Z")}e.buildFetchURL=function(e,t,r={}){let n=new URL(`https://sheets.googleapis.com/v4/spreadsheets/${t}/values/`),i=r.onlyColumnNames?"A1:Z1":s(r);n.pathname+=i;let o=n.searchParams;return o.set("alt","json"),r.onlyColumnNames||(o.set("dateTimeRenderOption","FORMATTED_STRING"),o.set("majorDimension","COLUMNS"),o.set("valueRenderOption","UNFORMATTED_VALUE")),o.set("prettyPrint","false"),o.set("key",e),n.href},e.buildQueryRange=s}(e3||(e3={})),F.registerType("GoogleSheets",e3);let{merge:e4}=o();class e6 extends j{constructor(e){let t=e4(e6.defaultOptions,e);super(t),this.columns=[],this.headers=[],this.options=t,t.tableElement&&(this.tableElement=t.tableElement,this.tableElementID=t.tableElement.id)}export(e,t=this.options){let s=!1!==t.firstRowAsNames,r=t.useMultiLevelHeaders,n=e.getSortedColumns(t.usePresentationOrder),i=Object.keys(n),o=[],l=i.length,a=[],u="";if(s){let e=[];if(r){for(let t of i){let s=(n[t].shift()||"").toString();e.push(s)}u=this.getTableHeaderHTML(i,e,t)}else u=this.getTableHeaderHTML(void 0,i,t)}for(let e=0;e<l;e++){let t=n[i[e]],s=t.length;for(let r=0;r<s;r++){let s=t[r];a[r]||(a[r]=[]),"string"==typeof s||"number"==typeof s||void 0===s||(s=(s||"").toString()),a[r][e]=this.getCellHTMLFromValue(e?"td":"th",null,e?"":'scope="row"',s),e===l-1&&o.push("<tr>"+a[r].join("")+"</tr>")}}let h="";return t.tableCaption&&(h='<caption class="highcharts-table-caption">'+t.tableCaption+"</caption>"),"<table>"+h+u+"<tbody>"+o.join("")+"</tbody></table>"}getCellHTMLFromValue(e,t,s,r,n){let i=r,o="text"+(t?" "+t:"");return"number"==typeof i?(i=i.toString(),","===n&&(i=i.replace(".",n)),o="number"):r||(i="",o="empty"),"<"+e+(s?" "+s:"")+' class="'+o+'">'+i+"</"+e+">"}getTableHeaderHTML(e=[],t=[],s=this.options){let{useMultiLevelHeaders:r,useRowspanHeaders:n}=s,i="<thead>",o=0,l=t&&t.length,a,u=0,h;if(r&&e&&t&&!function(e,t){let s=e.length;if(t.length!==s)return!1;for(;--s;)if(e[s]!==t[s])return!1;return!0}(e,t)){for(i+="<tr>";o<l;++o)(a=e[o])===e[o+1]?++u:u?(i+=this.getCellHTMLFromValue("th","highcharts-table-topheading",'scope="col" colspan="'+(u+1)+'"',a),u=0):(a===t[o]?n?(h=2,delete t[o]):(h=1,t[o]=""):h=1,i+=this.getCellHTMLFromValue("th","highcharts-table-topheading",'scope="col"'+(h>1?' valign="top" rowspan="'+h+'"':""),a));i+="</tr>"}if(t){for(i+="<tr>",o=0,l=t.length;o<l;++o)void 0!==t[o]&&(i+=this.getCellHTMLFromValue("th",null,'scope="col"',t[o]));i+="</tr>"}return i+"</thead>"}parse(e,t){let s=[],r=[],n=e4(this.options,e),{endRow:i,startColumn:o,endColumn:l,firstRowAsNames:a}=n,u=n.tableElement||this.tableElement;if(!(u instanceof HTMLElement)){this.emit({type:"parseError",columns:s,detail:t,headers:r,error:"Not a valid HTML Table"});return}this.tableElement=u,this.tableElementID=u.id,this.emit({type:"parse",columns:this.columns,detail:t,headers:this.headers});let h=u.getElementsByTagName("tr"),m=h.length,f=0,c,{startRow:d}=n;if(a&&m){let e=h[0].children,t=e.length;for(let s=o;s<t&&!(s>l);s++)("TD"===(c=e[s]).tagName||"TH"===c.tagName)&&r.push(c.innerHTML);d++}for(;f<m;){if(f>=d&&f<=i){let e=h[f].children,t=e.length,r=0;for(;r<t;){let t=r-o,n=s[t];if(("TD"===(c=e[r]).tagName||"TH"===c.tagName)&&r>=o&&r<=l){s[t]||(s[t]=[]);let e=this.asGuessedType(c.innerHTML);e instanceof Date&&(e=e.getTime()),s[t][f-d]=e;let r=1;for(;f-d>=r&&void 0===n[f-d-r];)n[f-d-r]=null,r++}r++}}f++}this.columns=s,this.headers=r,this.emit({type:"afterParse",columns:s,detail:t,headers:r})}getTable(){return j.getTableFromColumns(this.columns,this.headers)}}e6.defaultOptions={...j.defaultOptions,useRowspanHeaders:!0,useMultiLevelHeaders:!0},j.registerType("HTMLTable",e6);let{win:e9}=o(),{merge:e5}=o();class e7 extends F{constructor(e){let t=e5(e7.defaultOptions,e);super(t),this.converter=new e6(t),this.options=t}load(e){let t;let s=this,r=s.converter,n=s.table,{dataModifier:i,table:o}=s.options;if(s.emit({type:"load",detail:e,table:n,tableElement:s.tableElement}),"string"==typeof o?(s.tableID=o,t=e9.document.getElementById(o)):(t=o,s.tableID=t.id),s.tableElement=t||void 0,!s.tableElement){let t="HTML table not provided, or element with ID not found";return s.emit({type:"loadError",detail:e,error:t,table:n}),Promise.reject(Error(t))}return r.parse(e5({tableElement:s.tableElement},s.options),e),n.deleteColumns(),n.setColumns(r.getTable().getColumns()),s.setModifierOptions(i).then(()=>(s.emit({type:"afterLoad",detail:e,table:n,tableElement:s.tableElement}),s))}}e7.defaultOptions={table:""},F.registerType("HTMLTable",e7);let{merge:e8}=o();class te extends m{constructor(e,...t){super(),this.chain=t,this.options=e8(te.defaultOptions,e);let s=this.options.chain||[];for(let e=0,r=s.length,n,i;e<r;++e)(n=s[e]).type&&(i=m.types[n.type])&&t.push(new i(n))}add(e,t){this.emit({type:"addModifier",detail:t,modifier:e}),this.chain.push(e),this.emit({type:"addModifier",detail:t,modifier:e})}clear(e){this.emit({type:"clearChain",detail:e}),this.chain.length=0,this.emit({type:"afterClearChain",detail:e})}async modify(e,t){let s=this.options.reverse?this.chain.slice().reverse():this.chain.slice();e.modified===e&&(e.modified=e.clone(!1,t));let r=e;for(let n=0,i=s.length;n<i;++n){try{await s[n].modify(r,t)}catch(s){throw this.emit({type:"error",detail:t,table:e}),s}r=r.modified}return e.modified=r,e}modifyCell(e,t,s,r,n){let i=this.options.reverse?this.chain.reverse():this.chain;if(i.length){let o=e.clone();for(let e=0,l=i.length;e<l;++e)i[e].modifyCell(o,t,s,r,n),o=o.modified;e.modified=o}return e}modifyColumns(e,t,s,r){let n=this.options.reverse?this.chain.reverse():this.chain.slice();if(n.length){let i=e.clone();for(let e=0,o=n.length;e<o;++e)n[e].modifyColumns(i,t,s,r),i=i.modified;e.modified=i}return e}modifyRows(e,t,s,r){let n=this.options.reverse?this.chain.reverse():this.chain.slice();if(n.length){let i=e.clone();for(let e=0,o=n.length;e<o;++e)n[e].modifyRows(i,t,s,r),i=i.modified;e.modified=i}return e}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let s=this.options.reverse?this.chain.reverse():this.chain.slice(),r=e.modified;for(let e=0,n=s.length;e<n;++e)r=s[e].modifyTable(r,t).modified;return e.modified=r,this.emit({type:"afterModify",detail:t,table:e}),e}remove(e,t){let s=this.chain;this.emit({type:"removeModifier",detail:t,modifier:e}),s.splice(s.indexOf(e),1),this.emit({type:"afterRemoveModifier",detail:t,modifier:e})}}te.defaultOptions={type:"Chain"},m.registerType("Chain",te);let{merge:tt}=o();class ts extends m{constructor(e){super(),this.options=tt(ts.defaultOptions,e)}modifyCell(e,t,s,r,n){let i=e.modified,o=i.getRowIndexBy("columnNames",t);return void 0===o?i.setColumns(this.modifyTable(e.clone()).getColumns(),void 0,n):i.setCell(`${s}`,o,r,n),e}modifyColumns(e,t,s,r){let n=e.modified,i=n.getColumn("columnNames")||[],o=e.getColumnNames(),l=e.getRowCount()!==i.length;if(!l){for(let e=0,t=o.length;e<t;++e)if(o[e]!==i[e]){l=!0;break}}if(l)return this.modifyTable(e,r);o=Object.keys(t);for(let e=0,i=o.length,l,a,u;e<i;++e){l=t[a=o[e]],u=n.getRowIndexBy("columnNames",a)||n.getRowCount();for(let e=0,t=s,i=l.length;e<i;++e,++t)n.setCell(`${t}`,u,l[e],r)}return e}modifyRows(e,t,s,r){let n=e.getColumnNames(),i=e.modified,o=i.getColumn("columnNames")||[],l=e.getRowCount()!==o.length;if(!l){for(let e=0,t=n.length;e<t;++e)if(n[e]!==o[e]){l=!0;break}}if(l)return this.modifyTable(e,r);for(let e=0,o=s,l=t.length,a;e<l;++e,++o)if((a=t[e])instanceof Array)i.setColumn(`${o}`,a);else for(let e=0,t=n.length;e<t;++e)i.setCell(`${o}`,e,a[n[e]],r);return e}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let s=e.modified;if(e.hasColumns(["columnNames"])){let t=((e.deleteColumns(["columnNames"])||{}).columnNames||[]).map(e=>`${e}`),r={};for(let s=0,n=e.getRowCount(),i;s<n;++s)(i=e.getRow(s))&&(r[t[s]]=i);s.deleteColumns(),s.setColumns(r)}else{let t={};for(let s=0,r=e.getRowCount(),n;s<r;++s)(n=e.getRow(s))&&(t[`${s}`]=n);t.columnNames=e.getColumnNames(),s.deleteColumns(),s.setColumns(t)}return this.emit({type:"afterModify",detail:t,table:e}),e}}ts.defaultOptions={type:"Invert"},m.registerType("Invert",ts);class tr extends m{constructor(e){super(),this.options={...tr.defaultOptions,...e}}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let s=this.options.alternativeSeparators,r=this.options.formulaColumns||e.getColumnNames(),n=e.modified;for(let t=0,s=r.length,i;t<s;++t)i=r[t],r.indexOf(i)>=0&&n.setColumn(i,this.processColumn(e,i));let i=this.options.columnFormulas||[];for(let t=0,r=i.length,o,l;t<r;++t)o=i[t],l=W.parseFormula(o.formula,s),n.setColumn(o.column,this.processColumnFormula(l,e,o.rowStart,o.rowEnd));return this.emit({type:"afterModify",detail:t,table:e}),e}processColumn(e,t,s=0){let r=this.options.alternativeSeparators,n=(e.getColumn(t,!0)||[]).slice(s>0?s:0);for(let t=0,s=n.length,i=[],o;t<s;++t)if("string"==typeof(o=n[t])&&"="===o[0])try{i=""===o?i:W.parseFormula(o.substring(1),r),n[t]=ev.processFormula(i,e)}catch{n[t]=NaN}return n}processColumnFormula(e,t,s=0,r=t.getRowCount()){s=s>=0?s:0,r=r>=0?r:t.getRowCount()+r;let n=[],i=t.modified;for(let t=0,o=r-s;t<o;++t)try{n[t]=ev.processFormula(e,i)}catch{n[t]=NaN}finally{e=ev.translateReferences(e,0,1)}return n}}tr.defaultOptions={type:"Math",alternativeSeparators:!1},m.registerType("Math",tr);let{merge:tn}=o();class ti extends m{constructor(e){super(),this.options=tn(ti.defaultOptions,e)}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let s=[],{additive:r,ranges:n,strict:i}=this.options;if(n.length){let t=e.modified,o=e.getColumns(),l=[];for(let a=0,u=n.length,h,m;a<u;++a)if(h=n[a],!i||typeof h.minValue==typeof h.maxValue){a>0&&!r&&(t.deleteRows(),t.setRows(l),t.setOriginalRowIndexes(s,!0),o=t.getColumns(),l=[],s=[]),m=o[h.column]||[];for(let n=0,o=m.length,a,u,f;n<o;++n){switch(typeof(a=m[n])){default:continue;case"boolean":case"number":case"string":}(!i||typeof a==typeof h.minValue)&&a>=h.minValue&&a<=h.maxValue&&(r?(u=e.getRow(n),f=e.getOriginalRowIndex(n)):(u=t.getRow(n),f=t.getOriginalRowIndex(n)),u&&(l.push(u),s.push(f)))}}t.deleteRows(),t.setRows(l),t.setOriginalRowIndexes(s)}return this.emit({type:"afterModify",detail:t,table:e}),e}}ti.defaultOptions={type:"Range",ranges:[]},m.registerType("Range",ti);let{merge:to}=o();class tl extends m{static ascending(e,t){return(e||0)<(t||0)?-1:(e||0)>(t||0)?1:0}static descending(e,t){return(t||