!/**
 * Highcharts JS v12.5.0 (2026-01-12)
 * @module highcharts/modules/data-tools
 * @requires highcharts
 *
 * Highcharts
 *
 * (c) 2010-2026 Highsoft AS
 *
 * A commercial license may be required depending on use.
 * See 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)}("u"<typeof window?this:window,e=>(()=>{"use strict";var t,r,s,n,i,o,l={944:t=>{t.exports=e}},a={};function u(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}};return l[e](r,r.exports,u),r.exports}u.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return u.d(t,{a:t}),t},u.d=(e,t)=>{for(var r in t)u.o(t,r)&&!u.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var h={};u.d(h,{default:()=>tU});var c=u(944),d=u.n(c);let{addEvent:f,fireEvent:p,merge:m}=d();class g{benchmark(e,t){let r=[],s=this,n=()=>{s.modifyTable(e),s.emit({type:"afterBenchmarkIteration"})},{iterations:i}=m({iterations:1},t);s.on("afterBenchmarkIteration",()=>{r.length===i?s.emit({type:"afterBenchmark",results:r}):n()});let o={startTime:0,endTime:0};return s.on("modify",()=>{o.startTime=window.performance.now()}),s.on("afterModify",()=>{o.endTime=window.performance.now(),r.push(o.endTime-o.startTime)}),n(),r}emit(e){p(this,e.type,e)}modify(e,t){let r=this;return new Promise((s,n)=>{e.modified||(e.modified=e.clone(!1,t));try{s(r.modifyTable(e,t))}catch(s){r.emit({type:"error",detail:t,table:e}),n(s instanceof Error?s:Error(""+s))}})}on(e,t){return f(this,e,t)}}(t=g||(g={})).types={},t.registerType=function(e,r){return!!e&&!t.types[e]&&!!(t.types[e]=r)};let y=g;(r=i||(i={})).setLength=function(e,t,r){return Array.isArray(e)?(e.length=t,e):e[r?"subarray":"slice"](0,t)},r.splice=function(e,t,r,s,n=[]){if(Array.isArray(e))return Array.isArray(n)||(n=Array.from(n)),{removed:e.splice(t,r,...n),array:e};let i=Object.getPrototypeOf(e).constructor,o=e[s?"subarray":"slice"](t,t+r),l=new i(e.length-r+n.length);return l.set(e.subarray(0,t),0),l.set(n,t),l.set(e.subarray(t+r),t+n.length),{removed:o,array:l}},r.convertToNumber=function(e,t){switch(typeof e){case"boolean":return+!!e;case"number":return isNaN(e)&&!t?null:e;default:return isNaN(e=parseFloat(`${e??""}`))&&!t?null:e}};let b=i,{setLength:w,splice:C}=b,{fireEvent:R,objectEach:N,uniqueKey:T}=d(),v=class{constructor(e={}){this.autoId=!e.id,this.columns={},this.id=e.id||T(),this.rowCount=0,this.versionTag=T();let t=0;N(e.columns||{},(e,r)=>{this.columns[r]=e.slice(),t=Math.max(t,e.length)}),this.applyRowCount(t)}applyRowCount(e){this.rowCount=e,N(this.columns,(t,r)=>{t.length!==e&&(this.columns[r]=w(t,e))})}deleteRows(e,t=1){if(t>0&&e<this.rowCount){let r=0;N(this.columns,(s,n)=>{this.columns[n]=C(s,e,t).array,r=s.length}),this.rowCount=r}R(this,"afterDeleteRows",{rowIndex:e,rowCount:t}),this.versionTag=T()}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=[],r=0,s){this.setColumns({[e]:t},r,s)}setColumns(e,t,r){let s=this.rowCount;N(e,(e,t)=>{this.columns[t]=e.slice(),s=e.length}),this.applyRowCount(s),r?.silent||(R(this,"afterSetColumns"),this.versionTag=T())}setRow(e,t=this.rowCount,r,s){let{columns:n}=this,i=r?this.rowCount+1:t+1,o=Object.keys(e);if(s?.addColumns!==!1)for(let e=0,t=o.length;e<t;e++){let t=o[e];n[t]||(n[t]=[])}N(n,(o,l)=>{o||s?.addColumns===!1||(o=Array(i)),o&&(r?o=C(o,t,0,!0,[e[l]??null]).array:o[t]=e[l]??null,n[l]=o)}),i>this.rowCount&&this.applyRowCount(i),s?.silent||(R(this,"afterSetRows"),this.versionTag=T())}getModified(){return this.modified||this}},{splice:O,setLength:A}=b,{addEvent:M,defined:x,extend:I,fireEvent:E,isNumber:F,uniqueKey:D}=d();class P extends v{constructor(e={}){super(e),this.metadata=e.metadata}clone(e,t){let r={};this.emit({type:"cloneTable",detail:t}),e||(r.columns=this.columns),this.autoId||(r.id=this.id);let s=new P(r);return e||(s.versionTag=this.versionTag,s.originalRowIndexes=this.originalRowIndexes,s.localRowIndexes=this.localRowIndexes),s.metadata={...this.metadata},this.emit({type:"afterCloneTable",detail:t,tableClone:s}),s}deleteColumns(e,t){let r=this.columns,s={},n={},i=this.modifier,o=this.rowCount;if((e=e||Object.keys(r)).length){this.emit({type:"deleteColumns",columnIds:e,detail:t});for(let t=0,i=e.length,l,a;t<i;++t)(l=r[a=e[t]])&&(s[a]=l,n[a]=Array(o)),delete r[a];return Object.keys(r).length||(this.rowCount=0,this.deleteRowIndexReferences()),i&&i.modifyTable(this),this.emit({type:"afterDeleteColumns",columns:s,columnIds:e,detail:t}),s}}deleteRowIndexReferences(){delete this.originalRowIndexes,delete this.localRowIndexes}deleteRows(e,t=1,r){let s,n,{columns:i,modifier:o}=this,l=[];if(x(e)?Array.isArray(e)?n=(s=e.filter((e,t,r)=>e>=0&&e<this.rowCount&&r.indexOf(e)===t).sort((e,t)=>t-e)).length:(s=[e],n=t):(s=[0],n=this.rowCount),this.emit({type:"deleteRows",detail:r,rowCount:n,rowIndex:e??0}),n>0){let e=Object.keys(i);for(let t=0;t<e.length;++t){let r,o=e[t],a=i[o];if(1===s.length&&n>1){let e=O(a,s[0],n);r=e.removed,i[o]=e.array}else{for(let e of(r=[],s))r.push(a[e]),O(a,e,1);r.reverse()}t||(this.rowCount=a.length);for(let e=0,s=r.length;e<s;++e)l[e]=l[e]||[],l[e][t]=r[e]}}return o&&o.modifyTable(this),this.emit({type:"afterDeleteRows",detail:r,rowCount:n,rowIndex:e??0,rows:l}),l}emit(e){["afterDeleteColumns","afterDeleteRows","afterSetCell","afterSetColumns","afterSetRows"].includes(e.type)&&(this.versionTag=D()),E(this,e.type,e)}getCell(e,t){let r=this.columns[e];if(r)return r[t]}getColumn(e,t){return this.getColumns([e],t)[e]}getColumnIds(){return Object.keys(this.columns)}getColumns(e,t,r){let s=this.columns,n={};e=e||Object.keys(s);for(let i=0,o=e.length,l,a;i<o;++i)(l=s[a=e[i]])&&(t?n[a]=l:r&&!Array.isArray(l)?n[a]=Array.from(l):n[a]=l.slice());return n}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,r){let s=this.columns[e];if(s){let e=-1;if(Array.isArray(s)?e=s.indexOf(t,r):F(t)&&(e=s.indexOf(t,r)),-1!==e)return e}}getRowObject(e,t){return this.getRowObjects(e,1,t)[0]}getRowObjects(e=0,t=this.rowCount-e,r){let s=this.columns,n=Array(t);r=r||Object.keys(s);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]={},r))a=s[e],u[e]=a?a[i]:void 0;return n}getRows(e=0,t=this.rowCount-e,r){let s=this.columns,n=Array(t);r=r||Object.keys(s);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]=[],r))a=s[e],u.push(a?a[i]:void 0);return n}getVersionTag(){return this.versionTag}hasColumns(e){let t=this.columns;for(let r=0,s=e.length;r<s;++r)if(!t[e[r]])return!1;return!0}hasRowWith(e,t){let r=this.columns[e];return Array.isArray(r)?-1!==r.indexOf(t):!!(x(t)&&Number.isFinite(t))&&-1!==r.indexOf(+t)}on(e,t){return M(this,e,t)}changeColumnId(e,t){let r=this.columns;return!!r[e]&&(e!==t&&(r[t]=r[e],delete r[e]),!0)}setCell(e,t,r,s){let n=this.columns,i=this.modifier,o=n[e];o&&o[t]===r||(this.emit({type:"setCell",cellValue:r,columnId:e,detail:s,rowIndex:t}),o||(o=n[e]=Array(this.rowCount)),t>=this.rowCount&&(this.rowCount=t+1),o[t]=r,i&&i.modifyTable(this),this.emit({type:"afterSetCell",cellValue:r,columnId:e,detail:s,rowIndex:t}))}setColumns(e,t,r,s){let n=this.columns,i=this.modifier,o=Object.keys(e),l=this.rowCount;if(this.emit({type:"setColumns",columns:e,columnIds:o,detail:r,rowIndex:t}),x(t)||s){for(let r=0,i=o.length,a,u,h,c;r<i;++r){a=e[h=o[r]],c=Object.getPrototypeOf((u=n[h])&&s?u:a).constructor,u?c===Array?Array.isArray(u)||(u=Array.from(u)):u.length<l&&(u=new c(l)).set(n[h]):u=new c(l),n[h]=u;for(let e=t||0,r=a.length;e<r;++e)u[e]=a[e];l=Math.max(l,a.length)}this.applyRowCount(l)}else super.setColumns(e,t,I(r,{silent:!0}));i&&i.modifyTable(this),this.emit({type:"afterSetColumns",columns:e,columnIds:o,detail:r,rowIndex:t})}setModifier(e,t){let r=this;return r.emit({type:"setModifier",detail:t,modifier:e,modified:r.getModified()}),r.modifier=e,(e?e.modify(r):Promise.resolve(r)).then(r=>(r.emit({type:"afterSetModifier",detail:t,modifier:e,modified:r.getModified()}),r)).catch(t=>{throw r.emit({type:"setModifierError",error:t,modifier:e,modified:r.getModified()}),t})}setOriginalRowIndexes(e,t=!1){if(this.originalRowIndexes=e,t)return;let r=this.localRowIndexes=[];for(let t=0,s=e.length,n;t<s;++t)x(n=e[t])&&(r[n]=t)}setRow(e,t,r,s){this.setRows([e],t,r,s)}setRows(e,t=this.rowCount,r,s){let n=this.columns,i=Object.keys(n),o=this.modifier,l=e.length;this.emit({type:"setRows",detail:s,rowCount:l,rowIndex:t,rows:e});for(let s=0,o=t,a;s<l;++s,++o)if(0===Object.keys(a=e[s]).length)for(let e=0,t=i.length;e<t;++e){let t=n[i[e]];r?n[i[e]]=O(t,o,0,!0,[null]).array:t[o]=null}else if(Array.isArray(a))for(let e=0,t=i.length;e<t;++e)n[i[e]][o]=a[e];else super.setRow(a,o,r,{silent:!0});let a=r?l+e.length:t+l;if(a>this.rowCount){this.rowCount=a;for(let e=0,t=i.length;e<t;++e){let t=i[e];n[t]=A(n[t],a)}}o&&o.modifyTable(this),this.emit({type:"afterSetRows",detail:s,rowCount:l,rowIndex:t,rows:e})}}let{addEvent:j,fireEvent:L,merge:S,pick:k}=d();class Y{get polling(){return!!this._polling}constructor(e){this.dataTables={},this.loaded=!1,this.metadata=e.metadata||{columns:{}},this.options=e;const t=e?.dataTables;let r=0;if(e.options&&console.error("The `DataConnectorOptions.options` property was removed in Dashboards v4.0.0. Check how to upgrade your connector to use the new options structure here: https://api.highcharts.com/dashboards/#interfaces/Data_DataTableOptions.DataTableOptions"),t&&t?.length>0)for(let e=0,s=t.length;e<s;++e){const s=t[e],n=s?.key;this.dataTables[n??r]=new P(s),!n&&r++}else this.dataTables[0]=new P({id:e.id})}getTable(e){return e?this.dataTables[e]:Object.values(this.dataTables)[0]}describeColumn(e,t){let r=this.metadata.columns;r[e]=S(r[e]||{},t)}describeColumns(e){let t,r=Object.keys(e);for(;"string"==typeof(t=r.pop());)this.describeColumn(t,e[t])}getColumnOrder(){let e=this.metadata.columns,t=Object.keys(e||{});if(t.length)return t.sort((t,r)=>k(e[t].index,0)-k(e[r].index,0))}getSortedColumns(){return this.getTable().getColumns(this.getColumnOrder())}setColumnOrder(e){for(let t=0,r=e.length;t<r;++t)this.describeColumn(e[t],{index:t})}async update(e,t=!0){this.emit({type:"beforeUpdate"}),S(!0,this.options,e);let{options:r}=this;("enablePolling"in e||"dataRefreshRate"in e)&&("enablePolling"in r&&r.enablePolling?(this.stopPolling(),this.startPolling("dataRefreshRate"in r&&"number"==typeof r.dataRefreshRate?1e3*Math.max(r.dataRefreshRate,1):1e3)):this.stopPolling()),t&&await this.load(),this.emit({type:"afterUpdate"})}load(){return this.emit({type:"afterLoad"}),Promise.resolve(this)}async applyTableModifiers(){let e=this.options?.dataTables;for(let[t,r]of Object.entries(this.dataTables)){let s=e?.find(e=>e.key===t)?.dataModifier??this.options?.dataModifier,n=s&&y.types[s.type];await r.setModifier(n?new n(s):void 0)}return this}startPolling(e=1e3){let t=this;this.pollingController=new AbortController,window.clearTimeout(t._polling),t._polling=window.setTimeout(()=>t.load().catch(e=>t.emit({type:"loadError",error:e})).then(()=>{t._polling&&t.startPolling(e)}),e)}stopPolling(){this.polling&&(this?.pollingController?.abort(),window.clearTimeout(this._polling),delete this._polling)}emit(e){L(this,e.type,e)}on(e,t){return j(this,e,t)}initConverters(e,t,r){let s=0;for(let[n,i]of Object.entries(this.dataTables)){let o=t(n),l=r(o,e);i.deleteColumns(),i.setColumns(l),0===s&&(this.converter=o),s++}}}(s=Y||(Y={})).types={},s.registerType=function(e,t){return!!e&&!s.types[e]&&!!(s.types[e]=t)};let V=Y,{isNumber:$}=d();var U=o||(o={});function H(e,t){if("number"==typeof e)return e;if("boolean"==typeof e)return+!!e;if("string"==typeof e){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}U.asDate=function(e,t){let r;if("string"==typeof e)r=t.parseDate(e);else if("number"==typeof e)r=e;else{if(e instanceof Date)return e;r=t.parseDate(""+e)}return new Date(r)},U.asNumber=H,U.asString=function(e){return""+e},U.asBoolean=function(e){return"boolean"==typeof e?e:"string"==typeof e?""!==e&&"0"!==e&&"false"!==e:!!H(e)},U.guessType=function(e,t){let r="string";if("string"==typeof e){let s=U.trim(`${e}`),n=t.decimalRegExp,i=U.trim(s,!0);n&&(i=n.test(i)?i.replace(n,"$1.$2"):"");let o=parseFloat(i);+i===o?e=o:r=$(t.parseDate(e))?"Date":"string"}return"number"==typeof e&&(r=e>31536e6?"Date":"number"),r},U.trim=function(e,t){return"string"==typeof e&&(e=e.replace(/^\s+|\s+$/g,""),t&&/^[\d\s]+$/.test(e)&&(e=e.replace(/\s/g,""))),e},U.getColumnsCollection=function(e=[],t){let r={};for(let s=0,n=Math.max(t.length,e.length);s<n;++s)r[t[s]||`${s}`]=e[s]?e[s].slice():[];return r};let _=o,{addEvent:B,fireEvent:X,merge:Z}=d();class J{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 r=+e[4];return r>t.getFullYear()-2e3?r+=1900:r+=2e3,Date.UTC(r,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}}};const t=Z(J.defaultOptions,e);let r=t.decimalPoint;("."===r||","===r)&&(r="."===r?"\\.":",",this.decimalRegExp=RegExp("^(-?[0-9]+)"+r+"([0-9]+)$")),this.options=t}convertByType(e){let t=this;return({number:e=>_.asNumber(e,t.decimalRegExp),Date:e=>_.asDate(e,t),string:_.asString})[_.guessType(e,t)].call(t,e)}deduceDateFormat(e,t,r){let s=[],n=[],i="YYYY/mm/dd",o,l=[],a=0,u=!1,h,c;for((!t||t>e.length)&&(t=e.length);a<t;a++)if(void 0!==e[a]&&e[a]&&e[a].length)for(c=0,o=e[a].trim().replace(/[\-\.\/]/g," ").split(" "),l=["","",""];c<o.length;c++)c<l.length&&(h=parseInt(o[c],10))&&(n[c]=!n[c]||n[c]<h?h:n[c],void 0!==s[c]?s[c]!==h&&(s[c]=!1):s[c]=h,h>31?h<100?l[c]="YY":l[c]="YYYY":h>12&&h<=31?(l[c]="dd",u=!0):l[c].length||(l[c]="mm"));if(u){for(c=0;c<s.length;c++)!1!==s[c]?n[c]>12&&"YY"!==l[c]&&"YYYY"!==l[c]&&(l[c]="YY"):n[c]>12&&"mm"===l[c]&&(l[c]="dd");3===l.length&&"dd"===l[1]&&"dd"===l[2]&&(l[2]="YY"),i=l.join("/")}return r&&(this.options.dateFormat=i),i}emit(e){X(this,e.type,e)}on(e,t){return B(this,e,t)}parseDate(e,t){let r=this.options,s=t||r.dateFormat,n=NaN,i,o=null;if(r.parseDate)n=r.parseDate(e);else{let t=this.dateFormats;if(s){let r=t[s];r||(r=t["YYYY/mm/dd"]),(o=e.match(r.regex))&&(n=r.parser(o))}else for(i in t){let r=t[i];if(o=e.match(r.regex)){s=i,n=r.parser(o);break}}if(!o){let t=Date.parse(e);!isNaN(t)&&(n=t-6e4*new Date(t).getTimezoneOffset(),e.includes("2001")||2001!==new Date(n).getFullYear()||(n=NaN))}}return n}}J.defaultOptions={dateFormat:"",firstRowAsNames:!0},(n=J||(J={})).types={},n.registerType=function(e,t){return!!e&&!n.types[e]&&!!(n.types[e]=t)};let G=J;class K{constructor(e={}){this.emittingRegister=[],this.listenerMap={},this.stateMap=e}addListener(e,t,r){let s=this.listenerMap[e]=this.listenerMap[e]||{};return(s[t]=s[t]||[]).push(r),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,r,s){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]||[];s&&(l.length||(i[t.state]=l),-1===K.getIndex(t,l)&&l.push(t));let a={cursor:t,cursors:l,table:e};r&&(a.event=r);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 r=this.stateMap[e]&&this.stateMap[e][t.state];if(r){let e=K.getIndex(t,r);e>=0&&r.splice(e,1)}return this}removeListener(e,t,r){let s=this.listenerMap[e]&&this.listenerMap[e][t];if(s){let e=s.indexOf(r);e>=0&&s.splice(e,1)}return this}}var q=K||(K={});function Q(e,t){if("range"===e.type)return e;let r={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&&(r.columns=[e.column]),r}q.getIndex=function(e,t){if("position"===e.type){for(let r,s=0,n=t.length;s<n;++s)if("position"===(r=t[s]).type&&r.state===e.state&&r.column===e.column&&r.row===e.row)return s}else{let r=JSON.stringify(e.columns);for(let s,n=0,i=t.length;n<i;++n)if("range"===(s=t[n]).type&&s.state===e.state&&s.firstRow===e.firstRow&&s.lastRow===e.lastRow&&JSON.stringify(s.columns)===r)return n}return -1},q.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)},q.isInRange=function(e,t){"position"===t.type&&(t=Q(t)),"position"===e.type&&(e=Q(e,t));let r=e.columns,s=t.columns;return e.firstRow>=t.firstRow&&e.lastRow<=t.lastRow&&(!r||!s||r.every(e=>s.indexOf(e)>=0))},q.toPositions=function(e){if("position"===e.type)return[e];let t=e.columns||[],r=[],s=e.state;for(let n=e.firstRow,i=e.lastRow;n<i;++n){if(!t.length){r.push({type:"position",row:n,state:s});continue}for(let e=0,i=t.length;e<i;++e)r.push({type:"position",column:t[e],row:n,state:s})}return r},q.toRange=Q;let W=K,{addEvent:z,fireEvent:ee,merge:et}=d();class er{constructor(e){this.options=et(er.defaultOptions,e),this.connectors={},this.waiting={}}emit(e){ee(this,e.type,e)}getConnector(e){let t=this.connectors[e];if(t?.loaded)return Promise.resolve(t);let r=this.waiting[e];if(!r){r=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,s=r.length;e<s;++e)r[e][0](t)}).catch(t=>{delete this.waiting[e];for(let e=0,s=r.length;e<s;++e)r[e][1](t)})}return new Promise((e,t)=>{r.push([e,t])})}getConnectorIds(){let e=this.options.connectors,t=[];for(let r=0,s=e.length;r<s;++r)t.push(e[r].id);return t}getConnectorOptions(e){let t=this.options.connectors;for(let r=0,s=t.length;r<s;++r)if(t[r].id===e)return t[r]}isNewConnector(e){return!this.connectors[e]}loadConnector(e){return new Promise((t,r)=>{this.emit({type:"load",options:e});let s=V.types[e.type];if(!s)throw Error(`Connector type not found. (${e.type})`);let n=this.connectors[e.id]=new s(e);n.load().then(({converter:r})=>{n.converter=r,n.loaded=!0,this.emit({type:"afterLoad",options:e}),t(n)}).catch(r)})}cancelPendingRequests(){let{connectors:e}=this;for(let t of Object.keys(e))e[t].stopPolling()}on(e,t){return z(this,e,t)}setConnectorOptions(e){let t=this.options.connectors,r=this.connectors;this.emit({type:"setConnectorOptions",options:e});for(let r=0,s=t.length;r<s;++r)if(t[r].id===e.id){t.splice(r,1);break}r[e.id]&&(r[e.id].stopPolling(),delete r[e.id]),t.push(e),this.emit({type:"afterSetConnectorOptions",options:e})}}er.defaultOptions={connectors:[]};let{isString:es}=d(),en=/^(?:FALSE|TRUE)/,ei=/^[+\-]?\d+(?:\.\d+)?(?:e[+\-]\d+)?/,eo=/^[+\-]?\d+(?:,\d+)?(?:e[+\-]\d+)?/,el=/^([A-Z][A-Z\d\.]*)\(/,ea=/^(?:[+\-*\/^<=>]|<=|=>)/,eu=/^(\$?[A-Z]+)(\$?\d+)\:(\$?[A-Z]+)(\$?\d+)/,eh=/^R(\d*|\[\d+\])C(\d*|\[\d+\])\:R(\d*|\[\d+\])C(\d*|\[\d+\])/,ec=/^(\$?[A-Z]+)(\$?\d+)(?![\:C])/,ed=/^R(\d*|\[\d+\])C(\d*|\[\d+\])(?!\:)/;function ef(e){let t=0;for(let r=0,s=e.length,n,i=1;r<s;++r){if("("===(n=e[r])){t||(i=r+1),++t;continue}if(")"===n&&!--t)return e.substring(i,r)}if(t>0){let e=Error("Incomplete parantheses.");throw e.name="FormulaParseError",e}return""}function ep(e){let t=-1;for(let r=0,s=e.length,n,i=!1;r<s;++r){if("\\"===(n=e[r])){i=!i;continue}if(i){i=!1;continue}if('"'===n)if(!(t<0))return e.substring(t+1,r);else t=r}let r=Error("Incomplete string.");throw r.name="FormulaParseError",r}function em(e,t){let r;if(r=e.match(eh)){let e=""===r[2]||"["===r[2][0],t=""===r[1]||"["===r[1][0],s=""===r[4]||"["===r[4][0],n=""===r[3]||"["===r[3][0],i={type:"range",beginColumn:e?parseInt(r[2].substring(1,-1)||"0",10):parseInt(r[2],10)-1,beginRow:t?parseInt(r[1].substring(1,-1)||"0",10):parseInt(r[1],10)-1,endColumn:s?parseInt(r[4].substring(1,-1)||"0",10):parseInt(r[4],10)-1,endRow:n?parseInt(r[3].substring(1,-1)||"0",10):parseInt(r[3],10)-1};return e&&(i.beginColumnRelative=!0),t&&(i.beginRowRelative=!0),s&&(i.endColumnRelative=!0),n&&(i.endRowRelative=!0),i}if(r=e.match(eu)){let e="$"!==r[1][0],t="$"!==r[2][0],s="$"!==r[3][0],n="$"!==r[4][0],i={type:"range",beginColumn:eb(e?r[1]:r[1].substring(1))-1,beginRow:parseInt(t?r[2]:r[2].substring(1),10)-1,endColumn:eb(s?r[3]:r[3].substring(1))-1,endRow:parseInt(n?r[4]:r[4].substring(1),10)-1};return e&&(i.beginColumnRelative=!0),t&&(i.beginRowRelative=!0),s&&(i.endColumnRelative=!0),n&&(i.endRowRelative=!0),i}let s=ey(e,t);return 1===s.length&&"string"!=typeof s[0]?s[0]:s}function eg(e){let t=e.length,r=e[t-2];return"-"===e[t-1]&&es(r)&&!!r.match(/\*|\/|\^/)}function ey(e,t){let r=t?eo:ei,s=[],n,i=("="===e[0]?e.substring(1):e).trim();for(;i;){if(n=i.match(ed)){let e=""===n[2]||"["===n[2][0],t=""===n[1]||"["===n[1][0],r={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&&(r.columnRelative=!0),t&&(r.rowRelative=!0),eg(s)&&(s.pop(),r.isNegative=!0),s.push(r),i=i.substring(n[0].length).trim();continue}if(n=i.match(ec)){let e="$"!==n[1][0],t="$"!==n[2][0],r={type:"reference",column:eb(e?n[1]:n[1].substring(1))-1,row:parseInt(t?n[2]:n[2].substring(1),10)-1};e&&(r.columnRelative=!0),t&&(r.rowRelative=!0),eg(s)&&(s.pop(),r.isNegative=!0),s.push(r),i=i.substring(n[0].length).trim();continue}if(n=i.match(ea)){s.push(n[0]),i=i.substring(n[0].length).trim();continue}if(n=i.match(en)){s.push("TRUE"===n[0]),i=i.substring(n[0].length).trim();continue}if(n=i.match(r)){let e=parseFloat(n[0]);eg(s)&&(s.pop(),e=-e),s.push(e),i=i.substring(n[0].length).trim();continue}if('"'===i[0]){let e=ep(i);s.push(e.substring(1,-1)),i=i.substring(e.length+2).trim();continue}if(n=i.match(el)){let e=ef(i=i.substring(n[1].length).trim());s.push({type:"function",name:n[1],args:function(e,t){let r=[],s=t?";":",",n=0,i="";for(let o=0,l=e.length,a;o<l;++o)if((a=e[o])===s&&!n&&i)r.push(em(i,t)),i="";else if('"'!==a||n||i)" "!==a&&(i+=a,"("===a?++n:")"===a&&--n);else{let t=ep(e.substring(o));r.push(t),o+=t.length+1}return!n&&i&&r.push(em(i,t)),r}(e,t)}),i=i.substring(e.length+2).trim();continue}if("("===i[0]){let e=ef(i);if(e){s.push(ey(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 s}function eb(e){let t=0;for(let r=0,s=e.length,n,i=e.length-1;r<s;++r)(n=e.charCodeAt(r))>=65&&n<=90&&(t+=(n-64)*Math.pow(26,i)),--i;return t}let ew={parseFormula:ey},eC=["+","-","*","/","^","=","<","<=",">",">="],eR={isFormula:function(e){return Array.isArray(e)},isFunction:function(e){return"object"==typeof e&&!Array.isArray(e)&&"function"===e.type},isOperator:function(e){return"string"==typeof e&&eC.indexOf(e)>=0},isRange:function(e){return"object"==typeof e&&!Array.isArray(e)&&"range"===e.type},isReference:function(e){return"object"==typeof e&&!Array.isArray(e)&&"reference"===e.type},isValue:function(e){return"boolean"==typeof e||"number"==typeof e||"string"==typeof e}},{isFormula:eN,isFunction:eT,isOperator:ev,isRange:eO,isReference:eA,isValue:eM}=eR,{defined:ex}=d(),eI=/ */,eE=Number.MAX_VALUE/1.000000000001,eF=Number.MAX_VALUE/1.000000000002,eD=Number.MAX_VALUE,eP={"^":3,"*":2,"/":2,"+":1,"-":1,"=":0,"<":0,"<=":0,">":0,">=":0},ej={},eL=/^[A-Z][A-Z\.]*$/;function eS(e){switch(typeof e){case"boolean":return e?eD:eE;case"string":return eF;case"number":return e;default:return NaN}}function ek(e){return"string"==typeof e?e.toLowerCase().replace(eI,"\0"):e}function eY(e){switch(typeof e){case"boolean":return+!!e;case"string":return parseFloat(e.replace(",","."));case"number":return e;default:return NaN}}function eV(e,t){return eM(e)?e:eO(e)?t&&e$(e,t)||[]:eT(e)?eB(e,t):e_(eN(e)?e:[e],t)}function e$(e,t){let r=t.getColumnIds().slice(e.beginColumn,e.endColumn+1),s=[];for(let n=0,i=r.length,o;n<i;++n){let i=t.getColumn(r[n],!0)||[];for(let l=e.beginRow,a=e.endRow+1;l<a;++l)"string"==typeof(o=i[l])&&"="===o[0]&&t!==t.getModified()&&(o=t.getModified().getCell(r[n],l)),s.push(eM(o)?o:NaN)}return s}function eU(e,t){let r=t.getColumnIds()[e.column];if(r){let s=t.getCell(r,e.row);if("string"==typeof s&&"="===s[0]&&t!==t.getModified()){let s=t.getModified().getCell(r,e.row);return eM(s)?s:NaN}if(eM(s))return e.isNegative?-s:s}return NaN}function eH(e,t){(e.length<2||t.length<1)&&e.push(NaN);let r=e.pop(),s=e.pop(),n=t.pop();ex(r)&&ex(s)&&ex(n)?e.push(function(e,t,r){let s;switch(e){case"=":return ek(t)===ek(r);case"<":if(typeof t==typeof r)return ek(t)<ek(r);return eS(t)<eS(r);case"<=":if(typeof t==typeof r)return ek(t)<=ek(r);return eS(t)<=eS(r);case">":if(typeof t==typeof r)return ek(t)>ek(r);return eS(t)>eS(r);case">=":if(typeof t==typeof r)return ek(t)>=ek(r);return eS(t)>=eS(r)}switch(t=eY(t),r=eY(r),e){case"+":s=t+r;break;case"-":s=t-r;break;case"*":s=t*r;break;case"/":s=t/r;break;case"^":s=Math.pow(t,r);break;default:return NaN}return s%1?Math.round(1e9*s)/1e9:s}(n,s,r)):e.push(NaN)}function e_(e,t){let r=[],s=[],n=!0;for(let i=0,o=e.length;i<o;++i){let o,l=e[i];if(ev(l)){if(n&&"-"===l)r.push(0),s.push("-"),n=!0;else{for(;s.length&&eP[s[s.length-1]]>=eP[l];)eH(r,s);s.push(l),n=!0}continue}if(eM(l))o=l;else if(eA(l))o=t?eU(l,t):NaN;else if(eT(l)){let e=eB(l,t);o=eM(e)?e:NaN}else eN(l)&&(o=e_(l,t));if(void 0===o)return NaN;r.push(o),n=!1}for(;s.length;)eH(r,s);return 1!==r.length?NaN:r[0]}function eB(e,t,r){let s=ej[e.name];if(s)try{return s(e.args,t)}catch{return NaN}let n=Error(`Function "${e.name}" not found.`);throw n.name="FormulaProcessError",n}let eX={asNumber:eY,getArgumentValue:eV,getArgumentsValues:function(e,t){let r=[];for(let s=0,n=e.length;s<n;++s)r.push(eV(e[s],t));return r},getRangeValues:e$,getReferenceValue:eU,processFormula:e_,processorFunctions:ej,registerProcessorFunction:function(e,t){return eL.test(e)&&!ej[e]&&!!(ej[e]=t)},translateReferences:function e(t,r=0,s=0){for(let n=0,i=t.length,o;n<i;++n)Array.isArray(o=t[n])?e(o,r,s):eT(o)?e(o.args,r,s):eO(o)?(o.beginColumnRelative&&(o.beginColumn+=r),o.beginRowRelative&&(o.beginRow+=s),o.endColumnRelative&&(o.endColumn+=r),o.endRowRelative&&(o.endRow+=s)):eA(o)&&(o.columnRelative&&(o.column+=r),o.rowRelative&&(o.row+=s));return t}},{getArgumentValue:eZ}=eX;eX.registerProcessorFunction("ABS",function(e,t){let r=eZ(e[0],t);switch(typeof r){case"number":return Math.abs(r);case"object":{let e=[];for(let t=0,s=r.length,n;t<s;++t){if("number"!=typeof(n=r[t]))return NaN;e.push(Math.abs(n))}return e}default:return NaN}});let{getArgumentValue:eJ}=eX;eX.registerProcessorFunction("AND",function e(t,r){for(let s=0,n=t.length,i;s<n;++s)if(!(i=eJ(t[s],r))||"object"==typeof i&&!e(i,r))return!1;return!0});let{getArgumentsValues:eG}=eX;eX.registerProcessorFunction("AVERAGE",function(e,t){let r=eG(e,t),s=0,n=0;for(let e=0,t=r.length,i;e<t;++e)switch(typeof(i=r[e])){case"number":isNaN(i)||(++s,n+=i);break;case"object":for(let e=0,t=i.length,r;e<t;++e)"number"!=typeof(r=i[e])||isNaN(r)||(++s,n+=r)}return s?n/s:0});let{getArgumentValue:eK}=eX;eX.registerProcessorFunction("AVERAGEA",function(e,t){let r=0,s=0;for(let n=0,i=e.length,o;n<i;++n)switch(typeof(o=eK(e[n],t))){case"boolean":++r,s+=+!!o;continue;case"number":isNaN(o)||(++r,s+=o);continue;case"string":++r;continue;default:for(let e=0,t=o.length,n;e<t;++e)switch(typeof(n=o[e])){case"boolean":++r,s+=+!!n;continue;case"number":isNaN(n)||(++r,s+=n);continue;case"string":++r;continue}continue}return r?s/r:0}),eX.registerProcessorFunction("COUNT",function e(t,r){let s=eX.getArgumentsValues(t,r),n=0;for(let t=0,i=s.length,o;t<i;++t)switch(typeof(o=s[t])){case"number":!isNaN(o)&&++n;break;case"object":n+=e(o,r)}return n}),eX.registerProcessorFunction("COUNTA",function e(t,r){let s=eX.getArgumentsValues(t,r),n=0;for(let t=0,i=s.length,o;t<i;++t){switch(typeof(o=s[t])){case"number":if(isNaN(o))continue;break;case"object":n+=e(o,r);continue;case"string":if(!o)continue}++n}return n});let{getArgumentValue:eq}=eX;eX.registerProcessorFunction("IF",function(e,t){return eq(e[0],t)?eq(e[1],t):eq(e[2],t)});let{getArgumentValue:eQ}=eX;eX.registerProcessorFunction("ISNA",function(e,t){let r=eQ(e[0],t);return"number"!=typeof r||isNaN(r)});let{getArgumentsValues:eW}=eX;eX.registerProcessorFunction("MAX",function e(t,r){let s=eW(t,r),n=-1/0;for(let t=0,r=s.length,i;t<r;++t)switch(typeof(i=s[t])){case"number":i>n&&(n=i);break;case"object":(i=e(i))>n&&(n=i)}return isFinite(n)?n:0}),eX.registerProcessorFunction("MEDIAN",function(e,t){let r=[],s=eX.getArgumentsValues(e,t);for(let e=0,t=s.length,n;e<t;++e)switch(typeof(n=s[e])){case"number":isNaN(n)||r.push(n);break;case"object":for(let e=0,t=n.length,s;e<t;++e)"number"!=typeof(s=n[e])||isNaN(s)||r.push(s)}let n=r.length;if(!n)return NaN;let i=Math.floor(n/2);return n%2?r[i]:(r[i-1]+r[i])/2});let{getArgumentsValues:ez}=eX;eX.registerProcessorFunction("MIN",function e(t,r){let s=ez(t,r),n=1/0;for(let t=0,r=s.length,i;t<r;++t)switch(typeof(i=s[t])){case"number":i<n&&(n=i);break;case"object":(i=e(i))<n&&(n=i)}return isFinite(n)?n:0});let{getArgumentValue:e0}=eX;function e1(e,t){let r={},s=eX.getArgumentsValues(e,t);for(let e=0,t=s.length,n;e<t;++e)switch(typeof(n=s[e])){case"number":isNaN(n)||(r[n]=(r[n]||0)+1);break;case"object":for(let e=0,t=n.length,s;e<t;++e)"number"!=typeof(s=n[e])||isNaN(s)||(r[s]=(r[s]||0)+1)}return r}function e2(e,t){let r=e1(e,t),s=Object.keys(r);if(!s.length)return NaN;let n=parseFloat(s[0]),i=r[s[0]];for(let e=1,t=s.length,o,l,a;e<t;++e)i<(a=r[o=s[e]])?(n=parseFloat(o),i=a):i===a&&n>(l=parseFloat(o))&&(n=l,i=a);return i>1?n:NaN}eX.registerProcessorFunction("MOD",function(e,t){let r=e0(e[0],t),s=e0(e[1],t);return("object"==typeof r&&(r=r[0]),"object"==typeof s&&(s=s[0]),"number"!=typeof r||"number"!=typeof s||0===s)?NaN:r%s}),eX.registerProcessorFunction("MODE",e2),eX.registerProcessorFunction("MODE.MULT",function(e,t){let r=e1(e,t),s=Object.keys(r);if(!s.length)return NaN;let n=[parseFloat(s[0])],i=r[s[0]];for(let e=1,t=s.length,o,l;e<t;++e)i<(l=r[o=s[e]])?(n=[parseFloat(o)],i=l):i===l&&n.push(parseFloat(o));return i>1?n:NaN}),eX.registerProcessorFunction("MODE.SNGL",e2);let{getArgumentValue:e3}=eX;eX.registerProcessorFunction("NOT",function(e,t){let r=e3(e[0],t);switch("object"==typeof r&&(r=r[0]),typeof r){case"boolean":case"number":return!r}return NaN});let{getArgumentValue:e4}=eX;eX.registerProcessorFunction("OR",function e(t,r){for(let s=0,n=t.length,i;s<n;++s)if("object"==typeof(i=e4(t[s],r))){if(e(i,r))return!0}else if(i)return!0;return!1});let{getArgumentsValues:e6}=eX;eX.registerProcessorFunction("PRODUCT",function e(t,r){let s=e6(t,r),n=1,i=!1;for(let t=0,o=s.length,l;t<o;++t)switch(typeof(l=s[t])){case"number":isNaN(l)||(i=!0,n*=l);break;case"object":i=!0,n*=e(l,r)}return i?n:0}),eX.registerProcessorFunction("SUM",function e(t,r){let s=eX.getArgumentsValues(t,r),n=0;for(let t=0,i=s.length,o;t<i;++t)switch(typeof(o=s[t])){case"number":isNaN(o)||(n+=o);break;case"object":n+=e(o,r)}return n});let{getArgumentValue:e9}=eX;eX.registerProcessorFunction("XOR",function(e,t){for(let r=0,s=e.length,n,i;r<s;++r)switch(typeof(i=e9(e[r],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,r;e<t;++e)switch(typeof(r=i[e])){case"boolean":case"number":if(void 0===n)n=!!r;else if(!!r!==n)return!0}}return!1});let e5={...ew,...eX,...eR},{merge:e7}=d();class e8 extends G{constructor(e){const t=e7(e8.defaultOptions,e);super(t),this.headers=[],this.dataTypes=[],this.options=t}parse(e,t){let r=this.dataTypes,s=e7(this.options,e),{beforeParse:n,lineDelimiter:i,firstRowAsNames:o,itemDelimiter:l}=s,a,u=0,{csv:h,startRow:c,endRow:d}=s,f,p=[];if(this.emit({type:"parse",columns:p,detail:t,headers:this.headers}),h&&n&&(h=n(h)),h){if(a=h.replace(/\r\n|\r/g,"\n").split(i||"\n"),(!c||c<0)&&(c=0),(!d||d>=a.length)&&(d=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,c++}let e=0;for(u=c;u<=d;u++)"#"===a[u][0]?e++:this.parseCSVRow(p,a[u],u-c-e);r.length&&r[0].length&&"date"===r[0][1]&&!this.options.dateFormat&&this.deduceDateFormat(p[0],null,!0);for(let e=0,t=p.length;e<t;++e){f=p[e];for(let t=0,r=f.length;t<r;++t)if(f[t]&&"string"==typeof f[t]){let r=this.convertByType(f[t]);r instanceof Date&&(r=r.getTime()),p[e][t]=r}}}return p.forEach(e=>{e.length=Math.max(...p.map(e=>e.length))}),this.emit({type:"afterParse",columns:p,detail:t,headers:this.headers}),_.getColumnsCollection(p,this.headers)}parseCSVRow(e,t,r){let s=this,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="",c="",d=0,f=0,p=e=>{h=t[e]},m=e=>{n.length<f+1&&n.push([e]),n[f][n[f].length-1]!==e&&n[f].push(e)},g=()=>{if(i>d||d>o){++d,c="";return}if("string"==typeof c){let e=parseFloat(c);!isNaN(e)&&isFinite(Number(c))?(c=e,m("number")):isNaN(Date.parse(c))?m("string"):(c=c.replace(/\//g,"-"),m("date"))}else m("number");if(e.length<f+1&&e.push([]),"number"!=typeof c&&"number"!==_.guessType(c,s)&&a){let e=c;c=c.replace(a,"."),"number"!==_.guessType(c,s)&&(c=e)}e[f][r]=c,c="",++f,++d};if(t.trim().length&&"#"!==t.trim()[0]){for(;u<t.length;u++){if(p(u),"#"===h&&!/^#[A-F\d]{3,3}|[A-F\d]{6,6}/i.test(t.substring(u)))return void g();if('"'===h)for(p(++u);u<t.length&&'"'!==h;)c+=h,p(++u);else h===l?g():c+=h}g()}}guessDelimiter(e){let t=0,r=0,s,n={",":0,";":0,"	":0},i=e.length;for(let s=0;s<i;s++){let i=!1,o,l,a,u="";if(s>13)break;let h=e[s];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&&r++,"."===o&&t++}}return n[";"]>n[","]?s=";":(n[","]>n[";"],s=","),t>r?this.guessedDecimalPoint=".":this.guessedDecimalPoint=",",s}}e8.defaultOptions={...G.defaultOptions,lineDelimiter:"\n",startColumn:0,endColumn:Number.MAX_VALUE,startRow:0,endRow:Number.MAX_VALUE},G.registerType("CSV",e8);let{merge:te,fireEvent:tt}=d();class tr extends V{constructor(e){const t=te(tr.defaultOptions,e);super(t),this.options=t,t.enablePolling&&this.startPolling(1e3*Math.max(t.dataRefreshRate||0,1))}emit(e){tt(this,e.type,e)}load(e){let t=this,r=t.options,{csv:s,csvURL:n,dataTables:i,decimalPoint:o}=r;return t.emit({type:"load",csv:s}),Promise.resolve(n?fetch(n,{signal:t?.pollingController?.signal}).then(e=>e.text()):s||"").then(e=>(e&&this.initConverters(e,e=>{let{firstRowAsNames:t=r.firstRowAsNames,beforeParse:s=r.beforeParse}=i?.find(t=>t.key===e)||{};return new e8(te(r,{decimalPoint:o,firstRowAsNames:t,beforeParse:s}))},(e,t)=>e.parse({csv:t})),t.applyTableModifiers().then(()=>e))).then(r=>(t.emit({type:"afterLoad",detail:e,csv:r}),t)).catch(r=>{throw t.emit({type:"loadError",detail:e,error:r}),r})}}tr.defaultOptions={id:"csv-connector",type:"CSV",csv:"",csvURL:"",enablePolling:!1,dataRefreshRate:1,firstRowAsNames:!0},V.registerType("CSV",tr);let{error:ts,isArray:tn,merge:ti,objectEach:to}=d();class tl extends G{constructor(e){const t=ti(tl.defaultOptions,e);super(t),this.headerColumnIds=[],this.headers=[],this.options=t}parse(e,t){let{beforeParse:r,orientation:s,firstRowAsNames:n,columnIds:i}=e=ti(this.options,e),o=e.data;if(!o)return{};this.headers=[];let l=[];return this.emit({type:"parse",columns:l,detail:t,headers:this.headers}),r&&(o=r(o)),o=o.slice(),"columns"===s?this.parseColumnsOrientation(l,o,n,i):"rows"===s&&this.parseRowsOrientation(l,o,n,i),this.emit({type:"afterParse",columns:l,detail:t,headers:this.headers}),_.getColumnsCollection(l,this.headers)}parseColumnsOrientation(e,t,r,s){for(let n=0,i=t.length;n<i;n++){let i=t[n];if(!Array.isArray(i))return;Array.isArray(this.headers)?(r?this.headers.push(`${i.shift()}`):s&&Array.isArray(s)&&this.headers.push(s[n]),e.push(i)):ts("JSONConverter: Invalid `columnIds` option.",!1)}}parseRowsOrientation(e,t,r,s){r?this.headers=t.shift():s&&(this.headerColumnIds=s);for(let n=0,i=t.length;n<i;n++){let i=t[n];tn(i)||(i=this.convertItemToRow(i,s));for(let t=0,s=i.length;t<s;t++)e.length<t+1&&e.push([]),e[t].push(i[t]),r||0!==n||(Array.isArray(this.headerColumnIds)?this.headers.push(this.headerColumnIds[t]||t.toString()):ts("JSONConverter: Invalid `columnIds` option.",!1))}}convertItemToRow(e,t){let r=this;if(t&&!Array.isArray(t)){let s=[];return to(t,(t,n)=>{s.push(t.reduce((e,t)=>e[t],e)),0>r.headers.indexOf(n)&&r.headers.push(n)}),s}return r.headerColumnIds=Object.keys(e),Object.values(e)}}tl.defaultOptions={...G.defaultOptions,orientation:"rows"},G.registerType("JSON",tl);let{merge:ta,fireEvent:tu}=d();class th extends V{constructor(e){const t=ta(th.defaultOptions,e);super(t),this.options=t,t.enablePolling&&this.startPolling(1e3*Math.max(t.dataRefreshRate||0,1))}emit(e){tu(this,e.type,e)}load(e){let t=this,r=t.options,{data:s,dataUrl:n,dataTables:i}=r;return t.emit({type:"load",detail:e,data:s}),Promise.resolve(n?fetch(n,{signal:t?.pollingController?.signal}).then(e=>e.json()).catch(r=>{t.emit({type:"loadError",detail:e,error:r}),console.warn(`Unable to fetch data from ${n}.`)}):s||[]).then(async e=>(e&&this.initConverters(e,t=>{let{columnIds:s=r.columnIds,firstRowAsNames:n=r.firstRowAsNames,orientation:o=r.orientation,beforeParse:l=r.beforeParse}=i?.find(e=>e.key===t)||{};return new tl({data:e,columnIds:s,firstRowAsNames:n,orientation:o,beforeParse:l})},(e,t)=>e.parse({data:t})),t.applyTableModifiers().then(()=>e??[]))).then(r=>(t.emit({type:"afterLoad",detail:e,data:r}),t)).catch(r=>{throw t.emit({type:"loadError",detail:e,error:r}),r})}}th.defaultOptions={type:"JSON",id:"json-connector",data:[],enablePolling:!1,dataRefreshRate:0,firstRowAsNames:!0,orientation:"rows"},V.registerType("JSON",th);let{merge:tc,uniqueKey:td}=d();class tf extends G{constructor(e){const t=tc(tf.defaultOptions,e);super(t),this.header=[],this.options=t}parse(e,t){let r,s=tc(this.options,e),n=(s.json?.values||[]).map(e=>e.slice());if(0===n.length)return{};this.header=[],this.emit({type:"parse",columns:[],detail:t,headers:this.header});let{beforeParse:i,json:o}=s;i&&o&&(n=i(o.values));for(let e=0,t=n.length;e<t;e++){r=n[e],this.header[e]=s.firstRowAsNames?`${r.shift()}`:td();for(let t=0,s=r.length;t<s;++t){var l;let s=r[t];l=s,"[object Date]"===Object.prototype.toString.call(l)&&(s=s.getTime()),n[e][t]=s}}return this.emit({type:"afterParse",columns:n,detail:t,headers:this.header}),_.getColumnsCollection(n,this.header)}}tf.defaultOptions={...G.defaultOptions},G.registerType("GoogleSheets",tf);let{merge:tp,pick:tm,fireEvent:tg}=d();class ty extends V{constructor(e){const t=tp(ty.defaultOptions,e);super(t),this.options=t}emit(e){tg(this,e.type,e)}load(e){let t=this,r=t.options,{dataRefreshRate:s,enablePolling:n,googleAPIKey:i,googleSpreadsheetKey:o,dataTables:l}=r,a=ty.buildFetchURL(i,o,r);if(t.emit({type:"load",detail:e,url:a}),!URL.canParse(a))throw Error("Invalid URL: "+a);return fetch(a,{signal:t?.pollingController?.signal}).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 this.initConverters(e,e=>{let{firstRowAsNames:t=r.firstRowAsNames,beforeParse:s=r.beforeParse}=l?.find(t=>t.key===e)||{};return new tf({firstRowAsNames:t,beforeParse:s})},(e,t)=>e.parse({json:t})),t.applyTableModifiers()}).then(()=>(t.emit({type:"afterLoad",detail:e,url:a}),n&&setTimeout(()=>t.load(),1e3*Math.max(s||0,1)),t)).catch(r=>{throw t.emit({type:"loadError",detail:e,error:r}),r})}}ty.defaultOptions={id:"google-sheets-connector",type:"GoogleSheets",googleAPIKey:"",googleSpreadsheetKey:"",enablePolling:!1,dataRefreshRate:2,firstRowAsNames:!0};var tb=ty||(ty={});let tw="ABCDEFGHIJKLMNOPQRSTUVWXYZ";function tC(e={}){let{endColumn:t,endRow:r,googleSpreadsheetRange:s,startColumn:n,startRow:i}=e;return s||(tw[n||0]||"A")+(Math.max(i||0,0)+1)+":"+(tw[tm(t,25)]||"Z")+(r?Math.max(r,0):"Z")}tb.buildFetchURL=function(e,t,r={}){let s=new URL(`https://sheets.googleapis.com/v4/spreadsheets/${t}/values/`),n=r.onlyColumnIds?"A1:Z1":tC(r);s.pathname+=n;let i=s.searchParams;return i.set("alt","json"),r.onlyColumnIds||(i.set("dateTimeRenderOption","FORMATTED_STRING"),i.set("majorDimension","COLUMNS"),i.set("valueRenderOption","UNFORMATTED_VALUE")),i.set("prettyPrint","false"),i.set("key",e),s.href},tb.buildQueryRange=tC,V.registerType("GoogleSheets",ty);let{merge:tR}=d();class tN extends G{constructor(e){const t=tR(tN.defaultOptions,e);super(t),this.headers=[],this.options=t,t.tableElement&&(this.tableElement=t.tableElement,this.tableElementID=t.tableElement.id)}export(e,t=this.options){let r=!1!==t.firstRowAsNames,s=t.useMultiLevelHeaders,n=e.getSortedColumns(),i=Object.keys(n),o=[],l=i.length,a=[],u="";if(r){let e=[];if(s){for(let t of i){let r=n[t];Array.isArray(r)||(r=Array.from(r));let s=(r.shift()||"").toString();n[t]=r,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]],r=t.length;for(let s=0;s<r;s++){let r=t[s];a[s]||(a[s]=[]),"string"!=typeof r&&"number"!=typeof r&&void 0!==r&&(r=(r||"").toString()),a[s][e]=this.getCellHTMLFromValue(e?"td":"th",null,e?"":'scope="row"',r),e===l-1&&o.push("<tr>"+a[s].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,r,s,n){let i=s,o="text"+(t?" "+t:"");return"number"==typeof i?(i=i.toString(),","===n&&(i=i.replace(".",n)),o="number"):s||(i="",o="empty"),"<"+e+(r?" "+r:"")+' class="'+o+'">'+i+"</"+e+">"}getTableHeaderHTML(e=[],t=[],r=this.options){let{useMultiLevelHeaders:s,useRowspanHeaders:n}=r,i="<thead>",o=0,l=t&&t.length,a,u=0,h;if(s&&e&&t&&!function(e,t){let r=e.length;if(t.length!==r)return!1;for(;--r;)if(e[r]!==t[r])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,t.splice(o,1)):(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 r=[],s=[],n=tR(this.options,e),{endRow:i,startColumn:o,endColumn:l,firstRowAsNames:a}=n,u=n.tableElement||this.tableElement;if(!(u instanceof HTMLElement))return this.emit({type:"parseError",columns:r,detail:t,headers:s,error:"Not a valid HTML Table"}),{};this.tableElement=u,this.tableElementID=u.id,this.emit({type:"parse",columns:r,detail:t,headers:this.headers});let h=u.getElementsByTagName("tr"),c=h.length,d=0,f,{startRow:p}=n;if(a&&c){let e=h[0].children,t=e.length;for(let r=o;r<t&&!(r>l);r++)("TD"===(f=e[r]).tagName||"TH"===f.tagName)&&s.push(f.innerHTML);p++}for(;d<c;){if(d>=p&&d<=i){let e=h[d].children,t=e.length,s=0;for(;s<t;){let t=s-o,n=r[t];if(("TD"===(f=e[s]).tagName||"TH"===f.tagName)&&s>=o&&s<=l){r[t]||(r[t]=[]);let e=this.convertByType(f.innerHTML);e instanceof Date&&(e=e.getTime()),r[t][d-p]=e;let s=1;for(;d-p>=s&&void 0===n[d-p-s];)n[d-p-s]=null,s++}s++}}d++}return this.headers=s,this.emit({type:"afterParse",columns:r,detail:t,headers:s}),_.getColumnsCollection(r,this.headers)}}tN.defaultOptions={...G.defaultOptions,useRowspanHeaders:!0,useMultiLevelHeaders:!0,startColumn:0,endColumn:Number.MAX_VALUE,startRow:0,endRow:Number.MAX_VALUE},G.registerType("HTMLTable",tN);let{win:tT}=d(),{merge:tv}=d();class tO extends V{constructor(e){const t=tv(tO.defaultOptions,e);super(t),this.options=t,this.converter=new tN(t)}async load(e){let t,r=this.options,s=this.converter,n=this.getTable(),i=r.htmlTable;if(this.emit({type:"load",detail:e}),"string"==typeof i?(this.tableID=i,t=tT.document.getElementById(i)):(t=i,this.tableID=t.id),this.tableElement=t||void 0,!this.tableElement){let t="HTML table not provided, or element with ID not found";return this.emit({type:"loadError",detail:e,error:t}),Promise.reject(Error(t))}let o=s.parse(tv({tableElement:this.tableElement},r),e);return n.deleteColumns(),n.setColumns(o),await this.applyTableModifiers(),this.emit({type:"afterLoad",detail:e}),this}}tO.defaultOptions={id:"HTML-table-connector",type:"HTMLTable",htmlTable:""},V.registerType("HTMLTable",tO);let{addEvent:tA,fireEvent:tM,merge:tx}=d();class tI extends y{constructor(e,...t){super(),this.chain=t,this.options=tx(tI.defaultOptions,e);const r=this.options.chain||[];for(let e=0,s=r.length,n,i;e<s;++e)(n=r[e]).type&&(i=y.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 r=this.options.reverse?this.chain.slice().reverse():this.chain.slice();e.modified||(e.modified=e.clone(!1,t));let s=e;for(let n=0,i=r.length;n<i;++n){try{await r[n].modify(s,t)}catch(r){throw this.emit({type:"error",detail:t,table:e}),r}s=s.getModified()}return e.modified=s,e}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let r=this.options.reverse?this.chain.reverse():this.chain.slice(),s=e.getModified();for(let e=0,n=r.length;e<n;++e)s=r[e].modifyTable(s,t).getModified();return e.modified=s,this.emit({type:"afterModify",detail:t,table:e}),e}remove(e,t){let r=this.chain;this.emit({type:"removeModifier",detail:t,modifier:e}),r.splice(r.indexOf(e),1),this.emit({type:"afterRemoveModifier",detail:t,modifier:e})}emit(e){tM(this,e.type,e)}on(e,t){return tA(this,e,t)}}tI.defaultOptions={type:"Chain"},y.registerType("Chain",tI);let{merge:tE}=d();class tF extends y{constructor(e){super(),this.options=tE(tF.defaultOptions,e)}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let r=e.getModified();if(e.hasColumns(["columnIds"])){let t=(e.deleteColumns(["columnIds"])||{}).columnIds||[],s={},n=[];for(let e=0,r=t.length;e<r;++e)n.push(""+t[e]);for(let t=0,r=e.getRowCount(),i;t<r;++t)(i=e.getRow(t))&&(s[n[t]]=i);r.deleteColumns(),r.setColumns(s)}else{let t={};for(let r=0,s=e.getRowCount(),n;r<s;++r)(n=e.getRow(r))&&(t[`${r}`]=n);t.columnIds=e.getColumnIds(),r.deleteColumns(),r.setColumns(t)}return this.emit({type:"afterModify",detail:t,table:e}),e}}tF.defaultOptions={type:"Invert"},y.registerType("Invert",tF);class tD extends y{constructor(e){super(),this.options={...tD.defaultOptions,...e}}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let r=this.options.alternativeSeparators,s=this.options.formulaColumns||e.getColumnIds(),n=e.getModified();for(let t=0,r=s.length,i;t<r;++t)i=s[t],s.indexOf(i)>=0&&n.setColumn(i,this.processColumn(e,i));let i=this.options.columnFormulas||[];for(let t=0,s=i.length,o,l;t<s;++t)o=i[t],l=ew.parseFormula(o.formula,r),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,r=0){let s=this.options.alternativeSeparators,n=(e.getColumn(t,!0)||[]).slice(r>0?r:0);for(let t=0,r=n.length,i=[],o;t<r;++t)if("string"==typeof(o=n[t])&&"="===o[0])try{i=""===o?i:ew.parseFormula(o.substring(1),s),n[t]=eX.processFormula(i,e)}catch{n[t]=NaN}return n}processColumnFormula(e,t,r=0,s=t.getRowCount()){r=r>=0?r:0,s=s>=0?s:t.getRowCount()+s;let n=[],i=t.getModified();for(let t=0,o=s-r;t<o;++t)try{n[t]=eX.processFormula(e,i)}catch{n[t]=NaN}finally{e=eX.translateReferences(e,0,1)}return n}}tD.defaultOptions={type:"Math",alternativeSeparators:!1},y.registerType("Math",tD);let{merge:tP}=d();class tj extends y{constructor(e){super(),this.options=tP(tj.defaultOptions,e)}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let{start:r,end:s}=this.options;r=Math.max(0,r||0);let n=Math.max((s=Math.min(s||1/0,e.getRowCount()))-r,0),i=e.getModified();return i.deleteRows(),i.setRows(e.getRows(r,n)),i.setOriginalRowIndexes(Array.from({length:n},(t,s)=>e.getOriginalRowIndex(r+s))),this.emit({type:"afterModify",detail:t,table:e}),e}}tj.defaultOptions={type:"Range",start:0,end:1/0},y.registerType("Range",tj);let{merge:tL}=d();class tS extends y{static ascending(e,t){return(e||0)<(t||0)?-1:+((e||0)>(t||0))}static descending(e,t){return(t||0)<(e||0)?-1:+((t||0)>(e||0))}static compareFactory(e,t){return t?"desc"===e?(e,r)=>-t(e,r):t:"asc"===e?tS.ascending:tS.descending}constructor(e){super(),this.options=tL(tS.defaultOptions,e)}getRowReferences(e){let t=e.getRows(),r=[];for(let e=0,s=t.length;e<s;++e)r.push({index:e,row:t[e]});return r}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let r=e.getColumnIds(),s=e.getRowCount(),n=this.getRowReferences(e),{direction:i,orderInColumn:o,compare:l}=this.options,a=e.getModified(),u="columns"in this.options?this.options.columns:[this.options.orderByColumn],h=[];for(let e=0,t=u.length;e<t;++e){let t=u[e],s="string"==typeof t,n=s?t:t.column,o=r.indexOf(n);-1!==o&&h.push({columnIndex:o,compare:tS.compareFactory(s?i:t.direction||i,s?l:t.compare||l)})}if(h.length&&n.sort((e,t)=>{for(let r=0,s=h.length;r<s;++r){let{columnIndex:s,compare:n}=h[r],i=n(e.row[s],t.row[s]);if(i)return i}return e.index-t.index}),o){let e=[];for(let t=0;t<s;++t)e[n[t].index]=t;a.setColumns({[o]:e})}else{let t,r=[],i=[];for(let o=0;o<s;++o)t=n[o],r.push(e.getOriginalRowIndex(t.index)),i.push(t.row);a.setRows(i,0),a.setOriginalRowIndexes(r)}return this.emit({type:"afterModify",detail:t,table:e}),e}}tS.defaultOptions={type:"Sort",direction:"desc",orderByColumn:"y"},y.registerType("Sort",tS);let{isFunction:tk,merge:tY}=d();class tV extends y{static compile(e){if(tk(e))return e;let t=e.operator;switch(t){case"and":{let t=e.conditions.map(e=>this.compile(e));return(e,r,s)=>t.every(t=>t(e,r,s))}case"or":{let t=e.conditions.map(e=>this.compile(e));return(e,r,s)=>t.some(t=>t(e,r,s))}case"not":{let t=this.compile(e.condition);return(e,r,s)=>!t(e,r,s)}}let{columnId:r,value:s}=e;switch(t){case"==":return e=>e[r]==s;case"===":return e=>e[r]===s;case"!=":return e=>e[r]!=s;case"!==":return e=>e[r]!==s;case">":return e=>(e[r]||0)>(s||0);case">=":return e=>(e[r]||0)>=(s||0);case"<":return e=>(e[r]||0)<(s||0);case"<=":return e=>(e[r]||0)<=(s||0);case"empty":return e=>null===e[r]||""===e[r]}let{ignoreCase:n}=e,i=e=>{let t=""+e;return n??!0?t.toLowerCase():t};return"contains"===t?e=>i(e[r]).includes(i(s)):e=>i(e[r])[t](i(s))}constructor(e){super(),this.options=tY(tV.defaultOptions,e)}modifyTable(e,t){this.emit({type:"modify",detail:t,table:e});let{condition:r}=this.options;if(!r)return e;let s=tV.compile(r),n=e.getModified(),i=[],o=[];for(let t=0,r=e.getRowCount();t<r;++t){let r=e.getRowObject(t);r&&s(r,e,t)&&(i.push(r),o.push(e.getOriginalRowIndex(t)))}return n.deleteRows(),n.setRows(i),n.setOriginalRowIndexes(o),this.emit({type:"afterModify",detail:t,table:e}),e}}tV.defaultOptions={type:"Filter"},y.registerType("Filter",tV);let t$=d();t$.DataConnector=t$.DataConnector||V,t$.DataConverter=t$.DataConverter||G,t$.DataCursor=t$.DataCursor||W,t$.DataModifier=t$.DataModifier||y,t$.DataPool=t$.DataPool||er,t$.DataTable=t$.DataTable||P,t$.Formula=t$.Formula||e5;let tU=d();return h.default})());