UNPKG

@highcharts/dashboards

Version:
7 lines 49.1 kB
!/** * Highcharts Dashboards v1.3.1 (2024-02-14) * * (c) 2009-2024 Highsoft AS * * License: www.highcharts.com/license * */function(t){"object"==typeof module&&module.exports?(t.default=t,module.exports=t):"function"==typeof define&&define.amd?define("dashboards/modules/dashboards-plugin",["dashboards"],function(e){return t(e),t.Dashboards=e,t}):t("undefined"!=typeof Dashboards?Dashboards:void 0)}(function(t){"use strict";var e=t?t._modules:{};function i(t,e,i,s){t.hasOwnProperty(e)||(t[e]=s.apply(null,i),"function"==typeof CustomEvent&&window.dispatchEvent(new CustomEvent("DashboardsModuleLoaded",{detail:{path:e,module:t[e]}})))}i(e,"Dashboards/Plugins/DataGridSyncHandlers.js",[e["Core/Utilities.js"]],function(t){let{addEvent:e}=t,i={emitters:{highlightEmitter:["highlightEmitter",function(){if("DataGrid"===this.type){let{dataGrid:t,board:i}=this;if(i){let{dataCursor:s}=i,n=[];if(!t)return;return n.push(e(t.container,"dataGridHover",t=>{let e=this.connector&&this.connector.table;if(e){let i=t.row,n=i.querySelector(`.highcharts-datagrid-cell[data-original-data="${i.dataset.rowXIndex}"]`);s.emitCursor(e,{type:"position",row:parseInt(i.dataset.rowIndex,10),column:n?n.dataset.columnName:void 0,state:"dataGrid.hoverRow"})}})),n.push(e(t.container,"mouseout",()=>{let t=this.connector&&this.connector.table;t&&s.emitCursor(t,{type:"position",state:"dataGrid.hoverOut"})})),function(){n.forEach(t=>t())}}}}]},handlers:{highlightHandler:["highlightHandler",function(){let{board:t}=this,e=t=>{let e=t.cursor;if("position"===e.type){let{row:t}=e,{dataGrid:i}=this;if(void 0!==t&&i){let e=i.container.querySelector(`.highcharts-datagrid-row[data-row-index="${t}"]`);e&&(i.toggleRowHighlight(e),i.hoveredRow=e)}}},i=()=>{let{dataGrid:t}=this;t&&t.toggleRowHighlight(void 0)},s=()=>{let{dataCursor:s}=t;if(!s)return;let n=this.connector&&this.connector.table;n&&(s.addListener(n.id,"point.mouseOver",e),s.addListener(n.id,"point.mouseOut",i))},n=()=>{let s=t.dataCursor,n=this.connector&&this.connector.table;n&&(s.addListener(n.id,"point.mouseOver",e),s.addListener(n.id,"point.mouseOut",i))};t&&(s(),this.on("setConnector",()=>n()),this.on("afterSetConnector",()=>s()))}],extremesHandler:function(){let{board:t}=this,e=t=>{let e=t.cursor;if("position"===e.type&&this.dataGrid&&"number"==typeof e?.row){let{row:t}=e;this.dataGrid.scrollToRow(t)}},i=()=>{let{dataCursor:i}=t;if(!i)return;let s=this.connector&&this.connector.table;s&&i.addListener(s.id,"xAxis.extremes.min",e)},s=()=>{let i=this.connector&&this.connector.table,{dataCursor:s}=t;i&&s.removeListener(i.id,"xAxis.extremes.min",e)};t&&(i(),this.on("setConnector",()=>s()),this.on("afterSetConnector",()=>i()))},visibilityHandler:function(){let t=this,{board:e}=t,i=e=>{let i=e.cursor,s=t.dataGrid;if(!(s&&"position"===i.type&&i.column))return;let n=i.column;s.update({columns:{[n]:{show:"series.hide"!==i.state}}})},s=()=>{let{dataCursor:t}=e;if(!t)return;let s=this.connector&&this.connector.table;s&&(t.addListener(s.id,"series.show",i),t.addListener(s.id,"series.hide",i))},n=()=>{let t=this.connector&&this.connector.table,{dataCursor:s}=e;t&&(s.removeListener(t.id,"series.show",i),s.removeListener(t.id,"series.hide",i))};e&&(s(),this.on("setConnector",()=>n()),this.on("afterSetConnector",()=>s()))}}};return{highlight:{emitter:i.emitters.highlightEmitter,handler:i.handlers.highlightHandler},extremes:{handler:i.handlers.extremesHandler},visibility:{handler:i.handlers.visibilityHandler}}}),i(e,"Dashboards/Plugins/DataGridComponent.js",[e["Dashboards/Components/Component.js"],e["Data/Converters/DataConverter.js"],e["Dashboards/Plugins/DataGridSyncHandlers.js"],e["Core/Utilities.js"]],function(t,e,i,s){let{diffObjects:n,merge:o,uniqueKey:r}=s;class a extends t{static onUpdate(t,i){let s=t.target;if(s){let t=s.closest(".highcharts-datagrid-row"),n=s.closest(".highcharts-datagrid-cell"),o=new e;if(t&&t instanceof HTMLElement&&n&&n instanceof HTMLElement){let e=t.dataset.rowIndex,{columnName:r}=n.dataset;if(void 0!==e&&void 0!==r){let t=i.table;if(t){let i=o.asGuessedType(s.value);i instanceof Date&&(i=i.toString()),t.setCell(r,parseInt(e,10),i)}}}}}static fromJSON(t,e){let i=new a(e,o(t.options,{dataGridOptions:JSON.parse(t.options.dataGridOptions||""),syncHandlers:a.syncHandlers}));return i.emit({type:"fromJSON",json:t}),i}constructor(t,e){super(t,e=o(a.defaultOptions,e)),this.connectorListeners=[],this.options=e,this.type="DataGrid",this.options.dataGridClassName&&this.contentElement.classList.add(this.options.dataGridClassName),this.options.dataGridID&&(this.contentElement.id=this.options.dataGridID),this.sync=new a.Sync(this,this.syncHandlers),this.dataGridOptions=this.options.dataGridOptions||{},this.innerResizeTimeouts=[],this.on("afterSetConnector",t=>{this.disableEditingModifiedColumns(t.connector)})}onTableChanged(){this.dataGrid&&!this.dataGrid?.cellInputEl&&this.dataGrid.update({dataTable:this.filterColumns()})}disableEditingModifiedColumns(t){let e=this.getColumnOptions(t);this.dataGrid?.update({columns:e})}getColumnOptions(t){let e=t.options.dataModifier;if(!e||"Math"!==e.type)return{};let i=e.columnFormulas;if(!i)return{};let s={};for(let t=0,e=i.length;t<e;++t)s[i[t].column]={editable:!1};return s}async load(){if(this.emit({type:"load"}),await super.load(),this.connector&&!this.connectorListeners.length){let t=this.connectorListeners;t.push(this.connector.on("afterLoad",t=>{t.table&&this.connector&&this.connector.table.setColumns(t.table.getColumns())})),t.push(this.connector.table.on("afterSetCell",t=>{let e=this.dataGrid,i=!0;if(e){let s=e.rowElements[t.rowIndex],n=[];s&&(n=Array.prototype.slice.call(s.childNodes)),n.forEach(e=>{if(e.childElementCount>0){let s=e.childNodes[0],n="string"==typeof t.cellValue?s.value:+s.value;e.dataset.columnName===t.columnName&&n===t.cellValue&&(i=!1)}})}i&&this.update({})}))}return this.emit({type:"afterLoad"}),this}render(){return super.render(),this.dataGrid||(this.dataGrid=this.constructDataGrid()),this.connector&&this.dataGrid&&this.dataGrid.dataTable.modified!==this.connector.table.modified&&this.dataGrid.update({dataTable:this.filterColumns()}),this.sync.start(),this.emit({type:"afterRender"}),this.setupConnectorUpdate(),this}resize(t,e){this.dataGrid&&super.resize(t,e)}async update(t){if(t.connector?.id!==this.connectorId){let t=this.connectorListeners;for(let e=0,i=t.length;e<i;++e)t[e]();t.length=0}await super.update(t),this.dataGrid&&(this.filterAndAssignSyncOptions(i),this.dataGrid.update(this.options.dataGridOptions||{})),this.emit({type:"afterUpdate"})}constructDataGrid(){if(a.DataGridConstructor){let t=this.connector?this.getColumnOptions(this.connector):{};return this.dataGrid=new a.DataGridConstructor(this.contentElement,{...this.options.dataGridOptions,dataTable:this.options.dataGridOptions?.dataTable||this.filterColumns(),columns:o(t,this.options.dataGridOptions?.columns)}),this.dataGrid}throw Error("DataGrid not connected.")}setupConnectorUpdate(){let{connector:t,dataGrid:e}=this;t&&e&&e.on("cellClick",e=>{"input"in e&&e.input.addEventListener("keyup",e=>this.options.onUpdate(e,t))})}filterColumns(){let t=this.connector?.table.modified,e=this.options.visibleColumns;if(t){if(!e?.length)return t;let i=t.getColumnNames().filter(t=>e?.length>0&&!e.includes(t)),s=t.clone();return s.deleteColumns(i),s}}getOptionsOnDrop(t){let e=t.editMode.board.dataPool.getConnectorIds(),i={cell:"",type:"DataGrid"};return e.length&&(i={...i,connector:{id:e[0]}}),i}toJSON(){let t=JSON.stringify(this.options.dataGridOptions),e=super.toJSON(),i={...e,options:{...e.options,dataGridOptions:t}};return this.emit({type:"toJSON",json:i}),i}getOptions(){return{...n(this.options,a.defaultOptions),type:"DataGrid"}}destroy(){this.dataGrid?.containerResizeObserver.disconnect(),super.destroy()}}return a.syncHandlers=i,a.defaultOptions=o(t.defaultOptions,{dataGridClassName:"dataGrid-container",dataGridID:"dataGrid-"+r(),dataGridOptions:{},editableOptions:[{name:"connectorName",propertyPath:["connector","id"],type:"select"}],syncHandlers:i,onUpdate:a.onUpdate}),a}),i(e,"Dashboards/Plugins/DataGridPlugin.js",[e["Dashboards/Plugins/DataGridComponent.js"]],function(t){return{custom:{connectDataGrid:function(e){t.DataGridConstructor=e}},name:"DataGrid.DashboardsPlugin",onRegister:function(e){let{ComponentRegistry:i}=e;i.registerComponent("DataGrid",t)},onUnregister:function(t){}}}),i(e,"Dashboards/Plugins/HighchartsSyncHandlers.js",[e["Core/Utilities.js"]],function(t){let{addEvent:e}=t;function i(t,e){let{ranges:i}=e;if(i){let e=i.reduce((t,e)=>(e.minValue>t.minValue&&(t=e),t),i[0]),s=t.getRowIndexBy(e.column,e.minValue);if(s)return s}return 0}let s={emitters:{highlightEmitter:["highlightEmitter",function(){if("Highcharts"===this.type){let{chart:t,board:e}=this;if(e){let{dataCursor:s}=e;return this.on("afterRender",()=>{let e=this.connector&&this.connector.table;t&&t.series&&e&&t.series.forEach(t=>{t.update({point:{events:{mouseOver:function(){let n=0,o=e.getModifier();o&&"Range"===o.options.type&&(n=i(e,o.options)),s.emitCursor(e,{type:"position",row:n+this.index,column:t.name,state:"point.mouseOver"})},mouseOut:function(){let n=0,o=e.getModifier();o&&"Range"===o.options.type&&(n=i(e,o.options)),s.emitCursor(e,{type:"position",row:n+this.index,column:t.name,state:"point.mouseOut"})}}}})})}),function(){t&&t.series&&t.series.forEach(t=>{t.update({point:{events:{mouseOver:void 0,mouseOut:void 0}}})})}}}}],seriesVisibilityEmitter:function(){if("Highcharts"===this.type){let t=this;return this.on("afterRender",()=>{let{chart:e,connector:i,board:s}=t,n=i&&i.table;if(n&&s&&e){let{dataCursor:t}=s,{series:i}=e;i.forEach(e=>{e.update({events:{show:function(){t.emitCursor(n,{type:"position",state:"series.show",column:this.name})},hide:function(){t.emitCursor(n,{type:"position",state:"series.hide",column:this.name})}}})})}})}},extremesEmitter:function(){if("Highcharts"===this.type){let t=this,i=[];return this.on("afterRender",()=>{let{chart:s,connector:n,board:o}=t,r=n&&n.table,{dataCursor:a}=o;if(r&&s){let t=t=>{let e=!!t.resetSelection;if((!t.trigger||t.trigger&&"dashboards-sync"!==t.trigger)&&!e){let e=t.target,i=e.series.filter(t=>r.hasColumns([t.name])),[s]=i.length?i:e.series;if(s){let n=s.points.filter(t=>t.isInside||!1),o={type:"position",state:`${e.coll}.extremes.min`},l={type:"position",state:`${e.coll}.extremes.max`};if(i.length&&"xAxis"===e.coll&&n.length){let t=e.dateTime&&r.hasColumns(["x"])?"x":s.name;o.row=n[0].index,o.column=t,l.row=n[n.length-1].index,l.column=t}a.emitCursor(r,o,t,!0).emitCursor(r,l,t,!0)}}},n=()=>s.axes.map(i=>e(i,"afterSetExtremes",t)),o=n(),l=()=>{o.forEach(t=>{t()}),o=[]};i.push(e(s,"selection",t=>{t.resetSelection&&(l(),a.emitCursor(r,{type:"position",state:"chart.zoomOut"},t),o.push(...n()))})),i.push(()=>{a.remitCursor(r.id,{type:"position",state:"xAxis.extremes.min"}),a.remitCursor(r.id,{type:"position",state:"xAxis.extremes.max"}),l()})}}),function(){i.forEach(t=>t())}}}},handlers:{seriesVisibilityHandler:function(){let t=this,{board:e}=this,i=(t,e)=>{for(let i of t)if(i.name===e)return i},s=e=>{let s=t.chart;if(s&&"position"===e.cursor.type&&void 0!==e.cursor.column){let t=i(s.series,e.cursor.column);t&&t.setVisible(!0,!0)}},n=e=>{let s=t.chart;if(s&&"position"===e.cursor.type&&void 0!==e.cursor.column){let t=i(s.series,e.cursor.column);t&&t.setVisible(!1,!0)}},o=()=>{let{dataCursor:t}=e;if(!t)return;let i=this.connector&&this.connector.table;i&&(t.addListener(i.id,"series.show",s),t.addListener(i.id,"series.hide",n))},r=()=>{let t=this.connector&&this.connector.table;t&&(e.dataCursor.removeListener(t.id,"series.show",s),e.dataCursor.removeListener(t.id,"series.hide",n))};e&&(o(),this.on("setConnector",()=>r()),this.on("afterSetConnector",()=>o()))},highlightHandler:function(){let{chart:t,board:e}=this,s=e=>{let s=this.connector&&this.connector.table;if(!s)return;let n=0,o=s.getModifier();if(o&&"Range"===o.options.type&&(n=i(s,o.options)),t&&t.series.length){let i=e.cursor;if("position"===i.type){let[e]=t.series;if(t.series.length>1&&i.column){let s=t.series.filter(t=>t.name===i.column);s.length>0&&([e]=s)}if(e?.visible&&void 0!==i.row){let s=e.points[i.row-n],o=t.tooltip?.shared;if(s){let e=t.hoverPoint,i=e?.series||t.hoverSeries,n=t.pointer.getHoverData(s,i,t.series,!0,!0);t.tooltip&&t.tooltip.refresh(o?n.hoverPoints:s)}}}}},n=()=>{t&&t.series.length&&t.tooltip&&t.tooltip.hide()},o=()=>{let{dataCursor:t}=e;if(t){let e=this.connector&&this.connector.table;e&&(t.addListener(e.id,"point.mouseOver",s),t.addListener(e.id,"dataGrid.hoverRow",s),t.addListener(e.id,"point.mouseOut",n),t.addListener(e.id,"dataGrid.hoverOut",n))}},r=()=>{let t=this.connector&&this.connector.table;t&&(e.dataCursor.removeListener(t.id,"point.mouseOver",s),e.dataCursor.removeListener(t.id,"dataGrid.hoverRow",s),e.dataCursor.removeListener(t.id,"point.mouseOut",n),e.dataCursor.removeListener(t.id,"dataGrid.hoverOut",n))};e&&(o(),this.on("setConnector",()=>r()),this.on("afterSetConnector",()=>o()))},extremesHandler:function(){let{chart:t,board:e}=this;t&&e&&t.zooming?.type&&t.zooming.type.split("").map(t=>t+"Axis").forEach(i=>{let s=[],n=e=>{let{cursor:s,event:n}=e;if("position"===s.type){let e=n&&n.target;if(e&&t){let s=t[i],n=!1;s.forEach(t=>{e.coll===t.coll&&e!==t&&null!==e.min&&null!==e.max&&(t.max!==e.max||t.min!==e.min)&&(t.setExtremes(e.min,e.max,!1,void 0,{trigger:"dashboards-sync"}),n=!0)}),n&&!t.resetZoomButton&&t.showResetZoom(),t.redraw()}}},o=()=>{let{dataCursor:o}=e,{connector:r}=this;if(r){let{table:e}=r;o.addListener(e.id,`${i}.extremes.min`,n),o.addListener(e.id,`${i}.extremes.max`,n);let a=()=>{t.zoomOut(),setTimeout(()=>{this.element.querySelectorAll(".highcharts-reset-zoom").forEach(t=>{t.remove()})})};o.addListener(e.id,"chart.zoomOut",a),s.push(()=>{o.removeListener(e.id,`${i}.extremes.min`,n),o.removeListener(e.id,`${i}.extremes.max`,n),o.removeListener(e.id,"chart.zoomOut",a)})}},r=()=>{s.forEach(t=>t())};e&&(o(),this.on("setConnector",()=>r()),this.on("afterSetConnector",()=>o()))})}}};return{extremes:{emitter:s.emitters.extremesEmitter,handler:s.handlers.extremesHandler},highlight:{emitter:s.emitters.highlightEmitter,handler:s.handlers.highlightHandler},visibility:{emitter:s.emitters.seriesVisibilityEmitter,handler:s.handlers.seriesVisibilityHandler}}}),i(e,"Dashboards/Plugins/HighchartsComponent.js",[e["Dashboards/Components/Component.js"],e["Data/Converters/DataConverter.js"],e["Data/DataTable.js"],e["Dashboards/Globals.js"],e["Dashboards/Plugins/HighchartsSyncHandlers.js"],e["Core/Utilities.js"]],function(t,e,i,s,n,o){let{addEvent:r,createElement:a,diffObjects:l,isString:h,merge:c,splat:d,uniqueKey:u,isObject:p}=o;class m extends t{static fromJSON(t,e){let i=new m(e,c(t.options,{chartOptions:JSON.parse(t.options.chartOptions||"{}"),syncHandlers:m.syncHandlers}));return i.emit({type:"fromJSON",json:t}),i}constructor(t,e){super(t,e=c(m.defaultOptions,e)),this.options=e,this.chartConstructor=this.options.chartConstructor,this.type="Highcharts",this.chartContainer=a("figure",void 0,void 0,this.contentElement,!0),this.setOptions(),this.sync=new m.Sync(this,this.syncHandlers),this.chartOptions=c(this.options.chartOptions||{chart:{}},{tooltip:{}}),this.connector&&this.connector.on("afterLoad",t=>{t.table&&this.connector&&this.connector.table.setColumns(t.table.getColumns())}),this.innerResizeTimeouts=[]}onTableChanged(){this.updateSeries()}async load(){return this.emit({type:"load"}),await super.load(),this.emit({type:"afterLoad"}),this}render(){return super.render(),this.chart=this.getChart(),this.updateSeries(),this.sync.start(),this.emit({type:"afterRender"}),this.setupConnectorUpdate(),this}resize(t,e){for(super.resize(t,e);this.innerResizeTimeouts.length;){let t=this.innerResizeTimeouts.pop();t&&clearTimeout(t)}return this.innerResizeTimeouts.push(setTimeout(()=>{this.chart&&this.chart.setSize(null,this.contentElement.clientHeight,!1)},33)),this}setupConnectorUpdate(){let{connector:t,chart:e}=this;t&&e&&this.options.allowConnectorUpdate&&e.series.forEach(e=>{e.points.forEach(e=>{r(e,"drag",()=>{this.onChartUpdate(e,t)})})})}setOptions(){this.options.chartClassName&&this.chartContainer.classList.add(this.options.chartClassName),this.options.chartID&&(this.chartContainer.id=this.options.chartID)}onChartUpdate(t,i){let s=i.table,n=t.series.name,o=t.index,r=new e().asNumber(t.y);s.setCell(n,o,r)}async update(t,e=!0){await super.update(t,!1),this.setOptions(),this.filterAndAssignSyncOptions(n),this.chart&&this.chart.update(c(this.options.chartOptions)||{}),this.emit({type:"afterUpdate"}),e&&this.render()}updateSeries(){if(this.chart&&this.connector){this.presentationTable=this.presentationModifier?this.connector.table.modified.clone():this.connector.table;let{id:t}=this.connector.table,{chart:e}=this;this.presentationModifier&&(this.presentationTable=this.presentationModifier.modifyTable(this.presentationTable).modified);let s=this.presentationTable,n=s.getModifier()?.options,o=s.modified.getColumnNames(),r=this.options.columnAssignment||this.getDefaultColumnAssignment(o),a={};this.emit({type:"afterPresentationModifier",table:s});let l=s.modified.getColumnNames().filter(t=>(!this.activeGroup||!1!==this.activeGroup.getSharedState().getColumnVisibility(t))&&!!r[t]&&("x"!==r[t]||(a[t]=t,!1)));Object.keys(r).forEach(function(t){p(r[t])&&l.push(t)}),l.map((i,s)=>{let o=0;for(;o<e.series.length;){let i=e.series[o],n=i.options.id===`${t}-series-${s}`,r=-1!==l.indexOf(i.name);if(o++,r&&n)return i;!r&&n&&i.destroy()}let r=!(n?.type==="Math"&&n.columnFormulas?.some(t=>t.column===i)),a={name:i,id:`${t}-series-${s}`,dragDrop:{draggableY:r}},h=e.series.find(t=>t.name===i);return h?(h.update(a,!1),h):e.addSeries(a,!1)}).forEach(t=>{let e=Object.keys(a)[0],n=p(r[t.name]),o=[];if(n){let e=r[t.name];Object.keys(e).forEach(t=>{o.push(e[t])})}let l=n?[e].concat(o):[e,t.name],h=new i({columns:s.modified.getColumns(l)});n||h.renameColumn(t.name,"y"),e&&h.renameColumn(e,"x");let c=h.getRowObjects().reduce((t,e)=>(n?t.push([e.x].concat(o.map(function(t){return e[t]}))):t.push([e.x,e.y]),t),[]);t.setData(c,!1)}),this.chart.redraw()}}getChart(){return this.chart||this.createChart()}getDefaultColumnAssignment(t=[]){let e={};for(let i=0,s=t.length;i<s;++i)if(e[t[i]]="y",0===i){let s=this.presentationTable?.getColumn(t[i],!0);s&&h(s[0])&&(e[t[i]]="x")}return e}createChart(){let t=m.charter||s.win.Highcharts;this.chartConstructor||(this.chartConstructor="chart");let e=t[this.chartConstructor];if(e)try{if("chart"===this.chartConstructor)return t.Chart.chart(this.chartContainer,this.chartOptions);return new e(this.chartContainer,this.chartOptions)}catch{throw Error("The Highcharts component is misconfigured: `"+this.cell.id+"`")}if("function"!=typeof t.chart)throw Error("Chart constructor not found");return this.chart}registerChartEvents(){if(this.chart&&this.chart.options){let t=this.chart.options;["chart","series","yAxis","xAxis","colorAxis","annotations","navigation"].map(e=>{let i=t[e]||{};return!Array.isArray(i)&&i.events&&(i=[i]),i&&"object"==typeof i&&Array.isArray(i)&&i.reduce((t,i,s)=>(i&&i.events&&(t[i.id||`${e}-${s}`]=i.events),t),{})||{}}).forEach(t=>{Object.keys(t).forEach(e=>{let i=t[e];Object.keys(i).forEach(t=>{this.callbackRegistry.addCallback(`${e}-${t}`,{type:"seriesEvent",func:i[t]})})})})}}setConnector(t){let e=this.chart;if(this.connector&&e&&e.series&&this.connector.table.id!==t?.table.id){let t=this.connector.table.id;for(let i=e.series.length-1;i>=0;i--){let s=e.series[i];s.options.id?.indexOf(t)!==-1&&s.remove(!1)}}return super.setConnector(t),this}getOptionsOnDrop(t){let e=t.editMode.board.dataPool.getConnectorIds(),i={cell:"",type:"Highcharts",chartOptions:{chart:{animation:!1,type:"column",zooming:{}}}};return e.length&&(i={...i,connector:{id:e[0]}}),i}toJSON(){let t=JSON.stringify(this.options.chartOptions),e=this.options.chartConstructor;this.registerChartEvents();let i=super.toJSON(),s={...i,type:"Highcharts",options:{...i.options,chartOptions:t,chartConstructor:e,type:"Highcharts",sync:{}}};return this.emit({type:"toJSON",json:s}),s}getOptions(){return{...l(this.options,m.defaultOptions),type:"Highcharts"}}getEditableOptions(){let t=this.options,e=this.chart,i=e&&e.options,s=i&&i.chart?.type||"line";return c(t,{chartOptions:i},{chartOptions:{yAxis:d(e&&e.yAxis[0].options),xAxis:d(e&&e.xAxis[0].options),plotOptions:{series:(i&&i.plotOptions||{})[s]}}})}getEditableOptionValue(t){return t?1===t.length&&"chartOptions"===t[0]?JSON.stringify(this.options.chartOptions,null,2):super.getEditableOptionValue.call(this,t):void 0}}return m.syncHandlers=n,m.defaultOptions=c(t.defaultOptions,{allowConnectorUpdate:!0,className:[t.defaultOptions.className,`${t.defaultOptions.className}-highcharts`].join(" "),chartClassName:"chart-container",chartID:"chart-"+u(),chartOptions:{chart:{styledMode:!0},series:[]},chartConstructor:"",editableOptions:(t.defaultOptions.editableOptions||[]).concat([{name:"chartOptions",type:"nested",nestedOptions:[{name:"chart",options:[{name:"title",propertyPath:["chartOptions","title","text"],type:"input"},{name:"subtitle",propertyPath:["chartOptions","subtitle","text"],type:"input"},{name:"type",propertyPath:["chartOptions","chart","type"],type:"select",selectOptions:[{name:"column",iconURL:"series-types/icon-column.svg"},{name:"line",iconURL:"series-types/icon-line.svg"},{name:"scatter",iconURL:"series-types/icon-scatter.svg"},{name:"pie",iconURL:"series-types/icon-pie.svg"}]}]},{name:"xAxis",options:[{name:"title",propertyPath:["chartOptions","xAxis","title","text"],type:"input"},{name:"type",propertyPath:["chartOptions","xAxis","type"],type:"select",selectOptions:[{name:"linear"},{name:"datetime"},{name:"logarithmic"}]}]},{name:"yAxis",options:[{name:"title",propertyPath:["chartOptions","yAxis","title","text"],type:"input"},{name:"type",propertyPath:["chartOptions","yAxis","type"],type:"select",selectOptions:[{name:"linear"},{name:"datetime"},{name:"logarithmic"}]}]},{name:"legend",showToggle:!0,propertyPath:["chartOptions","legend","enabled"],options:[{name:"align",propertyPath:["chartOptions","legend","align"],type:"select",selectOptions:[{name:"left"},{name:"center"},{name:"right"}]}]},{name:"tooltip",showToggle:!0,propertyPath:["chartOptions","tooltip","enabled"],options:[{name:"split",propertyPath:["chartOptions","tooltip","split"],type:"toggle"}]},{name:"dataLabels",propertyPath:["chartOptions","plotOptions","series","dataLabels","enabled"],showToggle:!0,options:[{name:"align",propertyPath:["chartOptions","plotOptions","series","dataLabels","align"],type:"select",selectOptions:[{name:"left"},{name:"center"},{name:"right"}]}]},{name:"credits",showToggle:!0,propertyPath:["chartOptions","credits","enabled"],options:[{name:"name",propertyPath:["chartOptions","credits","text"],type:"input"},{name:"url",propertyPath:["chartOptions","credits","href"],type:"input"}]}]},{name:"chartConfig",propertyPath:["chartOptions"],type:"textarea"},{name:"chartClassName",propertyPath:["chartClassName"],type:"input"},{name:"chartID",propertyPath:["chartID"],type:"input"}]),syncHandlers:n,editableOptionsBindings:c(t.defaultOptions.editableOptionsBindings,{skipRedraw:["chartOptions","chartConfig"]}),columnAssignment:void 0}),m}),i(e,"Dashboards/Plugins/KPISyncHandlers.js",[e["Core/Utilities.js"]],function(t){let{defined:e}=t;return{extremes:{handler:({emitters:{},handlers:{extremesHandler:function(){let{board:t}=this,i=t=>{let i=t.cursor;if("position"===i.type&&"number"==typeof i?.row&&e(i.column)&&this.connector&&!e(this.options.value)){let t=this.connector.table.modified.getCellAsString(i.column,i.row);this.setValue(t)}},s=()=>{let{dataCursor:e}=t;if(!e)return;let s=this.connector&&this.connector.table;s&&e.addListener(s.id,"xAxis.extremes.max",i)},n=()=>{let e=this.connector&&this.connector.table,{dataCursor:s}=t;e&&s.removeListener(e.id,"xAxis.extremes.max",i)};t&&(s(),this.on("setConnector",()=>n()),this.on("afterSetConnector",()=>s()))}}}).handlers.extremesHandler}}}),i(e,"Core/Chart/ChartDefaults.js",[],function(){return{alignThresholds:!1,panning:{enabled:!1,type:"x"},styledMode:!1,borderRadius:0,colorCount:10,allowMutatingData:!0,ignoreHiddenSeries:!0,spacing:[10,10,15,10],resetZoomButton:{theme:{},position:{}},reflow:!0,type:"line",zooming:{singleTouch:!1,resetButton:{theme:{zIndex:6},position:{align:"right",x:-10,y:10}}},width:null,height:null,borderColor:"#334eff",backgroundColor:"#ffffff",plotBorderColor:"#cccccc"}}),i(e,"Core/Color/Palettes.js",[],function(){return{colors:["#2caffe","#544fc5","#00e272","#fe6a35","#6b8abc","#d568fb","#2ee0ca","#fa4b42","#feb56a","#91e8e1"]}}),i(e,"Core/Time.js",[e["Core/Globals.js"],e["Core/Utilities.js"]],function(t,e){let{win:i}=t,{defined:s,error:n,extend:o,isNumber:r,isObject:a,merge:l,objectEach:h,pad:c,pick:d,splat:u,timeUnits:p}=e,m=t.isSafari&&i.Intl&&i.Intl.DateTimeFormat.prototype.formatRange,f=t.isSafari&&i.Intl&&!i.Intl.DateTimeFormat.prototype.formatRange;return class{constructor(t){this.options={},this.useUTC=!1,this.variableTimezone=!1,this.Date=i.Date,this.getTimezoneOffset=this.timezoneOffsetFunction(),this.update(t)}get(t,e){if(this.variableTimezone||this.timezoneOffset){let i=e.getTime(),s=i-this.getTimezoneOffset(e);e.setTime(s);let n=e["getUTC"+t]();return e.setTime(i),n}return this.useUTC?e["getUTC"+t]():e["get"+t]()}set(t,e,i){if(this.variableTimezone||this.timezoneOffset){if("Milliseconds"===t||"Seconds"===t||"Minutes"===t&&this.getTimezoneOffset(e)%36e5==0)return e["setUTC"+t](i);let s=this.getTimezoneOffset(e),n=e.getTime()-s;e.setTime(n),e["setUTC"+t](i);let o=this.getTimezoneOffset(e);return n=e.getTime()+o,e.setTime(n)}return this.useUTC||m&&"FullYear"===t?e["setUTC"+t](i):e["set"+t](i)}update(t={}){let e=d(t.useUTC,!0);this.options=t=l(!0,this.options,t),this.Date=t.Date||i.Date||Date,this.useUTC=e,this.timezoneOffset=e&&t.timezoneOffset||void 0,this.getTimezoneOffset=this.timezoneOffsetFunction(),this.variableTimezone=e&&!!(t.getTimezoneOffset||t.timezone)}makeTime(t,e,i,s,n,o){let r,a,l;return this.useUTC?(r=this.Date.UTC.apply(0,arguments),a=this.getTimezoneOffset(r),r+=a,a!==(l=this.getTimezoneOffset(r))?r+=l-a:a-36e5!==this.getTimezoneOffset(r-36e5)||f||(r-=36e5)):r=new this.Date(t,e,d(i,1),d(s,0),d(n,0),d(o,0)).getTime(),r}timezoneOffsetFunction(){let t=this,e=this.options,i=e.getTimezoneOffset;return this.useUTC?e.timezone?t=>{try{let[i,s,n,o,a=0]=Intl.DateTimeFormat("en",{timeZone:e.timezone,timeZoneName:"shortOffset"}).format(t).split(/(GMT|:)/).map(Number),l=-(36e5*(n+a/60));if(r(l))return l}catch(t){n(34)}return 0}:this.useUTC&&i?t=>6e4*i(t.valueOf()):()=>6e4*(t.timezoneOffset||0):t=>6e4*new Date(t.toString()).getTimezoneOffset()}dateFormat(e,i,n){if(!s(i)||isNaN(i))return t.defaultOptions.lang&&t.defaultOptions.lang.invalidDate||"";e=d(e,"%Y-%m-%d %H:%M:%S");let r=this,a=new this.Date(i),l=this.get("Hours",a),u=this.get("Day",a),p=this.get("Date",a),m=this.get("Month",a),f=this.get("FullYear",a),g=t.defaultOptions.lang,y=g&&g.weekdays,b=g&&g.shortWeekdays;return h(o({a:b?b[u]:y[u].substr(0,3),A:y[u],d:c(p),e:c(p,2," "),w:u,b:g.shortMonths[m],B:g.months[m],m:c(m+1),o:m+1,y:f.toString().substr(2,2),Y:f,H:c(l),k:l,I:c(l%12||12),l:l%12||12,M:c(this.get("Minutes",a)),p:l<12?"AM":"PM",P:l<12?"am":"pm",S:c(this.get("Seconds",a)),L:c(Math.floor(i%1e3),3)},t.dateFormats),function(t,s){for(;-1!==e.indexOf("%"+s);)e=e.replace("%"+s,"function"==typeof t?t.call(r,i):t)}),n?e.substr(0,1).toUpperCase()+e.substr(1):e}resolveDTLFormat(t){return a(t,!0)?t:{main:(t=u(t))[0],from:t[1],to:t[2]}}getTimeTicks(t,e,i,n){let r,a,l,h;let c=this,u=c.Date,m=[],f={},g=new u(e),y=t.unitRange,b=t.count||1;if(n=d(n,1),s(e)){c.set("Milliseconds",g,y>=p.second?0:b*Math.floor(c.get("Milliseconds",g)/b)),y>=p.second&&c.set("Seconds",g,y>=p.minute?0:b*Math.floor(c.get("Seconds",g)/b)),y>=p.minute&&c.set("Minutes",g,y>=p.hour?0:b*Math.floor(c.get("Minutes",g)/b)),y>=p.hour&&c.set("Hours",g,y>=p.day?0:b*Math.floor(c.get("Hours",g)/b)),y>=p.day&&c.set("Date",g,y>=p.month?1:Math.max(1,b*Math.floor(c.get("Date",g)/b))),y>=p.month&&(c.set("Month",g,y>=p.year?0:b*Math.floor(c.get("Month",g)/b)),a=c.get("FullYear",g)),y>=p.year&&(a-=a%b,c.set("FullYear",g,a)),y===p.week&&(h=c.get("Day",g),c.set("Date",g,c.get("Date",g)-h+n+(h<n?-7:0))),a=c.get("FullYear",g);let t=c.get("Month",g),o=c.get("Date",g),d=c.get("Hours",g);e=g.getTime(),(c.variableTimezone||!c.useUTC)&&s(i)&&(l=i-e>4*p.month||c.getTimezoneOffset(e)!==c.getTimezoneOffset(i));let u=g.getTime();for(r=1;u<i;)m.push(u),y===p.year?u=c.makeTime(a+r*b,0):y===p.month?u=c.makeTime(a,t+r*b):l&&(y===p.day||y===p.week)?u=c.makeTime(a,t,o+r*b*(y===p.day?1:7)):l&&y===p.hour&&b>1?u=c.makeTime(a,t,o,d+r*b):u+=y*b,r++;m.push(u),y<=p.hour&&m.length<1e4&&m.forEach(function(t){t%18e5==0&&"000000000"===c.dateFormat("%H%M%S%L",t)&&(f[t]="day")})}return m.info=o(t,{higherRanks:f,totalRange:y*b}),m}getDateFormat(t,e,i,s){let n=this.dateFormat("%m-%d %H:%M:%S.%L",e),o="01-01 00:00:00.000",r={millisecond:15,second:12,minute:9,hour:6,day:3},a="millisecond",l=a;for(a in p){if(t===p.week&&+this.dateFormat("%w",e)===i&&n.substr(6)===o.substr(6)){a="week";break}if(p[a]>t){a=l;break}if(r[a]&&n.substr(r[a])!==o.substr(r[a]))break;"week"!==a&&(l=a)}return this.resolveDTLFormat(s[a]).main}}}),i(e,"Core/Defaults.js",[e["Core/Chart/ChartDefaults.js"],e["Core/Globals.js"],e["Core/Color/Palettes.js"],e["Core/Time.js"],e["Core/Utilities.js"]],function(t,e,i,s,n){let{isTouchDevice:o,svg:r}=e,{merge:a}=n,l={colors:i.colors,symbols:["circle","diamond","square","triangle","triangle-down"],lang:{loading:"Loading...",months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],decimalPoint:".",numericSymbols:["k","M","G","T","P","E"],resetZoom:"Reset zoom",resetZoomTitle:"Reset zoom level 1:1",thousandsSep:" "},global:{},time:{Date:void 0,getTimezoneOffset:void 0,timezone:void 0,timezoneOffset:0,useUTC:!0},chart:t,title:{style:{color:"#333333",fontWeight:"bold"},text:"Chart title",align:"center",margin:15,widthAdjust:-44},subtitle:{style:{color:"#666666",fontSize:"0.8em"},text:"",align:"center",widthAdjust:-44},caption:{margin:15,style:{color:"#666666",fontSize:"0.8em"},text:"",align:"left",verticalAlign:"bottom"},plotOptions:{},legend:{enabled:!0,align:"center",alignColumns:!0,className:"highcharts-no-tooltip",layout:"horizontal",itemMarginBottom:2,itemMarginTop:2,labelFormatter:function(){return this.name},borderColor:"#999999",borderRadius:0,navigation:{style:{fontSize:"0.8em"},activeColor:"#0022ff",inactiveColor:"#cccccc"},itemStyle:{color:"#333333",cursor:"pointer",fontSize:"0.8em",textDecoration:"none",textOverflow:"ellipsis"},itemHoverStyle:{color:"#000000"},itemHiddenStyle:{color:"#666666",textDecoration:"line-through"},shadow:!1,itemCheckboxStyle:{position:"absolute",width:"13px",height:"13px"},squareSymbol:!0,symbolPadding:5,verticalAlign:"bottom",x:0,y:0,title:{style:{fontSize:"0.8em",fontWeight:"bold"}}},loading:{labelStyle:{fontWeight:"bold",position:"relative",top:"45%"},style:{position:"absolute",backgroundColor:"#ffffff",opacity:.5,textAlign:"center"}},tooltip:{enabled:!0,animation:r,borderRadius:3,dateTimeLabelFormats:{millisecond:"%A, %e %b, %H:%M:%S.%L",second:"%A, %e %b, %H:%M:%S",minute:"%A, %e %b, %H:%M",hour:"%A, %e %b, %H:%M",day:"%A, %e %b %Y",week:"Week from %A, %e %b %Y",month:"%B %Y",year:"%Y"},footerFormat:"",headerShape:"callout",hideDelay:500,padding:8,shape:"callout",shared:!1,snap:o?25:10,headerFormat:'<span style="font-size: 0.8em">{point.key}</span><br/>',pointFormat:'<span style="color:{point.color}">●</span> {series.name}: <b>{point.y}</b><br/>',backgroundColor:"#ffffff",borderWidth:void 0,shadow:!0,stickOnContact:!1,style:{color:"#333333",cursor:"default",fontSize:"0.8em"},useHTML:!1},credits:{enabled:!0,href:"https://www.highcharts.com?credits",position:{align:"right",x:-10,verticalAlign:"bottom",y:-5},style:{cursor:"pointer",color:"#999999",fontSize:"0.6em"},text:"Highcharts.com"}};l.chart.styledMode=!1;let h=new s(l.time);return{defaultOptions:l,defaultTime:h,getOptions:function(){return l},setOptions:function(t){return a(!0,l,t),(t.time||t.global)&&(e.time?e.time.update(a(l.global,l.time,t.global,t.time)):e.time=h),l}}}),i(e,"Core/Templating.js",[e["Core/Defaults.js"],e["Core/Utilities.js"]],function(t,e){let{defaultOptions:i,defaultTime:s}=t,{extend:n,getNestedProperty:o,isArray:r,isNumber:a,isObject:l,pick:h,pInt:c}=e,d={add:(t,e)=>t+e,divide:(t,e)=>0!==e?t/e:"",eq:(t,e)=>t==e,each:function(t){let e=arguments[arguments.length-1];return!!r(t)&&t.map((i,s)=>u(e.body,n(l(i)?i:{"@this":i},{"@index":s,"@first":0===s,"@last":s===t.length-1}))).join("")},ge:(t,e)=>t>=e,gt:(t,e)=>t>e,if:t=>!!t,le:(t,e)=>t<=e,lt:(t,e)=>t<e,multiply:(t,e)=>t*e,ne:(t,e)=>t!=e,subtract:(t,e)=>t-e,unless:t=>!t};function u(t="",e,n){let r=/\{([a-zA-Z0-9\:\.\,;\-\/<>%_@"'= #\(\)]+)\}/g,a=/\(([a-zA-Z0-9\:\.\,;\-\/<>%_@"'= ]+)\)/g,l=[],c=/f$/,m=/\.([0-9])/,f=i.lang,g=n&&n.time||s,y=n&&n.numberFormatter||p,b=(t="")=>{let i;return"true"===t||"false"!==t&&((i=Number(t)).toString()===t?i:o(t,e))},C,O,x=0,v;for(;null!==(C=r.exec(t));){let i=a.exec(C[1]);i&&(C=i,v=!0),O&&O.isBlock||(O={ctx:e,expression:C[1],find:C[0],isBlock:"#"===C[1].charAt(0),start:C.index,startInner:C.index+C[0].length,length:C[0].length});let s=C[1].split(" ")[0].replace("#","");d[s]&&(O.isBlock&&s===O.fn&&x++,O.fn||(O.fn=s));let n="else"===C[1];if(O.isBlock&&O.fn&&(C[1]===`/${O.fn}`||n)){if(x)!n&&x--;else{let e=O.startInner,i=t.substr(e,C.index-e);void 0===O.body?(O.body=i,O.startInner=C.index+C[0].length):O.elseBody=i,O.find+=i+C[0],n||(l.push(O),O=void 0)}}else O.isBlock||l.push(O);if(i&&!O?.isBlock)break}return l.forEach(i=>{let s,n;let{body:o,elseBody:r,expression:a,fn:l}=i;if(l){let t=[i],h=a.split(" ");for(n=d[l].length;n--;)t.unshift(b(h[n+1]));s=d[l].apply(e,t),i.isBlock&&"boolean"==typeof s&&(s=u(s?o:r,e))}else{let t=a.split(":");if(s=b(t.shift()||""),t.length&&"number"==typeof s){let e=t.join(":");if(c.test(e)){let t=parseInt((e.match(m)||["","-1"])[1],10);null!==s&&(s=y(s,t,f.decimalPoint,e.indexOf(",")>-1?f.thousandsSep:""))}else s=g.dateFormat(e,s)}}t=t.replace(i.find,h(s,""))}),v?u(t,e,n):t}function p(t,e,s,n){let o,r;t=+t||0,e=+e;let l=i.lang,d=(t.toString().split(".")[1]||"").split("e")[0].length,u=t.toString().split("e"),p=e;-1===e?e=Math.min(d,20):a(e)?e&&u[1]&&u[1]<0&&((r=e+ +u[1])>=0?(u[0]=(+u[0]).toExponential(r).split("e")[0],e=r):(u[0]=u[0].split(".")[0]||0,t=e<20?(u[0]*Math.pow(10,u[1])).toFixed(e):0,u[1]=0)):e=2;let m=(Math.abs(u[1]?u[0]:t)+Math.pow(10,-Math.max(e,d)-1)).toFixed(e),f=String(c(m)),g=f.length>3?f.length%3:0;return s=h(s,l.decimalPoint),n=h(n,l.thousandsSep),o=(t<0?"-":"")+(g?f.substr(0,g)+n:""),0>+u[1]&&!p?o="0":o+=f.substr(g).replace(/(\d{3})(?=\d)/g,"$1"+n),e&&(o+=s+m.slice(-e)),u[1]&&0!=+o&&(o+="e"+u[1]),o}return{dateFormat:function(t,e,i){return s.dateFormat(t,e,i)},format:u,helpers:d,numberFormat:p}}),i(e,"Dashboards/Plugins/KPIComponent.js",[e["Core/Renderer/HTML/AST.js"],e["Dashboards/Components/Component.js"],e["Dashboards/Plugins/KPISyncHandlers.js"],e["Core/Templating.js"],e["Core/Utilities.js"]],function(t,e,i,s,n){let{format:o}=s,{createElement:r,css:a,defined:l,diffObjects:h,isArray:c,isNumber:d,merge:u}=n;class p extends e{static fromJSON(t,e){let i=t.options,s=i.chartOptions&&JSON.parse(i.chartOptions),n=JSON.parse(i.subtitle||"{}"),o=i.title&&JSON.parse(i.title);return new p(e,u(i,{chartOptions:s,title:o,subtitle:n}))}constructor(t,e){super(t,e=u(p.defaultOptions,e)),this.options=e,this.type="KPI",this.sync=new p.Sync(this,this.syncHandlers),this.value=r("span",{className:`${e.className}-value`},{},this.contentElement),this.subtitle=r("span",{className:this.getSubtitleClassName()},{},this.contentElement)}async load(){return await super.load(),this.linkValueToChart(),this}resize(t,e){return super.resize(t,e),this.chart&&this.chart.reflow(),this}render(){super.render(),this.updateElements();let t=p.charter?.Chart;return t&&this.options.chartOptions&&!this.chart?(this.chartContainer||(this.chartContainer=r("div",{className:`${this.options.className}-chart-container`},{height:"100%"},this.contentElement),this.cell.container.style.height||(this.contentElement.style.height="100%",super.resize(null,null))),this.chart=t.chart(this.chartContainer,u(p.defaultChartOptions,this.options.chartOptions))):this.chart&&!this.options.chartOptions&&"chartOptions"in this.options&&(this.chart.destroy(),this.chart=void 0),this.sync.start(),this.emit({type:"afterRender"}),this}setOptions(){this.filterAndAssignSyncOptions(i)}async update(t,e=!0){await super.update(t),this.setOptions(),t.chartOptions&&this.chart&&this.chart.update(t.chartOptions),e&&this.render()}onTableChanged(){this.setValue()}getValue(){if(l(this.options.value))return this.options.value;if(this.connector&&this.options.columnName){let t=this.connector?.table.modified,e=t.getColumn(this.options.columnName),i=e?.length||0;return t.getCellAsString(this.options.columnName,i-1)}}setValue(e=this.getValue()){let{valueFormat:i,valueFormatter:s}=this.options;if(l(e)){let n;d(+e)&&(n=+e),s?e=s.call(this,e):i?e=o(i,{value:e}):d(e)&&(e=e.toLocaleString()),t.setElementHTML(this.value,""+e),this.linkValueToChart(n),this.prevValue=n}}linkValueToChart(t=this.getValue()){let e=this.chart,i=this.options.linkedValueTo;if(!e||!i.enabled||!l(t)||!d(+t))return;t=+t;let s=e.series[i.seriesIndex??0],n=s?.points[i.pointIndex??0];if(s){if(n){n.update({y:t});return}s.addPoint({y:t});return}e.addSeries({data:[{y:t}]})}updateElements(){let{style:e,subtitle:i}=this.options;this.setValue(),t.setElementHTML(this.subtitle,this.getSubtitle()),e&&a(this.element,e),"object"==typeof i&&(i.style&&a(this.subtitle,i.style),this.subtitle.className=this.getSubtitleClassName()),this.chartContainer&&(this.chartContainer.style.flex=this.options.chartOptions?"1":"0"),this.chart&&this.chart.reflow(),this.value.style.color=this.getValueColor()}getSubtitle(){let{subtitle:t,value:e}=this.options;if("string"==typeof t)return t;if(t){if(d(this.prevValue)&&d(e)){let i=e-this.prevValue,s="";if(i>0)s='<span style="color:green">&#9650;</span> +';else{if(!(i<0))return this.subtitle.innerHTML;s='<span style="color:red">&#9660;</span> '}if("diff"===t.type)return s+i.toLocaleString();if("diffpercent"===t.type)return s+o("{v:,.2f}%",{v:i/this.prevValue*100})}return t.text||""}return""}getSubtitleClassName(){let{subtitle:t}=this.options;return`${e.defaultOptions.className}-subtitle`+("object"==typeof t&&t.className||"")}getValueColor(){let{threshold:t,thresholdColors:e,value:i}=this.options;if(e&&t&&d(i)){if(c(t)){for(let s=t.length-1;s>=0;s--)if(i>=t[s]){if(s+1<e.length)return e[s+1];return e[e.length-1]}}else if(i>=t)return e[1];return e[0]}return""}getOptionsOnDrop(t){let e=t.editMode.board.dataPool.getConnectorIds(),i={cell:"",type:"KPI"};return e.length&&(i={...i,connector:{id:e[0]}}),i}toJSON(){let t=super.toJSON(),e={...t,type:"KPI",options:{...t.options,type:"KPI",value:this.options.value,subtitle:JSON.stringify(this.options.subtitle),title:JSON.stringify(this.options.title),threshold:this.options.threshold,thresholdColors:this.options.thresholdColors,chartOptions:JSON.stringify(this.options.chartOptions),valueFormat:this.options.valueFormat}};return this.emit({type:"toJSON",json:t}),e}getOptions(){return{...h(this.options,p.defaultOptions),type:"KPI"}}}return p.syncHandlers=i,p.defaultOptions=u(e.defaultOptions,{type:"KPI",className:[e.defaultOptions.className,`${e.defaultOptions.className}-kpi`].join(" "),minFontSize:20,syncHandlers:i,thresholdColors:["#f45b5b","#90ed7d"],editableOptions:(e.defaultOptions.editableOptions||[]).concat([{name:"Value",type:"input",propertyPath:["value"]},{name:"Column name",type:"input",propertyPath:["columnName"]},{name:"Value format",type:"input",propertyPath:["valueFormat"]}]),linkedValueTo:{enabled:!0,seriesIndex:0,pointIndex:0}}),p.defaultChartOptions={chart:{type:"spline",styledMode:!0,zooming:{mouseWheel:{enabled:!1}}},title:{text:void 0},xAxis:{visible:!1},yAxis:{visible:!1,title:{text:null}},legend:{enabled:!1},credits:{enabled:!1},tooltip:{outside:!0},plotOptions:{series:{marker:{enabled:!1}}}},p}),i(e,"Dashboards/Plugins/NavigatorComponentDefaults.js",[e["Dashboards/Components/Component.js"]],function(t){return{type:"Navigator",chartOptions:{chart:{animation:!1,height:200,styledMode:!0,type:"column",zooming:{mouseWheel:{enabled:!1}}},credits:{enabled:!1},legend:{enabled:!1},navigator:{enabled:!0,outlineWidth:0,series:{animation:!1,lineWidth:0},xAxis:{endOnTick:!0,gridZIndex:4,labels:{x:1,y:22},opposite:!0,showFirstLabel:!0,showLastLabel:!0,startOnTick:!0,tickPosition:"inside"},yAxis:{maxPadding:.5}},plotOptions:{series:{borderRadius:0,marker:{enabled:!1},states:{hover:{enabled:!1}}}},scrollbar:{enabled:!0},title:{text:""},tooltip:{enabled:!1},xAxis:{visible:!1,minRange:Number.MIN_VALUE},yAxis:{visible:!1}},editableOptions:(t.defaultOptions.editableOptions||[]).concat()}}),i(e,"Dashboards/Plugins/NavigatorComponent.js",[e["Dashboards/Components/Component.js"],e["Data/Modifiers/DataModifier.js"],e["Dashboards/Globals.js"],e["Dashboards/Plugins/NavigatorComponentDefaults.js"],e["Core/Utilities.js"]],function(t,e,i,s,n){let{Range:o}=e.types,{addEvent:r,diffObjects:a,isNumber:l,isObject:h,isString:c,merge:d,pick:u}=n,p={crossfilter:{emitter:function(){let t;let e=this,i=async t=>{if(e.connector){let i=e.connector.table,s=e.board.dataCursor,n=e.getColumnAssignment()[0],[r,a]=e.getAxisExtremes(),l=i.getModifier();l instanceof o?function(t,e,i,s){let n=!1;for(let o=0,r=t.length;o<r;++o)if(t[o].column===e){t[o].maxValue=s,t[o].minValue=i,n=!0;break}n||t.push({column:e,maxValue:s,minValue:i})}(l.options.ranges,n,r,a):l=new o({ranges:[{column:n,maxValue:a,minValue:r}]}),await i.setModifier(l),s.emitCursor(i,{type:"range",columns:[n],firstRow:0,lastRow:i.getRowCount()-1,state:"crossfilter"},t)}};return r(e.chart.xAxis[0],"afterSetExtremes",function(e){clearTimeout(t),t=setTimeout(i,50,this,e)})}},extremes:{emitter:function(){let t;let e=this,i=t=>{if(e.connector){let i=e.connector.table,s=e.board.dataCursor,n=e.getColumnAssignment()[0],[o,r]=e.getAxisExtremes();s.emitCursor(i,{type:"position",column:n,row:i.getRowIndexBy(n,o),state:"xAxis.extremes.min"},t),s.emitCursor(i,{type:"position",column:n,row:i.getRowIndexBy(n,r),state:"xAxis.extremes.max"},t)}};return r(e.chart.xAxis[0],"afterSetExtremes",function(e){clearTimeout(t),t=setTimeout(i,50,this,e)})},handler:function(){let t=this,e=t.board.dataCursor,i=e=>{let i=e.cursor;if(!t.connector)return;let s=t.connector.table,n=s.getColumnNames()[0],r=s.getRowCount(),a=0;"range"===i.type?(r=i.lastRow,a=i.firstRow,i.columns&&(n=u(i.columns[0],n))):"xAxis.extremes.max"===i.state?(n=u(i.column,n),r=u(i.row,r)):(n=u(i.column,n),a=u(i.row,a));let l=s.getModifier();if("string"==typeof n&&l instanceof o){let t=l.options.ranges,e=s.getCell(n,a),i=s.getCell(n,r);null!=i&&null!=e&&(function(t,e){for(let i=0,s=t.length;i<s;++i)if(t[i].column===e)return t.splice(i,1)[0]}(t,n),t.unshift({column:n,maxValue:i,minValue:e}),s.setModifier(l))}},s=()=>{let s=t.connector&&t.connector.table;s&&(e.addListener(s.id,"xAxis.extremes",i),e.addListener(s.id,"xAxis.extremes.max",i),e.addListener(s.id,"xAxis.extremes.min",i))},n=()=>{let s=t.connector&&t.connector.table;s&&(e.removeListener(s.id,"xAxis.extremes",i),e.removeListener(s.id,"xAxis.extremes.max",i),e.removeListener(s.id,"xAxis.extremes.min",i))};s(),t.on("setConnector",()=>n()),t.on("afterSetConnector",()=>s())}}};class m extends t{static fromJSON(t,e){let i=new m(e,t.options);return i.emit({type:"fromJSON",json:t}),i}constructor(t,e){super(t,e),this.options=d(m.defaultOptions,e);let s=m.charter.Chart||i.win.Highcharts;this.chartContainer=i.win.document.createElement("div"),this.chart=s.chart(this.chartContainer,this.options.chartOptions||{}),this.chartContainer.classList.add(i.classNamePrefix+"navigator"),this.filterAndAssignSyncOptions(p),this.sync=new m.Sync(this,this.syncHandlers);let n=this.options.sync?.crossfilter;(!0===n||h(n)&&n.enabled)&&this.chart.update(d({navigator:{xAxis:{labels:{format:"{value}"}}}},this.options.chartOptions||{}),!1)}adjustNavigator(){let t=this.chart,e=u(t.chartHeight,this.contentElement.clientHeight),i=this.contentElement.clientWidth,s={};if((t.chartHeight!==e||t.chartWidth!==i)&&(s.chart={height:e,width:i}),t.navigator){let i=t.navigator,n=i.top-t.plotTop+i.height;i.height!==n&&(s.navigator={handles:{height:Math.round(e/4)},height:n}),Object.keys(s).length&&t.update(s,!1),i.series&&i.series[0]&&i.series[0].update({type:t.series[0].type},!1)}else Object.keys(s).length&&t.update(s,!1)}getColumnAssignment(){let t;let e=this.options.columnAssignments||{};for(let i of Object.keys(e))if(null!==(t=e[i]))return[i,t];if(this.connector){let t=this.connector.table.getColumnNames();if(t.length)return[t[0],"y"]}return["","y"]}getOptions(){return{...a(this.options,s),type:"Navigator"}}getAxisExtremes(){let t=this.chart.xAxis[0],e=t.getExtremes(),i=l(e.min)?e.min:e.dataMin,s=l(e.max)?e.max:e.dataMax;return this.categories?[this.categories[Math.max(0,Math.ceil(i))],this.categories[Math.min(this.categories.length-1,Math.floor(s))]]:t.hasNames?[t.names[Math.ceil(i)],t.names[Math.floor(s)]]:[i,s]}async load(){return await super.load(),this.contentElement.appendChild(this.chartContainer),this.parentElement.appendChild(this.element),this.adjustNavigator(),this.emit({type:"afterLoad"}),this}onTableChanged(){this.renderNavigator()}redrawNavigator(){let t=this.resizeTimeouts;for(let e=0,i=t.length;e<i;++e)clearTimeout(t[e]);t.length=0,t.push(setTimeout(()=>{this.adjustNavigator(),this.chart.redraw()},33))}render(){return super.render(),this.renderNavigator(),this.sync.start(),this.emit({type:"afterRender"}),this}renderNavigator(){let t=this.chart;if(this.connector){let e;let i=this.connector.table,s=this.options,n=this.getColumnAssignment(),o=i.getColumn(n[0],!0)||[],r=s.sync?.crossfilter;e=!0===r||h(r)&&r.enabled?this.generateCrossfilterData():o.slice(),t.series[0]?t.series[0].setData(e,!1):t.addSeries({id:i.id,data:e},!1)}this.redrawNavigator()}generateCrossfilterData(){let t,e=this.options.sync?.crossfilter,i=this.connector?.table,s=i?.getColumn(this.getColumnAssignment()[0],!0)||[];if(!0===e&&(e={affectNavigator:!1}),!i||s.length<1||!h(e))return[];let n=[],o=[];for(let t=0,e=s.length;t<e;t++){let e=s[t];if(null!==e){if(l(e)||(e=`${e}`),void 0===this.stringData)this.stringData=c(e);else if(this.stringData!==c(e))throw Error("Mixed data types in crossfilter navigator are not supported.");n.push(e),-1===o.indexOf(e)&&o.push(e)}}o.sort((t,e)=>u(t,NaN)<u(e,NaN)?-1:t===e?0:1);let r=i.getModifier()?.options;if(e.affectNavigator&&r){let e=[],s=[],{ranges:o}=r;for(let t=0,n=o.length;t<n;t++)o[t].column!==this.getColumnAssignment()[0]&&(e.push(o[t]),s.push(i.getColumn(o[t].column,!0)||[]));t=[];let a=e.length;for(let i=0,o=n.length;i<o;i++){let o=n[i],r=!0;for(let t=0;t<a;t++){let n=e[t];if(!(s[t][i]>=(n.minValue??-1/0)&&s[t][i]<=(n.maxValue??1/0))){r=!1;break}}r&&t.push(o)}}else t=n;let a=[];if(this.stringData){this.categories=o;for(let t=0,e=o.length;t<e;t++)a.push([t,null])}else for(let t=0,e=o.length;t<e;t++)a.push([o[t],null]);for(let e=0,i=t.length;e<i;e++){let i=o.indexOf(t[e]);a[i][1]=(a[i][1]||0)+1}return a}resize(t,e){return super.resize(t,e),this.redrawNavigator(),this}async update(t,e=!0){let i=this.chart,s=this.options.sync?.crossfilter;await super.update(t,!1),t.sync&&this.filterAndAssignSyncOptions(p),t.chartOptions&&i.update(d(!0===s||h(s)&&s.enabled?{navigator:{xAxis:{labels:{format:"{value}"}}}}:{},t.chartOptions),!1),this.emit({type:"afterUpdate"}),e&&this.render()}getOptionsOnDrop(t){return{}}}return m.defaultOptions=d(t.defaultOptions,s),m}),i(e,"Dashboards/Plugins/HighchartsPlugin.js",[e["Dashboards/Plugins/HighchartsComponent.js"],e["Dashboards/Plugins/HighchartsSyncHandlers.js"],e["Dashboards/Plugins/KPIComponent.js"],e["Dashboards/Plugins/NavigatorComponent.js"]],function(t,e,i,s){return{custom:{connectHighcharts:function(e){t.charter=e,i.charter=e,s.charter=e}},name:"Highcharts.DashboardsPlugin",onRegister:function(n){let{Sync:o,ComponentRegistry:r}=n;r.registerComponent("Highcharts",t),r.registerComponent("KPI",i),r.registerComponent("Navigator",s),o.defaultHandlers={...o.defaultHandlers,...e}},onUnregister:function(t){let{Sync:i}=t;Object.keys(e).forEach(t=>{i.defaultHandlers[t]===e[t]&&delete i.defaultHandlers[t]})}}}),i(e,"masters/modules/dashboards-plugin.src.js",[e["Dashboards/Plugins/DataGridPlugin.js"],e["Dashboards/Globals.js"],e["Dashboards/Plugins/HighchartsPlugin.js"]],function(t,e,i){return e.DataGridPlugin=t,e.HighchartsPlugin=i,e.win.Highcharts&&(i.custom.connectHighcharts(e.win.Highcharts),e.PluginHandler.addPlugin(i)),e.win.DataGrid&&(t.custom.connectDataGrid(e.win.DataGrid.DataGrid),e.PluginHandler.addPlugin(t)),e})});