@odoo/o-spreadsheet 18.4.1 → 18.5.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
z-index: ${Fe.FigureTooltip};
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
|
-
`,Sh.add("chartShowValuesPlugin",{register:e=>e.register(uC),unregister:e=>e.unregister(uC)}),Sh.add("waterfallLinesPlugin",{register:e=>e.register(HC),unregister:e=>e.unregister(HC)}),Sh.add("funnelController",{register:e=>e.register(wh()),unregister:e=>e.unregister(wh())}),Sh.add("funnelElement",{register:e=>e.register(Ih()),unregister:e=>e.unregister(Ih())}),Sh.add("funnelTooltipPositioner",{register:e=>e.Tooltip.positioners.funnelTooltipPositioner=Eh,unregister:e=>e.Tooltip.positioners.funnelTooltipPositioner=void 0}),Sh.add("sunburstLabelsPlugin",{register:e=>e.register(LC),unregister:e=>e.unregister(LC)}),Sh.add("sunburstHoverPlugin",{register:e=>e.register(kC),unregister:e=>e.unregister(kC)});class zC extends t.Component{static template="o-spreadsheet-ChartJsComponent";static props={figureUI:Object,isFullScreen:{type:Boolean,optional:!0}};canvas=t.useRef("graphContainer");chart;currentRuntime;animationStore;currentDevicePixelRatio=window.devicePixelRatio;get background(){return this.chartRuntime.background}get canvasStyle(){return`background-color: ${this.background}`}get chartRuntime(){const e=this.env.model.getters.getChartRuntime(this.props.figureUI.id);if(!("chartJsConfig"in e))throw new Error("Unsupported chart runtime");return e}setup(){this.env.model.getters.isDashboard()&&(this.animationStore=oh(yh)),t.onMounted((()=>{const e=this.chartRuntime;this.currentRuntime=e,this.createChart(ze(e.chartJsConfig))})),t.onWillUnmount((()=>this.chart?.destroy())),t.useEffect((()=>{const e=this.chartRuntime;e!==this.currentRuntime?(e.chartJsConfig.type!==this.currentRuntime.chartJsConfig.type?(this.chart?.destroy(),this.createChart(ze(e.chartJsConfig))):this.updateChartJs(ze(e.chartJsConfig)),this.currentRuntime=e):this.currentDevicePixelRatio!==window.devicePixelRatio&&(this.currentDevicePixelRatio=window.devicePixelRatio,this.updateChartJs(ze(this.currentRuntime.chartJsConfig)))}))}createChart(e){if(this.env.model.getters.isDashboard()&&this.animationStore){const t=this.env.model.getters.getChart(this.props.figureUI.id)?.type;t&&this.animationStore.animationPlayed[this.animationFigureId]!==t&&(e=this.enableAnimationInChartData(e),this.animationStore.disableAnimationForChart(this.animationFigureId,t))}const t=this.canvas.el.getContext("2d");this.chart=new window.Chart(t,e)}updateChartJs(e){if(this.env.model.getters.isDashboard()){const t=this.env.model.getters.getChart(this.props.figureUI.id)?.type;t&&this.hasChartDataChanged()&&this.animationStore&&(e=this.enableAnimationInChartData(e),this.animationStore.disableAnimationForChart(this.animationFigureId,t))}e.data&&e.data.datasets?(this.chart.data=e.data,e.options?.plugins?.title&&(this.chart.config.options.plugins.title=e.options.plugins.title)):this.chart.data.datasets=[],this.chart.config.options=e.options,this.chart.update()}hasChartDataChanged(){return!mt(this.currentRuntime.chartJsConfig.data,this.chartRuntime.chartJsConfig.data)}enableAnimationInChartData(e){return{...e,options:{...e.options,animation:{animateRotate:!0}}}}get animationFigureId(){return this.props.isFullScreen?this.props.figureUI.id+"-fullscreen":this.props.figureUI.id}}class $C{sheetId;title;getters;constructor(e,t,o){this.title=e.title,this.sheetId=t,this.getters=o}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t,o){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function GC(e,t,o,s,i){if("text"===t||"progress"===t||e?.type!==Ts.number||o?.type!==Ts.number)return;const n=o.value-e.value;return n>0?s:n<0?i:void 0}function WC(e,t,o){if("text"===o||e?.type!==Ts.number||t?.type!==Ts.number)return"neutral";const s=t.value-e.value;return s>0?"up":s<0?"down":"neutral"}function qC(e){return e.keyValue&&!Xr.test(e.keyValue)?"InvalidScorecardKeyValue":"Success"}function ZC(e){return e.baseline&&!Xr.test(e.baseline)?"InvalidScorecardBaseline":"Success"}const jC=new window.Path2D("M8.6 4.8a.5.5 0 0 1 0 .75l-3.9 3.9a.5 .5 0 0 1 -.75 0l-3.8 -3.9a.5 .5 0 0 1 0 -.75l.4-.4a.5.5 0 0 1 .75 0l2.3 2.4v-5.7c0-.25.25-.5.5-.5h.6c.25 0 .5.25.5.5v5.8l2.3 -2.4a.5.5 0 0 1 .75 0z"),YC=new window.Path2D("M8.7 5.5a.5.5 0 0 0 0-.75l-3.8-4a.5.5 0 0 0-.75 0l-3.8 4a.5.5 0 0 0 0 .75l.4.4a.5.5 0 0 0 .75 0l2.3-2.4v5.8c0 .25.25.5.5.5h.6c.25 0 .5-.25.5-.5v-5.8l2.2 2.4a.5.5 0 0 0 .75 0z");let XC=class e extends $C{keyValue;keyDescr;baseline;baselineMode;baselineDescr;progressBar=!1;background;baselineColorUp;baselineColorDown;fontColor;humanize;type="scorecard";constructor(e,t,o){super(e,t,o),this.keyValue=fa(o,t,e.keyValue),this.keyDescr=e.keyDescr,this.baseline=fa(o,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp??xe,this.baselineColorDown=e.baselineColorDown??Ee,this.humanize=e.humanize??!1}static validateChartDefinition(e,t){return e.checkValidations(t,qC,ZC)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0].dataRange:void 0,title:e.title||{text:""},baselineMode:Ie,baselineColorUp:xe,baselineColorDown:Ee,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t,o){let s,i;if(t.baseline){const i=US(e,t.baseline,o);i!==Js.InvalidReference&&(s=i)}if(t.keyValue){const s=US(e,t.keyValue,o);s!==Js.InvalidReference&&(i=s)}return{...t,baseline:s,keyValue:i}}duplicateInDuplicatedSheet(t){const o=ZS(this.sheetId,t,this.baseline),s=ZS(this.sheetId,t,this.keyValue),i=this.getDefinitionWithSpecificRanges(o,s,t);return new e(i,t,this.getters)}copyInSheetId(t){const o=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,t);return new e(o,t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{...this,range:this.keyValue?[{dataRange:this.getters.getRangeString(this.keyValue,this.sheetId)}]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,o){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,o||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,o||this.sheetId):void 0,keyDescr:this.keyDescr,humanize:this.humanize}}getDefinitionForExcel(){}updateRanges(t){const o=jS(this.baseline,t),s=jS(this.keyValue,t);if(this.baseline===o&&this.keyValue===s)return this;const i=this.getDefinitionWithSpecificRanges(o,s);return new e(i,this.sheetId,this.getters)}};function KC(e,t){const o=t.getContext("2d"),s=window.devicePixelRatio||1;t.width=s*e.canvas.width,t.height=s*e.canvas.height,o.scale(s,s);const i=e.canvas.width-j;if(o.fillStyle=e.canvas.backgroundColor,o.fillRect(0,0,e.canvas.width,e.canvas.height),e.title){o.font=e.title.style.font,o.fillStyle=e.title.style.color;const t=o.textBaseline;o.textBaseline="middle",o.fillText(za(o,e.title.text,i-e.title.position.x),e.title.position.x,e.title.position.y),o.textBaseline=t}if(e.baseline&&(o.font=e.baseline.style.font,o.fillStyle=e.baseline.style.color,$a(o,e.baseline.text,e.baseline.position,e.baseline.style.underline,e.baseline.style.strikethrough)),e.baselineArrow&&e.baselineArrow.style.size>0){o.save(),o.fillStyle=e.baselineArrow.style.color,o.translate(e.baselineArrow.position.x,e.baselineArrow.position.y);const t=e.baselineArrow.style.size/10;switch(o.scale(t,t),e.baselineArrow.direction){case"down":o.fill(jC);break;case"up":o.fill(YC)}o.restore()}if(e.baselineDescr){const t=e.baselineDescr;o.font=t.style.font,o.fillStyle=t.style.color,o.fillText(za(o,t.text,i-t.position.x),t.position.x,t.position.y)}if(e.key&&(o.font=e.key.style.font,o.fillStyle=e.key.style.color,$a(o,za(o,e.key.text,i-e.key.position.x),e.key.position,e.key.style.underline,e.key.style.strikethrough)),e.keyDescr){const t=e.keyDescr;o.font=e.keyDescr?.style.font??t.style.font,o.fillStyle=t.style.color,o.fillText(za(o,t.text,i-t.position.x),t.position.x,t.position.y)}if(e.progressBar){if(o.fillStyle=e.progressBar.style.backgroundColor,o.beginPath(),o.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width,e.progressBar.dimension.height,e.progressBar.dimension.height/2),o.fill(),o.fillStyle=e.progressBar.style.color,o.beginPath(),e.progressBar.value>0)o.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width*Math.max(0,Math.min(1,e.progressBar.value)),e.progressBar.dimension.height,e.progressBar.dimension.height/2);else{const t=e.progressBar.dimension.width*Math.max(0,Math.min(1,-e.progressBar.value));o.roundRect(e.progressBar.position.x+e.progressBar.dimension.width-t,e.progressBar.position.y,t,e.progressBar.dimension.height,e.progressBar.dimension.height/2)}o.fill()}}function JC(e,t){let o,s="";const i=t.getLocale();if(e.keyValue){const n={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};o=t.getEvaluatedCell(n),s=function(e,t,o){return e?t?Vn(e,o):e.formattedValue??String(e.value??""):""}(o,e.humanize??!1,i)}let n;const r=e.baseline;if(r){const e={sheetId:r.sheetId,col:r.zone.left,row:r.zone.top};n=t.getEvaluatedCell(e)}const{background:a,fontColor:l}=t.getStyleOfSingleCellChart(e.background,e.keyValue),c=function(e,t,o,s,i){if(!e)return"";if("text"===o||t?.type!==Ts.number||e.type!==Ts.number)return s?Vn(e,i):e.formattedValue;let{value:n,format:r}=e;return"progress"===o?(n=t.value/n,r="0.0%"):(n=Math.abs(t.value-n),"percentage"===o&&0!==n&&(n/=e.value),"percentage"===o&&(r="0.0%"),r||(n=Math.round(100*n)/100)),s?Vn({value:n,format:r},i):bn(n,{format:r,locale:i})}(n,o,e.baselineMode,e.humanize??!1,i),h="progress"===e.baselineMode&&Is(c,i)?gi(c,i):0;return{title:{...e.title,text:e.title.text?Vo(e.title.text):""},keyValue:s,keyDescr:e.keyDescr?.text?Vo(e.keyDescr.text):"",baselineDisplay:c,baselineArrow:WC(n,o,e.baselineMode),baselineColor:GC(n,e.baselineMode,o,e.baselineColorUp,e.baselineColorDown),baselineDescr:"progress"!==e.baselineMode&&e.baselineDescr?.text?Vo(e.baselineDescr.text):"",fontColor:l,background:a,baselineStyle:{..."percentage"!==e.baselineMode&&"progress"!==e.baselineMode&&r?t.getCellComputedStyle({sheetId:r.sheetId,col:r.zone.left,row:r.zone.top}):void 0,fontSize:e.baselineDescr?.fontSize,align:e.baselineDescr?.align},baselineDescrStyle:{textColor:e.baselineDescr?.color,...e.baselineDescr},keyValueStyle:{...e.keyValue?t.getCellComputedStyle({sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top}):void 0,fontSize:e.keyDescr?.fontSize,align:e.keyDescr?.align},keyValueDescrStyle:{textColor:e.keyDescr?.color,...e.keyDescr},progressBar:"progress"===e.baselineMode?{value:h,color:h>0?e.baselineColorUp:e.baselineColorDown}:void 0}}const QC=.05;function ey(e,t){const o=e||"";return t&&o?" "+o:o}function ty({width:e,height:t},o){return new oy({width:e,height:t},o).computeDesign()}class oy{runtime;context;width;height;constructor({width:e,height:t},o){this.runtime=o;const s=document.createElement("canvas");this.width=s.width=e,this.height=s.height=t,this.context=s.getContext("2d")}computeDesign(){const e={canvas:{width:this.width,height:this.height,backgroundColor:this.backgroundColor}},t=this.getTextStyles();let o=0;if(this.title){let s,i;switch(({height:o,width:i}=this.getFullTextDimensions(this.title,t.title.font)),this.runtime.title.align){case"center":s=(this.width-i)/2;break;case"right":s=this.width-i-j;break;default:s=j}e.title={text:this.title,style:t.title,position:{x:s,y:Y+o/2}}}const s=t.baselineArrow?.size??0;let{height:i,width:n}=this.getTextDimensions(this.baseline,t.baselineValue.font);this.baseline||(i=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).height);const r=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).width;let a;switch(this.runtime.baselineStyle?.align){case"right":a=this.width-j-r-n;break;case"left":a=j+s;break;default:a=(this.width-n-r+s)/2}if(this.baseline&&(e.baseline={text:this.baseline,style:t.baselineValue,position:{x:a,y:this.keyValue?this.height*(1-QC*(this.runtime.progressBar?1:2)):this.height-(this.height-o-i)/2-Y}},t.baselineArrow&&!this.runtime.progressBar&&(e.baselineArrow={direction:this.baselineArrow,style:t.baselineArrow,position:{x:e.baseline.position.x-s,y:e.baseline.position.y-(i+s)/2}})),e.baseline&&this.baselineDescr){const o={x:e.baseline.position.x+n,y:e.baseline.position.y};e.baselineDescr={text:this.baselineDescr,style:t.baselineDescr,position:o}}let l=0;this.runtime.progressBar&&(l=.05*this.height,e.progressBar={position:{x:2*j,y:.9*this.height-i-l},dimension:{height:l,width:this.width-4*j},value:this.runtime.progressBar.value,style:{color:this.runtime.progressBar.color,backgroundColor:this.secondaryFontColor}});const{width:c,height:h}=this.getFullTextDimensions(this.keyValue,t.keyValue.font),d=this.getTextDimensions(this.keyDescr,t.keyDescr.font).width;let u;switch(this.runtime.keyValueStyle?.align){case"right":u=this.width-j-d-c;break;case"left":u=j;break;default:u=(this.width-c-d)/2}if(this.keyValue&&(e.key={text:this.keyValue,style:t.keyValue,position:{x:Math.max(j,u),y:.4*this.height+Y/2+(o+h/2)/2}}),e.key&&this.keyDescr){const o={x:e.key.position.x+c,y:e.key.position.y};e.keyDescr={text:this.keyDescr,style:t.keyDescr,position:o}}return e}get title(){return this.runtime.title.text??""}get keyValue(){return this.runtime.keyValue}get keyDescr(){return ey(this.runtime.keyDescr,this.keyValue)}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){return ey(this.runtime.baselineDescr,this.baseline)}get baselineArrow(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get secondaryFontColor(){return tC(this.backgroundColor)}getTextDimensions(e,t){this.context.font=t;const o=this.context.measureText(e);return{width:o.width,height:o.actualBoundingBoxAscent+o.actualBoundingBoxDescent}}getFullTextDimensions(e,t){this.context.font=t;const o=this.context.measureText(e);return{width:o.width,height:o.fontBoundingBoxAscent+o.fontBoundingBoxDescent}}getTextStyles(){const e=this.runtime.keyValueStyle?.fontSize??32,t=Math.floor(.9*e);let o=this.runtime.baselineStyle?.fontSize??16;const s=Math.floor(.9*o);return this.runtime.progressBar&&(o/=1.5),{title:{font:Da(this.runtime.title.fontSize??14,this.runtime.title.bold,this.runtime.title.italic),color:this.runtime.title.color??this.secondaryFontColor},keyValue:{color:this.runtime.keyValueStyle?.textColor||this.runtime.fontColor,font:Da(e,this.runtime.keyValueStyle?.bold,this.runtime.keyValueStyle?.italic),strikethrough:this.runtime.keyValueStyle?.strikethrough,underline:this.runtime.keyValueStyle?.underline},keyDescr:{color:this.runtime.keyValueDescrStyle?.textColor||this.runtime.fontColor,font:Da(t,this.runtime.keyValueDescrStyle?.bold,this.runtime.keyValueDescrStyle?.italic),strikethrough:this.runtime.keyValueDescrStyle?.strikethrough,underline:this.runtime.keyValueDescrStyle?.underline},baselineValue:{font:Da(o,this.runtime.baselineStyle?.bold,this.runtime.baselineStyle?.italic),strikethrough:this.runtime.baselineStyle?.strikethrough,underline:this.runtime.baselineStyle?.underline,color:this.runtime.baselineColor||this.runtime.baselineStyle?.textColor||this.secondaryFontColor},baselineDescr:{font:Da(s,this.runtime.baselineDescrStyle?.bold,this.runtime.baselineDescrStyle?.italic),strikethrough:this.runtime.baselineDescrStyle?.strikethrough,underline:this.runtime.baselineDescrStyle?.underline,color:this.runtime.baselineDescrStyle?.textColor??this.secondaryFontColor},baselineArrow:"neutral"===this.baselineArrow||this.runtime.progressBar?void 0:{size:this.keyValue?.8*o:0,color:this.runtime.baselineColor||this.runtime.baselineStyle?.textColor||this.secondaryFontColor}}}}class sy extends t.Component{static template="o-spreadsheet-ScorecardChart";static props={figureUI:Object};canvas=t.useRef("chartContainer");get runtime(){return this.env.model.getters.getChartRuntime(this.props.figureUI.id)}get title(){const e=this.env.model.getters.getChartDefinition(this.props.figureUI.id).title.text??"";return Vo(e)}setup(){t.useEffect(this.createChart.bind(this),(()=>{const e=this.canvas.el.getBoundingClientRect();return[e.width,e.height,this.runtime,this.canvas.el,window.devicePixelRatio]}))}createChart(){const e=this.canvas.el;KC(ty(e.getBoundingClientRect(),this.runtime),e)}}const iy=/Mac/i,ny=["Shift","Control","Alt","Meta"];function ry(e,t){return!!e&&(!!t.target&&e.contains(t.target))}function ay(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:o}=e.getBoundingClientRect();return{top:t,left:o}}throw new Error("Can't find spreadsheet position")}function ly(e){return e.el?cy(e.el):{x:0,y:0,width:0,height:0}}function cy(e){const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}function*hy(e){if(yield e,e.hasChildNodes())for(const t of e.childNodes)yield*hy(t)}function dy(e){const{startElement:t,endElement:o,startSelectionOffset:s,endSelectionOffset:i}=function(e){const t=document.getSelection();return{startElement:t.anchorNode||e,startSelectionOffset:t.anchorOffset,endElement:t.focusNode||e,endSelectionOffset:t.focusOffset}}(e);return{start:uy(e,t,s),end:uy(e,o,i)}}function uy(e,t,o){let s=0;const i=hy(e);let n=i.next(),r=!0;for(;!n.done&&n.value!==t;)n.value.hasChildNodes()||n.value.textContent&&(s+=n.value.textContent.length),("P"===n.value.nodeName||"DIV"===n.value.nodeName&&n.value!==e)&&(r?r=!1:s++),n=i.next();if(n.value!==t)return 0;if(n.value.hasChildNodes()){const e=[...n.value.childNodes].slice(0,o);s+=e.reduce(((t,o,s)=>{if(null!==o.textContent){let i=o.textContent.length;return"P"===o.nodeName&&s!==e.length-1&&i++,t+i}return t}),0)}else s+=o;return"P"!==t.nodeName||r||""!==t.textContent||s++,s}const gy=/^[a-zA-Z]$/;function py(e,t="key"){let o="";ny.includes(e.key)||(fy(e)&&(o+="Ctrl+"),e.altKey&&(o+="Alt+"),e.shiftKey&&(o+="Shift+"));const s="key"===t?e.key:e.code;return o+=gy.test(s)?s.toUpperCase():s,o}function my(){return Boolean(iy.test(navigator.userAgent))}function fy(e){return my()||Cy()?e.metaKey:e.ctrlKey}function vy(e){return 1===e.button||fy(e)&&0===e.button}function by(e,t){const o=document.createElement("a");o.href=e,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o)}function Sy(){return/Firefox/i.test(navigator.userAgent)}function Cy(){return/(iPad|iPhone|iPod)/i.test(navigator.userAgent)||"MacIntel"===navigator.platform&&(navigator.maxTouchPoints||1)>1}function yy(){return/Android/i.test(navigator.userAgent)||Cy()||/(webOS|BlackBerry|Windows Phone)/i.test(navigator.userAgent)}function wy(e){return 8===(e=$t(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}const Iy=30,xy=10,Ey=20,Ry=12,Ty=80,Ay="#F3F2F1",Dy=6,_y=25;function Oy(e,t){const o=e.getBoundingClientRect(),s=window.devicePixelRatio||1;e.width=s*o.width,e.height=s*o.height;const i=e.getContext("2d");i.scale(s,s);const n=function(e,t,o){const s=t.maxValue,i=t.minValue,n=Vy(t,"animated"),r=function(e,t){const o=t?_y:0,s=e.height-Ey-o-xy,i=e.width-2*Iy;let n,r;i>2*s?(n=2*s,r=s):(n=i,r=i/2);const a=o+xy+(s-r)/2;return{x:Iy+(i-n)/2,y:a,width:n,height:r}}(e,t.title.text),a=r.width/6,l=n?(n-i.value)/(s.value-i.value):0,c={x:e.width/2,y:r.y+r.height-r.height/12};let h=Ty;r.height<300&&(h*=r.height/300);const d=r.width/2,u=t.gaugeValue?.label||"-";Oa(o,u,{fontSize:h},"px")>d&&(h=function(e,t,o,s=.25){let i=1;if(o(i)>e)return i;if(o(t)<e)return t;let n=(i+t)/2,r=o(n),a=0;for(;Math.abs(r-e)>s&&a<20;)r>=e?t=(i+t)/2:i=(i+t)/2,n=(i+t)/2,r=o(n),a++;return n}(d,h,(e=>Oa(o,u,{fontSize:e},"px"))));const g={x:r.x+a/2,y:r.y+r.height+Ry},p={x:r.x+r.width-a/2,y:r.y+r.height+Ry},m=tC(t.background),f=function(e,t,o,s){const i=e.maxValue,n=e.minValue,r={x:t.x+t.width/2,y:t.y+t.height},a={fontSize:Ry},l=[],c=[];for(const h of e.inflectionValues){const e=(h.value-n.value)/(i.value-n.value),d=Oa(s,h.label,a,"px"),u=Math.PI-Math.PI*e,g=ky(u,t.height+Dy,r.x,r.y,d+2,Ry),p=c.some((e=>Ny(e,g)))?Ry:0;c.push(g),l.push({rotation:u,label:h.label,fontSize:Ry,color:o,offset:p})}return l}(t,r,m,o);let v=0,b=0,S=0;t.title.text&&({width:b,height:S}=Ma(o,t.title.text,{fontSize:K,...t.title},"px"));switch(t.title.align){case"right":v=e.width-b-j;break;case"center":v=(e.width-b)/2;break;default:v=j}return{width:e.width,height:e.height,title:{label:t.title.text??"",fontSize:t.title.fontSize??K,textPosition:{x:v,y:X+S/2},color:t.title.color??m,bold:t.title.bold,italic:t.title.italic},backgroundColor:t.background,gauge:{rect:r,arcWidth:a,percentage:Ze(l,0,1),color:Fy(t)},inflectionValues:f,gaugeValue:{label:u,textPosition:c,fontSize:h,color:m},minLabel:{label:t.minValue.label,textPosition:g,fontSize:Ry,color:m},maxLabel:{label:t.maxValue.label,textPosition:p,fontSize:Ry,color:m}}}(o,t,i);!function(e,t){e.save(),e.fillStyle=t.backgroundColor,e.fillRect(0,0,t.width,t.height),e.restore()}(i,n),function(e,t){e.save();const o=t.gauge,s=o.rect.x+o.rect.width/2,i=o.rect.y+o.rect.height,n=o.rect.height-o.arcWidth/2;if(n<0)return;const r=1===o.percentage?0:Math.PI*(1+o.percentage);e.strokeStyle=Ay,e.beginPath(),e.lineWidth=o.arcWidth,e.arc(s,i,n,r,0),e.stroke(),e.strokeStyle=o.color,e.beginPath(),e.arc(s,i,n,Math.PI,r),e.stroke(),e.restore()}(i,n),function(e,t){const{x:o,y:s,width:i,height:n}=t.gauge.rect;for(const r of t.inflectionValues){e.save(),e.translate(o+i/2-.5,s+n-.5),e.rotate(Math.PI/2-r.rotation),e.lineWidth=2,e.strokeStyle=tC(t.backgroundColor)+"aa",e.beginPath(),e.moveTo(0,-(n-t.gauge.arcWidth)),e.lineTo(0,-n-3),e.stroke(),e.textAlign="center",e.font=`${r.fontSize}px ${fe}`,e.fillStyle=r.color;const a=-n-Dy-r.offset;e.fillText(r.label,0,a),e.restore()}}(i,n),function(e,t){for(const o of[t.minLabel,t.maxLabel,t.gaugeValue])e.save(),e.textAlign="center",e.fillStyle=o.color,e.font=`${o.fontSize}px ${fe}`,e.fillText(o.label,o.textPosition.x,o.textPosition.y),e.restore()}(i,n),function(e,t){e.save();const o=t.title;e.font=Da(o.fontSize,o.bold,o.italic),e.textBaseline="middle",e.fillStyle=o.color,e.fillText(o.label,o.textPosition.x,o.textPosition.y),e.restore()}(i,n)}function Fy(e){const t=Vy(e,"final");if(void 0===t)return Ay;for(let o=0;o<e.inflectionValues.length;o++){const s=e.inflectionValues[o];if("<"===s.operator&&t<s.value)return e.colors[o];if("<="===s.operator&&t<=s.value)return e.colors[o]}return e.colors.at(-1)}function Py(e){return[{start:e.topLeft,end:e.topRight},{start:e.topRight,end:e.bottomRight},{start:e.bottomRight,end:e.bottomLeft},{start:e.bottomLeft,end:e.topLeft}]}function My(e,t){const o=e.start,s=e.end,i=t.start,n=t.end;function r(e,t,o){return(o.y-e.y)*(t.x-e.x)>(t.y-e.y)*(o.x-e.x)}return r(o,i,n)!==r(s,i,n)&&r(o,s,i)!==r(o,s,n)}function Ny(e,t){const o=Py(e),s=Py(t);for(const e of o)for(const t of s)if(My(e,t))return!0;return!1}function ky(e,t,o,s,i,n){const r=Math.cos(e),a=Math.sin(e),l=r*t,c=a*t,h=a*(i/2),d=r*(i/2),u=r*(t+n),g=a*(t+n);return{bottomLeft:{x:l-h+o,y:s-(c+d)},bottomRight:{x:l+h+o,y:s-(c-d)},topRight:{x:u+h+o,y:s-(g-d)},topLeft:{x:u-h+o,y:s-(g+d)}}}function Vy(e,t){return"animated"===t&&void 0!==e.animationValue?e.animationValue:e.gaugeValue?.value}const Ly={responsive:!0,maintainAspectRatio:!1,elements:{line:{fill:!1},point:{hitRadius:15}},animation:!1,events:["mousemove","mouseout","click","touchstart","touchmove","mouseup"]};function Hy(e,t,o){const s=document.createElement("div");s.style.width=`${t.width}px`,s.style.height=`${t.height}px`;const i=document.createElement("canvas");let n;if(s.append(i),i.setAttribute("width",t.width.toString()),i.setAttribute("height",t.height.toString()),document.body.append(s),"chartJsConfig"in e){const t=ze(e.chartJsConfig);t.plugins=[By];const o=new window.Chart(i,t);n=o.toBase64Image(),o.destroy()}else if("scorecard"===o){KC(ty(t,e),i),n=i.toDataURL()}else"gauge"===o&&(Oy(i,e),n=i.toDataURL());return s.remove(),n}async function Uy(e,t,o){const s=document.createElement("div");s.style.width=`${t.width}px`,s.style.height=`${t.height}px`,s.style.position="fixed",s.style.opacity="0";const i=document.createElement("canvas");s.append(i),i.setAttribute("width",t.width.toString()),i.setAttribute("height",t.height.toString()),document.body.append(s);let n=null;if("chartJsConfig"in e){const t=ze(e.chartJsConfig);t.plugins=[By];const o=new window.Chart(i,t);n=await new Promise((e=>i.toBlob(e,"image/png"))),o.destroy()}else if("scorecard"===o){KC(ty(t,e),i),n=await new Promise((e=>i.toBlob(e,"image/png")))}else"gauge"===o&&(Oy(i,e),n=await new Promise((e=>i.toBlob(e,"image/png"))));return s.remove(),n?new File([n],"chart.png",{type:"image/png"}):void 0}const By={id:"customCanvasBackgroundColor",beforeDraw:e=>{const{ctx:t}=e;t.save(),t.globalCompositeOperation="destination-over",t.fillStyle="#ffffff",t.fillRect(0,0,e.width,e.height),t.restore()}},zy={Errors:{InvalidRange:Vo("The range is invalid"),FirstArgMissing:Vo("The argument is missing. Please provide a value"),SecondArgMissing:Vo("The second argument is missing. Please provide a value"),MinNaN:Vo("The minpoint must be a number"),MidNaN:Vo("The midpoint must be a number"),MaxNaN:Vo("The maxpoint must be a number"),ValueUpperInflectionNaN:Vo("The first value must be a number"),ValueLowerInflectionNaN:Vo("The second value must be a number"),MinBiggerThanMax:Vo("Minimum must be smaller then Maximum"),MinBiggerThanMid:Vo("Minimum must be smaller then Midpoint"),MidBiggerThanMax:Vo("Midpoint must be smaller then Maximum"),LowerBiggerThanUpper:Vo("Lower inflection point must be smaller than upper inflection point"),MinInvalidFormula:Vo("Invalid Minpoint formula"),MaxInvalidFormula:Vo("Invalid Maxpoint formula"),MidInvalidFormula:Vo("Invalid Midpoint formula"),ValueUpperInvalidFormula:Vo("Invalid upper inflection point formula"),ValueLowerInvalidFormula:Vo("Invalid lower inflection point formula"),EmptyRange:Vo("A range needs to be defined"),ValueCellIsInvalidFormula:Vo("At least one of the provided values is an invalid formula"),Unexpected:Vo("The rule is invalid for an unknown reason")},ColorScale:Vo("Color scale"),IconSet:Vo("Icon set"),DataBar:Vo("Data bar")},$y={Series:Vo("Series"),BackgroundColor:Vo("Background color"),StackedBarChart:Vo("Stacked bar chart"),StackedLineChart:Vo("Stacked line chart"),StackedAreaChart:Vo("Stacked area chart"),StackedColumnChart:Vo("Stacked column chart"),CumulativeData:Vo("Cumulative data"),TreatLabelsAsText:Vo("Treat labels as text"),AggregatedChart:Vo("Aggregate"),Errors:{Unexpected:Vo("The chart definition is invalid for an unknown reason"),InvalidDataSet:Vo("The dataset is invalid"),InvalidLabelRange:Vo("Labels are invalid"),InvalidScorecardKeyValue:Vo("The key value is invalid"),InvalidScorecardBaseline:Vo("The baseline value is invalid"),InvalidGaugeDataRange:Vo("The data range is invalid"),EmptyGaugeRangeMin:Vo("A minimum range limit value is needed"),GaugeRangeMinNaN:Vo("The minimum range limit value must be a number"),EmptyGaugeRangeMax:Vo("A maximum range limit value is needed"),GaugeRangeMaxNaN:Vo("The maximum range limit value must be a number"),GaugeLowerInflectionPointNaN:Vo("The lower inflection point value must be a number"),GaugeUpperInflectionPointNaN:Vo("The upper inflection point value must be a number")},GeoChart:{ColorScales:{blues:Vo("Blues"),cividis:Vo("Cividis"),greens:Vo("Greens"),greys:Vo("Greys"),oranges:Vo("Oranges"),purples:Vo("Purples"),rainbow:Vo("Rainbow"),reds:Vo("Reds"),viridis:Vo("Viridis")}}},Gy={Custom:Vo("Custom")},Wy=Vo("Merged cells are preventing this operation. Unmerge those cells and try again."),qy={Errors:{Unexpected:Vo("Cannot split the selection for an unknown reason"),NoSplitSeparatorInSelection:Vo("There is no match for the selected separator in the selection"),MoreThanOneColumnSelected:Vo("Only a selection from a single column can be split"),SplitWillOverwriteContent:Vo("Splitting will overwrite existing content")}},Zy={Errors:{Unexpected:Vo("Cannot remove duplicates for an unknown reason"),MoreThanOneRangeSelected:Vo("Please select only one range of cells"),EmptyTarget:Vo("Please select a range of cells containing values."),NoColumnsProvided:Vo("Please select at latest one column to analyze."),WillRemoveExistingMerge:Vo("This operation is not possible due to a merge. Please remove the merges first than try again.")}},jy={DateIs:{today:Vo("today"),yesterday:Vo("yesterday"),tomorrow:Vo("tomorrow"),lastWeek:Vo("in the past week"),lastMonth:Vo("in the past month"),lastYear:Vo("in the past year")},DateIsBefore:{today:Vo("today"),yesterday:Vo("yesterday"),tomorrow:Vo("tomorrow"),lastWeek:Vo("one week ago"),lastMonth:Vo("one month ago"),lastYear:Vo("one year ago")},CriterionError:{notEmptyValue:Vo("The value must not be empty"),numberValue:Vo("The value must be a number"),dateValue:Vo("The value must be a date"),validRange:Vo("The value must be a valid range"),validFormula:Vo("The formula must be valid")},Errors:{InvalidRange:Vo("The range is invalid."),InvalidDataValidationCriterionValue:Vo("One or more of the provided criteria values are invalid. Please review and correct them."),InvalidNumberOfCriterionValues:Vo("One or more of the provided criteria values are missing."),Unexpected:Vo("The rule is invalid for an unknown reason.")}},Yy={Errors:{Unexpected:Vo("The table zone is invalid for an unknown reason"),TableOverlap:Vo("You cannot create overlapping tables."),NonContinuousTargets:Vo("A table can only be created on a continuous selection."),InvalidRange:Vo("The range is invalid"),TargetOutOfSheet:Vo("The range is out of the sheet")},Checkboxes:{hasFilters:Vo("Filter button"),headerRow:Vo("Header row(s)"),bandedRows:Vo("Banded rows"),firstColumn:Vo("First column"),lastColumn:Vo("Last column"),bandedColumns:Vo("Banded columns"),automaticAutofill:Vo("Automatically autofill formulas"),totalRow:Vo("Total row"),isDynamic:Vo("Auto-adjust to formula result")},Tooltips:{filterWithoutHeader:Vo("Cannot have filters without a header row"),isDynamic:Vo("For tables based on array formulas only")}},Xy={labels:{no_calculations:Vo("No calculations"),"%_of_grand_total":Vo("% of grand total"),"%_of_col_total":Vo("% of column total"),"%_of_row_total":Vo("% of row total"),"%_of":Vo("% of"),"%_of_parent_row_total":Vo("% of parent row total"),"%_of_parent_col_total":Vo("% of parent column total"),"%_of_parent_total":Vo("% of parent total"),difference_from:Vo("Difference from"),"%_difference_from":Vo("% difference from"),running_total:Vo("Running total"),"%_running_total":Vo("% Running total"),rank_asc:Vo("Rank smallest to largest"),rank_desc:Vo("Rank largest to smallest"),index:Vo("Index")},descriptions:{"%_of_grand_total":()=>Vo("Displayed as % of grand total"),"%_of_col_total":()=>Vo("Displayed as % of column total"),"%_of_row_total":()=>Vo("Displayed as % of row total"),"%_of":e=>Vo('Displayed as % of "%s"',e),"%_of_parent_row_total":e=>Vo('Displayed as % of parent row total of "%s"',e),"%_of_parent_col_total":()=>Vo("Displayed as % of parent column total"),"%_of_parent_total":e=>Vo('Displayed as % of parent "%s" total',e),difference_from:e=>Vo('Displayed as difference from "%s"',e),"%_difference_from":e=>Vo('Displayed as % difference from "%s"',e),running_total:e=>Vo('Displayed as running total based on "%s"',e),"%_running_total":e=>Vo('Displayed as % running total based on "%s"',e),rank_asc:e=>Vo('Displayed as rank from smallest to largest based on "%s"',e),rank_desc:e=>Vo('Displayed as rank largest to smallest based on "%s"',e),index:()=>Vo("Displayed as index")},documentation:{no_calculations:Vo("Displays the value that is entered in the field."),"%_of_grand_total":Vo("Displays values as a percentage of the grand total of all the values or data points in the report."),"%_of_col_total":Vo("Displays all the values in each column or series as a percentage of the total for the column or series."),"%_of_row_total":Vo("Displays the value in each row or category as a percentage of the total for the row or category."),"%_of":Vo("Displays values as a percentage of the value of the Base item in the Base field."),"%_of_parent_row_total":Vo("Calculates values as follows:\n(value for the item) / (value for the parent item on rows)"),"%_of_parent_col_total":Vo("Calculates values as follows:\n(value for the item) / (value for the parent item on columns)"),"%_of_parent_total":Vo("Calculates values as follows:\n(value for the item) / (value for the parent item of the selected Base field)"),difference_from:Vo("Displays values as the difference from the value of the Base item in the Base field."),"%_difference_from":Vo("Displays values as the percentage difference from the value of the Base item in the Base field."),running_total:Vo("Displays the value for successive items in the Base field as a running total."),"%_running_total":Vo("Calculates the value as a percentage for successive items in the Base field that are displayed as a running total."),rank_asc:Vo("Displays the rank of selected values in a specific field, listing the smallest item in the field as 1, and each larger value with a higher rank value."),rank_desc:Vo("Displays the rank of selected values in a specific field, listing the largest item in the field as 1, and each smaller value with a higher rank value."),index:Vo("Calculates values as follows:\n((value in cell) x (Grand Total of Grand Totals)) / ((Grand Row Total) x (Grand Column Total))")}},Ky={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},Jy={inSeconds:function(e){return Math.floor(e/Ky.second)},inMinutes:function(e){return Math.floor(e/Ky.minute)},inHours:function(e){return Math.floor(e/Ky.hour)},inDays:function(e){return Math.floor(e/Ky.day)},inMonths:function(e){return Math.floor(e/Ky.month)},inYears:function(e){return Math.floor(e/Ky.year)}},Qy=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function ew(e,t,o){const s=function(e){const t=e.indexOf("h");e=t>=0?e.slice(0,t).replace(/m/g,"M")+e.slice(t):e.replace(/m/g,"M");e.includes("a")||(e=e.replace(/h/g,"H"));return e}(t),i=function(e,t,o){const s=e.map((e=>ls(e,o)?.jsDate));if(s.some((e=>void 0===e))||e.length<2)return;const i=s.map((e=>e.getTime())),n=Ot(i)-Ft(i),r=function(e){if(e.includes("s"))return"second";if(e.includes("m"))return"minute";if(e.includes("h")||e.includes("H"))return"hour";if(e.includes("d"))return"day";if(e.includes("M"))return"month";return"year"}(t);if(Ky.second>=Ky[r]&&Jy.inSeconds(n)<180)return"second";if(Ky.minute>=Ky[r]&&Jy.inMinutes(n)<180)return"minute";if(Ky.hour>=Ky[r]&&Jy.inHours(n)<96)return"hour";if(Ky.day>=Ky[r]&&Jy.inDays(n)<90)return"day";if(Ky.month>=Ky[r]&&Jy.inMonths(n)<36)return"month";return"year"}(e,s,o),n={};return i&&(n[i]=s),{parser:s,displayFormats:n,unit:i??!1}}function tw(e,t,o,s){let i=Cw(s,t,o).formattedValues,n=ww(s,t);iC(o,t[0],e.dataSetsHaveTitle||!1)&&i.shift(),({labels:i,dataSetsValues:n}=vw(i,n)),e.aggregated&&({labels:i,dataSetsValues:n}=bw(i,n));const r=yw(s,t,"left"),a=yw(s,t,"right"),l=e.horizontal?{x:r||a}:{y:r,y1:a},c=[];for(const t in n){const{data:o}=n[t],s=e.dataSets?.[t].trend;if(!s?.display||e.horizontal){c.push(void 0);continue}const i=cw(s,o);c.push(i)}return{dataSetsValues:n,trendDataSetsValues:c,axisFormats:l,labels:i,locale:s.getLocale(),topPadding:xw(e,s)}}function ow(e,t,o,s){const i=tw(e,t.slice(0,2),o,s),n=i.dataSetsValues.filter((e=>!e.hidden)),r=[];if(n[0]){const e=n[0].data.map((e=>e>0?e:0));r.push({...n[0],data:e})}if(n[1]){const e=n[1].data.map((e=>e>0?-e:0));r.push({...n[1],data:e})}return{...i,dataSetsValues:r}}function sw(e,t,o,s){const i=function(e,t,o,s){if(function(e,t,o,s){return!e.labelsAsText&&gw(e,t,o,s)}(e,t,o,s)&&function(){if(!window.Chart)return!1;const e="luxon"===new window.Chart._adapters._date({})._id;e||mw||(mw=!0,console.warn("'chartjs-adapter-luxon' time adapter is not installed. Time scale axes are disabled."));return e}())return"time";if(function(e,t,o,s){return!e.labelsAsText&&pw(e,t,o,s)}(e,t,o,s))return"linear";return"category"}(e,t,o,s),n=Cw(s,t,o);let r="linear"===i?n.values:n.formattedValues,a=ww(s,t);const l=iC(o,t[0],e.dataSetsHaveTitle||!1);l&&r.shift(),({labels:r,dataSetsValues:a}=vw(r,a)),"time"===i&&({labels:r,dataSetsValues:a}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const o=[...e],s=ze(t);for(let e=0;e<o.length;e++)if(!o[e]){o[e]=gt(o,e);for(const t of s)t.data[e]=void 0}return{labels:o,dataSetsValues:s}}(r,a)),e.aggregated&&({labels:r,dataSetsValues:a}=bw(r,a)),e.cumulative&&(a=Iw(a,"asc"));const c={y:yw(s,t,"left"),y1:yw(s,t,"right"),x:Sw(s,o,l)},h=[];for(const t in a){const o=e.dataSets?.[t].trend;if(!o?.display){h.push(void 0);continue}const{data:n}=a[t];h.push(hw(o,n,r,i,s.getLocale()))}return{dataSetsValues:a,axisFormats:c,labels:r,locale:s.getLocale(),trendDataSetsValues:h,axisType:i,topPadding:xw(e,s)}}function iw(e,t,o,s){let i=Cw(s,t,o).formattedValues,n=ww(s,t);iC(o,t[0],e.dataSetsHaveTitle||!1)&&i.shift(),({labels:i,dataSetsValues:n}=vw(i,n)),e.aggregated&&({labels:i,dataSetsValues:n}=bw(i,n)),({dataSetsValues:n,labels:i}=function(e,t){const o=Math.max(e.length,...t.map((e=>e.data?.length||0))),s=je(0,o).filter((e=>t.some((t=>"number"==typeof t.data[e]&&t.data[e]>0))));return{labels:s.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:s.map((t=>"number"==typeof e.data[t]&&e.data[t]>0?e.data[t]:null))})))}}(i,n));return{dataSetsValues:n,axisFormats:{y:yw(s,t,"left")},labels:i,locale:s.getLocale(),topPadding:xw(e,s)}}function nw(e,t,o,s){let i=Cw(s,t,o).formattedValues,n=ww(s,t);iC(o,t[0],e.dataSetsHaveTitle||!1)&&i.shift(),({labels:i,dataSetsValues:n}=vw(i,n)),e.aggregated&&({labels:i,dataSetsValues:n}=bw(i,n));return{dataSetsValues:n,axisFormats:{r:yw(s,t,"left")||yw(s,t,"right")},labels:i,locale:s.getLocale()}}function rw(e,t,o,s){const i=t.slice(0,1);let n=Cw(s,i,o).formattedValues;iC(o,i[0],e.dataSetsHaveTitle||!1)&&n.shift();let r=ww(s,i);({labels:n,dataSetsValues:r}=bw(n,r));return{dataSetsValues:r,axisFormats:{y:yw(s,i,"left")||yw(s,i,"right")},labels:n,locale:s.getLocale(),availableRegions:s.getGeoChartAvailableRegions(),geoFeatureNameToId:s.geoFeatureNameToId,getGeoJsonFeatures:s.getGeoJsonFeatures}}function aw(e,t,o,s){let i=Cw(s,t,o).formattedValues,n=ww(s,t);iC(o,t[0],e.dataSetsHaveTitle||!1)&&i.shift(),({labels:i,dataSetsValues:n}=vw(i,n)),e.aggregated&&({labels:i,dataSetsValues:n}=bw(i,n)),e.cumulative&&(n=Iw(n,"desc"));return{dataSetsValues:n,axisFormats:{x:yw(s,t,"left")||yw(s,t,"right")},labels:i,locale:s.getLocale()}}function lw(e,t,o,s){let i=Cw(s,t,o).values,n=function(e,t){t=t.filter((t=>!e.isColHidden(t.dataRange.sheetId,t.dataRange.zone.left)));const o=t.map((()=>({data:[],label:""}))),s=t.map((t=>fw(e,t)));if(!s.length)return o;const i=Math.min(...s.map((e=>e.length)));let n=[];const r=t.length-1;for(let e=0;e<i;e++)for(let t=0;t<s.length;t++){let i=s[t][e];null==i&&t!==r&&(i=n[t]),i!==n[t]&&(n=n.slice(0,t),n[t]=i),o[t].data.push(i??null)}return o.filter((e=>e.data.some((e=>null!==e))))}(s,t);const r=iC(o,t[0],e.dataSetsHaveTitle||!1);return r&&i.shift(),({labels:i,dataSetsValues:n}=function(e,t){const o=[],s=[];for(let t=0;t<e.length;t++)Number(e[t])<=0?s.push(t):Number(e[t])>0&&o.push(t);const i=o.length?o:s;return{labels:i.map((t=>e[t])),dataSetsValues:t.map((e=>({...e,data:i.map((t=>e.data[t]))})))}}(i,n)),({labels:i,dataSetsValues:n}=function(e,t){const o=Math.max(e.length,...t.map((e=>e.data?.length||0))),s=e=>null==e||""===e,i=je(0,o).filter((o=>{const i=t.map((e=>e.data?.[o]));if(s(i[0]))return!1;let n=!1;for(const e of i)if(n||=s(e),n&&!s(e))return!1;return e[o]&&!isNaN(Number(e[o]))}));return{labels:i.map((t=>e[t])),dataSetsValues:t.map((e=>({...e,data:i.map((t=>e.data[t]))})))}}(i,n)),{dataSetsValues:n,axisFormats:{y:Sw(s,o,r)},labels:i,locale:s.getLocale()}}function cw(e,t){const o=[],s=[],i=[];for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(o.push(t[e]),s.push(e+1)),i.push(e+1);const n=dw(e,o,s,je(.5,i.length+.55,.2));return n.length?n:void 0}function hw(e,t,o,s,i){const n=[],r=[],a=[],l=t.length;if(l<2)return;switch(s){case"category":for(let e=0;e<l;e++)"number"==typeof t[e]&&(n.push(t[e]),r.push(e+1)),a.push(e+1);break;case"linear":for(let e=0;e<t.length;e++){const s=Number(o[e]);isNaN(s)||("number"==typeof t[e]&&(n.push(t[e]),r.push(s)),a.push(s))}break;case"time":for(let e=0;e<t.length;e++){const s=gi({value:o[e]},i);null!==t[e]&&(n.push(t[e]),r.push(s)),a.push(s)}}const c=Math.min(...a),h=Math.max(...a);if(h===c)return;const d=(h-c)/(5*a.length),u=dw(e,n,r,je(c,h+d/2,d));return u.length?u:void 0}function dw(e,t,o,s){if(t.length<2||o.length<2||0===s.length)return[];const{normalizedLabels:i,normalizedNewLabels:n}=function(e,t,o){let s=[],i=[];if("logarithmic"===o.type){const o=Math.max(...e.map(Math.abs));s=e.map((e=>e/o)),i=t.map((e=>e/o))}else{const o=Math.max(...e),n=Math.min(...e),r=o-n;s=e.map((e=>(e-o)/r)),i=t.map((e=>(e-o)/r))}return{normalizedLabels:s,normalizedNewLabels:i}}(o,s,e);try{switch(e.type){case"polynomial":{const o=e.order;if(!o)return s.map((e=>({x:e,y:NaN})));if(1===o)return hc([t],[i],[n],!0)[0].map(((e,t)=>({x:s[t],y:e})));const r=nc(t,i,o,!0).flat();return n.map(((e,t)=>({x:s[t],y:ac(r,e,o)})))}case"exponential":{const e=[],o=[];for(let s=0;s<t.length;s++)t[s]>0&&(e.push(Math.log(t[s])),o.push(i[s]));return o.length?lc(hc([e],[o],[n],!0))[0].map(((e,t)=>({x:s[t],y:e}))):s.map((e=>({x:e,y:NaN})))}case"logarithmic":return hc([t],cc([i]),cc([n]),!0)[0].map(((e,t)=>({x:s[t],y:e})));case"trailingMovingAverage":return function(e,t,o=Ae){const s=[];for(let e=0;e<o-1;e++)s.push({x:t[e],y:NaN});for(let i=0;i<=e.length-o;i++){let n=0;for(let t=i;t<i+o;t++)n+=e[t];s.push({x:t[i+o-1],y:n/o})}return s}(t,o,e.window);default:return s.map((e=>({x:e,y:NaN})))}}catch(e){return s.map((e=>({x:e,y:NaN})))}}function uw(e,t,o,s){return gw(e,t,o,s)||pw(e,t,o,s)}function gw(e,t,o,s){if(!o||!pw(e,t,o,s))return!1;const i=Sw(s,o,iC(o,t[0],e.dataSetsHaveTitle||!1));return Boolean(i&&Qy.test(i))}function pw(e,t,o,s){if(!o)return!1;const i=s.getRangeValues(o);return iC(o,t[0],e.dataSetsHaveTitle||!1)&&i.shift(),!i.some((e=>isNaN(Number(e))&&e))&&!i.every((e=>!e))}let mw=!1;function fw(e,t){if(t.dataRange){const o=t.labelCell?[t.labelCell.zone]:[],s=er([t.dataRange.zone],o)[0];if(void 0===s)return[];const i=e.getRangeFromZone(t.dataRange.sheetId,s);return e.getRangeValues(i).map((e=>""===e?void 0:e))}return[]}function vw(e,t){const o=je(0,Math.max(e.length,...t.map((e=>e.data?.length||0)))).filter((o=>{const s=e[o],i=t.map((e=>e.data?.[o]));return s||i.some((e=>"number"==typeof e))}));return{labels:o.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:o.map((t=>"number"==typeof e.data[t]?e.data[t]:null))})))}}function bw(e,t){const o=new Set(e),s={};o.forEach((e=>{s[e]=new Array(t.length).fill(0)}));for(const o of je(0,e.length)){const n=e[o];for(const e of je(0,t.length))s[n][e]+="number"==typeof(i=t[e].data[o])?i:0}var i;return{labels:Array.from(o),dataSetsValues:t.map(((e,t)=>({...e,data:Array.from(o).map((e=>s[e][t]))})))}}function Sw(e,t,o){if(!t)return;const{sheetId:s,zone:i}=t,n=Er(i).map((t=>e.getEvaluatedCell({sheetId:s,...t}).format));return o&&n.shift(),n.find((e=>void 0!==e))}function Cw(e,t,o){let s={values:[],formattedValues:[]};if(o){const{left:i}=o.zone;if(o.invalidXc||o.invalidSheetName||e.isColHidden(o.sheetId,i)){if(t[0]){s={formattedValues:je(0,fw(e,t[0]).length).map((e=>e.toString())),values:s.formattedValues}}}else s={formattedValues:e.getRangeFormattedValues(o),values:e.getRangeValues(o).map((e=>String(e??"")))}}else if(1===t.length){const o=fw(e,t[0]).length;for(let e=0;e<o;e++)s.formattedValues.push(""),s.values.push("")}else if(t[0]){s={formattedValues:je(0,fw(e,t[0]).length).map((e=>e.toString())),values:s.formattedValues}}return s}function yw(e,t,o){const s=t.filter((e=>"right"===o==!!e.rightYAxis));for(const t of s){const o=e.getRangeFormats(t.dataRange).find((e=>void 0!==e&&!Rn(e)));if(o)return o}}function ww(e,t){const o=[];for(const[s,i]of Object.entries(t)){let t,n=e.isColHidden(i.dataRange.sheetId,i.dataRange.zone.left);if(i.labelCell){const o=i.labelCell,n=o?e.getEvaluatedCell({sheetId:o.sheetId,col:o.zone.left,row:o.zone.top}):void 0;t=n&&o?n.formattedValue:t=`${$y.Series} ${parseInt(s)+1}`}else t=`${$y.Series} ${parseInt(s)+1}`;const r=i.dataRange?fw(e,i):[];r.every((e=>"string"==typeof e&&!hi(e)))&&r.some((e=>""!==e))?r.fill(1):r.every((e=>null==e||!Is(e.toString(),$s)))&&(n=!0),o.push({data:r,label:t,hidden:n})}return o}function Iw(e,t){return e.map((e=>{const o=[];let s=0;const i="asc"===t?Object.keys(e.data):Object.keys(e.data).reverse();for(const t of i)isNaN(parseFloat(e.data[t]))?o[t]=e.data[t]:(s+=parseFloat(e.data[t]),o[t]=s);return{...e,data:o}}))}function xw(e,t){const{title:o,legendPosition:s}=e,i=o&&o.text||"top"===s;return t.isDashboard()&&!i?30:0}function Ew(e,t){return{padding:{left:j,right:j,top:Math.max(X,t.topPadding||0),bottom:Y}}}function Rw(e,t){return{display:"none"!==e.legendPosition,position:"none"!==e.legendPosition?e.legendPosition:void 0}}function Tw(e,t){return{...Nw,...Rw(e),...kw(eC(e.background),{pointStyle:"rect",lineWidth:3})}}function Aw(e,t){const o=e.fillArea,s=o?"rect":"line",i=o?2:3;return{...Nw,...Rw(e),...kw(eC(e.background),{pointStyle:s,lineWidth:i})}}function Dw(e,t){const{dataSetsValues:o}=t,s=Math.max(0,...o.map((e=>e?.data?.length??0))),i=cC(new po(s),o),n=eC(e.background);return{...Rw(e),labels:{usePointStyle:!0,generateLabels:e=>(e.data.labels?.map(((e,t)=>({text:hC(String(e)),strokeStyle:i[t],fillStyle:i[t],pointStyle:"rect",lineWidth:2,fontColor:n})))||[]).filter((e=>e.text)),filter:(e,t)=>!("datasetIndex"in e)||!t.datasets[e.datasetIndex].hidden}}}function _w(e,t){return{...Nw,...Rw(e),...kw(eC(e.background),{pointStyle:"circle",strokeStyle:e.background||"#ffffff",lineWidth:8})}}function Ow(e,t){return{...Nw,...Rw(e),...kw(eC(e.background),{lineWidth:3})}}function Fw(e,t){const o=eC(e.background),s=e.negativeValuesColor||A,i=e.positiveValuesColor||T,n=e.subTotalValuesColor||D;return{...Rw(e),labels:{usePointStyle:!0,generateLabels:()=>{const t=[{text:Vo("Positive values"),fontColor:o,fillStyle:i,strokeStyle:i,pointStyle:"rect"},{text:Vo("Negative values"),fontColor:o,fillStyle:s,strokeStyle:s,pointStyle:"rect"}];return(e.showSubTotals||e.firstValueAsSubtotal)&&t.push({text:Vo("Subtotals"),fontColor:o,fillStyle:n,strokeStyle:n,pointStyle:"rect"}),t},filter:(e,t)=>!("datasetIndex"in e)||!t.datasets[e.datasetIndex].hidden},onClick:()=>{}}}function Pw(e,t){const o=e.fillArea??!1,s=o?"rect":"line",i=o?2:3;return{...Nw,...Rw(e),...kw(eC(e.background),{pointStyle:s,lineWidth:i})}}function Mw(e,t){const o=eC(e.background);return{...Rw(e),labels:{usePointStyle:!0,generateLabels:e=>{const t=e.data.datasets.at(-1);if(!t)return[];return t.groupColors.map((({color:e,label:t})=>({text:hC(t),fontColor:o,fillStyle:e,strokeStyle:e,pointStyle:"rect"})))}}}}const Nw={onHover:e=>{const t=e.native?.target;t&&(t.style.cursor="pointer")},onLeave:e=>{const t=e.native?.target;t&&(t.style.cursor="default")},onClick:(e,t,o)=>{if("click"!==e.type)return;const s=t.datasetIndex;o.legendItems&&void 0!==s&&(o.chart.isDatasetVisible(s)?o.chart.hide(s):o.chart.show(s),e.native.preventDefault(),e.native.stopPropagation())}};function kw(e,t){return{labels:{color:e,usePointStyle:!0,generateLabels:o=>o.data.datasets.map(((s,i)=>dC(s.xAxisID)?{text:hC(s.label),fontColor:e,strokeStyle:s.borderColor,hidden:!o.isDatasetVisible(i),pointStyle:"line",datasetIndex:i,lineWidth:3}:{text:hC(s.label),fontColor:e,strokeStyle:s.borderColor,fillStyle:s.backgroundColor,hidden:!o.isDatasetVisible(i),pointStyle:"line"===s.type?"line":"rect",datasetIndex:i,...t})).filter((e=>e.text)),filter:(e,t)=>!("datasetIndex"in e)||!t.datasets[e.datasetIndex].hidden}}}function Vw(e,t){let o={};const{trendDataSetsValues:s,locale:i,axisFormats:n}=t,r={stacked:e.stacked,locale:i};if(e.horizontal)o.x=Zw(e,"bottom","values",{...r,format:n?.x}),o.y=Zw(e,"left","labels",r);else{o.x=Zw(e,"bottom","labels",r);const t={...r,format:n?.y};o.y=Zw(e,"left","values",t);const s={...r,format:n?.y1};o.y1=Zw(e,"right","values",s)}if(o=bt(o),s&&s.length&&s.some(lt)){const e=Math.max(...s.map((e=>e?.length||0)));o[zS]={...o.x,labels:Array(e).fill(""),offset:!1,display:!1},o[$S]={...o.x,offset:!0,display:!1}}return o}function Lw(e,t){const{locale:o,axisType:s,trendDataSetsValues:i,labels:n,axisFormats:r}=t,a=r?.x,l=e.stacked;let c={x:Zw(e,"bottom","labels",{locale:o}),y:Zw(e,"left","values",{locale:o,stacked:l,format:r?.y}),y1:Zw(e,"right","values",{locale:o,stacked:l,format:r?.y1})};if(c=bt(c),"time"===s&&n&&a){const e={type:"time",time:ew(n,a,o)};Object.assign(c.x,e),c.x.ticks.maxTicksLimit=15}else"linear"===s&&(c.x.type="linear",c.x.ticks.callback=e=>bn(e,{format:a,locale:o}));if(i&&i.length&&i.some(lt)&&(c[zS]={...c.x,display:!1},c[$S]={...c.x,display:!1},"category"===s||"time"===s)){const e=Math.max(...i.map((e=>e?.length||0)));c[zS].type="category",c[zS].labels=je(0,e).map((e=>e.toString())),c[zS].offset=!1,c[$S].type="category",c[$S].offset=!1}return c}function Hw(e,t){const o=Lw(e,t);return{...o,x:{...o.x,grid:{display:!0}}}}function Uw(e,t){const{locale:o,axisFormats:s}=t,i=s?.y||s?.y1;e.dataSets;const n={x:{...Zw(e,"bottom","labels",{locale:o}),grid:{display:!1}},y:{position:e.verticalAxisPosition,ticks:{color:eC(e.background),callback:aC({locale:o,format:i})},grid:{lineWidth:e=>0===e.tick.value?2:1},title:qw(e.axesDesign?.y)}},r=n?.y||n?.y1;return r&&(r.grid={lineWidth:e=>0===e.tick.value?2:1}),n}function Bw(e,t){const{dataSetsValues:o}=t,s=Vw(e,t),i=s.x.ticks.callback;s.x.ticks.callback=e=>i(Math.abs(e));const n=Math.max(...o.map((e=>Math.max(...e.data.map(Math.abs)))));return s.x.suggestedMin=-n,s.x.suggestedMax=n,s}function zw(e,t){const{locale:o,axisFormats:s,dataSetsValues:i}=t,n=Math.min(...i.map((e=>Math.min(...e.data.filter((e=>!isNaN(e)))))));return{r:{beginAtZero:!0,ticks:{callback:aC({format:s?.r,locale:o}),backdropColor:e.background||"#FFFFFF"},pointLabels:{color:eC(e.background),callback:hC},suggestedMin:n<0?n-1:0}}}function $w(e,t){const{locale:o,axisFormats:s,availableRegions:i}=t,n=function(e){switch(e){case"top":return"top-left";case"right":return"top-right";case"bottom":return"bottom-right";case"left":case"none":return"bottom-left"}}(e.legendPosition),r=e.region?i.find((t=>t.id===e.region)):i[0],a=s?.y||s?.y1;return{projection:{projection:Ww(r?.defaultProjection||"mercator"),axis:"x"},color:{axis:"x",display:"none"!==e.legendPosition,border:{color:O},grid:{color:O},ticks:{color:eC(e.background),callback:aC({locale:o,format:a})},legend:{position:n,align:n.includes("right")?"left":"right",margin:Yw(e)},interpolate:jw(e),missing:e.missingValueColor||"#ffffff"}}}function Gw(e,t){const o=t.dataSetsValues[0];return{x:{display:!1},y:{grid:{offset:!1},ticks:{callback:function(e){return hC(this.getLabelForValue(e))}},border:{display:!1}},percentages:{position:"right",border:{display:!1},ticks:{callback:function(e,s,i){const n=o.data?.[s],r=o.data?.[0];return r&&void 0!==n?bn(n/r,{format:"0%",locale:t.locale}):""}},grid:{display:!1}}}}function Ww(e){return"conicConformal"===e?window.ChartGeo.geoConicConformal().rotate([100,0]):e}function qw(e){if(e?.title?.text){const{text:t,color:o,align:s,italic:i,bold:n}=e.title;return{display:!0,text:t,color:o,font:{style:i?"italic":"normal",weight:n?"bold":"normal",size:e.title.fontSize??J},align:"left"===s?"start":"right"===s?"end":"center"}}}function Zw(e,t,o,s){const{useLeftAxis:i,useRightAxis:n}=nC(e);if("left"===t&&!i||"right"===t&&!n)return;const r=eC(e.background);let a;if(a="bottom"===t?e.axesDesign?.x:"left"===t?e.axesDesign?.y:e.axesDesign?.y1,"values"===o){const e=!("right"===t&&i);return{position:t,title:qw(a),grid:{display:e},beginAtZero:!0,stacked:s?.stacked,ticks:{color:r,callback:aC(s)}}}return{ticks:{padding:5,color:r,callback:function(e){return hC(this.getLabelForValue(e))}},grid:{display:!1},stacked:s?.stacked,title:qw(a)}}function jw(e){if(!e.colorScale||"string"==typeof e.colorScale)return e.colorScale||"oranges";const t=[{value:0,color:e.colorScale.minColor}];return e.colorScale.midColor&&t.push({value:.5,color:e.colorScale.midColor}),t.push({value:1,color:e.colorScale.maxColor}),vo(t)}function Yw(e){switch(e.legendPosition){case"top":case"right":return{top:!!e.title.text?X+30:X,left:j,right:j};case"bottom":case"left":case"none":return{left:j,right:j,bottom:Y}}}const Xw={showValues:!1,showLabels:!0,valuesDesign:{align:"center",fontSize:13}};function Kw(e,t){const{axisFormats:o,locale:s}=t;return{horizontal:"horizontal"in e&&e.horizontal,showValues:"showValues"in e&&!!e.showValues,background:e.background,callback:(t,i)=>{const n=function(e,t){if(t.rAxisID)return t.rAxisID;const o="horizontal"in e&&e.horizontal?t.xAxisID:t.yAxisID;return o||"y"}(e,i);return rC(o,s)(t,n)}}}function Jw(e,t){const{axisFormats:o,locale:s}=t;return{callback:rC(o,s),showLabels:e.showLabels??Xw.showLabels,showValues:e.showValues??Xw.showValues,style:{fontSize:e.valuesDesign?.fontSize??Xw.valuesDesign.fontSize,align:e.valuesDesign?.align??Xw.valuesDesign.align,bold:e.valuesDesign?.bold??Xw.valuesDesign.bold,italic:e.valuesDesign?.italic??Xw.valuesDesign.italic,textColor:e.valuesDesign?.color??Xw.valuesDesign.color}}}function Qw(e,t){const{axisFormats:o,locale:s}=t;return{horizontal:!0,showValues:"showValues"in e&&!!e.showValues,background:e.background,callback:(e,t)=>0===(e=Math.abs(Number(e)))?"":rC(o,s)(e,t.xAxisID||"x")}}function eI(e,t){const{axisFormats:o,locale:s,dataSetsValues:i}=t,n=i.reduce(((e,t)=>(e.push((e.at(-1)||-1)+t.data.length+1),e)),[]);return{showValues:"showValues"in e&&!!e.showValues,background:e.background,callback:(t,i,r)=>{const a=i._dataset.data[r],l=a[1]-a[0];let c=l>=0?"+":"";return e.showSubTotals&&n.includes(r)&&"+"===c&&(c=""),`${c}${rC(o,s)(l,i.yAxisID)}`}}}function tI(e){const t=e.title,o=tC(e.background);return{display:!!t.text,text:Vo(t.text),color:t?.color??o,align:"center"===t.align?"center":"right"===t.align?"end":"start",font:{size:e.title.fontSize??K,weight:t.bold?"bold":"normal",style:t.italic?"italic":"normal"},padding:{bottom:"top"===e.legendPosition?0:j}}}const oI='\n<templates>\n <t t-name="o-spreadsheet-CustomTooltip">\n <div\n class="o-chart-custom-tooltip border rounded px-2 py-1 pe-none mw-100 position-absolute text-nowrap shadow opacity-100">\n <table class="overflow-hidden m-0">\n <thead t-if="title">\n <tr>\n <th class="o-tooltip-title align-baseline border-0 text-truncate" t-esc="title" t-attf-style="max-width: {{ labelsMaxWidth }}"/>\n </tr>\n </thead>\n <tbody>\n <tr t-foreach="tooltipItems" t-as="tooltipItem" t-key="tooltipItem_index">\n <td>\n <span\n class="badge ps-2 py-2 rounded-0 align-middle"\n t-attf-style="background-color: {{ tooltipItem.boxColor }}"\n > </span>\n <small\n t-if="tooltipItem.label"\n class="o-tooltip-label d-inline-block text-truncate align-middle smaller ms-2"\n t-esc="tooltipItem.label"\n t-attf-style="max-width: {{ labelsMaxWidth }}"\n />\n </td>\n <td class="o-tooltip-value ps-2 fw-bolder text-end">\n <small class="smaller d-inline-block text-truncate align-middle" t-attf-style="max-width: {{ valuesMaxWidth }}">\n <t t-esc="tooltipItem.value"/>\n <t t-if="tooltipItem.percentage">\n (\n <t t-esc="tooltipItem.percentage"/>\n %)\n </t>\n </small>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n </t>\n</templates>\n';let sI;function iI(e,o={}){return function(e,o={}){sI||(sI=new t.App(t.Component,{templates:oI,translateFn:Vo}));const s=sI.getTemplate(e),i=s(o,{}),n=document.createElement("div");return t.blockDom.mount(i,n),n}(e,o).innerHTML}function nI(e,t){return{enabled:!1,external:mI,callbacks:{title:function(e){return e.some((e=>!dC(e.dataset.xAxisID)))?void 0:""},beforeLabel:e=>e.dataset?.label||e.label,label:function(o){const s=e.horizontal;let i=s?o.parsed.x:o.parsed.y;null==i&&(i=o.parsed);const n=s?o.dataset.xAxisID:o.dataset.yAxisID;return rC(t.axisFormats,t.locale)(i,n)}}}}function rI(e,t){const{axisType:o,locale:s,axisFormats:i}=t,n=i?.x,r={enabled:!1,external:mI,callbacks:{}};return r.callbacks.label="linear"===o?e=>{const t=e.parsed.y;let o=dC(e.dataset.xAxisID)?"":e.parsed.x;"string"==typeof o&&Is(o,s)&&(o=gi(o,s));const r=bn(o,{locale:s,format:n}),a=e.dataset.yAxisID||"y",l=bn(t,{locale:s,format:i?.[a]});return r?`(${r}, ${l})`:`${l}`}:function(e){const t=e.parsed.y,o=e.dataset.yAxisID;return rC(i,s)(t,o)},r.callbacks.beforeLabel=e=>e.dataset?.label||e.label,r.callbacks.title=function(e){return"linear"!==o&&e.some((e=>!dC(e.dataset.xAxisID)))?void 0:""},r}function aI(e,t){const{locale:o,axisFormats:s}=t,i=s?.y||s?.y1;return{enabled:!1,external:mI,callbacks:{title:function(e){return e[0].dataset.label},beforeLabel:e=>e.label||e.dataset.label,label:function(e){const t=function(e,t){const o=e.filter((e=>"number"==typeof e)).reduce(((e,t)=>e+t),0);if(!o)return"";const s=e[t]/o*100;return s.toFixed(2)}(e.dataset.data,e.dataIndex),s=e.parsed.y??e.parsed;return`${bn(s,{format:!i&&s>=1e3?"#,##":i,locale:o})} (${t}%)`}}}}function lI(e,t){const{dataSetsValues:o,locale:s,axisFormats:i,labels:n}=t,r=i?.y||i?.y1,a=o.map((e=>e.label));return{enabled:!1,external:mI,callbacks:{beforeLabel:function(e){const t=n.length?Math.floor(e.dataIndex/n.length):0;return a[t]},label:function(e){const[t,o]=e.raw,i=o-t;return bn(i,{format:!r&&Math.abs(i)>1e3?"#,##":r,locale:s})}}}}function cI(e,t){const o=nI(e,t);return{...o,callbacks:{...o.callbacks,label:e=>{const t={...e,parsed:{y:e.parsed.y,x:Math.abs(e.parsed.x)}};return(o?.callbacks?.label)(t)}}}}function hI(e,t){const{locale:o,axisFormats:s}=t;return{enabled:!1,external:mI,callbacks:{beforeLabel:e=>e.dataset?.label||e.label,label:function(e){return bn(e.parsed.r,{format:s?.r,locale:o})}}}}function dI(e,t){const{locale:o,axisFormats:s}=t,i=s?.y||s?.y1;return{enabled:!1,external:mI,filter:function(e){return void 0!==e.raw.value},callbacks:{beforeLabel:e=>e.raw.feature.properties.name,label:function(e){const t=e.raw.value;return bn(t,{format:!i&&Math.abs(t)>=1e3?"#,##":i,locale:o})}}}}function uI(e,t){return{enabled:!1,external:mI,position:"funnelTooltipPositioner",callbacks:{title:()=>"",beforeLabel:e=>e.label,label:function(e){const o=e.parsed.x,s=e.dataset.xAxisID;return rC(t.axisFormats,t.locale)(o,s)}}}}function gI(e,t){const{locale:o,axisFormats:s}=t,i=s?.y||s?.y1;return{enabled:!1,external:mI,filter:function(e){const t=e.raw;return t?.label!==fC},callbacks:{title:()=>"",beforeLabel:e=>e.raw.groups.join(" / "),label:function(e){const t=e.raw.value;return bn(t,{format:!i&&t>=1e3?"#,##":i,locale:o})}}}}function pI(e,t){const{locale:o,axisFormats:s}=t,i=s?.y;return{enabled:!1,external:mI,filter:(e,t,o)=>t===o.length-1,callbacks:{title:()=>"",beforeLabel:e=>{const t=e.raw._data.children[0];if(!t)return"";const o=[];for(let s=0;s<=e.raw.l;s++)o.push(t[s]);return o.join(" / ")},label:e=>{const t=e.raw.v;return bn(t,{format:!i&&t>=1e3?"#,##":i,locale:o})}}}}function mI({chart:e,tooltip:t}){if(e.canvas.parentNode.querySelector("div.o-chart-custom-tooltip")?.remove(),0===t.opacity||0===t.dataPoints.length)return;const o=t.body.map(((e,o)=>{let s=e.before[0],i=e.lines[0];i||(i=s,s="");const n=t.labelColors[o].backgroundColor;return{label:s,value:i,boxColor:"string"==typeof n?eo(n,1):n}})),s=iI("o-spreadsheet-CustomTooltip",{labelsMaxWidth:Math.floor(.5*e.canvas.clientWidth)+"px",valuesMaxWidth:Math.floor(.25*e.canvas.clientWidth)+"px",title:t.title[0],tooltipItems:o}),i=Object.assign(document.createElement("template"),{innerHTML:s}).content.firstChild;e.canvas.parentNode?.appendChild(i),Object.assign(i.style,{left:fI(e,t,i.clientWidth)+"px",top:Math.floor(t.caretY-i.clientHeight/2)+"px"})}function fI(e,t,o){const s=t.caretX;return s+o>e.chartArea.right?Math.max(0,s-o):s}var vI=Object.freeze({__proto__:null,GHOST_SUNBURST_VALUE:fC,INTERACTIVE_LEGEND_CONFIG:Nw,canChartParseLabels:uw,getBarChartData:tw,getBarChartDatasets:vC,getBarChartLegend:Tw,getBarChartScales:Vw,getBarChartTooltip:nI,getChartColorsGenerator:NC,getChartLabelFormat:Sw,getChartLayout:Ew,getChartShowValues:Kw,getChartTitle:tI,getComboChartDatasets:wC,getComboChartLegend:Ow,getData:fw,getFunnelChartData:aw,getFunnelChartDatasets:EC,getFunnelChartScales:Gw,getFunnelChartTooltip:uI,getFunnelLabelColors:RC,getGeoChartData:rw,getGeoChartDatasets:xC,getGeoChartScales:$w,getGeoChartTooltip:dI,getHierarchalChartData:lw,getLineChartData:sw,getLineChartDatasets:SC,getLineChartLegend:Aw,getLineChartScales:Lw,getLineChartTooltip:rI,getPieChartData:iw,getPieChartDatasets:yC,getPieChartLegend:Dw,getPieChartTooltip:aI,getPyramidChartData:ow,getPyramidChartScales:Bw,getPyramidChartShowValues:Qw,getPyramidChartTooltip:cI,getRadarChartData:nw,getRadarChartDatasets:IC,getRadarChartLegend:Pw,getRadarChartScales:zw,getRadarChartTooltip:hI,getScatterChartDatasets:CC,getScatterChartLegend:_w,getScatterChartScales:Hw,getSunburstChartDatasets:TC,getSunburstChartLegend:Mw,getSunburstChartTooltip:gI,getSunburstShowValues:Jw,getTopPaddingForDashboard:xw,getTreeMapChartDatasets:OC,getTreeMapChartTooltip:pI,getTrendDatasetForBarChart:cw,getTrendDatasetForLineChart:hw,getWaterfallChartLegend:Fw,getWaterfallChartScales:Uw,getWaterfallChartShowValues:eI,getWaterfallChartTooltip:lI,getWaterfallDatasetAndLabels:bC,makeDatasetsCumulative:Iw});class bI extends $C{dataSets;labelRange;background;legendPosition;stacked;aggregated;type="bar";dataSetsHaveTitle;dataSetDesign;axesDesign;horizontal;showValues;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.horizontal=e.horizontal,this.showValues=e.showValues}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,stacked:e.stacked??!1,aggregated:e.aggregated??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"bar",labelRange:e.auxiliaryRange||void 0,axesDesign:e.axesDesign,showValues:e.showValues}}getContextCreation(){const e=[];for(const[t,o]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(o.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new bI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new bI(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=[];for(const[t,i]of e.entries())s.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,o||this.sheetId)});return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated,axesDesign:this.axesDesign,horizontal:this.horizontal,showValues:this.showValues}}getDefinitionForExcel(){const e=this.dataSets.map((e=>KS(this.getters,e))).filter((e=>""!==e.range&&e.range!==Js.InvalidReference)),t=JS(this.getters,this.labelRange,iC(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle)),o=this.getDefinition();return{...o,backgroundColor:wy(this.background||m),fontColor:wy(eC(this.background)),dataSets:e,labelRange:t,verticalAxis:nC(o)}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new bI(i,this.sheetId,this.getters)}}function SI(e,t){const o=e.getDefinition(),s=tw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"bar",data:{labels:s.labels,datasets:vC(o,s)},options:{...Ly,indexAxis:e.horizontal?"y":"x",layout:Ew(0,s),scales:Vw(o,s),plugins:{title:tI(o),legend:Tw(o),tooltip:nI(o,s),chartShowValuesPlugin:Kw(o,s)}}},background:e.background||m}}const CI=new n;CI.add("animatedBackgroundColorChange",{id:"animatedBackgroundColorChange",easingFn:"easeOutCubic",hasAnimation:(e,t)=>e?.style?.fillColor!==t?.style?.fillColor,updateAnimation:function(e,t,o,s){const i=vo([{value:0,color:o.style.fillColor||"#ffffff"},{value:1,color:s.style.fillColor||"#ffffff"}]);t.style.fillColor=i(yI[this.easingFn](e))}}),CI.add("animatedTextColorChange",{id:"animatedTextColorChange",easingFn:"easeOutCubic",hasAnimation:(e,t)=>e?.style?.textColor!==t?.style?.textColor,updateAnimation:function(e,t,o,s){const i=vo([{value:0,color:o.style.textColor||"#000000"},{value:1,color:s.style.textColor||"#000000"}]);t.style.textColor=i(yI[this.easingFn](e))}}),CI.add("animatedDataBar",{id:"animatedDataBar",easingFn:"easeOutCubic",hasAnimation:(e,t)=>e?.dataBarFill?.percentage!==t?.dataBarFill?.percentage,updateAnimation:function(e,t,o,s){const i=o?.dataBarFill?.percentage||0,n=i+((s?.dataBarFill?.percentage||0)-i)*yI[this.easingFn](e);t.dataBarFill={color:s.dataBarFill?.color||o.dataBarFill?.color||"#ffffff",percentage:n}}}),CI.add("textFadeIn",{id:"textFadeIn",easingFn:"easeInCubic",hasAnimation:(e,t)=>{const o=e?.content?.textLines?.join("\n"),s=t?.content?.textLines?.join("\n");return Boolean(!o&&s)},updateAnimation:function(e,t,o,s){t.textOpacity=yI[this.easingFn](e)}}),CI.add("textFadeOut",{id:"textFadeOut",easingFn:"easeOutCubic",hasAnimation:(e,t)=>{const o=e?.content?.textLines?.join("\n"),s=t?.content?.textLines?.join("\n");return Boolean(o&&!s)},updateAnimation:function(e,t,o,s){const i=1-yI[this.easingFn](e),n={...o.style};delete n.fillColor,t.textOpacity=i,t.content=o.content,t.clipRect=o.clipRect,Object.assign(t.style,n)}}),CI.add("iconFadeIn",{id:"iconFadeIn",easingFn:"easeInCubic",hasAnimation:(e,t)=>Boolean(!e?.icons?.left&&t?.icons?.left||!e?.icons?.right&&t?.icons?.right||!e?.icons?.center&&t?.icons?.center),updateAnimation:function(e,t,o,s){const i=yI[this.easingFn](e);t.icons.left&&s.icons.left&&!o.icons.left&&(t.icons.left.opacity=i),t.icons.right&&s.icons.right&&!o.icons.right&&(t.icons.right.opacity=i),t.icons.center&&s.icons.center&&!o.icons.center&&(t.icons.center.opacity=i)}}),CI.add("iconFadeOut",{id:"iconFadeOut",easingFn:"easeOutCubic",hasAnimation:(e,t)=>Boolean(e?.icons?.left&&!t?.icons?.left||e?.icons?.right&&!t?.icons?.right||e?.icons?.center&&!t?.icons?.center),updateAnimation:function(e,t,o,s){const i=1-yI[this.easingFn](e);t.icons||(t.icons={}),o.icons.left&&!s.icons.left&&(t.icons.left={...o.icons.left,opacity:i}),o.icons.right&&!s.icons.right&&(t.icons.right={...o.icons.right,opacity:i}),o.icons.center&&!s.icons.center&&(t.icons.center={...o.icons.center,opacity:i})}}),CI.add("textChange",{id:"textChange",easingFn:"easeOutCubic",hasAnimation:(e,t)=>{const o=e?.content?.textLines?.join("\n"),s=t?.content?.textLines?.join("\n");return Boolean(o&&s&&(o!==s||xI(t,e)))},updateAnimation:function(e,t,o,s){const i=yI[this.easingFn](e),n=s.y+(i-1)*s.height,r=s.y+i*s.height,a=xI(s,o),l={id:s.id+"-text-slide-in",x:s.x,y:n,width:s.width,height:s.height,style:{...s.style},skipCellGridLines:!0,content:s.content?{...s.content}:void 0,clipRect:s.clipRect||{...s,x:Math.max(0,s.x-(s.content?.width||0)),width:s.width+2*(s.content?.width||0)},icons:a?II(s.icons,s):wI(s.icons)},c={id:o.id+"-text-slide-out",x:s.x,y:r,width:s.width,height:s.height,style:{...o.style},skipCellGridLines:!0,content:o.content?{...o.content}:void 0,clipRect:o.clipRect||{...s,x:Math.max(0,s.x-(o.content?.width||0)),width:s.width+2*(o.content?.width||0)},icons:a?II(o.icons,s):wI(o.icons)};if(s.content&&o.content&&l.content&&c.content){const e=s.content.y+(i-1)*s.height,t=s.content.y+i*s.height;l.content.y=e,c.content.y=t}return c.style.fillColor=l.style.fillColor=void 0,t.content=void 0,t.icons=a?{}:t.icons,{newBoxes:[l,c]}}}),CI.add("borderFadeIn",{id:"borderFadeIn",easingFn:"easeInCubic",hasAnimation:(e,t)=>Boolean(!e?.border?.bottom&&t?.border?.bottom||!e?.border?.top&&t?.border?.top||!e?.border?.left&&t?.border?.left||!e?.border?.right&&t?.border?.right),updateAnimation:function(e,t,o,s){const i=yI[this.easingFn](e);t.border?.top&&s.border?.top&&!o.border?.top&&(t.border.top.opacity=i),t.border?.bottom&&s.border?.bottom&&!o.border?.bottom&&(t.border.bottom.opacity=i),t.border?.left&&s.border?.left&&!o.border?.left&&(t.border.left.opacity=i),t.border?.right&&s.border?.right&&!o.border?.right&&(t.border.right.opacity=i)}}),CI.add("borderFadeOut",{id:"borderFadeOut",easingFn:"easeOutCubic",hasAnimation:(e,t)=>Boolean(e?.border?.bottom&&!t?.border?.bottom||e?.border?.top&&!t?.border?.top||e?.border?.left&&!t?.border?.left||e?.border?.right&&!t?.border?.right),updateAnimation:function(e,t,o,s){const i=1-yI[this.easingFn](e);t.border||(t.border={}),o.border?.top&&!s.border?.top&&(t.border.top={...o.border.top,opacity:i}),o.border?.bottom&&!s.border?.bottom&&(t.border.bottom={...o.border.bottom,opacity:i}),o.border?.left&&!s.border?.left&&(t.border.left={...o.border.left,opacity:i}),o.border?.right&&!s.border?.right&&(t.border.right={...o.border.right,opacity:i})}}),CI.add("borderColorChange",{id:"borderColorChange",easingFn:"easeOutCubic",hasAnimation:(e,t)=>{const o=e?.border,s=t?.border;return!(!o||!s)&&Boolean(o.bottom?.color!==s.bottom?.color||o.top?.color!==s.top?.color||o.left?.color!==s.left?.color||o.right?.color!==s.right?.color)},updateAnimation:function(e,t,o,s){const i=i=>{const n=o?.border?.[i],r=s?.border?.[i],a=t.border?.[i];if(n&&r&&a){const t=vo([{value:0,color:n.color||"#000000"},{value:1,color:r.color||"#000000"}]);a.color=t(yI[this.easingFn](e))}};i("top"),i("bottom"),i("left"),i("right")}}),CI.add("iconChange",{id:"iconChange",easingFn:"easeOutCubic",hasAnimation:(e,t)=>!xI(t,e)&&Boolean(e?.icons?.center?.svg?.name!==t?.icons?.center?.svg?.name||e?.icons?.left?.svg?.name!==t?.icons?.left?.svg?.name||e?.icons?.right?.svg?.name!==t?.icons?.right?.svg?.name),updateAnimation:function(e,t,o,s){const i=yI[this.easingFn](e),n=s.y+(i-1)*s.height,r=s.y+i*s.height,a=[],l=e=>{const i=o.icons?.[e],l=s.icons?.[e],c={id:`${s.id}-icon-${e}-slide-in`,style:{verticalAlign:s.style.verticalAlign},x:s.x,y:n,width:s.width,height:s.height,skipCellGridLines:!0,icons:{[e]:{...l,clipRect:s}}},h={id:`${s.id}-icon-${e}-slide-out`,style:{verticalAlign:o.style.verticalAlign},x:s.x,y:r,width:s.width,height:s.height,skipCellGridLines:!0,icons:{[e]:{...i,clipRect:s}}};t.icons[e]=wI(s.icons)[e],a.push(c,h)};return l("left"),l("right"),l("center"),{newBoxes:a}}});const yI={linear:e=>e,easeInCubic:e=>e*e*e,easeOutCubic:e=>(e-=1)*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeOutQuart:e=>-((e-=1)*e*e*e-1)};function wI(e){return{left:e.left?{...e.left,svg:void 0}:void 0,right:e.right?{...e.right,svg:void 0}:void 0,center:e.center?{...e.center,svg:void 0}:void 0}}function II(e,t){return{left:e.left?{...e.left,clipRect:t}:void 0,right:e.right?{...e.right,clipRect:t}:void 0,center:e.center?{...e.center,clipRect:t}:void 0}}function xI(e,t){const o=(e,t)=>t&&e?!!(e.horizontalAlign!==t.horizontalAlign||e.size!==t.size||e.margin!==t.margin||e.svg&&!t.svg||!e.svg&&t.svg):!!(e&&!t||!e&&t);return o(e?.icons.left,t?.icons.left)||o(e?.icons.right,t?.icons.right)||o(e?.icons.center,t?.icons.center)}class EI extends t.Component{static template="o-spreadsheet-GaugeChartComponent";static props={figureUI:Object,isFullScreen:{type:Boolean,optional:!0}};canvas=t.useRef("chartContainer");animationStore;get runtime(){return this.env.model.getters.getChartRuntime(this.props.figureUI.id)}setup(){this.env.model.getters.isDashboard()&&(this.animationStore=oh(yh));let e,o=null;t.useEffect((()=>(this.env.isDashboard()&&void 0===e&&"gauge"!==this.animationStore?.animationPlayed[this.animationFigureId]||this.env.isDashboard()&&void 0!==e&&!mt(this.runtime,e)?(o=this.drawGaugeWithAnimation(),this.animationStore?.disableAnimationForChart(this.animationFigureId,"gauge")):Oy(this.canvasEl,this.runtime),e=this.runtime,()=>o?.stop())),(()=>{const e=this.canvasEl.getBoundingClientRect();return[e.width,e.height,this.runtime,this.canvas.el,window.devicePixelRatio]}))}drawGaugeWithAnimation(){Oy(this.canvasEl,{...this.runtime,animationValue:0});const e=this.runtime.gaugeValue?.value||0,t=this.runtime.maxValue.value,o=Math.sign(e)*Math.min(Math.abs(e),Math.abs(t));if(0===o)return null;const s=this.runtime.minValue.value,i=new RI(s,o,1e3,(e=>Oy(this.canvasEl,{...this.runtime,animationValue:e})));return i.start(),i}get canvasEl(){return this.canvas.el}get animationFigureId(){return this.props.isFullScreen?this.props.figureUI.id+"-fullscreen":this.props.figureUI.id}}class RI{startValue;endValue;duration;callback;startTime=void 0;animationFrameId=null;constructor(e,t,o,s){this.startValue=e,this.endValue=t,this.duration=o,this.callback=s}start(){this.animationFrameId=requestAnimationFrame(this.animate.bind(this))}stop(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}animate(e){this.startTime||(this.startTime=e);const t=e-this.startTime,o=Math.min(t/this.duration,1),s=this.startValue+(this.endValue-this.startValue)*yI.easeOutQuart(o);this.callback(s),o<1?this.animationFrameId=requestAnimationFrame(this.animate.bind(this)):this.stop()}}class TI extends $C{dataSets;labelRange;background;legendPosition;aggregated;dataSetsHaveTitle;dataSetDesign;axesDesign;type="combo";showValues;hideDataMarkers;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.showValues=e.showValues,this.hideDataMarkers=e.hideDataMarkers}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}getContextCreation(){const e=[];for(const[t,o]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(o.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=[];for(const[t,i]of e.entries())s.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,o||this.sheetId),type:this.dataSetDesign?.[t]?.type??(t?"line":"bar")});return{type:"combo",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,aggregated:this.aggregated,axesDesign:this.axesDesign,showValues:this.showValues,hideDataMarkers:this.hideDataMarkers}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>KS(this.getters,e))).filter((e=>""!==e.range&&e.range!==Js.InvalidReference)),t=JS(this.getters,this.labelRange,iC(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle)),o=this.getDefinition();return{...o,backgroundColor:wy(this.background||m),fontColor:wy(eC(this.background)),dataSets:e,labelRange:t,verticalAxis:nC(o)}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new TI(i,this.sheetId,this.getters)}static getDefinitionFromContextCreation(e){const t=(e.range??[]).map(((e,t)=>({...e,type:t?"line":"bar"})));return{background:e.background,dataSets:t,dataSetsHaveTitle:e.dataSetsHaveTitle??!1,aggregated:e.aggregated,legendPosition:e.legendPosition??"top",title:e.title||{text:""},labelRange:e.auxiliaryRange||void 0,type:"combo",axesDesign:e.axesDesign,showValues:e.showValues,hideDataMarkers:e.hideDataMarkers}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new TI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new TI(t,e,this.getters)}}class AI extends $C{dataSets;labelRange;background;legendPosition;aggregated;type="funnel";dataSetsHaveTitle;dataSetDesign;axesDesign;horizontal=!0;showValues;funnelColors;cumulative;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.showValues=e.showValues,this.horizontal=!0,this.funnelColors=e.funnelColors,this.cumulative=e.cumulative}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,aggregated:e.aggregated??!1,legendPosition:"none",title:e.title||{text:""},type:"funnel",labelRange:e.auxiliaryRange||void 0,showValues:e.showValues,axesDesign:e.axesDesign,funnelColors:e.funnelColors,horizontal:!0,cumulative:e.cumulative}}getContextCreation(){const e=[];for(const[t,o]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(o.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new AI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new AI(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=[];for(const[t,i]of e.entries())s.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,o||this.sheetId)});return{type:"funnel",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,aggregated:this.aggregated,horizontal:this.horizontal,axesDesign:this.axesDesign,showValues:this.showValues,funnelColors:this.funnelColors,cumulative:this.cumulative}}getDefinitionForExcel(){}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new AI(i,this.sheetId,this.getters)}}function DI(e){return e.dataRange&&!Xr.test(e.dataRange)?"InvalidGaugeDataRange":"Success"}function _I(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):"Success"),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):"Success"))}function OI(e,t){if(""===e)switch(t){case"rangeMin":return"EmptyGaugeRangeMin";case"rangeMax":return"EmptyGaugeRangeMax"}return"Success"}function FI(e,t){if(e.startsWith("="))return"Success";if(isNaN(e))switch(t){case"rangeMin":return"GaugeRangeMinNaN";case"rangeMax":return"GaugeRangeMaxNaN";case"lowerInflectionPointValue":return"GaugeLowerInflectionPointNaN";case"upperInflectionPointValue":return"GaugeUpperInflectionPointNaN"}return"Success"}class PI extends $C{dataRange;sectionRule;background;type="gauge";constructor(e,t,o){super(e,t,o),this.dataRange=fa(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,DI,e.chainValidations(_I(OI,e.batchValidations),_I(FI,e.batchValidations)),e.chainValidations((o=FI,(0,e.batchValidations)((e=>e.sectionRule?o(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):"Success"),(e=>e.sectionRule?o(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):"Success")))));var o}static transformDefinition(e,t,o){let s;if(t.dataRange){const i=US(e,t.dataRange,o);i!==Js.InvalidReference&&(s=i)}return{...t,dataRange:s}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||{text:""},type:"gauge",dataRange:e.range?e.range[0].dataRange:void 0,sectionRule:{colors:{lowerColor:"#EA6175",middleColor:"#FFD86D",upperColor:"#43C5B1"},rangeMin:"0",rangeMax:"100",lowerInflectionPoint:{type:"percentage",value:"15",operator:"<="},upperInflectionPoint:{type:"percentage",value:"40",operator:"<="}}}}duplicateInDuplicatedSheet(e){const t=ZS(this.sheetId,e,this.dataRange),o=VI(this.sectionRule,(t=>this.getters.copyFormulaStringForSheet(this.sheetId,e,t,"moveReference"))),s=this.getDefinitionWithSpecificRanges(t,o,e);return new PI(s,e,this.getters)}copyInSheetId(e){const t=VI(this.sectionRule,(t=>this.getters.copyFormulaStringForSheet(this.sheetId,e,t,"keepSameReference"))),o=this.getDefinitionWithSpecificRanges(this.dataRange,t,e);return new PI(o,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.dataRange,this.sectionRule)}getDefinitionWithSpecificRanges(e,t,o){return{background:this.background,sectionRule:t,title:this.title,type:"gauge",dataRange:e?this.getters.getRangeString(e,o||this.sheetId):void 0}}getDefinitionForExcel(){}getContextCreation(){return{...this,range:this.dataRange?[{dataRange:this.getters.getRangeString(this.dataRange,this.sheetId)}]:void 0}}updateRanges(e){const t=jS(this.dataRange,e),o=VI(this.sectionRule,(t=>this.getters.adaptFormulaStringDependencies(this.sheetId,t,e))),s=this.getDefinitionWithSpecificRanges(t,o);return new PI(s,this.sheetId,this.getters)}}function MI(e,t){const o=t.getLocale(),s=e.sectionRule.colors;let i,n,r;const a=e.dataRange;if(void 0!==a){const e=t.getEvaluatedCell({sheetId:a.sheetId,col:a.zone.left,row:a.zone.top});e.type===Ts.number&&(i=e.value,n=e.formattedValue,r=e.format)}let l=kI(e.sheetId,e.sectionRule.rangeMin,t),c=kI(e.sheetId,e.sectionRule.rangeMax,t);if(void 0===l||void 0===c)return function(e,t){return{background:t.getStyleOfSingleCellChart(e.background,e.dataRange).background,title:e.title??{text:""},minValue:{value:0,label:""},maxValue:{value:100,label:""},gaugeValue:{value:0,label:Js.GenericError},inflectionValues:[],colors:[]}}(e,t);c<l&&([l,c]=[c,l]);const h=e.sectionRule.lowerInflectionPoint,d=e.sectionRule.upperInflectionPoint,u=NI(e.sheetId,e.sectionRule.lowerInflectionPoint,l,c,t),g=NI(e.sheetId,e.sectionRule.upperInflectionPoint,l,c,t),p=[],m=[];return void 0!==u&&(p.push({value:u,label:bn(u,{locale:o,format:r}),operator:h.operator}),m.push(s.lowerColor)),void 0!==g&&g!==u&&(p.push({value:g,label:bn(g,{locale:o,format:r}),operator:d.operator}),m.push(s.middleColor)),void 0!==g&&void 0!==u&&u>g&&(p.reverse(),m.reverse()),m.push(s.upperColor),{background:t.getStyleOfSingleCellChart(e.background,a).background,title:{...e.title,text:Vo(e.title.text??"")},minValue:{value:l,label:bn(l,{locale:o,format:r})},maxValue:{value:c,label:bn(c,{locale:o,format:r})},gaugeValue:void 0!==i&&n?{value:i,label:n}:void 0,inflectionValues:p,colors:m}}function NI(e,t,o,s,i){const n=kI(e,t.value,i);if(void 0===n)return;return Ze("number"===t.type?n:o+(s-o)*n/100,o,s)}function kI(e,t,o){const s=o.evaluateFormula(e,t);return Ws(s)?void 0:pi(s,o.getLocale())}function VI(e,t){return{...e,rangeMin:t(e.rangeMin),rangeMax:t(e.rangeMax),lowerInflectionPoint:{...e.lowerInflectionPoint,value:t(e.lowerInflectionPoint.value)},upperInflectionPoint:{...e.upperInflectionPoint,value:t(e.upperInflectionPoint.value)}}}class LI extends $C{dataSets;labelRange;background;legendPosition;type="geo";dataSetsHaveTitle;dataSetDesign;colorScale;missingValueColor;region;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.colorScale=e.colorScale,this.missingValueColor=e.missingValueColor,this.region=e.region}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"geo",labelRange:e.auxiliaryRange||void 0}}getContextCreation(){const e=[];for(const[t,o]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(o.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new LI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new LI(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=[];for(const[t,i]of e.entries())s.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,o||this.sheetId)});return{type:"geo",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,colorScale:this.colorScale,missingValueColor:this.missingValueColor,region:this.region}}getDefinitionForExcel(){}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new LI(i,this.sheetId,this.getters)}}class HI extends $C{dataSets;labelRange;background;legendPosition;labelsAsText;stacked;aggregated;type="line";dataSetsHaveTitle;cumulative;dataSetDesign;axesDesign;fillArea;showValues;hideDataMarkers;constructor(e,t,o){super(e,t,o),this.dataSets=YS(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(this.getters,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.stacked=e.stacked,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.cumulative=e.cumulative,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.fillArea=e.fillArea,this.showValues=e.showValues,this.hideDataMarkers=e.hideDataMarkers}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static transformDefinition(e,t,o){return QS(e,t,o)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,labelsAsText:e.labelsAsText??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"line",labelRange:e.auxiliaryRange||void 0,stacked:e.stacked??!1,aggregated:e.aggregated??!1,cumulative:e.cumulative??!1,axesDesign:e.axesDesign,fillArea:e.fillArea,showValues:e.showValues,hideDataMarkers:e.hideDataMarkers}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=[];for(const[t,i]of e.entries())s.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,o||this.sheetId)});return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated,cumulative:this.cumulative,axesDesign:this.axesDesign,fillArea:this.fillArea,showValues:this.showValues,hideDataMarkers:this.hideDataMarkers}}getContextCreation(){const e=[];for(const[t,o]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(o.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new HI(i,this.sheetId,this.getters)}getDefinitionForExcel(){const e=this.dataSets.map((e=>KS(this.getters,e))).filter((e=>""!==e.range&&e.range!==Js.InvalidReference)),t=JS(this.getters,this.labelRange,iC(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle)),o=this.getDefinition();return{...o,backgroundColor:wy(this.background||m),fontColor:wy(eC(this.background)),dataSets:e,labelRange:t,verticalAxis:nC(o)}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new HI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new HI(t,e,this.getters)}}function UI(e,t){const o=e.getDefinition(),s=sw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"line",data:{labels:s.labels,datasets:SC(o,s)},options:{...Ly,layout:Ew(0,s),scales:Lw(o,s),plugins:{title:tI(o),legend:Aw(o),tooltip:rI(0,s),chartShowValuesPlugin:Kw(o,s)}}},background:e.background||m}}class BI extends $C{dataSets;labelRange;background;legendPosition;type="pie";aggregated;dataSetsHaveTitle;isDoughnut;showValues;pieHolePercentage;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.isDoughnut=e.isDoughnut,this.showValues=e.showValues,this.pieHolePercentage=e.pieHolePercentage}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"pie",labelRange:e.auxiliaryRange||void 0,aggregated:e.aggregated??!1,isDoughnut:!1,showValues:e.showValues}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){return{...this,range:this.dataSets.map((e=>({dataRange:this.getters.getRangeString(e.dataRange,this.sheetId)}))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinitionWithSpecificDataSets(e,t,o){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>({dataRange:this.getters.getRangeString(e.dataRange,o||this.sheetId)}))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,aggregated:this.aggregated,isDoughnut:this.isDoughnut,showValues:this.showValues,pieHolePercentage:this.pieHolePercentage}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new BI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new BI(t,e,this.getters)}getDefinitionForExcel(){const e=this.dataSets.map((e=>KS(this.getters,e))).filter((e=>""!==e.range&&e.range!==Js.InvalidReference)),t=JS(this.getters,this.labelRange,iC(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:wy(this.background||m),fontColor:wy(eC(this.background)),dataSets:e,labelRange:t}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new BI(i,this.sheetId,this.getters)}}function zI(e,t){const o=e.getDefinition(),s=iw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:e.isDoughnut?"doughnut":"pie",data:{labels:s.labels,datasets:yC(o,s)},options:{...Ly,cutout:e.isDoughnut&&void 0!==o.pieHolePercentage?o.pieHolePercentage+"%":void 0,layout:Ew(0,s),plugins:{title:tI(o),legend:Dw(o,s),tooltip:aI(0,s),chartShowValuesPlugin:Kw(o,s)}}},background:e.background||m}}class $I extends $C{dataSets;labelRange;background;legendPosition;aggregated;type="pyramid";dataSetsHaveTitle;dataSetDesign;axesDesign;horizontal=!0;stacked=!0;showValues;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.showValues=e.showValues}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,aggregated:e.aggregated??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"pyramid",labelRange:e.auxiliaryRange||void 0,axesDesign:e.axesDesign,horizontal:!0,stacked:!0,showValues:e.showValues}}getContextCreation(){const e=[];for(const[t,o]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(o.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new $I(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new $I(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=[];for(const[t,i]of e.entries())s.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,o||this.sheetId)});return{type:"pyramid",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,aggregated:this.aggregated,axesDesign:this.axesDesign,horizontal:!0,stacked:!0,showValues:this.showValues}}getDefinitionForExcel(){}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new $I(i,this.sheetId,this.getters)}}class GI extends $C{dataSets;labelRange;background;legendPosition;stacked;aggregated;type="radar";dataSetsHaveTitle;dataSetDesign;fillArea;showValues;hideDataMarkers;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.fillArea=e.fillArea,this.showValues=e.showValues,this.hideDataMarkers=e.hideDataMarkers}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,stacked:e.stacked??!1,aggregated:e.aggregated??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"radar",labelRange:e.auxiliaryRange||void 0,fillArea:e.fillArea??!1,showValues:e.showValues??!1,hideDataMarkers:e.hideDataMarkers}}getContextCreation(){const e=[];for(const[t,o]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(o.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new GI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new GI(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=[];for(const[t,i]of e.entries())s.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,o||this.sheetId)});return{type:"radar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated,fillArea:this.fillArea,showValues:this.showValues,hideDataMarkers:this.hideDataMarkers}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>KS(this.getters,e))).filter((e=>""!==e.range&&e.range!==Js.InvalidReference)),t=JS(this.getters,this.labelRange,iC(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:wy(this.background||m),fontColor:wy(eC(this.background)),dataSets:e,labelRange:t}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new GI(i,this.sheetId,this.getters)}}class WI extends $C{dataSets;labelRange;background;legendPosition;labelsAsText;aggregated;type="scatter";dataSetsHaveTitle;dataSetDesign;axesDesign;showValues;constructor(e,t,o){super(e,t,o),this.dataSets=YS(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(this.getters,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.showValues=e.showValues}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static transformDefinition(e,t,o){return QS(e,t,o)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,labelsAsText:e.labelsAsText??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"scatter",labelRange:e.auxiliaryRange||void 0,aggregated:e.aggregated??!1,axesDesign:e.axesDesign,showValues:e.showValues}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=[];for(const[t,i]of e.entries())s.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,o||this.sheetId)});return{type:"scatter",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,aggregated:this.aggregated,axesDesign:this.axesDesign,showValues:this.showValues}}getContextCreation(){const e=[];for(const[t,o]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(o.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new WI(i,this.sheetId,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>KS(this.getters,e))).filter((e=>""!==e.range)),t=JS(this.getters,this.labelRange,iC(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle)),o=this.getDefinition();return{...o,backgroundColor:wy(this.background||m),fontColor:wy(eC(this.background)),dataSets:e,labelRange:t,verticalAxis:nC(o)}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new WI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new WI(t,e,this.getters)}}class qI extends $C{dataSets;labelRange;background;legendPosition;type="sunburst";dataSetsHaveTitle;showValues;showLabels;valuesDesign;groupColors;pieHolePercentage;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.showValues=e.showValues,this.showLabels=e.showLabels,this.valuesDesign=e.valuesDesign,this.groupColors=e.groupColors,this.pieHolePercentage=e.pieHolePercentage}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static getDefinitionFromContextCreation(e){const t=[];return e.hierarchicalRanges?.length?t.push(...e.hierarchicalRanges):e.auxiliaryRange&&t.push({...e.range?.[0],dataRange:e.auxiliaryRange}),{background:e.background,dataSets:t,dataSetsHaveTitle:e.dataSetsHaveTitle??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"sunburst",labelRange:e.range?.[0]?.dataRange,showValues:e.showValues,showLabels:e.showLabels,valuesDesign:e.valuesDesign,groupColors:e.groupColors}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){const e=this.dataSets.at(-1)?.dataRange;return{...this,range:this.labelRange?[{dataRange:this.getters.getRangeString(this.labelRange,this.sheetId)}]:[],auxiliaryRange:e?this.getters.getRangeString(e,this.sheetId):void 0,hierarchicalRanges:this.dataSets.map((e=>({dataRange:this.getters.getRangeString(e.dataRange,this.sheetId)})))}}getDefinitionWithSpecificDataSets(e,t,o){return{type:"sunburst",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>({dataRange:this.getters.getRangeString(e.dataRange,o||this.sheetId)}))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,showValues:this.showValues,showLabels:this.showLabels,valuesDesign:this.valuesDesign,groupColors:this.groupColors,pieHolePercentage:this.pieHolePercentage}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new qI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new qI(t,e,this.getters)}getDefinitionForExcel(){}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new qI(i,this.sheetId,this.getters)}}class ZI extends $C{static defaults={background:m,legendPosition:"top",dataSetsHaveTitle:!1,showHeaders:!0,headersColor:"#000000"};dataSets;labelRange;background;legendPosition;type="treemap";dataSetsHaveTitle;showHeaders;headerDesign;showValues;showLabels;valuesDesign;coloringOptions;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.showHeaders=e.showHeaders,this.headerDesign=e.headerDesign,this.showValues=e.showValues,this.showLabels=e.showLabels,this.valuesDesign=e.valuesDesign,this.coloringOptions=e.coloringOptions}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static getDefinitionFromContextCreation(e){const t=[];return e.hierarchicalRanges?.length?t.push(...e.hierarchicalRanges):e.auxiliaryRange&&t.push({...e.range?.[0],dataRange:e.auxiliaryRange}),{background:e.background,dataSets:t,dataSetsHaveTitle:e.dataSetsHaveTitle??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"treemap",labelRange:e.range?.[0]?.dataRange,showValues:e.showValues,showHeaders:e.showHeaders,headerDesign:e.headerDesign,showLabels:e.showLabels,valuesDesign:e.valuesDesign,coloringOptions:e.treemapColoringOptions}}getContextCreation(){const e=this.dataSets.at(-1)?.dataRange;return{...this,range:this.labelRange?[{dataRange:this.getters.getRangeString(this.labelRange,this.sheetId)}]:[],auxiliaryRange:e?this.getters.getRangeString(e,this.sheetId):void 0,hierarchicalRanges:this.dataSets.map((e=>({dataRange:this.getters.getRangeString(e.dataRange,this.sheetId)})))}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new ZI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new ZI(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=e.map((e=>({dataRange:this.getters.getRangeString(e.dataRange,o||this.sheetId)})));return{type:"treemap",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,showValues:this.showValues,showHeaders:this.showHeaders,headerDesign:this.headerDesign,showLabels:this.showLabels,valuesDesign:this.valuesDesign,coloringOptions:this.coloringOptions}}getDefinitionForExcel(){}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new ZI(i,this.sheetId,this.getters)}}class jI extends $C{dataSets;labelRange;background;verticalAxisPosition;legendPosition;aggregated;type="waterfall";dataSetsHaveTitle;showSubTotals;firstValueAsSubtotal;showConnectorLines;positiveValuesColor;negativeValuesColor;subTotalValuesColor;dataSetDesign;axesDesign;showValues;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.showSubTotals=e.showSubTotals,this.showConnectorLines=e.showConnectorLines,this.positiveValuesColor=e.positiveValuesColor,this.negativeValuesColor=e.negativeValuesColor,this.subTotalValuesColor=e.subTotalValuesColor,this.firstValueAsSubtotal=e.firstValueAsSubtotal,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.showValues=e.showValues}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,aggregated:e.aggregated??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"waterfall",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0,showSubTotals:e.showSubTotals??!1,showConnectorLines:e.showConnectorLines??!0,firstValueAsSubtotal:e.firstValueAsSubtotal??!1,axesDesign:e.axesDesign,showValues:e.showValues}}getContextCreation(){const e=[];for(const[t,o]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(o.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new jI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new jI(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=[];for(const[t,i]of e.entries())s.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,o||this.sheetId)});return{type:"waterfall",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,aggregated:this.aggregated,showSubTotals:this.showSubTotals,showConnectorLines:this.showConnectorLines,positiveValuesColor:this.positiveValuesColor,negativeValuesColor:this.negativeValuesColor,subTotalValuesColor:this.subTotalValuesColor,firstValueAsSubtotal:this.firstValueAsSubtotal,axesDesign:this.axesDesign,showValues:this.showValues}}getDefinitionForExcel(){}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new jI(i,this.sheetId,this.getters)}}function YI(e,t){const o=e.getDefinition(),s=tw(o,e.dataSets,e.labelRange,t),{labels:i,datasets:n}=bC(o,s);return{chartJsConfig:{type:"bar",data:{labels:i,datasets:n},options:{...Ly,layout:Ew(0,s),scales:Uw(o,s),plugins:{title:tI(o),legend:Fw(o),tooltip:lI(0,s),chartShowValuesPlugin:eI(o,s),waterfallLinesPlugin:{showConnectorLines:o.showConnectorLines}}}},background:e.background||m}}const XI=new n;XI.add("bar",{match:e=>"bar"===e,createChart:(e,t,o)=>new bI(e,t,o),getChartRuntime:SI,validateChartDefinition:bI.validateChartDefinition,transformDefinition:bI.transformDefinition,getChartDefinitionFromContextCreation:bI.getDefinitionFromContextCreation,sequence:10}),XI.add("combo",{match:e=>"combo"===e,createChart:(e,t,o)=>new TI(e,t,o),getChartRuntime:function(e,t){const o=e.getDefinition(),s=tw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"bar",data:{labels:s.labels,datasets:wC(o,s)},options:{...Ly,layout:Ew(0,s),scales:Vw(o,s),plugins:{title:tI(o),legend:Ow(o),tooltip:nI(o,s),chartShowValuesPlugin:Kw(o,s)}}},background:e.background||m}},validateChartDefinition:TI.validateChartDefinition,transformDefinition:TI.transformDefinition,getChartDefinitionFromContextCreation:TI.getDefinitionFromContextCreation,sequence:15}),XI.add("line",{match:e=>"line"===e,createChart:(e,t,o)=>new HI(e,t,o),getChartRuntime:UI,validateChartDefinition:HI.validateChartDefinition,transformDefinition:HI.transformDefinition,getChartDefinitionFromContextCreation:HI.getDefinitionFromContextCreation,sequence:20}),XI.add("pie",{match:e=>"pie"===e,createChart:(e,t,o)=>new BI(e,t,o),getChartRuntime:zI,validateChartDefinition:BI.validateChartDefinition,transformDefinition:BI.transformDefinition,getChartDefinitionFromContextCreation:BI.getDefinitionFromContextCreation,sequence:30}),XI.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,o)=>new XC(e,t,o),getChartRuntime:JC,validateChartDefinition:XC.validateChartDefinition,transformDefinition:XC.transformDefinition,getChartDefinitionFromContextCreation:XC.getDefinitionFromContextCreation,sequence:40}),XI.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,o)=>new PI(e,t,o),getChartRuntime:MI,validateChartDefinition:PI.validateChartDefinition,transformDefinition:PI.transformDefinition,getChartDefinitionFromContextCreation:PI.getDefinitionFromContextCreation,sequence:50}),XI.add("scatter",{match:e=>"scatter"===e,createChart:(e,t,o)=>new WI(e,t,o),getChartRuntime:function(e,t){const o=e.getDefinition(),s=sw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"line",data:{labels:s.labels,datasets:CC(o,s)},options:{...Ly,layout:Ew(0,s),scales:Hw(o,s),plugins:{title:tI(o),legend:_w(o),tooltip:rI(0,s),chartShowValuesPlugin:Kw(o,s)}}},background:e.background||m}},validateChartDefinition:WI.validateChartDefinition,transformDefinition:WI.transformDefinition,getChartDefinitionFromContextCreation:WI.getDefinitionFromContextCreation,sequence:60}),XI.add("waterfall",{match:e=>"waterfall"===e,createChart:(e,t,o)=>new jI(e,t,o),getChartRuntime:YI,validateChartDefinition:jI.validateChartDefinition,transformDefinition:jI.transformDefinition,getChartDefinitionFromContextCreation:jI.getDefinitionFromContextCreation,sequence:70}),XI.add("pyramid",{match:e=>"pyramid"===e,createChart:(e,t,o)=>new $I(e,t,o),getChartRuntime:function(e,t){const o=e.getDefinition(),s=ow(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"bar",data:{labels:s.labels,datasets:vC(o,s)},options:{...Ly,indexAxis:"y",layout:Ew(0,s),scales:Bw(o,s),plugins:{title:tI(o),legend:Tw(o),tooltip:cI(o,s),chartShowValuesPlugin:Qw(o,s)}}},background:e.background||m}},validateChartDefinition:$I.validateChartDefinition,transformDefinition:$I.transformDefinition,getChartDefinitionFromContextCreation:$I.getDefinitionFromContextCreation,sequence:80,dataSeriesLimit:2}),XI.add("radar",{match:e=>"radar"===e,createChart:(e,t,o)=>new GI(e,t,o),getChartRuntime:function(e,t){const o=e.getDefinition(),s=nw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"radar",data:{labels:s.labels,datasets:IC(o,s)},options:{...Ly,layout:Ew(0,s),scales:zw(o,s),plugins:{title:tI(o),legend:Pw(o),tooltip:hI(0,s),chartShowValuesPlugin:Kw(o,s)}}},background:e.background||m}},validateChartDefinition:GI.validateChartDefinition,transformDefinition:GI.transformDefinition,getChartDefinitionFromContextCreation:GI.getDefinitionFromContextCreation,sequence:80}),XI.add("geo",{match:e=>"geo"===e,createChart:(e,t,o)=>new LI(e,t,o),getChartRuntime:function(e,t){const o=e.getDefinition(),s=rw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"choropleth",data:{datasets:xC(o,s)},options:{...Ly,layout:Ew(0,s),scales:$w(o,s),plugins:{title:tI(o),tooltip:dI(0,s),legend:{display:!1}}}},background:e.background||m}},validateChartDefinition:LI.validateChartDefinition,transformDefinition:LI.transformDefinition,getChartDefinitionFromContextCreation:LI.getDefinitionFromContextCreation,sequence:90,dataSeriesLimit:1}),XI.add("funnel",{match:e=>"funnel"===e,createChart:(e,t,o)=>new AI(e,t,o),getChartRuntime:function(e,t){const o=e.getDefinition(),s=aw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"funnel",data:{labels:s.labels,datasets:EC(o,s)},options:{...Ly,indexAxis:"y",layout:Ew(0,s),scales:Gw(0,s),plugins:{title:tI(o),legend:{display:!1},tooltip:uI(0,s),chartShowValuesPlugin:Kw(o,s)}}},background:e.background||m}},validateChartDefinition:AI.validateChartDefinition,transformDefinition:AI.transformDefinition,getChartDefinitionFromContextCreation:AI.getDefinitionFromContextCreation,sequence:100,dataSeriesLimit:1}),XI.add("sunburst",{match:e=>"sunburst"===e,createChart:(e,t,o)=>new qI(e,t,o),getChartRuntime:function(e,t){const o=e.getDefinition(),s=lw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"doughnut",data:{datasets:TC(o,s)},options:{cutout:void 0===e.pieHolePercentage?"25%":`${e.pieHolePercentage}%`,...Ly,layout:Ew(0,s),plugins:{title:tI(o),legend:Mw(o),tooltip:gI(0,s),sunburstLabelsPlugin:Jw(o,s),sunburstHoverPlugin:{enabled:!0}}}},background:e.background||m}},validateChartDefinition:qI.validateChartDefinition,transformDefinition:qI.transformDefinition,getChartDefinitionFromContextCreation:qI.getDefinitionFromContextCreation,sequence:30}),XI.add("treemap",{match:e=>"treemap"===e,createChart:(e,t,o)=>new ZI(e,t,o),getChartRuntime:function(e,t){const o=e.getDefinition(),s=lw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"treemap",data:{labels:s.labels,datasets:OC(o,s)},options:{...Ly,layout:Ew(0,s),plugins:{title:tI(o),legend:{display:!1},tooltip:pI(0,s)}}},background:e.background||m}},validateChartDefinition:ZI.validateChartDefinition,transformDefinition:ZI.transformDefinition,getChartDefinitionFromContextCreation:ZI.getDefinitionFromContextCreation,sequence:100});const KI=new n;KI.add("line",zC),KI.add("bar",zC),KI.add("combo",zC),KI.add("pie",zC),KI.add("gauge",EI),KI.add("scatter",zC),KI.add("scorecard",sy),KI.add("waterfall",zC),KI.add("pyramid",zC),KI.add("radar",zC),KI.add("geo",zC),KI.add("funnel",zC),KI.add("sunburst",zC),KI.add("treemap",zC);const JI={line:Vo("Line"),column:Vo("Column"),bar:Vo("Bar"),area:Vo("Area"),pie:Vo("Pie"),hierarchical:Vo("Hierarchical"),misc:Vo("Miscellaneous")},QI=new n;function ex(e){const t=XI.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(o,s,i){const n=t.find((e=>e.match(s.type)));if(!n)throw new Error(`No builder for this chart: ${s.type}`);return n.createChart(s,i,e)}}function tx(e){const t=XI.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(o){const s=t.find((e=>e.match(o.type)));if(!s)throw new Error("No runtime builder for this chart.");return s.getChartRuntime(o,e)}}function ox(e,t){const o=XI.getAll().find((e=>e.match(t.type)));if(!o)throw new Error("Unknown chart type.");return o.validateChartDefinition(e,t)}function sx(e,t,o){const s=XI.getAll().find((e=>e.match(t.type)));if(!s)throw new Error("Unknown chart type.");return s.transformDefinition(e,t,o)}function ix(e,t){const o=function(e,t){const o=e.getActiveSheetId(),s=wr(t).numberOfCols;if(t.top===t.bottom||s<=2)return;const i=e.getEvaluatedCell({sheetId:o,col:t.right,row:t.top}),n=i.type!==Ts.number,r=s=>{const i=e.getEvaluatedCellsInZone(o,{...t,left:s,right:s,top:t.top+(n?1:0)});return i.every((e=>e.type!==Ts.number))?"string":i.every((e=>e.type!==Ts.text))?"number":void 0};for(let e=t.left;e<t.right;e++){const o=r(e);if(e!==t.right&&"string"!==o)return;if(e===t.right&&"number"!==o)return}const a={...t,right:t.right-1},l={...t,left:t.right};return{title:{},dataSets:[{dataRange:dr(a)}],type:"sunburst",legendPosition:"none",labelRange:dr(l),dataSetsHaveTitle:n}}(t,e);if(o)return o;const s=t.getActiveSheetId();let i=e;const n=1===wr(e).numberOfCols;n||(i={...e,left:e.left+1});const r=dr(t.getUnboundedZone(s,i)),a=[{dataRange:r,yAxisId:"y"}],l=t.getCell({sheetId:s,col:e.left,row:e.top});if(1===Pr(e)&&l?.content)return{type:"scorecard",title:{},background:l.style?.fillColor||void 0,keyValue:dr(e),baselineMode:Ie,baselineColorUp:xe,baselineColorDown:Ee};const c=!!t.getEvaluatedCellsInZone(s,{...i,bottom:i.top}).find((e=>e.type!==Ts.empty&&e.type!==Ts.number));let h;n||(h=dr(t.getUnboundedZone(s,{...e,right:e.left})));const d=i.right===i.left?"none":"top",u={title:{},dataSets:a,labelsAsText:!1,stacked:!1,aggregated:!1,cumulative:!1,labelRange:h,type:"line",dataSetsHaveTitle:c,legendPosition:d},g=new HI(u,s,t);if(uw(u,g.dataSets,g.labelRange,t))return u;const p=YS(t,a,s,c);return n&&fw(t,p[0]).every((e=>"string"==typeof e&&!hi(e)))?{title:{},dataSets:[{dataRange:r}],aggregated:!0,labelRange:r,type:"pie",legendPosition:"top",dataSetsHaveTitle:!1}:{title:{},dataSets:a,labelRange:h,type:"bar",stacked:!1,aggregated:!1,dataSetsHaveTitle:c,legendPosition:d}}QI.add("line",{matcher:e=>"line"===e.type&&!e.stacked&&!e.fillArea,displayName:Vo("Line"),chartType:"line",chartSubtype:"line",subtypeDefinition:{stacked:!1,fillArea:!1},category:"line",preview:"o-spreadsheet-ChartPreview.LINE_CHART"}).add("stacked_line",{matcher:e=>"line"===e.type&&!e.fillArea&&!!e.stacked,displayName:Vo("Stacked Line"),chartType:"line",chartSubtype:"stacked_line",subtypeDefinition:{stacked:!0,fillArea:!1},category:"line",preview:"o-spreadsheet-ChartPreview.STACKED_LINE_CHART"}).add("area",{matcher:e=>"line"===e.type&&!e.stacked&&!!e.fillArea,displayName:Vo("Area"),chartType:"line",chartSubtype:"area",subtypeDefinition:{stacked:!1,fillArea:!0},category:"area",preview:"o-spreadsheet-ChartPreview.AREA_CHART"}).add("stacked_area",{matcher:e=>"line"===e.type&&e.stacked&&!!e.fillArea,displayName:Vo("Stacked Area"),chartType:"line",chartSubtype:"stacked_area",subtypeDefinition:{stacked:!0,fillArea:!0},category:"area",preview:"o-spreadsheet-ChartPreview.STACKED_AREA_CHART"}).add("scatter",{displayName:Vo("Scatter"),chartType:"scatter",chartSubtype:"scatter",category:"misc",preview:"o-spreadsheet-ChartPreview.SCATTER_CHART"}).add("column",{matcher:e=>"bar"===e.type&&!e.stacked&&!e.horizontal,displayName:Vo("Column"),chartType:"bar",chartSubtype:"column",subtypeDefinition:{stacked:!1,horizontal:!1},category:"column",preview:"o-spreadsheet-ChartPreview.COLUMN_CHART"}).add("stacked_column",{matcher:e=>"bar"===e.type&&e.stacked&&!e.horizontal,displayName:Vo("Stacked Column"),chartType:"bar",chartSubtype:"stacked_column",subtypeDefinition:{stacked:!0,horizontal:!1},category:"column",preview:"o-spreadsheet-ChartPreview.STACKED_COLUMN_CHART"}).add("bar",{matcher:e=>"bar"===e.type&&!e.stacked&&!!e.horizontal,displayName:Vo("Bar"),chartType:"bar",chartSubtype:"bar",subtypeDefinition:{horizontal:!0,stacked:!1},category:"bar",preview:"o-spreadsheet-ChartPreview.BAR_CHART"}).add("stacked_bar",{matcher:e=>"bar"===e.type&&e.stacked&&!!e.horizontal,displayName:Vo("Stacked Bar"),chartType:"bar",chartSubtype:"stacked_bar",subtypeDefinition:{horizontal:!0,stacked:!0},category:"bar",preview:"o-spreadsheet-ChartPreview.STACKED_BAR_CHART"}).add("combo",{displayName:Vo("Combo"),chartSubtype:"combo",chartType:"combo",category:"line",preview:"o-spreadsheet-ChartPreview.COMBO_CHART"}).add("pie",{matcher:e=>"pie"===e.type&&!e.isDoughnut,displayName:Vo("Pie"),chartSubtype:"pie",chartType:"pie",subtypeDefinition:{isDoughnut:!1},category:"pie",preview:"o-spreadsheet-ChartPreview.PIE_CHART"}).add("doughnut",{matcher:e=>"pie"===e.type&&!!e.isDoughnut,displayName:Vo("Doughnut"),chartSubtype:"doughnut",chartType:"pie",subtypeDefinition:{isDoughnut:!0},category:"pie",preview:"o-spreadsheet-ChartPreview.DOUGHNUT_CHART"}).add("gauge",{displayName:Vo("Gauge"),chartSubtype:"gauge",chartType:"gauge",category:"misc",preview:"o-spreadsheet-ChartPreview.GAUGE_CHART"}).add("scorecard",{displayName:Vo("Scorecard"),chartSubtype:"scorecard",chartType:"scorecard",category:"misc",preview:"o-spreadsheet-ChartPreview.SCORECARD_CHART"}).add("waterfall",{displayName:Vo("Waterfall"),chartSubtype:"waterfall",chartType:"waterfall",category:"misc",preview:"o-spreadsheet-ChartPreview.WATERFALL_CHART"}).add("pyramid",{displayName:Vo("Population Pyramid"),chartSubtype:"pyramid",chartType:"pyramid",category:"misc",preview:"o-spreadsheet-ChartPreview.POPULATION_PYRAMID_CHART"}).add("radar",{matcher:e=>"radar"===e.type&&!e.fillArea,displayName:Vo("Radar"),chartSubtype:"radar",chartType:"radar",subtypeDefinition:{fillArea:!1},category:"misc",preview:"o-spreadsheet-ChartPreview.RADAR_CHART"}).add("filled_radar",{matcher:e=>"radar"===e.type&&!!e.fillArea,displayName:Vo("Filled Radar"),chartType:"radar",chartSubtype:"filled_radar",subtypeDefinition:{fillArea:!0},category:"misc",preview:"o-spreadsheet-ChartPreview.FILLED_RADAR_CHART"}).add("geo",{displayName:Vo("Geo Chart"),chartSubtype:"geo",chartType:"geo",category:"misc",preview:"o-spreadsheet-ChartPreview.GEO_CHART"}).add("funnel",{displayName:Vo("Funnel"),chartSubtype:"funnel",chartType:"funnel",category:"misc",preview:"o-spreadsheet-ChartPreview.FUNNEL_CHART"}).add("sunburst",{matcher:e=>"sunburst"===e.type,displayName:Vo("Sunburst"),chartSubtype:"sunburst",chartType:"sunburst",category:"hierarchical",preview:"o-spreadsheet-ChartPreview.SUNBURST_CHART"}).add("treemap",{matcher:e=>"treemap"===e.type,displayName:Vo("Tree Map"),chartType:"treemap",chartSubtype:"treemap",category:"hierarchical",preview:"o-spreadsheet-ChartPreview.TREE_MAP_CHART"});var nx=Object.freeze({__proto__:null,AbstractChart:$C,BarChart:bI,CHART_AXIS_CHOICES:lC,CHART_COMMON_OPTIONS:Ly,GaugeChart:PI,LineChart:HI,MOVING_AVERAGE_TREND_LINE_XAXIS_ID:$S,PieChart:BI,SPREADSHEET_TO_EXCEL_TRENDLINE_TYPE_MAPPING:GS,ScorecardChart:XC,TREND_LINE_XAXIS_ID:zS,WaterfallChart:jI,adaptChartRange:jS,chartFactory:ex,chartFontColor:eC,chartMutedFontColor:tC,chartRuntimeFactory:tx,chartToImageFile:Uy,chartToImageUrl:Hy,checkDataset:oC,checkLabelRange:sC,createBarChartRuntime:SI,createDataSets:YS,createGaugeChartRuntime:MI,createLineChartRuntime:UI,createPieChartRuntime:zI,createScorecardChartRuntime:JC,createWaterfallChartRuntime:YI,drawScoreChart:KC,duplicateDataSetsInDuplicatedSheet:qS,duplicateLabelRangeInDuplicatedSheet:ZS,formatChartDatasetValue:rC,formatTickValue:aC,getChartPositionAtCenterOfViewport:function(e,t){const{x:o,y:s}=e.getMainViewportCoordinates(),{scrollX:i,scrollY:n}=e.getActiveSheetScrollInfo(),{width:r,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:o+i+Math.max(0,(r-t.width)/2),y:s+n+Math.max(0,(a-t.height)/2)}},getDefinedAxis:nC,getPieColors:cC,getSmartChartDefinition:ix,isTrendLineAxis:dC,shouldRemoveFirstLabel:iC,toExcelDataset:KS,toExcelLabelRange:JS,transformChartDefinitionWithDataSetsWithZone:QS,transformDefinition:sx,truncateLabel:hC,updateChartRangesWithDataSets:WS,validateChartDefinition:ox});function rx(e,t){const{scrollX:o,scrollY:s}=e.getActiveSheetScrollInfo(),i=e.getSheetViewDimension(),n=o+Math.max(0,(i.width-t.width)/2),r=s+Math.max(0,(i.height-t.height)/2);return e.getPositionAnchorOffset({x:n,y:r})}function ax(e,t){const o=ze(t),s=e.getSheetViewDimension(),i=s.width,n=s.height;if(o.width>i){const e=i/o.width;o.width=i,o.height=o.height*e}if(o.height>n){const e=n/o.height;o.height=n,o.width=o.width*e}return o}class lx{xmlString;constructor(e){this.xmlString=e}toString(){return this.xmlString}}const cx=["areaChart","area3DChart","lineChart","line3DChart","stockChart","radarChart","scatterChart","pieChart","pie3DChart","doughnutChart","barChart","bar3DChart","ofPieChart","surfaceChart","surface3DChart","bubbleChart","comboChart","radarChart"];function hx(e,t,o){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:o}}function dx(e){return String(e).replace(/\&/g,"&").replace(/\</g,"<").replace(/\>/g,">").replace(/\"/g,""").replace(/\'/g,"'").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function ux(e){return new lx(e.map((([e,t])=>`${e}="${dx(t)}"`)).join(" "))}function gx(e,t="text/xml"){const o=(new DOMParser).parseFromString(e.toString(),t),s=o.querySelector("parsererror");if(s){const t=s.innerHTML,o=parseInt(t.split(":")[0],10),i=e.toString().trim().split("\n"),n=i.slice(Math.max(o-3,0),Math.min(o+2,i.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${n}`)}return o}function px(e){if(e)return{style:e.style,color:{rgb:e.color}}}function mx(e,t){return vx`
|
|
9
|
+
`,Sh.add("chartShowValuesPlugin",{register:e=>e.register(uC),unregister:e=>e.unregister(uC)}),Sh.add("waterfallLinesPlugin",{register:e=>e.register(HC),unregister:e=>e.unregister(HC)}),Sh.add("funnelController",{register:e=>e.register(wh()),unregister:e=>e.unregister(wh())}),Sh.add("funnelElement",{register:e=>e.register(Ih()),unregister:e=>e.unregister(Ih())}),Sh.add("funnelTooltipPositioner",{register:e=>e.Tooltip.positioners.funnelTooltipPositioner=Eh,unregister:e=>e.Tooltip.positioners.funnelTooltipPositioner=void 0}),Sh.add("sunburstLabelsPlugin",{register:e=>e.register(LC),unregister:e=>e.unregister(LC)}),Sh.add("sunburstHoverPlugin",{register:e=>e.register(kC),unregister:e=>e.unregister(kC)});class zC extends t.Component{static template="o-spreadsheet-ChartJsComponent";static props={figureUI:Object,isFullScreen:{type:Boolean,optional:!0}};canvas=t.useRef("graphContainer");chart;currentRuntime;animationStore;currentDevicePixelRatio=window.devicePixelRatio;get background(){return this.chartRuntime.background}get canvasStyle(){return`background-color: ${this.background}`}get chartRuntime(){const e=this.env.model.getters.getChartRuntime(this.props.figureUI.id);if(!("chartJsConfig"in e))throw new Error("Unsupported chart runtime");return e}setup(){this.env.model.getters.isDashboard()&&(this.animationStore=oh(yh)),t.onMounted((()=>{const e=this.chartRuntime;this.currentRuntime=e,this.createChart(ze(e.chartJsConfig))})),t.onWillUnmount((()=>this.chart?.destroy())),t.useEffect((()=>{const e=this.chartRuntime;e!==this.currentRuntime?(e.chartJsConfig.type!==this.currentRuntime.chartJsConfig.type?(this.chart?.destroy(),this.createChart(ze(e.chartJsConfig))):this.updateChartJs(ze(e.chartJsConfig)),this.currentRuntime=e):this.currentDevicePixelRatio!==window.devicePixelRatio&&(this.currentDevicePixelRatio=window.devicePixelRatio,this.updateChartJs(ze(this.currentRuntime.chartJsConfig)))}))}createChart(e){if(this.env.model.getters.isDashboard()&&this.animationStore){const t=this.env.model.getters.getChart(this.props.figureUI.id)?.type;t&&this.animationStore.animationPlayed[this.animationFigureId]!==t&&(e=this.enableAnimationInChartData(e),this.animationStore.disableAnimationForChart(this.animationFigureId,t))}const t=this.canvas.el.getContext("2d");this.chart=new window.Chart(t,e)}updateChartJs(e){if(this.env.model.getters.isDashboard()){const t=this.env.model.getters.getChart(this.props.figureUI.id)?.type;t&&this.hasChartDataChanged()&&this.animationStore&&(e=this.enableAnimationInChartData(e),this.animationStore.disableAnimationForChart(this.animationFigureId,t))}e.data&&e.data.datasets?(this.chart.data=e.data,e.options?.plugins?.title&&(this.chart.config.options.plugins.title=e.options.plugins.title)):this.chart.data.datasets=[],this.chart.config.options=e.options,this.chart.update()}hasChartDataChanged(){return!mt(this.currentRuntime.chartJsConfig.data,this.chartRuntime.chartJsConfig.data)}enableAnimationInChartData(e){return{...e,options:{...e.options,animation:{animateRotate:!0}}}}get animationFigureId(){return this.props.isFullScreen?this.props.figureUI.id+"-fullscreen":this.props.figureUI.id}}class $C{sheetId;title;getters;constructor(e,t,o){this.title=e.title,this.sheetId=t,this.getters=o}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t,o){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function GC(e,t,o,s,i){if("text"===t||"progress"===t||e?.type!==Ts.number||o?.type!==Ts.number)return;const n=o.value-e.value;return n>0?s:n<0?i:void 0}function WC(e,t,o){if("text"===o||e?.type!==Ts.number||t?.type!==Ts.number)return"neutral";const s=t.value-e.value;return s>0?"up":s<0?"down":"neutral"}function qC(e){return e.keyValue&&!Xr.test(e.keyValue)?"InvalidScorecardKeyValue":"Success"}function ZC(e){return e.baseline&&!Xr.test(e.baseline)?"InvalidScorecardBaseline":"Success"}const jC=new window.Path2D("M8.6 4.8a.5.5 0 0 1 0 .75l-3.9 3.9a.5 .5 0 0 1 -.75 0l-3.8 -3.9a.5 .5 0 0 1 0 -.75l.4-.4a.5.5 0 0 1 .75 0l2.3 2.4v-5.7c0-.25.25-.5.5-.5h.6c.25 0 .5.25.5.5v5.8l2.3 -2.4a.5.5 0 0 1 .75 0z"),YC=new window.Path2D("M8.7 5.5a.5.5 0 0 0 0-.75l-3.8-4a.5.5 0 0 0-.75 0l-3.8 4a.5.5 0 0 0 0 .75l.4.4a.5.5 0 0 0 .75 0l2.3-2.4v5.8c0 .25.25.5.5.5h.6c.25 0 .5-.25.5-.5v-5.8l2.2 2.4a.5.5 0 0 0 .75 0z");let XC=class e extends $C{keyValue;keyDescr;baseline;baselineMode;baselineDescr;progressBar=!1;background;baselineColorUp;baselineColorDown;fontColor;humanize;type="scorecard";constructor(e,t,o){super(e,t,o),this.keyValue=fa(o,t,e.keyValue),this.keyDescr=e.keyDescr,this.baseline=fa(o,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp??xe,this.baselineColorDown=e.baselineColorDown??Ee,this.humanize=e.humanize??!1}static validateChartDefinition(e,t){return e.checkValidations(t,qC,ZC)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0].dataRange:void 0,title:e.title||{text:""},baselineMode:Ie,baselineColorUp:xe,baselineColorDown:Ee,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t,o){let s,i;if(t.baseline){const i=US(e,t.baseline,o);i!==Js.InvalidReference&&(s=i)}if(t.keyValue){const s=US(e,t.keyValue,o);s!==Js.InvalidReference&&(i=s)}return{...t,baseline:s,keyValue:i}}duplicateInDuplicatedSheet(t){const o=ZS(this.sheetId,t,this.baseline),s=ZS(this.sheetId,t,this.keyValue),i=this.getDefinitionWithSpecificRanges(o,s,t);return new e(i,t,this.getters)}copyInSheetId(t){const o=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,t);return new e(o,t,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{...this,range:this.keyValue?[{dataRange:this.getters.getRangeString(this.keyValue,this.sheetId)}]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,o){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,o||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,o||this.sheetId):void 0,keyDescr:this.keyDescr,humanize:this.humanize}}getDefinitionForExcel(){}updateRanges(t){const o=jS(this.baseline,t),s=jS(this.keyValue,t);if(this.baseline===o&&this.keyValue===s)return this;const i=this.getDefinitionWithSpecificRanges(o,s);return new e(i,this.sheetId,this.getters)}};function KC(e,t){const o=t.getContext("2d"),s=window.devicePixelRatio||1;t.width=s*e.canvas.width,t.height=s*e.canvas.height,o.scale(s,s);const i=e.canvas.width-j;if(o.fillStyle=e.canvas.backgroundColor,o.fillRect(0,0,e.canvas.width,e.canvas.height),e.title){o.font=e.title.style.font,o.fillStyle=e.title.style.color;const t=o.textBaseline;o.textBaseline="middle",o.fillText(za(o,e.title.text,i-e.title.position.x),e.title.position.x,e.title.position.y),o.textBaseline=t}if(e.baseline&&(o.font=e.baseline.style.font,o.fillStyle=e.baseline.style.color,$a(o,e.baseline.text,e.baseline.position,e.baseline.style.underline,e.baseline.style.strikethrough)),e.baselineArrow&&e.baselineArrow.style.size>0){o.save(),o.fillStyle=e.baselineArrow.style.color,o.translate(e.baselineArrow.position.x,e.baselineArrow.position.y);const t=e.baselineArrow.style.size/10;switch(o.scale(t,t),e.baselineArrow.direction){case"down":o.fill(jC);break;case"up":o.fill(YC)}o.restore()}if(e.baselineDescr){const t=e.baselineDescr;o.font=t.style.font,o.fillStyle=t.style.color,o.fillText(za(o,t.text,i-t.position.x),t.position.x,t.position.y)}if(e.key&&(o.font=e.key.style.font,o.fillStyle=e.key.style.color,$a(o,za(o,e.key.text,i-e.key.position.x),e.key.position,e.key.style.underline,e.key.style.strikethrough)),e.keyDescr){const t=e.keyDescr;o.font=e.keyDescr?.style.font??t.style.font,o.fillStyle=t.style.color,o.fillText(za(o,t.text,i-t.position.x),t.position.x,t.position.y)}if(e.progressBar){if(o.fillStyle=e.progressBar.style.backgroundColor,o.beginPath(),o.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width,e.progressBar.dimension.height,e.progressBar.dimension.height/2),o.fill(),o.fillStyle=e.progressBar.style.color,o.beginPath(),e.progressBar.value>0)o.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width*Math.max(0,Math.min(1,e.progressBar.value)),e.progressBar.dimension.height,e.progressBar.dimension.height/2);else{const t=e.progressBar.dimension.width*Math.max(0,Math.min(1,-e.progressBar.value));o.roundRect(e.progressBar.position.x+e.progressBar.dimension.width-t,e.progressBar.position.y,t,e.progressBar.dimension.height,e.progressBar.dimension.height/2)}o.fill()}}function JC(e,t){let o,s="";const i=t.getLocale();if(e.keyValue){const n={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};o=t.getEvaluatedCell(n),s=function(e,t,o){return e?t?Vn(e,o):e.formattedValue??String(e.value??""):""}(o,e.humanize??!1,i)}let n;const r=e.baseline;if(r){const e={sheetId:r.sheetId,col:r.zone.left,row:r.zone.top};n=t.getEvaluatedCell(e)}const{background:a,fontColor:l}=t.getStyleOfSingleCellChart(e.background,e.keyValue),c=function(e,t,o,s,i){if(!e)return"";if("text"===o||t?.type!==Ts.number||e.type!==Ts.number)return s?Vn(e,i):e.formattedValue;let{value:n,format:r}=e;return"progress"===o?(n=t.value/n,r="0.0%"):(n=Math.abs(t.value-n),"percentage"===o&&0!==n&&(n/=e.value),"percentage"===o&&(r="0.0%"),r||(n=Math.round(100*n)/100)),s?Vn({value:n,format:r},i):bn(n,{format:r,locale:i})}(n,o,e.baselineMode,e.humanize??!1,i),h="progress"===e.baselineMode&&Is(c,i)?gi(c,i):0;return{title:{...e.title,text:e.title.text?Vo(e.title.text):""},keyValue:s,keyDescr:e.keyDescr?.text?Vo(e.keyDescr.text):"",baselineDisplay:c,baselineArrow:WC(n,o,e.baselineMode),baselineColor:GC(n,e.baselineMode,o,e.baselineColorUp,e.baselineColorDown),baselineDescr:"progress"!==e.baselineMode&&e.baselineDescr?.text?Vo(e.baselineDescr.text):"",fontColor:l,background:a,baselineStyle:{..."percentage"!==e.baselineMode&&"progress"!==e.baselineMode&&r?t.getCellComputedStyle({sheetId:r.sheetId,col:r.zone.left,row:r.zone.top}):void 0,fontSize:e.baselineDescr?.fontSize,align:e.baselineDescr?.align},baselineDescrStyle:{textColor:e.baselineDescr?.color,...e.baselineDescr},keyValueStyle:{...e.keyValue?t.getCellComputedStyle({sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top}):void 0,fontSize:e.keyDescr?.fontSize,align:e.keyDescr?.align},keyValueDescrStyle:{textColor:e.keyDescr?.color,...e.keyDescr},progressBar:"progress"===e.baselineMode?{value:h,color:h>0?e.baselineColorUp:e.baselineColorDown}:void 0}}const QC=.05;function ey(e,t){const o=e||"";return t&&o?" "+o:o}function ty({width:e,height:t},o){return new oy({width:e,height:t},o).computeDesign()}class oy{runtime;context;width;height;constructor({width:e,height:t},o){this.runtime=o;const s=document.createElement("canvas");this.width=s.width=e,this.height=s.height=t,this.context=s.getContext("2d")}computeDesign(){const e={canvas:{width:this.width,height:this.height,backgroundColor:this.backgroundColor}},t=this.getTextStyles();let o=0;if(this.title){let s,i;switch(({height:o,width:i}=this.getFullTextDimensions(this.title,t.title.font)),this.runtime.title.align){case"center":s=(this.width-i)/2;break;case"right":s=this.width-i-j;break;default:s=j}e.title={text:this.title,style:t.title,position:{x:s,y:Y+o/2}}}const s=t.baselineArrow?.size??0;let{height:i,width:n}=this.getTextDimensions(this.baseline,t.baselineValue.font);this.baseline||(i=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).height);const r=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).width;let a;switch(this.runtime.baselineStyle?.align){case"right":a=this.width-j-r-n;break;case"left":a=j+s;break;default:a=(this.width-n-r+s)/2}if(this.baseline&&(e.baseline={text:this.baseline,style:t.baselineValue,position:{x:a,y:this.keyValue?this.height*(1-QC*(this.runtime.progressBar?1:2)):this.height-(this.height-o-i)/2-Y}},t.baselineArrow&&!this.runtime.progressBar&&(e.baselineArrow={direction:this.baselineArrow,style:t.baselineArrow,position:{x:e.baseline.position.x-s,y:e.baseline.position.y-(i+s)/2}})),e.baseline&&this.baselineDescr){const o={x:e.baseline.position.x+n,y:e.baseline.position.y};e.baselineDescr={text:this.baselineDescr,style:t.baselineDescr,position:o}}let l=0;this.runtime.progressBar&&(l=.05*this.height,e.progressBar={position:{x:2*j,y:.9*this.height-i-l},dimension:{height:l,width:this.width-4*j},value:this.runtime.progressBar.value,style:{color:this.runtime.progressBar.color,backgroundColor:this.secondaryFontColor}});const{width:c,height:h}=this.getFullTextDimensions(this.keyValue,t.keyValue.font),d=this.getTextDimensions(this.keyDescr,t.keyDescr.font).width;let u;switch(this.runtime.keyValueStyle?.align){case"right":u=this.width-j-d-c;break;case"left":u=j;break;default:u=(this.width-c-d)/2}if(this.keyValue&&(e.key={text:this.keyValue,style:t.keyValue,position:{x:Math.max(j,u),y:.4*this.height+Y/2+(o+h/2)/2}}),e.key&&this.keyDescr){const o={x:e.key.position.x+c,y:e.key.position.y};e.keyDescr={text:this.keyDescr,style:t.keyDescr,position:o}}return e}get title(){return this.runtime.title.text??""}get keyValue(){return this.runtime.keyValue}get keyDescr(){return ey(this.runtime.keyDescr,this.keyValue)}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){return ey(this.runtime.baselineDescr,this.baseline)}get baselineArrow(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get secondaryFontColor(){return tC(this.backgroundColor)}getTextDimensions(e,t){this.context.font=t;const o=this.context.measureText(e);return{width:o.width,height:o.actualBoundingBoxAscent+o.actualBoundingBoxDescent}}getFullTextDimensions(e,t){this.context.font=t;const o=this.context.measureText(e);return{width:o.width,height:o.fontBoundingBoxAscent+o.fontBoundingBoxDescent}}getTextStyles(){const e=this.runtime.keyValueStyle?.fontSize??32,t=Math.floor(.9*e);let o=this.runtime.baselineStyle?.fontSize??16;const s=Math.floor(.9*o);return this.runtime.progressBar&&(o/=1.5),{title:{font:Da(this.runtime.title.fontSize??14,this.runtime.title.bold,this.runtime.title.italic),color:this.runtime.title.color??this.secondaryFontColor},keyValue:{color:this.runtime.keyValueStyle?.textColor||this.runtime.fontColor,font:Da(e,this.runtime.keyValueStyle?.bold,this.runtime.keyValueStyle?.italic),strikethrough:this.runtime.keyValueStyle?.strikethrough,underline:this.runtime.keyValueStyle?.underline},keyDescr:{color:this.runtime.keyValueDescrStyle?.textColor||this.runtime.fontColor,font:Da(t,this.runtime.keyValueDescrStyle?.bold,this.runtime.keyValueDescrStyle?.italic),strikethrough:this.runtime.keyValueDescrStyle?.strikethrough,underline:this.runtime.keyValueDescrStyle?.underline},baselineValue:{font:Da(o,this.runtime.baselineStyle?.bold,this.runtime.baselineStyle?.italic),strikethrough:this.runtime.baselineStyle?.strikethrough,underline:this.runtime.baselineStyle?.underline,color:this.runtime.baselineColor||this.runtime.baselineStyle?.textColor||this.secondaryFontColor},baselineDescr:{font:Da(s,this.runtime.baselineDescrStyle?.bold,this.runtime.baselineDescrStyle?.italic),strikethrough:this.runtime.baselineDescrStyle?.strikethrough,underline:this.runtime.baselineDescrStyle?.underline,color:this.runtime.baselineDescrStyle?.textColor??this.secondaryFontColor},baselineArrow:"neutral"===this.baselineArrow||this.runtime.progressBar?void 0:{size:this.keyValue?.8*o:0,color:this.runtime.baselineColor||this.runtime.baselineStyle?.textColor||this.secondaryFontColor}}}}class sy extends t.Component{static template="o-spreadsheet-ScorecardChart";static props={figureUI:Object};canvas=t.useRef("chartContainer");get runtime(){return this.env.model.getters.getChartRuntime(this.props.figureUI.id)}get title(){const e=this.env.model.getters.getChartDefinition(this.props.figureUI.id).title.text??"";return Vo(e)}setup(){t.useEffect(this.createChart.bind(this),(()=>{const e=this.canvas.el.getBoundingClientRect();return[e.width,e.height,this.runtime,this.canvas.el,window.devicePixelRatio]}))}createChart(){const e=this.canvas.el;KC(ty(e.getBoundingClientRect(),this.runtime),e)}}const iy=/Mac/i,ny=["Shift","Control","Alt","Meta"];function ry(e,t){return!!e&&(!!t.target&&e.contains(t.target))}function ay(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:o}=e.getBoundingClientRect();return{top:t,left:o}}throw new Error("Can't find spreadsheet position")}function ly(e){return e.el?cy(e.el):{x:0,y:0,width:0,height:0}}function cy(e){const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}function*hy(e){if(yield e,e.hasChildNodes())for(const t of e.childNodes)yield*hy(t)}function dy(e){const{startElement:t,endElement:o,startSelectionOffset:s,endSelectionOffset:i}=function(e){const t=document.getSelection();return{startElement:t.anchorNode||e,startSelectionOffset:t.anchorOffset,endElement:t.focusNode||e,endSelectionOffset:t.focusOffset}}(e);return{start:uy(e,t,s),end:uy(e,o,i)}}function uy(e,t,o){let s=0;const i=hy(e);let n=i.next(),r=!0;for(;!n.done&&n.value!==t;)n.value.hasChildNodes()||n.value.textContent&&(s+=n.value.textContent.length),("P"===n.value.nodeName||"DIV"===n.value.nodeName&&n.value!==e)&&(r?r=!1:s++),n=i.next();if(n.value!==t)return 0;if(n.value.hasChildNodes()){const e=[...n.value.childNodes].slice(0,o);s+=e.reduce(((t,o,s)=>{if(null!==o.textContent){let i=o.textContent.length;return"P"===o.nodeName&&s!==e.length-1&&i++,t+i}return t}),0)}else s+=o;return"P"!==t.nodeName||r||""!==t.textContent||s++,s}const gy=/^[a-zA-Z]$/;function py(e,t="key"){let o="";ny.includes(e.key)||(fy(e)&&(o+="Ctrl+"),e.altKey&&(o+="Alt+"),e.shiftKey&&(o+="Shift+"));const s="key"===t?e.key:e.code;return o+=gy.test(s)?s.toUpperCase():s,o}function my(){return Boolean(iy.test(navigator.userAgent))}function fy(e){return my()||Cy()?e.metaKey:e.ctrlKey}function vy(e){return 1===e.button||fy(e)&&0===e.button}function by(e,t){const o=document.createElement("a");o.href=e,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o)}function Sy(){return/Firefox/i.test(navigator.userAgent)}function Cy(){return/(iPad|iPhone|iPod)/i.test(navigator.userAgent)||"MacIntel"===navigator.platform&&(navigator.maxTouchPoints||1)>1}function yy(){return/Android/i.test(navigator.userAgent)||Cy()||/(webOS|BlackBerry|Windows Phone)/i.test(navigator.userAgent)}function wy(e){return 8===(e=$t(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}const Iy=30,xy=10,Ey=20,Ry=12,Ty=80,Ay="#F3F2F1",Dy=6,_y=25;function Oy(e,t){const o=e.getBoundingClientRect(),s=window.devicePixelRatio||1;e.width=s*o.width,e.height=s*o.height;const i=e.getContext("2d");i.scale(s,s);const n=function(e,t,o){const s=t.maxValue,i=t.minValue,n=Vy(t,"animated"),r=function(e,t){const o=t?_y:0,s=e.height-Ey-o-xy,i=e.width-2*Iy;let n,r;i>2*s?(n=2*s,r=s):(n=i,r=i/2);const a=o+xy+(s-r)/2;return{x:Iy+(i-n)/2,y:a,width:n,height:r}}(e,t.title.text),a=r.width/6,l=n?(n-i.value)/(s.value-i.value):0,c={x:e.width/2,y:r.y+r.height-r.height/12};let h=Ty;r.height<300&&(h*=r.height/300);const d=r.width/2,u=t.gaugeValue?.label||"-";Oa(o,u,{fontSize:h},"px")>d&&(h=function(e,t,o,s=.25){let i=1;if(o(i)>e)return i;if(o(t)<e)return t;let n=(i+t)/2,r=o(n),a=0;for(;Math.abs(r-e)>s&&a<20;)r>=e?t=(i+t)/2:i=(i+t)/2,n=(i+t)/2,r=o(n),a++;return n}(d,h,(e=>Oa(o,u,{fontSize:e},"px"))));const g={x:r.x+a/2,y:r.y+r.height+Ry},p={x:r.x+r.width-a/2,y:r.y+r.height+Ry},m=tC(t.background),f=function(e,t,o,s){const i=e.maxValue,n=e.minValue,r={x:t.x+t.width/2,y:t.y+t.height},a={fontSize:Ry},l=[],c=[];for(const h of e.inflectionValues){const e=(h.value-n.value)/(i.value-n.value),d=Oa(s,h.label,a,"px"),u=Math.PI-Math.PI*e,g=ky(u,t.height+Dy,r.x,r.y,d+2,Ry),p=c.some((e=>Ny(e,g)))?Ry:0;c.push(g),l.push({rotation:u,label:h.label,fontSize:Ry,color:o,offset:p})}return l}(t,r,m,o);let v=0,b=0,S=0;t.title.text&&({width:b,height:S}=Ma(o,t.title.text,{fontSize:K,...t.title},"px"));switch(t.title.align){case"right":v=e.width-b-j;break;case"center":v=(e.width-b)/2;break;default:v=j}return{width:e.width,height:e.height,title:{label:t.title.text??"",fontSize:t.title.fontSize??K,textPosition:{x:v,y:X+S/2},color:t.title.color??m,bold:t.title.bold,italic:t.title.italic},backgroundColor:t.background,gauge:{rect:r,arcWidth:a,percentage:Ze(l,0,1),color:Fy(t)},inflectionValues:f,gaugeValue:{label:u,textPosition:c,fontSize:h,color:m},minLabel:{label:t.minValue.label,textPosition:g,fontSize:Ry,color:m},maxLabel:{label:t.maxValue.label,textPosition:p,fontSize:Ry,color:m}}}(o,t,i);!function(e,t){e.save(),e.fillStyle=t.backgroundColor,e.fillRect(0,0,t.width,t.height),e.restore()}(i,n),function(e,t){e.save();const o=t.gauge,s=o.rect.x+o.rect.width/2,i=o.rect.y+o.rect.height,n=o.rect.height-o.arcWidth/2;if(n<0)return;const r=1===o.percentage?0:Math.PI*(1+o.percentage);e.strokeStyle=Ay,e.beginPath(),e.lineWidth=o.arcWidth,e.arc(s,i,n,r,0),e.stroke(),e.strokeStyle=o.color,e.beginPath(),e.arc(s,i,n,Math.PI,r),e.stroke(),e.restore()}(i,n),function(e,t){const{x:o,y:s,width:i,height:n}=t.gauge.rect;for(const r of t.inflectionValues){e.save(),e.translate(o+i/2-.5,s+n-.5),e.rotate(Math.PI/2-r.rotation),e.lineWidth=2,e.strokeStyle=tC(t.backgroundColor)+"aa",e.beginPath(),e.moveTo(0,-(n-t.gauge.arcWidth)),e.lineTo(0,-n-3),e.stroke(),e.textAlign="center",e.font=`${r.fontSize}px ${fe}`,e.fillStyle=r.color;const a=-n-Dy-r.offset;e.fillText(r.label,0,a),e.restore()}}(i,n),function(e,t){for(const o of[t.minLabel,t.maxLabel,t.gaugeValue])e.save(),e.textAlign="center",e.fillStyle=o.color,e.font=`${o.fontSize}px ${fe}`,e.fillText(o.label,o.textPosition.x,o.textPosition.y),e.restore()}(i,n),function(e,t){e.save();const o=t.title;e.font=Da(o.fontSize,o.bold,o.italic),e.textBaseline="middle",e.fillStyle=o.color,e.fillText(o.label,o.textPosition.x,o.textPosition.y),e.restore()}(i,n)}function Fy(e){const t=Vy(e,"final");if(void 0===t)return Ay;for(let o=0;o<e.inflectionValues.length;o++){const s=e.inflectionValues[o];if("<"===s.operator&&t<s.value)return e.colors[o];if("<="===s.operator&&t<=s.value)return e.colors[o]}return e.colors.at(-1)}function Py(e){return[{start:e.topLeft,end:e.topRight},{start:e.topRight,end:e.bottomRight},{start:e.bottomRight,end:e.bottomLeft},{start:e.bottomLeft,end:e.topLeft}]}function My(e,t){const o=e.start,s=e.end,i=t.start,n=t.end;function r(e,t,o){return(o.y-e.y)*(t.x-e.x)>(t.y-e.y)*(o.x-e.x)}return r(o,i,n)!==r(s,i,n)&&r(o,s,i)!==r(o,s,n)}function Ny(e,t){const o=Py(e),s=Py(t);for(const e of o)for(const t of s)if(My(e,t))return!0;return!1}function ky(e,t,o,s,i,n){const r=Math.cos(e),a=Math.sin(e),l=r*t,c=a*t,h=a*(i/2),d=r*(i/2),u=r*(t+n),g=a*(t+n);return{bottomLeft:{x:l-h+o,y:s-(c+d)},bottomRight:{x:l+h+o,y:s-(c-d)},topRight:{x:u+h+o,y:s-(g-d)},topLeft:{x:u-h+o,y:s-(g+d)}}}function Vy(e,t){return"animated"===t&&void 0!==e.animationValue?e.animationValue:e.gaugeValue?.value}const Ly={responsive:!0,maintainAspectRatio:!1,elements:{line:{fill:!1},point:{hitRadius:15}},animation:!1,events:["mousemove","mouseout","click","touchstart","touchmove","mouseup"]};function Hy(e,t,o){const s=document.createElement("div");s.style.width=`${t.width}px`,s.style.height=`${t.height}px`;const i=document.createElement("canvas");let n;if(s.append(i),i.setAttribute("width",t.width.toString()),i.setAttribute("height",t.height.toString()),document.body.append(s),"chartJsConfig"in e){const t=ze(e.chartJsConfig);t.plugins=[By];const o=new window.Chart(i,t);n=o.toBase64Image(),o.destroy()}else if("scorecard"===o){KC(ty(t,e),i),n=i.toDataURL()}else"gauge"===o&&(Oy(i,e),n=i.toDataURL());return s.remove(),n}async function Uy(e,t,o){const s=document.createElement("div");s.style.width=`${t.width}px`,s.style.height=`${t.height}px`,s.style.position="fixed",s.style.opacity="0";const i=document.createElement("canvas");s.append(i),i.setAttribute("width",t.width.toString()),i.setAttribute("height",t.height.toString()),document.body.append(s);let n=null;if("chartJsConfig"in e){const t=ze(e.chartJsConfig);t.plugins=[By];const o=new window.Chart(i,t);n=await new Promise((e=>i.toBlob(e,"image/png"))),o.destroy()}else if("scorecard"===o){KC(ty(t,e),i),n=await new Promise((e=>i.toBlob(e,"image/png")))}else"gauge"===o&&(Oy(i,e),n=await new Promise((e=>i.toBlob(e,"image/png"))));return s.remove(),n?new File([n],"chart.png",{type:"image/png"}):void 0}const By={id:"customCanvasBackgroundColor",beforeDraw:e=>{const{ctx:t}=e;t.save(),t.globalCompositeOperation="destination-over",t.fillStyle="#ffffff",t.fillRect(0,0,e.width,e.height),t.restore()}},zy={Errors:{InvalidRange:Vo("The range is invalid"),FirstArgMissing:Vo("The argument is missing. Please provide a value"),SecondArgMissing:Vo("The second argument is missing. Please provide a value"),MinNaN:Vo("The minpoint must be a number"),MidNaN:Vo("The midpoint must be a number"),MaxNaN:Vo("The maxpoint must be a number"),ValueUpperInflectionNaN:Vo("The first value must be a number"),ValueLowerInflectionNaN:Vo("The second value must be a number"),MinBiggerThanMax:Vo("Minimum must be smaller then Maximum"),MinBiggerThanMid:Vo("Minimum must be smaller then Midpoint"),MidBiggerThanMax:Vo("Midpoint must be smaller then Maximum"),LowerBiggerThanUpper:Vo("Lower inflection point must be smaller than upper inflection point"),MinInvalidFormula:Vo("Invalid Minpoint formula"),MaxInvalidFormula:Vo("Invalid Maxpoint formula"),MidInvalidFormula:Vo("Invalid Midpoint formula"),ValueUpperInvalidFormula:Vo("Invalid upper inflection point formula"),ValueLowerInvalidFormula:Vo("Invalid lower inflection point formula"),EmptyRange:Vo("A range needs to be defined"),ValueCellIsInvalidFormula:Vo("At least one of the provided values is an invalid formula"),Unexpected:Vo("The rule is invalid for an unknown reason")},ColorScale:Vo("Color scale"),IconSet:Vo("Icon set"),DataBar:Vo("Data bar")},$y={Series:Vo("Series"),BackgroundColor:Vo("Background color"),StackedBarChart:Vo("Stacked bar chart"),StackedLineChart:Vo("Stacked line chart"),StackedAreaChart:Vo("Stacked area chart"),StackedColumnChart:Vo("Stacked column chart"),CumulativeData:Vo("Cumulative data"),TreatLabelsAsText:Vo("Treat labels as text"),AggregatedChart:Vo("Aggregate"),Errors:{Unexpected:Vo("The chart definition is invalid for an unknown reason"),InvalidDataSet:Vo("The dataset is invalid"),InvalidLabelRange:Vo("Labels are invalid"),InvalidScorecardKeyValue:Vo("The key value is invalid"),InvalidScorecardBaseline:Vo("The baseline value is invalid"),InvalidGaugeDataRange:Vo("The data range is invalid"),EmptyGaugeRangeMin:Vo("A minimum range limit value is needed"),GaugeRangeMinNaN:Vo("The minimum range limit value must be a number"),EmptyGaugeRangeMax:Vo("A maximum range limit value is needed"),GaugeRangeMaxNaN:Vo("The maximum range limit value must be a number"),GaugeLowerInflectionPointNaN:Vo("The lower inflection point value must be a number"),GaugeUpperInflectionPointNaN:Vo("The upper inflection point value must be a number")},GeoChart:{ColorScales:{blues:Vo("Blues"),cividis:Vo("Cividis"),greens:Vo("Greens"),greys:Vo("Greys"),oranges:Vo("Oranges"),purples:Vo("Purples"),rainbow:Vo("Rainbow"),reds:Vo("Reds"),viridis:Vo("Viridis")}}},Gy={Custom:Vo("Custom")},Wy=Vo("Merged cells are preventing this operation. Unmerge those cells and try again."),qy={Errors:{Unexpected:Vo("Cannot split the selection for an unknown reason"),NoSplitSeparatorInSelection:Vo("There is no match for the selected separator in the selection"),MoreThanOneColumnSelected:Vo("Only a selection from a single column can be split"),SplitWillOverwriteContent:Vo("Splitting will overwrite existing content")}},Zy={Errors:{Unexpected:Vo("Cannot remove duplicates for an unknown reason"),MoreThanOneRangeSelected:Vo("Please select only one range of cells"),EmptyTarget:Vo("Please select a range of cells containing values."),NoColumnsProvided:Vo("Please select at latest one column to analyze."),WillRemoveExistingMerge:Vo("This operation is not possible due to a merge. Please remove the merges first than try again.")}},jy={DateIs:{today:Vo("today"),yesterday:Vo("yesterday"),tomorrow:Vo("tomorrow"),lastWeek:Vo("in the past week"),lastMonth:Vo("in the past month"),lastYear:Vo("in the past year")},DateIsBefore:{today:Vo("today"),yesterday:Vo("yesterday"),tomorrow:Vo("tomorrow"),lastWeek:Vo("one week ago"),lastMonth:Vo("one month ago"),lastYear:Vo("one year ago")},CriterionError:{notEmptyValue:Vo("The value must not be empty"),numberValue:Vo("The value must be a number"),dateValue:Vo("The value must be a date"),validRange:Vo("The value must be a valid range"),validFormula:Vo("The formula must be valid")},Errors:{InvalidRange:Vo("The range is invalid."),InvalidDataValidationCriterionValue:Vo("One or more of the provided criteria values are invalid. Please review and correct them."),InvalidNumberOfCriterionValues:Vo("One or more of the provided criteria values are missing."),Unexpected:Vo("The rule is invalid for an unknown reason.")}},Yy={Errors:{Unexpected:Vo("The table zone is invalid for an unknown reason"),TableOverlap:Vo("You cannot create overlapping tables."),NonContinuousTargets:Vo("A table can only be created on a continuous selection."),InvalidRange:Vo("The range is invalid"),TargetOutOfSheet:Vo("The range is out of the sheet")},Checkboxes:{hasFilters:Vo("Filter button"),headerRow:Vo("Header row(s)"),bandedRows:Vo("Banded rows"),firstColumn:Vo("First column"),lastColumn:Vo("Last column"),bandedColumns:Vo("Banded columns"),automaticAutofill:Vo("Automatically autofill formulas"),totalRow:Vo("Total row"),isDynamic:Vo("Auto-adjust to formula result")},Tooltips:{filterWithoutHeader:Vo("Cannot have filters without a header row"),isDynamic:Vo("For tables based on array formulas only")}},Xy={labels:{no_calculations:Vo("No calculations"),"%_of_grand_total":Vo("% of grand total"),"%_of_col_total":Vo("% of column total"),"%_of_row_total":Vo("% of row total"),"%_of":Vo("% of"),"%_of_parent_row_total":Vo("% of parent row total"),"%_of_parent_col_total":Vo("% of parent column total"),"%_of_parent_total":Vo("% of parent total"),difference_from:Vo("Difference from"),"%_difference_from":Vo("% difference from"),running_total:Vo("Running total"),"%_running_total":Vo("% Running total"),rank_asc:Vo("Rank smallest to largest"),rank_desc:Vo("Rank largest to smallest"),index:Vo("Index")},descriptions:{"%_of_grand_total":()=>Vo("Displayed as % of grand total"),"%_of_col_total":()=>Vo("Displayed as % of column total"),"%_of_row_total":()=>Vo("Displayed as % of row total"),"%_of":e=>Vo('Displayed as % of "%s"',e),"%_of_parent_row_total":e=>Vo('Displayed as % of parent row total of "%s"',e),"%_of_parent_col_total":()=>Vo("Displayed as % of parent column total"),"%_of_parent_total":e=>Vo('Displayed as % of parent "%s" total',e),difference_from:e=>Vo('Displayed as difference from "%s"',e),"%_difference_from":e=>Vo('Displayed as % difference from "%s"',e),running_total:e=>Vo('Displayed as running total based on "%s"',e),"%_running_total":e=>Vo('Displayed as % running total based on "%s"',e),rank_asc:e=>Vo('Displayed as rank from smallest to largest based on "%s"',e),rank_desc:e=>Vo('Displayed as rank largest to smallest based on "%s"',e),index:()=>Vo("Displayed as index")},documentation:{no_calculations:Vo("Displays the value that is entered in the field."),"%_of_grand_total":Vo("Displays values as a percentage of the grand total of all the values or data points in the report."),"%_of_col_total":Vo("Displays all the values in each column or series as a percentage of the total for the column or series."),"%_of_row_total":Vo("Displays the value in each row or category as a percentage of the total for the row or category."),"%_of":Vo("Displays values as a percentage of the value of the Base item in the Base field."),"%_of_parent_row_total":Vo("Calculates values as follows:\n(value for the item) / (value for the parent item on rows)"),"%_of_parent_col_total":Vo("Calculates values as follows:\n(value for the item) / (value for the parent item on columns)"),"%_of_parent_total":Vo("Calculates values as follows:\n(value for the item) / (value for the parent item of the selected Base field)"),difference_from:Vo("Displays values as the difference from the value of the Base item in the Base field."),"%_difference_from":Vo("Displays values as the percentage difference from the value of the Base item in the Base field."),running_total:Vo("Displays the value for successive items in the Base field as a running total."),"%_running_total":Vo("Calculates the value as a percentage for successive items in the Base field that are displayed as a running total."),rank_asc:Vo("Displays the rank of selected values in a specific field, listing the smallest item in the field as 1, and each larger value with a higher rank value."),rank_desc:Vo("Displays the rank of selected values in a specific field, listing the largest item in the field as 1, and each smaller value with a higher rank value."),index:Vo("Calculates values as follows:\n((value in cell) x (Grand Total of Grand Totals)) / ((Grand Row Total) x (Grand Column Total))")}},Ky={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},Jy={inSeconds:function(e){return Math.floor(e/Ky.second)},inMinutes:function(e){return Math.floor(e/Ky.minute)},inHours:function(e){return Math.floor(e/Ky.hour)},inDays:function(e){return Math.floor(e/Ky.day)},inMonths:function(e){return Math.floor(e/Ky.month)},inYears:function(e){return Math.floor(e/Ky.year)}},Qy=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function ew(e,t,o){const s=function(e){const t=e.indexOf("h");e=t>=0?e.slice(0,t).replace(/m/g,"M")+e.slice(t):e.replace(/m/g,"M");e.includes("a")||(e=e.replace(/h/g,"H"));return e}(t),i=function(e,t,o){const s=e.map((e=>ls(e,o)?.jsDate));if(s.some((e=>void 0===e))||e.length<2)return;const i=s.map((e=>e.getTime())),n=Ot(i)-Ft(i),r=function(e){if(e.includes("s"))return"second";if(e.includes("m"))return"minute";if(e.includes("h")||e.includes("H"))return"hour";if(e.includes("d"))return"day";if(e.includes("M"))return"month";return"year"}(t);if(Ky.second>=Ky[r]&&Jy.inSeconds(n)<180)return"second";if(Ky.minute>=Ky[r]&&Jy.inMinutes(n)<180)return"minute";if(Ky.hour>=Ky[r]&&Jy.inHours(n)<96)return"hour";if(Ky.day>=Ky[r]&&Jy.inDays(n)<90)return"day";if(Ky.month>=Ky[r]&&Jy.inMonths(n)<36)return"month";return"year"}(e,s,o),n={};return i&&(n[i]=s),{parser:s,displayFormats:n,unit:i??!1}}function tw(e,t,o,s){let i=Cw(s,t,o).formattedValues,n=ww(s,t);iC(o,t[0],e.dataSetsHaveTitle||!1)&&i.shift(),({labels:i,dataSetsValues:n}=vw(i,n)),e.aggregated&&({labels:i,dataSetsValues:n}=bw(i,n));const r=yw(s,t,"left"),a=yw(s,t,"right"),l=e.horizontal?{x:r||a}:{y:r,y1:a},c=[];for(const t in n){const{data:o}=n[t],s=e.dataSets?.[t].trend;if(!s?.display||e.horizontal){c.push(void 0);continue}const i=cw(s,o);c.push(i)}return{dataSetsValues:n,trendDataSetsValues:c,axisFormats:l,labels:i,locale:s.getLocale(),topPadding:xw(e,s)}}function ow(e,t,o,s){const i=tw(e,t.slice(0,2),o,s),n=i.dataSetsValues.filter((e=>!e.hidden)),r=[];if(n[0]){const e=n[0].data.map((e=>e>0?e:0));r.push({...n[0],data:e})}if(n[1]){const e=n[1].data.map((e=>e>0?-e:0));r.push({...n[1],data:e})}return{...i,dataSetsValues:r}}function sw(e,t,o,s){const i=function(e,t,o,s){if(function(e,t,o,s){return!e.labelsAsText&&gw(e,t,o,s)}(e,t,o,s)&&function(){if(!window.Chart)return!1;const e="luxon"===new window.Chart._adapters._date({})._id;e||mw||(mw=!0,console.warn("'chartjs-adapter-luxon' time adapter is not installed. Time scale axes are disabled."));return e}())return"time";if(function(e,t,o,s){return!e.labelsAsText&&pw(e,t,o,s)}(e,t,o,s))return"linear";return"category"}(e,t,o,s),n=Cw(s,t,o);let r="linear"===i?n.values:n.formattedValues,a=ww(s,t);const l=iC(o,t[0],e.dataSetsHaveTitle||!1);l&&r.shift(),({labels:r,dataSetsValues:a}=vw(r,a)),"time"===i&&({labels:r,dataSetsValues:a}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const o=[...e],s=ze(t);for(let e=0;e<o.length;e++)if(!o[e]){o[e]=gt(o,e);for(const t of s)t.data[e]=void 0}return{labels:o,dataSetsValues:s}}(r,a)),e.aggregated&&({labels:r,dataSetsValues:a}=bw(r,a)),e.cumulative&&(a=Iw(a,"asc"));const c={y:yw(s,t,"left"),y1:yw(s,t,"right"),x:Sw(s,o,l)},h=[];for(const t in a){const o=e.dataSets?.[t].trend;if(!o?.display){h.push(void 0);continue}const{data:n}=a[t];h.push(hw(o,n,r,i,s.getLocale()))}return{dataSetsValues:a,axisFormats:c,labels:r,locale:s.getLocale(),trendDataSetsValues:h,axisType:i,topPadding:xw(e,s)}}function iw(e,t,o,s){let i=Cw(s,t,o).formattedValues,n=ww(s,t);iC(o,t[0],e.dataSetsHaveTitle||!1)&&i.shift(),({labels:i,dataSetsValues:n}=vw(i,n)),e.aggregated&&({labels:i,dataSetsValues:n}=bw(i,n)),({dataSetsValues:n,labels:i}=function(e,t){const o=Math.max(e.length,...t.map((e=>e.data?.length||0))),s=je(0,o).filter((e=>t.some((t=>"number"==typeof t.data[e]&&t.data[e]>0))));return{labels:s.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:s.map((t=>"number"==typeof e.data[t]&&e.data[t]>0?e.data[t]:null))})))}}(i,n));return{dataSetsValues:n,axisFormats:{y:yw(s,t,"left")},labels:i,locale:s.getLocale(),topPadding:xw(e,s)}}function nw(e,t,o,s){let i=Cw(s,t,o).formattedValues,n=ww(s,t);iC(o,t[0],e.dataSetsHaveTitle||!1)&&i.shift(),({labels:i,dataSetsValues:n}=vw(i,n)),e.aggregated&&({labels:i,dataSetsValues:n}=bw(i,n));return{dataSetsValues:n,axisFormats:{r:yw(s,t,"left")||yw(s,t,"right")},labels:i,locale:s.getLocale()}}function rw(e,t,o,s){const i=t.slice(0,1);let n=Cw(s,i,o).formattedValues;iC(o,i[0],e.dataSetsHaveTitle||!1)&&n.shift();let r=ww(s,i);({labels:n,dataSetsValues:r}=bw(n,r));return{dataSetsValues:r,axisFormats:{y:yw(s,i,"left")||yw(s,i,"right")},labels:n,locale:s.getLocale(),availableRegions:s.getGeoChartAvailableRegions(),geoFeatureNameToId:s.geoFeatureNameToId,getGeoJsonFeatures:s.getGeoJsonFeatures}}function aw(e,t,o,s){let i=Cw(s,t,o).formattedValues,n=ww(s,t);iC(o,t[0],e.dataSetsHaveTitle||!1)&&i.shift(),({labels:i,dataSetsValues:n}=vw(i,n)),e.aggregated&&({labels:i,dataSetsValues:n}=bw(i,n)),e.cumulative&&(n=Iw(n,"desc"));return{dataSetsValues:n,axisFormats:{x:yw(s,t,"left")||yw(s,t,"right")},labels:i,locale:s.getLocale()}}function lw(e,t,o,s){let i=Cw(s,t,o).values,n=function(e,t){t=t.filter((t=>!e.isColHidden(t.dataRange.sheetId,t.dataRange.zone.left)));const o=t.map((()=>({data:[],label:""}))),s=t.map((t=>fw(e,t)));if(!s.length)return o;const i=Math.min(...s.map((e=>e.length)));let n=[];const r=t.length-1;for(let e=0;e<i;e++)for(let t=0;t<s.length;t++){let i=s[t][e];null==i&&t!==r&&(i=n[t]),i!==n[t]&&(n=n.slice(0,t),n[t]=i),o[t].data.push(i??null)}return o.filter((e=>e.data.some((e=>null!==e))))}(s,t);const r=iC(o,t[0],e.dataSetsHaveTitle||!1);return r&&i.shift(),({labels:i,dataSetsValues:n}=function(e,t){const o=[],s=[];for(let t=0;t<e.length;t++)Number(e[t])<=0?s.push(t):Number(e[t])>0&&o.push(t);const i=o.length?o:s;return{labels:i.map((t=>e[t])),dataSetsValues:t.map((e=>({...e,data:i.map((t=>e.data[t]))})))}}(i,n)),({labels:i,dataSetsValues:n}=function(e,t){const o=Math.max(e.length,...t.map((e=>e.data?.length||0))),s=e=>null==e||""===e,i=je(0,o).filter((o=>{const i=t.map((e=>e.data?.[o]));if(s(i[0]))return!1;let n=!1;for(const e of i)if(n||=s(e),n&&!s(e))return!1;return e[o]&&!isNaN(Number(e[o]))}));return{labels:i.map((t=>e[t])),dataSetsValues:t.map((e=>({...e,data:i.map((t=>e.data[t]))})))}}(i,n)),{dataSetsValues:n,axisFormats:{y:Sw(s,o,r)},labels:i,locale:s.getLocale()}}function cw(e,t){const o=[],s=[],i=[];for(let e=0;e<t.length;e++)"number"==typeof t[e]&&(o.push(t[e]),s.push(e+1)),i.push(e+1);const n=dw(e,o,s,je(.5,i.length+.55,.2));return n.length?n:void 0}function hw(e,t,o,s,i){const n=[],r=[],a=[],l=t.length;if(l<2)return;switch(s){case"category":for(let e=0;e<l;e++)"number"==typeof t[e]&&(n.push(t[e]),r.push(e+1)),a.push(e+1);break;case"linear":for(let e=0;e<t.length;e++){const s=Number(o[e]);isNaN(s)||("number"==typeof t[e]&&(n.push(t[e]),r.push(s)),a.push(s))}break;case"time":for(let e=0;e<t.length;e++){const s=gi({value:o[e]},i);null!==t[e]&&(n.push(t[e]),r.push(s)),a.push(s)}}const c=Math.min(...a),h=Math.max(...a);if(h===c)return;const d=(h-c)/(5*a.length),u=dw(e,n,r,je(c,h+d/2,d));return u.length?u:void 0}function dw(e,t,o,s){if(t.length<2||o.length<2||0===s.length)return[];const{normalizedLabels:i,normalizedNewLabels:n}=function(e,t,o){let s=[],i=[];if("logarithmic"===o.type){const o=Math.max(...e.map(Math.abs));s=e.map((e=>e/o)),i=t.map((e=>e/o))}else{const o=Math.max(...e),n=Math.min(...e),r=o-n;s=e.map((e=>(e-o)/r)),i=t.map((e=>(e-o)/r))}return{normalizedLabels:s,normalizedNewLabels:i}}(o,s,e);try{switch(e.type){case"polynomial":{const o=e.order;if(!o)return s.map((e=>({x:e,y:NaN})));if(1===o)return hc([t],[i],[n],!0)[0].map(((e,t)=>({x:s[t],y:e})));const r=nc(t,i,o,!0).flat();return n.map(((e,t)=>({x:s[t],y:ac(r,e,o)})))}case"exponential":{const e=[],o=[];for(let s=0;s<t.length;s++)t[s]>0&&(e.push(Math.log(t[s])),o.push(i[s]));return o.length?lc(hc([e],[o],[n],!0))[0].map(((e,t)=>({x:s[t],y:e}))):s.map((e=>({x:e,y:NaN})))}case"logarithmic":return hc([t],cc([i]),cc([n]),!0)[0].map(((e,t)=>({x:s[t],y:e})));case"trailingMovingAverage":return function(e,t,o=Ae){const s=[];for(let e=0;e<o-1;e++)s.push({x:t[e],y:NaN});for(let i=0;i<=e.length-o;i++){let n=0;for(let t=i;t<i+o;t++)n+=e[t];s.push({x:t[i+o-1],y:n/o})}return s}(t,o,e.window);default:return s.map((e=>({x:e,y:NaN})))}}catch(e){return s.map((e=>({x:e,y:NaN})))}}function uw(e,t,o,s){return gw(e,t,o,s)||pw(e,t,o,s)}function gw(e,t,o,s){if(!o||!pw(e,t,o,s))return!1;const i=Sw(s,o,iC(o,t[0],e.dataSetsHaveTitle||!1));return Boolean(i&&Qy.test(i))}function pw(e,t,o,s){if(!o)return!1;const i=s.getRangeValues(o);return iC(o,t[0],e.dataSetsHaveTitle||!1)&&i.shift(),!i.some((e=>isNaN(Number(e))&&e))&&!i.every((e=>!e))}let mw=!1;function fw(e,t){if(t.dataRange){const o=t.labelCell?[t.labelCell.zone]:[],s=er([t.dataRange.zone],o)[0];if(void 0===s)return[];const i=e.getRangeFromZone(t.dataRange.sheetId,s);return e.getRangeValues(i).map((e=>""===e?void 0:e))}return[]}function vw(e,t){const o=je(0,Math.max(e.length,...t.map((e=>e.data?.length||0)))).filter((o=>{const s=e[o],i=t.map((e=>e.data?.[o]));return s||i.some((e=>"number"==typeof e))}));return{labels:o.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:o.map((t=>"number"==typeof e.data[t]?e.data[t]:null))})))}}function bw(e,t){const o=new Set(e),s={};o.forEach((e=>{s[e]=new Array(t.length).fill(0)}));for(const o of je(0,e.length)){const n=e[o];for(const e of je(0,t.length))s[n][e]+="number"==typeof(i=t[e].data[o])?i:0}var i;return{labels:Array.from(o),dataSetsValues:t.map(((e,t)=>({...e,data:Array.from(o).map((e=>s[e][t]))})))}}function Sw(e,t,o){if(!t)return;const{sheetId:s,zone:i}=t,n=Er(i).map((t=>e.getEvaluatedCell({sheetId:s,...t}).format));return o&&n.shift(),n.find((e=>void 0!==e))}function Cw(e,t,o){let s={values:[],formattedValues:[]};if(o){const{left:i}=o.zone;if(o.invalidXc||o.invalidSheetName||e.isColHidden(o.sheetId,i)){if(t[0]){s={formattedValues:je(0,fw(e,t[0]).length).map((e=>e.toString())),values:s.formattedValues}}}else s={formattedValues:e.getRangeFormattedValues(o),values:e.getRangeValues(o).map((e=>String(e??"")))}}else if(1===t.length){const o=fw(e,t[0]).length;for(let e=0;e<o;e++)s.formattedValues.push(""),s.values.push("")}else if(t[0]){s={formattedValues:je(0,fw(e,t[0]).length).map((e=>e.toString())),values:s.formattedValues}}return s}function yw(e,t,o){const s=t.filter((e=>"right"===o==!!e.rightYAxis));for(const t of s){const o=e.getRangeFormats(t.dataRange).find((e=>void 0!==e&&!Rn(e)));if(o)return o}}function ww(e,t){const o=[];for(const[s,i]of Object.entries(t)){let t,n=e.isColHidden(i.dataRange.sheetId,i.dataRange.zone.left);if(i.labelCell){const o=i.labelCell,n=o?e.getEvaluatedCell({sheetId:o.sheetId,col:o.zone.left,row:o.zone.top}):void 0;t=n&&o?n.formattedValue:t=`${$y.Series} ${parseInt(s)+1}`}else t=`${$y.Series} ${parseInt(s)+1}`;const r=i.dataRange?fw(e,i):[];r.every((e=>"string"==typeof e&&!hi(e)))&&r.some((e=>""!==e))?r.fill(1):r.every((e=>null==e||!Is(e.toString(),$s)))&&(n=!0),o.push({data:r,label:t,hidden:n})}return o}function Iw(e,t){return e.map((e=>{const o=[];let s=0;const i="asc"===t?Object.keys(e.data):Object.keys(e.data).reverse();for(const t of i)isNaN(parseFloat(e.data[t]))?o[t]=e.data[t]:(s+=parseFloat(e.data[t]),o[t]=s);return{...e,data:o}}))}function xw(e,t){const{title:o,legendPosition:s}=e,i=o&&o.text||"top"===s;return t.isDashboard()&&!i?30:0}function Ew(e,t){return{padding:{left:j,right:j,top:Math.max(X,t.topPadding||0),bottom:Y}}}function Rw(e,t){return{display:"none"!==e.legendPosition,position:"none"!==e.legendPosition?e.legendPosition:void 0}}function Tw(e,t){return{...Nw,...Rw(e),...kw(eC(e.background),{pointStyle:"rect",lineWidth:3})}}function Aw(e,t){const o=e.fillArea,s=o?"rect":"line",i=o?2:3;return{...Nw,...Rw(e),...kw(eC(e.background),{pointStyle:s,lineWidth:i})}}function Dw(e,t){const{dataSetsValues:o}=t,s=Math.max(0,...o.map((e=>e?.data?.length??0))),i=cC(new po(s),o),n=eC(e.background);return{...Rw(e),labels:{usePointStyle:!0,generateLabels:e=>(e.data.labels?.map(((e,t)=>({text:hC(String(e)),strokeStyle:i[t],fillStyle:i[t],pointStyle:"rect",lineWidth:2,fontColor:n})))||[]).filter((e=>e.text)),filter:(e,t)=>!("datasetIndex"in e)||!t.datasets[e.datasetIndex].hidden}}}function _w(e,t){return{...Nw,...Rw(e),...kw(eC(e.background),{pointStyle:"circle",strokeStyle:e.background||"#ffffff",lineWidth:8})}}function Ow(e,t){return{...Nw,...Rw(e),...kw(eC(e.background),{lineWidth:3})}}function Fw(e,t){const o=eC(e.background),s=e.negativeValuesColor||A,i=e.positiveValuesColor||T,n=e.subTotalValuesColor||D;return{...Rw(e),labels:{usePointStyle:!0,generateLabels:()=>{const t=[{text:Vo("Positive values"),fontColor:o,fillStyle:i,strokeStyle:i,pointStyle:"rect"},{text:Vo("Negative values"),fontColor:o,fillStyle:s,strokeStyle:s,pointStyle:"rect"}];return(e.showSubTotals||e.firstValueAsSubtotal)&&t.push({text:Vo("Subtotals"),fontColor:o,fillStyle:n,strokeStyle:n,pointStyle:"rect"}),t},filter:(e,t)=>!("datasetIndex"in e)||!t.datasets[e.datasetIndex].hidden},onClick:()=>{}}}function Pw(e,t){const o=e.fillArea??!1,s=o?"rect":"line",i=o?2:3;return{...Nw,...Rw(e),...kw(eC(e.background),{pointStyle:s,lineWidth:i})}}function Mw(e,t){const o=eC(e.background);return{...Rw(e),labels:{usePointStyle:!0,generateLabels:e=>{const t=e.data.datasets.at(-1);if(!t)return[];return t.groupColors.map((({color:e,label:t})=>({text:hC(t),fontColor:o,fillStyle:e,strokeStyle:e,pointStyle:"rect"})))}}}}const Nw={onHover:e=>{const t=e.native?.target;t&&(t.style.cursor="pointer")},onLeave:e=>{const t=e.native?.target;t&&(t.style.cursor="default")},onClick:(e,t,o)=>{if("click"!==e.type)return;const s=t.datasetIndex;o.legendItems&&void 0!==s&&(o.chart.isDatasetVisible(s)?o.chart.hide(s):o.chart.show(s),e.native.preventDefault(),e.native.stopPropagation())}};function kw(e,t){return{labels:{color:e,usePointStyle:!0,generateLabels:o=>o.data.datasets.map(((s,i)=>dC(s.xAxisID)?{text:hC(s.label),fontColor:e,strokeStyle:s.borderColor,hidden:!o.isDatasetVisible(i),pointStyle:"line",datasetIndex:i,lineWidth:3}:{text:hC(s.label),fontColor:e,strokeStyle:s.borderColor,fillStyle:s.backgroundColor,hidden:!o.isDatasetVisible(i),pointStyle:"line"===s.type?"line":"rect",datasetIndex:i,...t})).filter((e=>e.text)),filter:(e,t)=>!("datasetIndex"in e)||!t.datasets[e.datasetIndex].hidden}}}function Vw(e,t){let o={};const{trendDataSetsValues:s,locale:i,axisFormats:n}=t,r={stacked:e.stacked,locale:i};if(e.horizontal)o.x=Zw(e,"bottom","values",{...r,format:n?.x}),o.y=Zw(e,"left","labels",r);else{o.x=Zw(e,"bottom","labels",r);const t={...r,format:n?.y};o.y=Zw(e,"left","values",t);const s={...r,format:n?.y1};o.y1=Zw(e,"right","values",s)}if(o=bt(o),s&&s.length&&s.some(lt)){const e=Math.max(...s.map((e=>e?.length||0)));o[zS]={...o.x,labels:Array(e).fill(""),offset:!1,display:!1},o[$S]={...o.x,offset:!0,display:!1}}return o}function Lw(e,t){const{locale:o,axisType:s,trendDataSetsValues:i,labels:n,axisFormats:r}=t,a=r?.x,l=e.stacked;let c={x:Zw(e,"bottom","labels",{locale:o}),y:Zw(e,"left","values",{locale:o,stacked:l,format:r?.y}),y1:Zw(e,"right","values",{locale:o,stacked:l,format:r?.y1})};if(c=bt(c),"time"===s&&n&&a){const e={type:"time",time:ew(n,a,o)};Object.assign(c.x,e),c.x.ticks.maxTicksLimit=15}else"linear"===s&&(c.x.type="linear",c.x.ticks.callback=e=>bn(e,{format:a,locale:o}));if(i&&i.length&&i.some(lt)&&(c[zS]={...c.x,display:!1},c[$S]={...c.x,display:!1},"category"===s||"time"===s)){const e=Math.max(...i.map((e=>e?.length||0)));c[zS].type="category",c[zS].labels=je(0,e).map((e=>e.toString())),c[zS].offset=!1,c[$S].type="category",c[$S].offset=!1}return c}function Hw(e,t){const o=Lw(e,t);return{...o,x:{...o.x,grid:{display:!0}}}}function Uw(e,t){const{locale:o,axisFormats:s}=t,i=s?.y||s?.y1;e.dataSets;const n={x:{...Zw(e,"bottom","labels",{locale:o}),grid:{display:!1}},y:{position:e.verticalAxisPosition,ticks:{color:eC(e.background),callback:aC({locale:o,format:i})},grid:{lineWidth:e=>0===e.tick.value?2:1},title:qw(e.axesDesign?.y)}},r=n?.y||n?.y1;return r&&(r.grid={lineWidth:e=>0===e.tick.value?2:1}),n}function Bw(e,t){const{dataSetsValues:o}=t,s=Vw(e,t),i=s.x.ticks.callback;s.x.ticks.callback=e=>i(Math.abs(e));const n=Math.max(...o.map((e=>Math.max(...e.data.map(Math.abs)))));return s.x.suggestedMin=-n,s.x.suggestedMax=n,s}function zw(e,t){const{locale:o,axisFormats:s,dataSetsValues:i}=t,n=Math.min(...i.map((e=>Math.min(...e.data.filter((e=>!isNaN(e)))))));return{r:{beginAtZero:!0,ticks:{callback:aC({format:s?.r,locale:o}),backdropColor:e.background||"#FFFFFF"},pointLabels:{color:eC(e.background),callback:hC},suggestedMin:n<0?n-1:0}}}function $w(e,t){const{locale:o,axisFormats:s,availableRegions:i}=t,n=function(e){switch(e){case"top":return"top-left";case"right":return"top-right";case"bottom":return"bottom-right";case"left":case"none":return"bottom-left"}}(e.legendPosition),r=e.region?i.find((t=>t.id===e.region)):i[0],a=s?.y||s?.y1;return{projection:{projection:Ww(r?.defaultProjection||"mercator"),axis:"x"},color:{axis:"x",display:"none"!==e.legendPosition,border:{color:O},grid:{color:O},ticks:{color:eC(e.background),callback:aC({locale:o,format:a})},legend:{position:n,align:n.includes("right")?"left":"right",margin:Yw(e)},interpolate:jw(e),missing:e.missingValueColor||"#ffffff"}}}function Gw(e,t){const o=t.dataSetsValues[0];return{x:{display:!1},y:{grid:{offset:!1},ticks:{callback:function(e){return hC(this.getLabelForValue(e))}},border:{display:!1}},percentages:{position:"right",border:{display:!1},ticks:{callback:function(e,s,i){const n=o.data?.[s],r=o.data?.[0];return r&&void 0!==n?bn(n/r,{format:"0%",locale:t.locale}):""}},grid:{display:!1}}}}function Ww(e){return"conicConformal"===e?window.ChartGeo.geoConicConformal().rotate([100,0]):e}function qw(e){if(e?.title?.text){const{text:t,color:o,align:s,italic:i,bold:n}=e.title;return{display:!0,text:t,color:o,font:{style:i?"italic":"normal",weight:n?"bold":"normal",size:e.title.fontSize??J},align:"left"===s?"start":"right"===s?"end":"center"}}}function Zw(e,t,o,s){const{useLeftAxis:i,useRightAxis:n}=nC(e);if("left"===t&&!i||"right"===t&&!n)return;const r=eC(e.background);let a;if(a="bottom"===t?e.axesDesign?.x:"left"===t?e.axesDesign?.y:e.axesDesign?.y1,"values"===o){const e=!("right"===t&&i);return{position:t,title:qw(a),grid:{display:e},beginAtZero:!0,stacked:s?.stacked,ticks:{color:r,callback:aC(s)}}}return{ticks:{padding:5,color:r,callback:function(e){return hC(this.getLabelForValue(e))}},grid:{display:!1},stacked:s?.stacked,title:qw(a)}}function jw(e){if(!e.colorScale||"string"==typeof e.colorScale)return e.colorScale||"oranges";const t=[{value:0,color:e.colorScale.minColor}];return e.colorScale.midColor&&t.push({value:.5,color:e.colorScale.midColor}),t.push({value:1,color:e.colorScale.maxColor}),vo(t)}function Yw(e){switch(e.legendPosition){case"top":case"right":return{top:!!e.title.text?X+30:X,left:j,right:j};case"bottom":case"left":case"none":return{left:j,right:j,bottom:Y}}}const Xw={showValues:!1,showLabels:!0,valuesDesign:{align:"center",fontSize:13}};function Kw(e,t){const{axisFormats:o,locale:s}=t;return{horizontal:"horizontal"in e&&e.horizontal,showValues:"showValues"in e&&!!e.showValues,background:e.background,callback:(t,i)=>{const n=function(e,t){if(t.rAxisID)return t.rAxisID;const o="horizontal"in e&&e.horizontal?t.xAxisID:t.yAxisID;return o||"y"}(e,i);return rC(o,s)(t,n)}}}function Jw(e,t){const{axisFormats:o,locale:s}=t;return{callback:rC(o,s),showLabels:e.showLabels??Xw.showLabels,showValues:e.showValues??Xw.showValues,style:{fontSize:e.valuesDesign?.fontSize??Xw.valuesDesign.fontSize,align:e.valuesDesign?.align??Xw.valuesDesign.align,bold:e.valuesDesign?.bold??Xw.valuesDesign.bold,italic:e.valuesDesign?.italic??Xw.valuesDesign.italic,textColor:e.valuesDesign?.color??Xw.valuesDesign.color}}}function Qw(e,t){const{axisFormats:o,locale:s}=t;return{horizontal:!0,showValues:"showValues"in e&&!!e.showValues,background:e.background,callback:(e,t)=>0===(e=Math.abs(Number(e)))?"":rC(o,s)(e,t.xAxisID||"x")}}function eI(e,t){const{axisFormats:o,locale:s,dataSetsValues:i}=t,n=i.reduce(((e,t)=>(e.push((e.at(-1)||-1)+t.data.length+1),e)),[]);return{showValues:"showValues"in e&&!!e.showValues,background:e.background,callback:(t,i,r)=>{const a=i._dataset.data[r],l=a[1]-a[0];let c=l>=0?"+":"";return e.showSubTotals&&n.includes(r)&&"+"===c&&(c=""),`${c}${rC(o,s)(l,i.yAxisID)}`}}}function tI(e){const t=e.title,o=tC(e.background);return{display:!!t.text,text:Vo(t.text),color:t?.color??o,align:"center"===t.align?"center":"right"===t.align?"end":"start",font:{size:e.title.fontSize??K,weight:t.bold?"bold":"normal",style:t.italic?"italic":"normal"},padding:{bottom:"top"===e.legendPosition?0:j}}}const oI='\n<templates>\n <t t-name="o-spreadsheet-CustomTooltip">\n <div\n class="o-chart-custom-tooltip border rounded px-2 py-1 pe-none mw-100 position-absolute text-nowrap shadow opacity-100">\n <table class="overflow-hidden m-0">\n <thead t-if="title">\n <tr>\n <th class="o-tooltip-title align-baseline border-0 text-truncate" t-esc="title" t-attf-style="max-width: {{ labelsMaxWidth }}"/>\n </tr>\n </thead>\n <tbody>\n <tr t-foreach="tooltipItems" t-as="tooltipItem" t-key="tooltipItem_index">\n <td>\n <span\n class="badge ps-2 py-2 rounded-0 align-middle"\n t-attf-style="background-color: {{ tooltipItem.boxColor }}"\n > </span>\n <small\n t-if="tooltipItem.label"\n class="o-tooltip-label d-inline-block text-truncate align-middle smaller ms-2"\n t-esc="tooltipItem.label"\n t-attf-style="max-width: {{ labelsMaxWidth }}"\n />\n </td>\n <td class="o-tooltip-value ps-2 fw-bolder text-end">\n <small class="smaller d-inline-block text-truncate align-middle" t-attf-style="max-width: {{ valuesMaxWidth }}">\n <t t-esc="tooltipItem.value"/>\n <t t-if="tooltipItem.percentage">\n (\n <t t-esc="tooltipItem.percentage"/>\n %)\n </t>\n </small>\n </td>\n </tr>\n </tbody>\n </table>\n </div>\n </t>\n</templates>\n';let sI;function iI(e,o={}){return function(e,o={}){sI||(sI=new t.App(t.Component,{templates:oI,translateFn:Vo}));const s=sI.getTemplate(e),i=s(o,{}),n=document.createElement("div");return t.blockDom.mount(i,n),n}(e,o).innerHTML}function nI(e,t){return{enabled:!1,external:mI,callbacks:{title:function(e){return e.some((e=>!dC(e.dataset.xAxisID)))?void 0:""},beforeLabel:e=>e.dataset?.label||e.label,label:function(o){const s=e.horizontal;let i=s?o.parsed.x:o.parsed.y;null==i&&(i=o.parsed);const n=s?o.dataset.xAxisID:o.dataset.yAxisID;return rC(t.axisFormats,t.locale)(i,n)}}}}function rI(e,t){const{axisType:o,locale:s,axisFormats:i}=t,n=i?.x,r={enabled:!1,external:mI,callbacks:{}};return r.callbacks.label="linear"===o?e=>{const t=e.parsed.y;let o=dC(e.dataset.xAxisID)?"":e.parsed.x;"string"==typeof o&&Is(o,s)&&(o=gi(o,s));const r=bn(o,{locale:s,format:n}),a=e.dataset.yAxisID||"y",l=bn(t,{locale:s,format:i?.[a]});return r?`(${r}, ${l})`:`${l}`}:function(e){const t=e.parsed.y,o=e.dataset.yAxisID;return rC(i,s)(t,o)},r.callbacks.beforeLabel=e=>e.dataset?.label||e.label,r.callbacks.title=function(e){return"linear"!==o&&e.some((e=>!dC(e.dataset.xAxisID)))?void 0:""},r}function aI(e,t){const{locale:o,axisFormats:s}=t,i=s?.y||s?.y1;return{enabled:!1,external:mI,callbacks:{title:function(e){return e[0].dataset.label},beforeLabel:e=>e.label||e.dataset.label,label:function(e){const t=function(e,t){const o=e.filter((e=>"number"==typeof e)).reduce(((e,t)=>e+t),0);if(!o)return"";const s=e[t]/o*100;return s.toFixed(2)}(e.dataset.data,e.dataIndex),s=e.parsed.y??e.parsed;return`${bn(s,{format:!i&&s>=1e3?"#,##":i,locale:o})} (${t}%)`}}}}function lI(e,t){const{dataSetsValues:o,locale:s,axisFormats:i,labels:n}=t,r=i?.y||i?.y1,a=o.map((e=>e.label));return{enabled:!1,external:mI,callbacks:{beforeLabel:function(e){const t=n.length?Math.floor(e.dataIndex/n.length):0;return a[t]},label:function(e){const[t,o]=e.raw,i=o-t;return bn(i,{format:!r&&Math.abs(i)>1e3?"#,##":r,locale:s})}}}}function cI(e,t){const o=nI(e,t);return{...o,callbacks:{...o.callbacks,label:e=>{const t={...e,parsed:{y:e.parsed.y,x:Math.abs(e.parsed.x)}};return(o?.callbacks?.label)(t)}}}}function hI(e,t){const{locale:o,axisFormats:s}=t;return{enabled:!1,external:mI,callbacks:{beforeLabel:e=>e.dataset?.label||e.label,label:function(e){return bn(e.parsed.r,{format:s?.r,locale:o})}}}}function dI(e,t){const{locale:o,axisFormats:s}=t,i=s?.y||s?.y1;return{enabled:!1,external:mI,filter:function(e){return void 0!==e.raw.value},callbacks:{beforeLabel:e=>e.raw.feature.properties.name,label:function(e){const t=e.raw.value;return bn(t,{format:!i&&Math.abs(t)>=1e3?"#,##":i,locale:o})}}}}function uI(e,t){return{enabled:!1,external:mI,position:"funnelTooltipPositioner",callbacks:{title:()=>"",beforeLabel:e=>e.label,label:function(e){const o=e.parsed.x,s=e.dataset.xAxisID;return rC(t.axisFormats,t.locale)(o,s)}}}}function gI(e,t){const{locale:o,axisFormats:s}=t,i=s?.y||s?.y1;return{enabled:!1,external:mI,filter:function(e){const t=e.raw;return t?.label!==fC},callbacks:{title:()=>"",beforeLabel:e=>e.raw.groups.join(" / "),label:function(e){const t=e.raw.value;return bn(t,{format:!i&&t>=1e3?"#,##":i,locale:o})}}}}function pI(e,t){const{locale:o,axisFormats:s}=t,i=s?.y;return{enabled:!1,external:mI,filter:(e,t,o)=>t===o.length-1,callbacks:{title:()=>"",beforeLabel:e=>{const t=e.raw._data.children[0];if(!t)return"";const o=[];for(let s=0;s<=e.raw.l;s++)o.push(t[s]);return o.join(" / ")},label:e=>{const t=e.raw.v;return bn(t,{format:!i&&t>=1e3?"#,##":i,locale:o})}}}}function mI({chart:e,tooltip:t}){if(e.canvas.parentNode.querySelector("div.o-chart-custom-tooltip")?.remove(),0===t.opacity||0===t.dataPoints.length)return;const o=t.body.map(((e,o)=>{let s=e.before[0],i=e.lines[0];i||(i=s,s="");const n=t.labelColors[o].backgroundColor;return{label:s,value:i,boxColor:"string"==typeof n?eo(n,1):n}})),s=iI("o-spreadsheet-CustomTooltip",{labelsMaxWidth:Math.floor(.5*e.canvas.clientWidth)+"px",valuesMaxWidth:Math.floor(.25*e.canvas.clientWidth)+"px",title:t.title[0],tooltipItems:o}),i=Object.assign(document.createElement("template"),{innerHTML:s}).content.firstChild;e.canvas.parentNode?.appendChild(i),Object.assign(i.style,{left:fI(e,t,i.clientWidth)+"px",top:Math.floor(t.caretY-i.clientHeight/2)+"px"})}function fI(e,t,o){const s=t.caretX;return s+o>e.chartArea.right?Math.max(0,s-o):s}var vI=Object.freeze({__proto__:null,GHOST_SUNBURST_VALUE:fC,INTERACTIVE_LEGEND_CONFIG:Nw,canChartParseLabels:uw,getBarChartData:tw,getBarChartDatasets:vC,getBarChartLegend:Tw,getBarChartScales:Vw,getBarChartTooltip:nI,getChartColorsGenerator:NC,getChartLabelFormat:Sw,getChartLayout:Ew,getChartShowValues:Kw,getChartTitle:tI,getComboChartDatasets:wC,getComboChartLegend:Ow,getData:fw,getFunnelChartData:aw,getFunnelChartDatasets:EC,getFunnelChartScales:Gw,getFunnelChartTooltip:uI,getFunnelLabelColors:RC,getGeoChartData:rw,getGeoChartDatasets:xC,getGeoChartScales:$w,getGeoChartTooltip:dI,getHierarchalChartData:lw,getLineChartData:sw,getLineChartDatasets:SC,getLineChartLegend:Aw,getLineChartScales:Lw,getLineChartTooltip:rI,getPieChartData:iw,getPieChartDatasets:yC,getPieChartLegend:Dw,getPieChartTooltip:aI,getPyramidChartData:ow,getPyramidChartScales:Bw,getPyramidChartShowValues:Qw,getPyramidChartTooltip:cI,getRadarChartData:nw,getRadarChartDatasets:IC,getRadarChartLegend:Pw,getRadarChartScales:zw,getRadarChartTooltip:hI,getScatterChartDatasets:CC,getScatterChartLegend:_w,getScatterChartScales:Hw,getSunburstChartDatasets:TC,getSunburstChartLegend:Mw,getSunburstChartTooltip:gI,getSunburstShowValues:Jw,getTopPaddingForDashboard:xw,getTreeMapChartDatasets:OC,getTreeMapChartTooltip:pI,getTrendDatasetForBarChart:cw,getTrendDatasetForLineChart:hw,getWaterfallChartLegend:Fw,getWaterfallChartScales:Uw,getWaterfallChartShowValues:eI,getWaterfallChartTooltip:lI,getWaterfallDatasetAndLabels:bC,makeDatasetsCumulative:Iw});class bI extends $C{dataSets;labelRange;background;legendPosition;stacked;aggregated;type="bar";dataSetsHaveTitle;dataSetDesign;axesDesign;horizontal;showValues;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.horizontal=e.horizontal,this.showValues=e.showValues}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,stacked:e.stacked??!1,aggregated:e.aggregated??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"bar",labelRange:e.auxiliaryRange||void 0,axesDesign:e.axesDesign,showValues:e.showValues}}getContextCreation(){const e=[];for(const[t,o]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(o.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new bI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new bI(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=[];for(const[t,i]of e.entries())s.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,o||this.sheetId)});return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated,axesDesign:this.axesDesign,horizontal:this.horizontal,showValues:this.showValues}}getDefinitionForExcel(){const e=this.dataSets.map((e=>KS(this.getters,e))).filter((e=>""!==e.range&&e.range!==Js.InvalidReference)),t=JS(this.getters,this.labelRange,iC(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle)),o=this.getDefinition();return{...o,backgroundColor:wy(this.background||m),fontColor:wy(eC(this.background)),dataSets:e,labelRange:t,verticalAxis:nC(o)}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new bI(i,this.sheetId,this.getters)}}function SI(e,t){const o=e.getDefinition(),s=tw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"bar",data:{labels:s.labels,datasets:vC(o,s)},options:{...Ly,indexAxis:e.horizontal?"y":"x",layout:Ew(0,s),scales:Vw(o,s),plugins:{title:tI(o),legend:Tw(o),tooltip:nI(o,s),chartShowValuesPlugin:Kw(o,s)}}},background:e.background||m}}const CI=new n;CI.add("animatedBackgroundColorChange",{id:"animatedBackgroundColorChange",easingFn:"easeOutCubic",hasAnimation:(e,t)=>e?.style?.fillColor!==t?.style?.fillColor,updateAnimation:function(e,t,o,s){const i=vo([{value:0,color:o.style.fillColor||"#ffffff"},{value:1,color:s.style.fillColor||"#ffffff"}]);t.style.fillColor=i(yI[this.easingFn](e))}}),CI.add("animatedTextColorChange",{id:"animatedTextColorChange",easingFn:"easeOutCubic",hasAnimation:(e,t)=>e?.style?.textColor!==t?.style?.textColor,updateAnimation:function(e,t,o,s){const i=vo([{value:0,color:o.style.textColor||"#000000"},{value:1,color:s.style.textColor||"#000000"}]);t.style.textColor=i(yI[this.easingFn](e))}}),CI.add("animatedDataBar",{id:"animatedDataBar",easingFn:"easeOutCubic",hasAnimation:(e,t)=>e?.dataBarFill?.percentage!==t?.dataBarFill?.percentage,updateAnimation:function(e,t,o,s){const i=o?.dataBarFill?.percentage||0,n=i+((s?.dataBarFill?.percentage||0)-i)*yI[this.easingFn](e);t.dataBarFill={color:s.dataBarFill?.color||o.dataBarFill?.color||"#ffffff",percentage:n}}}),CI.add("textFadeIn",{id:"textFadeIn",easingFn:"easeInCubic",hasAnimation:(e,t)=>{const o=e?.content?.textLines?.join("\n"),s=t?.content?.textLines?.join("\n");return Boolean(!o&&s)},updateAnimation:function(e,t,o,s){t.textOpacity=yI[this.easingFn](e)}}),CI.add("textFadeOut",{id:"textFadeOut",easingFn:"easeOutCubic",hasAnimation:(e,t)=>{const o=e?.content?.textLines?.join("\n"),s=t?.content?.textLines?.join("\n");return Boolean(o&&!s)},updateAnimation:function(e,t,o,s){const i=1-yI[this.easingFn](e),n={...o.style};delete n.fillColor,t.textOpacity=i,t.content=o.content,t.clipRect=o.clipRect,Object.assign(t.style,n)}}),CI.add("textChange",{id:"textChange",easingFn:"easeOutCubic",hasAnimation:(e,t)=>{const o=e?.content?.textLines?.join("\n"),s=t?.content?.textLines?.join("\n");return Boolean(o&&s&&o!==s)||xI(t,e)},updateAnimation:function(e,t,o,s){const i=yI[this.easingFn](e),n=s.y+(i-1)*s.height,r=s.y+i*s.height,a=xI(s,o),l={id:s.id+"-text-slide-in",x:s.x,y:n,width:s.width,height:s.height,style:{...s.style},skipCellGridLines:!0,content:s.content,clipRect:s.clipRect||{...s,x:Math.max(0,s.x-(s.content?.width||0)),width:s.width+2*(s.content?.width||0)},icons:a?II(s.icons,s):wI(s.icons)},c={id:o.id+"-text-slide-out",x:s.x,y:r,width:s.width,height:s.height,style:{...o.style},skipCellGridLines:!0,content:o.content,clipRect:o.clipRect||{...s,x:Math.max(0,s.x-(o.content?.width||0)),width:s.width+2*(o.content?.width||0)},icons:a?II(o.icons,s):wI(o.icons)};if(s.content&&o.content&&l.content&&c.content){const e=s.content.y+(i-1)*s.height,t=s.content.y+i*s.height;l.content.y=e,c.content.y=t}return c.style.fillColor=l.style.fillColor=void 0,t.content=void 0,t.icons=a?{}:t.icons,{newBoxes:[l,c]}}}),CI.add("borderFadeIn",{id:"borderFadeIn",easingFn:"easeInCubic",hasAnimation:(e,t)=>Boolean(!e?.border?.bottom&&t?.border?.bottom||!e?.border?.top&&t?.border?.top||!e?.border?.left&&t?.border?.left||!e?.border?.right&&t?.border?.right),updateAnimation:function(e,t,o,s){const i=yI[this.easingFn](e);t.border?.top&&s.border?.top&&!o.border?.top&&(t.border.top.opacity=i),t.border?.bottom&&s.border?.bottom&&!o.border?.bottom&&(t.border.bottom.opacity=i),t.border?.left&&s.border?.left&&!o.border?.left&&(t.border.left.opacity=i),t.border?.right&&s.border?.right&&!o.border?.right&&(t.border.right.opacity=i)}}),CI.add("borderFadeOut",{id:"borderFadeOut",easingFn:"easeOutCubic",hasAnimation:(e,t)=>Boolean(e?.border?.bottom&&!t?.border?.bottom||e?.border?.top&&!t?.border?.top||e?.border?.left&&!t?.border?.left||e?.border?.right&&!t?.border?.right),updateAnimation:function(e,t,o,s){const i=1-yI[this.easingFn](e);t.border||(t.border={}),o.border?.top&&!s.border?.top&&(t.border.top={...o.border.top,opacity:i}),o.border?.bottom&&!s.border?.bottom&&(t.border.bottom={...o.border.bottom,opacity:i}),o.border?.left&&!s.border?.left&&(t.border.left={...o.border.left,opacity:i}),o.border?.right&&!s.border?.right&&(t.border.right={...o.border.right,opacity:i})}}),CI.add("borderColorChange",{id:"borderColorChange",easingFn:"easeOutCubic",hasAnimation:(e,t)=>{const o=e?.border,s=t?.border;return!(!o||!s)&&Boolean(o.bottom?.color!==s.bottom?.color||o.top?.color!==s.top?.color||o.left?.color!==s.left?.color||o.right?.color!==s.right?.color)},updateAnimation:function(e,t,o,s){const i=i=>{const n=o?.border?.[i],r=s?.border?.[i],a=t.border?.[i];if(n&&r&&a){const t=vo([{value:0,color:n.color||"#000000"},{value:1,color:r.color||"#000000"}]);a.color=t(yI[this.easingFn](e))}};i("top"),i("bottom"),i("left"),i("right")}}),CI.add("iconChange",{id:"iconChange",easingFn:"easeOutCubic",hasAnimation:(e,t)=>!xI(t,e)&&Boolean(e?.icons?.center?.svg?.name!==t?.icons?.center?.svg?.name||e?.icons?.left?.svg?.name!==t?.icons?.left?.svg?.name||e?.icons?.right?.svg?.name!==t?.icons?.right?.svg?.name),updateAnimation:function(e,t,o,s){const i=yI[this.easingFn](e),n=s.y+(i-1)*s.height,r=s.y+i*s.height,a=[],l=e=>{const i=o.icons?.[e],l=s.icons?.[e],c={id:`${s.id}-icon-${e}-slide-in`,style:{verticalAlign:s.style.verticalAlign},x:s.x,y:n,width:s.width,height:s.height,skipCellGridLines:!0,icons:{[e]:{...l,clipRect:s}}},h={id:`${s.id}-icon-${e}-slide-out`,style:{verticalAlign:o.style.verticalAlign},x:s.x,y:r,width:s.width,height:s.height,skipCellGridLines:!0,icons:{[e]:{...i,clipRect:s}}};t.icons[e]=wI(s.icons)[e],a.push(c,h)};return l("left"),l("right"),l("center"),{newBoxes:a}}});const yI={linear:e=>e,easeInCubic:e=>e*e*e,easeOutCubic:e=>(e-=1)*e*e+1,easeInOutCubic:e=>(e/=.5)<1?.5*e*e*e:.5*((e-=2)*e*e+2),easeOutQuart:e=>-((e-=1)*e*e*e-1)};function wI(e){return{left:e.left?{...e.left,svg:void 0}:void 0,right:e.right?{...e.right,svg:void 0}:void 0,center:e.center?{...e.center,svg:void 0}:void 0}}function II(e,t){return{left:e.left?{...e.left,clipRect:t}:void 0,right:e.right?{...e.right,clipRect:t}:void 0,center:e.center?{...e.center,clipRect:t}:void 0}}function xI(e,t){const o=(e,t)=>t&&e?!!(e.horizontalAlign!==t.horizontalAlign||e.size!==t.size||e.margin!==t.margin||e.svg&&!t.svg||!e.svg&&t.svg):!!(e&&!t||!e&&t);return o(e?.icons.left,t?.icons.left)||o(e?.icons.right,t?.icons.right)||o(e?.icons.center,t?.icons.center)}class EI extends t.Component{static template="o-spreadsheet-GaugeChartComponent";static props={figureUI:Object,isFullScreen:{type:Boolean,optional:!0}};canvas=t.useRef("chartContainer");animationStore;get runtime(){return this.env.model.getters.getChartRuntime(this.props.figureUI.id)}setup(){this.env.model.getters.isDashboard()&&(this.animationStore=oh(yh));let e,o=null;t.useEffect((()=>(this.env.isDashboard()&&void 0===e&&"gauge"!==this.animationStore?.animationPlayed[this.animationFigureId]||this.env.isDashboard()&&void 0!==e&&!mt(this.runtime,e)?(o=this.drawGaugeWithAnimation(),this.animationStore?.disableAnimationForChart(this.animationFigureId,"gauge")):Oy(this.canvasEl,this.runtime),e=this.runtime,()=>o?.stop())),(()=>{const e=this.canvasEl.getBoundingClientRect();return[e.width,e.height,this.runtime,this.canvas.el,window.devicePixelRatio]}))}drawGaugeWithAnimation(){Oy(this.canvasEl,{...this.runtime,animationValue:0});const e=this.runtime.gaugeValue?.value||0,t=this.runtime.maxValue.value,o=Math.sign(e)*Math.min(Math.abs(e),Math.abs(t));if(0===o)return null;const s=this.runtime.minValue.value,i=new RI(s,o,1e3,(e=>Oy(this.canvasEl,{...this.runtime,animationValue:e})));return i.start(),i}get canvasEl(){return this.canvas.el}get animationFigureId(){return this.props.isFullScreen?this.props.figureUI.id+"-fullscreen":this.props.figureUI.id}}class RI{startValue;endValue;duration;callback;startTime=void 0;animationFrameId=null;constructor(e,t,o,s){this.startValue=e,this.endValue=t,this.duration=o,this.callback=s}start(){this.animationFrameId=requestAnimationFrame(this.animate.bind(this))}stop(){this.animationFrameId&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}animate(e){this.startTime||(this.startTime=e);const t=e-this.startTime,o=Math.min(t/this.duration,1),s=this.startValue+(this.endValue-this.startValue)*yI.easeOutQuart(o);this.callback(s),o<1?this.animationFrameId=requestAnimationFrame(this.animate.bind(this)):this.stop()}}class TI extends $C{dataSets;labelRange;background;legendPosition;aggregated;dataSetsHaveTitle;dataSetDesign;axesDesign;type="combo";showValues;hideDataMarkers;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.showValues=e.showValues,this.hideDataMarkers=e.hideDataMarkers}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}getContextCreation(){const e=[];for(const[t,o]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(o.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=[];for(const[t,i]of e.entries())s.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,o||this.sheetId),type:this.dataSetDesign?.[t]?.type??(t?"line":"bar")});return{type:"combo",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,aggregated:this.aggregated,axesDesign:this.axesDesign,showValues:this.showValues,hideDataMarkers:this.hideDataMarkers}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>KS(this.getters,e))).filter((e=>""!==e.range&&e.range!==Js.InvalidReference)),t=JS(this.getters,this.labelRange,iC(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle)),o=this.getDefinition();return{...o,backgroundColor:wy(this.background||m),fontColor:wy(eC(this.background)),dataSets:e,labelRange:t,verticalAxis:nC(o)}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new TI(i,this.sheetId,this.getters)}static getDefinitionFromContextCreation(e){const t=(e.range??[]).map(((e,t)=>({...e,type:t?"line":"bar"})));return{background:e.background,dataSets:t,dataSetsHaveTitle:e.dataSetsHaveTitle??!1,aggregated:e.aggregated,legendPosition:e.legendPosition??"top",title:e.title||{text:""},labelRange:e.auxiliaryRange||void 0,type:"combo",axesDesign:e.axesDesign,showValues:e.showValues,hideDataMarkers:e.hideDataMarkers}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new TI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new TI(t,e,this.getters)}}class AI extends $C{dataSets;labelRange;background;legendPosition;aggregated;type="funnel";dataSetsHaveTitle;dataSetDesign;axesDesign;horizontal=!0;showValues;funnelColors;cumulative;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.showValues=e.showValues,this.horizontal=!0,this.funnelColors=e.funnelColors,this.cumulative=e.cumulative}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,aggregated:e.aggregated??!1,legendPosition:"none",title:e.title||{text:""},type:"funnel",labelRange:e.auxiliaryRange||void 0,showValues:e.showValues,axesDesign:e.axesDesign,funnelColors:e.funnelColors,horizontal:!0,cumulative:e.cumulative}}getContextCreation(){const e=[];for(const[t,o]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(o.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new AI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new AI(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=[];for(const[t,i]of e.entries())s.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,o||this.sheetId)});return{type:"funnel",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,aggregated:this.aggregated,horizontal:this.horizontal,axesDesign:this.axesDesign,showValues:this.showValues,funnelColors:this.funnelColors,cumulative:this.cumulative}}getDefinitionForExcel(){}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new AI(i,this.sheetId,this.getters)}}function DI(e){return e.dataRange&&!Xr.test(e.dataRange)?"InvalidGaugeDataRange":"Success"}function _I(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):"Success"),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):"Success"))}function OI(e,t){if(""===e)switch(t){case"rangeMin":return"EmptyGaugeRangeMin";case"rangeMax":return"EmptyGaugeRangeMax"}return"Success"}function FI(e,t){if(e.startsWith("="))return"Success";if(isNaN(e))switch(t){case"rangeMin":return"GaugeRangeMinNaN";case"rangeMax":return"GaugeRangeMaxNaN";case"lowerInflectionPointValue":return"GaugeLowerInflectionPointNaN";case"upperInflectionPointValue":return"GaugeUpperInflectionPointNaN"}return"Success"}class PI extends $C{dataRange;sectionRule;background;type="gauge";constructor(e,t,o){super(e,t,o),this.dataRange=fa(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,DI,e.chainValidations(_I(OI,e.batchValidations),_I(FI,e.batchValidations)),e.chainValidations((o=FI,(0,e.batchValidations)((e=>e.sectionRule?o(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):"Success"),(e=>e.sectionRule?o(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):"Success")))));var o}static transformDefinition(e,t,o){let s;if(t.dataRange){const i=US(e,t.dataRange,o);i!==Js.InvalidReference&&(s=i)}return{...t,dataRange:s}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||{text:""},type:"gauge",dataRange:e.range?e.range[0].dataRange:void 0,sectionRule:{colors:{lowerColor:"#EA6175",middleColor:"#FFD86D",upperColor:"#43C5B1"},rangeMin:"0",rangeMax:"100",lowerInflectionPoint:{type:"percentage",value:"15",operator:"<="},upperInflectionPoint:{type:"percentage",value:"40",operator:"<="}}}}duplicateInDuplicatedSheet(e){const t=ZS(this.sheetId,e,this.dataRange),o=VI(this.sectionRule,(t=>this.getters.copyFormulaStringForSheet(this.sheetId,e,t,"moveReference"))),s=this.getDefinitionWithSpecificRanges(t,o,e);return new PI(s,e,this.getters)}copyInSheetId(e){const t=VI(this.sectionRule,(t=>this.getters.copyFormulaStringForSheet(this.sheetId,e,t,"keepSameReference"))),o=this.getDefinitionWithSpecificRanges(this.dataRange,t,e);return new PI(o,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.dataRange,this.sectionRule)}getDefinitionWithSpecificRanges(e,t,o){return{background:this.background,sectionRule:t,title:this.title,type:"gauge",dataRange:e?this.getters.getRangeString(e,o||this.sheetId):void 0}}getDefinitionForExcel(){}getContextCreation(){return{...this,range:this.dataRange?[{dataRange:this.getters.getRangeString(this.dataRange,this.sheetId)}]:void 0}}updateRanges(e){const t=jS(this.dataRange,e),o=VI(this.sectionRule,(t=>this.getters.adaptFormulaStringDependencies(this.sheetId,t,e))),s=this.getDefinitionWithSpecificRanges(t,o);return new PI(s,this.sheetId,this.getters)}}function MI(e,t){const o=t.getLocale(),s=e.sectionRule.colors;let i,n,r;const a=e.dataRange;if(void 0!==a){const e=t.getEvaluatedCell({sheetId:a.sheetId,col:a.zone.left,row:a.zone.top});e.type===Ts.number&&(i=e.value,n=e.formattedValue,r=e.format)}let l=kI(e.sheetId,e.sectionRule.rangeMin,t),c=kI(e.sheetId,e.sectionRule.rangeMax,t);if(void 0===l||void 0===c)return function(e,t){return{background:t.getStyleOfSingleCellChart(e.background,e.dataRange).background,title:e.title??{text:""},minValue:{value:0,label:""},maxValue:{value:100,label:""},gaugeValue:{value:0,label:Js.GenericError},inflectionValues:[],colors:[]}}(e,t);c<l&&([l,c]=[c,l]);const h=e.sectionRule.lowerInflectionPoint,d=e.sectionRule.upperInflectionPoint,u=NI(e.sheetId,e.sectionRule.lowerInflectionPoint,l,c,t),g=NI(e.sheetId,e.sectionRule.upperInflectionPoint,l,c,t),p=[],m=[];return void 0!==u&&(p.push({value:u,label:bn(u,{locale:o,format:r}),operator:h.operator}),m.push(s.lowerColor)),void 0!==g&&g!==u&&(p.push({value:g,label:bn(g,{locale:o,format:r}),operator:d.operator}),m.push(s.middleColor)),void 0!==g&&void 0!==u&&u>g&&(p.reverse(),m.reverse()),m.push(s.upperColor),{background:t.getStyleOfSingleCellChart(e.background,a).background,title:{...e.title,text:Vo(e.title.text??"")},minValue:{value:l,label:bn(l,{locale:o,format:r})},maxValue:{value:c,label:bn(c,{locale:o,format:r})},gaugeValue:void 0!==i&&n?{value:i,label:n}:void 0,inflectionValues:p,colors:m}}function NI(e,t,o,s,i){const n=kI(e,t.value,i);if(void 0===n)return;return Ze("number"===t.type?n:o+(s-o)*n/100,o,s)}function kI(e,t,o){const s=o.evaluateFormula(e,t);return Ws(s)?void 0:pi(s,o.getLocale())}function VI(e,t){return{...e,rangeMin:t(e.rangeMin),rangeMax:t(e.rangeMax),lowerInflectionPoint:{...e.lowerInflectionPoint,value:t(e.lowerInflectionPoint.value)},upperInflectionPoint:{...e.upperInflectionPoint,value:t(e.upperInflectionPoint.value)}}}class LI extends $C{dataSets;labelRange;background;legendPosition;type="geo";dataSetsHaveTitle;dataSetDesign;colorScale;missingValueColor;region;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.colorScale=e.colorScale,this.missingValueColor=e.missingValueColor,this.region=e.region}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"geo",labelRange:e.auxiliaryRange||void 0}}getContextCreation(){const e=[];for(const[t,o]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(o.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new LI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new LI(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=[];for(const[t,i]of e.entries())s.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,o||this.sheetId)});return{type:"geo",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,colorScale:this.colorScale,missingValueColor:this.missingValueColor,region:this.region}}getDefinitionForExcel(){}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new LI(i,this.sheetId,this.getters)}}class HI extends $C{dataSets;labelRange;background;legendPosition;labelsAsText;stacked;aggregated;type="line";dataSetsHaveTitle;cumulative;dataSetDesign;axesDesign;fillArea;showValues;hideDataMarkers;constructor(e,t,o){super(e,t,o),this.dataSets=YS(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(this.getters,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.stacked=e.stacked,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.cumulative=e.cumulative,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.fillArea=e.fillArea,this.showValues=e.showValues,this.hideDataMarkers=e.hideDataMarkers}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static transformDefinition(e,t,o){return QS(e,t,o)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,labelsAsText:e.labelsAsText??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"line",labelRange:e.auxiliaryRange||void 0,stacked:e.stacked??!1,aggregated:e.aggregated??!1,cumulative:e.cumulative??!1,axesDesign:e.axesDesign,fillArea:e.fillArea,showValues:e.showValues,hideDataMarkers:e.hideDataMarkers}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=[];for(const[t,i]of e.entries())s.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,o||this.sheetId)});return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated,cumulative:this.cumulative,axesDesign:this.axesDesign,fillArea:this.fillArea,showValues:this.showValues,hideDataMarkers:this.hideDataMarkers}}getContextCreation(){const e=[];for(const[t,o]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(o.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new HI(i,this.sheetId,this.getters)}getDefinitionForExcel(){const e=this.dataSets.map((e=>KS(this.getters,e))).filter((e=>""!==e.range&&e.range!==Js.InvalidReference)),t=JS(this.getters,this.labelRange,iC(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle)),o=this.getDefinition();return{...o,backgroundColor:wy(this.background||m),fontColor:wy(eC(this.background)),dataSets:e,labelRange:t,verticalAxis:nC(o)}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new HI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new HI(t,e,this.getters)}}function UI(e,t){const o=e.getDefinition(),s=sw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"line",data:{labels:s.labels,datasets:SC(o,s)},options:{...Ly,layout:Ew(0,s),scales:Lw(o,s),plugins:{title:tI(o),legend:Aw(o),tooltip:rI(0,s),chartShowValuesPlugin:Kw(o,s)}}},background:e.background||m}}class BI extends $C{dataSets;labelRange;background;legendPosition;type="pie";aggregated;dataSetsHaveTitle;isDoughnut;showValues;pieHolePercentage;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.isDoughnut=e.isDoughnut,this.showValues=e.showValues,this.pieHolePercentage=e.pieHolePercentage}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"pie",labelRange:e.auxiliaryRange||void 0,aggregated:e.aggregated??!1,isDoughnut:!1,showValues:e.showValues}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){return{...this,range:this.dataSets.map((e=>({dataRange:this.getters.getRangeString(e.dataRange,this.sheetId)}))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinitionWithSpecificDataSets(e,t,o){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>({dataRange:this.getters.getRangeString(e.dataRange,o||this.sheetId)}))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,aggregated:this.aggregated,isDoughnut:this.isDoughnut,showValues:this.showValues,pieHolePercentage:this.pieHolePercentage}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new BI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new BI(t,e,this.getters)}getDefinitionForExcel(){const e=this.dataSets.map((e=>KS(this.getters,e))).filter((e=>""!==e.range&&e.range!==Js.InvalidReference)),t=JS(this.getters,this.labelRange,iC(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:wy(this.background||m),fontColor:wy(eC(this.background)),dataSets:e,labelRange:t}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new BI(i,this.sheetId,this.getters)}}function zI(e,t){const o=e.getDefinition(),s=iw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:e.isDoughnut?"doughnut":"pie",data:{labels:s.labels,datasets:yC(o,s)},options:{...Ly,cutout:e.isDoughnut&&void 0!==o.pieHolePercentage?o.pieHolePercentage+"%":void 0,layout:Ew(0,s),plugins:{title:tI(o),legend:Dw(o,s),tooltip:aI(0,s),chartShowValuesPlugin:Kw(o,s)}}},background:e.background||m}}class $I extends $C{dataSets;labelRange;background;legendPosition;aggregated;type="pyramid";dataSetsHaveTitle;dataSetDesign;axesDesign;horizontal=!0;stacked=!0;showValues;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.showValues=e.showValues}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,aggregated:e.aggregated??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"pyramid",labelRange:e.auxiliaryRange||void 0,axesDesign:e.axesDesign,horizontal:!0,stacked:!0,showValues:e.showValues}}getContextCreation(){const e=[];for(const[t,o]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(o.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new $I(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new $I(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=[];for(const[t,i]of e.entries())s.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,o||this.sheetId)});return{type:"pyramid",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,aggregated:this.aggregated,axesDesign:this.axesDesign,horizontal:!0,stacked:!0,showValues:this.showValues}}getDefinitionForExcel(){}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new $I(i,this.sheetId,this.getters)}}class GI extends $C{dataSets;labelRange;background;legendPosition;stacked;aggregated;type="radar";dataSetsHaveTitle;dataSetDesign;fillArea;showValues;hideDataMarkers;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.fillArea=e.fillArea,this.showValues=e.showValues,this.hideDataMarkers=e.hideDataMarkers}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,stacked:e.stacked??!1,aggregated:e.aggregated??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"radar",labelRange:e.auxiliaryRange||void 0,fillArea:e.fillArea??!1,showValues:e.showValues??!1,hideDataMarkers:e.hideDataMarkers}}getContextCreation(){const e=[];for(const[t,o]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(o.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new GI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new GI(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=[];for(const[t,i]of e.entries())s.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,o||this.sheetId)});return{type:"radar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated,fillArea:this.fillArea,showValues:this.showValues,hideDataMarkers:this.hideDataMarkers}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>KS(this.getters,e))).filter((e=>""!==e.range&&e.range!==Js.InvalidReference)),t=JS(this.getters,this.labelRange,iC(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle));return{...this.getDefinition(),backgroundColor:wy(this.background||m),fontColor:wy(eC(this.background)),dataSets:e,labelRange:t}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new GI(i,this.sheetId,this.getters)}}class WI extends $C{dataSets;labelRange;background;legendPosition;labelsAsText;aggregated;type="scatter";dataSetsHaveTitle;dataSetDesign;axesDesign;showValues;constructor(e,t,o){super(e,t,o),this.dataSets=YS(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(this.getters,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.showValues=e.showValues}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static transformDefinition(e,t,o){return QS(e,t,o)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range??[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,labelsAsText:e.labelsAsText??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"scatter",labelRange:e.auxiliaryRange||void 0,aggregated:e.aggregated??!1,axesDesign:e.axesDesign,showValues:e.showValues}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=[];for(const[t,i]of e.entries())s.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,o||this.sheetId)});return{type:"scatter",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,aggregated:this.aggregated,axesDesign:this.axesDesign,showValues:this.showValues}}getContextCreation(){const e=[];for(const[t,o]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(o.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new WI(i,this.sheetId,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>KS(this.getters,e))).filter((e=>""!==e.range)),t=JS(this.getters,this.labelRange,iC(this.labelRange,this.dataSets[0],this.dataSetsHaveTitle)),o=this.getDefinition();return{...o,backgroundColor:wy(this.background||m),fontColor:wy(eC(this.background)),dataSets:e,labelRange:t,verticalAxis:nC(o)}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new WI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new WI(t,e,this.getters)}}class qI extends $C{dataSets;labelRange;background;legendPosition;type="sunburst";dataSetsHaveTitle;showValues;showLabels;valuesDesign;groupColors;pieHolePercentage;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.showValues=e.showValues,this.showLabels=e.showLabels,this.valuesDesign=e.valuesDesign,this.groupColors=e.groupColors,this.pieHolePercentage=e.pieHolePercentage}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static getDefinitionFromContextCreation(e){const t=[];return e.hierarchicalRanges?.length?t.push(...e.hierarchicalRanges):e.auxiliaryRange&&t.push({...e.range?.[0],dataRange:e.auxiliaryRange}),{background:e.background,dataSets:t,dataSetsHaveTitle:e.dataSetsHaveTitle??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"sunburst",labelRange:e.range?.[0]?.dataRange,showValues:e.showValues,showLabels:e.showLabels,valuesDesign:e.valuesDesign,groupColors:e.groupColors}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){const e=this.dataSets.at(-1)?.dataRange;return{...this,range:this.labelRange?[{dataRange:this.getters.getRangeString(this.labelRange,this.sheetId)}]:[],auxiliaryRange:e?this.getters.getRangeString(e,this.sheetId):void 0,hierarchicalRanges:this.dataSets.map((e=>({dataRange:this.getters.getRangeString(e.dataRange,this.sheetId)})))}}getDefinitionWithSpecificDataSets(e,t,o){return{type:"sunburst",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>({dataRange:this.getters.getRangeString(e.dataRange,o||this.sheetId)}))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,showValues:this.showValues,showLabels:this.showLabels,valuesDesign:this.valuesDesign,groupColors:this.groupColors,pieHolePercentage:this.pieHolePercentage}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new qI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new qI(t,e,this.getters)}getDefinitionForExcel(){}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new qI(i,this.sheetId,this.getters)}}class ZI extends $C{static defaults={background:m,legendPosition:"top",dataSetsHaveTitle:!1,showHeaders:!0,headersColor:"#000000"};dataSets;labelRange;background;legendPosition;type="treemap";dataSetsHaveTitle;showHeaders;headerDesign;showValues;showLabels;valuesDesign;coloringOptions;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.showHeaders=e.showHeaders,this.headerDesign=e.headerDesign,this.showValues=e.showValues,this.showLabels=e.showLabels,this.valuesDesign=e.valuesDesign,this.coloringOptions=e.coloringOptions}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static getDefinitionFromContextCreation(e){const t=[];return e.hierarchicalRanges?.length?t.push(...e.hierarchicalRanges):e.auxiliaryRange&&t.push({...e.range?.[0],dataRange:e.auxiliaryRange}),{background:e.background,dataSets:t,dataSetsHaveTitle:e.dataSetsHaveTitle??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"treemap",labelRange:e.range?.[0]?.dataRange,showValues:e.showValues,showHeaders:e.showHeaders,headerDesign:e.headerDesign,showLabels:e.showLabels,valuesDesign:e.valuesDesign,coloringOptions:e.treemapColoringOptions}}getContextCreation(){const e=this.dataSets.at(-1)?.dataRange;return{...this,range:this.labelRange?[{dataRange:this.getters.getRangeString(this.labelRange,this.sheetId)}]:[],auxiliaryRange:e?this.getters.getRangeString(e,this.sheetId):void 0,hierarchicalRanges:this.dataSets.map((e=>({dataRange:this.getters.getRangeString(e.dataRange,this.sheetId)})))}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new ZI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new ZI(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=e.map((e=>({dataRange:this.getters.getRangeString(e.dataRange,o||this.sheetId)})));return{type:"treemap",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,showValues:this.showValues,showHeaders:this.showHeaders,headerDesign:this.headerDesign,showLabels:this.showLabels,valuesDesign:this.valuesDesign,coloringOptions:this.coloringOptions}}getDefinitionForExcel(){}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new ZI(i,this.sheetId,this.getters)}}class jI extends $C{dataSets;labelRange;background;verticalAxisPosition;legendPosition;aggregated;type="waterfall";dataSetsHaveTitle;showSubTotals;firstValueAsSubtotal;showConnectorLines;positiveValuesColor;negativeValuesColor;subTotalValuesColor;dataSetDesign;axesDesign;showValues;constructor(e,t,o){super(e,t,o),this.dataSets=YS(o,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=fa(o,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated,this.dataSetsHaveTitle=e.dataSetsHaveTitle,this.showSubTotals=e.showSubTotals,this.showConnectorLines=e.showConnectorLines,this.positiveValuesColor=e.positiveValuesColor,this.negativeValuesColor=e.negativeValuesColor,this.subTotalValuesColor=e.subTotalValuesColor,this.firstValueAsSubtotal=e.firstValueAsSubtotal,this.dataSetDesign=e.dataSets,this.axesDesign=e.axesDesign,this.showValues=e.showValues}static transformDefinition(e,t,o){return QS(e,t,o)}static validateChartDefinition(e,t){return e.checkValidations(t,oC,sC)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:e.dataSetsHaveTitle??!1,aggregated:e.aggregated??!1,legendPosition:e.legendPosition??"top",title:e.title||{text:""},type:"waterfall",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0,showSubTotals:e.showSubTotals??!1,showConnectorLines:e.showConnectorLines??!0,firstValueAsSubtotal:e.firstValueAsSubtotal??!1,axesDesign:e.axesDesign,showValues:e.showValues}}getContextCreation(){const e=[];for(const[t,o]of this.dataSets.entries())e.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(o.dataRange,this.sheetId)});return{...this,range:e,auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}duplicateInDuplicatedSheet(e){const t=qS(this.sheetId,e,this.dataSets),o=ZS(this.sheetId,e,this.labelRange),s=this.getDefinitionWithSpecificDataSets(t,o,e);return new jI(s,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new jI(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,o){const s=[];for(const[t,i]of e.entries())s.push({...this.dataSetDesign?.[t],dataRange:this.getters.getRangeString(i.dataRange,o||this.sheetId)});return{type:"waterfall",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:s,legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,o||this.sheetId):void 0,title:this.title,aggregated:this.aggregated,showSubTotals:this.showSubTotals,showConnectorLines:this.showConnectorLines,positiveValuesColor:this.positiveValuesColor,negativeValuesColor:this.negativeValuesColor,subTotalValuesColor:this.subTotalValuesColor,firstValueAsSubtotal:this.firstValueAsSubtotal,axesDesign:this.axesDesign,showValues:this.showValues}}getDefinitionForExcel(){}updateRanges(e){const{dataSets:t,labelRange:o,isStale:s}=WS(this.getters,e,this.dataSets,this.labelRange);if(!s)return this;const i=this.getDefinitionWithSpecificDataSets(t,o);return new jI(i,this.sheetId,this.getters)}}function YI(e,t){const o=e.getDefinition(),s=tw(o,e.dataSets,e.labelRange,t),{labels:i,datasets:n}=bC(o,s);return{chartJsConfig:{type:"bar",data:{labels:i,datasets:n},options:{...Ly,layout:Ew(0,s),scales:Uw(o,s),plugins:{title:tI(o),legend:Fw(o),tooltip:lI(0,s),chartShowValuesPlugin:eI(o,s),waterfallLinesPlugin:{showConnectorLines:o.showConnectorLines}}}},background:e.background||m}}const XI=new n;XI.add("bar",{match:e=>"bar"===e,createChart:(e,t,o)=>new bI(e,t,o),getChartRuntime:SI,validateChartDefinition:bI.validateChartDefinition,transformDefinition:bI.transformDefinition,getChartDefinitionFromContextCreation:bI.getDefinitionFromContextCreation,sequence:10}),XI.add("combo",{match:e=>"combo"===e,createChart:(e,t,o)=>new TI(e,t,o),getChartRuntime:function(e,t){const o=e.getDefinition(),s=tw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"bar",data:{labels:s.labels,datasets:wC(o,s)},options:{...Ly,layout:Ew(0,s),scales:Vw(o,s),plugins:{title:tI(o),legend:Ow(o),tooltip:nI(o,s),chartShowValuesPlugin:Kw(o,s)}}},background:e.background||m}},validateChartDefinition:TI.validateChartDefinition,transformDefinition:TI.transformDefinition,getChartDefinitionFromContextCreation:TI.getDefinitionFromContextCreation,sequence:15}),XI.add("line",{match:e=>"line"===e,createChart:(e,t,o)=>new HI(e,t,o),getChartRuntime:UI,validateChartDefinition:HI.validateChartDefinition,transformDefinition:HI.transformDefinition,getChartDefinitionFromContextCreation:HI.getDefinitionFromContextCreation,sequence:20}),XI.add("pie",{match:e=>"pie"===e,createChart:(e,t,o)=>new BI(e,t,o),getChartRuntime:zI,validateChartDefinition:BI.validateChartDefinition,transformDefinition:BI.transformDefinition,getChartDefinitionFromContextCreation:BI.getDefinitionFromContextCreation,sequence:30}),XI.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,o)=>new XC(e,t,o),getChartRuntime:JC,validateChartDefinition:XC.validateChartDefinition,transformDefinition:XC.transformDefinition,getChartDefinitionFromContextCreation:XC.getDefinitionFromContextCreation,sequence:40}),XI.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,o)=>new PI(e,t,o),getChartRuntime:MI,validateChartDefinition:PI.validateChartDefinition,transformDefinition:PI.transformDefinition,getChartDefinitionFromContextCreation:PI.getDefinitionFromContextCreation,sequence:50}),XI.add("scatter",{match:e=>"scatter"===e,createChart:(e,t,o)=>new WI(e,t,o),getChartRuntime:function(e,t){const o=e.getDefinition(),s=sw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"line",data:{labels:s.labels,datasets:CC(o,s)},options:{...Ly,layout:Ew(0,s),scales:Hw(o,s),plugins:{title:tI(o),legend:_w(o),tooltip:rI(0,s),chartShowValuesPlugin:Kw(o,s)}}},background:e.background||m}},validateChartDefinition:WI.validateChartDefinition,transformDefinition:WI.transformDefinition,getChartDefinitionFromContextCreation:WI.getDefinitionFromContextCreation,sequence:60}),XI.add("waterfall",{match:e=>"waterfall"===e,createChart:(e,t,o)=>new jI(e,t,o),getChartRuntime:YI,validateChartDefinition:jI.validateChartDefinition,transformDefinition:jI.transformDefinition,getChartDefinitionFromContextCreation:jI.getDefinitionFromContextCreation,sequence:70}),XI.add("pyramid",{match:e=>"pyramid"===e,createChart:(e,t,o)=>new $I(e,t,o),getChartRuntime:function(e,t){const o=e.getDefinition(),s=ow(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"bar",data:{labels:s.labels,datasets:vC(o,s)},options:{...Ly,indexAxis:"y",layout:Ew(0,s),scales:Bw(o,s),plugins:{title:tI(o),legend:Tw(o),tooltip:cI(o,s),chartShowValuesPlugin:Qw(o,s)}}},background:e.background||m}},validateChartDefinition:$I.validateChartDefinition,transformDefinition:$I.transformDefinition,getChartDefinitionFromContextCreation:$I.getDefinitionFromContextCreation,sequence:80,dataSeriesLimit:2}),XI.add("radar",{match:e=>"radar"===e,createChart:(e,t,o)=>new GI(e,t,o),getChartRuntime:function(e,t){const o=e.getDefinition(),s=nw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"radar",data:{labels:s.labels,datasets:IC(o,s)},options:{...Ly,layout:Ew(0,s),scales:zw(o,s),plugins:{title:tI(o),legend:Pw(o),tooltip:hI(0,s),chartShowValuesPlugin:Kw(o,s)}}},background:e.background||m}},validateChartDefinition:GI.validateChartDefinition,transformDefinition:GI.transformDefinition,getChartDefinitionFromContextCreation:GI.getDefinitionFromContextCreation,sequence:80}),XI.add("geo",{match:e=>"geo"===e,createChart:(e,t,o)=>new LI(e,t,o),getChartRuntime:function(e,t){const o=e.getDefinition(),s=rw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"choropleth",data:{datasets:xC(o,s)},options:{...Ly,layout:Ew(0,s),scales:$w(o,s),plugins:{title:tI(o),tooltip:dI(0,s),legend:{display:!1}}}},background:e.background||m}},validateChartDefinition:LI.validateChartDefinition,transformDefinition:LI.transformDefinition,getChartDefinitionFromContextCreation:LI.getDefinitionFromContextCreation,sequence:90,dataSeriesLimit:1}),XI.add("funnel",{match:e=>"funnel"===e,createChart:(e,t,o)=>new AI(e,t,o),getChartRuntime:function(e,t){const o=e.getDefinition(),s=aw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"funnel",data:{labels:s.labels,datasets:EC(o,s)},options:{...Ly,indexAxis:"y",layout:Ew(0,s),scales:Gw(0,s),plugins:{title:tI(o),legend:{display:!1},tooltip:uI(0,s),chartShowValuesPlugin:Kw(o,s)}}},background:e.background||m}},validateChartDefinition:AI.validateChartDefinition,transformDefinition:AI.transformDefinition,getChartDefinitionFromContextCreation:AI.getDefinitionFromContextCreation,sequence:100,dataSeriesLimit:1}),XI.add("sunburst",{match:e=>"sunburst"===e,createChart:(e,t,o)=>new qI(e,t,o),getChartRuntime:function(e,t){const o=e.getDefinition(),s=lw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"doughnut",data:{datasets:TC(o,s)},options:{cutout:void 0===e.pieHolePercentage?"25%":`${e.pieHolePercentage}%`,...Ly,layout:Ew(0,s),plugins:{title:tI(o),legend:Mw(o),tooltip:gI(0,s),sunburstLabelsPlugin:Jw(o,s),sunburstHoverPlugin:{enabled:!0}}}},background:e.background||m}},validateChartDefinition:qI.validateChartDefinition,transformDefinition:qI.transformDefinition,getChartDefinitionFromContextCreation:qI.getDefinitionFromContextCreation,sequence:30}),XI.add("treemap",{match:e=>"treemap"===e,createChart:(e,t,o)=>new ZI(e,t,o),getChartRuntime:function(e,t){const o=e.getDefinition(),s=lw(o,e.dataSets,e.labelRange,t);return{chartJsConfig:{type:"treemap",data:{labels:s.labels,datasets:OC(o,s)},options:{...Ly,layout:Ew(0,s),plugins:{title:tI(o),legend:{display:!1},tooltip:pI(0,s)}}},background:e.background||m}},validateChartDefinition:ZI.validateChartDefinition,transformDefinition:ZI.transformDefinition,getChartDefinitionFromContextCreation:ZI.getDefinitionFromContextCreation,sequence:100});const KI=new n;KI.add("line",zC),KI.add("bar",zC),KI.add("combo",zC),KI.add("pie",zC),KI.add("gauge",EI),KI.add("scatter",zC),KI.add("scorecard",sy),KI.add("waterfall",zC),KI.add("pyramid",zC),KI.add("radar",zC),KI.add("geo",zC),KI.add("funnel",zC),KI.add("sunburst",zC),KI.add("treemap",zC);const JI={line:Vo("Line"),column:Vo("Column"),bar:Vo("Bar"),area:Vo("Area"),pie:Vo("Pie"),hierarchical:Vo("Hierarchical"),misc:Vo("Miscellaneous")},QI=new n;function ex(e){const t=XI.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(o,s,i){const n=t.find((e=>e.match(s.type)));if(!n)throw new Error(`No builder for this chart: ${s.type}`);return n.createChart(s,i,e)}}function tx(e){const t=XI.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(o){const s=t.find((e=>e.match(o.type)));if(!s)throw new Error("No runtime builder for this chart.");return s.getChartRuntime(o,e)}}function ox(e,t){const o=XI.getAll().find((e=>e.match(t.type)));if(!o)throw new Error("Unknown chart type.");return o.validateChartDefinition(e,t)}function sx(e,t,o){const s=XI.getAll().find((e=>e.match(t.type)));if(!s)throw new Error("Unknown chart type.");return s.transformDefinition(e,t,o)}function ix(e,t){const o=function(e,t){const o=e.getActiveSheetId(),s=wr(t).numberOfCols;if(t.top===t.bottom||s<=2)return;const i=e.getEvaluatedCell({sheetId:o,col:t.right,row:t.top}),n=i.type!==Ts.number,r=s=>{const i=e.getEvaluatedCellsInZone(o,{...t,left:s,right:s,top:t.top+(n?1:0)});return i.every((e=>e.type!==Ts.number))?"string":i.every((e=>e.type!==Ts.text))?"number":void 0};for(let e=t.left;e<t.right;e++){const o=r(e);if(e!==t.right&&"string"!==o)return;if(e===t.right&&"number"!==o)return}const a={...t,right:t.right-1},l={...t,left:t.right};return{title:{},dataSets:[{dataRange:dr(a)}],type:"sunburst",legendPosition:"none",labelRange:dr(l),dataSetsHaveTitle:n}}(t,e);if(o)return o;const s=t.getActiveSheetId();let i=e;const n=1===wr(e).numberOfCols;n||(i={...e,left:e.left+1});const r=dr(t.getUnboundedZone(s,i)),a=[{dataRange:r,yAxisId:"y"}],l=t.getCell({sheetId:s,col:e.left,row:e.top});if(1===Pr(e)&&l?.content)return{type:"scorecard",title:{},background:l.style?.fillColor||void 0,keyValue:dr(e),baselineMode:Ie,baselineColorUp:xe,baselineColorDown:Ee};const c=!!t.getEvaluatedCellsInZone(s,{...i,bottom:i.top}).find((e=>e.type!==Ts.empty&&e.type!==Ts.number));let h;n||(h=dr(t.getUnboundedZone(s,{...e,right:e.left})));const d=i.right===i.left?"none":"top",u={title:{},dataSets:a,labelsAsText:!1,stacked:!1,aggregated:!1,cumulative:!1,labelRange:h,type:"line",dataSetsHaveTitle:c,legendPosition:d},g=new HI(u,s,t);if(uw(u,g.dataSets,g.labelRange,t))return u;const p=YS(t,a,s,c);return n&&fw(t,p[0]).every((e=>"string"==typeof e&&!hi(e)))?{title:{},dataSets:[{dataRange:r}],aggregated:!0,labelRange:r,type:"pie",legendPosition:"top",dataSetsHaveTitle:!1}:{title:{},dataSets:a,labelRange:h,type:"bar",stacked:!1,aggregated:!1,dataSetsHaveTitle:c,legendPosition:d}}QI.add("line",{matcher:e=>"line"===e.type&&!e.stacked&&!e.fillArea,displayName:Vo("Line"),chartType:"line",chartSubtype:"line",subtypeDefinition:{stacked:!1,fillArea:!1},category:"line",preview:"o-spreadsheet-ChartPreview.LINE_CHART"}).add("stacked_line",{matcher:e=>"line"===e.type&&!e.fillArea&&!!e.stacked,displayName:Vo("Stacked Line"),chartType:"line",chartSubtype:"stacked_line",subtypeDefinition:{stacked:!0,fillArea:!1},category:"line",preview:"o-spreadsheet-ChartPreview.STACKED_LINE_CHART"}).add("area",{matcher:e=>"line"===e.type&&!e.stacked&&!!e.fillArea,displayName:Vo("Area"),chartType:"line",chartSubtype:"area",subtypeDefinition:{stacked:!1,fillArea:!0},category:"area",preview:"o-spreadsheet-ChartPreview.AREA_CHART"}).add("stacked_area",{matcher:e=>"line"===e.type&&e.stacked&&!!e.fillArea,displayName:Vo("Stacked Area"),chartType:"line",chartSubtype:"stacked_area",subtypeDefinition:{stacked:!0,fillArea:!0},category:"area",preview:"o-spreadsheet-ChartPreview.STACKED_AREA_CHART"}).add("scatter",{displayName:Vo("Scatter"),chartType:"scatter",chartSubtype:"scatter",category:"misc",preview:"o-spreadsheet-ChartPreview.SCATTER_CHART"}).add("column",{matcher:e=>"bar"===e.type&&!e.stacked&&!e.horizontal,displayName:Vo("Column"),chartType:"bar",chartSubtype:"column",subtypeDefinition:{stacked:!1,horizontal:!1},category:"column",preview:"o-spreadsheet-ChartPreview.COLUMN_CHART"}).add("stacked_column",{matcher:e=>"bar"===e.type&&e.stacked&&!e.horizontal,displayName:Vo("Stacked Column"),chartType:"bar",chartSubtype:"stacked_column",subtypeDefinition:{stacked:!0,horizontal:!1},category:"column",preview:"o-spreadsheet-ChartPreview.STACKED_COLUMN_CHART"}).add("bar",{matcher:e=>"bar"===e.type&&!e.stacked&&!!e.horizontal,displayName:Vo("Bar"),chartType:"bar",chartSubtype:"bar",subtypeDefinition:{horizontal:!0,stacked:!1},category:"bar",preview:"o-spreadsheet-ChartPreview.BAR_CHART"}).add("stacked_bar",{matcher:e=>"bar"===e.type&&e.stacked&&!!e.horizontal,displayName:Vo("Stacked Bar"),chartType:"bar",chartSubtype:"stacked_bar",subtypeDefinition:{horizontal:!0,stacked:!0},category:"bar",preview:"o-spreadsheet-ChartPreview.STACKED_BAR_CHART"}).add("combo",{displayName:Vo("Combo"),chartSubtype:"combo",chartType:"combo",category:"line",preview:"o-spreadsheet-ChartPreview.COMBO_CHART"}).add("pie",{matcher:e=>"pie"===e.type&&!e.isDoughnut,displayName:Vo("Pie"),chartSubtype:"pie",chartType:"pie",subtypeDefinition:{isDoughnut:!1},category:"pie",preview:"o-spreadsheet-ChartPreview.PIE_CHART"}).add("doughnut",{matcher:e=>"pie"===e.type&&!!e.isDoughnut,displayName:Vo("Doughnut"),chartSubtype:"doughnut",chartType:"pie",subtypeDefinition:{isDoughnut:!0},category:"pie",preview:"o-spreadsheet-ChartPreview.DOUGHNUT_CHART"}).add("gauge",{displayName:Vo("Gauge"),chartSubtype:"gauge",chartType:"gauge",category:"misc",preview:"o-spreadsheet-ChartPreview.GAUGE_CHART"}).add("scorecard",{displayName:Vo("Scorecard"),chartSubtype:"scorecard",chartType:"scorecard",category:"misc",preview:"o-spreadsheet-ChartPreview.SCORECARD_CHART"}).add("waterfall",{displayName:Vo("Waterfall"),chartSubtype:"waterfall",chartType:"waterfall",category:"misc",preview:"o-spreadsheet-ChartPreview.WATERFALL_CHART"}).add("pyramid",{displayName:Vo("Population Pyramid"),chartSubtype:"pyramid",chartType:"pyramid",category:"misc",preview:"o-spreadsheet-ChartPreview.POPULATION_PYRAMID_CHART"}).add("radar",{matcher:e=>"radar"===e.type&&!e.fillArea,displayName:Vo("Radar"),chartSubtype:"radar",chartType:"radar",subtypeDefinition:{fillArea:!1},category:"misc",preview:"o-spreadsheet-ChartPreview.RADAR_CHART"}).add("filled_radar",{matcher:e=>"radar"===e.type&&!!e.fillArea,displayName:Vo("Filled Radar"),chartType:"radar",chartSubtype:"filled_radar",subtypeDefinition:{fillArea:!0},category:"misc",preview:"o-spreadsheet-ChartPreview.FILLED_RADAR_CHART"}).add("geo",{displayName:Vo("Geo Chart"),chartSubtype:"geo",chartType:"geo",category:"misc",preview:"o-spreadsheet-ChartPreview.GEO_CHART"}).add("funnel",{displayName:Vo("Funnel"),chartSubtype:"funnel",chartType:"funnel",category:"misc",preview:"o-spreadsheet-ChartPreview.FUNNEL_CHART"}).add("sunburst",{matcher:e=>"sunburst"===e.type,displayName:Vo("Sunburst"),chartSubtype:"sunburst",chartType:"sunburst",category:"hierarchical",preview:"o-spreadsheet-ChartPreview.SUNBURST_CHART"}).add("treemap",{matcher:e=>"treemap"===e.type,displayName:Vo("Tree Map"),chartType:"treemap",chartSubtype:"treemap",category:"hierarchical",preview:"o-spreadsheet-ChartPreview.TREE_MAP_CHART"});var nx=Object.freeze({__proto__:null,AbstractChart:$C,BarChart:bI,CHART_AXIS_CHOICES:lC,CHART_COMMON_OPTIONS:Ly,GaugeChart:PI,LineChart:HI,MOVING_AVERAGE_TREND_LINE_XAXIS_ID:$S,PieChart:BI,SPREADSHEET_TO_EXCEL_TRENDLINE_TYPE_MAPPING:GS,ScorecardChart:XC,TREND_LINE_XAXIS_ID:zS,WaterfallChart:jI,adaptChartRange:jS,chartFactory:ex,chartFontColor:eC,chartMutedFontColor:tC,chartRuntimeFactory:tx,chartToImageFile:Uy,chartToImageUrl:Hy,checkDataset:oC,checkLabelRange:sC,createBarChartRuntime:SI,createDataSets:YS,createGaugeChartRuntime:MI,createLineChartRuntime:UI,createPieChartRuntime:zI,createScorecardChartRuntime:JC,createWaterfallChartRuntime:YI,drawScoreChart:KC,duplicateDataSetsInDuplicatedSheet:qS,duplicateLabelRangeInDuplicatedSheet:ZS,formatChartDatasetValue:rC,formatTickValue:aC,getChartPositionAtCenterOfViewport:function(e,t){const{x:o,y:s}=e.getMainViewportCoordinates(),{scrollX:i,scrollY:n}=e.getActiveSheetScrollInfo(),{width:r,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:o+i+Math.max(0,(r-t.width)/2),y:s+n+Math.max(0,(a-t.height)/2)}},getDefinedAxis:nC,getPieColors:cC,getSmartChartDefinition:ix,isTrendLineAxis:dC,shouldRemoveFirstLabel:iC,toExcelDataset:KS,toExcelLabelRange:JS,transformChartDefinitionWithDataSetsWithZone:QS,transformDefinition:sx,truncateLabel:hC,updateChartRangesWithDataSets:WS,validateChartDefinition:ox});function rx(e,t){const{scrollX:o,scrollY:s}=e.getActiveSheetScrollInfo(),i=e.getSheetViewDimension(),n=o+Math.max(0,(i.width-t.width)/2),r=s+Math.max(0,(i.height-t.height)/2);return e.getPositionAnchorOffset({x:n,y:r})}function ax(e,t){const o=ze(t),s=e.getSheetViewDimension(),i=s.width,n=s.height;if(o.width>i){const e=i/o.width;o.width=i,o.height=o.height*e}if(o.height>n){const e=n/o.height;o.height=n,o.width=o.width*e}return o}class lx{xmlString;constructor(e){this.xmlString=e}toString(){return this.xmlString}}const cx=["areaChart","area3DChart","lineChart","line3DChart","stockChart","radarChart","scatterChart","pieChart","pie3DChart","doughnutChart","barChart","bar3DChart","ofPieChart","surfaceChart","surface3DChart","bubbleChart","comboChart","radarChart"];function hx(e,t,o){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:o}}function dx(e){return String(e).replace(/\&/g,"&").replace(/\</g,"<").replace(/\>/g,">").replace(/\"/g,""").replace(/\'/g,"'").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function ux(e){return new lx(e.map((([e,t])=>`${e}="${dx(t)}"`)).join(" "))}function gx(e,t="text/xml"){const o=(new DOMParser).parseFromString(e.toString(),t),s=o.querySelector("parsererror");if(s){const t=s.innerHTML,o=parseInt(t.split(":")[0],10),i=e.toString().trim().split("\n"),n=i.slice(Math.max(o-3,0),Math.min(o+2,i.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${n}`)}return o}function px(e){if(e)return{style:e.style,color:{rgb:e.color}}}function mx(e,t){return vx`
|
|
10
10
|
<Override ContentType="${t}" PartName="${e}" />
|
|
11
11
|
`}function fx(e){return new lx(e.join("\n"))}function vx(e,...t){const o=[e[0]];for(let s=0;s<t.length;s++){const i=t[s]instanceof lx?t[s]:dx(t[s]);o.push(i+e[s+1])}return new lx(dt(o))}function bx(e){return e.replace(/NAMESPACE.*NAMESPACE(.*)/,"$1")}function Sx(e){return e.replaceAll(/([a-zA-Z0-9]+):([a-zA-Z0-9]+)/g,"NAMESPACE$1NAMESPACE$2")}function Cx(e,t,s){return o([{id:"edit",name:Vo("Edit"),sequence:1,execute:()=>{s.model.dispatch("SELECT_FIGURE",{figureId:e}),s.openSidePanel("ChartPanel")},icon:"o-spreadsheet-Icon.EDIT",isEnabled:e=>!e.isSmall},yx(e,s),wx(e,s),{id:"copy_as_image",name:Vo("Copy as image"),icon:"o-spreadsheet-Icon.COPY_AS_IMAGE",sequence:4,execute:async()=>{const t=s.model.getters.getFigureSheetId(e),o=s.model.getters.getFigure(t,e),i=s.model.getters.getChartType(e),n=s.model.getters.getChartRuntime(e),r=`<img src="${dx(Hy(n,o,i))}" />`,a=await Uy(n,o,i);s.clipboard.write({"text/html":r,"image/png":a}),s.notifyUser({sticky:!1,type:"success",text:Vo("Chart copied to clipboard")})},isReadonlyAllowed:!0},{id:"download",name:Vo("Download"),icon:"o-spreadsheet-Icon.DOWNLOAD",sequence:6,execute:async()=>{const t=s.model.getters.getFigureSheetId(e),o=s.model.getters.getFigure(t,e),i=s.model.getters.getChartType(e);by(Hy(s.model.getters.getChartRuntime(e),o,i),"chart")},isReadonlyAllowed:!0},Ix(e,t,s)]).filter((e=>!s.model.getters.isReadonly()||e.isReadonlyAllowed))}function yx(e,t,o){return{id:"copy",name:Vo("Copy"),sequence:2,description:"Ctrl+C",execute:async()=>{t.model.dispatch("SELECT_FIGURE",{figureId:e}),t.model.dispatch("COPY");const s=await t.model.getters.getClipboardTextAndImageContent();await t.clipboard.write(s),o&&t.notifyUser({sticky:!1,type:"success",text:o})},icon:"o-spreadsheet-Icon.CLIPBOARD"}}function wx(e,t){return{id:"cut",name:Vo("Cut"),sequence:3,description:"Ctrl+X",execute:async()=>{t.model.dispatch("SELECT_FIGURE",{figureId:e}),t.model.dispatch("CUT"),await t.clipboard.write(await t.model.getters.getClipboardTextAndImageContent())},icon:"o-spreadsheet-Icon.CUT"}}function Ix(e,t,o){return{id:"delete",name:Vo("Delete"),sequence:10,execute:()=>{o.model.dispatch("DELETE_FIGURE",{sheetId:o.model.getters.getActiveSheetId(),figureId:e}),t()},icon:"o-spreadsheet-Icon.TRASH"}}class xx extends hh{mutators=["toggleFullScreenChart"];fullScreenFigure=void 0;toggleFullScreenChart(e){this.fullScreenFigure?.id===e?this.fullScreenFigure=void 0:this.makeFullScreen(e)}makeFullScreen(e){const t=this.getters.getActiveSheetId(),o=this.getters.getFigure(t,e);o&&(this.fullScreenFigure={...o,x:0,y:0,width:0,height:0})}}mh`
|
|
12
12
|
.o-menu {
|
|
@@ -267,7 +267,7 @@
|
|
|
267
267
|
max-width: 300px;
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
|
-
`;class rE extends t.Component{static template="o-spreadsheet-SpeechBubble";static props={content:String,anchorRect:Object};static components={};spreadsheetRect=Ax();bubbleRef=t.useRef("bubble");setup(){t.useEffect((()=>{const e=this.bubbleRef.el;if(!e)return;const t=this.props.anchorRect,o=cy(e),s=t.x+t.width/2-o.width/2-this.spreadsheetRect.x,i=t.y-o.height-7-this.spreadsheetRect.y;e.style.left=`${s}px`,e.style.top=`${i}px`}))}}class aE{lastId=0;add(e){this.lastId++;const t=this.lastId;return new Promise(((o,s)=>{e.then((e=>{this.lastId===t&&o(e)})).catch((e=>{this.lastId===t&&s(e)}))}))}}const lE=new n;function cE(e,t,o){const{x:s,y:i,width:n,height:r}=o;if(n<0||r<0)return;const l=t.color||a,{ctx:c}=e;c.save(),t.noBorder||(t.dashed&&c.setLineDash([5,3]),c.strokeStyle=l,t.thinLine?(c.lineWidth=1,c.strokeRect(s,i,n,r)):(c.lineWidth=2,c.strokeRect(s+.5,i+.5,n,r))),t.noFill||(c.fillStyle=eo($t(l),t.fillAlpha??.12),c.fillRect(s,i,n,r)),c.restore()}class hE extends hh{mutators=["register","unRegister"];providers=[];constructor(e){super(e),this.onDispose((()=>{this.providers=[]}))}get renderingLayers(){return["Highlights"]}get highlights(){const e=this.getters.getActiveSheetId();return this.providers.flatMap((e=>e.highlights)).filter((t=>t.range.sheetId===e)).map((e=>{const{numberOfRows:t,numberOfCols:o}=wr(e.range.zone),s=t*o==1?this.getters.expandZone(e.range.sheetId,e.range.zone):e.range.unboundedZone;return{...e,range:this.model.getters.getRangeFromZone(e.range.sheetId,s)}}))}register(e){this.providers.push(e)}unRegister(e){this.providers=this.providers.filter((t=>t!==e))}drawLayer(e,t){if("Highlights"===t)for(const t of this.highlights){cE(e,t,this.getters.getVisibleRect(t.range.zone))}}}class dE{mutators=["notifyUser","raiseError","askConfirmation","updateNotificationCallbacks"];notifyUser=e=>window.alert(e.text);askConfirmation=(e,t,o)=>{window.confirm(e)?t():o?.()};raiseError=(e,t)=>{window.alert(e),t?.()};updateNotificationCallbacks(e){this.notifyUser=e.notifyUser||this.notifyUser,this.raiseError=e.raiseError||this.raiseError,this.askConfirmation=e.askConfirmation||this.askConfirmation}}class uE extends hh{mutators=["useProvider","moveSelection","hide","selectIndex"];selectedIndex=void 0;provider;get selectedProposal(){if(void 0!==this.selectedIndex&&void 0!==this.provider)return this.provider.proposals[this.selectedIndex]}useProvider(e){this.provider=e,this.selectedIndex=e.autoSelectFirstProposal?0:void 0}hide(){this.provider=void 0,this.selectedIndex=void 0}selectIndex(e){this.selectedIndex=e}moveSelection(e){this.provider&&(void 0!==this.selectedIndex?"previous"===e?(this.selectedIndex--,this.selectedIndex<0&&(this.selectedIndex=this.provider.proposals.length-1)):this.selectedIndex=(this.selectedIndex+1)%this.provider.proposals.length:this.selectedIndex=0)}}const gE="#000000",pE="#3da4ab",mE={OPERATOR:pE,NUMBER:"#02c39a",STRING:"#00a82d",FUNCTION:gE,DEBUGGER:pE,LEFT_PAREN:gE,RIGHT_PAREN:gE,ARG_SEPARATOR:gE,ORPHAN_RIGHT_PAREN:"#ff0000"};class fE extends hh{mutators=["startEdition","setCurrentContent","stopEdition","stopComposerRangeSelection","cancelEdition","cycleReferences","hideHelp","autoCompleteOrStop","insertAutoCompleteValue","moveAutoCompleteSelection","selectAutoCompleteIndex","toggleEditionMode","changeComposerCursorSelection","replaceComposerCursorSelection","hoverToken"];col=0;row=0;editionMode="inactive";sheetId="";_currentContent="";currentTokens=[];selectionStart=0;selectionEnd=0;initialContent="";colorIndexByRange={};autoComplete=new uE(this.get);hoveredTokens=[];hoveredContentEvaluation="";autoCompleteKeepLast=new aE;notificationStore=this.get(dE);highlightStore=this.get(hE);constructor(e){super(e),this.highlightStore.register(this),this.onDispose((()=>{this.highlightStore.unRegister(this)}))}handleEvent(e){this.hideHelp();const t=this.getters.getActiveSheetId();let o;if(o=e.options.unbounded?this.getters.getUnboundedZone(t,e.anchor.zone):e.anchor.zone,"newAnchor"===e.mode)"selecting"===this.editionMode&&this.insertSelectedRange(o);else"selecting"===this.editionMode?this.replaceSelectedRange(o):this.updateComposerRange(e.previousAnchor.zone,o)}changeComposerCursorSelection(e,t){this.isSelectionValid(this._currentContent.length,e,t)&&(this.selectionStart=e,this.selectionEnd=t,this.computeFormulaCursorContext(),this.computeParenthesisRelatedToCursor(),this.updateAutoCompleteProvider())}stopComposerRangeSelection(){this.isSelectingRange&&(this.editionMode="editing")}startEdition(e,t){if(t){const o=e||this.getComposerContent(this.getters.getActivePosition());if(!this.isSelectionValid(o.length,t.start,t.end))return}const{col:o,row:s}=this.getters.getActivePosition();this.model.dispatch("SELECT_FIGURE",{figureId:null}),this.model.dispatch("SCROLL_TO_CELL",{col:o,row:s}),"inactive"!==this.editionMode&&e?this.setContent(e,t):this._startEdition(e,t),this.updateTokenColor(),this.computeFormulaCursorContext(),this.computeParenthesisRelatedToCursor(),this.updateAutoCompleteProvider()}cancelEdition(){this.resetContent(),this.cancelEditionAndActivateSheet()}setCurrentContent(e,t){t&&!this.isSelectionValid(e.length,t.start,t.end)||(this.setContent(e,t,!0),this.updateTokenColor(),this.computeFormulaCursorContext(),this.computeParenthesisRelatedToCursor())}replaceComposerCursorSelection(e){this.replaceSelection(e)}handle(e){switch(e.type){case"SELECT_FIGURE":e.figureId&&(this.resetContent(),this.cancelEditionAndActivateSheet());break;case"START_CHANGE_HIGHLIGHT":const{left:t,top:o}=e.zone;this.isSelectingRange&&(this.editionMode="editing"),this.model.selection.resetAnchor(this,{cell:{col:t,row:o},zone:e.zone})}}get currentContent(){return"inactive"===this.editionMode?this.getComposerContent(this.getters.getActivePosition()):this._currentContent}get composerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}get isSelectingRange(){return"selecting"===this.editionMode}get showSelectionIndicator(){return this.isSelectingRange&&this.canStartComposerRangeSelection()}get tokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((o=>o.start<=e&&o.end>=t))}get autoCompleteProposals(){return this.autoComplete.provider?.proposals||[]}get autoCompleteSelectedIndex(){return this.autoComplete.selectedIndex}get isAutoCompleteDisplayed(){return!!this.autoComplete.provider}cycleReferences(){const e=this.getters.getLocale(),t=mv(this.composerSelection,this._currentContent,e);void 0!==t&&this.setCurrentContent(t.content,t.selection)}toggleEditionMode(){if("inactive"===this.editionMode)return;const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd),o=[...this.currentTokens].reverse().find((o=>o.end>=e&&t>=o.start&&"REFERENCE"===o.type));if("editing"===this.editionMode&&o){const e=this.getters.getActiveSheetId(),{sheetName:t,xc:s}=ta(o.value),i=this.getters.getSheetIdByName(t);i&&i!==e&&this.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e,sheetIdTo:i}),this.selectionStart=this.selectionEnd=o.end;const n=this.getters.getRangeFromSheetXC(this.sheetId,s).zone;this.captureSelection(n),this.editionMode="selecting"}else this.editionMode="editing"}hoverToken(e){this.currentTokens.forEach((e=>e.isInHoverContext=void 0));const t=[...this.currentTokens];if(void 0===e||["ARG_SEPARATOR","SPACE"].includes(t[e].type))return this.hoveredContentEvaluation="",void(this.hoveredTokens=[]);const o=this.getNumberOfMissingParenthesis(t);o>0&&t.push(...Array(o).fill({value:")",type:"RIGHT_PAREN"}));let s=t;if(0!==e){const o=this.getRelatedTokens(t,e),i=t.filter((e=>!o.includes(e)&&"SPACE"!==e.type));s=1===i.length&&i[0]===t[0]?t:o}s.forEach((e=>e.isInHoverContext=!0));let i=s.map((e=>e.value)).join("");Vt(i)||(i=`=${i}`);const n=Cl(i,this.getters.getLocale()),r=this.getters.evaluateFormulaResult(this.sheetId,n);this.hoveredTokens=s,this.hoveredContentEvaluation=this.evaluationResultToDisplayString(r)}getRelatedTokens(e,t){try{const o=ov(e);let s;for(const e of iv(o))if(t>=e.tokenStartIndex&&t<=e.tokenEndIndex)s=e;else if(t<e.tokenStartIndex)break;return s?e.slice(s.tokenStartIndex,s.tokenEndIndex+1):e}catch(t){if(t instanceof ei)return e;throw t}}evaluationResultToDisplayString(e){const t=this.getters.getLocale();if(Ws(e)){const o=","===t.decimalSeparator?"/":",";return`{${Mi(e).map((e=>e.map((e=>this.cellValueToDisplayString(e))).join(o))).join(";")}}`}return this.cellValueToDisplayString(e)}cellValueToDisplayString(e){const t=e.value;switch(typeof t){case"number":return bn(t,{locale:this.getters.getLocale(),format:e.format});case"string":return hi(t)?t:`"${t}"`;case"boolean":return t?"TRUE":"FALSE"}return"0"}captureSelection(e,t,o){this.model.selection.capture(this,{cell:{col:t??e.left,row:o??e.right},zone:e},{handleEvent:this.handleEvent.bind(this),release:()=>{this._stopEdition()}})}isSelectionValid(e,t,o){return t>=0&&t<=e&&o>=0&&o<=e}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=Dr({col:this.col,row:this.row});this.model.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.editionMode="selecting"}_startEdition(e,t){const o=this.getters.getActiveCell(),s=this.getters.getLocale();e&&o.format?.includes("%")&&Is(e,s)&&(t=t||{start:e.length,end:e.length},e=`${e}%`);const{col:i,row:n,sheetId:r}=this.getters.getActivePosition();this.col=i,this.sheetId=r,this.row=n,this.initialContent=this.getComposerContent({sheetId:r,col:i,row:n}),this.editionMode="editing",this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const a=Dr({col:this.col,row:this.row});this.captureSelection(a,i,n)}_stopEdition(){if("inactive"!==this.editionMode){this.cancelEditionAndActivateSheet();let e=this.getCurrentCanonicalContent();if(!(this.initialContent!==e))return;if(e&&Vt(e)){const t=this.getNumberOfMissingParenthesis(this.currentTokens);t>0&&(e+=dt(new Array(t).fill(")")))}this.confirmEdition(e)}}getCurrentCanonicalContent(){return Cl(this._currentContent,this.getters.getLocale())}cancelEditionAndActivateSheet(){if("inactive"===this.editionMode)return;this._cancelEdition();this.getters.getActiveSheetId()!==this.sheetId&&this.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}_cancelEdition(){"inactive"!==this.editionMode&&(this.editionMode="inactive",this.model.selection.release(this),this.colorIndexByRange={},this.hoveredTokens=[],this.hoveredContentEvaluation="")}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,o){const s=this._currentContent!==e;if(this._currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,s||"inactive"!==this.editionMode){const t=this.getters.getLocale();this.currentTokens=Vt(e)?hv(e,t):[],this.currentTokens.length>100&&o&&this.notificationStore.raiseError(Vo("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells"))}this.canStartComposerRangeSelection()&&this.startComposerRangeSelection(),this.updateAutoCompleteProvider()}getAutoCompleteProviders(){return lE.getAll()}insertSelectedRange(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=this.getZoneReference(e);this.canStartComposerRangeSelection()?this.insertText(o,t):this.insertText(","+o,t)}replaceSelectedRange(e){const t=this.getZoneReference(e),o=this.tokenAtCursor,s="REFERENCE"===o?.type?o.start:this.selectionStart;this.replaceText(t,s,this.selectionEnd)}updateComposerRange(e,t){const o=this.getters.getActiveSheetId(),s=this.tokenAtCursor,i=(s?[s,...this.currentTokens]:this.currentTokens).filter((e=>"REFERENCE"===e.type)).find((t=>{const{xc:s,sheetName:i}=ta(t.value),n=i||this.getters.getSheetName(this.sheetId);if(!la(this.getters.getSheetName(o),n))return!1;const r=this.getters.getRangeFromSheetXC(o,s);return br(this.getters.expandZone(o,r.zone),e)}));if(!i)return;const n=this.getters.getRangeFromSheetXC(o,i.value);this.selectionStart=i.start,this.selectionEnd=this.selectionStart+i.value.length;const r=this.getters.getRangeFromZone(o,t),a=this.getRangeReference(r,n.parts);this.replaceSelection(a)}getZoneReference(e){const t=this.sheetId,o=this.getters.getActiveSheetId(),s=this.getters.getRangeFromZone(o,e);return this.getters.getSelectionRangeString(s,t)}getRangeReference(e,t){const o={...e,parts:[...t]};return this.getters.getSelectionRangeString(o,this.sheetId)}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,o)}replaceText(e,t,o){this._currentContent=this._currentContent.slice(0,t)+this._currentContent.slice(o,this._currentContent.length),this.insertText(e,t)}insertText(e,t){const o=this._currentContent.slice(0,t)+e+this._currentContent.slice(t),s=t+e.length;this.setCurrentContent(o,{start:s,end:s})}updateTokenColor(){this.updateRangeColor();for(let e=0;e<this.currentTokens.length;e++)this.currentTokens[e].color=this.getTokenColor(this.currentTokens[e])}getTokenColor(e){if("REFERENCE"===e.type){const{xc:t,sheetName:o}=ta(e.value);return this.rangeColor(t,o)||gE}if("SYMBOL"===e.type){const t=e.value.toUpperCase();if("TRUE"===t||"FALSE"===t)return mE.NUMBER;if(t in CS.content)return mE.FUNCTION}return["LEFT_PAREN","RIGHT_PAREN"].includes(e.type)&&""===e.parenthesesCode?mE.ORPHAN_RIGHT_PAREN:mE[e.type]||gE}rangeColor(e,t){const o=t?this.model.getters.getSheetIdByName(t):this.sheetId,s=this.highlights.find((t=>{if(t.range.sheetId!==o)return!1;let s=this.model.getters.getRangeFromSheetXC(o,e).zone;return s=1===Pr(s)?this.model.getters.expandZone(o,s):s,br(s,t.range.zone)}));return s&&s.color?s.color:void 0}computeFormulaCursorContext(){for(let e=0;e<this.currentTokens.length;e++)this.currentTokens[e].isBlurred=!1;if(this.selectionStart!==this.selectionEnd)return;const e=this.getParenthesesCodeAfterCursor(),t=[...this.currentTokens].reverse().find((t=>e.startsWith(t.parenthesesCode)&&"SYMBOL"===t.type));if(t)for(let e=0;e<this.currentTokens.length;e++)(this.currentTokens[e].parenthesesCode||"").startsWith(t.parenthesesCode||"")||(this.currentTokens[e].isBlurred=!0)}getParenthesesCodeAfterCursor(){const e=this.tokenAtCursor?.parenthesesCode||"";return"RIGHT_PAREN"===this.tokenAtCursor?.type?e.slice(0,-1)||"":e}computeParenthesisRelatedToCursor(){for(let e=0;e<this.currentTokens.length;e++)this.currentTokens[e].isParenthesisLinkedToCursor=!1;const e=this.tokenAtCursor;if(e&&""!==e.parenthesesCode&&["LEFT_PAREN","RIGHT_PAREN"].includes(e.type))for(let t=0;t<this.currentTokens.length;t++){const o=this.currentTokens[t];["LEFT_PAREN","RIGHT_PAREN"].includes(o.type)&&o.parenthesesCode===e.parenthesesCode&&o!==e&&(this.currentTokens[t].isParenthesisLinkedToCursor=!0,this.tokenAtCursor.isParenthesisLinkedToCursor=!0)}}updateRangeColor(){if(!Vt(this._currentContent)||"inactive"===this.editionMode)return;const e=this.sheetId,t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),o={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(o[e]=this.colorIndexByRange[e]);const s=new Set(Object.values(o));let i=0;const n=()=>{for(;s.has(i);)i++;return s.add(i),i};for(const e of t){const t=e in o?o[e]:n();o[e]=t}this.colorIndexByRange=o}get highlights(){if(!Vt(this.currentContent)||"inactive"===this.editionMode)return[];const e=this.sheetId,t=e=>{const t=this.colorIndexByRange[e];return Ut[t%Ut.length]};return this.getReferencedRanges().map((o=>{const s=this.getters.getRangeString(o,e),{numberOfRows:i,numberOfCols:n}=wr(o.zone),r=i*n==1?this.getters.expandZone(o.sheetId,o.zone):o.unboundedZone;return{range:this.model.getters.getRangeFromZone(o.sheetId,r),color:t(s),interactive:!0}}))}getReferencedRanges(){const e=this.sheetId;return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value))).filter((e=>!e.invalidSheetName&&!e.invalidXc))}async updateAutoCompleteProvider(){this.autoComplete.hide();const e=await this.autoCompleteKeepLast.add(this.findAutocompleteProvider());e&&(this.autoComplete.useProvider(e),this.model.trigger("update"))}async findAutocompleteProvider(){const e=this.currentContent,t=Vt(e)?this.tokenAtCursor:{type:"STRING",value:e};if("inactive"===this.editionMode||!t||["TRUE","FALSE"].includes(t.value.toUpperCase())||!this.canStartComposerRangeSelection()&&!["SYMBOL","STRING","UNKNOWN"].includes(t.type))return;const o={composer:this,getters:this.getters},s=this.getAutoCompleteProviders().sort(((e,t)=>(e.sequence??1/0)-(t.sequence??1/0))).map((s=>({...s,getProposals:s.getProposals.bind(o,t,e),selectProposal:s.selectProposal.bind(o,t)})));for(const e of s){let o=await e.getProposals();const s=o?.find((e=>e.text===t.value)),i=t.value.replace(/[ ,\(\)]/g,"");if(this._currentContent===this.initialContent&&e.displayAllOnInitialContent&&o?.length)return{proposals:o,selectProposal:e.selectProposal,autoSelectFirstProposal:e.autoSelectFirstProposal??!1};if(s&&this._currentContent!==this.initialContent)return;if(i&&o&&!["ARG_SEPARATOR","LEFT_PAREN","OPERATOR"].includes(t.type)){const e=Ra(i,o,(e=>e.fuzzySearchKey||e.text));s&&!e.length||(o=e)}if(e.maxDisplayedProposals&&(o=o?.slice(0,e.maxDisplayedProposals)),o?.length)return{proposals:o,selectProposal:e.selectProposal,autoSelectFirstProposal:e.autoSelectFirstProposal??!1}}}hideHelp(){this.autoComplete.hide()}autoCompleteOrStop(e){if("inactive"!==this.editionMode){const t=this.autoComplete;if(t.provider&&void 0!==t.selectedIndex){const e=t.provider.proposals[t.selectedIndex]?.text;if(e)return void this.autoComplete.provider?.selectProposal(e)}this.stopEdition(e)}}insertAutoCompleteValue(e){this.autoComplete.provider?.selectProposal(e)}selectAutoCompleteIndex(e){this.autoComplete.selectIndex(Ze(0,e,10))}moveAutoCompleteSelection(e){this.autoComplete.moveSelection(e)}canStartComposerRangeSelection(){if(Vt(this._currentContent)){const e=this.tokenAtCursor;if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let o=t,s=e;for(;!["ARG_SEPARATOR","LEFT_PAREN","OPERATOR"].includes(s.type)||tl.includes(s.value);){if("SPACE"!==s.type||o<1)return!1;o--,s=this.currentTokens[o]}for(o=t+1,s=this.currentTokens[o];s&&!["ARG_SEPARATOR","RIGHT_PAREN","OPERATOR"].includes(s.type);){if("SPACE"!==s.type)return!1;o++,s=this.currentTokens[o]}return!0}return!1}getNumberOfMissingParenthesis(e){return e.filter((e=>"LEFT_PAREN"===e.type)).length-e.filter((e=>"RIGHT_PAREN"===e.type)).length}}const vE=CS.content,bE=300,SE="selector-flag",CE="highlight-parenthesis-flag",yE="highlight-flag";mh`
|
|
270
|
+
`;class rE extends t.Component{static template="o-spreadsheet-SpeechBubble";static props={content:String,anchorRect:Object};static components={};spreadsheetRect=Ax();bubbleRef=t.useRef("bubble");setup(){t.useEffect((()=>{const e=this.bubbleRef.el;if(!e)return;const t=this.props.anchorRect,o=cy(e),s=t.x+t.width/2-o.width/2-this.spreadsheetRect.x,i=t.y-o.height-7-this.spreadsheetRect.y;e.style.left=`${s}px`,e.style.top=`${i}px`}))}}class aE{lastId=0;add(e){this.lastId++;const t=this.lastId;return new Promise(((o,s)=>{e.then((e=>{this.lastId===t&&o(e)})).catch((e=>{this.lastId===t&&s(e)}))}))}}const lE=new n;function cE(e,t,o){const{x:s,y:i,width:n,height:r}=o;if(n<0||r<0)return;const l=t.color||a,{ctx:c}=e;c.save(),t.noBorder||(t.dashed&&c.setLineDash([5,3]),c.strokeStyle=l,t.thinLine?(c.lineWidth=1,c.strokeRect(s,i,n,r)):(c.lineWidth=2,c.strokeRect(s+.5,i+.5,n,r))),t.noFill||(c.fillStyle=eo($t(l),t.fillAlpha??.12),c.fillRect(s,i,n,r)),c.restore()}class hE extends hh{mutators=["register","unRegister"];providers=[];constructor(e){super(e),this.onDispose((()=>{this.providers=[]}))}get renderingLayers(){return["Highlights"]}get highlights(){const e=this.getters.getActiveSheetId();return this.providers.flatMap((e=>e.highlights)).filter((t=>t.range.sheetId===e)).map((e=>{const{numberOfRows:t,numberOfCols:o}=wr(e.range.zone),s=t*o==1?this.getters.expandZone(e.range.sheetId,e.range.zone):e.range.unboundedZone;return{...e,range:this.model.getters.getRangeFromZone(e.range.sheetId,s)}}))}register(e){this.providers.push(e)}unRegister(e){this.providers=this.providers.filter((t=>t!==e))}drawLayer(e,t){if("Highlights"===t)for(const t of this.highlights){cE(e,t,this.getters.getVisibleRect(t.range.zone))}}}class dE{mutators=["notifyUser","raiseError","askConfirmation","updateNotificationCallbacks"];notifyUser=e=>window.alert(e.text);askConfirmation=(e,t,o)=>{window.confirm(e)?t():o?.()};raiseError=(e,t)=>{window.alert(e),t?.()};updateNotificationCallbacks(e){this.notifyUser=e.notifyUser||this.notifyUser,this.raiseError=e.raiseError||this.raiseError,this.askConfirmation=e.askConfirmation||this.askConfirmation}}class uE extends hh{mutators=["useProvider","moveSelection","hide","selectIndex"];selectedIndex=void 0;provider;get selectedProposal(){if(void 0!==this.selectedIndex&&void 0!==this.provider)return this.provider.proposals[this.selectedIndex]}useProvider(e){this.provider=e,this.selectedIndex=e.autoSelectFirstProposal?0:void 0}hide(){this.provider=void 0,this.selectedIndex=void 0}selectIndex(e){this.selectedIndex=e}moveSelection(e){this.provider&&(void 0!==this.selectedIndex?"previous"===e?(this.selectedIndex--,this.selectedIndex<0&&(this.selectedIndex=this.provider.proposals.length-1)):this.selectedIndex=(this.selectedIndex+1)%this.provider.proposals.length:this.selectedIndex=0)}}const gE="#000000",pE="#3da4ab",mE={OPERATOR:pE,NUMBER:"#02c39a",STRING:"#00a82d",FUNCTION:gE,DEBUGGER:pE,LEFT_PAREN:gE,RIGHT_PAREN:gE,ARG_SEPARATOR:gE,ORPHAN_RIGHT_PAREN:"#ff0000"};class fE extends hh{mutators=["startEdition","setCurrentContent","stopEdition","stopComposerRangeSelection","cancelEdition","cycleReferences","hideHelp","autoCompleteOrStop","insertAutoCompleteValue","moveAutoCompleteSelection","selectAutoCompleteIndex","toggleEditionMode","changeComposerCursorSelection","replaceComposerCursorSelection","hoverToken"];col=0;row=0;editionMode="inactive";sheetId="";_currentContent="";currentTokens=[];selectionStart=0;selectionEnd=0;initialContent="";colorIndexByRange={};autoComplete=new uE(this.get);hoveredTokens=[];hoveredContentEvaluation="";autoCompleteKeepLast=new aE;notificationStore=this.get(dE);highlightStore=this.get(hE);constructor(e){super(e),this.highlightStore.register(this),this.onDispose((()=>{this.highlightStore.unRegister(this)}))}handleEvent(e){this.hideHelp();const t=this.getters.getActiveSheetId();let o;if(o=e.options.unbounded?this.getters.getUnboundedZone(t,e.anchor.zone):e.anchor.zone,"newAnchor"===e.mode)"selecting"===this.editionMode&&this.insertSelectedRange(o);else"selecting"===this.editionMode?this.replaceSelectedRange(o):this.updateComposerRange(e.previousAnchor.zone,o)}changeComposerCursorSelection(e,t){this.isSelectionValid(this._currentContent.length,e,t)&&(this.selectionStart=e,this.selectionEnd=t,this.computeFormulaCursorContext(),this.computeParenthesisRelatedToCursor(),this.updateAutoCompleteProvider())}stopComposerRangeSelection(){this.isSelectingRange&&(this.editionMode="editing")}startEdition(e,t){if(t){const o=e||this.getComposerContent(this.getters.getActivePosition());if(!this.isSelectionValid(o.length,t.start,t.end))return}const{col:o,row:s}=this.getters.getActivePosition();this.model.dispatch("SELECT_FIGURE",{figureId:null}),this.model.dispatch("SCROLL_TO_CELL",{col:o,row:s}),"inactive"!==this.editionMode&&e?this.setContent(e,t):this._startEdition(e,t),this.updateTokenColor(),this.computeFormulaCursorContext(),this.computeParenthesisRelatedToCursor(),this.updateAutoCompleteProvider()}cancelEdition(){this.resetContent(),this.cancelEditionAndActivateSheet()}setCurrentContent(e,t){t&&!this.isSelectionValid(e.length,t.start,t.end)||(this.setContent(e,t,!0),this.updateTokenColor(),this.computeFormulaCursorContext(),this.computeParenthesisRelatedToCursor())}replaceComposerCursorSelection(e){this.replaceSelection(e)}handle(e){switch(e.type){case"SELECT_FIGURE":e.figureId&&(this.resetContent(),this.cancelEditionAndActivateSheet());break;case"START_CHANGE_HIGHLIGHT":const{left:t,top:o}=e.zone;this.isSelectingRange&&(this.editionMode="editing"),this.model.selection.resetAnchor(this,{cell:{col:t,row:o},zone:e.zone})}}get currentContent(){return"inactive"===this.editionMode?this.getComposerContent(this.getters.getActivePosition()):this._currentContent}get composerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}get isSelectingRange(){return"selecting"===this.editionMode}get showSelectionIndicator(){return this.isSelectingRange&&this.canStartComposerRangeSelection()}get tokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((o=>o.start<=e&&o.end>=t))}get autoCompleteProposals(){return this.autoComplete.provider?.proposals||[]}get autoCompleteSelectedIndex(){return this.autoComplete.selectedIndex}get isAutoCompleteDisplayed(){return!!this.autoComplete.provider}cycleReferences(){const e=this.getters.getLocale(),t=mv(this.composerSelection,this._currentContent,e);void 0!==t&&this.setCurrentContent(t.content,t.selection)}toggleEditionMode(){if("inactive"===this.editionMode)return;const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd),o=[...this.currentTokens].reverse().find((o=>o.end>=e&&t>=o.start&&"REFERENCE"===o.type));if("editing"===this.editionMode&&o){const e=this.getters.getActiveSheetId(),{sheetName:t,xc:s}=ta(o.value),i=this.getters.getSheetIdByName(t);i&&i!==e&&this.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e,sheetIdTo:i}),this.selectionStart=this.selectionEnd=o.end;const n=this.getters.getRangeFromSheetXC(this.sheetId,s).zone;this.captureSelection(n),this.editionMode="selecting"}else this.editionMode="editing"}hoverToken(e){this.currentTokens.forEach((e=>e.isInHoverContext=void 0));const t=[...this.currentTokens];if(void 0===e||["ARG_SEPARATOR","SPACE"].includes(t[e].type))return this.hoveredContentEvaluation="",void(this.hoveredTokens=[]);const o=this.getNumberOfMissingParenthesis(t);o>0&&t.push(...Array(o).fill({value:")",type:"RIGHT_PAREN"}));let s=t;if(0!==e){const o=this.getRelatedTokens(t,e),i=t.filter((e=>!o.includes(e)&&"SPACE"!==e.type));s=1===i.length&&i[0]===t[0]?t:o}s.forEach((e=>e.isInHoverContext=!0));let i=s.map((e=>e.value)).join("");Vt(i)||(i=`=${i}`);const n=Cl(i,this.getters.getLocale()),r=this.getters.evaluateFormulaResult(this.sheetId,n);this.hoveredTokens=s,this.hoveredContentEvaluation=this.evaluationResultToDisplayString(r)}getRelatedTokens(e,t){try{const o=ov(e);let s;for(const e of iv(o))if(t>=e.tokenStartIndex&&t<=e.tokenEndIndex)s=e;else if(t<e.tokenStartIndex)break;return s?e.slice(s.tokenStartIndex,s.tokenEndIndex+1):e}catch(t){if(t instanceof ei)return e;throw t}}evaluationResultToDisplayString(e){const t=this.getters.getLocale();if(Ws(e)){const o=","===t.decimalSeparator?"/":",";return`{${Mi(e).map((e=>e.map((e=>this.cellValueToDisplayString(e))).join(o))).join(";")}}`}return this.cellValueToDisplayString(e)}cellValueToDisplayString(e){const t=e.value;switch(typeof t){case"number":return bn(t,{locale:this.getters.getLocale(),format:e.format});case"string":return hi(t)?t:`"${t}"`;case"boolean":return t?"TRUE":"FALSE"}return"0"}captureSelection(e,t,o){this.model.selection.capture(this,{cell:{col:t||e.left,row:o||e.right},zone:e},{handleEvent:this.handleEvent.bind(this),release:()=>{this._stopEdition()}})}isSelectionValid(e,t,o){return t>=0&&t<=e&&o>=0&&o<=e}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=Dr({col:this.col,row:this.row});this.model.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.editionMode="selecting"}_startEdition(e,t){const o=this.getters.getActiveCell(),s=this.getters.getLocale();e&&o.format?.includes("%")&&Is(e,s)&&(t=t||{start:e.length,end:e.length},e=`${e}%`);const{col:i,row:n,sheetId:r}=this.getters.getActivePosition();this.col=i,this.sheetId=r,this.row=n,this.initialContent=this.getComposerContent({sheetId:r,col:i,row:n}),this.editionMode="editing",this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const a=Dr({col:this.col,row:this.row});this.captureSelection(a,i,n)}_stopEdition(){if("inactive"!==this.editionMode){this.cancelEditionAndActivateSheet();let e=this.getCurrentCanonicalContent();if(!(this.initialContent!==e))return;if(e&&Vt(e)){const t=this.getNumberOfMissingParenthesis(this.currentTokens);t>0&&(e+=dt(new Array(t).fill(")")))}this.confirmEdition(e)}}getCurrentCanonicalContent(){return Cl(this._currentContent,this.getters.getLocale())}cancelEditionAndActivateSheet(){if("inactive"===this.editionMode)return;this._cancelEdition();this.getters.getActiveSheetId()!==this.sheetId&&this.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}_cancelEdition(){"inactive"!==this.editionMode&&(this.editionMode="inactive",this.model.selection.release(this),this.colorIndexByRange={},this.hoveredTokens=[],this.hoveredContentEvaluation="")}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,o){const s=this._currentContent!==e;if(this._currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,s||"inactive"!==this.editionMode){const t=this.getters.getLocale();this.currentTokens=Vt(e)?hv(e,t):[],this.currentTokens.length>100&&o&&this.notificationStore.raiseError(Vo("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells"))}this.canStartComposerRangeSelection()&&this.startComposerRangeSelection(),this.updateAutoCompleteProvider()}getAutoCompleteProviders(){return lE.getAll()}insertSelectedRange(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=this.getZoneReference(e);this.canStartComposerRangeSelection()?this.insertText(o,t):this.insertText(","+o,t)}replaceSelectedRange(e){const t=this.getZoneReference(e),o=this.tokenAtCursor,s="REFERENCE"===o?.type?o.start:this.selectionStart;this.replaceText(t,s,this.selectionEnd)}updateComposerRange(e,t){const o=this.getters.getActiveSheetId(),s=this.tokenAtCursor,i=(s?[s,...this.currentTokens]:this.currentTokens).filter((e=>"REFERENCE"===e.type)).find((t=>{const{xc:s,sheetName:i}=ta(t.value),n=i||this.getters.getSheetName(this.sheetId);if(!la(this.getters.getSheetName(o),n))return!1;const r=this.getters.getRangeFromSheetXC(o,s);return br(this.getters.expandZone(o,r.zone),e)}));if(!i)return;const n=this.getters.getRangeFromSheetXC(o,i.value);this.selectionStart=i.start,this.selectionEnd=this.selectionStart+i.value.length;const r=this.getters.getRangeFromZone(o,t),a=this.getRangeReference(r,n.parts);this.replaceSelection(a)}getZoneReference(e){const t=this.sheetId,o=this.getters.getActiveSheetId(),s=this.getters.getRangeFromZone(o,e);return this.getters.getSelectionRangeString(s,t)}getRangeReference(e,t){const o={...e,parts:[...t]};return this.getters.getSelectionRangeString(o,this.sheetId)}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),o=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,o)}replaceText(e,t,o){this._currentContent=this._currentContent.slice(0,t)+this._currentContent.slice(o,this._currentContent.length),this.insertText(e,t)}insertText(e,t){const o=this._currentContent.slice(0,t)+e+this._currentContent.slice(t),s=t+e.length;this.setCurrentContent(o,{start:s,end:s})}updateTokenColor(){this.updateRangeColor();for(let e=0;e<this.currentTokens.length;e++)this.currentTokens[e].color=this.getTokenColor(this.currentTokens[e])}getTokenColor(e){if("REFERENCE"===e.type){const{xc:t,sheetName:o}=ta(e.value);return this.rangeColor(t,o)||gE}if("SYMBOL"===e.type){const t=e.value.toUpperCase();if("TRUE"===t||"FALSE"===t)return mE.NUMBER;if(t in CS.content)return mE.FUNCTION}return["LEFT_PAREN","RIGHT_PAREN"].includes(e.type)&&""===e.parenthesesCode?mE.ORPHAN_RIGHT_PAREN:mE[e.type]||gE}rangeColor(e,t){const o=t?this.model.getters.getSheetIdByName(t):this.sheetId,s=this.highlights.find((t=>{if(t.range.sheetId!==o)return!1;let s=this.model.getters.getRangeFromSheetXC(o,e).zone;return s=1===Pr(s)?this.model.getters.expandZone(o,s):s,br(s,t.range.zone)}));return s&&s.color?s.color:void 0}computeFormulaCursorContext(){for(let e=0;e<this.currentTokens.length;e++)this.currentTokens[e].isBlurred=!1;if(this.selectionStart!==this.selectionEnd)return;const e=this.getParenthesesCodeAfterCursor(),t=[...this.currentTokens].reverse().find((t=>e.startsWith(t.parenthesesCode)&&"SYMBOL"===t.type));if(t)for(let e=0;e<this.currentTokens.length;e++)(this.currentTokens[e].parenthesesCode||"").startsWith(t.parenthesesCode||"")||(this.currentTokens[e].isBlurred=!0)}getParenthesesCodeAfterCursor(){const e=this.tokenAtCursor?.parenthesesCode||"";return"RIGHT_PAREN"===this.tokenAtCursor?.type?e.slice(0,-1)||"":e}computeParenthesisRelatedToCursor(){for(let e=0;e<this.currentTokens.length;e++)this.currentTokens[e].isParenthesisLinkedToCursor=!1;const e=this.tokenAtCursor;if(e&&""!==e.parenthesesCode&&["LEFT_PAREN","RIGHT_PAREN"].includes(e.type))for(let t=0;t<this.currentTokens.length;t++){const o=this.currentTokens[t];["LEFT_PAREN","RIGHT_PAREN"].includes(o.type)&&o.parenthesesCode===e.parenthesesCode&&o!==e&&(this.currentTokens[t].isParenthesisLinkedToCursor=!0,this.tokenAtCursor.isParenthesisLinkedToCursor=!0)}}updateRangeColor(){if(!Vt(this._currentContent)||"inactive"===this.editionMode)return;const e=this.sheetId,t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),o={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(o[e]=this.colorIndexByRange[e]);const s=new Set(Object.values(o));let i=0;const n=()=>{for(;s.has(i);)i++;return s.add(i),i};for(const e of t){const t=e in o?o[e]:n();o[e]=t}this.colorIndexByRange=o}get highlights(){if(!Vt(this.currentContent)||"inactive"===this.editionMode)return[];const e=this.sheetId,t=e=>{const t=this.colorIndexByRange[e];return Ut[t%Ut.length]};return this.getReferencedRanges().map((o=>{const s=this.getters.getRangeString(o,e),{numberOfRows:i,numberOfCols:n}=wr(o.zone),r=i*n==1?this.getters.expandZone(o.sheetId,o.zone):o.unboundedZone;return{range:this.model.getters.getRangeFromZone(o.sheetId,r),color:t(s),interactive:!0}}))}getReferencedRanges(){const e=this.sheetId;return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value))).filter((e=>!e.invalidSheetName&&!e.invalidXc))}async updateAutoCompleteProvider(){this.autoComplete.hide();const e=await this.autoCompleteKeepLast.add(this.findAutocompleteProvider());e&&(this.autoComplete.useProvider(e),this.model.trigger("update"))}async findAutocompleteProvider(){const e=this.currentContent,t=Vt(e)?this.tokenAtCursor:{type:"STRING",value:e};if("inactive"===this.editionMode||!t||["TRUE","FALSE"].includes(t.value.toUpperCase())||!this.canStartComposerRangeSelection()&&!["SYMBOL","STRING","UNKNOWN"].includes(t.type))return;const o={composer:this,getters:this.getters},s=this.getAutoCompleteProviders().sort(((e,t)=>(e.sequence??1/0)-(t.sequence??1/0))).map((s=>({...s,getProposals:s.getProposals.bind(o,t,e),selectProposal:s.selectProposal.bind(o,t)})));for(const e of s){let o=await e.getProposals();const s=o?.find((e=>e.text===t.value)),i=t.value.replace(/[ ,\(\)]/g,"");if(this._currentContent===this.initialContent&&e.displayAllOnInitialContent&&o?.length)return{proposals:o,selectProposal:e.selectProposal,autoSelectFirstProposal:e.autoSelectFirstProposal??!1};if(s&&this._currentContent!==this.initialContent)return;if(i&&o&&!["ARG_SEPARATOR","LEFT_PAREN","OPERATOR"].includes(t.type)){const e=Ra(i,o,(e=>e.fuzzySearchKey||e.text));s&&!e.length||(o=e)}if(e.maxDisplayedProposals&&(o=o?.slice(0,e.maxDisplayedProposals)),o?.length)return{proposals:o,selectProposal:e.selectProposal,autoSelectFirstProposal:e.autoSelectFirstProposal??!1}}}hideHelp(){this.autoComplete.hide()}autoCompleteOrStop(e){if("inactive"!==this.editionMode){const t=this.autoComplete;if(t.provider&&void 0!==t.selectedIndex){const e=t.provider.proposals[t.selectedIndex]?.text;if(e)return void this.autoComplete.provider?.selectProposal(e)}this.stopEdition(e)}}insertAutoCompleteValue(e){this.autoComplete.provider?.selectProposal(e)}selectAutoCompleteIndex(e){this.autoComplete.selectIndex(Ze(0,e,10))}moveAutoCompleteSelection(e){this.autoComplete.moveSelection(e)}canStartComposerRangeSelection(){if(Vt(this._currentContent)){const e=this.tokenAtCursor;if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let o=t,s=e;for(;!["ARG_SEPARATOR","LEFT_PAREN","OPERATOR"].includes(s.type)||tl.includes(s.value);){if("SPACE"!==s.type||o<1)return!1;o--,s=this.currentTokens[o]}for(o=t+1,s=this.currentTokens[o];s&&!["ARG_SEPARATOR","RIGHT_PAREN","OPERATOR"].includes(s.type);){if("SPACE"!==s.type)return!1;o++,s=this.currentTokens[o]}return!0}return!1}getNumberOfMissingParenthesis(e){return e.filter((e=>"LEFT_PAREN"===e.type)).length-e.filter((e=>"RIGHT_PAREN"===e.type)).length}}const vE=CS.content,bE=300,SE="selector-flag",CE="highlight-parenthesis-flag",yE="highlight-flag";mh`
|
|
271
271
|
.o-composer-container {
|
|
272
272
|
.o-composer {
|
|
273
273
|
overflow-y: auto;
|
|
@@ -1012,7 +1012,7 @@
|
|
|
1012
1012
|
height: ${te}px;
|
|
1013
1013
|
}
|
|
1014
1014
|
}
|
|
1015
|
-
`;class zP extends t.Component{static props={onOpenContextMenu:Function};static template="o-spreadsheet-HeadersOverlay";static components={ColResizer:UP,RowResizer:BP};selectAll(){this.env.model.selection.selectAll()}}class $P extends hh{fingerprints;hoveredTables;hoveredIcon;lastRenderBoxes=new Map;preventNewAnimationsInNextFrame=!1;zonesWithPreventedAnimationsInNextFrame=[];animations=new Map;constructor(e){super(e),this.getters=e(ah).getters,this.fingerprints=e(ND),this.hoveredTables=e(FP),this.hoveredIcon=e(PP)}handle(e){switch(e.type){case"START":case"ACTIVATE_SHEET":case"ADD_COLUMNS_ROWS":case"REMOVE_COLUMNS_ROWS":this.animations.clear(),this.preventNewAnimationsInNextFrame=!0;break;case"RESIZE_COLUMNS_ROWS":this.preventNewAnimationsInNextFrame=!0;break;case"REDO":this.zonesWithPreventedAnimationsInNextFrame=[];break;case"UNDO":for(const t of e.commands)if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type||"RESIZE_COLUMNS_ROWS"===t.type){this.animations.clear(),this.preventNewAnimationsInNextFrame=!0;break}break;case"PASTE":this.zonesWithPreventedAnimationsInNextFrame.push(...this.getters.getSelectedZones());break;case"UPDATE_CELL":const t=this.getters.getCommandZones(e);this.zonesWithPreventedAnimationsInNextFrame.push(...t)}}get renderingLayers(){return["Background","Headers"]}drawLayer(e,t,o){switch(t){case"Background":this.drawGlobalBackground(e);const t=this.lastRenderBoxes;this.lastRenderBoxes=new Map;for(const{zone:s,rect:i}of this.getters.getAllActiveViewportsZonesAndRect()){const{ctx:n}=e;n.save(),n.beginPath(),n.rect(i.x,i.y,i.width,i.height),n.clip();const r=this.getGridBoxes(s),a=this.getBoxesWithAnimations(r,t,o);this.drawBackground(e,a),this.drawOverflowingCellBackground(e,a),this.drawCellBackground(e,a),this.drawBorders(e,a),this.drawTexts(e,a),this.drawIcon(e,a),n.restore()}this.drawFrozenPanes(e),this.preventNewAnimationsInNextFrame=!1,this.zonesWithPreventedAnimationsInNextFrame=[];break;case"Headers":this.getters.isDashboard()||(this.drawHeaders(e),this.drawFrozenPanesHeaders(e))}}drawGlobalBackground(e){const{ctx:t}=e,{width:o,height:s}=this.getters.getSheetViewDimensionWithHeaders();t.fillStyle="#ffffff",t.fillRect(0,0,o+r,s+r)}drawBackground(e,t){const{ctx:o,thinLineWidth:s}=e,i=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId()),n=i?.1*s:0;if(i)for(const e of t)e.skipCellGridLines||(o.strokeStyle="#E2E3E3",o.lineWidth=s,o.strokeRect(e.x+n,e.y+n,e.width-2*n,e.height-2*n))}drawCellBackground(e,t){const{ctx:o}=e;for(const e of t){const t=e.style;if(t.fillColor&&"#ffffff"!==t.fillColor&&(o.fillStyle=t.fillColor||"#ffffff",o.fillRect(e.x,e.y,e.width,e.height)),e.dataBarFill){o.fillStyle=e.dataBarFill.color;const t=e.dataBarFill.percentage,s=e.width*(t/100);o.fillRect(e.x,e.y,s,e.height)}if(e?.chip){o.save(),o.beginPath(),o.rect(e.x,e.y,e.width,e.height),o.clip();const t=e.chip;o.fillStyle=t.color;const s=10;o.beginPath(),o.roundRect(t.x,t.y,t.width,t.height,s),o.fill(),o.restore()}e.overlayColor&&(o.fillStyle=e.overlayColor,o.fillRect(e.x,e.y,e.width,e.height)),e.isError&&(o.fillStyle="red",o.beginPath(),o.moveTo(e.x+e.width-5,e.y),o.lineTo(e.x+e.width,e.y),o.lineTo(e.x+e.width,e.y+5),o.fill())}}drawOverflowingCellBackground(e,t){const{ctx:o,thinLineWidth:s}=e;for(const e of t)if(e.content&&e.isOverflow){const t=e.content.align||"left";let i,n;const r=e.y+s/2,a=e.height-s,l=Math.min(e.clipRect?.width||1/0,e.content.width);"left"===t?(i=e.x+s/2,n=l-2*s):"right"===t?(i=e.x+e.width-s/2,n=2*s-l):(i=(e.clipRect?.x||e.x+e.width/2-e.content.width/2)+s/2,n=l-2*s),o.fillStyle="#ffffff",o.fillRect(i,r,n,a)}}drawBorders(e,t){const{ctx:o}=e;for(const e of t){const t=e.border;if(t){const{x:o,y:i,width:n,height:r}=e;t.left&&s(t.left,o,i,o,i+r),t.top&&s(t.top,o,i,o+n,i),t.right&&s(t.right,o+n,i,o+n,i+r),t.bottom&&s(t.bottom,o,i+r,o+n,i+r)}}function s({color:e,style:t,opacity:s},i,n,r,a){switch(o.globalAlpha=s??1,o.strokeStyle=e,t){case"medium":o.lineWidth=2,n+=(i+=n===a?-.5:.5)===(r+=n===a?1.5:.5)?-.5:.5,a+=i===r?1.5:.5;break;case"thick":o.lineWidth=3,n===a&&(i--,r++),i===r&&(n--,a++);break;case"dashed":o.lineWidth=1,o.setLineDash([1,3]);break;case"dotted":o.lineWidth=1,n===a&&(i+=.5,r+=.5),i===r&&(n+=.5,a+=.5),o.setLineDash([1,1]);break;default:o.lineWidth=1}o.beginPath(),o.moveTo(i,n),o.lineTo(r,a),o.stroke(),o.lineWidth=1,o.setLineDash([]),o.globalAlpha=1}}drawTexts(e,t){const{ctx:o}=e;let s;o.textBaseline="top";for(const e of t)if(e.content){o.globalAlpha=e.textOpacity??1;const t=e.style||{},i=e.content.align||"left",n=ka(t);if(n!==s&&(s=n,o.font=n),o.fillStyle=t.textColor||"#000",o.textAlign=i,e.clipRect){o.save(),o.beginPath();const{x:t,y:s,width:i,height:n}=e.clipRect;o.rect(t,s,i,n),o.clip()}const r=e.content.x;let a=e.content.y;for(const s of e.content.textLines)$a(o,s,{x:r,y:a},t.underline,t.strikethrough),a+=re+e.content.fontSizePx;e.clipRect&&o.restore(),o.globalAlpha=1}}drawIcon(e,t){const{ctx:o}=e;for(const e of t)for(const t of Object.values(e.icons)){if(!t)continue;const s=mt({id:t.type,position:t.position},this.hoveredIcon.hoveredIcon)&&t.hoverSvg||t.svg;if(!s)continue;o.save(),o.globalAlpha=t.opacity??1,o.beginPath();const i=t.clipRect||e;o.rect(i.x,i.y,i.width,i.height),o.clip();const n=t.size,{x:r,y:a}=this.getters.getCellIconRect(t,e);o.translate(r,a),o.scale(n/s.width,n/s.height);for(const e of s.paths)o.fillStyle=e.fillColor,o.fill(ZR(e.path));o.restore()}}drawHeaders(e){const{ctx:t,thinLineWidth:o}=e,s=this.getters.getSheetViewVisibleCols(),i=s[0],n=this.getters.getSheetViewVisibleRows(),r=n[0],{width:a,height:l}=this.getters.getSheetViewDimensionWithHeaders(),g=this.getters.getSelectedZones(),p=function(e){const t=new Set;for(const o of er(e))for(const e of je(o.left,o.right+1))t.add(e);return t}(g),m=function(e){const t=new Set;for(const o of er(e))for(const e of je(o.top,o.bottom+1))t.add(e);return t}(g),f=this.getters.getActiveSheetId(),v=this.getters.getNumberCols(f),b=this.getters.getNumberRows(f),S=this.getters.getActiveCols(),C=this.getters.getActiveRows();t.font=`400 11px ${fe}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=o,t.strokeStyle="#333";for(const e of s){const o={left:e,right:e,top:0,bottom:b-1},{x:s,width:i}=this.getters.getVisibleRect(o),n=S.has(e),r=p.has(e);t.fillStyle=n?d:r?h:c,t.fillRect(s,0,i,te)}for(const e of n){const o={top:e,bottom:e,left:0,right:v-1},{y:s,height:i}=this.getters.getVisibleRect(o),n=C.has(e),r=m.has(e);t.fillStyle=n?d:r?h:c,t.fillRect(0,s,oe,i)}t.beginPath(),t.moveTo(oe,0),t.lineTo(oe,l),t.moveTo(0,te),t.lineTo(a,te),t.strokeStyle="#C0C0C0",t.stroke();for(const e of s){const o=Co(e);t.fillStyle=S.has(e)?"#fff":u;const s={left:e,right:e,top:r,bottom:r},{x:i,width:n}=this.getters.getRect(s),{x:a,width:l}=this.getters.getVisibleRect(s);t.save(),t.beginPath(),t.rect(a,0,l,te),t.clip(),t.fillText(o,i+n/2,13),t.restore(),t.beginPath(),t.moveTo(i+n,0),t.lineTo(i+n,te),t.stroke()}for(const e of n){t.fillStyle=C.has(e)?"#fff":u;const o={top:e,bottom:e,left:i,right:i},{y:s,height:n}=this.getters.getRect(o),{y:r,height:a}=this.getters.getVisibleRect(o);t.save(),t.beginPath(),t.rect(0,r,oe,a),t.clip(),t.fillText(String(e+1),24,s+n/2),t.restore(),t.beginPath(),t.moveTo(0,s+n),t.lineTo(oe,s+n),t.stroke()}}drawFrozenPanesHeaders(e){const{ctx:t,thinLineWidth:o}=e,{x:s,y:i}=this.getters.getMainViewportCoordinates(),n=this.getters.isDashboard()?0:oe,r=this.getters.isDashboard()?0:te;t.lineWidth=6*o,t.strokeStyle=x,t.beginPath(),s&&(t.moveTo(n+s,0),t.lineTo(n+s,r)),i&&(t.moveTo(0,r+i),t.lineTo(n,r+i)),t.stroke()}drawFrozenPanes(e){const{ctx:t,thinLineWidth:o}=e,{x:s,y:i}=this.getters.getMainViewportCoordinates(),n=this.getters.getSheetViewVisibleCols(),r=n[0],a=n[n.length-1],l=this.getters.getSheetViewVisibleRows(),c={left:r,right:a,top:l[0],bottom:l[l.length-1]},h=this.getters.getVisibleRect(c),d=this.getters.isDashboard()?0:oe,u=this.getters.isDashboard()?0:te;t.lineWidth=6*o,t.strokeStyle="#DADFE8",t.beginPath(),s&&(t.moveTo(d+s,u),t.lineTo(d+s,h.height+u)),i&&(t.moveTo(d,u+i),t.lineTo(h.width+d,u+i)),t.stroke()}findNextEmptyCol(e,t,o){const s=this.getters.getActiveSheetId();let i=e;for(;i<t;){const e={sheetId:s,col:i+1,row:o},t=this.getters.getEvaluatedCell(e),n=this.getters.getCellComputedBorder(e),r=this.getters.doesCellHaveGridIcon(e);if(t.type!==Ts.empty||this.getters.isInMerge(e)||n?.left||r)return i;i++}return i}findPreviousEmptyCol(e,t,o){const s=this.getters.getActiveSheetId();let i=e;for(;i>t;){const e={sheetId:s,col:i-1,row:o},t=this.getters.getEvaluatedCell(e),n=this.getters.getCellComputedBorder(e),r=this.getters.doesCellHaveGridIcon(e);if(t.type!==Ts.empty||this.getters.isInMerge(e)||n?.right||r)return i;i--}return i}computeCellAlignment(e,t){const o=this.getters.getCell(e);if(o?.isFormula&&this.getters.shouldShowFormulas())return"left";const{align:s}=this.getters.getCellStyle(e),i=this.getters.getEvaluatedCell(e);return t&&i.type===Ts.number?"center"!==s?"left":s:s||i.defaultAlign}createZoneBox(e,t,o){const{left:s,right:i}=o,n=t.left,r=t.top,a={sheetId:e,col:n,row:r},l=this.getters.getEvaluatedCell(a),c=this.getters.shouldShowFormulas(),{x:h,y:d,width:u,height:g}=this.getters.getRect(t),p=this.getters.getDataValidationChipStyle(a);let m=this.getters.getCellComputedStyle(a);if(this.fingerprints.isEnabled){const e=this.fingerprints.colors.get(a);m={...m,fillColor:e}}p?.textColor&&(m={...m,textColor:p.textColor});const f=this.fingerprints.isEnabled?void 0:this.getters.getConditionalDataBar(a),v=this.getters.getCellIcons(a),b={left:v.find((e=>"left"===e?.horizontalAlign)),right:v.find((e=>"right"===e?.horizontalAlign)),center:v.find((e=>"center"===e?.horizontalAlign))},S={id:dr(t),x:h,y:d,width:u,height:g,border:this.getters.getCellComputedBorder(a)||void 0,style:m,dataBarFill:f,overlayColor:this.hoveredTables.overlayColors.get(a),isError:l.type===Ts.error&&!!l.message||this.getters.isDataValidationInvalid(a),icons:b,disabledAnimation:this.zonesWithPreventedAnimationsInNextFrame.some((e=>yr(t,e)||Sr(t,e)))},C=Va(S.style);if(l.type===Ts.empty||S.icons.center)return S;const y=m.wrapping||"overflow",w="wrap"===y&&!c,I=u-2*re,x=this.getters.getCellMultiLineText(a,{maxWidth:I,wrapText:w}),E=Math.max(...x.map((e=>this.getters.getTextWidth(e,m)+re))),R=p?5:0,T=(S.icons.left?S.icons.left.size+S.icons.left.margin:0)+R,A=(S.icons.right?S.icons.right.size+S.icons.right.margin:0)+R,D=T+E+A,_=this.computeCellAlignment(a,D>u),O=x.length,F=Math.round(this.getters.computeTextYCoordinate(S,C,m.verticalAlign,O));let P=S.x;P+="left"===_?re+T:"right"===_?S.width-re-A:S.width/2,P=Math.round(P);const M=Ta(C,O);if(S.content={textLines:x,width:"overflow"===y?E:u,align:_,x:P,y:F,fontSizePx:C},p?.fillColor){const e=T,t=5;S.chip={color:p.fillColor,width:S.width-e-t,height:M+2,x:S.x+e,y:F-2}}const N=D>u||C>g;if(S.icons.left||S.icons.right||S.chip)S.clipRect={x:S.x+T,y:S.y,width:Math.max(0,u-T-A),height:g};else if(N&&"overflow"===y){let e,o;switch(this.getters.isInMerge(a)?(e=this.getters.getMerge(a).right,o=n):(e=S.border?.right?t.right:this.findNextEmptyCol(n,i,r),o=S.border?.left?t.left:this.findPreviousEmptyCol(n,s,r),S.isOverflow=!0),_){case"left":{const o=Dr({col:e,row:r}),{x:s,y:i,width:n,height:a}=this.getters.getVisibleRect(fr(t,o));(n<D||C>a||x.length>1)&&(S.clipRect={x:s,y:i,width:n,height:a});break}case"right":{const e=Dr({col:o,row:r}),{x:s,y:i,width:n,height:a}=this.getters.getVisibleRect(fr(t,e));(n<D||C>a||x.length>1)&&(S.clipRect={x:s,y:i,width:n,height:a});break}case"center":{const s={...t,left:o,right:e},{x:i,y:n,height:r,width:a}=this.getters.getVisibleRect(s),l=D/2,c=S.x+S.width/2;if(i+a<c+l||i>c-l||C>r||x.length>1){const e=i>c-l?i:c-l,t=i+a-e;S.clipRect={x:e,y:n,width:t,height:r}}break}}}else("clip"===y||"wrap"===y||x.length>1)&&(S.clipRect={x:S.x,y:S.y,width:u,height:g});return S}getGridBoxes(e){const t=[],o=this.getters.getSheetViewVisibleCols().filter((t=>t>=e.left&&t<=e.right)),s=o[0],i=o[o.length-1],n=this.getters.getSheetViewVisibleRows().filter((t=>t>=e.top&&t<=e.bottom)),r={left:s,right:i,top:n[0],bottom:n[n.length-1]},a=this.getters.getActiveSheetId();for(const e of n)for(const s of o){const o={sheetId:a,col:s,row:e};this.getters.isInMerge(o)||t.push(this.createZoneBox(a,Dr(o),r))}for(const e of this.getters.getMerges(a))if(!this.getters.isMergeHidden(a,e)&&Sr(e,r)){const o=this.createZoneBox(a,e,r),s=this.getters.getCellComputedBorder({sheetId:a,col:e.right,row:e.bottom});o.border={...o.border,bottom:s?s.bottom:void 0,right:s?s.right:void 0},o.isMerge=!0,t.push(o)}return t}getBoxesWithAnimations(e,t,o){return this.updateAnimationsProgress(o),this.addNewAnimations(e,t,o),this.animations.size>0?(this.renderer.startAnimation("grid_renderer_animation"),this.updateBoxesWithAnimations(e)):(this.renderer.stopAnimation("grid_renderer_animation"),e)}updateBoxesWithAnimations(e){const t=[];for(const o of e){const e=this.animations.get(o.id);if(!e){t.push(o);continue}const s=ze(o);t.push(s);for(const i of e.animationTypes){const n=CI.get(i).updateAnimation(e.progress,s,e.oldBox,o);n&&t.push(...n.newBoxes)}}return t}updateAnimationsProgress(e){if(void 0!==e)for(const t of this.animations.keys()){const o=this.animations.get(t);if(void 0===o.startTime){o.startTime=e;continue}const s=e-o.startTime,i=Math.min(1,s/200);i>=1&&this.animations.delete(t),o.progress=i}}addNewAnimations(e,t,o){for(const s of e){this.lastRenderBoxes.set(s.id,s);const e=t.get(s.id);if(this.preventNewAnimationsInNextFrame||!e||s.disabledAnimation)continue;const i=[];for(const t of CI.getAll())t.hasAnimation(e,s)&&i.push(t.id);const n=i.length>0?{animationTypes:i,oldBox:e,progress:0,startTime:o}:void 0;n&&this.animations.set(s.id,n)}}}function GP(e,o,s){const i=t.useRef(e);t.useEffect((function(){const e=i.el,t=window.devicePixelRatio||1,o=e.getContext("2d",{alpha:!1}),r={ctx:o,dpr:t,thinLineWidth:.4*t},{width:a,height:l}=s();if(e.style.width=`${a}px`,e.style.height=`${l}px`,e.width=a*t,e.height=l*t,e.setAttribute("style",`width:${a}px;height:${l}px;`),0===a||0===l)return;o.translate(-.5,-.5),o.scale(t,t),n.draw(r)}));const n=oh(ch);oh($P)}function WP(e,t,o){let s=0,i=0,n=0,r=0,a=!1,l=0,c=null;function h(){if(Math.abs(n)<.05&&(n=0),Math.abs(r)<.05&&(r=0),!n&&!r)return;const e=Date.now(),o=Math.abs(e-l);t(1*(n*o),1*(r*o)),l=e,n*=.95,r*=.95,requestAnimationFrame(h)}DP(e,"touchstart",(function(e){a=!0,({clientX:s,clientY:i}=e.touches[0]),n=0,r=0}),{capture:!1}),DP(e,"touchmove",(function(e){if(!a)return;c&&(clearTimeout(c),c=null);const h=Date.now(),{clientX:d,clientY:u}=e.touches[0],g=s-d,p=i-u,m=h-l;if(!m)return;n=g/m,r=p/m,s=d,i=u,l=h,o()&&(e.cancelable&&e.preventDefault(),e.stopPropagation());c=setTimeout((()=>{n=0,r=0}),100),t(1*g,1*p)}),{capture:!1}),DP(e,"touchend",(function(e){a=!1,s=i=0,c&&clearTimeout(c);n*=1.2,r*=1.2,requestAnimationFrame(h)}),{capture:!1})}function qP(e){function t(e,t){return e*(0===t?1:ie)}return o=>{const s=t(o.shiftKey&&!my()?o.deltaY:o.deltaX,o.deltaMode),i=t(o.shiftKey&&!my()?o.deltaX:o.deltaY,o.deltaMode);e(s,i)}}mh`
|
|
1015
|
+
`;class zP extends t.Component{static props={onOpenContextMenu:Function};static template="o-spreadsheet-HeadersOverlay";static components={ColResizer:UP,RowResizer:BP};selectAll(){this.env.model.selection.selectAll()}}class $P extends hh{fingerprints;hoveredTables;hoveredIcon;lastRenderBoxes=new Map;preventNewAnimationsInNextFrame=!1;zonesWithPreventedAnimationsInNextFrame=[];animations=new Map;constructor(e){super(e),this.getters=e(ah).getters,this.fingerprints=e(ND),this.hoveredTables=e(FP),this.hoveredIcon=e(PP)}handle(e){switch(e.type){case"START":case"ACTIVATE_SHEET":case"ADD_COLUMNS_ROWS":case"REMOVE_COLUMNS_ROWS":this.animations.clear(),this.preventNewAnimationsInNextFrame=!0;break;case"RESIZE_COLUMNS_ROWS":this.preventNewAnimationsInNextFrame=!0;break;case"REDO":this.zonesWithPreventedAnimationsInNextFrame=[];break;case"UNDO":for(const t of e.commands)if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type||"RESIZE_COLUMNS_ROWS"===t.type){this.animations.clear(),this.preventNewAnimationsInNextFrame=!0;break}break;case"PASTE":this.zonesWithPreventedAnimationsInNextFrame.push(...this.getters.getSelectedZones());break;case"UPDATE_CELL":const t=this.getters.getCommandZones(e);this.zonesWithPreventedAnimationsInNextFrame.push(...t)}}get renderingLayers(){return["Background","Headers"]}drawLayer(e,t,o){switch(t){case"Background":this.drawGlobalBackground(e);const t=this.lastRenderBoxes;this.lastRenderBoxes=new Map;for(const{zone:s,rect:i}of this.getters.getAllActiveViewportsZonesAndRect()){const{ctx:n}=e;n.save(),n.beginPath(),n.rect(i.x,i.y,i.width,i.height),n.clip();const r=this.getGridBoxes(s),a=this.getBoxesWithAnimations(r,t,o);this.drawBackground(e,a),this.drawOverflowingCellBackground(e,a),this.drawCellBackground(e,a),this.drawBorders(e,a),this.drawTexts(e,a),this.drawIcon(e,a),n.restore()}this.drawFrozenPanes(e),this.preventNewAnimationsInNextFrame=!1,this.zonesWithPreventedAnimationsInNextFrame=[];break;case"Headers":this.getters.isDashboard()||(this.drawHeaders(e),this.drawFrozenPanesHeaders(e))}}drawGlobalBackground(e){const{ctx:t}=e,{width:o,height:s}=this.getters.getSheetViewDimensionWithHeaders();t.fillStyle="#ffffff",t.fillRect(0,0,o+r,s+r)}drawBackground(e,t){const{ctx:o,thinLineWidth:s}=e,i=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId()),n=i?.1*s:0;if(i)for(const e of t)e.skipCellGridLines||(o.strokeStyle="#E2E3E3",o.lineWidth=s,o.strokeRect(e.x+n,e.y+n,e.width-2*n,e.height-2*n))}drawCellBackground(e,t){const{ctx:o}=e;for(const e of t){const t=e.style;if(t.fillColor&&"#ffffff"!==t.fillColor&&(o.fillStyle=t.fillColor||"#ffffff",o.fillRect(e.x,e.y,e.width,e.height)),e.dataBarFill){o.fillStyle=e.dataBarFill.color;const t=e.dataBarFill.percentage,s=e.width*(t/100);o.fillRect(e.x,e.y,s,e.height)}if(e?.chip){o.save(),o.beginPath(),o.rect(e.x,e.y,e.width,e.height),o.clip();const t=e.chip;o.fillStyle=t.color;const s=10;o.beginPath(),o.roundRect(t.x,t.y,t.width,t.height,s),o.fill(),o.restore()}e.overlayColor&&(o.fillStyle=e.overlayColor,o.fillRect(e.x,e.y,e.width,e.height)),e.isError&&(o.fillStyle="red",o.beginPath(),o.moveTo(e.x+e.width-5,e.y),o.lineTo(e.x+e.width,e.y),o.lineTo(e.x+e.width,e.y+5),o.fill())}}drawOverflowingCellBackground(e,t){const{ctx:o,thinLineWidth:s}=e;for(const e of t)if(e.content&&e.isOverflow){const t=e.content.align||"left";let i,n;const r=e.y+s/2,a=e.height-s,l=Math.min(e.clipRect?.width||1/0,e.content.width);"left"===t?(i=e.x+s/2,n=l-2*s):"right"===t?(i=e.x+e.width-s/2,n=2*s-l):(i=(e.clipRect?.x||e.x+e.width/2-e.content.width/2)+s/2,n=l-2*s),o.fillStyle="#ffffff",o.fillRect(i,r,n,a)}}drawBorders(e,t){const{ctx:o}=e;for(const e of t){const t=e.border;if(t){const{x:o,y:i,width:n,height:r}=e;t.left&&s(t.left,o,i,o,i+r),t.top&&s(t.top,o,i,o+n,i),t.right&&s(t.right,o+n,i,o+n,i+r),t.bottom&&s(t.bottom,o,i+r,o+n,i+r)}}function s({color:e,style:t,opacity:s},i,n,r,a){switch(o.globalAlpha=s??1,o.strokeStyle=e,t){case"medium":o.lineWidth=2,n+=(i+=n===a?-.5:.5)===(r+=n===a?1.5:.5)?-.5:.5,a+=i===r?1.5:.5;break;case"thick":o.lineWidth=3,n===a&&(i--,r++),i===r&&(n--,a++);break;case"dashed":o.lineWidth=1,o.setLineDash([1,3]);break;case"dotted":o.lineWidth=1,n===a&&(i+=.5,r+=.5),i===r&&(n+=.5,a+=.5),o.setLineDash([1,1]);break;default:o.lineWidth=1}o.beginPath(),o.moveTo(i,n),o.lineTo(r,a),o.stroke(),o.lineWidth=1,o.setLineDash([]),o.globalAlpha=1}}drawTexts(e,t){const{ctx:o}=e;let s;o.textBaseline="top";for(const e of t)if(e.content){o.globalAlpha=e.textOpacity??1;const t=e.style||{},i=e.content.align||"left",n=ka(t);if(n!==s&&(s=n,o.font=n),o.fillStyle=t.textColor||"#000",o.textAlign=i,e.clipRect){o.save(),o.beginPath();const{x:t,y:s,width:i,height:n}=e.clipRect;o.rect(t,s,i,n),o.clip()}const r=e.content.x;let a=e.content.y;for(const s of e.content.textLines)$a(o,s,{x:r,y:a},t.underline,t.strikethrough),a+=re+e.content.fontSizePx;e.clipRect&&o.restore(),o.globalAlpha=1}}drawIcon(e,t){const{ctx:o}=e;for(const e of t)for(const t of Object.values(e.icons)){if(!t)continue;const s=mt({id:t.type,position:t.position},this.hoveredIcon.hoveredIcon)&&t.hoverSvg||t.svg;if(!s)continue;o.save(),o.beginPath();const i=t.clipRect||e;o.rect(i.x,i.y,i.width,i.height),o.clip();const n=t.size,{x:r,y:a}=this.getters.getCellIconRect(t,e);o.translate(r,a),o.scale(n/s.width,n/s.height);for(const e of s.paths)o.fillStyle=e.fillColor,o.fill(ZR(e.path));o.restore()}}drawHeaders(e){const{ctx:t,thinLineWidth:o}=e,s=this.getters.getSheetViewVisibleCols(),i=s[0],n=this.getters.getSheetViewVisibleRows(),r=n[0],{width:a,height:l}=this.getters.getSheetViewDimensionWithHeaders(),g=this.getters.getSelectedZones(),p=function(e){const t=new Set;for(const o of er(e))for(const e of je(o.left,o.right+1))t.add(e);return t}(g),m=function(e){const t=new Set;for(const o of er(e))for(const e of je(o.top,o.bottom+1))t.add(e);return t}(g),f=this.getters.getActiveSheetId(),v=this.getters.getNumberCols(f),b=this.getters.getNumberRows(f),S=this.getters.getActiveCols(),C=this.getters.getActiveRows();t.font=`400 11px ${fe}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=o,t.strokeStyle="#333";for(const e of s){const o={left:e,right:e,top:0,bottom:b-1},{x:s,width:i}=this.getters.getVisibleRect(o),n=S.has(e),r=p.has(e);t.fillStyle=n?d:r?h:c,t.fillRect(s,0,i,te)}for(const e of n){const o={top:e,bottom:e,left:0,right:v-1},{y:s,height:i}=this.getters.getVisibleRect(o),n=C.has(e),r=m.has(e);t.fillStyle=n?d:r?h:c,t.fillRect(0,s,oe,i)}t.beginPath(),t.moveTo(oe,0),t.lineTo(oe,l),t.moveTo(0,te),t.lineTo(a,te),t.strokeStyle="#C0C0C0",t.stroke();for(const e of s){const o=Co(e);t.fillStyle=S.has(e)?"#fff":u;const s={left:e,right:e,top:r,bottom:r},{x:i,width:n}=this.getters.getRect(s),{x:a,width:l}=this.getters.getVisibleRect(s);t.save(),t.beginPath(),t.rect(a,0,l,te),t.clip(),t.fillText(o,i+n/2,13),t.restore(),t.beginPath(),t.moveTo(i+n,0),t.lineTo(i+n,te),t.stroke()}for(const e of n){t.fillStyle=C.has(e)?"#fff":u;const o={top:e,bottom:e,left:i,right:i},{y:s,height:n}=this.getters.getRect(o),{y:r,height:a}=this.getters.getVisibleRect(o);t.save(),t.beginPath(),t.rect(0,r,oe,a),t.clip(),t.fillText(String(e+1),24,s+n/2),t.restore(),t.beginPath(),t.moveTo(0,s+n),t.lineTo(oe,s+n),t.stroke()}}drawFrozenPanesHeaders(e){const{ctx:t,thinLineWidth:o}=e,{x:s,y:i}=this.getters.getMainViewportCoordinates(),n=this.getters.isDashboard()?0:oe,r=this.getters.isDashboard()?0:te;t.lineWidth=6*o,t.strokeStyle=x,t.beginPath(),s&&(t.moveTo(n+s,0),t.lineTo(n+s,r)),i&&(t.moveTo(0,r+i),t.lineTo(n,r+i)),t.stroke()}drawFrozenPanes(e){const{ctx:t,thinLineWidth:o}=e,{x:s,y:i}=this.getters.getMainViewportCoordinates(),n=this.getters.getSheetViewVisibleCols(),r=n[0],a=n[n.length-1],l=this.getters.getSheetViewVisibleRows(),c={left:r,right:a,top:l[0],bottom:l[l.length-1]},h=this.getters.getVisibleRect(c),d=this.getters.isDashboard()?0:oe,u=this.getters.isDashboard()?0:te;t.lineWidth=6*o,t.strokeStyle="#DADFE8",t.beginPath(),s&&(t.moveTo(d+s,u),t.lineTo(d+s,h.height+u)),i&&(t.moveTo(d,u+i),t.lineTo(h.width+d,u+i)),t.stroke()}findNextEmptyCol(e,t,o){const s=this.getters.getActiveSheetId();let i=e;for(;i<t;){const e={sheetId:s,col:i+1,row:o},t=this.getters.getEvaluatedCell(e),n=this.getters.getCellComputedBorder(e),r=this.getters.doesCellHaveGridIcon(e);if(t.type!==Ts.empty||this.getters.isInMerge(e)||n?.left||r)return i;i++}return i}findPreviousEmptyCol(e,t,o){const s=this.getters.getActiveSheetId();let i=e;for(;i>t;){const e={sheetId:s,col:i-1,row:o},t=this.getters.getEvaluatedCell(e),n=this.getters.getCellComputedBorder(e),r=this.getters.doesCellHaveGridIcon(e);if(t.type!==Ts.empty||this.getters.isInMerge(e)||n?.right||r)return i;i--}return i}computeCellAlignment(e,t){const o=this.getters.getCell(e);if(o?.isFormula&&this.getters.shouldShowFormulas())return"left";const{align:s}=this.getters.getCellStyle(e),i=this.getters.getEvaluatedCell(e);return t&&i.type===Ts.number?"center"!==s?"left":s:s||i.defaultAlign}createZoneBox(e,t,o){const{left:s,right:i}=o,n=t.left,r=t.top,a={sheetId:e,col:n,row:r},l=this.getters.getEvaluatedCell(a),c=this.getters.shouldShowFormulas(),{x:h,y:d,width:u,height:g}=this.getters.getRect(t),p=this.getters.getDataValidationChipStyle(a);let m=this.getters.getCellComputedStyle(a);if(this.fingerprints.isEnabled){const e=this.fingerprints.colors.get(a);m={...m,fillColor:e}}p?.textColor&&(m={...m,textColor:p.textColor});const f=this.fingerprints.isEnabled?void 0:this.getters.getConditionalDataBar(a),v=this.getters.getCellIcons(a),b={left:v.find((e=>"left"===e?.horizontalAlign)),right:v.find((e=>"right"===e?.horizontalAlign)),center:v.find((e=>"center"===e?.horizontalAlign))},S={id:dr(t),x:h,y:d,width:u,height:g,border:this.getters.getCellComputedBorder(a)||void 0,style:m,dataBarFill:f,overlayColor:this.hoveredTables.overlayColors.get(a),isError:l.type===Ts.error&&!!l.message||this.getters.isDataValidationInvalid(a),icons:b,disabledAnimation:this.zonesWithPreventedAnimationsInNextFrame.some((e=>yr(t,e)||Sr(t,e)))},C=Va(S.style);if(l.type===Ts.empty||S.icons.center)return S;const y=m.wrapping||"overflow",w="wrap"===y&&!c,I=u-2*re,x=this.getters.getCellMultiLineText(a,{maxWidth:I,wrapText:w}),E=Math.max(...x.map((e=>this.getters.getTextWidth(e,m)+re))),R=p?5:0,T=(S.icons.left?S.icons.left.size+S.icons.left.margin:0)+R,A=(S.icons.right?S.icons.right.size+S.icons.right.margin:0)+R,D=T+E+A,_=this.computeCellAlignment(a,D>u),O=x.length,F=Math.round(this.getters.computeTextYCoordinate(S,C,m.verticalAlign,O));let P=S.x;P+="left"===_?re+T:"right"===_?S.width-re-A:S.width/2,P=Math.round(P);const M=Ta(C,O);if(S.content={textLines:x,width:"overflow"===y?E:u,align:_,x:P,y:F,fontSizePx:C},p?.fillColor){const e=T,t=5;S.chip={color:p.fillColor,width:S.width-e-t,height:M+2,x:S.x+e,y:F-2}}const N=D>u||C>g;if(S.icons.left||S.icons.right||S.chip)S.clipRect={x:S.x+T,y:S.y,width:Math.max(0,u-T-A),height:g};else if(N&&"overflow"===y){let e,o;switch(this.getters.isInMerge(a)?(e=this.getters.getMerge(a).right,o=n):(e=S.border?.right?t.right:this.findNextEmptyCol(n,i,r),o=S.border?.left?t.left:this.findPreviousEmptyCol(n,s,r),S.isOverflow=!0),_){case"left":{const o=Dr({col:e,row:r}),{x:s,y:i,width:n,height:a}=this.getters.getVisibleRect(fr(t,o));(n<D||C>a||x.length>1)&&(S.clipRect={x:s,y:i,width:n,height:a});break}case"right":{const e=Dr({col:o,row:r}),{x:s,y:i,width:n,height:a}=this.getters.getVisibleRect(fr(t,e));(n<D||C>a||x.length>1)&&(S.clipRect={x:s,y:i,width:n,height:a});break}case"center":{const s={...t,left:o,right:e},{x:i,y:n,height:r,width:a}=this.getters.getVisibleRect(s),l=D/2,c=S.x+S.width/2;if(i+a<c+l||i>c-l||C>r||x.length>1){const e=i>c-l?i:c-l,t=i+a-e;S.clipRect={x:e,y:n,width:t,height:r}}break}}}else("clip"===y||"wrap"===y||x.length>1)&&(S.clipRect={x:S.x,y:S.y,width:u,height:g});return S}getGridBoxes(e){const t=[],o=this.getters.getSheetViewVisibleCols().filter((t=>t>=e.left&&t<=e.right)),s=o[0],i=o[o.length-1],n=this.getters.getSheetViewVisibleRows().filter((t=>t>=e.top&&t<=e.bottom)),r={left:s,right:i,top:n[0],bottom:n[n.length-1]},a=this.getters.getActiveSheetId();for(const e of n)for(const s of o){const o={sheetId:a,col:s,row:e};this.getters.isInMerge(o)||t.push(this.createZoneBox(a,Dr(o),r))}for(const e of this.getters.getMerges(a))if(!this.getters.isMergeHidden(a,e)&&Sr(e,r)){const o=this.createZoneBox(a,e,r),s=this.getters.getCellComputedBorder({sheetId:a,col:e.right,row:e.bottom});o.border={...o.border,bottom:s?s.bottom:void 0,right:s?s.right:void 0},o.isMerge=!0,t.push(o)}return t}getBoxesWithAnimations(e,t,o){return this.updateAnimationsProgress(o),this.addNewAnimations(e,t,o),this.animations.size>0?(this.renderer.startAnimation("grid_renderer_animation"),this.updateBoxesWithAnimations(e)):(this.renderer.stopAnimation("grid_renderer_animation"),e)}updateBoxesWithAnimations(e){const t=[];for(const o of e){const e=this.animations.get(o.id);if(!e){t.push(o);continue}const s=ze(o);t.push(s);for(const i of e.animationTypes){const n=CI.get(i).updateAnimation(e.progress,s,e.oldBox,o);n&&t.push(...n.newBoxes)}}return t}updateAnimationsProgress(e){if(void 0!==e)for(const t of this.animations.keys()){const o=this.animations.get(t);if(void 0===o.startTime){o.startTime=e;continue}const s=e-o.startTime,i=Math.min(1,s/200);i>=1&&this.animations.delete(t),o.progress=i}}addNewAnimations(e,t,o){for(const s of e){this.lastRenderBoxes.set(s.id,s);const e=t.get(s.id);if(this.preventNewAnimationsInNextFrame||!e||s.disabledAnimation)continue;const i=[];for(const t of CI.getAll())t.hasAnimation(e,s)&&i.push(t.id);const n=i.length>0?{animationTypes:i,oldBox:e,progress:0,startTime:o}:void 0;n&&this.animations.set(s.id,n)}}}function GP(e,o,s){const i=t.useRef(e);t.useEffect((function(){const e=i.el,t=window.devicePixelRatio||1,o=e.getContext("2d",{alpha:!1}),r={ctx:o,dpr:t,thinLineWidth:.4*t},{width:a,height:l}=s();if(e.style.width=`${a}px`,e.style.height=`${l}px`,e.width=a*t,e.height=l*t,e.setAttribute("style",`width:${a}px;height:${l}px;`),0===a||0===l)return;o.translate(-.5,-.5),o.scale(t,t),n.draw(r)}));const n=oh(ch);oh($P)}function WP(e,t,o){let s=0,i=0,n=0,r=0,a=!1,l=0,c=null;function h(){if(Math.abs(n)<.05&&(n=0),Math.abs(r)<.05&&(r=0),!n&&!r)return;const e=Date.now(),o=Math.abs(e-l);t(1*(n*o),1*(r*o)),l=e,n*=.95,r*=.95,requestAnimationFrame(h)}DP(e,"touchstart",(function(e){a=!0,({clientX:s,clientY:i}=e.touches[0]),n=0,r=0}),{capture:!1}),DP(e,"touchmove",(function(e){if(!a)return;c&&(clearTimeout(c),c=null);const h=Date.now(),{clientX:d,clientY:u}=e.touches[0],g=s-d,p=i-u,m=h-l;if(!m)return;n=g/m,r=p/m,s=d,i=u,l=h,o()&&(e.cancelable&&e.preventDefault(),e.stopPropagation());c=setTimeout((()=>{n=0,r=0}),100),t(1*g,1*p)}),{capture:!1}),DP(e,"touchend",(function(e){a=!1,s=i=0,c&&clearTimeout(c);n*=1.2,r*=1.2,requestAnimationFrame(h)}),{capture:!1})}function qP(e){function t(e,t){return e*(0===t?1:ie)}return o=>{const s=t(o.shiftKey&&!my()?o.deltaY:o.deltaX,o.deltaMode),i=t(o.shiftKey&&!my()?o.deltaX:o.deltaY,o.deltaMode);e(s,i)}}mh`
|
|
1016
1016
|
.o-border {
|
|
1017
1017
|
position: absolute;
|
|
1018
1018
|
&:hover {
|
|
@@ -1517,7 +1517,7 @@
|
|
|
1517
1517
|
color: #6aa84f;
|
|
1518
1518
|
}
|
|
1519
1519
|
}
|
|
1520
|
-
`;class JM extends t.Component{static template="o-spreadsheet-ConditionalFormattingEditor";static props={editedCf:Object,onCancel:Function,onSave:Function};static components={SelectionInput:$E,IconPicker:ZM,ColorPickerWidget:aM,ConditionalFormatPreviewList:KM,Section:ME,RoundColorPicker:NE,StandaloneComposer:xE,BadgeSelection:nM,ValidationMessages:TP,SelectMenu:ZE};icons=GR;iconSets=WR;getTextDecoration=fh;colorNumberString=Bt;state;setup(){switch(this.state=t.useState({errors:[],currentCFType:this.props.editedCf.rule.type,ranges:this.props.editedCf.ranges,rules:this.getDefaultRules()}),this.props.editedCf.rule.type){case"CellIsRule":this.state.rules.cellIs=this.props.editedCf.rule;break;case"ColorScaleRule":this.state.rules.colorScale=this.props.editedCf.rule;break;case"IconSetRule":this.state.rules.iconSet=this.props.editedCf.rule;break;case"DataBarRule":this.state.rules.dataBar=this.props.editedCf.rule}t.useExternalListener(window,"click",this.closeMenus)}get isRangeValid(){return this.state.errors.includes("EmptyRange")}get errorMessages(){return this.state.errors.map((e=>zy.Errors[e]||zy.Errors.Unexpected))}get cfTypesValues(){return[{value:"CellIsRule",label:Vo("Single color")},{value:"ColorScaleRule",label:Vo("Color scale")},{value:"IconSetRule",label:Vo("Icon set")},{value:"DataBarRule",label:Vo("Data bar")}]}updateConditionalFormat(e){const t=e.ranges||this.state.ranges;if(this.state.ranges.some((e=>!e.match(Xr))))return e.suppressErrors||(this.state.errors=["InvalidRange"]),["InvalidRange"];const o=this.env.model.getters.getActiveSheetId(),s=this.env.model.getters.getLocale(),i=e.rule||this.getEditedRule(this.state.currentCFType),n=this.env.model.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{rule:Al(i,s),id:this.props.editedCf.id},ranges:t.map((e=>this.env.model.getters.getRangeDataFromXc(o,e))),sheetId:o}).reasons.filter((e=>"NoChanges"!==e));return e.suppressErrors||(this.state.errors=n),n}getEditedRule(e){switch(e){case"CellIsRule":return this.state.rules.cellIs;case"ColorScaleRule":return this.state.rules.colorScale;case"IconSetRule":return this.state.rules.iconSet;case"DataBarRule":return this.state.rules.dataBar}}onSave(){0===this.updateConditionalFormat({}).length&&this.props.onSave()}getDefaultRules(){return{cellIs:{type:"CellIsRule",operator:"isNotEmpty",values:[],style:{fillColor:"#b6d7a8"}},colorScale:{type:"ColorScaleRule",minimum:{type:"value",color:IT("EFF7FF")},midpoint:void 0,maximum:{type:"value",color:6989903}},iconSet:{type:"IconSetRule",icons:{upper:"arrowGood",middle:"arrowNeutral",lower:"arrowBad"},upperInflectionPoint:{type:"percentage",value:"66",operator:"gt"},lowerInflectionPoint:{type:"percentage",value:"33",operator:"gt"}},dataBar:{type:"DataBarRule",color:14281427}}}changeRuleType(e){this.state.currentCFType!==e&&(this.state.errors=[],this.state.currentCFType=e,this.updateConditionalFormat({rule:this.getEditedRule(e),suppressErrors:!0}))}onRangeUpdate(e){this.state.ranges=e}onRangeConfirmed(){this.updateConditionalFormat({ranges:this.state.ranges})}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}closeMenus(){this.state.openedMenu=void 0}get isValue1Invalid(){return this.state.errors.includes("FirstArgMissing")||this.state.errors.includes("ValueCellIsInvalidFormula")}get isValue2Invalid(){return this.state.errors.includes("SecondArgMissing")}toggleStyle(e){const t=this.state.rules.cellIs.style;t[e]=!t[e],this.updateConditionalFormat({rule:this.state.rules.cellIs}),this.closeMenus()}onKeydown(e){if("F4"===e.key){const t=e.target,o=mv({start:t.selectionStart??0,end:t.selectionEnd??0},t.value,this.env.model.getters.getLocale());if(!o)return;t.value=o.content,t.setSelectionRange(o.selection.start,o.selection.end),t.dispatchEvent(new Event("input"))}}setColor(e,t){this.state.rules.cellIs.style[e]=t,this.updateConditionalFormat({rule:this.state.rules.cellIs}),this.closeMenus()}editOperator(e){this.state.rules.cellIs.operator=e,this.updateConditionalFormat({rule:this.state.rules.cellIs,suppressErrors:!0}),this.closeMenus()}get cfCriterionMenuItems(){return qE((e=>this.editOperator(e)),Us)}get selectedCriterionName(){return Zx.get(this.state.rules.cellIs.operator).name}get criterionComponent(){return WE.get(this.state.rules.cellIs.operator).component}get genericCriterion(){return{type:this.state.rules.cellIs.operator,values:this.state.rules.cellIs.values}}onRuleValuesChanged(e){this.state.rules.cellIs.values=e.values,this.updateConditionalFormat({rule:{...this.state.rules.cellIs,values:e.values}})}isValueInvalid(e){switch(e){case"minimum":return this.state.errors.includes("MinInvalidFormula")||this.state.errors.includes("MinBiggerThanMid")||this.state.errors.includes("MinBiggerThanMax")||this.state.errors.includes("MinNaN");case"midpoint":return this.state.errors.includes("MidInvalidFormula")||this.state.errors.includes("MidNaN")||this.state.errors.includes("MidBiggerThanMax");case"maximum":return this.state.errors.includes("MaxInvalidFormula")||this.state.errors.includes("MaxNaN");default:return!1}}setColorScaleColor(e,t){if(!Gt(t))return;const o=this.state.rules.colorScale[e];o&&(o.color=zt(t)),this.updateConditionalFormat({rule:this.state.rules.colorScale}),this.closeMenus()}getPreviewGradient(){const e=this.state.rules.colorScale,t=Bt(e.minimum.color),o=Bt(e.midpoint?.color||v),s=Bt(e.maximum.color),i="background-image: linear-gradient(to right, ";return void 0===e.midpoint?i+t+", "+s+")":i+t+", "+o+", "+s+")"}getThresholdColor(e){return Bt(e?e.color:v)}onMidpointChange(e){const t=e.target.value,o=this.state.rules.colorScale;o.midpoint="none"===t?void 0:{color:v,value:"",...o.midpoint,type:t},this.updateConditionalFormat({rule:o,suppressErrors:!0})}updateThresholdType(e,t){this.state.rules.colorScale[e].type=t,this.updateConditionalFormat({rule:this.state.rules.colorScale,suppressErrors:!0})}updateThresholdValue(e,t){this.state.rules.colorScale[e].value=t,this.updateConditionalFormat({rule:this.state.rules.colorScale})}isInflectionPointInvalid(e){switch(e){case"lowerInflectionPoint":return this.state.errors.includes("ValueLowerInflectionNaN")||this.state.errors.includes("ValueLowerInvalidFormula")||this.state.errors.includes("LowerBiggerThanUpper");case"upperInflectionPoint":return this.state.errors.includes("ValueUpperInflectionNaN")||this.state.errors.includes("ValueUpperInvalidFormula")||this.state.errors.includes("LowerBiggerThanUpper");default:return!0}}reverseIcons(){const e=this.state.rules.iconSet.icons,t=e.upper;e.upper=e.lower,e.lower=t,this.updateConditionalFormat({rule:this.state.rules.iconSet})}setIconSet(e){const t=this.state.rules.iconSet.icons;t.upper=this.iconSets[e].good,t.middle=this.iconSets[e].neutral,t.lower=this.iconSets[e].bad,this.updateConditionalFormat({rule:this.state.rules.iconSet})}setIcon(e,t){this.state.rules.iconSet.icons[e]=t,this.updateConditionalFormat({rule:this.state.rules.iconSet})}setInflectionOperator(e,t){this.state.rules.iconSet[e].operator=t,this.updateConditionalFormat({rule:this.state.rules.iconSet})}setInflectionValue(e,t){this.state.rules.iconSet[e].value=t,this.updateConditionalFormat({rule:this.state.rules.iconSet})}setInflectionType(e,t,o){this.state.rules.iconSet[e].type=t,this.updateConditionalFormat({rule:this.state.rules.iconSet,suppressErrors:!0})}getColorScaleComposerProps(e){const t=this.state.rules.colorScale[e];if(!t)throw new Error("Threshold not found");const o=this.isValueInvalid(e);return{onConfirm:e=>{t.value=e,this.updateConditionalFormat({rule:this.state.rules.colorScale})},composerContent:t.value||"",placeholder:Vo("Formula"),defaultStatic:!0,invalid:o,class:"o-sidePanel-composer",defaultRangeSheetId:this.env.model.getters.getActiveSheetId()}}getColorIconSetComposerProps(e){const t=this.state.rules.iconSet[e],o=this.isInflectionPointInvalid(e);return{onConfirm:e=>{t.value=e,this.updateConditionalFormat({rule:this.state.rules.iconSet})},composerContent:t.value||"",placeholder:Vo("Formula"),defaultStatic:!0,invalid:o,class:"o-sidePanel-composer",defaultRangeSheetId:this.env.model.getters.getActiveSheetId()}}getRangeValues(){return[this.state.rules.dataBar.rangeValues||""]}updateDataBarColor(e){Gt(e)&&(this.state.rules.dataBar.color=Number.parseInt(e.slice(1),16),this.updateConditionalFormat({rule:this.state.rules.dataBar}))}onDataBarRangeUpdate(e){this.state.rules.dataBar.rangeValues=e[0]}onDataBarRangeChange(){this.updateConditionalFormat({rule:this.state.rules.dataBar})}}class QM extends t.Component{static template="o-spreadsheet-ConditionalFormattingPanel";static props={selection:{type:Object,optional:!0},onCloseSidePanel:Function};static components={ConditionalFormatPreviewList:KM,ConditionalFormattingEditor:JM,Section:ME};activeSheetId;originalEditedCf=void 0;state=t.useState({mode:"list"});setup(){this.activeSheetId=this.env.model.getters.getActiveSheetId();const e=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRulesSelection(e,this.props.selection||[]);if(1===o.length){const e=this.conditionalFormats.find((e=>e.id===o[0]));e&&this.editConditionalFormat(e)}t.onWillUpdateProps((e=>{const t=this.env.model.getters.getActiveSheetId();if(t!==this.activeSheetId)this.activeSheetId=t,this.switchToList();else if(e.selection!==this.props.selection){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRulesSelection(t,e.selection||[]);if(1===o.length){const e=this.conditionalFormats.find((e=>e.id===o[0]));e&&this.editConditionalFormat(e)}else this.switchToList()}else this.editedCF||this.switchToList()}))}get conditionalFormats(){return this.env.model.getters.getConditionalFormats(this.env.model.getters.getActiveSheetId()).map((e=>({...e,rule:Dl(e.rule,this.env.model.getters.getLocale())})))}switchToList(){this.state.mode="list",this.state.editedCfId=void 0,this.originalEditedCf=void 0}addConditionalFormat(){const e=this.env.model.uuidGenerator.smallUuid();this.env.model.dispatch("ADD_CONDITIONAL_FORMAT",{sheetId:this.activeSheetId,ranges:this.env.model.getters.getSelectedZones().map((e=>this.env.model.getters.getRangeDataFromZone(this.activeSheetId,e))),cf:{id:e,rule:{type:"CellIsRule",operator:"isNotEmpty",style:{fillColor:"#b6d7a8"},values:[]}}}),this.state.editedCfId=e,this.state.mode="edit",this.originalEditedCf=void 0}editConditionalFormat(e){this.state.mode="edit",this.state.editedCfId=e.id,this.originalEditedCf=e}cancelEdition(){this.originalEditedCf?this.env.model.dispatch("ADD_CONDITIONAL_FORMAT",{sheetId:this.activeSheetId,ranges:this.originalEditedCf.ranges.map((e=>this.env.model.getters.getRangeDataFromXc(this.activeSheetId,e))),cf:this.originalEditedCf}):this.state.editedCfId&&this.env.model.dispatch("REMOVE_CONDITIONAL_FORMAT",{sheetId:this.activeSheetId,id:this.state.editedCfId}),this.switchToList()}get editedCF(){return this.conditionalFormats.find((e=>e.id===this.state.editedCfId))}}const eN=new n;mh`
|
|
1520
|
+
`;class JM extends t.Component{static template="o-spreadsheet-ConditionalFormattingEditor";static props={editedCf:Object,onCancel:Function,onSave:Function};static components={SelectionInput:$E,IconPicker:ZM,ColorPickerWidget:aM,ConditionalFormatPreviewList:KM,Section:ME,RoundColorPicker:NE,StandaloneComposer:xE,BadgeSelection:nM,ValidationMessages:TP,SelectMenu:ZE};icons=GR;iconSets=WR;getTextDecoration=fh;colorNumberString=Bt;state;setup(){switch(this.state=t.useState({errors:[],currentCFType:this.props.editedCf.rule.type,ranges:this.props.editedCf.ranges,rules:this.getDefaultRules()}),this.props.editedCf.rule.type){case"CellIsRule":this.state.rules.cellIs=this.props.editedCf.rule;break;case"ColorScaleRule":this.state.rules.colorScale=this.props.editedCf.rule;break;case"IconSetRule":this.state.rules.iconSet=this.props.editedCf.rule;break;case"DataBarRule":this.state.rules.dataBar=this.props.editedCf.rule}t.useExternalListener(window,"click",this.closeMenus)}get isRangeValid(){return this.state.errors.includes("EmptyRange")}get errorMessages(){return this.state.errors.map((e=>zy.Errors[e]||zy.Errors.Unexpected))}get cfTypesValues(){return[{value:"CellIsRule",label:Vo("Single color")},{value:"ColorScaleRule",label:Vo("Color scale")},{value:"IconSetRule",label:Vo("Icon set")},{value:"DataBarRule",label:Vo("Data bar")}]}updateConditionalFormat(e){const t=e.ranges||this.state.ranges;if(this.state.ranges.some((e=>!e.match(Xr))))return e.suppressErrors||(this.state.errors=["InvalidRange"]),["InvalidRange"];const o=this.env.model.getters.getActiveSheetId(),s=this.env.model.getters.getLocale(),i=e.rule||this.getEditedRule(this.state.currentCFType),n=this.env.model.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{rule:Al(i,s),id:this.props.editedCf.id},ranges:t.map((e=>this.env.model.getters.getRangeDataFromXc(o,e))),sheetId:o}).reasons.filter((e=>"NoChanges"!==e));return e.suppressErrors||(this.state.errors=n),n}getEditedRule(e){switch(e){case"CellIsRule":return this.state.rules.cellIs;case"ColorScaleRule":return this.state.rules.colorScale;case"IconSetRule":return this.state.rules.iconSet;case"DataBarRule":return this.state.rules.dataBar}}onSave(){0===this.updateConditionalFormat({}).length&&this.props.onSave()}getDefaultRules(){return{cellIs:{type:"CellIsRule",operator:"isNotEmpty",values:[],style:{fillColor:"#b6d7a8"}},colorScale:{type:"ColorScaleRule",minimum:{type:"value",color:IT("EFF7FF")},midpoint:void 0,maximum:{type:"value",color:6989903}},iconSet:{type:"IconSetRule",icons:{upper:"arrowGood",middle:"arrowNeutral",lower:"arrowBad"},upperInflectionPoint:{type:"percentage",value:"66",operator:"gt"},lowerInflectionPoint:{type:"percentage",value:"33",operator:"gt"}},dataBar:{type:"DataBarRule",color:14281427}}}changeRuleType(e){this.state.currentCFType!==e&&(this.state.errors=[],this.state.currentCFType=e,this.updateConditionalFormat({rule:this.getEditedRule(e),suppressErrors:!0}))}onRangeUpdate(e){this.state.ranges=e}onRangeConfirmed(){this.updateConditionalFormat({ranges:this.state.ranges})}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}closeMenus(){this.state.openedMenu=void 0}get isValue1Invalid(){return this.state.errors.includes("FirstArgMissing")||this.state.errors.includes("ValueCellIsInvalidFormula")}get isValue2Invalid(){return this.state.errors.includes("SecondArgMissing")}toggleStyle(e){const t=this.state.rules.cellIs.style;t[e]=!t[e],this.updateConditionalFormat({rule:this.state.rules.cellIs}),this.closeMenus()}onKeydown(e){if("F4"===e.key){const t=e.target,o=mv({start:t.selectionStart??0,end:t.selectionEnd??0},t.value,this.env.model.getters.getLocale());if(!o)return;t.value=o.content,t.setSelectionRange(o.selection.start,o.selection.end),t.dispatchEvent(new Event("input"))}}setColor(e,t){this.state.rules.cellIs.style[e]=t,this.updateConditionalFormat({rule:this.state.rules.cellIs}),this.closeMenus()}editOperator(e){this.state.rules.cellIs.operator=e,this.updateConditionalFormat({rule:this.state.rules.cellIs,suppressErrors:!0}),this.closeMenus()}get cfCriterionMenuItems(){return qE((e=>this.editOperator(e)),Us)}get selectedCriterionName(){return Zx.get(this.state.rules.cellIs.operator).name}get criterionComponent(){return WE.get(this.state.rules.cellIs.operator).component}get genericCriterion(){return{type:this.state.rules.cellIs.operator,values:this.state.rules.cellIs.values}}onRuleValuesChanged(e){this.state.rules.cellIs.values=e.values,this.updateConditionalFormat({rule:{...this.state.rules.cellIs,values:e.values}})}isValueInvalid(e){switch(e){case"minimum":return this.state.errors.includes("MinInvalidFormula")||this.state.errors.includes("MinBiggerThanMid")||this.state.errors.includes("MinBiggerThanMax")||this.state.errors.includes("MinNaN");case"midpoint":return this.state.errors.includes("MidInvalidFormula")||this.state.errors.includes("MidNaN")||this.state.errors.includes("MidBiggerThanMax");case"maximum":return this.state.errors.includes("MaxInvalidFormula")||this.state.errors.includes("MaxNaN");default:return!1}}setColorScaleColor(e,t){if(!Gt(t))return;const o=this.state.rules.colorScale[e];o&&(o.color=zt(t)),this.updateConditionalFormat({rule:this.state.rules.colorScale}),this.closeMenus()}getPreviewGradient(){const e=this.state.rules.colorScale,t=Bt(e.minimum.color),o=Bt(e.midpoint?.color||v),s=Bt(e.maximum.color),i="background-image: linear-gradient(to right, ";return void 0===e.midpoint?i+t+", "+s+")":i+t+", "+o+", "+s+")"}getThresholdColor(e){return Bt(e?e.color:v)}onMidpointChange(e){const t=e.target.value,o=this.state.rules.colorScale;o.midpoint="none"===t?void 0:{color:v,value:"",...o.midpoint,type:t},this.updateConditionalFormat({rule:o,suppressErrors:!0})}updateThresholdType(e,t){this.state.rules.colorScale[e].type=t,this.updateConditionalFormat({rule:this.state.rules.colorScale,suppressErrors:!0})}updateThresholdValue(e,t){this.state.rules.colorScale[e].value=t,this.updateConditionalFormat({rule:this.state.rules.colorScale})}isInflectionPointInvalid(e){switch(e){case"lowerInflectionPoint":return this.state.errors.includes("ValueLowerInflectionNaN")||this.state.errors.includes("ValueLowerInvalidFormula")||this.state.errors.includes("LowerBiggerThanUpper");case"upperInflectionPoint":return this.state.errors.includes("ValueUpperInflectionNaN")||this.state.errors.includes("ValueUpperInvalidFormula")||this.state.errors.includes("LowerBiggerThanUpper");default:return!0}}reverseIcons(){const e=this.state.rules.iconSet.icons,t=e.upper;e.upper=e.lower,e.lower=t,this.updateConditionalFormat({rule:this.state.rules.iconSet})}setIconSet(e){const t=this.state.rules.iconSet.icons;t.upper=this.iconSets[e].good,t.middle=this.iconSets[e].neutral,t.lower=this.iconSets[e].bad,this.updateConditionalFormat({rule:this.state.rules.iconSet})}setIcon(e,t){this.state.rules.iconSet.icons[e]=t,this.updateConditionalFormat({rule:this.state.rules.iconSet})}setInflectionOperator(e,t){this.state.rules.iconSet[e].operator=t,this.updateConditionalFormat({rule:this.state.rules.iconSet})}setInflectionValue(e,t){this.state.rules.iconSet[e].value=t,this.updateConditionalFormat({rule:this.state.rules.iconSet})}setInflectionType(e,t,o){this.state.rules.iconSet[e].type=t,this.updateConditionalFormat({rule:this.state.rules.iconSet,suppressErrors:!0})}getColorScaleComposerProps(e){const t=this.state.rules.colorScale[e];if(!t)throw new Error("Threshold not found");const o=this.isValueInvalid(e);return{onConfirm:e=>{t.value=e,this.updateConditionalFormat({rule:this.state.rules.colorScale})},composerContent:t.value||"",placeholder:Vo("Formula"),defaultStatic:!0,invalid:o,class:"o-sidePanel-composer",defaultRangeSheetId:this.env.model.getters.getActiveSheetId()}}getColorIconSetComposerProps(e){const t=this.state.rules.iconSet[e],o=this.isInflectionPointInvalid(e);return{onConfirm:e=>{t.value=e,this.updateConditionalFormat({rule:this.state.rules.iconSet})},composerContent:t.value||"",placeholder:Vo("Formula"),defaultStatic:!0,invalid:o,class:"o-sidePanel-composer",defaultRangeSheetId:this.env.model.getters.getActiveSheetId()}}getRangeValues(){return[this.state.rules.dataBar.rangeValues||""]}updateDataBarColor(e){Gt(e)&&(this.state.rules.dataBar.color=Number.parseInt(e.slice(1),16),this.updateConditionalFormat({rule:this.state.rules.dataBar}))}onDataBarRangeUpdate(e){this.state.rules.dataBar.rangeValues=e[0]}onDataBarRangeChange(){this.updateConditionalFormat({rule:this.state.rules.dataBar})}}class QM extends t.Component{static template="o-spreadsheet-ConditionalFormattingPanel";static props={selection:{type:Object,optional:!0},onCloseSidePanel:Function};static components={ConditionalFormatPreviewList:KM,ConditionalFormattingEditor:JM,Section:ME};activeSheetId;originalEditedCf=void 0;state=t.useState({mode:"list"});setup(){this.activeSheetId=this.env.model.getters.getActiveSheetId();const e=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRulesSelection(e,this.props.selection||[]);if(1===o.length){const e=this.conditionalFormats.find((e=>e.id===o[0]));e&&this.editConditionalFormat(e)}t.onWillUpdateProps((e=>{const t=this.env.model.getters.getActiveSheetId();if(t!==this.activeSheetId)this.activeSheetId=t,this.switchToList();else if(e.selection!==this.props.selection){const t=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getRulesSelection(t,e.selection||[]);if(1===o.length){const e=this.conditionalFormats.find((e=>e.id===o[0]));e&&this.editConditionalFormat(e)}else this.switchToList()}}))}get conditionalFormats(){return this.env.model.getters.getConditionalFormats(this.env.model.getters.getActiveSheetId()).map((e=>({...e,rule:Dl(e.rule,this.env.model.getters.getLocale())})))}switchToList(){this.state.mode="list",this.state.editedCfId=void 0,this.originalEditedCf=void 0}addConditionalFormat(){const e=this.env.model.uuidGenerator.smallUuid();this.env.model.dispatch("ADD_CONDITIONAL_FORMAT",{sheetId:this.activeSheetId,ranges:this.env.model.getters.getSelectedZones().map((e=>this.env.model.getters.getRangeDataFromZone(this.activeSheetId,e))),cf:{id:e,rule:{type:"CellIsRule",operator:"isNotEmpty",style:{fillColor:"#b6d7a8"},values:[]}}}),this.state.editedCfId=e,this.state.mode="edit",this.originalEditedCf=void 0}editConditionalFormat(e){this.state.mode="edit",this.state.editedCfId=e.id,this.originalEditedCf=e}cancelEdition(){this.originalEditedCf?this.env.model.dispatch("ADD_CONDITIONAL_FORMAT",{sheetId:this.activeSheetId,ranges:this.originalEditedCf.ranges.map((e=>this.env.model.getters.getRangeDataFromXc(this.activeSheetId,e))),cf:this.originalEditedCf}):this.state.editedCfId&&this.env.model.dispatch("REMOVE_CONDITIONAL_FORMAT",{sheetId:this.activeSheetId,id:this.state.editedCfId}),this.switchToList()}get editedCF(){return this.conditionalFormats.find((e=>e.id===this.state.editedCfId))}}const eN=new n;mh`
|
|
1521
1521
|
.o-custom-currency {
|
|
1522
1522
|
.o-format-proposals {
|
|
1523
1523
|
color: black;
|
|
@@ -2582,7 +2582,7 @@
|
|
|
2582
2582
|
.o-spreadsheet-bottombar-wrapper {
|
|
2583
2583
|
z-index: ${Fe.ScrollBar+1};
|
|
2584
2584
|
}
|
|
2585
|
-
`;class lH extends t.Component{static template="o-spreadsheet-Spreadsheet";static props={model:Object,notifyUser:{type:Function,optional:!0},raiseError:{type:Function,optional:!0},askConfirmation:{type:Function,optional:!0}};static components={TopBar:rH,Grid:yk,BottomBar:kL,SmallBottomBar:qL,SidePanels:GL,SpreadsheetDashboard:LL,HeaderGroupContainer:zL,FullScreenChart:Ik};sidePanel;spreadsheetRef=t.useRef("spreadsheet");spreadsheetRect=Ax();_focusGrid;isViewportTooSmall=!1;notificationStore;composerFocusStore;get model(){return this.props.model}getStyle(){const e={};this.env.isDashboard()?e["grid-template-rows"]="auto":e["grid-template-rows"]="min-content auto min-content";const t=this.sidePanel.mainPanel?`${this.sidePanel.totalPanelSize||mk}px`:"auto";return e["grid-template-columns"]=`auto ${t}`,bh(e)}setup(){if(!("isSmall"in this.env)){const e=function(){const e=Ax();return{get isSmall(){return e.width<768}}}();t.useSubEnv({get isSmall(){return e.isSmall}})}const e=th();e.inject(ah,this.model);const o=this.env;e.get(pk).setSmallThreshhold((()=>o.isSmall)),this.notificationStore=oh(dE),this.composerFocusStore=oh(uh),this.sidePanel=oh(vk);const s=this.model.config.external.fileStore;t.useSubEnv({model:this.model,imageProvider:s?new AL(s):void 0,loadCurrencies:this.model.config.external.loadCurrencies,loadLocales:this.model.config.external.loadLocales,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.sidePanel.open.bind(this.sidePanel),toggleSidePanel:this.sidePanel.toggle.bind(this.sidePanel),clipboard:this.env.clipboard||new aH(navigator.clipboard),startCellEdition:e=>this.composerFocusStore.focusActiveComposer({content:e}),notifyUser:e=>this.notificationStore.notifyUser(e),askConfirmation:(e,t,o)=>this.notificationStore.askConfirmation(e,t,o),raiseError:(e,t)=>this.notificationStore.raiseError(e,t),isMobile:yy}),this.notificationStore.updateNotificationCallbacks({...this.props}),t.useEffect((()=>{!this.spreadsheetRef.el.contains(document.activeElement)&&document.activeElement?.contains(this.spreadsheetRef.el)&&this.focusGrid()}),(()=>[this.env.model.getters.getActiveSheetId()])),t.useExternalListener(window,"resize",(()=>this.render(!0))),t.useExternalListener(document.body,"wheel",(()=>{})),this.bindModelEvents(),t.onWillUpdateProps((e=>{if(e.model!==this.props.model)throw new Error("Changing the props model is not supported at the moment.");e.notifyUser===this.props.notifyUser&&e.askConfirmation===this.props.askConfirmation&&e.raiseError===this.props.raiseError||this.notificationStore.updateNotificationCallbacks({...e})}));const i=function(e){let t=!1;return async(...o)=>{t||(t=!0,await Promise.resolve(),t=!1,e(...o))}}(this.render.bind(this,!0));t.onMounted((()=>{this.checkViewportSize(),e.on("store-updated",this,i),n.observe(this.spreadsheetRef.el),Ch()})),t.onWillUnmount((()=>{this.unbindModelEvents(),e.off("store-updated",this),n.disconnect(),function(){if(window.Chart)for(const e of Sh.getAll())e.unregister(window.Chart)}()})),t.onPatched((()=>{this.checkViewportSize()}));const n=new ResizeObserver((()=>{this.sidePanel.changeSpreadsheetWidth(this.spreadsheetRect.width)}))}bindModelEvents(){this.model.on("update",this,(()=>this.render(!0))),this.model.on("notify-ui",this,(e=>this.notificationStore.notifyUser(e))),this.model.on("raise-error-ui",this,(({text:e})=>this.notificationStore.raiseError(e)))}unbindModelEvents(){this.model.off("update",this),this.model.off("notify-ui",this),this.model.off("raise-error-ui",this)}checkViewportSize(){const{xRatio:e,yRatio:t}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());if(isFinite(e)&&isFinite(t))if(t>.85||e>.85){if(this.isViewportTooSmall)return;this.notificationStore.notifyUser({text:Vo("The current window is too small to display this sheet properly. Consider resizing your browser window or adjusting frozen rows and columns."),type:"warning",sticky:!1}),this.isViewportTooSmall=!0}else this.isViewportTooSmall=!1}focusGrid(){this._focusGrid&&this._focusGrid()}get gridHeight(){return this.env.model.getters.getSheetViewDimension().height}get gridContainerStyle(){const e=ce*this.rowLayers.length,t=ce*this.colLayers.length;return bh({"grid-template-columns":`${e?e+2:0}px auto`,"grid-template-rows":`${t?t+2:0}px auto`})}get rowLayers(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getVisibleGroupLayers(e,"ROW")}get colLayers(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getVisibleGroupLayers(e,"COL")}getGridSize(){const e=this.spreadsheetRef.el?.querySelector(".o-spreadsheet-topbar-wrapper")?.getBoundingClientRect().height||0,t=this.spreadsheetRef.el?.querySelector(".o-spreadsheet-bottombar-wrapper")?.getBoundingClientRect().height||0,o=this.spreadsheetRef.el?.querySelector(".o-grid")?.getBoundingClientRect().width||0,s=(this.spreadsheetRef.el?.getBoundingClientRect().height||0)-(this.spreadsheetRef.el?.querySelector(".o-column-groups")?.getBoundingClientRect().height||0)-e-t;return{width:Math.max(o-ne,0),height:Math.max(s-ne,0)}}}function cH(e){return CL.get(e.type)(e)}class hH{buildTransformation;operations;constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){return this.operations[this.operations.length-1]?.id}getFirstOperationAmong(e,t){for(const o of this.operations){if(o.id===e)return e;if(o.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const o=this.buildTransformation.with(e.data),{before:s,operation:i,after:n}=this.locateOperation(t);this.operations=[...s,i,e,...n.map((e=>e.transformed(o)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new hH(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:o}=this.locateOperation(e);this.operations=t.concat([o])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class dH{id;data;constructor(e,t){this.id=e,this.data=t}transformed(e){return new uH(this.id,ut((()=>e(this.data))))}}class uH{id;lazyData;constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new uH(this.id,this.lazyData.map(e))}}class gH{operations;constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new gH(function*(e,t){for(const o of e)if(yield o,o.operation.id===t)return}(this.operations,e))}stopBefore(e){return new gH(function*(e,t){for(const o of e){if(o.operation.id===t)return;yield o}}(this.operations,e))}startAfter(e){return new gH(function*(e,t){let o=!0;for(const s of e)o||(yield s),s.operation.id===t&&(o=!1)}(this.operations,e))}}class pH{buildTransformation;branches;branchingOperationIds=new Map;constructor(e,t){this.buildTransformation=e,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new gH(Xe(this._execution(e),this._execution(e)))}revertedExecution(e){return new gH(Xe(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){const o=e.getLastOperationId()||this.previousBranch(e)?.getLastOperationId();e.append(t),o&&this.insertPrevious(e,t,o)}insertOperationAfter(e,t,o){e.insert(t,o),this.updateNextWith(e,t,o),this.insertPrevious(e,t,o)}undo(e,t){const o=this.buildTransformation.without(t.data),s=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const i=e.fork(t.id);s&&this.branchingOperationIds.set(i,s),this.insertBranchAfter(e,i),this.transform(i,o)}redo(e){const t=this.nextBranch(e);if(!t)return;const o=this.nextBranch(t);this.removeBranchFromTree(t);const s=this.branchingOperationIds.get(t);s?this.branchingOperationIds.set(e,s):this.branchingOperationIds.delete(e),o&&this.rebaseUp(o)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const o of this.revertedExecution(e))if(o.operation.id===t)return o;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:o}=this.findPreviousBranchingOperation(e);if(!t||!o)return;const s=this.buildTransformation.without(o.data),i=t.fork(o.id);this.branchingOperationIds.set(i,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,i),i.transform(s);const n=this.nextBranch(i);n&&this.rebaseUp(n)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const o=this.branches.findIndex((t=>t===e));this.branches.splice(o+1,0,t)}updateNextWith(e,t,o){const s=this.branchingOperationIds.get(e),i=this.nextBranch(e);if(s&&i)if(e.getFirstOperationAmong(o,s)===s){const n=this.addToNextBranch(e,i,s,t,o);this.updateNextWith(i,n,o)}else{const e=this.buildTransformation.with(t.data);this.transform(i,e)}}addToNextBranch(e,t,o,s,i){let n=s;return i===o?(n=this.getTransformedOperation(e,o,s),t.prepend(n)):t.contains(i)?(n=this.getTransformedOperation(e,o,s),t.insert(n,i)):t.append(s),n}getTransformedOperation(e,t,o){const s=e.getOperation(t),i=this.buildTransformation.without(s.data);return o.transformed(i)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const o=this.nextBranch(e);o&&this.transform(o,t)}insertPrevious(e,t,o){const{previousBranch:s,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!s||!i)return;const n=this.buildTransformation.with(i.data),r=e.fork(o);r.transform(n),s.cutAfter(o),s.appendBranch(r);const a=t.transformed(n);this.insertPrevious(s,a,o)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const o=this.branchingOperationIds.get(t);return o?{previousBranch:t,branchingOperation:t.getOperation(o)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let o=!!t;const s=e.getOperations();for(let i=s.length-1;i>=0;i--){const n=s[i];n.id===t&&(o=!1),o||(yield{operation:n,branch:e,isCancelled:!this.shouldExecute(e,n)})}const i=this.previousBranch(e);yield*i?this._revertedExecution(i):[]}*_execution(e){for(const t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){const t=this.nextBranch(e);return void(yield*t?this._execution(t):[])}if(!this.branchingOperationIds.get(e)){const t=this.nextBranch(e);yield*t?this._execution(t):[]}}}class mH{HEAD_BRANCH;HEAD_OPERATION;tree;applyOperation;revertOperation;buildEmpty;buildTransformation;constructor(e){this.applyOperation=e.applyOperation,this.revertOperation=e.revertOperation,this.buildEmpty=e.buildEmpty,this.buildTransformation=e.buildTransformation,this.HEAD_BRANCH=new hH(this.buildTransformation),this.tree=new pH(this.buildTransformation,this.HEAD_BRANCH);const t=e.initialOperationId,o=new dH(t,this.buildEmpty(t));this.tree.insertOperationLast(this.HEAD_BRANCH,o),this.HEAD_OPERATION=o}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const o=new dH(e,t),s=this.tree.getLastBranch();this.tree.insertOperationLast(s,o),this.HEAD_BRANCH=s,this.HEAD_OPERATION=o}insert(e,t,o){const s=new dH(e,t);this.revertTo(o),this.tree.insertOperationAfter(this.HEAD_BRANCH,s,o),this.fastForward()}undo(e,t,o){const{branch:s,operation:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(s,i),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}redo(e,t,o){const{branch:s}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(s),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}rebase(e){const t=this.get(e),o=[...this.tree.execution(this.HEAD_BRANCH).startAfter(e)];this.revertBefore(e);const s=this.HEAD_OPERATION.id;this.tree.drop(e),this.insert(e,t,s);for(const{operation:e}of o)this.insert(e.id,e.data,this.HEAD_OPERATION.id)}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:o,isCancelled:s}of e)s||this.revertOperation(o.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:o,isCancelled:s}of e)s||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=o}}function fH(e){return new mH({initialOperationId:e.initialRevisionId,applyOperation:t=>{const o=t.commands.slice(),{changes:s}=e.recordChanges((()=>{for(const t of o)e.dispatch(t)}));t.setChanges(s)},revertOperation:e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){vH(t.changes[e])}}([e]),buildEmpty:e=>new ZV(e,"empty",[]),buildTransformation:{with:e=>t=>new ZV(t.id,t.clientId,WV(t.commands,e.commands),t.rootCommand,void 0,t.timestamp),without:e=>t=>new ZV(t.id,t.clientId,WV(t.commands,e.commands.map(cH).flat()),t.rootCommand,void 0,t.timestamp)}})}function vH(e){const t=e.target,o=e.key,s=e.before;void 0===s?delete t[o]:t[o]=s}class bH{observers=new Map;defaultSubscription;mainSubscription;registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||(this.mainSubscription=this.defaultSubscription)}observe(e,t){this.observers.set(e,{owner:e,callbacks:t})}capture(e,t){if(this.observers.get(e))throw new Error("You are already subscribed forever");this.mainSubscription?.owner&&this.mainSubscription.owner!==e&&this.mainSubscription.callbacks.release?.(),this.mainSubscription={owner:e,callbacks:t}}release(e){this.mainSubscription?.owner!==e||this.observers.get(e)||(this.mainSubscription=this.defaultSubscription)}getBackToDefault(){this.mainSubscription!==this.defaultSubscription&&(this.mainSubscription?.callbacks.release?.(),this.mainSubscription=this.defaultSubscription)}isListening(e){return this.mainSubscription?.owner===e}send(e){this.mainSubscription?.callbacks.handleEvent(e),this.observers.forEach((t=>t.callbacks.handleEvent(e)))}}class SH{getters;stream;anchor;defaultAnchor;constructor(e){this.getters=e,this.stream=new bH,this.anchor={cell:{col:0,row:0},zone:Dr({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,o){this.stream.capture(e,o),this.anchor=t}registerAsDefault(e,t,o){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,o),this.defaultAnchor=t,this.capture(e,t,o)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}modifyAnchor(e,t,o){const s=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(s,e.zone)},this.processEvent({options:o,anchor:e,mode:t})}selectZone(e,t={scrollIntoView:!0}){return this.modifyAnchor(e,"overrideSelection",t)}selectCell(e,t){const o=Dr({col:e,row:t});return this.selectZone({zone:o,cell:{col:e,row:t}},{scrollIntoView:!0})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new Vs("InvalidSelectionStep");const{col:o,row:s}=this.getNextAvailablePosition(e,t);return this.selectCell(o,s)}setAnchorCorner(e,t){const o=this.getters.getActiveSheetId(),{col:s,row:i}=this.anchor.cell,n={left:Math.min(s,e),top:Math.min(i,t),right:Math.max(s,e),bottom:Math.max(i,t)},r={zone:this.getters.expandZone(o,n),cell:{col:s,row:i}};return this.processEvent({mode:"updateAnchor",anchor:r,options:{scrollIntoView:!1}})}addCellToSelection(e,t){const o=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:o,col:e,row:t}));const s=this.getters.expandZone(o,Dr({col:e,row:t}));return this.processEvent({options:{scrollIntoView:!0},anchor:{zone:s,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new Vs("InvalidSelectionStep");const o=this.getters.getActiveSheetId(),s=this.anchor,{col:i,row:n}=s.cell,{left:r,right:a,top:l,bottom:c}=s.zone,h=this.getStartingPosition(e),[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return Vs.Success;let g=s.zone;const p=e=>{e=Rr(e);const{left:t,right:s,top:i,bottom:n}=this.getters.expandZone(o,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(o)-1,s),top:Math.max(0,i),bottom:Math.min(this.getters.getNumberRows(o)-1,n)}},{cell:m,zone:f}=this.getReferenceAnchor(),{col:v,row:b}=m;let S=0;for(;null!==g;){if(S++,d<0){const e=this.getNextAvailableCol(d,a-(S-1),b);g=f.right<=a-S?p({top:l,left:r,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,r+(S-1),b);g=r+S<=f.left?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,v,c-(S-1));g=f.bottom<=c-S?p({top:l,left:r,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,v,l+(S-1));g=l+S<=f.top?p({top:e,left:r,bottom:c,right:a}):null}if(g=g?Rr(g):g,g&&!br(g,s.zone))return this.processEvent({options:{scrollIntoView:!0},mode:"updateAnchor",anchor:{zone:g,cell:{col:i,row:n}}})}g=p(fr({top:n,bottom:n,left:i,right:i},Rr({top:this.getNextAvailableRow(u,v,l),left:this.getNextAvailableCol(d,r,b),bottom:this.getNextAvailableRow(u,v,c),right:this.getNextAvailableCol(d,a,b)})));const C={zone:g,cell:{col:i,row:n}};return this.processEvent({anchor:C,mode:"updateAnchor",options:{scrollIntoView:!0}})}selectColumn(e,t){const o=this.getters.getActiveSheetId(),s=this.getters.getNumberRows(o)-1;let i={left:e,right:e,top:0,bottom:s};const n=this.getters.findFirstVisibleColRowIndex(o,"ROW");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=e,a=n;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),i=fr(i,{left:r,right:r,top:n,bottom:s})}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:i,cell:{col:r,row:a}},mode:t})}selectRow(e,t){const o=this.getters.getActiveSheetId(),s=this.getters.getNumberCols(o)-1;let i={top:e,bottom:e,left:0,right:s};const n=this.getters.findFirstVisibleColRowIndex(o,"COL");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=n,a=e;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),i=fr(i,{left:n,right:s,top:a,bottom:a})}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:i,cell:{col:r,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor;if(br(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:Dr(t.cell)},"updateAnchor",{scrollIntoView:!1});const o=this.getters.getContiguousZone(e,t.zone);return mt(o,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:o},"updateAnchor",{scrollIntoView:!1})}selectTableAroundSelection(){const e=this.getters.getActiveSheetId(),t=this.getters.getContiguousZone(e,this.anchor.zone);return this.modifyAnchor({...this.anchor,zone:t},"updateAnchor",{scrollIntoView:!1})}selectAll(){const e=this.getters.getActiveSheetId(),t={left:0,top:0,bottom:this.getters.getNumberRows(e)-1,right:this.getters.getNumberCols(e)-1};return this.processEvent({mode:"overrideSelection",anchor:{zone:t,cell:this.anchor.cell},options:{scrollIntoView:!1}})}isListening(e){return this.stream.isListening(e)}processEvent(e){const t={...e,previousAnchor:ze(this.anchor)},o=this.checkEventAnchorZone(t);return"Success"!==o?new Vs(o):(this.anchor=t.anchor,this.stream.send(t),Vs.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:o}=e;if(!Cr(t.col,t.row,o))return"InvalidAnchorZone";const{left:s,right:i,top:n,bottom:r}=o,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",s,i);return void 0===this.getters.findVisibleHeader(a,"ROW",n,r)||void 0===l?"SelectionOutOfBound":"Success"}checkAnchorZoneOrThrow(e){if("InvalidAnchorZone"===this.checkAnchorZone(e))throw new Error("The provided anchor is invalid. The cell must be part of the zone.")}getNextAvailablePosition(e,t=1){const{col:o,row:s}=this.anchor.cell,i=this.deltaToTarget({col:o,row:s},e,t);return{col:this.getNextAvailableCol(i[0],o,s),row:this.getNextAvailableRow(i[1],o,s)}}getNextAvailableCol(e,t,o){const s=this.getters.getActiveSheetId(),i={col:t,row:o};return this.getNextAvailableHeader(e,"COL",t,i,(e=>this.getters.isInSameMerge(s,t,o,e,o)))}getNextAvailableRow(e,t,o){const s=this.getters.getActiveSheetId(),i={col:t,row:o};return this.getNextAvailableHeader(e,"ROW",o,i,(e=>this.getters.isInSameMerge(s,t,o,t,e)))}getNextAvailableHeader(e,t,o,s,i){const n=this.getters.getActiveSheetId();if(0===e)return o;const r=Math.sign(e);let a=o+e;for(;i(a);)a+=r;for(;this.getters.isHeaderHidden(n,t,a);)a+=r;return a<0||a>this.getters.getNumberHeaders(n,t)-1?this.getters.isHeaderHidden(n,t,o)?this.getNextAvailableHeader(-r,t,o,s,i):o:a}getReferenceAnchor(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:o,right:s,top:i,bottom:n}=t.zone,{col:r,row:a}=t.cell,l=this.getters.isColHidden(e,r)&&this.getters.findVisibleHeader(e,"COL",o,s)||r,c=this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",i,n)||a;return{cell:{col:l,row:c},zone:this.getters.expandZone(e,{left:l,right:l,top:c,bottom:c})}}deltaToTarget(e,t,o){switch(t){case"up":return"end"!==o?[0,-o]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==o?[0,o]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==o?[-o,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==o?[o,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:o}=this.getPosition();const s=this.anchor.zone;switch(e){case"down":case"up":o=o===s.top?s.bottom:s.top;break;case"left":case"right":t=t===s.right?s.left:s.right}return{col:t,row:o}}getEndOfCluster(e,t,o){const s=this.getters.getActiveSheetId();let i=e;const n=this.getNextCellPosition(e,t,o),r=this.isCellSkippableInCluster({...i,sheetId:s})||this.isCellSkippableInCluster({...n,sheetId:s})?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(i,t,o);if(i.col===e.col&&i.row===e.row)break;const n=this.isCellSkippableInCluster({...e,sheetId:s});if("endOfCluster"===r&&n)break;if("nextCluster"===r&&!n){i=e;break}i=e}return"cols"===t?i.col:i.row}getNextCellPosition(e,t,o){const s={...e};return s["cols"===t?"col":"row"]="cols"===t?this.getNextAvailableCol(o,s.col,s.row):this.getNextAvailableRow(o,s.col,s.row),{col:s.col,row:s.row}}getPosition(){return{...this.anchor.cell}}isCellSkippableInCluster(e){const t=this.getters.getMainCellPosition(e),o=this.getters.getEvaluatedCell(t);return o.type===Ts.empty||o.type===Ts.text&&""===o.value}}function CH(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class yH{changes;commands=[];recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop();let o=e[0];const s=e.at(-1),i=e.length-2;for(let t=1;t<=i;t++){const s=e[t];if(void 0===o[s]){const i=e[t+1];o[s]=CH(i)}o=o[s]}o[s]!==t&&(this.changes?.push({key:s,target:o,before:o[s]}),void 0===t?delete o[s]:o[s]=t)}}const wH=17781237,IH=17781238,xH=88853993,EH=88853994;function RH(e,t,o){const s=[["xmlns:r",Mh],["xmlns:a",Dh],["xmlns:c",_h]],i=TH({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let n=vx``;if(e.data.title?.text){const t=wy(tC(e.data.backgroundColor)),o=e.data.title.fontSize??K;n=vx`
|
|
2585
|
+
`;class lH extends t.Component{static template="o-spreadsheet-Spreadsheet";static props={model:Object,notifyUser:{type:Function,optional:!0},raiseError:{type:Function,optional:!0},askConfirmation:{type:Function,optional:!0}};static components={TopBar:rH,Grid:yk,BottomBar:kL,SmallBottomBar:qL,SidePanels:GL,SpreadsheetDashboard:LL,HeaderGroupContainer:zL,FullScreenChart:Ik};sidePanel;spreadsheetRef=t.useRef("spreadsheet");spreadsheetRect=Ax();_focusGrid;isViewportTooSmall=!1;notificationStore;composerFocusStore;get model(){return this.props.model}getStyle(){const e={};this.env.isDashboard()?e["grid-template-rows"]="auto":e["grid-template-rows"]="min-content auto min-content";const t=this.sidePanel.mainPanel?`${this.sidePanel.totalPanelSize||mk}px`:"auto";return e["grid-template-columns"]=`auto ${t}`,bh(e)}setup(){if(!("isSmall"in this.env)){const e=function(){const e=Ax();return{get isSmall(){return e.width<768}}}();t.useSubEnv({get isSmall(){return e.isSmall}})}const e=th();e.inject(ah,this.model);const o=this.env;e.get(pk).setSmallThreshhold((()=>o.isSmall)),this.notificationStore=oh(dE),this.composerFocusStore=oh(uh),this.sidePanel=oh(vk);const s=this.model.config.external.fileStore;t.useSubEnv({model:this.model,imageProvider:s?new AL(s):void 0,loadCurrencies:this.model.config.external.loadCurrencies,loadLocales:this.model.config.external.loadLocales,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.sidePanel.open.bind(this.sidePanel),toggleSidePanel:this.sidePanel.toggle.bind(this.sidePanel),clipboard:this.env.clipboard||new aH(navigator.clipboard),startCellEdition:e=>this.composerFocusStore.focusActiveComposer({content:e}),notifyUser:e=>this.notificationStore.notifyUser(e),askConfirmation:(e,t,o)=>this.notificationStore.askConfirmation(e,t,o),raiseError:(e,t)=>this.notificationStore.raiseError(e,t),isMobile:yy}),this.notificationStore.updateNotificationCallbacks({...this.props}),t.useEffect((()=>{!this.spreadsheetRef.el.contains(document.activeElement)&&document.activeElement?.contains(this.spreadsheetRef.el)&&this.focusGrid()}),(()=>[this.env.model.getters.getActiveSheetId()])),t.useExternalListener(window,"resize",(()=>this.render(!0))),t.useExternalListener(document.body,"wheel",(()=>{})),this.bindModelEvents(),t.onWillUpdateProps((e=>{if(e.model!==this.props.model)throw new Error("Changing the props model is not supported at the moment.");e.notifyUser===this.props.notifyUser&&e.askConfirmation===this.props.askConfirmation&&e.raiseError===this.props.raiseError||this.notificationStore.updateNotificationCallbacks({...e})}));const i=function(e){let t=!1;return async(...o)=>{t||(t=!0,await Promise.resolve(),t=!1,e(...o))}}(this.render.bind(this,!0));t.onMounted((()=>{this.checkViewportSize(),e.on("store-updated",this,i),n.observe(this.spreadsheetRef.el),Ch()})),t.onWillUnmount((()=>{this.unbindModelEvents(),e.off("store-updated",this),n.disconnect(),function(){if(window.Chart)for(const e of Sh.getAll())e.unregister(window.Chart)}()})),t.onPatched((()=>{this.checkViewportSize()}));const n=new ResizeObserver((()=>{this.sidePanel.changeSpreadsheetWidth(this.spreadsheetRect.width)}))}bindModelEvents(){this.model.on("update",this,(()=>this.render(!0))),this.model.on("notify-ui",this,(e=>this.notificationStore.notifyUser(e))),this.model.on("raise-error-ui",this,(({text:e})=>this.notificationStore.raiseError(e)))}unbindModelEvents(){this.model.off("update",this),this.model.off("notify-ui",this),this.model.off("raise-error-ui",this)}checkViewportSize(){const{xRatio:e,yRatio:t}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());if(isFinite(e)&&isFinite(t))if(t>.85||e>.85){if(this.isViewportTooSmall)return;this.notificationStore.notifyUser({text:Vo("The current window is too small to display this sheet properly. Consider resizing your browser window or adjusting frozen rows and columns."),type:"warning",sticky:!1}),this.isViewportTooSmall=!0}else this.isViewportTooSmall=!1}focusGrid(){this._focusGrid&&this._focusGrid()}get gridHeight(){return this.env.model.getters.getSheetViewDimension().height}get gridContainerStyle(){const e=ce*this.rowLayers.length,t=ce*this.colLayers.length;return bh({"grid-template-columns":`${e?e+2:0}px auto`,"grid-template-rows":`${t?t+2:0}px auto`})}get rowLayers(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getVisibleGroupLayers(e,"ROW")}get colLayers(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getVisibleGroupLayers(e,"COL")}getGridSize(){const e=this.spreadsheetRef.el?.querySelector(".o-spreadsheet-topbar-wrapper")?.getBoundingClientRect().height||0,t=this.spreadsheetRef.el?.querySelector(".o-spreadsheet-bottombar-wrapper")?.getBoundingClientRect().height||0,o=this.spreadsheetRef.el?.querySelector(".o-grid")?.getBoundingClientRect().width||0,s=(this.spreadsheetRef.el?.getBoundingClientRect().height||0)-(this.spreadsheetRef.el?.querySelector(".o-column-groups")?.getBoundingClientRect().height||0)-e-t;return{width:Math.max(o-ne,0),height:Math.max(s-ne,0)}}}function cH(e){return CL.get(e.type)(e)}class hH{buildTransformation;operations;constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){return this.operations[this.operations.length-1]?.id}getFirstOperationAmong(e,t){for(const o of this.operations){if(o.id===e)return e;if(o.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const o=this.buildTransformation.with(e.data),{before:s,operation:i,after:n}=this.locateOperation(t);this.operations=[...s,i,e,...n.map((e=>e.transformed(o)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new hH(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:o}=this.locateOperation(e);this.operations=t.concat([o])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class dH{id;data;constructor(e,t){this.id=e,this.data=t}transformed(e){return new uH(this.id,ut((()=>e(this.data))))}}class uH{id;lazyData;constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new uH(this.id,this.lazyData.map(e))}}class gH{operations;constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new gH(function*(e,t){for(const o of e)if(yield o,o.operation.id===t)return}(this.operations,e))}stopBefore(e){return new gH(function*(e,t){for(const o of e){if(o.operation.id===t)return;yield o}}(this.operations,e))}startAfter(e){return new gH(function*(e,t){let o=!0;for(const s of e)o||(yield s),s.operation.id===t&&(o=!1)}(this.operations,e))}}class pH{buildTransformation;branches;branchingOperationIds=new Map;constructor(e,t){this.buildTransformation=e,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new gH(Xe(this._execution(e),this._execution(e)))}revertedExecution(e){return new gH(Xe(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){const o=e.getLastOperationId()||this.previousBranch(e)?.getLastOperationId();e.append(t),o&&this.insertPrevious(e,t,o)}insertOperationAfter(e,t,o){e.insert(t,o),this.updateNextWith(e,t,o),this.insertPrevious(e,t,o)}undo(e,t){const o=this.buildTransformation.without(t.data),s=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const i=e.fork(t.id);s&&this.branchingOperationIds.set(i,s),this.insertBranchAfter(e,i),this.transform(i,o)}redo(e){const t=this.nextBranch(e);if(!t)return;const o=this.nextBranch(t);this.removeBranchFromTree(t);const s=this.branchingOperationIds.get(t);s?this.branchingOperationIds.set(e,s):this.branchingOperationIds.delete(e),o&&this.rebaseUp(o)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const o of this.revertedExecution(e))if(o.operation.id===t)return o;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:o}=this.findPreviousBranchingOperation(e);if(!t||!o)return;const s=this.buildTransformation.without(o.data),i=t.fork(o.id);this.branchingOperationIds.set(i,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,i),i.transform(s);const n=this.nextBranch(i);n&&this.rebaseUp(n)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const o=this.branches.findIndex((t=>t===e));this.branches.splice(o+1,0,t)}updateNextWith(e,t,o){const s=this.branchingOperationIds.get(e),i=this.nextBranch(e);if(s&&i)if(e.getFirstOperationAmong(o,s)===s){const n=this.addToNextBranch(e,i,s,t,o);this.updateNextWith(i,n,o)}else{const e=this.buildTransformation.with(t.data);this.transform(i,e)}}addToNextBranch(e,t,o,s,i){let n=s;return i===o?(n=this.getTransformedOperation(e,o,s),t.prepend(n)):t.contains(i)?(n=this.getTransformedOperation(e,o,s),t.insert(n,i)):t.append(s),n}getTransformedOperation(e,t,o){const s=e.getOperation(t),i=this.buildTransformation.without(s.data);return o.transformed(i)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const o=this.nextBranch(e);o&&this.transform(o,t)}insertPrevious(e,t,o){const{previousBranch:s,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!s||!i)return;const n=this.buildTransformation.with(i.data),r=e.fork(o);r.transform(n),s.cutAfter(o),s.appendBranch(r);const a=t.transformed(n);this.insertPrevious(s,a,o)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const o=this.branchingOperationIds.get(t);return o?{previousBranch:t,branchingOperation:t.getOperation(o)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let o=!!t;const s=e.getOperations();for(let i=s.length-1;i>=0;i--){const n=s[i];n.id===t&&(o=!1),o||(yield{operation:n,branch:e,isCancelled:!this.shouldExecute(e,n)})}const i=this.previousBranch(e);yield*i?this._revertedExecution(i):[]}*_execution(e){for(const t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){const t=this.nextBranch(e);return void(yield*t?this._execution(t):[])}if(!this.branchingOperationIds.get(e)){const t=this.nextBranch(e);yield*t?this._execution(t):[]}}}class mH{HEAD_BRANCH;HEAD_OPERATION;tree;applyOperation;revertOperation;buildEmpty;buildTransformation;constructor(e){this.applyOperation=e.applyOperation,this.revertOperation=e.revertOperation,this.buildEmpty=e.buildEmpty,this.buildTransformation=e.buildTransformation,this.HEAD_BRANCH=new hH(this.buildTransformation),this.tree=new pH(this.buildTransformation,this.HEAD_BRANCH);const t=e.initialOperationId,o=new dH(t,this.buildEmpty(t));this.tree.insertOperationLast(this.HEAD_BRANCH,o),this.HEAD_OPERATION=o}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const o=new dH(e,t),s=this.tree.getLastBranch();this.tree.insertOperationLast(s,o),this.HEAD_BRANCH=s,this.HEAD_OPERATION=o}insert(e,t,o){const s=new dH(e,t);this.revertTo(o),this.tree.insertOperationAfter(this.HEAD_BRANCH,s,o),this.fastForward()}undo(e,t,o){const{branch:s,operation:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(s,i),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}redo(e,t,o){const{branch:s}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(s),this.fastForward(),this.insert(t,this.buildEmpty(t),o)}rebase(e){const t=this.get(e),o=[...this.tree.execution(this.HEAD_BRANCH).startAfter(e)];this.revertBefore(e);const s=this.HEAD_OPERATION.id;this.tree.drop(e),this.insert(e,t,s);for(const{operation:e}of o)this.insert(e.id,e.data,this.HEAD_OPERATION.id)}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:o,isCancelled:s}of e)s||this.revertOperation(o.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:o,isCancelled:s}of e)s||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=o}}function fH(e){return new mH({initialOperationId:e.initialRevisionId,applyOperation:t=>{const o=t.commands.slice(),{changes:s}=e.recordChanges((()=>{for(const t of o)e.dispatch(t)}));t.setChanges(s)},revertOperation:e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){vH(t.changes[e])}}([e]),buildEmpty:e=>new ZV(e,"empty",[]),buildTransformation:{with:e=>t=>new ZV(t.id,t.clientId,WV(t.commands,e.commands),t.rootCommand,void 0,t.timestamp),without:e=>t=>new ZV(t.id,t.clientId,WV(t.commands,e.commands.map(cH).flat()),t.rootCommand,void 0,t.timestamp)}})}function vH(e){const t=e.target,o=e.key,s=e.before;void 0===s?delete t[o]:t[o]=s}class bH{observers=new Map;defaultSubscription;mainSubscription;registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||(this.mainSubscription=this.defaultSubscription)}observe(e,t){this.observers.set(e,{owner:e,callbacks:t})}capture(e,t){if(this.observers.get(e))throw new Error("You are already subscribed forever");this.mainSubscription?.owner&&this.mainSubscription.owner!==e&&this.mainSubscription.callbacks.release?.(),this.mainSubscription={owner:e,callbacks:t}}release(e){this.mainSubscription?.owner!==e||this.observers.get(e)||(this.mainSubscription=this.defaultSubscription)}getBackToDefault(){this.mainSubscription!==this.defaultSubscription&&(this.mainSubscription?.callbacks.release?.(),this.mainSubscription=this.defaultSubscription)}isListening(e){return this.mainSubscription?.owner===e}send(e){this.mainSubscription?.callbacks.handleEvent(e),this.observers.forEach((t=>t.callbacks.handleEvent(e)))}}class SH{getters;stream;anchor;defaultAnchor;constructor(e){this.getters=e,this.stream=new bH,this.anchor={cell:{col:0,row:0},zone:Dr({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,o){this.stream.capture(e,o),this.anchor=t}registerAsDefault(e,t,o){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,o),this.defaultAnchor=t,this.capture(e,t,o)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}modifyAnchor(e,t,o){const s=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(s,e.zone)},this.processEvent({options:o,anchor:e,mode:t})}selectZone(e,t={scrollIntoView:!0}){return this.modifyAnchor(e,"overrideSelection",t)}selectCell(e,t){const o=Dr({col:e,row:t});return this.selectZone({zone:o,cell:{col:e,row:t}},{scrollIntoView:!0})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new Vs("InvalidSelectionStep");const{col:o,row:s}=this.getNextAvailablePosition(e,t);return this.selectCell(o,s)}setAnchorCorner(e,t){const o=this.getters.getActiveSheetId(),{col:s,row:i}=this.anchor.cell,n={left:Math.min(s,e),top:Math.min(i,t),right:Math.max(s,e),bottom:Math.max(i,t)},r={zone:this.getters.expandZone(o,n),cell:{col:s,row:i}};return this.processEvent({mode:"updateAnchor",anchor:r,options:{scrollIntoView:!1}})}addCellToSelection(e,t){const o=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:o,col:e,row:t}));const s=this.getters.expandZone(o,Dr({col:e,row:t}));return this.processEvent({options:{scrollIntoView:!0},anchor:{zone:s,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new Vs("InvalidSelectionStep");const o=this.getters.getActiveSheetId(),s=this.anchor,{col:i,row:n}=s.cell,{left:r,right:a,top:l,bottom:c}=s.zone,h=this.getStartingPosition(e),[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return Vs.Success;let g=s.zone;const p=e=>{e=Rr(e);const{left:t,right:s,top:i,bottom:n}=this.getters.expandZone(o,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(o)-1,s),top:Math.max(0,i),bottom:Math.min(this.getters.getNumberRows(o)-1,n)}},{col:m,row:f}=this.getReferencePosition();let v=0;for(;null!==g;){if(v++,d<0){const e=this.getNextAvailableCol(d,a-(v-1),f);g=m<=a-v?p({top:l,left:r,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,r+(v-1),f);g=r+v<=m?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,m,c-(v-1));g=f<=c-v?p({top:l,left:r,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,m,l+(v-1));g=l+v<=f?p({top:e,left:r,bottom:c,right:a}):null}if(g=g?Rr(g):g,g&&!br(g,s.zone))return this.processEvent({options:{scrollIntoView:!0},mode:"updateAnchor",anchor:{zone:g,cell:{col:i,row:n}}})}g=p(fr({top:n,bottom:n,left:i,right:i},Rr({top:this.getNextAvailableRow(u,m,l),left:this.getNextAvailableCol(d,r,f),bottom:this.getNextAvailableRow(u,m,c),right:this.getNextAvailableCol(d,a,f)})));const b={zone:g,cell:{col:i,row:n}};return this.processEvent({anchor:b,mode:"updateAnchor",options:{scrollIntoView:!0}})}selectColumn(e,t){const o=this.getters.getActiveSheetId(),s=this.getters.getNumberRows(o)-1;let i={left:e,right:e,top:0,bottom:s};const n=this.getters.findFirstVisibleColRowIndex(o,"ROW");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=e,a=n;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),i=fr(i,{left:r,right:r,top:n,bottom:s})}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:i,cell:{col:r,row:a}},mode:t})}selectRow(e,t){const o=this.getters.getActiveSheetId(),s=this.getters.getNumberCols(o)-1;let i={top:e,bottom:e,left:0,right:s};const n=this.getters.findFirstVisibleColRowIndex(o,"COL");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=n,a=e;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),i=fr(i,{left:n,right:s,top:a,bottom:a})}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:i,cell:{col:r,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor;if(br(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:Dr(t.cell)},"updateAnchor",{scrollIntoView:!1});const o=this.getters.getContiguousZone(e,t.zone);return mt(o,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:o},"updateAnchor",{scrollIntoView:!1})}selectTableAroundSelection(){const e=this.getters.getActiveSheetId(),t=this.getters.getContiguousZone(e,this.anchor.zone);return this.modifyAnchor({...this.anchor,zone:t},"updateAnchor",{scrollIntoView:!1})}selectAll(){const e=this.getters.getActiveSheetId(),t={left:0,top:0,bottom:this.getters.getNumberRows(e)-1,right:this.getters.getNumberCols(e)-1};return this.processEvent({mode:"overrideSelection",anchor:{zone:t,cell:this.anchor.cell},options:{scrollIntoView:!1}})}isListening(e){return this.stream.isListening(e)}processEvent(e){const t={...e,previousAnchor:ze(this.anchor)},o=this.checkEventAnchorZone(t);return"Success"!==o?new Vs(o):(this.anchor=t.anchor,this.stream.send(t),Vs.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:o}=e;if(!Cr(t.col,t.row,o))return"InvalidAnchorZone";const{left:s,right:i,top:n,bottom:r}=o,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",s,i);return void 0===this.getters.findVisibleHeader(a,"ROW",n,r)||void 0===l?"SelectionOutOfBound":"Success"}checkAnchorZoneOrThrow(e){if("InvalidAnchorZone"===this.checkAnchorZone(e))throw new Error("The provided anchor is invalid. The cell must be part of the zone.")}getNextAvailablePosition(e,t=1){const{col:o,row:s}=this.anchor.cell,i=this.deltaToTarget({col:o,row:s},e,t);return{col:this.getNextAvailableCol(i[0],o,s),row:this.getNextAvailableRow(i[1],o,s)}}getNextAvailableCol(e,t,o){const s=this.getters.getActiveSheetId(),i={col:t,row:o};return this.getNextAvailableHeader(e,"COL",t,i,(e=>this.getters.isInSameMerge(s,t,o,e,o)))}getNextAvailableRow(e,t,o){const s=this.getters.getActiveSheetId(),i={col:t,row:o};return this.getNextAvailableHeader(e,"ROW",o,i,(e=>this.getters.isInSameMerge(s,t,o,t,e)))}getNextAvailableHeader(e,t,o,s,i){const n=this.getters.getActiveSheetId();if(0===e)return o;const r=Math.sign(e);let a=o+e;for(;i(a);)a+=r;for(;this.getters.isHeaderHidden(n,t,a);)a+=r;return a<0||a>this.getters.getNumberHeaders(n,t)-1?this.getters.isHeaderHidden(n,t,o)?this.getNextAvailableHeader(-r,t,o,s,i):o:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:o,right:s,top:i,bottom:n}=t.zone,{col:r,row:a}=t.cell;return{col:this.getters.isColHidden(e,r)&&this.getters.findVisibleHeader(e,"COL",o,s)||r,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",i,n)||a}}deltaToTarget(e,t,o){switch(t){case"up":return"end"!==o?[0,-o]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==o?[0,o]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==o?[-o,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==o?[o,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:o}=this.getPosition();const s=this.anchor.zone;switch(e){case"down":case"up":o=o===s.top?s.bottom:s.top;break;case"left":case"right":t=t===s.right?s.left:s.right}return{col:t,row:o}}getEndOfCluster(e,t,o){const s=this.getters.getActiveSheetId();let i=e;const n=this.getNextCellPosition(e,t,o),r=this.isCellSkippableInCluster({...i,sheetId:s})||this.isCellSkippableInCluster({...n,sheetId:s})?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(i,t,o);if(i.col===e.col&&i.row===e.row)break;const n=this.isCellSkippableInCluster({...e,sheetId:s});if("endOfCluster"===r&&n)break;if("nextCluster"===r&&!n){i=e;break}i=e}return"cols"===t?i.col:i.row}getNextCellPosition(e,t,o){const s={...e};return s["cols"===t?"col":"row"]="cols"===t?this.getNextAvailableCol(o,s.col,s.row):this.getNextAvailableRow(o,s.col,s.row),{col:s.col,row:s.row}}getPosition(){return{...this.anchor.cell}}isCellSkippableInCluster(e){const t=this.getters.getMainCellPosition(e),o=this.getters.getEvaluatedCell(t);return o.type===Ts.empty||o.type===Ts.text&&""===o.value}}function CH(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class yH{changes;commands=[];recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop();let o=e[0];const s=e.at(-1),i=e.length-2;for(let t=1;t<=i;t++){const s=e[t];if(void 0===o[s]){const i=e[t+1];o[s]=CH(i)}o=o[s]}o[s]!==t&&(this.changes?.push({key:s,target:o,before:o[s]}),void 0===t?delete o[s]:o[s]=t)}}const wH=17781237,IH=17781238,xH=88853993,EH=88853994;function RH(e,t,o){const s=[["xmlns:r",Mh],["xmlns:a",Dh],["xmlns:c",_h]],i=TH({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let n=vx``;if(e.data.title?.text){const t=wy(tC(e.data.backgroundColor)),o=e.data.title.fontSize??K;n=vx`
|
|
2586
2586
|
<c:title>
|
|
2587
2587
|
${DH(e.data.title.text,t,o,e.data.title)}
|
|
2588
2588
|
<c:overlay val="0" />
|
|
@@ -3341,4 +3341,4 @@
|
|
|
3341
3341
|
<tableParts count="${e.tables.length}">
|
|
3342
3342
|
${fx(a)}
|
|
3343
3343
|
</tableParts>
|
|
3344
|
-
`}var IU;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(IU||(IU={}));function xU(e,t={}){const o=ze(t);return o.type=e,o}const EU={},RU={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:te,HEADER_WIDTH:oe,DESKTOP_BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:se,DEFAULT_CELL_HEIGHT:ie,SCROLLBAR_WIDTH:ne},TU={autoCompleteProviders:lE,autofillModifiersRegistry:xV,autofillRulesRegistry:EV,cellMenuRegistry:qO,colMenuRegistry:iP,errorTypes:Qs,linkMenuRegistry:dR,functionRegistry:CS,featurePluginRegistry:fL,iconsOnCellRegistry:bV,statefulUIPluginRegistry:vL,coreViewsPluginRegistry:bL,corePluginRegistry:mL,rowMenuRegistry:hP,sidePanelRegistry:gk,figureRegistry:Vx,chartSidePanelComponentRegistry:$M,chartComponentRegistry:KI,chartRegistry:XI,chartSubtypeRegistry:QI,topbarMenuRegistry:EL,topbarComponentRegistry:RL,clickableCellRegistry:SL,otRegistry:MV,inverseCommandRegistry:CL,urlRegistry:Uo,cellPopoverRegistry:Ux,numberFormatMenuRegistry:wL,repeatLocalCommandTransformRegistry:lL,repeatCommandTransformRegistry:aL,clipboardHandlersRegistries:jc,pivotRegistry:YN,pivotTimeAdapterRegistry:dc,pivotSidePanelRegistry:QN,pivotNormalizationValueRegistry:zc,supportedPivotPositionalFormulaRegistry:wk,pivotToFunctionValueRegistry:$c,migrationStepRegistry:QA,chartJsExtensionRegistry:Sh},AU={arg:Zh,isEvaluationError:hi,toBoolean:wi,toJsDate:Ii,toNumber:gi,toString:Si,toNormalizedPivotValue:Lc,toFunctionPivotValue:Uc,toXC:Oo,toZone:ar,toUnboundedZone:rr,toCartesian:_o,numberToLetters:Co,lettersToNumber:yo,UuidGenerator:Wa,formatValue:bn,createCurrencyFormat:Fn,ColorGenerator:po,computeTextWidth:Oa,createEmptyWorkbookData:hD,createEmptySheet:cD,createEmptyExcelSheet:dD,rgbaToHex:jt,colorToRGBA:Yt,positionToZone:Dr,isDefined:lt,isMatrix:Ws,lazy:ut,genericRepeat:cL,createAction:i,createActions:o,transformRangeData:Xc,deepEquals:mt,overlap:Sr,union:fr,isInside:Cr,deepCopy:ze,expandZoneOnInsertion:ur,reduceZoneOnDeletion:mr,unquote:Ge,getMaxObjectId:_c,getFunctionsFromTokens:LS,getFirstPivotFunction:FN,getNumberOfPivotFunctions:PN,parseDimension:Pc,isDateOrDatetimeField:Mc,makeFieldProposal:AN,insertTokenAfterArgSeparator:DN,insertTokenAfterLeftParenthesis:_N,mergeContiguousZones:kr,getPivotHighlights:gN,pivotTimeAdapter:uc,UNDO_REDO_PIVOT_COMMANDS:wV,createPivotFormula:Vc,areDomainArgsFieldsValid:kc,splitReference:ta,sanitizeSheetName:qe,getUniqueText:kt,isNumber:Is,isDateTime:rs},DU={isMarkdownLink:et,parseMarkdownLink:st,markdownLink:ot,openLink:Wo,urlRepresentation:Go},_U={Checkbox:YE,Section:ME,RoundColorPicker:NE,ChartDataSeries:eM,ChartErrorSection:tM,ChartLabelRange:oM,ChartTitle:hM,ChartPanel:qM,ChartFigure:Nx,ChartJsComponent:zC,Grid:yk,GridOverlay:NP,ScorecardChart:sy,LineConfigPanel:DM,BarConfigPanel:iM,PieChartDesignPanel:FM,GenericChartConfigPanel:sM,ChartWithAxisDesignPanel:bM,LineChartDesignPanel:_M,GaugeChartConfigPanel:wM,GaugeChartDesignPanel:IM,ScorecardChartConfigPanel:MM,ScorecardChartDesignPanel:NM,GeoChartDesignPanel:TM,RadarChartDesignPanel:PM,WaterfallChartDesignPanel:zM,ComboChartDesignPanel:CM,FunnelChartDesignPanel:yM,ChartTypePicker:GM,FigureComponent:Lx,MenuPopover:Px,Popover:Dx,SelectionInput:$E,ValidationMessages:TP,AddDimensionButton:vN,PivotDimensionGranularity:yN,PivotDimensionOrder:wN,PivotDimension:CN,PivotLayoutConfigurator:EN,PivotHTMLRenderer:xk,PivotDeferUpdate:pN,PivotTitleSection:RN,CogWheelMenu:SN,TextInput:bN,SidePanelCollapsible:Wx,RadioSelection:uM,GeoChartRegionSelectSection:xM,ChartDashboardMenu:Mx,FullScreenChart:Ik},OU={useDragAndDropListItems:kE,useHighlights:YM,useHighlightsOnHover:jM},FU={useStoreProvider:th,DependencyContainer:Jc,CellPopoverStore:Bx,ComposerFocusStore:uh,CellComposerStore:SP,FindAndReplaceStore:aN,HighlightStore:hE,DelayedHoveredCellStore:Hx,HoveredTableStore:FP,ModelStore:ah,NotificationStore:dE,RendererStore:ch,SelectionInputStore:zE,SpreadsheetStore:hh,useStore:oh,useLocalStore:sh,SidePanelStore:vk,PivotSidePanelStore:KN,PivotMeasureDisplayPanelStore:dN,ClientFocusStore:uP};const PU={DEFAULT_LOCALE:$s,HIGHLIGHT_COLOR:a,PIVOT_TABLE_CONFIG:Ve,ChartTerms:$y},MU={...nx,...vI};e.AbstractCellClipboardHandler=el,e.AbstractChart=$C,e.AbstractFigureClipboardHandler=Zc,e.CellErrorType=Js,e.ClientDisconnectedError=jV,e.CorePlugin=Rk,e.CoreViewPlugin=Mk,e.DispatchResult=Vs,e.EvaluationError=ei,e.LocalTransportService=TL,e.Model=class extends Kc{corePlugins=[];statefulUIPlugins=[];range;session;isReplayingCommand=!1;renderers={};status=0;config;corePluginConfig;coreViewPluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},o={},s=[],i=new Wa,n=!1){const r=performance.now();console.debug("##### Model creation #####"),super(),Mo===Fo&&No===Po&&(No=()=>!0),s=aD(e,s);const a=iD(e,n);this.state=new yH,this.uuidGenerator=i,this.config=this.setupConfig(o),this.session=this.setupSession(a.revisionId),this.coreGetters={},this.range=new Fk(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeData=this.range.getRangeData.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getRangeFromZone=this.range.getRangeFromZone.bind(this.range),this.coreGetters.recomputeRanges=this.range.recomputeRanges.bind(this.range),this.coreGetters.isRangeValid=this.range.isRangeValid.bind(this.range),this.coreGetters.extendRange=this.range.extendRange.bind(this.range),this.coreGetters.getRangesUnion=this.range.getRangesUnion.bind(this.range),this.coreGetters.removeRangesSheetPrefix=this.range.removeRangesSheetPrefix.bind(this.range),this.coreGetters.adaptFormulaStringDependencies=this.range.adaptFormulaStringDependencies.bind(this.range),this.coreGetters.copyFormulaStringForSheet=this.range.copyFormulaStringForSheet.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode},this.selection=new SH(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.coreViewPluginConfig=this.setupCoreViewPluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(const e of mL.getAll())this.setupCorePlugin(e,a);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(s);for(const e of bL.getAll()){const t=this.setupCoreViewPlugin(e);this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(const e of vL.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(const e of fL.getAll()){const t=this.setupUiPlugin(e);this.handlers.push(t),this.uiHandlers.push(t)}if(this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.joinSession(),o.snapshotRequested||e["[Content_Types].xml"]&&!this.getters.isReadonly()){const e=performance.now();console.debug("Snapshot requested"),this.session.snapshot(this.exportData()),this.garbageCollectExternalResources(),console.debug("Snapshot taken in",performance.now()-e,"ms")}t.markRaw(this),console.debug("Model created in",performance.now()-r,"ms"),console.debug("######")}joinSession(){this.session.join(this.config.client)}async leaveSession(){const e=this.getters.isReadonly()?void 0:ut((()=>this.exportData()));await this.session.leave(e)}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(const o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}for(const o of e.layers)this.renderers[o]||(this.renderers[o]=[]),this.renderers[o].push(t);return t}setupCoreViewPlugin(e){const t=new e(this.coreViewPluginConfig);for(const o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}return t}setupCorePlugin(e,t){const o=new e(this.corePluginConfig);for(const t of e.getters){if(!(t in o))throw new Error(`Invalid getter name: ${t} for plugin ${o.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=o[t].bind(o)}o.import(t),this.corePlugins.push(o),this.coreHandlers.push(o),this.handlers.push(o)}onRemoteRevisionReceived({commands:e}){for(const t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new YV(fH({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{this.checkDispatchAllowed(e).isSuccessful?(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1):this.dispatchToHandlers(this.coreHandlers,{type:"UNDO",commands:[e]})}}),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-undone",this,(({commands:e})=>{this.dispatchFromCorePlugin("UNDO",{commands:e}),this.finalize()})),this.session.on("revision-redone",this,(({commands:e})=>{this.dispatchFromCorePlugin("REDO",{commands:e}),this.finalize()})),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.smallUuid(),name:Vo("Anonymous").toString()},o=e.transportService||new TL;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:o,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e),raiseBlockingErrorUI:e=>this.trigger("raise-error-ui",{text:e}),customColors:e.customColors||[]}}setupExternalConfig(e){const t=e.loadLocales||(()=>Promise.resolve(zs));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,canDispatch:this.canDispatch,custom:this.config.custom,external:this.config.external}}setupCoreViewPluginConfig(){return{getters:this.getters,stateObserver:this.state,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,canDispatch:this.canDispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external}}checkDispatchAllowed(e){const t=ks(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some((e=>"Success"!==e))?new Vs(t.flat()):Vs.Success}checkDispatchAllowedCoreCommand(e){const t=this.corePlugins.map((t=>t.allowDispatch(e)));return t.push(this.range.allowDispatch(e)),t}checkDispatchAllowedLocalCommand(e){return this.uiHandlers.map((t=>t.allowDispatch(e)))}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0,this.trigger("command-finalized")}canDispatch=(e,t)=>this.checkDispatchAllowed(xU(e,t));dispatch=(e,t)=>{const o=xU(e,t),s=this.status;if(this.getters.isReadonly()&&(i=o,!Ms.has(i.type)))return new Vs("Readonly");var i;if(!this.session.canApplyOptimisticUpdate())return new Vs("WaitingSessionConfirmation");switch(s){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return this.trigger("update"),t;this.status=1;const{changes:s,commands:i}=this.state.recordChanges((()=>{const t=performance.now();ks(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize();const s=performance.now()-t;s>5&&console.debug(e,s,"ms")}));this.session.save(o,i,s),this.status=0,this.trigger("update");break;case 1:if(ks(o)){const e=this.checkDispatchAllowed(o);if(!e.isSuccessful)return e;this.state.addCommand(o)}this.dispatchToHandlers(this.handlers,o);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(ks(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return Vs.Success};dispatchFromCorePlugin=(e,t)=>{const o=xU(e,t),s=this.status;this.status=2;const i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,o),this.status=s,Vs.Success};dispatchToHandlers(e,t){const o=ks(t);for(const s of e)!o&&s instanceof Rk||s.beforeHandle(t);for(const s of e)!o&&s instanceof Rk||s.handle(t);this.trigger("command-dispatched",t)}drawLayer(e,t){const o=this.renderers[t];if(o)for(const s of o)e.ctx.save(),s.drawLayer(e,t),e.ctx.restore()}exportData(){let e=hD();for(const t of this.handlers)t instanceof Rk&&t.export(e);return e.revisionId=this.session.getRevisionId()||Se,e=ze(e),e}updateMode(e){this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...hD(),sheets:[dD(sD,"Sheet1")]};for(const t of this.handlers)t instanceof Ek&&t.exportForExcel(e);return e=ze(e),yU(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.PivotRuntimeDefinition=MN,e.Registry=n,e.Revision=ZV,e.SPREADSHEET_DIMENSIONS=RU,e.Spreadsheet=lH,e.SpreadsheetPivotTable=VN,e.UIPlugin=FV,e.__info__=EU,e.addFunction=function e(t,o){return CS.add(t,o),{addFunction:(t,o)=>e(t,o)}},e.addRenderingLayer=function(e,t){if(Zs[e])throw new Error(`Layer ${e} already exists`);Zs[e]=t},e.astToFormula=av,e.chartHelpers=MU,e.compile=PS,e.compileTokens=MS,e.components=_U,e.constants=PU,e.convertAstNodes=sv,e.coreTypes=Ns,e.findCellInNewZone=Ar,e.functionCache=FS,e.helpers=AU,e.hooks=OU,e.invalidateCFEvaluationCommands=Fs,e.invalidateChartEvaluationCommands=_s,e.invalidateDependenciesCommands=Os,e.invalidateEvaluationCommands=Ds,e.iterateAstNodes=iv,e.links=DU,e.load=iD,e.parse=tv,e.parseTokens=ov,e.readonlyAllowedCommands=Ms,e.registries=TU,e.setDefaultSheetViewSize=function(e){Pe=e},e.setTranslationMethod=function(e,t=(()=>!0)){Mo=e,No=t},e.stores=FU,e.tokenColors=mE,e.tokenize=sl,EU.version="18.4.1",EU.date="2025-06-27T09:13:01.303Z",EU.hash="5cecc0e"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|
|
3344
|
+
`}var IU;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(IU||(IU={}));function xU(e,t={}){const o=ze(t);return o.type=e,o}const EU={},RU={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:te,HEADER_WIDTH:oe,DESKTOP_BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:se,DEFAULT_CELL_HEIGHT:ie,SCROLLBAR_WIDTH:ne},TU={autoCompleteProviders:lE,autofillModifiersRegistry:xV,autofillRulesRegistry:EV,cellMenuRegistry:qO,colMenuRegistry:iP,errorTypes:Qs,linkMenuRegistry:dR,functionRegistry:CS,featurePluginRegistry:fL,iconsOnCellRegistry:bV,statefulUIPluginRegistry:vL,coreViewsPluginRegistry:bL,corePluginRegistry:mL,rowMenuRegistry:hP,sidePanelRegistry:gk,figureRegistry:Vx,chartSidePanelComponentRegistry:$M,chartComponentRegistry:KI,chartRegistry:XI,chartSubtypeRegistry:QI,topbarMenuRegistry:EL,topbarComponentRegistry:RL,clickableCellRegistry:SL,otRegistry:MV,inverseCommandRegistry:CL,urlRegistry:Uo,cellPopoverRegistry:Ux,numberFormatMenuRegistry:wL,repeatLocalCommandTransformRegistry:lL,repeatCommandTransformRegistry:aL,clipboardHandlersRegistries:jc,pivotRegistry:YN,pivotTimeAdapterRegistry:dc,pivotSidePanelRegistry:QN,pivotNormalizationValueRegistry:zc,supportedPivotPositionalFormulaRegistry:wk,pivotToFunctionValueRegistry:$c,migrationStepRegistry:QA,chartJsExtensionRegistry:Sh},AU={arg:Zh,isEvaluationError:hi,toBoolean:wi,toJsDate:Ii,toNumber:gi,toString:Si,toNormalizedPivotValue:Lc,toFunctionPivotValue:Uc,toXC:Oo,toZone:ar,toUnboundedZone:rr,toCartesian:_o,numberToLetters:Co,lettersToNumber:yo,UuidGenerator:Wa,formatValue:bn,createCurrencyFormat:Fn,ColorGenerator:po,computeTextWidth:Oa,createEmptyWorkbookData:hD,createEmptySheet:cD,createEmptyExcelSheet:dD,rgbaToHex:jt,colorToRGBA:Yt,positionToZone:Dr,isDefined:lt,isMatrix:Ws,lazy:ut,genericRepeat:cL,createAction:i,createActions:o,transformRangeData:Xc,deepEquals:mt,overlap:Sr,union:fr,isInside:Cr,deepCopy:ze,expandZoneOnInsertion:ur,reduceZoneOnDeletion:mr,unquote:Ge,getMaxObjectId:_c,getFunctionsFromTokens:LS,getFirstPivotFunction:FN,getNumberOfPivotFunctions:PN,parseDimension:Pc,isDateOrDatetimeField:Mc,makeFieldProposal:AN,insertTokenAfterArgSeparator:DN,insertTokenAfterLeftParenthesis:_N,mergeContiguousZones:kr,getPivotHighlights:gN,pivotTimeAdapter:uc,UNDO_REDO_PIVOT_COMMANDS:wV,createPivotFormula:Vc,areDomainArgsFieldsValid:kc,splitReference:ta,sanitizeSheetName:qe,getUniqueText:kt,isNumber:Is,isDateTime:rs},DU={isMarkdownLink:et,parseMarkdownLink:st,markdownLink:ot,openLink:Wo,urlRepresentation:Go},_U={Checkbox:YE,Section:ME,RoundColorPicker:NE,ChartDataSeries:eM,ChartErrorSection:tM,ChartLabelRange:oM,ChartTitle:hM,ChartPanel:qM,ChartFigure:Nx,ChartJsComponent:zC,Grid:yk,GridOverlay:NP,ScorecardChart:sy,LineConfigPanel:DM,BarConfigPanel:iM,PieChartDesignPanel:FM,GenericChartConfigPanel:sM,ChartWithAxisDesignPanel:bM,LineChartDesignPanel:_M,GaugeChartConfigPanel:wM,GaugeChartDesignPanel:IM,ScorecardChartConfigPanel:MM,ScorecardChartDesignPanel:NM,GeoChartDesignPanel:TM,RadarChartDesignPanel:PM,WaterfallChartDesignPanel:zM,ComboChartDesignPanel:CM,FunnelChartDesignPanel:yM,ChartTypePicker:GM,FigureComponent:Lx,MenuPopover:Px,Popover:Dx,SelectionInput:$E,ValidationMessages:TP,AddDimensionButton:vN,PivotDimensionGranularity:yN,PivotDimensionOrder:wN,PivotDimension:CN,PivotLayoutConfigurator:EN,PivotHTMLRenderer:xk,PivotDeferUpdate:pN,PivotTitleSection:RN,CogWheelMenu:SN,TextInput:bN,SidePanelCollapsible:Wx,RadioSelection:uM,GeoChartRegionSelectSection:xM,ChartDashboardMenu:Mx,FullScreenChart:Ik},OU={useDragAndDropListItems:kE,useHighlights:YM,useHighlightsOnHover:jM},FU={useStoreProvider:th,DependencyContainer:Jc,CellPopoverStore:Bx,ComposerFocusStore:uh,CellComposerStore:SP,FindAndReplaceStore:aN,HighlightStore:hE,DelayedHoveredCellStore:Hx,HoveredTableStore:FP,ModelStore:ah,NotificationStore:dE,RendererStore:ch,SelectionInputStore:zE,SpreadsheetStore:hh,useStore:oh,useLocalStore:sh,SidePanelStore:vk,PivotSidePanelStore:KN,PivotMeasureDisplayPanelStore:dN,ClientFocusStore:uP};const PU={DEFAULT_LOCALE:$s,HIGHLIGHT_COLOR:a,PIVOT_TABLE_CONFIG:Ve,ChartTerms:$y},MU={...nx,...vI};e.AbstractCellClipboardHandler=el,e.AbstractChart=$C,e.AbstractFigureClipboardHandler=Zc,e.CellErrorType=Js,e.ClientDisconnectedError=jV,e.CorePlugin=Rk,e.CoreViewPlugin=Mk,e.DispatchResult=Vs,e.EvaluationError=ei,e.LocalTransportService=TL,e.Model=class extends Kc{corePlugins=[];statefulUIPlugins=[];range;session;isReplayingCommand=!1;renderers={};status=0;config;corePluginConfig;coreViewPluginConfig;uiPluginConfig;state;selection;getters;coreGetters;uuidGenerator;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},o={},s=[],i=new Wa,n=!1){const r=performance.now();console.debug("##### Model creation #####"),super(),Mo===Fo&&No===Po&&(No=()=>!0),s=aD(e,s);const a=iD(e,n);this.state=new yH,this.uuidGenerator=i,this.config=this.setupConfig(o),this.session=this.setupSession(a.revisionId),this.coreGetters={},this.range=new Fk(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeData=this.range.getRangeData.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getRangeFromZone=this.range.getRangeFromZone.bind(this.range),this.coreGetters.recomputeRanges=this.range.recomputeRanges.bind(this.range),this.coreGetters.isRangeValid=this.range.isRangeValid.bind(this.range),this.coreGetters.extendRange=this.range.extendRange.bind(this.range),this.coreGetters.getRangesUnion=this.range.getRangesUnion.bind(this.range),this.coreGetters.removeRangesSheetPrefix=this.range.removeRangesSheetPrefix.bind(this.range),this.coreGetters.adaptFormulaStringDependencies=this.range.adaptFormulaStringDependencies.bind(this.range),this.coreGetters.copyFormulaStringForSheet=this.range.copyFormulaStringForSheet.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode},this.selection=new SH(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.coreViewPluginConfig=this.setupCoreViewPluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(const e of mL.getAll())this.setupCorePlugin(e,a);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(s);for(const e of bL.getAll()){const t=this.setupCoreViewPlugin(e);this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(const e of vL.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(const e of fL.getAll()){const t=this.setupUiPlugin(e);this.handlers.push(t),this.uiHandlers.push(t)}if(this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.joinSession(),o.snapshotRequested||e["[Content_Types].xml"]&&!this.getters.isReadonly()){const e=performance.now();console.debug("Snapshot requested"),this.session.snapshot(this.exportData()),this.garbageCollectExternalResources(),console.debug("Snapshot taken in",performance.now()-e,"ms")}t.markRaw(this),console.debug("Model created in",performance.now()-r,"ms"),console.debug("######")}joinSession(){this.session.join(this.config.client)}async leaveSession(){const e=this.getters.isReadonly()?void 0:ut((()=>this.exportData()));await this.session.leave(e)}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(const o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}for(const o of e.layers)this.renderers[o]||(this.renderers[o]=[]),this.renderers[o].push(t);return t}setupCoreViewPlugin(e){const t=new e(this.coreViewPluginConfig);for(const o of e.getters){if(!(o in t))throw new Error(`Invalid getter name: ${o} for plugin ${t.constructor}`);if(o in this.getters)throw new Error(`Getter "${o}" is already defined.`);this.getters[o]=t[o].bind(t)}return t}setupCorePlugin(e,t){const o=new e(this.corePluginConfig);for(const t of e.getters){if(!(t in o))throw new Error(`Invalid getter name: ${t} for plugin ${o.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=o[t].bind(o)}o.import(t),this.corePlugins.push(o),this.coreHandlers.push(o),this.handlers.push(o)}onRemoteRevisionReceived({commands:e}){for(const t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new YV(fH({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{this.checkDispatchAllowed(e).isSuccessful?(this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1):this.dispatchToHandlers(this.coreHandlers,{type:"UNDO",commands:[e]})}}),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-undone",this,(({commands:e})=>{this.dispatchFromCorePlugin("UNDO",{commands:e}),this.finalize()})),this.session.on("revision-redone",this,(({commands:e})=>{this.dispatchFromCorePlugin("REDO",{commands:e}),this.finalize()})),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.smallUuid(),name:Vo("Anonymous").toString()},o=e.transportService||new TL;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:o,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e),raiseBlockingErrorUI:e=>this.trigger("raise-error-ui",{text:e}),customColors:e.customColors||[]}}setupExternalConfig(e){const t=e.loadLocales||(()=>Promise.resolve(zs));return{...e,loadLocales:t}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,canDispatch:this.canDispatch,custom:this.config.custom,external:this.config.external}}setupCoreViewPluginConfig(){return{getters:this.getters,stateObserver:this.state,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,canDispatch:this.canDispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external}}checkDispatchAllowed(e){const t=ks(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return t.some((e=>"Success"!==e))?new Vs(t.flat()):Vs.Success}checkDispatchAllowedCoreCommand(e){const t=this.corePlugins.map((t=>t.allowDispatch(e)));return t.push(this.range.allowDispatch(e)),t}checkDispatchAllowedLocalCommand(e){return this.uiHandlers.map((t=>t.allowDispatch(e)))}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0,this.trigger("command-finalized")}canDispatch=(e,t)=>this.checkDispatchAllowed(xU(e,t));dispatch=(e,t)=>{const o=xU(e,t),s=this.status;if(this.getters.isReadonly()&&(i=o,!Ms.has(i.type)))return new Vs("Readonly");var i;if(!this.session.canApplyOptimisticUpdate())return new Vs("WaitingSessionConfirmation");switch(s){case 0:const t=this.checkDispatchAllowed(o);if(!t.isSuccessful)return this.trigger("update"),t;this.status=1;const{changes:s,commands:i}=this.state.recordChanges((()=>{const t=performance.now();ks(o)&&this.state.addCommand(o),this.dispatchToHandlers(this.handlers,o),this.finalize();const s=performance.now()-t;s>5&&console.debug(e,s,"ms")}));this.session.save(o,i,s),this.status=0,this.trigger("update");break;case 1:if(ks(o)){const e=this.checkDispatchAllowed(o);if(!e.isSuccessful)return e;this.state.addCommand(o)}this.dispatchToHandlers(this.handlers,o);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(ks(o))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,o)}return Vs.Success};dispatchFromCorePlugin=(e,t)=>{const o=xU(e,t),s=this.status;this.status=2;const i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,o),this.status=s,Vs.Success};dispatchToHandlers(e,t){const o=ks(t);for(const s of e)!o&&s instanceof Rk||s.beforeHandle(t);for(const s of e)!o&&s instanceof Rk||s.handle(t);this.trigger("command-dispatched",t)}drawLayer(e,t){const o=this.renderers[t];if(o)for(const s of o)e.ctx.save(),s.drawLayer(e,t),e.ctx.restore()}exportData(){let e=hD();for(const t of this.handlers)t instanceof Rk&&t.export(e);return e.revisionId=this.session.getRevisionId()||Se,e=ze(e),e}updateMode(e){this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...hD(),sheets:[dD(sD,"Sheet1")]};for(const t of this.handlers)t instanceof Ek&&t.exportForExcel(e);return e=ze(e),yU(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.PivotRuntimeDefinition=MN,e.Registry=n,e.Revision=ZV,e.SPREADSHEET_DIMENSIONS=RU,e.Spreadsheet=lH,e.SpreadsheetPivotTable=VN,e.UIPlugin=FV,e.__info__=EU,e.addFunction=function e(t,o){return CS.add(t,o),{addFunction:(t,o)=>e(t,o)}},e.addRenderingLayer=function(e,t){if(Zs[e])throw new Error(`Layer ${e} already exists`);Zs[e]=t},e.astToFormula=av,e.chartHelpers=MU,e.compile=PS,e.compileTokens=MS,e.components=_U,e.constants=PU,e.convertAstNodes=sv,e.coreTypes=Ns,e.findCellInNewZone=Ar,e.functionCache=FS,e.helpers=AU,e.hooks=OU,e.invalidateCFEvaluationCommands=Fs,e.invalidateChartEvaluationCommands=_s,e.invalidateDependenciesCommands=Os,e.invalidateEvaluationCommands=Ds,e.iterateAstNodes=iv,e.links=DU,e.load=iD,e.parse=tv,e.parseTokens=ov,e.readonlyAllowedCommands=Ms,e.registries=TU,e.setDefaultSheetViewSize=function(e){Pe=e},e.setTranslationMethod=function(e,t=(()=>!0)){Mo=e,No=t},e.stores=FU,e.tokenColors=mE,e.tokenize=sl,EU.version="18.5.0-alpha.0",EU.date="2025-06-24T12:26:38.163Z",EU.hash="ed0f325"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|