@odoo/o-spreadsheet 19.5.0-alpha.0 → 19.5.0-alpha.1
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.
- package/dist/o_spreadsheet.cjs +9 -9
- package/dist/o_spreadsheet.css +3 -3
- package/dist/o_spreadsheet.esm.js +9 -9
- package/dist/o_spreadsheet.iife.js +9 -9
- package/dist/o_spreadsheet.min.iife.js +2 -2
- package/dist/o_spreadsheet.xml +3 -3
- package/dist/types/helpers/pivot/pivot_helpers.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -33,7 +33,7 @@ stores.inject(MyMetaStore, storeInstance);
|
|
|
33
33
|
<Default Extension="${e}" ContentType="${t}" />
|
|
34
34
|
`}function Y(e){return new av(e.join(`
|
|
35
35
|
`))}function X(e,...t){let n=[e[0]];for(let r=0;r<t.length;r++){let i=t[r]instanceof av?t[r]:Dx(t[r]);n.push(i+e[r+1])}return new av(Wt(n))}function Nx(e){return e.replace(/NAMESPACE.*NAMESPACE(.*)/,`$1`)}function Px(e){return e.replaceAll(/(<\/?)([a-zA-Z0-9]+):([a-zA-Z0-9]+)/g,`$1NAMESPACE$2NAMESPACE$3`)}function Fx(e){return e.replaceAll(/([a-zA-Z0-9]+):([a-zA-Z0-9]+)/g,`NAMESPACE$1NAMESPACE$2`)}var Ix=class{value;constructor(e){this.value=e}asString(){return By(String(this.value))}asBool(){return this.value===`true`?!0:this.value===`false`?!1:!!Number(this.value)}asNum(){return Number(this.value)}},Lx=class{rootFile;xlsxFileStructure;warningManager;relationships;currentFile=void 0;constructor(e,t,n){this.rootFile=e,this.currentFile=e.file.fileName,this.xlsxFileStructure=t,this.warningManager=n,this.relationships={},e.rels&&this.extractRelationships(e.rels).map(e=>{this.relationships[e.id]=e})}extractRelationships(e){return this.mapOnElements({parent:e.xml,query:`Relationship`},e=>({id:this.extractAttr(e,`Id`,{required:!0}).asString(),target:this.extractAttr(e,`Target`,{required:!0}).asString(),type:this.extractAttr(e,`Type`,{required:!0}).asString()}))}getListOfXMLFiles(){return Object.entries(this.xlsxFileStructure).filter(([e])=>e!==`images`).map(([e,t])=>t).flat().filter(w)}mapOnElements(e,t){let n=[],r=this.currentFile,i;if(i=e.children?this.querySelector(e.parent,e.query)?.children||[]:this.querySelectorAll(e.parent,e.query),i)for(let e of i)try{n.push(t(e))}catch(t){this.catchErrorOnElement(t,e)}return this.currentFile=r,n}catchErrorOnElement(e,t){let n=t?`Error when parsing an element <${t.tagName}> of file ${this.currentFile}, skip this element. \n${e.stack}`:`Error when parsing file ${this.currentFile}.`;this.warningManager.addParsingWarning([n,e.message].join(`
|
|
36
|
-
`))}extractAttr(e,t,n){let r=e.attributes[t];r||this.handleMissingValue(e,`attribute "${t}"`,n);let i=r?.value?r.value:n?.default;return i===void 0?void 0:new Ix(i)}extractTextContent(e,t){if(t?.default!==void 0&&typeof t.default!=`string`)throw Error(`extractTextContent default value should be a string`);let n=e?.attributes[`xml:space`]?.value===`preserve`,r=e?.textContent;return(!e||r===null)&&this.handleMissingValue(e,`text content`,t),r&&=n?r:r.trim(),r?By(r):t?.default}extractChildAttr(e,t,n,r){let i;i=typeof t==`number`?e.children[t]:this.querySelector(e,t),i||this.handleMissingValue(e,typeof t==`number`?`child at index ${t}`:`child <${t}>`,r);let a=i?this.extractAttr(i,n,r)?.asString():r?.default;return a===void 0?void 0:new Ix(a)}extractChildTextContent(e,t,n){if(n?.default!==void 0&&typeof n.default!=`string`)throw Error(`extractTextContent default value should be a string`);let r=this.querySelector(e,t);return r||this.handleMissingValue(e,`child <${t}>`,n),r?this.extractTextContent(r,n):n?.default}handleMissingValue(e,t,n){if(n?.required)if(n?.default!==void 0)this.warningManager.addParsingWarning(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, replacing it by the default value ${n.default}`);else throw Error(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, and no default value was set`)}extractColor(e,t,n){if(!e)return n?{rgb:n}:void 0;let r=this.extractAttr(e,`theme`)?.asString(),i;if(r!==void 0){if(!t||!t.clrScheme)throw Error(`Color referencing a theme but no theme was provided`);i=this.getThemeColor(r,t.clrScheme)}else i=this.extractAttr(e,`rgb`)?.asString(),i=i===`FF000000`?void 0:i;return{rgb:i||n,auto:this.extractAttr(e,`auto`)?.asBool(),indexed:this.extractAttr(e,`indexed`)?.asNum(),tint:this.extractAttr(e,`tint`)?.asNum()}}getTargetXmlFile(e){if(!e)throw Error(`Undefined target file`);let t=this.processRelationshipTargetName(e.target),n=this.getListOfXMLFiles().find(e=>e.file.fileName.endsWith(t));if(!n||!n.file)throw Error(`Cannot find target file`);return n}getTargetImageFile(e){if(!e)throw Error(`Undefined target file`);let t=this.processRelationshipTargetName(e.target),n=this.xlsxFileStructure.images.find(e=>e.fileName.endsWith(t));if(!n)throw Error(`Cannot find target file`);return n}querySelector(e,t){let n=Fx(t);return e.querySelector(n)}querySelectorAll(e,t){let n=Fx(t);return e.querySelectorAll(n)}getThemeColor(e,t){switch(e){case`0`:return`FFFFFF`;case`1`:return`000000`;case`2`:return t[3].value;case`3`:return t[2].value;default:return t[e].value}}processRelationshipTargetName(e){return e.replace(/\.+\//,``)}},Rx=class extends Lx{getExternalBook(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`externalBook`},e=>({rId:this.extractAttr(e,`r:id`,{required:!0}).asString(),sheetNames:this.mapOnElements({parent:e,query:`sheetName`},e=>this.extractAttr(e,`val`,{required:!0}).asString()),datasets:this.extractExternalSheetData(e)}))[0]}extractExternalSheetData(e){return this.mapOnElements({parent:e,query:`sheetData`},e=>{let t=this.mapOnElements({parent:e,query:`cell`},e=>({xc:this.extractAttr(e,`r`,{required:!0}).asString(),value:this.extractChildTextContent(e,`v`,{required:!0})})),n={};for(let e of t)n[e.xc]=e.value;return{sheetId:this.extractAttr(e,`sheetId`,{required:!0}).asNum(),data:n}})}},zx=class extends Lx{getTheme(){return{clrScheme:this.mapOnElements({query:`a:clrScheme`,parent:this.rootFile.file.xml,children:!0},e=>({name:e.tagName,value:this.extractChildAttr(e,0,`val`,{required:!0,default:Rp}).asString(),lastClr:this.extractChildAttr(e,0,`lastClr`,{default:Rp}).asString()}))}}getSharedStrings(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`si`},e=>this.mapOnElements({parent:e,query:`t`},e=>this.extractTextContent(e)||``).join(``))}getNamedRanges(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`definedNames definedName`},e=>({name:this.extractAttr(e,`name`,{required:!0}).asString(),value:this.extractTextContent(e)||``}))}},Bx=class extends Lx{theme;constructor(e,t,n,r){super(e,t,n),this.theme=r}extractConditionalFormattings(){let e=this.mapOnElements({parent:this.rootFile.file.xml,query:`worksheet > conditionalFormatting`},e=>({sqref:this.extractAttr(e,`sqref`,{required:!0}).asString().split(` `),pivot:this.extractAttr(e,`pivot`)?.asBool(),cfRules:this.extractCFRules(e,this.theme)}));return e.push(...this.mapOnElements({parent:this.rootFile.file.xml,query:`extLst x14:conditionalFormatting`},e=>({sqref:this.extractChildTextContent(e,`xm:sqref`,{required:!0}).split(` `),pivot:this.extractAttr(e,`xm:pivot`)?.asBool(),cfRules:this.extractCFRules(e,this.theme)}))),e}extractCFRules(e,t){return this.mapOnElements({parent:e,query:`cfRule, x14:cfRule`},e=>({type:this.extractAttr(e,`type`,{required:!0}).asString(),priority:this.extractAttr(e,`priority`,{required:!0}).asNum(),colorScale:this.extractCfColorScale(e,t),formula:this.extractCfFormula(e),iconSet:this.extractCfIconSet(e),dxfId:this.extractAttr(e,`dxfId`)?.asNum(),stopIfTrue:this.extractAttr(e,`stopIfTrue`)?.asBool(),aboveAverage:this.extractAttr(e,`aboveAverage`)?.asBool(),percent:this.extractAttr(e,`percent`)?.asBool(),bottom:this.extractAttr(e,`bottom`)?.asBool(),operator:this.extractAttr(e,`operator`)?.asString(),text:this.extractAttr(e,`text`)?.asString(),timePeriod:this.extractAttr(e,`timePeriod`)?.asString(),rank:this.extractAttr(e,`rank`)?.asNum(),stdDev:this.extractAttr(e,`stdDev`)?.asNum(),equalAverage:this.extractAttr(e,`equalAverage`)?.asBool(),dataBar:this.extractCfDataBar(e,t)}))}extractCfFormula(e){return this.mapOnElements({parent:e,query:`formula`},e=>this.extractTextContent(e,{required:!0}))}extractCfColorScale(e,t){let n=this.querySelector(e,`colorScale`);if(n)return{colors:this.mapOnElements({parent:n,query:`color`},e=>this.extractColor(e,t,`ffffff`)),cfvos:this.extractCFVos(n)}}extractCfDataBar(e,t){let n=this.querySelector(e,`dataBar`);if(n)return{color:this.extractColor(n.querySelector(`color`),t,`EFF7FF`),cfvos:this.extractCFVos(n)}}extractCfIconSet(e){let t=this.querySelector(e,`iconSet, x14:iconSet`);if(t)return{iconSet:this.extractAttr(t,`iconSet`,{default:`3TrafficLights1`}).asString(),showValue:this.extractAttr(t,`showValue`,{default:!0}).asBool(),percent:this.extractAttr(t,`percent`,{default:!0}).asBool(),reverse:this.extractAttr(t,`reverse`)?.asBool(),custom:this.extractAttr(t,`custom`)?.asBool(),cfvos:this.extractCFVos(t),cfIcons:this.extractCfIcons(t)}}extractCfIcons(e){let t=this.mapOnElements({parent:e,query:`cfIcon, x14:cfIcon`},e=>({iconSet:this.extractAttr(e,`iconSet`,{required:!0}).asString(),iconId:this.extractAttr(e,`iconId`,{required:!0}).asNum()}));return t.length===0?void 0:t}extractCFVos(e){return this.mapOnElements({parent:e,query:`cfvo, x14:cfvo`},e=>({type:this.extractAttr(e,`type`,{required:!0}).asString(),gte:this.extractAttr(e,`gte`,{default:!0})?.asBool(),value:e.attributes.val?this.extractAttr(e,`val`)?.asString():this.extractChildTextContent(e,`f, xm:f`)}))}},Vx=class extends Lx{theme;constructor(e,t,n,r){super(e,t,n),this.theme=r}extractDataValidations(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`worksheet > dataValidations > dataValidation`},e=>({type:this.extractAttr(e,`type`,{required:!0}).asString(),operator:this.extractAttr(e,`operator`,{default:`between`})?.asString(),sqref:this.extractAttr(e,`sqref`,{required:!0}).asString().split(` `),errorStyle:this.extractAttr(e,`errorStyle`)?.asString(),formula1:this.extractDataValidationFormula(e,1)[0],formula2:this.extractDataValidationFormula(e,2)[0],showErrorMessage:this.extractAttr(e,`showErrorMessage`)?.asBool(),errorTitle:this.extractAttr(e,`errorTitle`)?.asString(),error:this.extractAttr(e,`error`)?.asString(),showInputMessage:this.extractAttr(e,`showInputMessage`)?.asBool(),promptTitle:this.extractAttr(e,`promptTitle`)?.asString(),prompt:this.extractAttr(e,`prompt`)?.asString(),allowBlank:this.extractAttr(e,`allowBlank`)?.asBool()}))}extractDataValidationFormula(e,t){return this.mapOnElements({parent:e,query:`formula${t}`},e=>this.extractTextContent(e,{required:!0}))}};let Hx={bg1:`lt1`,tx1:`dk1`,bg2:`lt2`,tx2:`dk2`};var Ux=class extends Lx{extractChart(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`c:chartSpace`},e=>{let t=this.getChartType(e);if(!Pv[t])throw Error(`Unsupported chart type ${t}`);if(Pv[t]===`combo`)return this.extractComboChart(e);let n=this.mapOnElements({parent:e,query:`c:chart > c:title a:t`},e=>e.textContent||``).join(``),r=this.extractTitleStyle(e,`c:chart > c:title a:p a:pPr a:defRPr`),i=this.extractChildAttr(e,`c:grouping`,`val`,{default:`clustered`}).asString(),a=this.extractChildAttr(e,`c:barDir`,`val`,{default:`col`}).asString(),o=this.extractChildAttr(e,`c:holeSize`,`val`,{default:`0`}).asNum(),s=[...this.querySelectorAll(e,`c:chart c:showVal`)].some(e=>e.attributes.getNamedItem(`val`)?.value===`1`),c=[];if(Pv[t]===`pie`){let t=this.querySelector(e,`c:ser`);if(t){let e=Array.from(this.querySelectorAll(t,`c:dPt`)),n={};for(let t of e){let e=this.extractChildAttr(t,`c:idx`,`val`,{required:!0}).asNum(),r=this.extractDrawingFillColor(t);typeof e==`number`&&r&&(n[e]=r)}if(Object.keys(n).length){let e=Math.max(...Object.keys(n).map(Number));for(let t=0;t<=e;++t)c.push(n[t]||``)}}}return{title:{text:n,...r},type:Pv[t],axesDesign:this.extractAxesDesign(e),dataSets:this.extractChartDatasets(this.querySelectorAll(e,`c:${t}`),t),labelRange:this.extractLabelRange(t,e),backgroundColor:this.extractChildAttr(e,`c:chartSpace > c:spPr a:srgbClr`,`val`,{default:`ffffff`}).asString(),legendPosition:Nv[this.extractChildAttr(e,`c:legendPos`,`val`,{default:`none`}).asString()],stacked:i===`stacked`,fontColor:`000000`,horizontal:a===`bar`,isDoughnut:o>0,pieHolePercentage:o,showValues:s,slicesColors:c.length?c:void 0}})[0]}extractLabelRange(e,t){return e===`scatterChart`?this.extractChildTextContent(t,`c:ser c:strRef c:f`)||this.extractChildTextContent(t,`c:ser c:numRef c:f`):this.extractChildTextContent(t,`c:ser c:cat c:f`)}extractComboChart(e){let t=this.mapOnElements({parent:e,query:`c:title a:t`},e=>e.textContent||``).join(``),n=this.extractTitleStyle(e,`c:chart > c:title a:p a:pPr a:defRPr`),r=this.extractChildAttr(e,`c:grouping`,`val`,{default:`clustered`}).asString(),i=[...this.querySelectorAll(e,`c:chart c:showVal`)].some(e=>e.attributes.getNamedItem(`val`)?.value===`1`);return{title:{text:t,...n},type:`combo`,axesDesign:this.extractAxesDesign(e),dataSets:[...this.extractChartDatasets(this.querySelectorAll(e,`c:barChart`),`comboChart`),...this.extractChartDatasets(this.querySelectorAll(e,`c:lineChart`),`comboChart`)],labelRange:this.extractChildTextContent(e,`c:ser c:cat c:f`),backgroundColor:this.extractChildAttr(e,`c:chartSpace > c:spPr a:srgbClr`,`val`,{default:`ffffff`}).asString(),legendPosition:Nv[this.extractChildAttr(e,`c:legendPos`,`val`,{default:`none`}).asString()],stacked:r===`stacked`,fontColor:`000000`,showValues:i}}extractTitleStyle(e,t){let n=this.querySelector(e,t);if(!n)return{};let r=n.getAttribute(`b`),i=r===`1`||r===`true`?!0:void 0,a=n.getAttribute(`i`),o=a===`1`||a===`true`?!0:void 0,s=n.getAttribute(`sz`);return{bold:i,italic:o,fontSize:s?Math.round(parseInt(s)/100):void 0,color:this.extractDrawingFillColor(n)}}extractDrawingFillColor(e){let t=this.querySelector(e,`a:solidFill a:srgbClr`);if(t){let e=t.getAttribute(`val`);return e&&Xf(e)?Yf(e):void 0}let n=this.querySelector(e,`a:solidFill a:schemeClr`);if(n)return this.resolveSchemeColor(n)}resolveSchemeColor(e){let t=e.getAttribute(`val`);if(!t)return;let n=this.xlsxFileStructure.theme;if(!n)return;let r=Hx[t]??t,i=this.querySelector(n.file.xml,`a:clrScheme a:${r}`);if(!i)return;let a,o=this.querySelector(i,`a:srgbClr`);if(o){let e=o.getAttribute(`val`);a=e&&Xf(e)?Yf(e):void 0}else{let e=this.querySelector(i,`a:sysClr`);if(e){let t=e.getAttribute(`lastClr`);a=t&&Xf(t)?Yf(t):void 0}}if(!a)return;let s=this.querySelector(e,`a:lumMod`)?.getAttribute(`val`),c=this.querySelector(e,`a:lumOff`)?.getAttribute(`val`);if(s!==void 0||c!==void 0){let e=s?parseInt(s)/1e5:1,t=c?parseInt(c)/1e5:0;a=Gy(a,e,t)}return a}extractAxisTitleDesign(e){if(e===null)return;let t=this.mapOnElements({parent:e,query:`c:title a:t`},e=>e.textContent||``).join(``);if(t)return{text:t,...this.extractTitleStyle(e,`c:title a:p a:pPr a:defRPr`)}}extractAxesDesign(e){let t=this.querySelector(e,`c:catAx`),n=this.querySelector(e,`c:valAx`),r=t?this.extractChildAttr(t,`c:axPos`,`val`)?.asString():void 0,i=r===`l`||r===`r`,a=i?n:t,o=i?t:n,s=this.extractAxisTitleDesign(a),c=this.extractAxisTitleDesign(o);if(!s&&!c)return;let l={};return s&&(l.x={title:s}),c&&(l.y={title:c}),l}extractChartDatasets(e,t){return Array.from(e).map(e=>t===`scatterChart`?this.extractScatterChartDatasets(e):this.mapOnElements({parent:e,query:`c:ser`},e=>{let t={},n=this.extractChildTextContent(e,`c:tx c:f`);if(n)t={reference:n};else{let n=this.extractChildTextContent(e,`c:tx c:v`);n&&(t={text:n})}let r=this.querySelectorAll(e,`c:spPr`),i=r.length?this.extractDrawingFillColor(r[0]):void 0;return{label:t,range:this.extractChildTextContent(e,`c:val c:f`,{required:!0}),backgroundColor:i,trend:this.extractChartTrendline(e)}})).flat()}extractChartTrendline(e){let t=this.querySelector(e,`c:trendline`);if(!t)return;let n=this.extractChildAttr(t,`c:trendlineType`,`val`),r=this.extractDrawingFillColor(t);return{type:n?n.asString():void 0,order:this.extractChildAttr(t,`c:order`,`val`)?.asNum(),window:this.extractChildAttr(t,`c:period`,`val`)?.asNum(),color:r}}extractScatterChartDatasets(e){return this.mapOnElements({parent:e,query:`c:ser`},e=>{let t={},n=this.querySelectorAll(e,`c:spPr`),r=n.length?this.extractDrawingFillColor(n[0]):void 0,i=this.extractChildTextContent(e,`c:tx c:f`);if(i)t={reference:i};else{let n=this.extractChildTextContent(e,`c:tx c:v`);n&&(t={text:n})}return{label:t,range:this.extractChildTextContent(e,`c:yVal c:f`,{required:!0}),trend:this.extractChartTrendline(e),backgroundColor:r}})}getChartType(e){let t=this.querySelector(e,`c:plotArea`);if(!t)throw Error(`Missing plot area in the chart definition.`);let n;for(let e of t.children){let t=Nx(e.tagName);ov.some(e=>e===t)&&(n?n!==t&&(n=`comboChart`):n=t)}if(n)return n;throw Error(`Unknown chart type`)}};let Wx=`oneCellAnchor`,Gx=`twoCellAnchor`;var Kx=class extends Lx{extractFigures(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`xdr:wsDr`,children:!0},e=>{let t=Nx(e.tagName),n=this.extractFigureAnchorsByType(e,t),r=this.querySelector(e,`c:chart`),i=this.querySelector(e,`a:blip`);if(!r&&!i)throw Error(`Only chart and image figures are currently supported.`);return{anchors:n,data:r?this.extractChart(r):this.extractImage(e),figureSize:t===Wx?this.extractFigureSizeFromSizeTag(e,`xdr:ext`):void 0}})}extractFigureAnchorsByType(e,t){switch(t){case Wx:return[this.extractFigureAnchor(`xdr:from`,e)];case Gx:return[this.extractFigureAnchor(`xdr:from`,e),this.extractFigureAnchor(`xdr:to`,e)];default:throw Error(`${t} is not supported for xlsx drawings. `)}}extractFigureSizeFromSizeTag(e,t){let n=this.querySelector(e,t);if(!n)throw Error(`Missing size element '${t}'`);return{cx:this.extractAttr(n,`cx`,{required:!0}).asNum(),cy:this.extractAttr(n,`cy`,{required:!0}).asNum()}}extractFigureAnchor(e,t){let n=this.querySelector(t,e);if(!n)throw Error(`Missing anchor element ${e}`);return{col:Number(this.extractChildTextContent(n,`xdr:col`,{required:!0})),colOffset:Number(this.extractChildTextContent(n,`xdr:colOff`,{required:!0})),row:Number(this.extractChildTextContent(n,`xdr:row`,{required:!0})),rowOffset:Number(this.extractChildTextContent(n,`xdr:rowOff`,{required:!0}))}}extractChart(e){let t=this.extractAttr(e,`r:id`,{required:!0}).asString(),n=new Ux(this.getTargetXmlFile(this.relationships[t]),this.xlsxFileStructure,this.warningManager).extractChart();if(!n)throw Error(`Unable to extract chart definition`);return n}extractImage(e){let t=this.querySelector(e,`a:blip`),n=this.extractAttr(t,`r:embed`,{required:!0}).asString(),r=this.getTargetImageFile(this.relationships[n]);if(!r)throw Error(`Unable to extract image`);let i=r.fileName.split(`.`).at(-1),a=Nx(e.tagName),o=a===Gx?this.querySelector(e,`a:xfrm`):e,s=a===Gx?`a:ext`:`xdr:ext`,c=this.extractFigureSizeFromSizeTag(o,s);return{imageSrc:r.imageSrc,mimetype:i?Vv[i]:void 0,size:c}}},qx=class extends Lx{getPivotTable(){return this.mapOnElements({query:`:root`,parent:this.rootFile.file.xml},e=>({name:this.extractAttr(e,`name`,{required:!0}).asString(),rowGrandTotals:this.extractAttr(e,`rowGrandTotals`,{default:!0}).asBool(),location:this.extractPivotLocation(e),style:this.extractPivotStyleInfo(e)}))[0]}extractPivotLocation(e){return this.mapOnElements({query:`location`,parent:e},e=>({ref:this.extractAttr(e,`ref`,{required:!0}).asString(),firstHeaderRow:this.extractAttr(e,`firstHeaderRow`,{required:!0}).asNum(),firstDataRow:this.extractAttr(e,`firstDataRow`,{required:!0}).asNum(),firstDataCol:this.extractAttr(e,`firstDataCol`,{required:!0}).asNum()}))[0]}extractPivotStyleInfo(e){return this.mapOnElements({query:`pivotTableStyleInfo`,parent:e},e=>({name:this.extractAttr(e,`name`,{required:!0}).asString(),showRowHeaders:this.extractAttr(e,`showRowHeaders`,{required:!0}).asBool(),showColHeaders:this.extractAttr(e,`showColHeaders`,{required:!0}).asBool(),showRowStripes:this.extractAttr(e,`showRowStripes`,{required:!0}).asBool(),showColStripes:this.extractAttr(e,`showColStripes`,{required:!0}).asBool(),showLastColumn:this.extractAttr(e,`showLastColumn`)?.asBool()}))[0]}},Jx=class extends Lx{getTable(){return this.mapOnElements({query:`table`,parent:this.rootFile.file.xml},e=>({displayName:this.extractAttr(e,`displayName`,{required:!0}).asString(),name:this.extractAttr(e,`name`)?.asString(),id:this.extractAttr(e,`id`,{required:!0}).asString(),ref:this.extractAttr(e,`ref`,{required:!0}).asString(),headerRowCount:this.extractAttr(e,`headerRowCount`,{default:1}).asNum(),totalsRowCount:this.extractAttr(e,`totalsRowCount`,{default:0}).asNum(),cols:this.extractTableCols(e),style:this.extractTableStyleInfo(e),autoFilter:this.extractTableAutoFilter(e)}))[0]}extractTableCols(e){return this.mapOnElements({query:`tableColumn`,parent:e},e=>({id:this.extractAttr(e,`id`,{required:!0}).asString(),name:this.extractAttr(e,`name`,{required:!0}).asString(),colFormula:this.extractChildTextContent(e,`calculatedColumnFormula`)}))}extractTableStyleInfo(e){return this.mapOnElements({query:`tableStyleInfo`,parent:e},e=>({name:this.extractAttr(e,`name`)?.asString(),showFirstColumn:this.extractAttr(e,`showFirstColumn`)?.asBool(),showLastColumn:this.extractAttr(e,`showLastColumn`)?.asBool(),showRowStripes:this.extractAttr(e,`showRowStripes`)?.asBool(),showColumnStripes:this.extractAttr(e,`showColumnStripes`)?.asBool()}))[0]}extractTableAutoFilter(e){return this.mapOnElements({query:`autoFilter`,parent:e},e=>({columns:this.extractFilterColumns(e),zone:this.extractAttr(e,`ref`,{required:!0}).asString()}))[0]}extractFilterColumns(e){return this.mapOnElements({query:`tableColumn`,parent:e},t=>({colId:this.extractAttr(e,`colId`,{required:!0}).asNum(),hiddenButton:this.extractAttr(e,`hiddenButton`,{default:!1}).asBool(),filters:this.extractSimpleFilter(t)}))}extractSimpleFilter(e){return this.mapOnElements({query:`filter`,parent:e},e=>({val:this.extractAttr(e,`val`,{required:!0}).asString()}))}},Yx=class extends Lx{theme;constructor(e,t,n,r){super(e,t,n),this.theme=r}getSheet(){return this.mapOnElements({query:`worksheet`,parent:this.rootFile.file.xml},e=>{let t=this.getSheetWorkbookInfo();return{sheetName:this.extractSheetName(),sheetViews:this.extractSheetViews(e),sheetFormat:this.extractSheetFormat(e),sheetProperties:this.extractSheetProperties(e),cols:this.extractCols(e),rows:this.extractRows(e),sharedFormulas:this.extractSharedFormulas(e),merges:this.extractMerges(e),cfs:this.extractConditionalFormats(),dataValidations:this.extractDataValidations(),figures:this.extractFigures(e),hyperlinks:this.extractHyperLinks(e),tables:this.extractTables(e),pivotTables:this.extractPivotTables(),isVisible:t.state===`visible`,isLocked:this.extractProtection(e)}})[0]}extractSheetViews(e){return this.mapOnElements({parent:e,query:`sheetView`},e=>{let t=this.querySelector(e,`pane`);return{tabSelected:this.extractAttr(e,`tabSelected`,{default:!1}).asBool(),showFormulas:this.extractAttr(e,`showFormulas`,{default:!1}).asBool(),showGridLines:this.extractAttr(e,`showGridLines`,{default:!0}).asBool(),showRowColHeaders:this.extractAttr(e,`showRowColHeaders`,{default:!0}).asBool(),pane:{xSplit:t?this.extractAttr(t,`xSplit`,{default:0}).asNum():0,ySplit:t?this.extractAttr(t,`ySplit`,{default:0}).asNum():0}}})}extractSheetName(){let e=Ry(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find(t=>t.target===e).id;for(let e of this.querySelectorAll(this.xlsxFileStructure.workbook.file.xml,`sheet`))if(e.attributes[`r:id`].value===t)return e.attributes.name.value;throw Error(`Missing sheet name`)}getSheetWorkbookInfo(){let e=Ry(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find(t=>t.target===e).id,n=this.mapOnElements({parent:this.xlsxFileStructure.workbook.file.xml,query:`sheet`},e=>({relationshipId:this.extractAttr(e,`r:id`,{required:!0}).asString(),sheetId:this.extractAttr(e,`sheetId`,{required:!0}).asString(),sheetName:this.extractAttr(e,`name`,{required:!0}).asString(),state:this.extractAttr(e,`state`,{default:`visible`}).asString()})).find(e=>e.relationshipId===t);if(!n)throw Error(`Cannot find corresponding workbook sheet`);return n}extractConditionalFormats(){return new Bx(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractConditionalFormattings()}extractDataValidations(){return new Vx(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractDataValidations()}extractFigures(e){return this.mapOnElements({parent:e,query:`drawing`},e=>{let t=this.extractAttr(e,`r:id`,{required:!0})?.asString();return new Kx(this.getTargetXmlFile(this.relationships[t]),this.xlsxFileStructure,this.warningManager).extractFigures()})[0]||[]}extractTables(e){return this.mapOnElements({query:`tablePart`,parent:e},e=>{let t=this.extractAttr(e,`r:id`,{required:!0})?.asString();return new Jx(this.getTargetXmlFile(this.relationships[t]),this.xlsxFileStructure,this.warningManager).getTable()})}extractPivotTables(){try{return Object.values(this.relationships).filter(e=>e.type.endsWith(`pivotTable`)).map(e=>new qx(this.getTargetXmlFile(e),this.xlsxFileStructure,this.warningManager).getPivotTable())}catch(e){return this.catchErrorOnElement(e),[]}}extractMerges(e){return this.mapOnElements({parent:e,query:`mergeCell`},e=>this.extractAttr(e,`ref`,{required:!0}).asString())}extractSheetFormat(e){let t=this.querySelector(e,`sheetFormatPr`);if(t)return{defaultColWidth:this.extractAttr(t,`defaultColWidth`,{default:`8.43`}).asNum(),defaultRowHeight:this.extractAttr(t,`defaultRowHeight`,{default:`12.75`}).asNum()}}extractSheetProperties(e){let t=this.querySelector(e,`sheetPr`);if(t)return{outlinePr:this.extractSheetOutlineProperties(t),tabColor:this.extractColor(this.querySelector(t,`tabColor`),this.theme)}}extractSheetOutlineProperties(e){let t=this.querySelector(e,`outlinePr`);if(t)return{summaryBelow:this.extractAttr(t,`summaryBelow`,{default:!0}).asBool(),summaryRight:this.extractAttr(t,`summaryRight`,{default:!0}).asBool()}}extractCols(e){return this.mapOnElements({parent:e,query:`cols col`},e=>({width:this.extractAttr(e,`width`)?.asNum(),customWidth:this.extractAttr(e,`customWidth`)?.asBool(),bestFit:this.extractAttr(e,`bestFit`)?.asBool(),hidden:this.extractAttr(e,`hidden`)?.asBool(),min:this.extractAttr(e,`min`,{required:!0})?.asNum(),max:this.extractAttr(e,`max`,{required:!0})?.asNum(),styleIndex:this.extractAttr(e,`style`)?.asNum(),outlineLevel:this.extractAttr(e,`outlineLevel`)?.asNum(),collapsed:this.extractAttr(e,`collapsed`)?.asBool()}))}extractRows(e){let t=new Set;return this.mapOnElements({parent:e,query:`sheetData row`},e=>({index:this.extractAttr(e,`r`,{required:!0})?.asNum(),cells:this.extractCells(e,t),height:this.extractAttr(e,`ht`)?.asNum(),customHeight:this.extractAttr(e,`customHeight`)?.asBool(),hidden:this.extractAttr(e,`hidden`)?.asBool(),styleIndex:this.extractAttr(e,`s`)?.asNum(),outlineLevel:this.extractAttr(e,`outlineLevel`)?.asNum(),collapsed:this.extractAttr(e,`collapsed`)?.asBool()}))}extractCells(e,t){return this.mapOnElements({parent:e,query:`c`},e=>{let n=this.extractAttr(e,`r`,{required:!0})?.asString(),r=this.extractCellFormula(e);if(r?.ref&&r.sharedIndex===void 0){let e=Un(r.ref);for(let{col:r,row:i}of ur(e)){let e=E(r,i);e!==n&&t.add(e)}}let i=t.has(n);return{xc:n,styleIndex:this.extractAttr(e,`s`)?.asNum(),type:wv[this.extractAttr(e,`t`,{default:`n`})?.asString()],value:i?void 0:this.extractChildTextContent(e,`v`)??void 0,formula:i?void 0:r}})}extractCellFormula(e){let t=this.querySelector(e,`f`);if(!t)return;let n=this.extractTextContent(t),r=this.extractAttr(t,`si`)?.asNum(),i=this.extractAttr(t,`ref`)?.asString();if(!((n===void 0||n.trim()===``)&&r===void 0))return{content:n,sharedIndex:r,ref:i}}extractHyperLinks(e){return this.mapOnElements({parent:e,query:`hyperlink`},e=>{let t=this.extractAttr(e,`r:id`)?.asString();return{xc:this.extractAttr(e,`ref`,{required:!0})?.asString(),location:this.extractAttr(e,`location`)?.asString(),display:this.extractAttr(e,`display`)?.asString(),relTarget:t?this.relationships[t].target:void 0}})}extractSharedFormulas(e){let t=this.querySelectorAll(e,`f[si][ref]`),n={};for(let e of t){let t=this.extractAttr(e,`si`,{required:!0}).asNum();n[t]=this.extractTextContent(e,{required:!0})}let r=[];for(let e=0;e<Object.keys(n).length;e++)n[e]?r.push(n[e]):(this.warningManager.addParsingWarning(`Missing shared formula ${e}, replacing it by empty formula`),r.push(``));return r}extractProtection(e){let t=this.querySelector(e,`sheetProtection`);return t?this.extractAttr(t,`sheet`,{default:!1}).asBool():!1}},Xx=class extends Lx{theme;constructor(e,t,n){super(e.styles,e,t),this.theme=n}getNumFormats(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`numFmt`},e=>this.extractNumFormats(e))}extractNumFormats(e){return{id:this.extractAttr(e,`numFmtId`,{required:!0}).asNum(),format:this.extractAttr(e,`formatCode`,{required:!0,default:``}).asString()}}getFonts(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`font`},e=>this.extractFont(e))}extractFont(e){let t=this.extractChildAttr(e,`name`,`val`,{default:`Arial`}).asString(),n=this.extractChildAttr(e,`sz`,`val`,{default:qe.toString()}).asNum(),r=this.extractColor(this.querySelector(e,`color`),this.theme),i=this.querySelector(e,`i`)||void 0,a=i&&i.attributes.val?.value!==`0`,o=this.querySelector(e,`b`)||void 0,s=o&&o.attributes.val?.value!==`0`,c=this.querySelector(e,`strike`)||void 0,l=c&&c.attributes.val?.value!==`0`,u=this.querySelector(e,`u`)||void 0;return{name:t,size:n,color:r,italic:a,bold:s,underline:u&&u.attributes.val?.value!==`none`,strike:l}}getFills(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`fill`},e=>this.extractFill(e))}extractFill(e){let t=e.children[0];return t.tagName===`patternFill`?{patternType:t.attributes.patternType?.value,bgColor:this.extractColor(this.querySelector(t,`bgColor`),this.theme),fgColor:this.extractColor(this.querySelector(t,`fgColor`),this.theme)}:{patternType:`solid`,fgColor:this.extractColor(this.querySelectorAll(t,`color`)[1],this.theme)}}getBorders(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`border`},e=>this.extractBorder(e))}extractBorder(e){let t={left:this.extractSingleBorder(e,`left`,this.theme),right:this.extractSingleBorder(e,`right`,this.theme),top:this.extractSingleBorder(e,`top`,this.theme),bottom:this.extractSingleBorder(e,`bottom`,this.theme),diagonal:this.extractSingleBorder(e,`diagonal`,this.theme)};return t.diagonal&&(t.diagonalUp=this.extractAttr(e,`diagonalUp`)?.asBool(),t.diagonalDown=this.extractAttr(e,`diagonalDown`)?.asBool()),t}extractSingleBorder(e,t,n){let r=this.querySelector(e,t);if(!(!r||!r.attributes.style))return{style:this.extractAttr(r,`style`,{required:!0,default:`thin`}).asString(),color:this.extractColor(r.children[0],n,`000000`)}}extractAlignment(e){return{horizontal:this.extractAttr(e,`horizontal`,{default:`general`}).asString(),vertical:this.extractAttr(e,`vertical`,{default:`bottom`}).asString(),textRotation:this.extractAttr(e,`textRotation`)?.asNum(),wrapText:this.extractAttr(e,`wrapText`)?.asBool(),indent:this.extractAttr(e,`indent`)?.asNum(),relativeIndent:this.extractAttr(e,`relativeIndent`)?.asNum(),justifyLastLine:this.extractAttr(e,`justifyLastLine`)?.asBool(),shrinkToFit:this.extractAttr(e,`shrinkToFit`)?.asBool(),readingOrder:this.extractAttr(e,`readingOrder`)?.asNum()}}getDxfs(){return this.mapOnElements({query:`dxf`,parent:this.rootFile.file.xml},e=>{let t=this.querySelector(e,`font`),n=this.querySelector(e,`fill`),r=this.querySelector(e,`border`),i=this.querySelector(e,`numFmt`),a=this.querySelector(e,`alignment`);return{font:t?this.extractFont(t):void 0,fill:n?this.extractFill(n):void 0,numFmt:i?this.extractNumFormats(i):void 0,alignment:a?this.extractAlignment(a):void 0,border:r?this.extractBorder(r):void 0}})}getStyles(){return this.mapOnElements({query:`cellXfs xf`,parent:this.rootFile.file.xml},e=>{let t=this.querySelector(e,`alignment`);return{fontId:this.extractAttr(e,`fontId`,{required:!0,default:0}).asNum(),fillId:this.extractAttr(e,`fillId`,{required:!0,default:0}).asNum(),borderId:this.extractAttr(e,`borderId`,{required:!0,default:0}).asNum(),numFmtId:this.extractAttr(e,`numFmtId`,{required:!0,default:0}).asNum(),alignment:t?this.extractAlignment(t):void 0}})}};function Zx(e,t){return Qx($x(e,t),t)}function Qx(e,t){let n=[];for(let r of e){let e=eS(r,t);n.push({file:{fileName:r,xml:t[r]},rels:e?{fileName:e,xml:t[e]}:void 0})}return n}function $x(e,t){let n=t[`[Content_Types].xml`].querySelectorAll(`Override[ContentType="${e}"]`),r=[];for(let e of n){let t=e?.attributes.PartName.value;r.push(t.substring(1))}return r}function eS(e,t){if(e===`[Content_Types].xml`)return`_rels/.rels`;let n=``,r=e.split(`/`);for(let e=0;e<r.length-1;e++)n+=r[e]+`/`;return n+=`_rels/`,n+=r[r.length-1]+`.rels`,t[n]||(n=void 0),n}var tS=class{warningManager;xmls;images;constructor(e){this.warningManager=new my,this.xmls={},this.images=[];for(let t of Object.keys(e))if(t.endsWith(`.xml`)||t.endsWith(`.rels`)){let n=Px(e[t]);this.xmls[t]=Ox(new av(n))}else t.includes(`media/image`)&&this.images.push({fileName:t,imageSrc:e[t].imageSrc})}convertXlsx(){let e=this.getXlsxData();return this.convertImportedData(e)}getXlsxData(){let e=this.buildXlsxFileStructure(),t=e.theme?new zx(e.theme,e,this.warningManager).getTheme():void 0,n=e.sharedStrings?new zx(e.sharedStrings,e,this.warningManager).getSharedStrings():[],r=new zx(e.workbook,e,this.warningManager).getNamedRanges(),i=e.sheets.sort((e,t)=>e.file.fileName.localeCompare(t.file.fileName,void 0,{numeric:!0})).map(n=>new Yx(n,e,this.warningManager,t).getSheet()),a=e.externalLinks.map(t=>new Rx(t,e,this.warningManager).getExternalBook()),o=new Xx(e,this.warningManager,t);return{fonts:o.getFonts(),fills:o.getFills(),borders:o.getBorders(),dxfs:o.getDxfs(),numFmts:o.getNumFormats(),styles:o.getStyles(),sheets:i,sharedStrings:n,externalBooks:a,chartIds:[],imageIds:[],namedRanges:r}}buildXlsxFileStructure(){let e={sheets:Zx(Up.sheet,this.xmls),workbook:Zx(Up.workbook,this.xmls)[0]||Zx(Up.macroEnabledWorkbook,this.xmls)[0]||Zx(Up.templateWorkbook,this.xmls)[0]||Zx(Up.macroEnabledTemplateWorkbook,this.xmls)[0]||Zx(Up.excelAddInWorkbook,this.xmls)[0],styles:Zx(Up.styles,this.xmls)[0],sharedStrings:Zx(Up.sharedStrings,this.xmls)[0],theme:Zx(Up.themes,this.xmls)[0],charts:Zx(Up.chart,this.xmls),figures:Zx(Up.drawing,this.xmls),tables:Zx(Up.table,this.xmls),pivots:Zx(Up.pivot,this.xmls),externalLinks:Zx(Up.externalLink,this.xmls),images:this.images};if(!e.workbook.rels)throw Error(P(`Cannot find workbook relations file`));return e}convertImportedData(e){let t={version:`18.4.2`,sheets:Vb(e,this.warningManager),styles:tb(e,this.warningManager),formats:rb(e,this.warningManager),borders:$y(e,this.warningManager),namedRanges:dv(e,this.warningManager),revisionId:Xe};return _x(t,e),Object.keys(e.styles).map(t=>{e.styles[t]=Zt(e.styles[t])}),t}};function nS(e){let t=!1,n=!0;return ss(e,e=>(t=!0,n&&=e,n)),{foundBoolean:t,result:n}}function rS(e){let t=!1,n=!1;return ss(e,e=>(t=!0,n||=e,!n)),{foundBoolean:t,result:n}}function iS(e,t){return es(e,(e,t)=>e+t,0,t)}function aS(e){return $o(e,(e,t)=>vs(t)?e.add(t?.value):e,new Set).size}function oS(e,t){if(!e)throw new I(t)}function sS(e,t=P(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)){if(e===0)throw new ko(t)}function cS(e){return e.length===1||e[0].length===1}function lS(...e){if(e.every(ht)){let t=e[0].length,n=e[0][0].length;for(let r of e)if(r.length!==t||r[0].length!==n)return!1;return!0}return!e.some(e=>Array.isArray(e)&&(e.length!==1||e[0].length!==1))}function uS(e){return e.length===e[0].length}let dS=e=>P(`The function [[FUNCTION_NAME]] expects a number value to be greater than or equal to 1, but receives %s.`,e);function fS(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=Array(e).fill(0),t[n][n]=1;return t}function pS(e){if(e.length<1||e[0].length<1)throw Error(`invertMatrix: an empty matrix cannot be inverted.`);if(e.length!==e[0].length)throw Error(`invertMatrix: only square matrices are invertible`);let t=1,n=e.length,r=fS(n),i=e.map(e=>e.slice());for(let e=0;e<n;e++){let a=i[e][e];if(a===0){for(let a=e+1;a<n;a++)if(i[e][a]!==0){mS(i,e,a),mS(r,e,a),t*=-1;break}if(a=i[e][e],a===0)return{determinant:0}}for(let t=0;t<n;t++)i[t][e]=i[t][e]/a,r[t][e]=r[t][e]/a;t*=a;for(let t=0;t<n;t++){if(t===e)continue;let a=i[e][t];for(let o=0;o<n;o++)i[o][t]-=a*i[o][e],r[o][t]-=a*r[o][e]}}return{inverted:r,determinant:t}}function mS(e,t,n){for(let r=0;r<e.length;r++){let i=e[r][t];e[r][t]=e[r][n],e[r][n]=i}}function hS(e,t){if(e.length<1||t.length<1)throw Error(`multiplyMatrices: empty matrices cannot be multiplied.`);if(e.length!==t[0].length)throw Error(`multiplyMatrices: incompatible matrices size.`);let n=e[0].length,r=t.length,i=e.length,a=Array(r);for(let o=0;o<r;o++){a[o]=Array(n);for(let r=0;r<n;r++){let n=0;for(let a=0;a<i;a++)n+=e[a][r]*t[o][a];a[o][r]=n}}return a}function gS(e){if(!ht(e))return e;if(!_S(e))throw Error(`The value should be a scalar or a 1x1 matrix`);return e[0][0]}function _S(e){return e.length===1&&e[0].length===1}function vS(e){return ht(e)&&!_S(e)}function yS(...e){let t=e[0].length;e.forEach((e,n)=>oS(e.length===t,P(`[[FUNCTION_NAME]] has mismatched dimensions for argument %s (%s vs %s).`,n.toString(),t.toString(),e.length.toString())))}function bS(e,t){let n=0,r=es(e,(e,t)=>(n+=1,e+t),0,t);return sS(n),r/n}function xS(e,t){let n=[];Zo(e,e=>{n.push(e.value)},t),n.sort((e,t)=>e-t);let r=n.length;if(r===0)return;let i=Math.floor(r/2);return r%2==0?(n[i-1]+n[i])/2:n[i]}function SS(e,t){let n=0;for(let r of e)if(ht(r))for(let e of r)for(let t of e)typeof t.value==`number`&&(n+=1);else{let e=r?.value;!No(e)&&(typeof e!=`string`||lo(e,t)||Na(e,t))&&(n+=1)}return n}function CS(e){return $o(e,(e,t)=>t!==void 0&&t.value!==null?e+1:e,0)}function wS(e,t){let n={value:-1/0};return Zo(e,e=>{e.value>=n.value&&(n=e)},t),n.value===-1/0?{value:0}:n}function TS(e,t){let n={value:1/0};return Zo(e,e=>{e.value<=n.value&&(n=e)},t),n.value===1/0?{value:0}:n}function ES(e,t,n){let r=e[0].length?e:[C(1,t.flat().length+1)],i=r.length,a=n[0].length?n:r;return a=a.length===i?as(a):a,{_X:r,_newX:a}}function DS(e,t,n=!0,r=!1){let i=t.flat(),a=i.length,{_X:o}=ES(e,t,[[]]);o=o.length===a?as(o):o.slice(),yS(o[0],i);let s=o.length,c=a-s-+!!n,l=[i],u=as(o.reverse()),d=[];for(let e=0;e<s;e++)if(d.push(0),n){for(let t of o[e])d[e]+=t;d[e]/=a}let f=0;if(n){for(let e of i)f+=e;f/=a}let p=u.map(e=>e.map((e,t)=>e-d[t]));n&&u.forEach(e=>e.push(1));let m=kS(u,l);if(n||m.push([0]),!r)return m;let{inverted:h}=pS(hS(p,as(p)));if(h===void 0)throw new I(P(`Matrix is not invertible`));let g=0,_=0;for(let e=0;e<a;e++){let t=i[e]-f,n=0;for(let t=0;t<s;t++){let r=p[e][t];n+=r*m[t][0]}let r=t-n;g+=r*r,_+=n*n}let v=Math.sqrt(g/c),ee=_/(_+g),y=_/s/(g/c),b=[];for(let e=0;e<s;e++)b.push(v*Math.sqrt(h[e][e]));if(n){let e=hS(h,[d]),t=hS(as([d]),e);b.push(v*Math.sqrt(t[0][0]+1/i.length))}let te=[[m[0][0],b[0],ee,y,_],[m[1][0],b[1],v,c,g]];for(let e=2;e<s;e++)te.push([m[e][0],b[e],``,``,``]);return n?te.push([m[s][0],b[s],``,``,``]):te.push([0,``,``,``,``]),te}function OS(e,t,n,r){yS(t,e),oS(n>=1,P(`Function [[FUNCTION_NAME]] A regression of order less than 1 cannot be possible.`));let i=[e],a=t.map(e=>C(0,n).map(t=>e**+(n-t)));r&&a.forEach(e=>e.push(1));let o=kS(a,i);return r||o.push([0]),o}function kS(e,t){let{inverted:n}=pS(hS(e,as(e)));if(n===void 0)throw new I(P(`Matrix is not invertible`));return as(hS(n,hS(e,t)))}function AS(e,t,n){return e.reduce((e,r,i)=>e+r*t**+(n-i),0)}function jS(e){return e.map(e=>e.map(e=>Math.exp(e)))}function MS(e){return e.map(e=>e.map(e=>Math.log(e)))}function NS(e,t,n,r){let{_X:i,_newX:a}=ES(t,e,n),o=DS(i,e,r,!1),s=o.length-1,c=a.map(e=>{let t=0;for(let n=0;n<s;n++)t+=o[n][0]*e[s-n-1];return t+=o[s][0],[t]});return c.length===n.length?c:as(c)}function PS(e,t,n=2){let r=[];for(let e=0;e<n-1;e++)r.push({x:t[e],y:NaN});for(let i=0;i<=e.length-n;i++){let a=0;for(let t=i;t<i+n;t++)a+=e[t];r.push({x:t[i+n-1],y:a/n})}return r}function FS(e){let[t,n]=e.split(`/`);return Number(n)*100+Number(t)}let IS=new k;function LS(e){return IS.get(e)}let RS={normalizeFunctionValue(e){return L(e,V)},toValueAndFormat(e,t){return{value:L(e,V),format:`dd mmm yyyy`}},toFunctionValue(e){let t=qo(e,V);return`DATE(${t.getFullYear()},${t.getMonth()+1},${t.getDate()})`}},zS={normalizeFunctionValue(e){let t=L(e,V);if(t<1||t>31)throw new I(P(`%s is not a valid day of month (it should be a number between 1 and 31)`,t));return t},toValueAndFormat(e){return{value:L(e,V),format:`0`}},toFunctionValue(e){return`${e}`}},BS={normalizeFunctionValue(e){let t=L(e,V);if(t<1||t>7)throw new I(P(`%s is not a valid day of week (it should be a number between 1 and 7)`,t));return t},toValueAndFormat(e,t){return{value:Zs[(e-1+(t||V).weekStart)%7].toString(),format:`@`}},toFunctionValue(e){return`${e}`}},VS={normalizeFunctionValue(e){let t=L(e,V);if(t<0||t>53)throw new I(P(`%s is not a valid week (it should be a number between 0 and 53)`,t));return t},toValueAndFormat(e){return{value:L(e,V),format:`0`}},toFunctionValue(e){return`${e}`}},HS={normalizeFunctionValue(e){let t=L(e,V);if(t<1||t>12)throw new I(P(`%s is not a valid month (it should be a number between 1 and 12)`,t));return t},toValueAndFormat(e){return{value:Xs[L(e,V)-1].toString(),format:`@`}},toFunctionValue(e){return`${e}`}},US={normalizeFunctionValue(e){return H(L(e,V),{locale:V,format:`mm/yyyy`})},toValueAndFormat(e){return{value:L(e,V),format:`mmmm yyyy`}},toFunctionValue(e){let t=qo(e,V);return`DATE(${t.getFullYear()},${t.getMonth()+1},1)`},toComparableValue(e){return FS(e)}},WS={normalizeFunctionValue(e){let t=L(e,V);if(t<1||t>4)throw new I(P(`%s is not a valid quarter (it should be a number between 1 and 4)`,t));return t},toValueAndFormat(e){return{value:P(`Q%(quarter_number)s`,{quarter_number:e}),format:`@`}},toFunctionValue(e){return`${e}`}},GS={normalizeFunctionValue(e){let t=L(e,V);return t>3e3?qo(t,V).getFullYear():t},toValueAndFormat(e){return{value:L(e,V),format:`0`}},toFunctionValue(e){return`${e}`}},KS={normalizeFunctionValue(e){let t=L(e,V);if(t<0||t>23)throw new I(P(`%s is not a valid hour (it should be a number between 0 and 23)`,t));return t},toValueAndFormat(e){return{value:P(`%(hour_number)sh`,{hour_number:e}),format:`@`}},toFunctionValue(e){return`${e}`}},qS={normalizeFunctionValue(e){let t=L(e,V);if(t<0||t>59)throw new I(P(`%s is not a valid minute (it should be a number between 0 and 59)`,t));return t},toValueAndFormat(e){return{value:P(`%(minute_number)s'`,{minute_number:e}),format:`@`}},toFunctionValue(e){return`${e}`}},JS={normalizeFunctionValue(e){let t=L(e,V);if(t<0||t>59)throw new I(P(`%s is not a valid second (it should be a number between 0 and 59)`,t));return t},toValueAndFormat(e){return{value:P(`%(second_number)s''`,{second_number:e}),format:`@`}},toFunctionValue(e){return`${e}`}};function YS(e){return{normalizeFunctionValue(t){return t===null?null:e.normalizeFunctionValue(t)},toValueAndFormat(t,n){return t===null?{value:P(`(Undefined)`)}:e.toValueAndFormat(t,n)},toFunctionValue(t){return t===null?`false`:e.toFunctionValue(t)},toComparableValue(t){if(t!==null)return e.toComparableValue?.(t)}}}IS.add(`day`,YS(RS)).add(`year`,YS(GS)).add(`day_of_month`,YS(zS)).add(`iso_week_number`,YS(VS)).add(`month_number`,YS(HS)).add(`month`,YS(US)).add(`quarter_number`,YS(WS)).add(`day_of_week`,YS(BS)).add(`hour_number`,YS(KS)).add(`minute_number`,YS(qS)).add(`second_number`,YS(JS));let XS={displayTotals:!0,displayColumnHeaders:!0,displayMeasuresRow:!0,numberOfRows:Number.MAX_VALUE,numberOfColumns:Number.MAX_VALUE,tableStyleId:`None`,bandedRows:!1,bandedColumns:!1,hasFilters:!1,tabularForm:!1},ZS={count:P(`Count`),count_distinct:P(`Count Distinct`),bool_and:P(`Boolean And`),bool_or:P(`Boolean Or`),max:P(`Maximum`),min:P(`Minimum`),avg:P(`Average`),sum:P(`Sum`)},QS=[`max`,`min`,`avg`,`sum`,`count_distinct`,`count`],$S={integer:QS,char:QS,datetime:QS,boolean:[`count_distinct`,`count`,`bool_and`,`bool_or`]},eC={};for(let e in $S){eC[e]={};for(let t of $S[e])eC[e][t]=ZS[t]}let tC={count:e=>({value:CS([e]),format:`0`}),count_distinct:e=>({value:aS([e]),format:`0`}),bool_and:e=>({value:nS([e]).result}),bool_or:e=>({value:rS([e]).result}),max:(e,t)=>wS([e],t),min:(e,t)=>TS([e],t),avg:(e,t)=>({value:bS([e],t),format:Mo(e)}),sum:(e,t)=>({value:iS([e],t),format:Mo(e)})};function nC(e){let t=Object.keys(e);if(!t.length)return 0;let n=t.map(e=>parseInt(e,10));return Math.max(...n)}let rC={year:P(`Year`),quarter:P(`Quarter & Year`),month:P(`Month & Year`),week:P(`Week & Year`),day:P(`Day`),quarter_number:P(`Quarter`),month_number:P(`Month`),iso_week_number:P(`Week`),day_of_month:P(`Day of Month`),day_of_week:P(`Day of Week`),hour_number:P(`Hour`),minute_number:P(`Minute`),second_number:P(`Second`)},iC=[`date`,`datetime`];function aC(e){let[t,n]=e.split(`:`);return n?{fieldName:t,granularity:n}:{fieldName:t}}function oC(e){return iC.includes(e.type)}function sC(e,t,n){let r=[e];n&&r.push(`"${n}"`);for(let{field:e,value:n,type:i}of t){if(e===`measure`){r.push(`"measure"`,`"${n}"`);continue}let{granularity:t}=aC(e),a=fC(n,{type:i,granularity:t});r.push(`"${e}"`,a)}return r}function cC(e,t){let n=0,r=0,i=t.columns.map(e=>e.nameWithGranularity),a=t.rows.map(e=>e.nameWithGranularity);for(;e[n]!==void 0&&e[n]===a[r];)n++,r++;for(r=0;e[n]!==void 0&&e[n]===i[r];)n++,r++;return e.length===n}function lC(e,t){switch(t.type){case`HEADER`:return`=PIVOT.HEADER(${sC(e,t.domain).join(`,`)})`;case`VALUE`:return`=PIVOT.VALUE(${sC(e,t.domain,t.measure).join(`,`)})`;case`MEASURE_HEADER`:return`=PIVOT.HEADER(${sC(e,[...t.domain,{field:`measure`,value:t.measure,type:`char`}]).join(`,`)})`}return``}function uC(e,t){if(t===null||t===`null`)return null;let n=typeof t==`object`?t.value:t;if(No(n))return n;if(e.type===`custom`)return Jo(t)??null;let r=typeof t==`boolean`?R(t).toLocaleLowerCase():R(t);if(r===`null`)return null;if(!mC.contains(e.type))throw new I(P(`Field %(field)s is not supported because of its type (%(type)s)`,{field:e.displayName,type:e.type}));return r.toLowerCase()===`false`?!1:mC.get(e.type)(r,e.granularity)}function dC(e,t){return LS(t??`month`).normalizeFunctionValue(e)}function fC(e,t){return e===null?`"null"`:hC.contains(t.type)?hC.get(t.type)(e,t.granularity):`"${e}"`}function pC(e,t){return LS(t??`month`).toFunctionValue(e)}let mC=new k;mC.add(`date`,dC).add(`datetime`,dC).add(`integer`,e=>L(e,V)).add(`boolean`,e=>z(e)).add(`char`,e=>R(e)).add(`custom`,e=>e);let hC=new k;hC.add(`date`,pC).add(`datetime`,pC).add(`integer`,e=>`${L(e,V)}`).add(`boolean`,e=>z(e)?`TRUE`:`FALSE`).add(`char`,e=>`"${R(e).replace(/"/g,`\\"`)}"`).add(`custom`,e=>typeof e==`string`?`"${e}"`:String(e));function gC(e){return e.displayName+(e.granularity?` (${rC[e.granularity]})`:``)}function _C(e,t){return e.length===0?t:{...t,format:(t.format||`@`)+`* `}}function vC(e,t){try{if(!t.getMeasure(e.measure))return!1;let n=t.definition.columns;for(let r=0;r<e.domain.length;r++){if(n[r].nameWithGranularity!==e.domain[r].field)return!1;let i=t.getPossibleFieldValues(n[r]).map(e=>e.value);if(!i.includes(e.domain[r].value)&&!(e.domain[r].value===null&&i.includes(``)))return!1}return!0}catch{return!1}}function yC(e,t){return _n(e,t.groups.map(e=>e.name),{compute:(e,t)=>`${e}${t}`,start:2})}function bC(e,t){return _n(e,Object.values(t).map(e=>[e?.name,e?.string]).flat().filter(w),{compute:(e,t)=>`${e}${t}`,start:2})}function xC(e,t){let n={};for(let r of Object.values(e.customFields||{}))t[r.parentField]&&(n[r.name]={type:`custom`,isCustomField:!0,name:r.name,string:r.name,customGroups:r.groups,parentField:r.parentField});return n}function SC(e,t){t.groups=t.groups.filter(t=>!t.values.some(t=>e.includes(t)))}function CC(e,t,n){let r=e.rows.some(e=>e.fieldName===t)?e.rows:e.columns,i=r.findIndex(e=>e.fieldName===t);return i===-1||r.some(e=>e.fieldName===n)||r.splice(i,0,{fieldName:n}),e}function wC(e,t,n){return Object.values(e.customFields||{}).find(e=>e.parentField===t.name)||{parentField:t.name,name:bC(t.string,n),groups:[]}}function TC(e,t){let n=t.model.getters.getPivotCellFromPosition(e),r=t.model.getters.getPivotIdFromPosition(e);if(!r||n.type!==`HEADER`)return;let i=t.model.getters.getPivotCoreDefinition(r),a=i.collapsedDomains?.[n.dimension]?[...i.collapsedDomains[n.dimension]]:[],o=a.findIndex(e=>T(e,n.domain));o===-1?a.push(n.domain):a.splice(o,1);let s=i.collapsedDomains?{...i.collapsedDomains}:{COL:[],ROW:[]};s[n.dimension]=a,t.model.dispatch(`UPDATE_PIVOT`,{pivotId:r,pivot:{...i,collapsedDomains:s}})}function EC(e,t,n,r,i,a,o){let s=e.style;return{numberOfRows:t===void 0?s?.numberOfRows??XS.numberOfRows:L(t,o),numberOfColumns:i===void 0?s?.numberOfColumns??XS.numberOfColumns:L(i,o),displayTotals:n===void 0?s?.displayTotals??XS.displayTotals:z(n),displayColumnHeaders:r===void 0?s?.displayColumnHeaders??XS.displayColumnHeaders:z(r),displayMeasuresRow:a===void 0?s?.displayMeasuresRow??XS.displayMeasuresRow:z(a),tableStyleId:s?.tableStyleId||XS.tableStyleId,bandedRows:s?.bandedRows??XS.bandedRows,bandedColumns:s?.bandedColumns??XS.bandedColumns,hasFilters:s?.hasFilters??XS.hasFilters,tabularForm:s?.tabularForm??XS.tabularForm}}function DC(e,t=`>`){let n=e.indexOf(t),r=e.lastIndexOf(t);return!e||!n||n===r?e:`${e.slice(0,n+1)} … ${e.slice(r)}`}function OC(e,t,n){return n.map(n=>{if(n.id===e.id)return t;if(!n.computedBy||e.id===t.id)return n;let r=Xu(n.computedBy.formula,e.id,t.id);return{...n,computedBy:{...n.computedBy,formula:r}}})}let kC=[`line`,`bar`,`pie`,`scorecard`,`gauge`,`scatter`,`bubble`,`combo`,`waterfall`,`pyramid`,`radar`,`geo`,`funnel`,`sunburst`,`treemap`,`calendar`];function AC(e){let t=Np[e];return t===void 0?void 0:{minColor:t[0],midColor:t.length===3?t[1]:void 0,maxColor:t[t.length-1]}}function jC(e){let t=Ql(e),n=[];return{text:``.concat(...t.map(e=>{if(e.type===`REFERENCE`&&al.test(e.value)){let t=e.value.trim();return n.includes(t)||n.push(t),`|${n.indexOf(t)}|`}else return e.value})),dependencies:n}}let MC={am_ET:7,ar_001:6,ar_SY:6,az_AZ:1,eu_ES:1,be_BY:1,bn_IN:1,bs_BA:1,bg_BG:1,ca_ES:1,zh_CN:7,zh_HK:7,zh_TW:7,hr_HR:1,cs_CZ:1,da_DK:1,nl_BE:1,nl_NL:1,en_AU:7,en_CA:7,en_GB:1,en_IN:7,en_NZ:7,et_EE:1,fi_FI:1,fr_BE:1,fr_CA:7,fr_CH:1,fr_FR:1,gl_ES:1,ka_GE:1,de_DE:1,de_CH:1,el_GR:1,gu_IN:7,he_IL:7,hi_IN:7,hu_HU:1,id_ID:7,it_IT:1,ja_JP:7,kab_DZ:6,km_KH:7,ko_KP:1,ko_KR:7,lo_LA:7,lv_LV:1,lt_LT:1,lb_LU:1,mk_MK:1,ml_IN:1,mn_MN:7,ms_MY:1,nb_NO:1,fa_IR:6,pl_PL:1,pt_AO:1,pt_BR:7,pt_PT:1,ro_RO:1,ru_RU:1,sr_RS:7,"sr@latin":7,sk_SK:1,sl_SI:1,es_AR:7,es_BO:1,es_CL:1,es_CO:7,es_CR:1,es_DO:1,es_EC:1,es_GT:7,es_MX:7,es_PA:7,es_PE:7,es_PY:7,es_UY:1,es_VE:7,sw:1,sv_SE:1,th_TH:7,tl_PH:1,tr_TR:1,uk_UA:1,vi_VN:1,sq_AL:1,te_IN:7,en_US:7,my_MM:7,es_ES:1,es_419:1},NC=new k;NC.add(`0.1`,{migrate(e){return e.sheets&&e.sheets[0]&&(e.activeSheet=e.sheets[0].name),e}}).add(`0.2`,{migrate(e){if(e.sheets&&e.sheets.length)for(let t of e.sheets)t.id=t.id||t.name;return e}}).add(`0.3`,{migrate(e){return e.sheets&&e.activeSheet&&(e.activeSheet=e.sheets.find(t=>t.name===e.activeSheet).id),e}}).add(`0.4`,{migrate(e){for(let t of e.sheets||[])t.figures=t.figures||[];return e}}).add(`0.5`,{migrate(e){for(let t of e.sheets||[])for(let e in t.cells||[]){let n=t.cells[e];n.content&&n.content.startsWith(`=`)&&(n.formula=jC(n.content))}return e}}).add(`0.6`,{migrate(e){for(let t of e.sheets||[])for(let e in t.figures||[]){let{dataSets:n,...r}=t.figures[e].data,i=[];for(let e of n)if(e.labelCell){let t=Un(e.dataRange),n=e.labelCell+`:`+E(t.right,t.bottom);i.push(n)}else i.push(e.dataRange);r.dataSetsHaveTitle=!!n[0].labelCell,r.dataSets=i,t.figures[e].data=r}return e}}).add(`0.7`,{migrate(e){let t=[];for(let n of e.sheets||[]){if(!n.name)continue;let e=n.name,r=_n(Et(e,`_`),t,{compute:(e,t)=>`${e}${t}`});n.name=r,t.push(r);let i=t=>{if(t===void 0)return t;let n=t.replace(e,r),i=t;for(;i!==n;)i=n,n=i.replace(e,r);return i};for(let e in n.cells){let t=n.cells[e];t.formula&&(t.formula.dependencies=t.formula.dependencies.map(i))}for(let e of n.figures||[])if(e.tag===`chart`){let t=e.data.dataSets.map(i),n=i(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:n}}for(let e of n.conditionalFormats||[]){e.ranges=e.ranges.map(i);for(let t of[`minimum`,`maximum`,`midpoint`,`upperInflectionPoint`,`lowerInflectionPoint`])e.rule[t]?.type===`formula`&&(e.rule[t].value=i(e.rule[t].value))}}return e}}).add(`0.8`,{migrate(e){for(let t of e.sheets||[])for(let e of t.figures||[])e.data.background=`#FFFFFF`,e.data.verticalAxisPosition=`left`,e.data.legendPosition=`top`,e.data.stacked=!1;return e}}).add(`0.9`,{migrate(e){for(let t of e.sheets||[])for(let e in t.cells||[]){let n=t.cells[e];if(n.formula){let{text:e,dependencies:t}=n.formula;for(let[n,r]of Object.entries(t)){let t=`\\|${n}\\|`;e=e.replace(new RegExp(t,`g`),r)}n.content=e,delete n.formula}}return e}}).add(`0.10`,{migrate(e){let t={};for(let n of e.sheets||[])for(let e in n.cells||[]){let r=n.cells[e];r.format&&=mv(r.format,t)}return e.formats=t,e}}).add(`15.4`,{migrate(e){for(let t of e.sheets||[])t.isVisible=!0;return e}}).add(`15.4.1`,{migrate(e){return PC(e)}}).add(`16.3`,{migrate(e){for(let t in e.borders){let n=e.borders[t];for(let e in n)Array.isArray(n[e])&&(n[e]={style:n[e][0],color:n[e][1]})}return e}}).add(`16.4`,{migrate(e){return e.settings||={},e.settings.locale||(e.settings.locale=V),e}}).add(`16.4.1`,{migrate(e){return PC(e)}}).add(`17.2`,{migrate(e){for(let t of e.sheets||[])t.tables=t.tables||t.filterTables||[],delete t.filterTables;return e}}).add(`17.3`,{migrate(e){return e.pivots||={},e.pivotNextId||=nC(e.pivots)+1,e}}).add(`17.4`,{migrate(e){for(let t of e.sheets||[])for(let e in t.figures||[]){let n=t.figures[e];`title`in n.data&&typeof n.data.title==`string`&&(n.data.title={text:n.data.title});let r=n.data.type;if(![`line`,`bar`,`pie`,`scatter`,`waterfall`,`combo`].includes(r))continue;let{dataSets:i,...a}=t.figures[e].data;a.dataSets=i.map(e=>({dataRange:e})),t.figures[e].data=a}return e}}).add(`18.0`,{migrate(e){return e}}).add(`18.0.1`,{migrate(e){for(let t of Object.values(e.pivots||{}))t.measures=t.measures.map(e=>({id:e.name,fieldName:e.name,aggregator:e.aggregator})),t.columns=t.columns.map(e=>({fieldName:e.name,order:e.order,granularity:e.granularity})),t.rows=t.rows.map(e=>({fieldName:e.name,order:e.order,granularity:e.granularity}));return e}}).add(`18.0.2`,{migrate(e){let t=e.settings?.locale;return t&&(t.weekStart=MC[t.code]||1),e}}).add(`18.0.3`,{migrate(e){for(let t of e.sheets||[]){t.styles={},t.formats={},t.borders={};for(let e in t.cells)t.styles[e]=t.cells[e].style,t.formats[e]=t.cells[e].format,t.borders[e]=t.cells[e].border,delete t.cells[e].style,delete t.cells[e].format,delete t.cells[e].border}return e}}).add(`18.0.4`,{migrate(e){for(let t of e.sheets||[])for(let e of t.figures||[]){if(e.tag!==`chart`||e.data.type!==`gauge`)continue;let t=e.data;t?.sectionRule?.lowerInflectionPoint&&(t.sectionRule.lowerInflectionPoint.operator=`<=`),t?.sectionRule?.upperInflectionPoint&&(t.sectionRule.upperInflectionPoint.operator=`<=`)}return e}}).add(`18.1`,{migrate(e){for(let t of e.sheets||[])for(let e of t.tables||[])e.config||={...$b,hasFilters:!0};return e}}).add(`18.1.1`,{migrate(e){for(let t of e.sheets||[])for(let e in t.cells){let n=t.cells[e];n&&(t.cells[e]=n.content)}return e}}).add(`18.2`,{migrate(e){return e}}).add(`18.3`,{migrate(e){if(!e.pivots)return e;for(let t of Object.values(e.pivots))t.sortedColumn&&(t.measures.map(e=>e.id).includes(t.sortedColumn.measure)||delete t.sortedColumn);return e}}).add(`18.3.1`,{migrate(e){for(let t of e.sheets||[])for(let e of t.figures||[]){let t=e;e.offset={x:t.x||0,y:t.y||0},e.col=0,e.row=0,delete e.x,delete e.y}return e}}).add(`18.4.1`,{migrate(e){let t={textContains:`containsText`,textNotContains:`notContainsText`,textIs:`isEqualText`,textIsEmail:`isEmail`,textIsLink:`isLink`},n={BeginsWith:`beginsWithText`,Between:`isBetween`,ContainsText:`containsText`,EndsWith:`endsWithText`,Equal:`isEqual`,GreaterThan:`isGreaterThan`,GreaterThanOrEqual:`isGreaterOrEqualTo`,IsEmpty:`isEmpty`,IsNotEmpty:`isNotEmpty`,LessThan:`isLessThan`,LessThanOrEqual:`isLessOrEqualTo`,NotBetween:`isNotBetween`,NotContains:`notContainsText`,NotEqual:`isNotEqual`};for(let t of e.sheets||[])for(let e of t.conditionalFormats||[])e.rule.type===`CellIsRule`&&(e.rule.operator=n[e.rule.operator]);for(let n of e.sheets||[])for(let e of n.dataValidationRules||[])e.criterion.type in t&&(e.criterion.type=t[e.criterion.type]);return e}}).add(`18.4.2`,{migrate(e){for(let t of e.sheets||[])for(let e of t.figures||[]){if(e.tag!==`chart`||e.data.type!==`scorecard`)continue;let t=e.data;t.baselineDescr&&={text:t.baselineDescr}}return e}}).add(`18.4.3`,{migrate(e){if(!e.pivots)return e;for(let t in e.pivots){let n=e.pivots[t];if(n.sortedColumn){let e=n.measures.find(e=>e.fieldName===n.sortedColumn?.measure);e&&(n.sortedColumn.measure=e.id)}}return e}}).add(`18.5.1`,{migrate(e){for(let t of e.sheets||[])for(let e of t.figures||[])e.tag===`chart`&&(e.data.chartId=e.id);return e}}).add(`19.1.0`,{migrate(e){for(let t of e.sheets||[])for(let e of t.figures||[])if(e.tag===`chart`&&e.data.type===`geo`&&`colorScale`in e.data&&typeof e.data.colorScale==`string`&&(e.data.colorScale=AC(e.data.colorScale)),e.tag===`carousel`)for(let t of Object.values(e.data.chartDefinitions)||[])t.type===`geo`&&`colorScale`in t&&typeof t.colorScale==`string`&&(t.colorScale=AC(t.colorScale));return e}}).add(`19.3.1`,{migrate(e){for(let t of e.sheets||[])for(let e of t.figures||[])if(e.tag===`chart`&&!(`humanize`in e.data))e.data.humanize=!0;else if(e.tag===`carousel`)for(let t in e.data.chartDefinitions){let n=e.data.chartDefinitions[t];`humanize`in n||(n.humanize=!0)}return e}}).add(`19.3.2`,{migrate(e){function t(e){if(!(`dataSets`in e))return e;e={...e};let t={};return e.dataSource={type:`range`,dataSetsHaveTitle:e.dataSetsHaveTitle,labelRange:e.labelRange,dataSets:e.dataSets.map((e,n)=>{let r=n.toString(),i=e.dataRange;return delete e.dataRange,Object.keys(e).length&&(t[r]={...e}),{dataRange:i,dataSetId:r}})},delete e.dataSetsHaveTitle,delete e.labelRange,delete e.dataSets,e.dataSetStyles=t,e}for(let n of e.sheets||[])for(let e of n.figures||[])if(e.tag===`chart`&&`dataSets`in e.data)e.data=t(e.data);else if(e.tag===`carousel`)for(let n in e.data.chartDefinitions){let r=e.data.chartDefinitions[n];e.data.chartDefinitions[n]=t(r)}return e}});function PC(e){for(let t of e.sheets||[]){let e=[];for(let n of t.filterTables||[]){let t=Un(n.range),r=e.findIndex(e=>rr(e,t));r===-1?e.push(t):e[r]=t}t.filterTables=e.map(e=>({range:Jn(e)}))}return e}function FC(){return IC().at(-1)}function IC(){return NC.getKeys().sort(VC)}let LC=`Sheet1`;function RC(e,t){if(!e)return $C();console.debug(`### Loading data ###`);let n=performance.now();if(e[`[Content_Types].xml`]){let n=new tS(e);if(e=n.convertXlsx(),t)for(let e of n.warningManager.warnings.sort())console.warn(e)}return`version`in e&&(BC(e)&&(e.version=zC[e.version]),e.version!==FC()&&(console.debug(`Migrating data from version`,e.version),e=HC(e))),e=UC(e),console.debug(`Data loaded in`,performance.now()-n,`ms`),console.debug(`###`),e}let zC={25:`18.2`,24:`18.1.1`,23:`18.1`,22:`18.0.4`,21:`18.0.3`,20:`18.0.2`,19:`18.0.1`,18:`18.0`,17:`17.4`,16:`17.3`,15:`17.2`,"14.5":`16.4.1`,14:`16.4`,13:`16.3`,"12.5":`15.4.1`,12:`15.4`,11:`0.10`,10:`0.9`,9:`0.8`,8:`0.7`,7:`0.6`,6:`0.5`,5:`0.4`,4:`0.3`,3:`0.2`,2:`0.1`,1:`0`};function BC(e){return typeof e.version==`number`}function VC(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<Math.max(n.length,r.length);e++){let t=n[e]||0,i=r[e]||0;if(t>i)return 1;if(t<i)return-1}return 0}function HC(e){let t=performance.now(),n=IC(),r=n.findIndex(t=>VC(t,e.version)>=0);if(r===-1)throw Error(`Data version ${e.version} postdates the current version of o-spreadsheet (version ${FC()}). It cannot be loaded.`);for(let t=r+1;t<n.length;t++){let r=n[t];e=NC.get(r).migrate(e)}return console.debug(`Data migrated in`,performance.now()-t,`ms`),e}function UC(e){return e=WC(e),e=GC(e),e}function WC(e){if(e.uniqueFigureIds)return e;let t=new Set,n=new Set;for(let r of e.sheets||[])for(let e of r.figures||[])t.has(e.id)&&(e.id+=G.smallUuid()),t.add(e.id),e.tag===`chart`&&(n.has(e.data?.chartId)&&(e.data.chartId+=G.smallUuid()),n.add(e.data?.chartId));return e.uniqueFigureIds=!0,e}function GC(e){let t=Object.assign($C(),e,{version:FC()});return t.sheets=t.sheets?t.sheets.map((e,t)=>Object.assign(QC(`Sheet${t+1}`,`Sheet${t+1}`),e)):[],t.sheets.length===0&&t.sheets.push(QC(LC,`Sheet1`)),K_(t.settings.locale)||(t.settings.locale=V),t}function KC(e,t){return t=qC(e,t),t=JC(t,`SORT_CELLS`),t=JC(t,`SET_DECIMAL`),t=YC(e,t),t=XC(e,t),t=ZC(e,t),t}function qC(e,t){if(Object.keys(e).length!==0)return t;let n=[],r=[],i=e=>{if(e.type===`CREATE_SHEET`)n.push(e.sheetId);else if(`sheetId`in e&&!n.includes(e.sheetId))return{...e,sheetId:LC};return e};for(let e of t)e.type===`REMOTE_REVISION`?r.push({...e,commands:e.commands.map(i)}):r.push(e);return r}function JC(e,t){let n=[];for(let r of e)r.type===`REMOTE_REVISION`?n.push({...r,commands:r.commands.filter(e=>e.type!==t)}):n.push(r);return n}function YC(e,t){if(!e.version||VC(String(e.version),`18.5.1`)>=0)return t;let n=[],r={};e=RC(x(e));for(let t of e.sheets||[])t.figures?.forEach(e=>{e.tag===`chart`&&(r[e.id]=e.data)});for(let e of t)if(e.type===`REMOTE_REVISION`){let t=[];for(let n of e.commands){let e=n;switch(n.type){case`CREATE_CHART`:r[n.chartId]=n.definition;break;case`UPDATE_CHART`:if(!r[n.chartId]){console.log(`Fix chart definition: chart with id ${n.chartId} not found.`);continue}let t={...r[n.chartId],...n.definition};e={...n,definition:t},delete t.chartId,r[n.chartId]=t;break}t.push(e)}n.push({...e,commands:t})}else n.push(e);return n}function XC(e,t){let n={};for(let t of e.sheets||[])t.figures?.forEach(e=>{n[e.id]=e.offset});for(let e of t)if(e.type===`REMOTE_REVISION`)for(let t of e.commands)switch(t.type){case`UPDATE_FIGURE`:t.offset&&(t.offset.x===void 0&&(t.offset.x=n[t.figureId]||0),t.offset.y===void 0&&(t.offset.y=n[t.figureId]||0),n[t.figureId]=n);break;case`CREATE_IMAGE`:case`CREATE_CHART`:case`CREATE_FIGURE`:n[t.figureId]=t.offset;break}return t}function ZC(e,t){let n={};for(let t of e.sheets||[])n[t.id]=t.name;let r=[];for(let e of t)if(e.type===`REMOTE_REVISION`){let t=[];for(let r of e.commands){switch(r.type){case`DUPLICATE_SHEET`:r.sheetNameTo=r.sheetNameTo??Vu(n[r.sheetId],Object.values(n));break;case`CREATE_SHEET`:n[r.sheetId]=r.name||Bu(Object.values(n));break;case`RENAME_SHEET`:n[r.sheetId]=r.newName||Bu(Object.values(n));break}t.push(r)}r.push({...e,commands:t})}else r.push(e);return t}function QC(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},styles:{},formats:{},borders:{},cols:{},rows:{},merges:[],conditionalFormats:[],dataValidationRules:[],figures:[],tables:[],isVisible:!0}}function $C(e=`Sheet1`){return{version:FC(),sheets:[QC(LC,e)],styles:{},formats:{},borders:{},revisionId:Xe,uniqueFigureIds:!0,settings:{locale:V},pivots:{},pivotNextId:1,customTableStyles:{},namedRanges:{}}}function ew(e,t){return{...QC(e,t),charts:[],images:[],cellValues:{}}}function tw(){return{...$C(),sheets:[ew(LC,`Sheet1`)]}}let nw=(e,t)=>{e.model.dispatch(t.type).isCancelledBecause(`WillRemoveExistingMerge`)&&e.raiseError(R_)},rw={wrongPasteSelection:P(`This operation is not allowed with multiple selections.`),willRemoveExistingMerge:V_.Errors.WillRemoveExistingMerge,wrongFigurePasteOption:P(`Cannot do a special paste of a figure.`),frozenPaneOverlap:P(`This operation is not allowed due to an overlapping frozen pane.`)};function iw(e,t){t.isSuccessful||(t.reasons.includes(`WrongPasteSelection`)?e.raiseError(rw.wrongPasteSelection):t.reasons.includes(`WillRemoveExistingMerge`)?e.raiseError(rw.willRemoveExistingMerge):t.reasons.includes(`WrongFigurePasteOption`)?e.raiseError(rw.wrongFigurePasteOption):t.reasons.includes(`FrozenPaneOverlap`)&&e.raiseError(rw.frozenPaneOverlap))}function aw(e,t,n){iw(e,e.model.dispatch(`PASTE`,{target:t,pasteOption:n}))}async function ow(e,t,n,r){if(n.data&&n.data.version!==FC()&&e.notifyUser({type:`warning`,text:P(`You copied content from a different version of the application. Only text and image content will be pasted.`),sticky:!1}),n.imageBlob){let t=n;try{t.imageData=await e.imageProvider?.uploadFile(n.imageBlob)}catch(t){let n=P(`An error occurred while uploading the image. %s`,t.message);console.error(t),e.raiseError(n)}delete n.imageBlob}iw(e,e.model.dispatch(`PASTE_FROM_OS_CLIPBOARD`,{target:t,clipboardContent:n,pasteOption:r}))}let sw=new k;var cw=class extends Br{mutators=[`open`,`close`];persistentPopover;hoveredCell=this.get(M_);handle(e){switch(e.type){case`ACTIVATE_SHEET`:this.close()}}open({col:e,row:t},n){let r=this.getters.getActiveSheetId();sw.contains(n)&&(this.persistentPopover={col:e,row:t,sheetId:r,type:n})}close(){if(!this.persistentPopover)return`noStateChange`;this.persistentPopover=void 0}get persistentCellPopover(){return this.persistentPopover&&{isOpen:!0,...this.persistentPopover}||{isOpen:!1}}get isOpen(){return this.persistentPopover!==void 0}get cellPopover(){let e=this.getters.getActiveSheetId();if(this.persistentPopover&&this.getters.isVisibleInViewport(this.persistentPopover)){let e=this.getters.getMainCellPosition(this.persistentPopover),t=sw.get(this.persistentPopover.type).onOpen?.(e,this.getters);return t?.isOpen?{...t,anchorRect:this.computePopoverAnchorRect(this.persistentPopover)}:{isOpen:!1}}let{col:t,row:n}=this.hoveredCell;if(t===void 0||n===void 0||!this.getters.isVisibleInViewport({sheetId:e,col:t,row:n}))return{isOpen:!1};let r=this.getters.getMainCellPosition({sheetId:e,col:t,row:n}),i=sw.getAll().map(e=>e.onHover?.(r,this.getters)).find(e=>e?.isOpen);return i?.isOpen?{...i,anchorRect:this.computePopoverAnchorRect(r)}:{isOpen:!1}}computePopoverAnchorRect({col:e,row:t}){let n=this.getters.getActiveSheetId(),r=this.getters.getMerge({sheetId:n,col:e,row:t});return r?this.getters.getVisibleRect(r):this.getters.getVisibleRect(O({col:e,row:t}))}};let lw=function(e){return e.PlainText=`text/plain`,e.Html=`text/html`,e.Image=`image`,e}({}),uw=[`image/avif`,`image/bmp`,`image/gif`,`image/vnd.microsoft.icon`,`image/jpeg`,`image/png`,`image/tiff`,`image/webp`];function dw(e,t){let n=new Set(t.map(e=>e.left)),r=new Set(t.map(e=>e.right)),i=new Set(t.map(e=>e.top)),a=new Set(t.map(e=>e.bottom)),o=i.size===1&&a.size===1||n.size===1&&r.size===1?hr(t):[t[t.length-1]],s=o.map(e=>ur(e)).flat();return{sheetId:e,zones:t,clippedZones:o,columnsIndexes:[...new Set(s.map(e=>e.col))].sort((e,t)=>e-t),rowsIndexes:[...new Set(s.map(e=>e.row))].sort((e,t)=>e-t)}}function fw(e,t,n){let r=Math.max(e.right-t+1,e.left),i=Math.max(e.bottom-n+1,e.top),a=[];for(let o=e.left;o<=r;o+=t)for(let r=e.top;r<=i;r+=n)a.push({left:o,top:r,bottom:r+n-1,right:o+t-1});return a}function pw(e,t){if(!t.length||!t[0].length)return e;let n=t[0].length,r=t.length;return e.map(e=>fw(e,n,r)).flat()}function mw(e){let t;e[`text/html`]&&(t=gw(new DOMParser().parseFromString(e[`text/html`],`text/html`)));let n=e[`text/plain`]||``,r;if(!n.trim()){for(let t of uw)if(e[t]){r=e[t];break}}return{text:n,data:t,imageBlob:r}}function hw(e){return e?.match(/<div data-osheet-clipboard-id=(['"])([^'"]+)\1/)?.[2]}function gw(e){if([...e.documentElement.attributes].some(e=>e.value.includes(`microsoft`)))return;let t=e.querySelector(`div`)?.getAttribute(`data-osheet-clipboard`);return t&&JSON.parse(t)}let _w=(e,t,n,r)=>{e.forEach(({handlerName:e,handler:i})=>{let a=t[e];a&&i.paste(n,a,r)})};function vw(e,t,n,r,i){let a,o=[],s={sheetId:e,zones:t};for(let{handlerName:c,handler:l}of r){let r=n[c];if(!r)continue;let u=l.getPasteTarget(e,t,r,i);u.figureIds&&(s.figureIds={...s.figureIds,...u.figureIds});for(let e of u.zones){if(o.push(e),a===void 0){a=e;continue}a=$n(a,e)}}return{target:s,zone:a,selectedZones:o}}let yw=(e,t,n)=>{let r={col:t[0].left,row:t[0].top};e.getBackToDefault(),e.selectZone({cell:r,zone:$n(...n)},{scrollIntoView:!1})},bw={type:`bar`,title:{},dataSource:{type:`range`,dataSets:[],dataSetsHaveTitle:!1},dataSetStyles:{},legendPosition:`none`,stacked:!1,humanize:!0},xw={type:`line`,title:{},dataSource:{type:`range`,dataSets:[],dataSetsHaveTitle:!1},dataSetStyles:{},legendPosition:`none`,stacked:!1,cumulative:!1,labelsAsText:!1,humanize:!0};function Sw(e,t){return Jn(e.getUnboundedZone(e.getActiveSheetId(),t))}function Cw(e){if(!e.length)return`empty`;let t={number:0,text:0,date:0,percentage:0},n=0,r=`empty`;for(let i of e){let e=null;if(i.type===`number`?e=i.format&&fc(i.format)?`date`:i.format?.includes(`%`)?`percentage`:`number`:i.type===`text`&&(e=`text`),e){let i=++t[e];i>n&&(n=i,r=e)}}return r}function ww(e,t){let n=[];for(let r of Er(e)){let e=t.getEvaluatedCellsInZone(t.getActiveSheetId(),r);n.push({zone:r,type:Cw(e)})}return n}function Tw(e,t){let n=e.getEvaluatedCellsInZone(e.getActiveSheetId(),t).map(e=>e.value?.toString().trim()||``).filter(e=>e);return{uniqueCount:new Set(n).size,totalCount:n.length}}function Ew(e,t){let n=e.getEvaluatedCell({sheetId:e.getActiveSheetId(),col:t.zone.left,row:t.zone.top});return![`number`,`empty`].includes(n.type)}function Dw(e,t){let{type:n,zone:r}=e,i=t.getActiveSheetId(),a=Ew(t,e),o=Sw(t,r),s=t.getEvaluatedCell({sheetId:i,col:r.left,row:r.top});if(br(r)===1)return Aw(r,t);switch(n){case`percentage`:return{type:`pie`,title:a?{text:String(s.value)}:{},dataSource:{type:`range`,dataSets:[{dataRange:o,dataSetId:`0`}],dataSetsHaveTitle:a},dataSetStyles:{},legendPosition:`none`};case`text`:let e=t.getEvaluatedCellsInZone(i,r).reduce((e,t)=>t.value===s.value?e+1:e,0),n=s.value!==null&&e===1;return{type:`pie`,title:n?{text:String(s.value)}:{},dataSource:{type:`range`,dataSets:[{dataRange:o,dataSetId:`0`}],labelRange:o,dataSetsHaveTitle:n},dataSetStyles:{},aggregated:!0,legendPosition:`top`};case`date`:return{...xw,type:`line`,title:a?{text:String(s.value)}:{},dataSource:{type:`range`,dataSets:[{dataRange:o,dataSetId:`0`}],dataSetsHaveTitle:a},dataSetStyles:{}}}return{...bw,title:a?{text:String(s.value)}:{},dataSource:{type:`range`,dataSets:[{dataRange:o,dataSetId:`0`}],dataSetsHaveTitle:a},dataSetStyles:{}}}function Ow(e,t){if(e.length!==2)throw Error(`buildTwoColumnChart expects exactly two columns`);if(e[1].type===`percentage`)return{type:`pie`,title:{},dataSource:{type:`range`,dataSets:[{dataRange:Sw(t,e[1].zone),dataSetId:`0`}],labelRange:Sw(t,e[0].zone),dataSetsHaveTitle:Ew(t,e[1])},dataSetStyles:{},aggregated:!0,legendPosition:`none`};if(e[0].type===`number`&&e[1].type===`number`)return{type:`scatter`,title:{},dataSource:{type:`range`,dataSets:[{dataRange:Sw(t,e[1].zone),dataSetId:`0`}],labelRange:Sw(t,e[0].zone),dataSetsHaveTitle:Ew(t,e[1])},dataSetStyles:{},labelsAsText:!1,legendPosition:`none`};if(e[0].type===`date`&&e[1].type===`number`)return{...xw,type:`line`,dataSource:{type:`range`,dataSets:[{dataRange:Sw(t,e[1].zone),dataSetId:`0`}],labelRange:Sw(t,e[0].zone),dataSetsHaveTitle:Ew(t,e[0])},dataSetStyles:{}};if(e[0].type===`text`&&e[1].type===`number`){let n=e[0],r=e[1],{uniqueCount:i,totalCount:a}=Tw(t,n.zone),o=Ew(t,r);if(i!==a)return{type:`treemap`,title:{},dataSource:{type:`range`,dataSets:[{dataRange:Sw(t,n.zone),dataSetId:`0`}],labelRange:Sw(t,r.zone),dataSetsHaveTitle:o},dataSetStyles:{},legendPosition:`none`}}return{...bw,dataSource:{type:`range`,dataSets:[{dataRange:Sw(t,e[1].zone),dataSetId:`0`}],labelRange:Sw(t,e[0].zone),dataSetsHaveTitle:Ew(t,e[1])},dataSetStyles:{}}}function kw(e,t){if(e.length<3)throw Error(`buildMultiColumnChart expects at least three columns`);let n=e.some(e=>e.type!==`text`&&Ew(t,e)),r=e[e.length-1],i=e.slice(0,e.length-1);if((r.type===`percentage`||r.type===`number`)&&i.every(e=>e.type===`text`)){let e=i.map(({zone:e},n)=>({dataRange:Sw(t,e),dataSetId:n.toString()}));return{type:i.length>=3?`sunburst`:`treemap`,title:{},dataSource:{type:`range`,dataSets:e,dataSetsHaveTitle:n,labelRange:Sw(t,r.zone)},dataSetStyles:{},legendPosition:`none`}}let a=e[0],o=e.slice(1),s=o.map(({zone:e},n)=>({dataRange:Sw(t,e),dataSetId:n.toString()}));return o.every(e=>e.type===`percentage`)?{type:`pie`,title:{},dataSource:{type:`range`,dataSets:s,labelRange:Sw(t,a.zone),dataSetsHaveTitle:n},dataSetStyles:{},aggregated:!1,legendPosition:`top`}:a.type===`date`&&o.every(e=>e.type===`number`)?{...xw,type:`line`,dataSource:{type:`range`,dataSets:s,labelRange:Sw(t,a.zone),dataSetsHaveTitle:n},dataSetStyles:{},legendPosition:`top`}:{...bw,dataSource:{type:`range`,dataSets:s,labelRange:Sw(t,a.zone),dataSetsHaveTitle:n},dataSetStyles:{},legendPosition:`top`}}function Aw(e,t){let n=t.getCell({sheetId:t.getActiveSheetId(),col:e.left,row:e.top});return{type:`scorecard`,title:{},keyValue:Sw(t,e),background:n?.style?.fillColor,baselineMode:Ze,baselineColorUp:Qe,baselineColorDown:$e}}function jw(e,t){let n=ww(e,t);if(n.length===0||n.every(e=>e.type===`empty`)){let e=n.map(({zone:e},n)=>({dataRange:Sw(t,e),dataSetId:n.toString()}));return{...bw,dataSource:{type:`range`,dataSets:e,dataSetsHaveTitle:!1}}}let r=n.filter(e=>e.type!==`empty`);switch(r.length){case 1:return{humanize:!0,...Dw(r[0],t)};case 2:return{humanize:!0,...Ow(r,t)};default:return{humanize:!0,...kw(r,t)}}}function Mw(e,t,n=$b){let r=e.model.getters.getSelectedZones(),i=e.model.getters.canCreateDynamicTableOnZones(t,r);r.length===1&&!i&&br(r[0])===1&&(e.model.selection.selectTableAroundSelection(),r=e.model.getters.getSelectedZones(),i=e.model.getters.canCreateDynamicTableOnZones(t,r));let a=r.map(n=>e.model.getters.getRangeDataFromZone(t,n)),o=e.model.dispatch(`CREATE_TABLE`,{ranges:a,sheetId:t,config:n,tableType:i?`dynamic`:`static`});return o.isCancelledBecause(`TableOverlap`)?e.raiseError(U_.Errors.TableOverlap):o.isCancelledBecause(`NonContinuousTargets`)&&e.raiseError(U_.Errors.NonContinuousTargets),o}function Nw(e,t){e.model.dispatch(`SET_FORMATTING_WITH_PIVOT`,{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function Pw(e,t){e.model.dispatch(`SET_FORMATTING`,{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}let Fw=async e=>Lw(e),Iw=async e=>Lw(e,`asValue`);async function Lw(e,t){let n=await e.clipboard.read();switch(n.status){case`ok`:let r=e.model.getters.getClipboardId(),i=e.model.getters.getSelectedZones();r===hw(n.content[`text/html`])?aw(e,i,t):await ow(e,i,mw(n.content),t),e.model.getters.isCutOperation()&&t!==`asValue`&&await e.clipboard.write({"text/plain":``});break;case`notImplemented`:e.raiseError(P(`Pasting from the context menu is not supported in this browser. Use keyboard shortcuts ctrl+c / ctrl+v instead.`));break;case`permissionDenied`:e.raiseError(P(`Access to the clipboard denied by the browser. Please enable clipboard permission for this page in your browser settings.`));break}}let Rw=e=>Lw(e,`onlyFormat`),zw=e=>{if(e.model.getters.getSelectedZones().length>1)return P(`Clear rows`);let t,n,r=e.model.getters.getActiveRows();if(r.size!==0)t=pn([...r]),n=fn([...r]);else{let r=e.model.getters.getSelectedZones()[0];t=r.top,n=r.bottom}return t===n?P(`Clear row %s`,(t+1).toString()):P(`Clear rows %s - %s`,(t+1).toString(),(n+1).toString())},Bw=e=>{let t=e.model.getters.getActiveSheetId(),n=[...e.model.getters.getActiveRows()].map(n=>e.model.getters.getRowsZone(t,n,n));e.model.dispatch(`DELETE_CONTENT`,{target:n,sheetId:e.model.getters.getActiveSheetId()})},Vw=e=>{if(e.model.getters.getSelectedZones().length>1)return P(`Clear columns`);let t,n,r=e.model.getters.getActiveCols();if(r.size!==0)t=pn([...r]),n=fn([...r]);else{let r=e.model.getters.getSelectedZones()[0];t=r.left,n=r.right}return t===n?P(`Clear column %s`,Cn(t)):P(`Clear columns %s - %s`,Cn(t),Cn(n))},Hw=e=>{let t=e.model.getters.getActiveSheetId(),n=[...e.model.getters.getActiveCols()].map(n=>e.model.getters.getColsZone(t,n,n));e.model.dispatch(`DELETE_CONTENT`,{target:n,sheetId:e.model.getters.getActiveSheetId()})},Uw=e=>{if(e.model.getters.getSelectedZones().length>1)return P(`Delete rows`);let t,n,r=e.model.getters.getActiveRows();if(r.size!==0)t=pn([...r]),n=fn([...r]);else{let r=e.model.getters.getSelectedZones()[0];t=r.top,n=r.bottom}return t===n?P(`Delete row %s`,(t+1).toString()):P(`Delete rows %s - %s`,(t+1).toString(),(n+1).toString())},Ww=e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){let n=e.model.getters.getSelectedZones()[0];for(let e=n.top;e<=n.bottom;e++)t.push(e)}e.model.dispatch(`REMOVE_COLUMNS_ROWS`,{sheetId:e.model.getters.getActiveSheetId(),sheetName:e.model.getters.getActiveSheetName(),dimension:`ROW`,elements:t})},Gw=(e,t)=>{if(e===`COL`&&t.model.getters.getActiveRows().size>0||e===`ROW`&&t.model.getters.getActiveCols().size>0)return!1;let n=t.model.getters.getActiveSheetId(),r=t.model.getters.getElementsFromSelection(e),i=t.model.getters.checkElementsIncludeAllVisibleHeaders(n,e,r),a=t.model.getters.checkElementsIncludeAllNonFrozenHeaders(n,e,r);return!i&&!a},Kw=e=>{if(e.model.getters.getSelectedZones().length>1)return P(`Delete columns`);let t,n,r=e.model.getters.getActiveCols();if(r.size!==0)t=pn([...r]),n=fn([...r]);else{let r=e.model.getters.getSelectedZones()[0];t=r.left,n=r.right}return t===n?P(`Delete column %s`,Cn(t)):P(`Delete columns %s - %s`,Cn(t),Cn(n))},qw=e=>{let t=e.model.getters.getActiveSheetId(),n=e.model.getters.getElementsFromSelection(`ROW`);return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,`ROW`,n)},Jw=e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){let n=e.model.getters.getSelectedZones()[0];for(let e=n.left;e<=n.right;e++)t.push(e)}e.model.dispatch(`REMOVE_COLUMNS_ROWS`,{sheetId:e.model.getters.getActiveSheetId(),sheetName:e.model.getters.getActiveSheetName(),dimension:`COL`,elements:t})},Yw=e=>{let t=e.model.getters.getActiveSheetId(),n=e.model.getters.getElementsFromSelection(`COL`);return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,`COL`,n)},Xw=e=>{let t=e.model.getters.getActiveRows(),n,r;if(t.size)n=pn([...t]),r=t.size;else{let t=e.model.getters.getSelectedZones()[0];n=t.top,r=t.bottom-t.top+1}e.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:e.model.getters.getActiveSheetId(),sheetName:e.model.getters.getActiveSheetName(),position:`before`,base:n,quantity:r,dimension:`ROW`})},Zw=e=>{let t=e.model.getters.getActiveRows(),n,r;if(t.size)n=fn([...t]),r=t.size;else{let t=e.model.getters.getSelectedZones()[0];n=t.bottom,r=t.bottom-t.top+1}e.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:e.model.getters.getActiveSheetId(),sheetName:e.model.getters.getActiveSheetName(),position:`after`,base:n,quantity:r,dimension:`ROW`})},Qw=e=>{let t=e.model.getters.getActiveCols(),n,r;if(t.size)n=pn([...t]),r=t.size;else{let t=e.model.getters.getSelectedZones()[0];n=t.left,r=t.right-t.left+1}e.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:e.model.getters.getActiveSheetId(),sheetName:e.model.getters.getActiveSheetName(),position:`before`,dimension:`COL`,base:n,quantity:r})},$w=e=>{let t=e.model.getters.getActiveCols(),n,r;if(t.size)n=fn([...t]),r=t.size;else{let t=e.model.getters.getSelectedZones()[0];n=t.right,r=t.right-t.left+1}e.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:e.model.getters.getActiveSheetId(),sheetName:e.model.getters.getActiveSheetName(),position:`after`,dimension:`COL`,base:n,quantity:r})},eT=e=>{let t=e.model.getters.getElementsFromSelection(`COL`),n=t[0],r=t[t.length-1];return t.length===1?P(`Hide column %s`,Cn(n).toString()):r-n+1===t.length?P(`Hide columns %s - %s`,Cn(n).toString(),Cn(r).toString()):P(`Hide columns`)},tT=e=>{let t=e.model.getters.getElementsFromSelection(`ROW`),n=t[0],r=t[t.length-1];return t.length===1?P(`Hide row %s`,(n+1).toString()):r-n+1===t.length?P(`Hide rows %s - %s`,(n+1).toString(),(r+1).toString()):P(`Hide rows`)},nT=e=>{let t=e.model.getters,n=G.smallUuid(),r=t.getActiveSheetId(),i=t.getSelectedZones();i.length===1&&br(i[0])===1&&(e.model.selection.selectTableAroundSelection(),i=t.getSelectedZones());let a={width:536,height:335},{col:o,row:s,offset:c}=kg(t,a);e.model.dispatch(`CREATE_CHART`,{sheetId:r,figureId:n,chartId:G.smallUuid(),col:o,row:s,offset:c,size:a,definition:jw(i,e.model.getters)}).isSuccessful&&(e.model.dispatch(`SELECT_FIGURE`,{figureId:n}),e.openSidePanel(`ChartPanel`))},rT=e=>{let t=e.model.getters,n=G.smallUuid(),r=t.getActiveSheetId(),i={width:536,height:335},{col:a,row:o,offset:s}=kg(t,i);e.model.dispatch(`CREATE_CAROUSEL`,{sheetId:r,figureId:n,col:a,row:o,offset:s,size:i,definition:{items:[]}}).isSuccessful&&(e.model.dispatch(`SELECT_FIGURE`,{figureId:n}),e.openSidePanel(`CarouselPanel`,{figureId:n}))},iT=e=>{let t=G.smallUuid(),n=G.smallUuid();e.model.dispatch(`INSERT_NEW_PIVOT`,{pivotId:t,newSheetId:n}).isSuccessful&&e.openSidePanel(`PivotSidePanel`,{pivotId:t})},aT=e=>e.model.getters.getPivotIds().map((t,n)=>({id:`reinsert_dynamic_pivot_${e.model.getters.getPivotFormulaId(t)}`,name:e.model.getters.getPivotDisplayName(t),sequence:n,execute:e=>{let n=e.model.getters.getSelectedZone(),r=e.model.getters.getPivot(t).getCollapsedTableStructure().export();e.model.dispatch(`INSERT_PIVOT_WITH_TABLE`,{pivotId:t,table:r,col:n.left,row:n.top,sheetId:e.model.getters.getActiveSheetId(),pivotMode:`dynamic`}),e.model.dispatch(`REFRESH_PIVOT`,{id:t})},isVisible:e=>e.model.getters.getPivot(t).isValid()})),oT=e=>e.model.getters.getPivotIds().map((t,n)=>({id:`reinsert_static_pivot_${e.model.getters.getPivotFormulaId(t)}`,name:e.model.getters.getPivotDisplayName(t),sequence:n,execute:e=>{let n=e.model.getters.getSelectedZone(),r=e.model.getters.getPivot(t).getExpandedTableStructure();if(r.numberOfCells>5e5){e.notifyUser({type:`warning`,text:G_(r.numberOfCells,e.model.getters.getLocale()),sticky:!0});return}e.model.dispatch(`INSERT_PIVOT_WITH_TABLE`,{pivotId:t,table:r.export(),col:n.left,row:n.top,sheetId:e.model.getters.getActiveSheetId(),pivotMode:`static`}),e.model.dispatch(`REFRESH_PIVOT`,{id:t})},isVisible:e=>e.model.getters.getPivot(t).isValid()})),sT=async e=>{if(e.imageProvider){let t=e.model.getters.getActiveSheetId(),n=G.smallUuid(),r=await e.imageProvider.requestImage(),i=Ag(e.model.getters,r.size),{col:a,row:o,offset:s}=kg(e.model.getters,i);e.model.dispatch(`CREATE_IMAGE`,{sheetId:t,figureId:n,col:a,row:o,offset:s,size:i,definition:r})}},cT=e=>Nw(e,`0.00%`),lT=e=>{let t=e.model.getters.getActiveSheetId(),n=e.model.getters.getSelectedZones(),r=e.model.getters.getConditionalFormats(t),i=e.model.getters.getRulesSelection(t,n);return i.length===1?e.openSidePanel(`ConditionalFormattingEditor`,{cf:r.find(e=>e.id===i[0]),isNewCf:!1}):e.openSidePanel(`ConditionalFormatting`)},uT=e=>{let{col:t,row:n}=e.model.getters.getActivePosition();e.getStore(cw).open({col:t,row:n},`LinkEditor`)},dT=e=>{let t=e.model.getters.getActiveSheetId(),{col:n,row:r}=e.model.getters.getActivePosition(),i=e.model.getters.getEvaluatedCell({sheetId:t,col:n,row:r});return i&&i.link?P(`Edit link`):P(`Insert link`)},fT=e=>e.model.getters.getFirstTableInSelection()?.config.hasFilters||!1,pT=e=>{let t=e.model.getters.getActiveSheetId(),n=e.model.getters.getSelectedZones(),r=e.model.getters.getTablesOverlappingZones(t,n);return r.length===1&&!r[0].isPivotTable},mT=e=>wr(e.model.getters.getSelectedZones()),hT=e=>{let t=e.model.getters.getActiveSheetId(),n=e.model.getters.getFirstTableInSelection();n?e.model.dispatch(`UPDATE_TABLE`,{sheetId:t,zone:n.range.zone,config:{hasFilters:!0}}):Mw(e,t,{...$b,hasFilters:!0,bandedRows:!1,styleId:`TableStyleLight11`})},gT=e=>{let t=e.model.getters.getActiveSheetId(),n=e.model.getters.getFirstTableInSelection();n&&e.model.dispatch(`UPDATE_TABLE`,{sheetId:t,zone:n.range.zone,config:{hasFilters:!1}})},_T=e=>{Mw(e,e.model.getters.getActiveSheetId()).isSuccessful&&e.openSidePanel(`TableSidePanel`,{})},vT=e=>{let t=e.model.getters.getFirstTableInSelection();t&&e.model.dispatch(`REMOVE_TABLE`,{sheetId:e.model.getters.getActiveSheetId(),target:[t.range.zone]})},yT=e=>e.model.getters.getSelectedZones().length===1,bT=(e,t)=>{if(!yT(e))return!1;let n=t===`COL`?e.model.getters.getActiveCols():e.model.getters.getActiveRows(),r=t===`COL`?e.model.getters.getActiveRows():e.model.getters.getActiveCols(),i=e.model.getters.getActiveSheetId(),a=nr(e.model.getters.getSelectedZone(),e.model.getters.getSheetZone(i));return rn(n)&&(r.size===0||a)},xT={name:e=>fT(e)?P(`Remove selected filters`):P(`Add filters`),isEnabled:e=>mT(e),execute:e=>fT(e)?gT(e):hT(e),icon:`o-spreadsheet-Icon.FILTER_ICON_ACTIVE`},ST={name:e=>{let t=nE(e);return t===1?P(`Insert row`):P(`Insert %s rows`,t.toString())},isVisible:e=>bT(e,`ROW`),icon:`o-spreadsheet-Icon.INSERT_ROW`},CT={name:e=>{let t=nE(e);return t===1?P(`Insert row above`):P(`Insert %s rows above`,t.toString())},execute:Xw,isVisible:e=>bT(e,`ROW`),icon:`o-spreadsheet-Icon.INSERT_ROW_BEFORE`},wT={...CT,name:e=>{let t=nE(e);return t===1?P(`Row above`):P(`%s Rows above`,t.toString())}},TT={...CT,name:e=>{let t=nE(e);return t===1?P(`Insert row`):P(`Insert %s rows`,t.toString())},isVisible:yT,icon:`o-spreadsheet-Icon.INSERT_ROW_BEFORE`},ET={execute:Zw,name:e=>{let t=nE(e);return t===1?P(`Insert row below`):P(`Insert %s rows below`,t.toString())},isVisible:e=>bT(e,`ROW`),icon:`o-spreadsheet-Icon.INSERT_ROW_AFTER`},DT={...ET,name:e=>{let t=nE(e);return t===1?P(`Row below`):P(`%s Rows below`,t.toString())}},OT={name:e=>{let t=rE(e);return t===1?P(`Insert column`):P(`Insert %s columns`,t.toString())},isVisible:e=>bT(e,`COL`),icon:`o-spreadsheet-Icon.INSERT_COL`},kT={name:e=>{let t=rE(e);return t===1?P(`Insert column left`):P(`Insert %s columns left`,t.toString())},execute:Qw,isVisible:e=>bT(e,`COL`),icon:`o-spreadsheet-Icon.INSERT_COL_BEFORE`},AT={...kT,name:e=>{let t=rE(e);return t===1?P(`Column left`):P(`%s Columns left`,t.toString())}},jT={...kT,name:e=>{let t=rE(e);return t===1?P(`Insert column`):P(`Insert %s columns`,t.toString())},isVisible:yT,icon:`o-spreadsheet-Icon.INSERT_COL_BEFORE`},MT={name:e=>{let t=rE(e);return t===1?P(`Insert column right`):P(`Insert %s columns right`,t.toString())},execute:$w,isVisible:e=>bT(e,`COL`),icon:`o-spreadsheet-Icon.INSERT_COL_AFTER`},NT={...MT,name:e=>{let t=rE(e);return t===1?P(`Column right`):P(`%s Columns right`,t.toString())},execute:$w},PT={name:P(`Insert cells`),isVisible:e=>yT(e)&&e.model.getters.getActiveCols().size===0&&e.model.getters.getActiveRows().size===0,icon:`o-spreadsheet-Icon.INSERT_CELL`},FT={name:P(`Insert cells and shift down`),execute:e=>{let t=e.model.getters.getSelectedZone();iw(e,e.model.dispatch(`INSERT_CELL`,{zone:t,shiftDimension:`ROW`}))},isVisible:e=>e.model.getters.getActiveRows().size===0&&e.model.getters.getActiveCols().size===0,icon:`o-spreadsheet-Icon.INSERT_CELL_SHIFT_DOWN`},IT={name:P(`Insert cells and shift right`),execute:e=>{let t=e.model.getters.getSelectedZone();iw(e,e.model.dispatch(`INSERT_CELL`,{zone:t,shiftDimension:`COL`}))},isVisible:e=>e.model.getters.getActiveRows().size===0&&e.model.getters.getActiveCols().size===0,icon:`o-spreadsheet-Icon.INSERT_CELL_SHIFT_RIGHT`},LT={name:P(`Chart`),execute:nT,isEnabled:e=>!e.isSmall,icon:`o-spreadsheet-Icon.INSERT_CHART`},RT={name:P(`Carousel`),execute:rT,isEnabled:e=>!e.isSmall,icon:`o-spreadsheet-Icon.CAROUSEL`},zT={name:P(`Pivot table`),execute:iT,isEnabled:e=>!e.isSmall,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.PIVOT`},BT={name:P(`Image`),shortcut:`Ctrl+O`,execute:sT,isVisible:e=>e.imageProvider!==void 0,isEnabled:e=>!e.isSmall,icon:`o-spreadsheet-Icon.INSERT_IMAGE`},VT={name:()=>P(`Table`),shortcut:`Alt+T`,execute:_T,isVisible:e=>mT(e)&&!e.model.getters.getFirstTableInSelection(),isEnabled:e=>!e.isSmall,icon:`o-spreadsheet-Icon.PAINT_TABLE`},HT={name:P(`Function`),icon:`o-spreadsheet-Icon.FORMULA`},UT={name:P(`SUM`),execute:e=>e.startCellEdition(`=SUM(`)},WT={name:P(`AVERAGE`),execute:e=>e.startCellEdition(`=AVERAGE(`)},GT={name:P(`COUNT`),execute:e=>e.startCellEdition(`=COUNT(`)},KT={name:P(`MAX`),execute:e=>e.startCellEdition(`=MAX(`)},qT={name:P(`MIN`),execute:e=>e.startCellEdition(`=MIN(`)},JT={name:P(`All`),children:[YT]};function YT(){return tE(il.getKeys().filter(e=>!il.get(e).hidden))}let XT=()=>{let e=il.content;return[...new Set(il.getAll().filter(e=>!e.hidden).map(e=>e.category))].filter(w).sort().map((t,n)=>({name:t,children:tE(Object.keys(e).filter(n=>e[n].category===t&&!e[n].hidden)),sequence:60+n}))},ZT={name:P(`Link`),shortcut:`Ctrl+Shift+K`,execute:uT,icon:`o-spreadsheet-Icon.INSERT_LINK`},QT={name:P(`Checkbox`),execute:e=>{let t=e.model.getters.getSelectedZones(),n=e.model.getters.getActiveSheetId(),r=t.map(t=>e.model.getters.getRangeDataFromZone(n,t));e.model.dispatch(`ADD_DATA_VALIDATION_RULE`,{ranges:r,sheetId:n,rule:{id:G.smallUuid(),criterion:{type:`isBoolean`,values:[]}}})},icon:`o-spreadsheet-Icon.INSERT_CHECKBOX`},$T={name:P(`Dropdown list`),execute:e=>{let t=e.model.getters.getSelectedZones(),n=e.model.getters.getActiveSheetId(),r=t.map(t=>e.model.getters.getRangeDataFromZone(n,t)),i=G.smallUuid();e.model.dispatch(`ADD_DATA_VALIDATION_RULE`,{ranges:r,sheetId:n,rule:{id:i,criterion:{type:`isValueInList`,values:[],displayStyle:`chip`}}}),e.model.getters.getDataValidationRule(n,i)&&e.openSidePanel(`DataValidationEditor`,{ruleId:i,onCancel:()=>{e.model.dispatch(`REMOVE_DATA_VALIDATION_RULE`,{sheetId:n,id:i})}})},isEnabled:e=>!e.isSmall,icon:`o-spreadsheet-Icon.INSERT_DROPDOWN`},eE={name:P(`Insert sheet`),shortcut:`Shift+F11`,execute:e=>{let t=e.model.getters.getActiveSheetId(),n=e.model.getters.getSheetIds().indexOf(t)+1,r=G.smallUuid();e.model.dispatch(`CREATE_SHEET`,{sheetId:r,position:n,name:e.model.getters.getNextSheetName()}),e.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:t,sheetIdTo:r})},icon:`o-spreadsheet-Icon.INSERT_SHEET`};function tE(e){return e.sort().map((e,t)=>({name:e,sequence:t*10,execute:t=>t.startCellEdition(`=${e}(`)}))}function nE(e){let t=e.model.getters.getActiveRows();if(t.size)return t.size;{let t=e.model.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function rE(e){let t=e.model.getters.getActiveCols();if(t.size)return t.size;{let t=e.model.getters.getSelectedZones()[0];return t.right-t.left+1}}function iE(e,t){let n=()=>{window.removeEventListener(`pointerup`,r,{capture:!0}),window.removeEventListener(`dragstart`,i),window.removeEventListener(`pointermove`,e),window.removeEventListener(`wheel`,e)},r=e=>{t(e),n()};function i(e){e.preventDefault()}return window.addEventListener(`pointerup`,r,{capture:!0}),window.addEventListener(`dragstart`,i),window.addEventListener(`pointermove`,e),window.addEventListener(`wheel`,e,{passive:!1}),n}function aE(){let e,n=document.body.style.cursor,r=[],i=()=>{e=void 0,document.body.style.cursor=n,r.forEach(e=>e()),r=[]},a=(t,a)=>{let s=()=>{document.body.style.cursor=`move`,e&&(Object.assign(o.itemsStyle,e.getItemStyles()),a.onChange?.())};o.cancel=()=>{o.draggedItemId=void 0,o.itemsStyle={},document.body.style.cursor=n,a.onCancel?.(),i()};let c=(e,t)=>{o.draggedItemId=void 0,o.itemsStyle={},document.body.style.cursor=n,a.onDragEnd?.(e,t),i()};document.body.style.cursor=`move`,o.draggedItemId=a.draggedItemId;let l=t===`horizontal`?new lE(a.scrollableContainerEl):new cE(a.scrollableContainerEl);e=new oE({...a,container:l,onChange:s,onDragEnd:c,onCancel:o.cancel});let u=iE(e.onMouseMove.bind(e),e.onMouseUp.bind(e));r.push(u);let d=e.onScroll.bind(e);a.scrollableContainerEl.addEventListener(`scroll`,d),r.push(()=>a.scrollableContainerEl.removeEventListener(`scroll`,d)),r.push(e.destroy.bind(e))};(0,t.onWillUnmount)(()=>{i()});let o=(0,t.proxy)({itemsStyle:{},draggedItemId:void 0,start:a,cancel:()=>{}});return o}var oE=class{draggedItemId;items;container;initialMousePosition;currentMousePosition;initialScroll;minPosition;maxPosition;edgeScrollIntervalId;onChange;onCancel;onDragEnd;deadZone;constructor(e){this.items=e.items.map(e=>({...e,positionAtStart:e.position})),this.draggedItemId=e.draggedItemId,this.container=e.container,this.onChange=e.onChange,this.onCancel=e.onCancel,this.onDragEnd=e.onDragEnd,this.initialMousePosition=e.initialMousePosition,this.currentMousePosition=e.initialMousePosition,this.initialScroll=this.container.scroll,this.minPosition=this.items[0].position,this.maxPosition=this.items[this.items.length-1].position+this.items[this.items.length-1].size}getItemStyles(){let e={};for(let t of this.items)e[t.id]=this.getItemStyle(t.id);return e}getItemStyle(e){let t=this.container.cssPositionProperty,n={};return n.position=`relative`,n[t]=(this.getItemsPositions()[e]||0)+`px`,n.transition=`${t} 0.5s`,n[`pointer-events`]=`none`,this.draggedItemId===e&&(n.transition=`${t} 0s`,n[`z-index`]=`1000`),W(n)}onScroll(){this.moveDraggedItemToPosition(this.currentMousePosition+this.scrollOffset)}onMouseMove(e){if(e.button>1){this.onCancel();return}let t=this.container.getMousePosition(e);if(this.currentMousePosition=t,t<this.container.start||t>this.container.end){this.startEdgeScroll(t<this.container.start?-1:1);return}else this.stopEdgeScroll();this.moveDraggedItemToPosition(t+this.scrollOffset)}moveDraggedItemToPosition(e){let t=this.getHoveredItemIndex(e,this.items),n=this.items.findIndex(e=>e.id===this.draggedItemId),r=this.items[n];if(this.deadZone&&this.isInZone(e,this.deadZone)){this.onChange(this.getItemsPositions());return}else this.isInZone(e,{start:r.position,end:r.position+r.size})&&(this.deadZone=void 0);if(n===t){this.onChange(this.getItemsPositions());return}let i=Math.min(n,t),a=Math.max(n,t),o=Math.sign(t-n),s=0;for(let e=i;e<=a;e++)e!==n&&(this.items[e].position-=o*r.size,s+=this.items[e].size);r.position+=o*s,this.items.sort((e,t)=>e.position-t.position),this.deadZone=o>0?{start:e,end:r.position}:{start:r.position+r.size,end:e},this.onChange(this.getItemsPositions())}onMouseUp(e){e.button!==0&&this.onCancel(),e.stopPropagation(),e.preventDefault();let t=this.items.findIndex(e=>e.id===this.draggedItemId);return this.onDragEnd(this.draggedItemId,t),this.stopEdgeScroll(),!1}startEdgeScroll(e){this.edgeScrollIntervalId||=window.setInterval(()=>{let t=e*3;this.container.scroll+=t},5)}stopEdgeScroll(){window.clearInterval(this.edgeScrollIntervalId),this.edgeScrollIntervalId=void 0}getHoveredItemIndex(e,t){return e<=this.minPosition?0:e>=this.maxPosition?t.length-1:t.findIndex(t=>t.position+t.size>=e)}getItemsPositions(){let e={};for(let t of this.items){if(t.id!==this.draggedItemId){e[t.id]=t.position-t.positionAtStart;continue}let n=this.currentMousePosition-this.initialMousePosition+this.scrollOffset;n=Math.max(this.minPosition-t.positionAtStart,n),n=Math.min(this.maxPosition-t.positionAtStart-t.size,n),e[t.id]=n}return e}isInZone(e,t){return e>=t.start&&e<=t.end}get scrollOffset(){return this.container.scroll-this.initialScroll}destroy(){this.stopEdgeScroll()}},sE=class{el;constructor(e){this.el=e}get containerRect(){return this.el.getBoundingClientRect()}},cE=class extends sE{get start(){return this.containerRect.top}get end(){return this.containerRect.bottom}get cssPositionProperty(){return`top`}get scroll(){return this.el.scrollTop}set scroll(e){this.el.scrollTop=e}getMousePosition(e){return e.clientY}},lE=class extends sE{get start(){return this.containerRect.left}get end(){return this.containerRect.right}get cssPositionProperty(){return`left`}get scroll(){return this.el.scrollLeft}set scroll(e){this.el.scrollLeft=e}getMousePosition(e){return e.clientX}};function uE(e){(0,t.useEffect)(()=>e()?.focus())}let dE={value:N.or([N.number(),N.string()]),onChange:N.function(),onFocused:N.function().optional(),onBlur:N.function().optional(),onInput:N.function().optional(),class:N.string().optional(),id:N.string().optional(),placeholder:N.string().optional(),autofocus:N.boolean().optional(),alwaysShowBorder:N.boolean().optional(),selectContentOnFocus:N.boolean().optional(),resetOnBlur:N.boolean().optional()};var fE=class extends A{props=(0,t.props)(dE);genericInputRef=t.signal.ref(HTMLInputElement);lastOnChangeValue=this.props.value.toString();setup(){(0,t.useListener)(window,`click`,e=>{let t=this.genericInputRef();!t||e.target===t||t.value===this.props.value.toString()||(this.props.resetOnBlur?t.value=this.props.value.toString():this.save())},{capture:!0}),this.props.autofocus&&uE(this.genericInputRef),(0,t.onWillUpdateProps)(e=>{let t=this.genericInputRef();document.activeElement!==t&&t&&(t.value=e.value),this.lastOnChangeValue=e.value.toString()}),(0,t.onMounted)(()=>{let e=this.genericInputRef();e&&(e.value=this.props.value.toString())})}onKeyDown(e){switch(e.key){case`Enter`:this.save(),e.preventDefault(),e.stopPropagation();break;case`Escape`:let t=this.genericInputRef();t&&(t.value=this.props.value.toString(),t.blur()),e.preventDefault(),e.stopPropagation();break}}save(){let e=(this.genericInputRef()?.value||``).trim();e!==this.lastOnChangeValue&&(this.lastOnChangeValue=e,this.props.onChange(e)),document.activeElement===this.genericInputRef()&&this.genericInputRef()?.blur()}onMouseDown(e){e.target!==document.activeElement&&this.props.selectContentOnFocus&&(e.preventDefault(),e.stopPropagation())}onMouseUp(e){let t=e.target;t!==document.activeElement&&this.props.selectContentOnFocus&&(t.focus(),this.props.selectContentOnFocus&&t.select(),e.preventDefault(),e.stopPropagation())}onFocus(){this.props.onFocused?.()}onBlur(){if(this.props.onBlur?.(),this.props.resetOnBlur){let e=this.genericInputRef();e&&(e.value=this.props.value.toString())}else this.save()}onInput(e){let t=e.target;this.props.onInput?.(t.value)}},pE=class extends fE{static template=`o-spreadsheet-TextInput`;static components={};props=(0,t.props)({...dE,value:N.string(),errorMessage:N.string().optional(),maxLength:N.number().optional()});get inputClass(){return[this.props.class,`w-100 os-input`,this.props.alwaysShowBorder?`o-input-border`:void 0,this.props.errorMessage?`o-invalid`:void 0].filter(w).join(` `)}},mE=class extends A{static template=`o-spreadsheet-ActionButton`;props=(0,t.props)({action:N.ActionSpec(),hasTriangleDownIcon:N.boolean().optional(),selectedColor:N.string().optional(),class:N.string().optional(),onClick:N.function().optional()});actionButton=xe(this.props.action);setup(){(0,t.onWillUpdateProps)(e=>{e.action!==this.props.action&&(this.actionButton=xe(e.action))})}get isVisible(){return this.actionButton.isVisible(this.env)}get isEnabled(){let e=this.actionButton.isEnabledOnLockedSheet||!this.env.model.getters.isCurrentSheetLocked();return this.actionButton.isEnabled(this.env)&&e}get isActive(){return this.actionButton.isActive?.(this.env)}get title(){let e=this.actionButton.name(this.env),t=this.actionButton.description(this.env)||ve(this.actionButton.shortcut);return e+(t?` (${t})`:``)}get iconTitle(){return this.actionButton.icon(this.env)}onClick(e){this.isEnabled&&(this.props.onClick?.(e),this.actionButton.execute?.(this.env))}get buttonStyle(){return this.props.selectedColor?W({"border-bottom":`4px solid ${this.props.selectedColor}`,height:`16px`,"margin-top":`2px`}):``}},hE=class extends A{static template=`o-spreadsheet-ColorPicker`;static components={Popover:y_};props=(0,t.props)({onColorPicked:N.function(),currentColor:N.string().optional(``),maxHeight:N.Pixel().optional(),anchorRect:N.Rect(),disableNoColor:N.boolean().optional()});COLORS=Ve;state=(0,t.proxy)({showGradient:!1,currentHslaColor:Xf(this.props.currentColor)?{...sp(this.props.currentColor),a:1}:{h:0,s:100,l:100,a:1},customHexColor:Xf(this.props.currentColor)?Yf(this.props.currentColor):``});get colorPickerStyle(){return this.props.maxHeight!==void 0&&this.props.maxHeight<=0?W({display:`none`}):``}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:`bottom-left`,verticalOffset:0}}get gradientHueStyle(){return W({background:`hsl(${this.state.currentHslaColor?.h||0} 100% 50%)`})}get sliderStyle(){let e=this.state.currentHslaColor?.h||0;return W({"margin-left":`${S(Math.round(e/360*216),1,216)-18/2}px`})}get pointerStyle(){let{s:e,l:t}=this.state.currentHslaColor||{s:0,l:0},n=Math.round(216*S(e/100,0,1)),r=Math.round(186*S(1-2*t/(200-e),0,1));return W({left:`${-16/2+n}px`,top:`${-16/2+r}px`,background:op(this.state.currentHslaColor)})}get colorPreviewStyle(){return W({"background-color":op(this.state.currentHslaColor)})}get checkmarkColor(){return om(this.props.currentColor)}get isHexColorInputValid(){return!this.state.customHexColor||Xf(this.state.customHexColor)}setCustomGradient({x:e,y:t}){let n=S(e,0,216),r=S(t,0,186),i=n/216,a=r/186,o=100*i,s=100*(1-a)*(1-.5*i);this.updateColor({s:o,l:s})}setCustomHue(e){let t=Math.round(S(360*e/216,0,359));this.updateColor({h:t})}updateColor(e){this.state.currentHslaColor={...this.state.currentHslaColor,...e},this.state.customHexColor=op(this.state.currentHslaColor)}onColorClick(e){e&&this.props.onColorPicked(Yf(e))}resetColor(){this.props.onColorPicked(``)}toggleColorPicker(){this.state.showGradient=!this.state.showGradient}dragGradientPointer(e){let t={x:e.offsetX,y:e.offsetY};this.setCustomGradient(t);let n={x:e.clientX,y:e.clientY};iE(e=>{let r={x:e.clientX,y:e.clientY},i=r.x-n.x,a=r.y-n.y,o={x:t.x+i,y:t.y+a};this.setCustomGradient(o)},()=>{})}dragHuePointer(e){let t=e.offsetX,n=e.clientX;this.setCustomHue(t),iE(e=>{let r=t+(e.clientX-n);this.setCustomHue(r)},()=>{})}setHexColor(e){let t=e.target.value.replace(`##`,`#`).slice(0,7);this.state.customHexColor=t,Xf(t)&&(this.state.currentHslaColor={...sp(t),a:1})}addCustomColor(e){!Zf(this.state.currentHslaColor)||!Xf(this.state.customHexColor)||this.props.onColorPicked(Yf(this.state.customHexColor))}isSameColor(e,t){return up(e,t)}get canUseEyeDropper(){return!!globalThis.EyeDropper&&!this.env.model.getters.isDarkMode()}async activateEyedropper(){if(globalThis.EyeDropper)try{let e=await new globalThis.EyeDropper().open();e&&e.sRGBHex&&this.props.onColorPicked(Yf(e.sRGBHex))}catch(e){if(e.name!==`AbortError`)throw e}}},gE=class extends A{static template=`o-spreadsheet-ColorPickerWidget`;static components={ColorPicker:hE};props=(0,t.props)({currentColor:N.string().optional(),toggleColorPicker:N.function(),showColorPicker:N.boolean(),onColorPicked:N.function(),icon:N.string(),title:N.string().optional(),disabled:N.boolean().optional(),dropdownMaxHeight:N.Pixel().optional(),class:N.string().optional()});colorPickerButtonRef=(0,t.signal)(null);get iconStyle(){return this.props.currentColor?`border-color: ${this.props.currentColor}`:`border-bottom-style: hidden`}get colorPickerAnchorRect(){return y(this.colorPickerButtonRef())}},_E=class extends A{static template=`o-spreadsheet-NumberEditor`;static components={Popover:y_};props=(0,t.props)({currentValue:N.number(),onValueChange:N.function(),onToggle:N.function().optional(),onFocusInput:N.function().optional(()=>()=>{}),class:N.string(),valueIcon:N.string().optional(),min:N.number(),max:N.number(),title:N.string(),valueList:N.array(N.number())});dropdown=(0,t.proxy)({isOpen:!1});inputRef=t.signal.ref(HTMLInputElement);rootEditorRef=(0,t.signal)(null);valueListRef=(0,t.signal)(null);DOMFocusableElementStore;setup(){this.DOMFocusableElementStore=j(c_),Fi(window,`click`,this.onExternalClick,{capture:!0}),(0,t.onWillUpdateProps)(e=>{let t=this.inputRef();t&&document.activeElement!==t&&(t.value=e.currentValue)}),(0,t.onMounted)(()=>{let e=this.inputRef();e&&(e.value=this.props.currentValue.toString())})}get popoverProps(){return{anchorRect:y(this.rootEditorRef()),positioning:`bottom-left`,verticalOffset:0}}onExternalClick(e){let t=this.valueListRef(),n=this.rootEditorRef();t&&n&&!_(t,e)&&!_(n,e)&&this.closeList()}toggleList(){this.dropdown.isOpen?this.closeList():(this.props.onToggle?.(),this.inputRef()?.focus())}closeList(){this.dropdown.isOpen=!1}setValue(e){let t=S(Math.floor(parseFloat(e)),this.props.min,this.props.max);this.props.onValueChange(t),this.closeList()}setValueFromInput(e){this.setValue(e.target.value)}setValueFromList(e){this.setValue(e)}get currentValue(){return`${this.props.currentValue}`}onInputFocused(e){this.dropdown.isOpen=!0,e.target.select()}onInputKeydown(e){if(e.key===`Enter`||e.key===`Escape`){this.closeList();let t=e.target;e.key===`Escape`&&(t.value=`${this.props.currentValue}`),this.props.onToggle?.()}if(e.key===`Tab`){e.preventDefault(),e.stopPropagation(),this.closeList(),this.DOMFocusableElementStore.focus();return}}},vE=class extends A{static template=`o-spreadsheet-FontSizeEditor`;static components={NumberEditor:_E};props=(0,t.props)({currentFontSize:N.number(),onFontSizeChanged:N.function(),onToggle:N.function().optional(),onFocusInput:N.function().optional(()=>()=>{}),class:N.string()});fontSizes=ot},yE=class extends A{static template=`o-spreadsheet.TextStyler`;static components={ColorPickerWidget:gE,ActionButton:mE,FontSizeEditor:vE};props=(0,t.props)({style:N.ChartStyle(),updateStyle:N.function(),defaultStyle:N.object().optional(),hasVerticalAlign:N.boolean().optional(),hasHorizontalAlign:N.boolean().optional(),hasBackgroundColor:N.boolean().optional(),class:N.string().optional()});openedEl=null;setup(){Fi(window,`click`,this.onExternalClick)}state=(0,t.proxy)({activeTool:``});updateFontSize(e){this.props.updateStyle?.({...this.props.style,fontSize:e})}toggleDropdownTool(e,t){let n=this.state.activeTool===e;this.closeMenus(),this.state.activeTool=n?``:e,this.openedEl=n?null:t.target}onExternalClick(e){this.openedEl!==e.target&&this.closeMenus()}onTextColorChange(e){this.props.updateStyle?.({...this.props.style,color:e}),this.closeMenus()}onFillColorChange(e){this.props.updateStyle?.({...this.props.style,fillColor:e}),this.closeMenus()}updateAlignment(e){this.props.updateStyle?.({...this.props.style,align:e}),this.closeMenus()}updateVerticalAlignment(e){this.props.updateStyle?.({...this.props.style,verticalAlign:e}),this.closeMenus()}toggleBold(){this.props.updateStyle?.({...this.props.style,bold:!this.bold})}toggleItalic(){this.props.updateStyle?.({...this.props.style,italic:!this.italic})}closeMenus(){this.state.activeTool=``,this.openedEl=null}get align(){return this.props.style.align??this.props.defaultStyle?.align}get verticalAlign(){return this.props.style.verticalAlign||this.props.defaultStyle?.verticalAlign}get bold(){return this.props.style.bold??this.props.defaultStyle?.bold}get italic(){return this.props.style.italic??this.props.defaultStyle?.italic}get currentFontSize(){return this.props.style.fontSize??this.props.defaultStyle?.fontSize??Ue.fontSize}get boldButtonAction(){return{name:P(`Bold`),execute:()=>this.toggleBold(),isActive:()=>this.bold||!1,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.BOLD`}}get italicButtonAction(){return{name:P(`Italic`),execute:()=>this.toggleItalic(),isActive:()=>this.italic||!1,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ITALIC`}}get horizontalAlignButtonAction(){let e=`o-spreadsheet-Icon.ALIGN_LEFT`;return this.align===`center`?e=`o-spreadsheet-Icon.ALIGN_CENTER`:this.align===`right`&&(e=`o-spreadsheet-Icon.ALIGN_RIGHT`),{name:P(`Horizontal alignment`),icon:e,isEnabledOnLockedSheet:!0}}get horizontalAlignActions(){return[{name:P(`Left`),execute:()=>this.updateAlignment(`left`),isActive:()=>this.align===`left`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_LEFT`},{name:P(`Center`),execute:()=>this.updateAlignment(`center`),isActive:()=>this.align===`center`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_CENTER`},{name:P(`Right`),execute:()=>this.updateAlignment(`right`),isActive:()=>this.align===`right`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_RIGHT`}]}get verticalAlignButtonAction(){let e=`o-spreadsheet-Icon.ALIGN_MIDDLE`;return this.verticalAlign===`top`?e=`o-spreadsheet-Icon.ALIGN_TOP`:this.verticalAlign===`bottom`&&(e=`o-spreadsheet-Icon.ALIGN_BOTTOM`),{name:P(`Vertical alignment`),icon:e,isEnabledOnLockedSheet:!0}}get verticalAlignActions(){return[{name:P(`Top`),execute:()=>this.updateVerticalAlignment(`top`),isActive:()=>this.verticalAlign===`top`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_TOP`},{name:P(`Middle`),execute:()=>this.updateVerticalAlignment(`middle`),isActive:()=>this.verticalAlign===`middle`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_MIDDLE`},{name:P(`Bottom`),execute:()=>this.updateVerticalAlignment(`bottom`),isActive:()=>this.verticalAlign===`bottom`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_BOTTOM`}]}},bE=class extends A{static template=`o-spreadsheet-CogWheelMenu`;static components={MenuPopover:C_};props=(0,t.props)({items:N.array(N.ActionSpec())});buttonRef=(0,t.signal)(null);menuState=(0,t.proxy)({isOpen:!1,anchorRect:null,menuItems:[]});menuId=G.uuidv4();toggleMenu(e){e.closedMenuId!==this.menuId&&(this.menuState.isOpen=!this.menuState.isOpen,this.menuState.anchorRect=b(this.buttonRef()),this.menuState.menuItems=_e(this.props.items))}},Z=class extends A{static template=`o_spreadsheet.Section`;props=(0,t.props)({class:N.string().optional(),title:N.string().optional(),slots:N.object()})},xE=class extends A{static template=`o-spreadsheet-CarouselPanel`;static components={Section:Z,TextInput:pE,TextStyler:yE,CogWheelMenu:bE};props=(0,t.props)({onCloseSidePanel:N.function(),figureId:N.UID()});DEFAULT_CAROUSEL_TITLE_STYLE=ut;dragAndDrop=aE();previewListRef=(0,t.signal)(null);setup(){let e=[...this.carouselItems];(0,t.onWillUpdateProps)(()=>{T(this.carouselItems,e)||this.dragAndDrop.cancel(),e=[...this.carouselItems]})}get carouselItems(){return this.env.model.getters.getCarousel(this.props.figureId).items}get title(){return this.env.model.getters.getCarousel(this.props.figureId).title}get carousel(){return this.env.model.getters.getCarousel(this.props.figureId)}getPreviewDivStyle(e){return this.dragAndDrop.itemsStyle[this.getItemId(e)]||``}getItemId(e){return e.type===`chart`?e.chartId:`transparent-carousel`}addNewChartToCarousel(){this.env.model.dispatch(`ADD_NEW_CHART_TO_CAROUSEL`,{figureId:this.props.figureId,sheetId:this.carouselSheetId})}get hasDataView(){return this.carouselItems.some(e=>e.type===`carouselDataView`)}isCarouselItemActive(e){return T(this.env.model.getters.getSelectedCarouselItem(this.props.figureId),e)}addDataViewToCarousel(){let e=this.env.model.getters.getCarousel(this.props.figureId);this.updateItems([...e.items,{type:`carouselDataView`}])}activateCarouselItem(e){this.env.model.dispatch(`UPDATE_CAROUSEL_ACTIVE_ITEM`,{figureId:this.props.figureId,sheetId:this.carouselSheetId,item:e})}editCarouselItem(e){e.type===`chart`&&(this.activateCarouselItem(e),this.env.model.dispatch(`SELECT_FIGURE`,{figureId:this.props.figureId}),this.env.openSidePanel(`ChartPanel`,{chartId:e.chartId}))}renameCarouselItem(e,t){let n=t.trim();if(!n||n===this.getItemTitle(e).toString())return;let r=[...this.carouselItems],i=this.carouselItems.findIndex(t=>T(t,e));i!==-1&&(r[i]={...e,title:n},this.updateItems(r))}deleteCarouselItem(e){let t=this.env.model.getters.getCarousel(this.props.figureId).items.filter(t=>!T(t,e));this.updateItems(t)}popOutCarouselItem(e){e.type===`chart`&&this.env.model.dispatch(`POPOUT_CHART_FROM_CAROUSEL`,{sheetId:this.carouselSheetId,carouselId:this.props.figureId,chartId:e.chartId})}duplicateCarouselChart(e){e.type===`chart`&&this.env.model.dispatch(`DUPLICATE_CAROUSEL_CHART`,{sheetId:this.carouselSheetId,carouselId:this.props.figureId,chartId:e.chartId,duplicatedChartId:G.smallUuid()})}onDragHandleMouseDown(e,t){if(t.button!==0)return;let n=this.previewListRef();if(!n)return;let r=Array.from(n.children).map(e=>b(e)),i=this.carouselItems.map((e,t)=>({id:this.getItemId(e),size:r[t].height,position:r[t].y}));this.dragAndDrop.start(`vertical`,{draggedItemId:this.getItemId(e),initialMousePosition:t.clientY,items:i,scrollableContainerEl:n,onDragEnd:(t,n)=>this.onDragEnd(e,n)})}onDragEnd(e,t){let n=this.carouselItems.findIndex(t=>T(t,e));if(n===-1||n===t)return;let r=[...this.env.model.getters.getCarousel(this.props.figureId).items];r.splice(n,1),r.splice(t,0,e),this.updateItems(r)}getItemTitle(e){return Wg(this.env.model.getters,e)}getItemPreview(e){return Ug(this.env.model.getters,e)}updateItems(e){this.env.model.dispatch(`UPDATE_CAROUSEL`,{figureId:this.props.figureId,sheetId:this.carouselSheetId,definition:{...this.carousel,items:e}})}updateTitleText(e){let t=this.env.model.getters.getCarousel(this.props.figureId);this.env.model.dispatch(`UPDATE_CAROUSEL`,{figureId:this.props.figureId,sheetId:this.carouselSheetId,definition:{...t,title:{...t.title,text:e}}})}updateTitleStyle(e){let t=this.env.model.getters.getCarousel(this.props.figureId);this.env.model.dispatch(`UPDATE_CAROUSEL`,{figureId:this.props.figureId,sheetId:this.carouselSheetId,definition:{...t,title:{...t.title,...e}}})}get carouselAddChartInfoMessage(){return P(`Add a chart to the carousel. You can also add a chart by dragging and dropping it over the carousel figure.`)}getCogWheelMenuItems(e){let t=[];return e.type===`chart`&&(t.push({name:P(`Edit chart`),execute:()=>this.editCarouselItem(e),icon:`o-spreadsheet-Icon.EDIT`}),t.push({name:P(`Pop out chart`),execute:()=>this.popOutCarouselItem(e),icon:`o-spreadsheet-Icon.EXTERNAL`}),t.push({name:P(`Duplicate chart`),execute:()=>this.duplicateCarouselChart(e),icon:`o-spreadsheet-Icon.COPY`})),t.push({name:P(`Delete item`),execute:()=>this.deleteCarouselItem(e),icon:`o-spreadsheet-Icon.TRASH`}),t}get carouselSheetId(){let e=this.env.model.getters.getFigureSheetId(this.props.figureId);if(!e)throw Error(`Could not find the sheetId of the carousel figure`);return e}get carouselDataViewMessage(){return P(`The data view makes the carousel transparent, revealing the data underneath.`)}};let SE=new k;var CE=class extends A{static template=`o-spreadsheet.Checkbox`;props=(0,t.props)({label:N.string().optional(),value:N.boolean().optional(!1),className:N.string().optional(),name:N.string().optional(),title:N.string().optional(),disabled:N.boolean().optional(),onChange:N.function()});onChange(e){let t=e.target.checked;this.props.onChange(t)}};let wE={chartId:N.UID(),definition:N.object({}),canUpdateChart:N.function(),updateChart:N.function()},TE={ArrowDown:`down`,ArrowLeft:`left`,ArrowRight:`right`,ArrowUp:`up`};function EE(e,t){let n=TE[e.key];e.shiftKey?t.resizeAnchorZone(n,le(e)?`end`:1):t.moveAnchorCell(n,le(e)?`end`:1)}function DE(e,t,n){let{anchor:{zone:r,cell:i}}=e.getSelection(),a={...i},o=br(r);do a=OE(a,r,n),o--;while(o>0&&!kE(e,a));o>0&&t.updateAnchorCell(a.col,a.row,{scrollIntoView:!0})}function OE(e,t,n){let{col:r,row:i}=e;switch(n){case`right`:r<t.right?r++:(r=t.left,i=i<t.bottom?i+1:t.top);break;case`left`:r>t.left?r--:(r=t.right,i=i>t.top?i-1:t.bottom);break;case`down`:i<t.bottom?i++:(i=t.top,r=r<t.right?r+1:t.left);break;case`up`:i>t.top?i--:(i=t.bottom,r=r>t.left?r-1:t.right);break}return{col:r,row:i}}function kE(e,t){let n=e.getActiveSheetId();if(e.isHeaderHidden(n,`COL`,t.col)||e.isHeaderHidden(n,`ROW`,t.row))return!1;let r=e.getMainCellPosition({sheetId:n,col:t.col,row:t.row});return r.col===t.col&&r.row===t.row}function AE(e,t,n){let{x:r,y:i,width:a,height:o}=n;if(a<0||o<0)return;let s=t.color||`#017E84`,{ctx:c}=e;c.save(),t.noBorder||(t.dashed&&c.setLineDash([5,3]),c.strokeStyle=s,t.thinLine?(c.lineWidth=1,c.strokeRect(r,i,a,o)):(c.lineWidth=2,c.strokeRect(r+.5,i+.5,a,o))),t.noFill||(c.fillStyle=dp(Yf(s),t.fillAlpha??.12),c.fillRect(r,i,a,o)),c.restore()}var jE=class extends Br{mutators=[`register`,`unRegister`];providers=[];constructor(e){super(e),this.onDispose(()=>{this.providers=[]})}get renderingLayers(){return[`Highlights`]}get highlights(){let e=this.getters.getActiveSheetId();return this.providers.flatMap(e=>e.highlights).filter(t=>t.range.sheetId===e).map(e=>{let{numberOfRows:t,numberOfCols:n}=sr(e.range.zone),r=t*n===1?this.getters.expandZone(e.range.sheetId,e.range.zone):e.range.unboundedZone;return{...e,range:this.model.getters.getRangeFromZone(e.range.sheetId,r)}})}register(e){this.providers.push(e)}unRegister(e){this.providers=this.providers.filter(t=>t!==e)}drawLayer(e,t){if(t===`Highlights`)for(let t of this.highlights)AE(e,t,e.viewports.getVisibleRect(e.sheetId,t.range.zone))}},ME=class{mutators=[`focus`,`unfocus`];focusedElement=null;focus(e){this.focusedElement=e}unfocus(e){this.focusedElement&&this.focusedElement===e&&(this.focusedElement=null)}},NE=class extends Br{initialRanges;inputHasSingleRange;colors;disabledRanges;mutators=[`resetWithRanges`,`focusById`,`unfocus`,`addEmptyRange`,`removeRange`,`changeRange`,`reset`,`confirm`,`updateColors`,`updateDisabledRanges`,`toggleEditMode`];ranges=[];focusedRangeIndex=null;mode=`text-edit`;inputSheetId;focusStore=this.get(ME);highlightStore=this.get(jE);constructor(e,t=[],n=!1,r=[],i=[]){if(super(e),this.initialRanges=t,this.inputHasSingleRange=n,this.colors=r,this.disabledRanges=i,n&&t.length>1)throw Error(`Input with a single range cannot be instantiated with several range references.`);this.inputSheetId=this.getters.getActiveSheetId(),this.resetWithRanges(t),this.highlightStore.register(this),this.onDispose(()=>{this.unfocus(),this.highlightStore.unRegister(this)})}handleEvent(e){if(this.focusedRangeIndex===null)return;let t=this.inputSheetId,n=this.getters.getActiveSheetId(),r=e.options.unbounded?this.getters.getUnboundedZone(n,e.anchor.zone):e.anchor.zone,i=this.getters.getRangeFromZone(n,r);if(e.mode===`newAnchor`&&!this.inputHasSingleRange&&this.ranges[this.focusedRangeIndex].xc.trim()!==``){let e=this.getters.getSelectionRangeString(i,t);this.insertNewRange(this.ranges.length,[e]),this.focusLast()}else{let e=i.parts,n=this.ranges[this.focusedRangeIndex].xc.trim();n&&(e=this.getters.getRangeFromSheetXC(t,n).parts);let r={...i,parts:e},a=this.getters.getSelectionRangeString(r,t);this.setRange(this.focusedRangeIndex,[a])}this.mode=`select-range`}handle(e){switch(e.type){case`ACTIVATE_SHEET`:if(e.sheetIdFrom!==e.sheetIdTo){let{col:t,row:n}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0}),r=this.getters.expandZone(e.sheetIdTo,O({col:t,row:n}));this.model.selection.resetAnchor(this,{cell:{col:t,row:n},zone:r})}break;case`START_CHANGE_HIGHLIGHT`:let t=this.getters.getActiveSheetId(),n=this.getters.expandZone(t,e.zone),r=this.ranges.findIndex(e=>{let{xc:r,sheetName:i}=_l(e.xc),a=i||this.getters.getSheetName(this.inputSheetId);if(this.getters.getSheetName(t)!==a)return!1;let o=this.getters.getRangeFromSheetXC(t,r);return nr(this.getters.expandZone(t,o.zone),n)});if(r!==-1){this.focus(r);let{left:e,top:t}=n;this.model.selection.resetAnchor(this,{cell:{col:e,row:t},zone:n})}break}}changeRange(e,t){if(this.inputHasSingleRange&&t.split(`,`).length>1)return;let n=this.getIndex(e);if(n!==null&&this.focusedRangeIndex!==n&&this.focus(n),n!==null){let e=t.replace(/^,+/,``).split(`,`).map(e=>e.trim());this.setRange(n,e),this.captureSelection()}}addEmptyRange(){this.inputHasSingleRange&&this.ranges.length===1||(this.insertNewRange(this.ranges.length,[``]),this.focusLast())}removeRange(e){if(this.ranges.length===1)return;let t=this.getIndex(e);t!==null&&this.removeRangeByIndex(t)}updateColors(e){this.colors=e;let t=new Ap(this.ranges.length,this.colors);this.ranges=this.ranges.map(e=>({...e,color:t.next()}))}updateDisabledRanges(e){this.disabledRanges=e}confirm(){for(let e of this.selectionInputs)e.xc===``&&this.removeRange(e.id);let e=this.getters.getActiveSheetId();this.inputSheetId!==e&&this.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:e,sheetIdTo:this.inputSheetId}),this.selectionInputValues.join()!==this.initialRanges.join()&&this.resetWithRanges(this.selectionInputValues),this.initialRanges=this.selectionInputValues,this.unfocus()}reset(){this.resetWithRanges(this.initialRanges),this.confirm()}get selectionInputValues(){return this.cleanInputs(this.ranges.map(e=>e.xc?e.xc:``))}get selectionInputs(){return this.ranges.map((e,t)=>Object.assign({},e,{color:this.hasMainFocus&&this.focusedRangeIndex!==null&&this.getters.isRangeValid(e.xc)?e.color:null,isFocused:this.hasMainFocus&&this.focusedRangeIndex===t,isValidRange:e.xc===``||this.getters.isRangeValid(e.xc),disabled:this.disabledRanges?.[t]}))}get isResettable(){return this.initialRanges.join()!==this.ranges.map(e=>e.xc).join()}get isConfirmable(){return this.selectionInputs.every(e=>e.isValidRange)}get hasFocus(){return this.selectionInputs.some(e=>e.isFocused)}get hasMainFocus(){let e=this.focusStore.focusedElement;return!!e&&e===this}get highlights(){return this.hasMainFocus?this.ranges.map(e=>this.inputToHighlights(e)).flat():[]}focusById(e){let t=this.getIndex(e);if(this.focusedRangeIndex!==t||this.mode===`select-range`){this.focus(t),this.mode=`text-edit`;return}return`noStateChange`}focus(e){this.focusStore.focus(this),this.focusedRangeIndex=e,this.captureSelection()}focusLast(){this.focus(this.ranges.length-1)}unfocus(){this.focusedRangeIndex=null,this.focusStore.unfocus(this),this.model.selection.release(this)}captureSelection(){if(this.focusedRangeIndex===null)return;let e=this.ranges[this.focusedRangeIndex],t=this.getters.getActiveSheetId(),n=this.getters.getRangeFromSheetXC(t,e?.xc||`A1`).zone;this.model.selection.capture(this,{cell:{col:n.left,row:n.top},zone:n},{handleEvent:this.handleEvent.bind(this),release:this.unfocus.bind(this)})}resetWithRanges(e){e.length&&e.every(e=>this.getters.isRangeValid(e))&&(this.initialRanges=e),this.ranges=[],this.insertNewRange(0,e),this.ranges.length===0&&(this.insertNewRange(this.ranges.length,[``]),this.focusLast())}setContent(e,t){this.ranges[e]={...this.ranges[e],xc:t}}insertNewRange(e,t){let n=Math.max(0,...this.ranges.map(e=>Number(e.id))),r=new Ap(this.ranges.length,this.colors);for(let t=0;t<e;t++)r.next();this.ranges.splice(e,0,...t.map((e,t)=>({xc:e,id:n+t+1,color:r.next()})))}setRange(e,t){let[,...n]=t;this.setContent(e,t[0]),this.insertNewRange(e+1,n),n.length&&this.focus(e+n.length)}removeRangeByIndex(e){this.ranges.splice(e,1),this.focusedRangeIndex!==null&&this.focusLast()}inputToHighlights({xc:e,color:t}){return this.cleanInputs([e]).filter(e=>this.getters.isRangeValid(e)).filter(e=>this.shouldBeHighlighted(this.inputSheetId,e)).map(e=>{let{sheetName:n}=_l(e),r=n&&this.getters.getSheetIdByName(n)||this.inputSheetId;return{range:this.getters.getRangeFromSheetXC(r,e),color:t,interactive:!0}})}cleanInputs(e){return e.map(e=>e.split(`,`)).flat().map(e=>e.trim()).filter(e=>e!==``)}shouldBeHighlighted(e,t){let{sheetName:n}=_l(t),r=this.getters.getSheetIdByName(n),i=this.getters.getActiveSheet().id;return this.getters.isRangeValid(t)&&(r===i||r===void 0&&i===e)}getIndex(e){let t=this.ranges.findIndex(t=>t.id===e);return t>=0?t:null}toggleEditMode(){this.mode=this.mode===`select-range`?`text-edit`:`select-range`}},PE=class extends A{static template=`o-spreadsheet-SelectionInput`;props=(0,t.props)({ranges:N.array(N.string()),hasSingleRange:N.boolean().optional(),required:N.boolean().optional(),autofocus:N.boolean().optional(),isInvalid:N.boolean().optional(),class:N.string().optional(),onSelectionChanged:N.function().optional(),onSelectionConfirmed:N.function().optional(),onSelectionReordered:N.function().optional(),onSelectionRemoved:N.function().optional(),onInputFocused:N.function().optional(),colors:N.ArrayOf().optional([]),disabledRanges:N.array(N.boolean()).optional([]),disabledRangeTitle:N.string().optional()});state=(0,t.proxy)({isMissing:!1});dragAndDrop=aE();focusedInputRef=t.signal.ref(HTMLInputElement);unfocusedInputRef=t.signal.ref(HTMLInputElement);selectionRef=(0,t.signal)(null);DOMFocusableElementStore;store;get ranges(){return this.store.selectionInputs}get canAddRange(){return!this.props.hasSingleRange}get isInvalid(){return this.props.isInvalid||this.state.isMissing}get isConfirmable(){return this.store.isConfirmable}get isResettable(){return this.store.isResettable}get hasDisabledRanges(){return this.store.disabledRanges.some(Boolean)}setup(){(0,t.onWillStart)(()=>{}),(0,t.onWillUpdateProps)(async()=>{}),this.DOMFocusableElementStore=j(c_),this.store=qi(NE,this.props.ranges,this.props.hasSingleRange||!1,this.props.colors,this.props.disabledRanges),this.props.autofocus&&(this.store.focusById(this.store.selectionInputs[0]?.id),this.props.onInputFocused?.()),(0,t.useEffect)(()=>{this.focusedInputRef()?.focus()}),Ii(()=>{let e=this.selectionRef();(this.store.isResettable||this.store.hasFocus)&&e?.offsetParent===null&&this.reset()}),(0,t.onWillUpdateProps)(e=>{e.ranges.join()!==this.store.selectionInputValues.join()&&this.triggerChange(),e.ranges.join()!==this.props.ranges.join()&&e.ranges.join()!==this.store.selectionInputValues.join()&&this.store.resetWithRanges(e.ranges),e.colors?.join()!==this.props.colors?.join()&&e.colors?.join()!==this.store.colors.join()&&this.store.updateColors(e.colors||[]),!T(e.disabledRanges,this.props.disabledRanges)&&!T(e.disabledRanges,this.store.disabledRanges)&&this.store.updateDisabledRanges(e.disabledRanges||[])})}startDragAndDrop(e,t){if(t.button!==0||t.target.tagName===`SELECT`)return;let n=this.getRangeElementsRects(),r=this.ranges.map(e=>e.id),i=r.map((e,t)=>({id:e.toString(),size:n[t].height,position:n[t].y}));this.dragAndDrop.start(`vertical`,{draggedItemId:e.toString(),initialMousePosition:t.clientY,items:i,scrollableContainerEl:this.selectionRef(),onDragEnd:(t,n)=>{let i=r.findIndex(t=>t===e);if(i===n)return;let a=C(0,r.length);a.splice(i,1),a.splice(n,0,i),this.props.onSelectionReordered?.(a),this.props.onSelectionConfirmed?.(),this.store.confirm()}})}getRangeElementsRects(){return Array.from(this.selectionRef().children).map(e=>e.getBoundingClientRect())}getColor(e){let t={};return e.color&&(t.color=e.color),this.store.mode===`select-range`&&(t[`caret-color`]=`transparent`),W(t)}triggerChange(){let e=this.store.selectionInputValues;this.props.onSelectionChanged?.(e)}onKeydown(e){e.key===`F2`?(e.preventDefault(),e.stopPropagation(),this.store.toggleEditMode()):e.key.startsWith(`Arrow`)?(e.stopPropagation(),this.store.mode===`select-range`&&(e.preventDefault(),EE(e,this.env.model.selection))):e.key===`Enter`?(e.target.blur(),this.isConfirmable&&this.confirm()):e.key===`Escape`&&(this.reset(),this.DOMFocusableElementStore.focus())}extractRanges(e){return this.props.hasSingleRange?e.split(`,`)[0]:e}focus(e){this.state.isMissing=!1,this.store.focusById(e),this.props.onInputFocused?.()}addEmptyInput(){this.store.addEmptyRange()}removeInput(e){let t=this.store.selectionInputs.findIndex(t=>t.id===e);this.ranges.find(t=>t.id===e)?.xc&&(this.props.onSelectionRemoved?.(t),this.props.onSelectionConfirmed?.()),this.store.removeRange(e)}onInputChanged(e,t){let n=t.target,r=this.extractRanges(n.value);this.store.changeRange(e,r),this.triggerChange()}reset(){this.store.reset(),this.triggerChange()}confirm(){this.store.confirm();let e=this.store.selectionInputs.some(e=>this.env.model.getters.isRangeValid(e.xc));this.props.required&&!e&&(this.state.isMissing=!0),this.props.onSelectionChanged?.(this.store.selectionInputValues),this.props.onSelectionConfirmed?.()}},FE=class extends A{static template=`o-spreadsheet.ChartDataSeries`;static components={SelectionInput:PE,Section:Z};props=(0,t.props)({ranges:N.ArrayOf(),dataSetStyles:N.DataSetStyle().optional(),hasSingleRange:N.boolean().optional(),onSelectionChanged:N.function(),onSelectionReordered:N.function().optional(),onSelectionRemoved:N.function().optional(),onSelectionConfirmed:N.function(),maxNumberOfUsedRanges:N.number().optional(),title:N.string().optional(),datasetOrientation:N.or([N.literal(`rows`),N.literal(`columns`)]).optional(),canChangeDatasetOrientation:N.boolean().optional(),onFlipAxis:N.function().optional()});get ranges(){return this.props.ranges.map(e=>e.dataRange)}setup(){(0,t.onWillUpdateProps)(async()=>{})}get disabledRanges(){return this.props.ranges.map((e,t)=>this.props.maxNumberOfUsedRanges?t>=this.props.maxNumberOfUsedRanges:!1)}get colors(){return this.props.ranges.map(e=>this.props.dataSetStyles?.[e.dataSetId]?.backgroundColor)}get title(){return this.props.title?this.props.title:this.props.hasSingleRange?P(`Data range`):P(`Data series`)}},IE=class extends A{static template=`o-spreadsheet.ChartLabelRange`;static components={SelectionInput:PE,Checkbox:CE,Section:Z};props=(0,t.props)({title:N.string().optional(P(`Categories / Labels`)),range:N.string(),class:N.string().optional(),isInvalid:N.boolean(),onSelectionChanged:N.function(),onSelectionConfirmed:N.function(),options:N.ArrayOf().optional([])});get sectionClass(){return`o-data-labels`+(this.props.class?` ${this.props.class}`:``)}},LE=class extends A{static template=`o-spreadsheet-ChartDataSourceComponent`;static components={ChartDataSeries:FE,ChartLabelRange:IE};props=(0,t.props)({chartId:N.UID(),definition:N.ChartDefinitionWithDataSource(),updateChart:N.function(),canUpdateChart:N.function(),dataSeriesTitle:N.string().optional(),labelRangeTitle:N.string().optional(),getLabelRangeOptions:N.function().optional()});get DataSourceComponent(){let e=this.props.definition.dataSource.type;return SE.get(e)}},RE=class extends A{static template=`o-spreadsheet-ValidationMessages`;props=(0,t.props)({messages:N.array(N.string()).optional(),msgType:N.or([N.literal(`warning`),N.literal(`error`),N.literal(`info`)]),slots:N.object().optional()});get divClasses(){return this.props.msgType===`warning`?`o-validation-warning`:this.props.msgType===`info`?`o-validation-info`:`o-validation-error`}},zE=class extends A{static template=`o-spreadsheet.ChartErrorSection`;static components={Section:Z,ValidationMessages:RE};props=(0,t.props)({messages:N.array(N.string())})},BE=class extends A{static template=`o-spreadsheet-GenericChartConfigPanel`;static components={ChartDataSourceComponent:LE,Section:Z,Checkbox:CE,ChartErrorSection:zE};props=(0,t.props)(wE);chartTerms=I_;state=(0,t.proxy)({errorMessages:[]});onErrorMessagesChanged(e){this.state.errorMessages=e}get errorMessages(){return this.state.errorMessages}getLabelRangeOptions(){return[this.getAggregateLabelRangeOption()]}getAggregateLabelRangeOption(){return{name:`aggregated`,label:this.chartTerms.AggregatedChart,value:(`aggregated`in this.props.definition?this.props.definition.aggregated:!1)??!1,onChange:e=>{this.props.updateChart(this.props.chartId,{aggregated:e})}}}},VE=class extends BE{static template=`o-spreadsheet-BarConfigPanel`;get stackedLabel(){return this.props.definition.horizontal?this.chartTerms.StackedBarChart:this.chartTerms.StackedColumnChart}onUpdateStacked(e){this.props.updateChart(this.props.chartId,{stacked:e})}getLabelRangeOptions(){return[this.getAggregateLabelRangeOption()]}},HE=class extends A{static template=`o-spreadsheet-Collapse`;props=(0,t.props)({isCollapsed:N.boolean()});contentRef=(0,t.signal)(null);setup(){(0,t.onMounted)(()=>{this.props.isCollapsed&&this.contentRef()?.classList.add(`d-none`)}),(0,t.onWillUpdateProps)(e=>{e.isCollapsed!==this.props.isCollapsed&&this.startTransition(e.isCollapsed)})}startTransition(e){let t=this.contentRef();if(!t)return;t.classList.remove(`d-none`),t.classList.add(`overflow-hidden`);let n=e?t.scrollHeight:0,r=e?0:t.scrollHeight,i=t.animate([{maxHeight:n+`px`},{maxHeight:r+`px`}],{duration:350,easing:`ease`});i.onfinish=()=>{t.classList.remove(`overflow-hidden`),this.props.isCollapsed&&t.classList.add(`d-none`)}}},UE=class extends A{static template=`o-spreadsheet-SidePanelCollapsible`;static components={Collapse:HE};props=(0,t.props)({title:N.string().optional(),isInitiallyCollapsed:N.boolean().optional(),class:N.string().optional()});state=(0,t.proxy)({isCollapsed:!!this.props.isInitiallyCollapsed});toggle(){this.state.isCollapsed=!this.state.isCollapsed}},WE=class extends A{static template=`o-spreadsheet.ChartAnnotation`;static components={SidePanelCollapsible:UE,Section:Z,TextInput:pE};props=(0,t.props)(wE);editorRef=(0,t.signal)(null);state=(0,t.proxy)({annotationTextInput:this.props.definition.annotationText||``,isOverflowing:!1});setup(){Ii((e,t)=>{e&&!e.matches(`:focus`)&&e.innerText!==(t||``)&&(e.innerText=t||``,this.state.annotationTextInput=t||``,this.updateOverflowState(e))},()=>[this.editorRef(),this.props.definition.annotationText]),Ii(e=>{if(!e)return;let t=new ResizeObserver(()=>this.updateOverflowState(e));return t.observe(e),this.updateOverflowState(e),()=>t.disconnect()},()=>[this.editorRef()])}updateOverflowState(e){this.state.isOverflowing=e.scrollHeight>e.clientHeight}get annotationPlaceholder(){return P(`Add a description text`)}checkLength(e){e.target.innerText.length>=2e3&&!e.inputType.startsWith(`delete`)&&e.preventDefault()}onInput(e){let t=e.target,n=t.innerText.trim();n===``?(t.replaceChildren(),this.state.annotationTextInput=``):n.length>2e3?(t.innerText=n.substring(0,2e3),this.state.annotationTextInput=t.innerText.trim()):this.state.annotationTextInput=n,this.updateOverflowState(t)}onBlur(){this.props.updateChart(this.props.chartId,{annotationText:this.state.annotationTextInput})}updateAnnotationLink(e){e&&=zd(e),this.props.updateChart(this.props.chartId,{annotationLink:e})}},GE=class extends fE{static template=`o-spreadsheet-NumberInput`;static components={};props=(0,t.props)({...dE,min:N.number().optional(),max:N.number().optional()});debouncedOnChange=Vt(this.props.onChange.bind(this),100,!0);save(){let e=(this.genericInputRef()?.value||``).trim();e!==this.props.value.toString()&&this.debouncedOnChange(e)}get inputClass(){return[this.props.class,`o-input`].join(` `)}},KE=class extends GE{static template=`o-spreadsheet-DateInput`},qE=class extends A{static template=`o-spreadsheet.BadgeSelection`;props=(0,t.props)({choices:N.ArrayOf(),onChange:N.function(),selectedValue:N.string()})},JE=class extends A{static template=`o-spreadsheet.ChartTitle`;static components={Section:Z,TextStyler:yE,TextInput:pE};props=(0,t.props)({title:N.string().optional(``),placeholder:N.string().optional(``),updateTitle:N.function(),name:N.string().optional(),style:N.TitleDesign(),defaultStyle:N.object().optional(),updateStyle:N.function()});updateTitle(e){this.props.updateTitle(e)}},YE=class extends A{static template=`o-spreadsheet-AxisDesignEditor`;static components={Section:Z,ChartTitle:JE,BadgeSelection:qE,Checkbox:CE,NumberInput:GE,DateInput:KE};props=(0,t.props)({chartId:N.UID(),definition:N.ChartWithAxisDefinition(),updateChart:N.function(),axesList:N.ArrayOf()});state=(0,t.proxy)({currentAxis:`x`});defaultFontSize=12;get axisTitleStyle(){return this.props.definition.axesDesign?.[this.state.currentAxis]?.title??{}}get badgeAxes(){return this.props.axesList.map(e=>({value:e.id,label:e.name}))}getAxisTitle(){return(this.props.definition.axesDesign??{})[this.state.currentAxis]?.title?.text||``}updateAxisTitle(e){let t=x(this.props.definition.axesDesign)??{};t[this.state.currentAxis]={...t[this.state.currentAxis],title:{...t?.[this.state.currentAxis]?.title,text:e}},this.props.updateChart(this.props.chartId,{axesDesign:t})}updateAxisTitleStyle(e){let t=x(this.props.definition.axesDesign)??{};t[this.state.currentAxis]={...t[this.state.currentAxis],title:e},this.props.updateChart(this.props.chartId,{axesDesign:t})}get axisMin(){let e=this.currentAxisDesign?.min;return(this.isTimeAxis?this.formatAxisBoundary(e):e)??``}get axisMax(){let e=this.currentAxisDesign?.max;return(this.isTimeAxis?this.formatAxisBoundary(e):e)??``}get isMajorGridEnabled(){let e=this.currentAxisDesign?.gridLines;return e===void 0?this.getDefaultMajorGridValue(this.state.currentAxis):e===`major`||e===`both`}get isMinorGridEnabled(){return this.currentAxisDesign?.gridLines===`minor`||this.currentAxisDesign?.gridLines===`both`}get isValueAxis(){return`horizontal`in this.props.definition&&this.props.definition.horizontal?this.state.currentAxis===`x`:this.state.currentAxis!==`x`}get majorGridLabel(){return this.state.currentAxis===`x`?P(`Major vertical gridlines`):P(`Major horizontal gridlines`)}get minorGridLabel(){return this.state.currentAxis===`x`?P(`Minor vertical gridlines`):P(`Minor horizontal gridlines`)}updateAxisMin(e){let t=e===``?void 0:Number(e);if(t===void 0||!isNaN(t)){let e=x(this.props.definition.axesDesign)??{};e[this.state.currentAxis]={...e[this.state.currentAxis],min:t},this.props.updateChart(this.props.chartId,{axesDesign:e})}}updateTimeAxisMin(e){let t=this.parseTimeAxisBoundaryValue(e);if(t===null)return;let n=x(this.props.definition.axesDesign)??{};n[this.state.currentAxis]={...n[this.state.currentAxis],min:t},this.props.updateChart(this.props.chartId,{axesDesign:n})}updateAxisMax(e){let t=e===``?void 0:Number(e);if(t===void 0||!isNaN(t)){let e=x(this.props.definition.axesDesign)??{};e[this.state.currentAxis]={...e[this.state.currentAxis],max:t},this.props.updateChart(this.props.chartId,{axesDesign:e})}}updateTimeAxisMax(e){let t=this.parseTimeAxisBoundaryValue(e);if(t===null)return;let n=x(this.props.definition.axesDesign)??{};n[this.state.currentAxis]={...n[this.state.currentAxis],max:t},this.props.updateChart(this.props.chartId,{axesDesign:n})}toggleMajorGrid(e){let t=x(this.props.definition.axesDesign)??{},n=`none`;n=this.isMinorGridEnabled?e?`both`:`minor`:e?`major`:`none`,t[this.state.currentAxis]={...t[this.state.currentAxis],gridLines:n},this.props.updateChart(this.props.chartId,{axesDesign:t})}toggleMinorGrid(e){let t=x(this.props.definition.axesDesign)??{},n=`none`;n=this.isMajorGridEnabled?e?`both`:`major`:e?`minor`:`none`,t[this.state.currentAxis]={...t[this.state.currentAxis],gridLines:n},this.props.updateChart(this.props.chartId,{axesDesign:t})}get currentAxisDesign(){return this.props.definition.axesDesign?.[this.state.currentAxis]}getDefaultMajorGridValue(e){let{useLeftAxis:t,useRightAxis:n}=fm(this.props.definition);if(e===`x`){if(`horizontal`in this.props.definition&&this.props.definition.horizontal||this.props.definition.type===`scatter`)return!0}else if(e===`y`)return!0;else if(e===`y1`)return!t&&n;return!1}get isCategoricalAxis(){if(this.isValueAxis)return!1;let e=this.getXAxisType();return e===void 0||e===`category`}get isTimeAxis(){return this.state.currentAxis===`x`&&this.getXAxisType()===`time`}get canChangeMinorGridVisibility(){if(this.isValueAxis)return!0;if(this.isCategoricalAxis)return!1;let e=this.props.definition.type;return e===`line`||e===`scatter`}parseTimeAxisBoundaryValue(e){let t=L(e,this.env.model.getters.getLocale());return Number.isNaN(t)?null:t}formatAxisBoundary(e){if(e!==void 0)return H(e,{format:`yyyy-mm-dd`,locale:this.env.model.getters.getLocale()})}getXAxisType(){return this.env.model.getters.getChartRuntime(this.props.chartId)?.chartJsConfig.options?.scales?.x?.type}},XE=class extends A{static template=`o-spreadsheet.RadioSelection`;props=(0,t.props)({choices:N.ArrayOf(),onChange:N.function(),selectedValue:N.string(),name:N.string(),direction:N.or([N.literal(`horizontal`),N.literal(`vertical`)]).optional(`horizontal`)})},ZE=class extends A{static template=`o-spreadsheet.RoundColorPicker`;static components={Section:Z,ColorPicker:hE};props=(0,t.props)({currentColor:N.string().optional(),title:N.string().optional(),onColorPicked:N.function(),disableNoColor:N.boolean().optional()});colorPickerButtonRef=(0,t.signal)(null);state;setup(){this.state=(0,t.proxy)({pickerOpened:!1}),Fi(window,`click`,this.closePicker)}closePicker(){this.state.pickerOpened=!1}togglePicker(){this.state.pickerOpened=!this.state.pickerOpened}onColorPicked(e){this.props.onColorPicked(e),this.state.pickerOpened=!1}get colorPickerAnchorRect(){return y(this.colorPickerButtonRef())}get buttonStyle(){return W({background:this.props.currentColor})}},QE=class extends A{static template=`o-spreadsheet-GeneralDesignEditor`;static components={RoundColorPicker:ZE,ChartTitle:JE,Section:Z,SidePanelCollapsible:UE,RadioSelection:XE};props=(0,t.props)({chartId:N.UID(),definition:N.ChartDefinition(),canUpdateChart:N.function(),updateChart:N.function(),defaultChartTitleFontSize:N.number().optional(16)});state;setup(){this.state=(0,t.proxy)({activeTool:``})}get title(){return this.props.definition.title}toggleDropdownTool(e,t){let n=this.state.activeTool===e;this.state.activeTool=n?``:e}updateBackgroundColor(e){this.props.updateChart(this.props.chartId,{background:e})}updateTitle(e){let t={...this.title,text:e};this.props.updateChart(this.props.chartId,{title:t})}updateChartTitleStyle(e){let t={...this.title,...e};this.props.updateChart(this.props.chartId,{title:t}),this.state.activeTool=``}},$E=class extends A{static template=`o-spreadsheet-ChartHumanizeNumbers`;static components={Checkbox:CE};props=(0,t.props)(wE);get title(){let e=this.env.model.getters.getLocale();return P(`E.g. 1234567 -> %(value)s`,{value:H(1234567,{format:Ec({value:1234567},void 0,e),locale:e})})}},eD=class extends A{static template=`o-spreadsheet-ChartLegend`;static components={Section:Z,Select:w_};props=(0,t.props)({chartId:N.string(),definition:N.ChartDefinitionWithDataSource(),canUpdateChart:N.function(),updateChart:N.function(),isDisabled:N.boolean().optional(!1)});updateLegendPosition(e){this.props.updateChart(this.props.chartId,{legendPosition:e})}get legendValues(){return[{value:`none`,label:P(`None`)},{value:`top`,label:P(`Top`)},{value:`bottom`,label:P(`Bottom`)},{value:`left`,label:P(`Left`)},{value:`right`,label:P(`Right`)}]}},tD=class extends A{static template=`o-spreadsheet-SeriesDesignEditor`;static components={SidePanelCollapsible:UE,Section:Z,RoundColorPicker:ZE,Select:w_};props=(0,t.props)({chartId:N.UID(),definition:N.ChartDefinitionWithDataSource(),updateChart:N.function(),canUpdateChart:N.function()});state=(0,t.proxy)({dataSetId:this.getDataSeries()[0]?.dataSetId||``});getRuntime(){let e=this.env.model.getters.getChartRuntime(this.props.chartId);if(!e||!(`customizableSeries`in e))throw Error(`SeriesDesignEditor: chart runtime is not compatible with series customization.`);return e}getDataSeries(){return this.getRuntime().customizableSeries}updateEditedSeries(e){this.state.dataSetId=e}updateDataSeriesColor(e){let t={...this.props.definition.dataSetStyles};t[this.state.dataSetId]={...t[this.state.dataSetId],backgroundColor:e},this.props.updateChart(this.props.chartId,{dataSetStyles:t})}getDataSeriesColor(){let e=this.props.definition.dataSetStyles?.[this.state.dataSetId]?.backgroundColor,t=this.getDataSeries(),n=t.findIndex(e=>e.dataSetId===this.state.dataSetId);return e?Yf(e):Dp(n,Op(t.length))}updateDataSeriesLabel(e){let t=e.target.value,n={...this.props.definition.dataSetStyles};n[this.state.dataSetId]={...n[this.state.dataSetId],label:t},this.props.updateChart(this.props.chartId,{dataSetStyles:n})}getDataSeriesLabel(){return this.props.definition.dataSetStyles?.[this.state.dataSetId]?.label||this.getDataSeries().find(e=>e.dataSetId===this.state.dataSetId)?.label||``}get selectOptions(){return this.getDataSeries().map(({label:e,dataSetId:t})=>({value:t,label:e}))}},nD=class extends A{static template=`o-spreadsheet-SeriesWithAxisDesignEditor`;static components={SeriesDesignEditor:tD,Checkbox:CE,RadioSelection:XE,Section:Z,RoundColorPicker:ZE,NumberInput:GE,Select:w_};props=(0,t.props)({chartId:N.UID(),definition:N.ChartDefinitionWithDataSource(),updateChart:N.function(),canUpdateChart:N.function()});axisChoices=hm;updateDataSeriesAxis(e,t){let n={...this.props.definition.dataSetStyles};n[e]={...n[e],yAxisId:t===`left`?`y`:`y1`},this.props.updateChart(this.props.chartId,{dataSetStyles:n})}getDataSerieAxis(e){let t=this.props.definition.dataSetStyles;return t?.[e]&&t[e]?.yAxisId===`y1`?`right`:`left`}get canHaveTwoVerticalAxis(){return!(`horizontal`in this.props.definition&&this.props.definition.horizontal)}toggleDataTrend(e,t){let n={...this.props.definition.dataSetStyles};n[e]={...n[e],trend:{type:`polynomial`,order:1,...n[e]?.trend,display:t}},this.props.updateChart(this.props.chartId,{dataSetStyles:n})}getTrendLineConfiguration(e){return this.props.definition.dataSetStyles?.[e]?.trend}getTrendType(e){return e?e.type===`polynomial`&&e.order===1?`linear`:e.type:``}onChangeTrendType(e,t){let n;switch(t){case`linear`:case`polynomial`:n={type:`polynomial`,order:t===`linear`?1:this.getMaxPolynomialDegree(e)};break;case`exponential`:case`logarithmic`:case`trailingMovingAverage`:n={type:t};break;default:return}this.updateTrendLineValue(e,n)}get trendOptions(){return[{value:`linear`,label:P(`Linear`)},{value:`polynomial`,label:P(`Polynomial`)},{value:`exponential`,label:P(`Exponential`)},{value:`logarithmic`,label:P(`Logarithmic`)},{value:`trailingMovingAverage`,label:P(`Trailing moving average`)}]}getPolynomialDegrees(e){return C(1,this.getMaxPolynomialDegree(e)+1).map(e=>({value:e.toString(),label:e.toString()}))}onChangePolynomialDegree(e,t){this.updateTrendLineValue(e,{order:parseInt(t)})}getMaxPolynomialDegree(e){let t=this.env.model.getters.getChartRuntime(this.props.chartId),n=t.customizableSeries.findIndex(t=>t.dataSetId===e);return Math.min(10,t.chartJsConfig.data.datasets[n].data.length-1)}get defaultWindowSize(){return 2}onChangeMovingAverageWindow(e,t){let n=parseInt(t)||2;n<=1&&(n=2),this.updateTrendLineValue(e,{window:n})}getDataSeriesColor(e){let t=this.props.definition.dataSetStyles;if(!t?.[e])return``;let n=t[e]?.backgroundColor,r=this.env.model.getters.getChartRuntime(this.props.chartId),i=r.customizableSeries.findIndex(t=>t.dataSetId===e);return n?Yf(n):Dp(i,Op(r.customizableSeries.length))}getTrendLineColor(e){return this.getTrendLineConfiguration(e)?.color??dp(this.getDataSeriesColor(e),.5)}updateTrendLineColor(e,t){this.updateTrendLineValue(e,{color:t})}updateTrendLineValue(e,t){let n={...this.props.definition.dataSetStyles};n[e]={...n[e],trend:{...n[e]?.trend,...t}},this.props.updateChart(this.props.chartId,{dataSetStyles:n})}},rD=class extends A{static template=`o-spreadsheet-ChartShowValues`;static components={Checkbox:CE};props=(0,t.props)({chartId:N.UID(),definition:N.ChartDefinitionWithDataSource(),canUpdateChart:N.function(),updateChart:N.function(),defaultValue:N.boolean().optional()})},iD=class extends A{static template=`o-spreadsheet-ChartWithAxisDesignPanel`;static components={GeneralDesignEditor:QE,ChartAnnotation:WE,SidePanelCollapsible:UE,Section:Z,AxisDesignEditor:YE,SeriesWithAxisDesignEditor:nD,ChartLegend:eD,ChartShowValues:rD,ChartHumanizeNumbers:$E};props=(0,t.props)(wE);get axesList(){let{useLeftAxis:e,useRightAxis:t}=fm(this.props.definition),n=[{id:`x`,name:P(`Horizontal axis`)}];return e&&n.push({id:`y`,name:P(t?`Left axis`:`Vertical axis`)}),t&&n.push({id:`y1`,name:P(e?`Right axis`:`Vertical axis`)}),n}},aD=class extends iD{static template=`o-spreadsheet-GenericZoomableChartDesignPanel`;static components={...iD.components,Checkbox:CE};onToggleZoom(e){this.props.updateChart(this.props.chartId,{zoomable:e})}},oD=class extends aD{static template=`o-spreadsheet-BarChartDesignPanel`;get isZoomable(){return!this.props.definition.horizontal}},sD=class extends A{static template=`o-spreadsheet-BubbleChartConfigPanel`;static components={ChartDataSeries:FE,ChartLabelRange:IE,ChartErrorSection:zE};props=(0,t.props)(wE);state=(0,t.proxy)({datasetDispatchResult:void 0,labelsDispatchResult:void 0,xRangeDispatchResult:void 0,sizeRangeDispatchResult:void 0});yRanges=[];labelRange;datasetOrientation;xRange;sizeRange;setup(){let e=this.props.definition;this.yRanges=e.yRanges||[],this.labelRange=e.labelRange,this.xRange=e.xRange,this.sizeRange=e.sizeRange,this.datasetOrientation=this.computeDatasetOrientation()}get errorMessages(){return[...this.state.datasetDispatchResult?.reasons||[],...this.state.xRangeDispatchResult?.reasons||[],...this.state.labelsDispatchResult?.reasons||[],...this.state.sizeRangeDispatchResult?.reasons||[]].filter(e=>e!==`NoChanges`).map(e=>I_.Errors[e]||I_.Errors.Unexpected)}get isLabelInvalid(){return!!this.state.labelsDispatchResult?.isCancelledBecause(`InvalidLabelRange`)}get isXDataInvalid(){return!!this.state.xRangeDispatchResult?.isCancelledBecause(`InvalidXRange`)}get isYDataInvalid(){return!!this.state.datasetDispatchResult?.isCancelledBecause(`InvalidYRange`)}get isBubbleSizeRangeInvalid(){return!!this.state.sizeRangeDispatchResult?.isCancelledBecause(`InvalidBubbleSizeRange`)}get dataSetsHaveTitleLabel(){return this.datasetOrientation===`rows`?P(`Use col %(column_name)s as headers`,{column_name:Cn(this.calculateHeaderPosition()||0)}):P(`Use row %(row_position)s as headers`,{row_position:this.calculateHeaderPosition()||``})}getDataSeriesRanges(){return this.yRanges.map((e,t)=>({dataRange:e,dataSetId:`${t}`}))}onDataSeriesRangesChanged(e){this.yRanges=e,this.state.datasetDispatchResult=this.props.canUpdateChart(this.props.chartId,{yRanges:this.yRanges})}onDataSeriesConfirmed(){this.datasetOrientation=this.computeDatasetOrientation(),this.state.datasetDispatchResult=this.props.updateChart(this.props.chartId,{yRanges:this.yRanges})}onDataSeriesReordered(e){this.yRanges=e.map(e=>this.yRanges[e]),this.state.datasetDispatchResult=this.props.updateChart(this.props.chartId,{yRanges:this.yRanges})}onDataSeriesRemoved(e){this.yRanges=this.yRanges.filter((t,n)=>n!==e),this.state.datasetDispatchResult=this.props.updateChart(this.props.chartId,{yRanges:this.yRanges})}onLabelRangeChanged(e){this.labelRange=e[0],this.state.labelsDispatchResult=this.props.canUpdateChart(this.props.chartId,{labelRange:this.labelRange})}onLabelRangeConfirmed(){this.state.labelsDispatchResult=this.props.updateChart(this.props.chartId,{labelRange:this.labelRange})}onUpdateDataSetsHaveTitle(e){this.props.updateChart(this.props.chartId,{dataSetsHaveTitle:e})}onXDataRangeChanged(e){this.xRange=e[0],this.state.xRangeDispatchResult=this.props.canUpdateChart(this.props.chartId,{xRange:this.xRange})}onXDataRangeConfirmed(){this.state.xRangeDispatchResult=this.props.updateChart(this.props.chartId,{xRange:this.xRange})}onBubbleSizeRangeChanged(e){this.sizeRange=e[0],this.state.sizeRangeDispatchResult=this.props.canUpdateChart(this.props.chartId,{sizeRange:this.sizeRange})}onBubbleSizeRangeConfirmed(){this.state.sizeRangeDispatchResult=this.props.updateChart(this.props.chartId,{sizeRange:this.sizeRange})}getLabelRangeOptions(){let e=this.props.definition;return[{name:`dataSetsHaveTitle`,label:this.dataSetsHaveTitleLabel,value:e.dataSetsHaveTitle,onChange:this.onUpdateDataSetsHaveTitle.bind(this)}]}calculateHeaderPosition(){if(this.isYDataInvalid)return;let e=this.yRanges[0]??this.xRange??``,t=this.env.model.getters,n=wu(t,t.getActiveSheetId(),e||``)?.zone;if(n)return this.datasetOrientation===`rows`?n.left:n.top+1}computeDatasetOrientation(){let e=!1,t=!1;for(let n of this.yRanges){let r=this.env.model.getters,i=wu(r,r.getActiveSheetId(),n)?.zone;if(!i)return;i.top===i.bottom&&(e=!0),i.left===i.right&&(t=!0)}if(e&&!t)return`rows`;if(!e&&t)return`columns`}},cD=class extends A{static template=`o-spreadsheet-BubbleChartDesignPanel`;static components={GeneralDesignEditor:QE,SidePanelCollapsible:UE,Section:Z,AxisDesignEditor:YE,ChartLegend:eD,ChartShowValues:rD,ChartHumanizeNumbers:$E,RadioSelection:XE,RoundColorPicker:ZE,Checkbox:CE,ChartAnnotation:WE};props=(0,t.props)(wE);get axesList(){return[{id:`x`,name:P(`Horizontal axis`)},{id:this.verticalAxisPosition===`right`?`y1`:`y`,name:P(`Vertical axis`)}]}colorModeChoices=[{value:`single`,label:P(`Single color`)},{value:`multiple`,label:P(`Multiple colors`)}];axisChoices=hm;get colorMode(){return this.props.definition.bubbleColor.color===`multiple`?`multiple`:`single`}onColorModeChange(e){this.updateBubbleColor(e===`multiple`?`multiple`:yp)}get verticalAxisPosition(){return this.props.definition.verticalAxisPosition??`left`}updateVerticalAxisPosition(e){this.props.updateChart(this.props.chartId,{verticalAxisPosition:e})}updateBubbleColor(e){let t=this.props.definition.bubbleColor;this.props.updateChart(this.props.chartId,{bubbleColor:{...t,color:e}})}get currentBubbleColor(){return this.colorMode===`multiple`?yp:this.props.definition.bubbleColor.color}get areBubblesTransparent(){return this.props.definition.bubbleColor.transparent||!1}updateBubbleTransparency(e){let t=this.props.definition.bubbleColor;this.props.updateChart(this.props.chartId,{bubbleColor:{...t,transparent:e}})}};function lD(e){return e=Yf(e).replace(`#`,``),e.length===8?e.slice(6)+e.slice(0,6):e}let uD=Symbol(`NULL`);function dD(e,t,n){let r=e.granularity||`month`;if(!(r in fD))throw Error(`Unknown date granularity: ${r}`);let i=typeof t==`number`||typeof t==`string`?t:uD;if(!fD[r].set.has(t)){fD[r].set.add(t);let a=null;if(typeof t==`number`||typeof t==`string`){let e=qo(t,n);switch(r){case`year`:a=e.getFullYear();break;case`quarter_number`:a=Math.floor(e.getMonth()/3)+1;break;case`month_number`:a=e.getMonth()+1;break;case`month`:a=Math.floor(L(t,n));break;case`iso_week_number`:a=e.getIsoWeek();break;case`day_of_month`:a=e.getDate();break;case`day`:a=Math.floor(L(t,n));break;case`day_of_week`:a=(e.getDay()+7-n.weekStart)%7+1;break;case`hour_number`:a=e.getHours();break;case`minute_number`:a=e.getMinutes();break;case`second_number`:a=e.getSeconds();break}}fD[r].values[i]=uC(e,a)}return fD[r].values[i]}let fD={year:{set:new Set,values:{}},quarter_number:{set:new Set,values:{}},month_number:{set:new Set,values:{}},month:{set:new Set,values:{}},iso_week_number:{set:new Set,values:{}},day_of_month:{set:new Set,values:{}},day:{set:new Set,values:{}},day_of_week:{set:new Set,values:{}},hour_number:{set:new Set,values:{}},minute_number:{set:new Set,values:{}},second_number:{set:new Set,values:{}}};function pD(){for(let e in fD)fD[e].set.clear(),fD[e].values={}}let mD=Object.freeze({value:null}),hD=Object.freeze({value:0});function gD(e,{labelValues:t,dataSetsValues:n},r){let i=r.getLocale(),a=t.map(({value:e,format:t})=>H(e,{format:t,locale:i}));({labels:a,dataSetsValues:n}=UD(a,n)),e.aggregated&&({labels:a,dataSetsValues:n}=qD(a,n));let o=YD(e.dataSetStyles,n,`left`),s=YD(e.dataSetStyles,n,`right`),c=e.horizontal?{x:o||s}:{y:o,y1:s},l=[];for(let t in n){let{data:r,dataSetId:i}=n[t],a=e.dataSetStyles?.[i]?.trend;if(!a?.display||e.horizontal){l.push(void 0);continue}let o=kD(a,r);l.push(o)}return{dataSetsValues:n,trendDataSetsValues:l,axisFormats:c,labels:a,locale:r.getLocale(),topPadding:ZD(e,r),background:ym(e,r)}}function _D(e,t){switch(t){case`day_of_week`:return Zs[e-1].toString();case`hour_number`:{let t=String(e%12).padStart(2,`0`);return P(e<12?`%(hour)s AM`:`%(hour)s PM`,{hour:t})}case`month_number`:return Xs[e-1].toString();case`iso_week_number`:return P(`W%(weekNumber)s`,{weekNumber:String(e).padStart(2,`0`)});case`quarter_number`:return P(`Q%(value)s`,{value:e});default:return e.toString()}}function vD(e,t,n,r,i){let a={},o=[],s=[],c=[];for(let l=0;l<e?.length;l++){let u=L(dD({granularity:n,type:`date`,displayName:`date`},e[l].value,V),i);u in a||(o.push(u),a[u]={});let d=L(dD({granularity:r,type:`date`,displayName:`date`},e[l].value,V),i);c.includes(d)||(s.push(d),c.push(d)),d in a[u]||(a[u][d]={value:0});let f=t[l];tf(f)&&(a[u][d].value+=f.value)}return o.sort((e,t)=>e-t),s.sort((e,t)=>t-e),{dataSetsValues:s.map(e=>({data:o.map(t=>a?.[t]?.[e]),label:_D(e,r),hidden:!1,dataSetId:`0`})),labels:o.map(e=>({value:_D(e,n)}))}}function yD(e,{labelValues:t,dataSetsValues:n},r){let i=t,a=r.getLocale();({labels:i,dataSetsValues:n}=WD(i,n));let o={y:YD(e.dataSetStyles,n,`left`)};return{labels:i,dataSetsValues:n}=vD(i,n[0]?.data??[],e.horizontalGroupBy??`day_of_week`,e.verticalGroupBy??`hour_number`,a),{dataSetsValues:n,axisFormats:o,labels:i.map(({value:e})=>String(e??``)),locale:r.getLocale(),topPadding:ZD(e,r),background:ym(e,r)}}function bD(e,{labelValues:t,dataSetsValues:n},r){let i=gD(e,{labelValues:t,dataSetsValues:n.slice(0,2)},r),a=i.dataSetsValues.filter(e=>!e.hidden),o=[];if(a[0]){let e=a[0].data.map(e=>tf(e)&&e.value>0?e:hD);o.push({...a[0],data:e})}if(a[1]){let e=a[1].data.map(e=>tf(e)&&e.value>0?{value:-e.value}:hD);o.push({...a[1],data:e})}return{...i,dataSetsValues:o}}function xD(e,{labelValues:t,dataSetsValues:n},r){let i=ND(e,{labelValues:t,dataSetsValues:n}),a=i===`linear`?t.map(({value:e})=>String(e??``)):t.map(({value:e,format:t})=>H(e,{format:t,locale:r.getLocale()}));({labels:a,dataSetsValues:n}=UD(a,n)),i===`time`&&({labels:a,dataSetsValues:n}=HD(a,n)),e.aggregated&&({labels:a,dataSetsValues:n}=qD(a,n)),e.cumulative&&(n=XD(n,`asc`));let o={y:YD(e.dataSetStyles,n,`left`),y1:YD(e.dataSetStyles,n,`right`),x:JD(t)},s=[];for(let t in n){let{data:o,dataSetId:c}=n[t],l=e.dataSetStyles?.[c]?.trend;if(!l?.display){s.push(void 0);continue}s.push(AD(l,o,a,i,r.getLocale()))}return{dataSetsValues:n,axisFormats:o,labels:a,locale:r.getLocale(),trendDataSetsValues:s,axisType:i,topPadding:ZD(e,r),background:ym(e,r)}}function SD(e,{labelValues:t,dataSetsValues:n},r){let i=t.map(({value:e,format:t})=>H(e,{format:t,locale:r.getLocale()}));({labels:i,dataSetsValues:n}=UD(i,n)),e.aggregated&&({labels:i,dataSetsValues:n}=qD(i,n)),{dataSetsValues:n,labels:i}=VD(i,n);let a=YD(e.dataSetStyles,n,`left`);return{dataSetsValues:n,axisFormats:{y:a},labels:i,locale:r.getLocale(),topPadding:ZD(e,r),background:ym(e,r)}}function CD(e,{labelValues:t,dataSetsValues:n},r){let i=t.map(({value:e,format:t})=>H(e,{format:t,locale:r.getLocale()}));({labels:i,dataSetsValues:n}=UD(i,n)),e.aggregated&&({labels:i,dataSetsValues:n}=qD(i,n));let a={r:YD(e.dataSetStyles,n,`left`)||YD(e.dataSetStyles,n,`right`)};return{dataSetsValues:n,axisFormats:a,labels:i,locale:r.getLocale(),background:ym(e,r)}}function wD(e,{labelValues:t,dataSetsValues:n},r){n=n.slice(0,1);let i=t.map(({value:e,format:t})=>H(e,{format:t,locale:r.getLocale()}));({labels:i,dataSetsValues:n}=qD(i,n));let a=YD(e.dataSetStyles,n,`left`)||YD(e.dataSetStyles,n,`right`);return{dataSetsValues:n,axisFormats:{y:a},labels:i,locale:r.getLocale(),availableRegions:r.getGeoChartAvailableRegions(),geoFeatureNameToId:r.geoFeatureNameToId,getGeoJsonFeatures:r.getGeoJsonFeatures,background:ym(e,r)}}function TD(e,{labelValues:t,dataSetsValues:n},r){let i=t.map(({value:e,format:t})=>H(e,{format:t,locale:r.getLocale()}));({labels:i,dataSetsValues:n}=UD(i,n)),e.aggregated&&({labels:i,dataSetsValues:n}=qD(i,n)),e.cumulative&&(n=XD(n,`desc`));let a=YD(e.dataSetStyles,n,`left`)||YD(e.dataSetStyles,n,`right`);return{dataSetsValues:n,axisFormats:{x:a},labels:i,locale:r.getLocale(),background:ym(e,r)}}function ED(e,{labelValues:t,dataSetsValues:n},r){let i=t;return{labels:i,dataSetsValues:n}=KD(i,n),{labels:i,dataSetsValues:n}=GD(i,n),{dataSetsValues:n,axisFormats:{y:JD(i)},labels:i.map(({value:e})=>String(e??``)),locale:r.getLocale(),background:ym(e,r)}}function DD(e,t){let n=OD(e,t),r=xD(e,n,t),i=e.labelRange?t.getVisibleRangeValues(e.labelRange):[],a=e.sizeRange?t.getVisibleRangeValues(e.sizeRange):[];n.shouldRemoveFirstLabel&&(i=i.slice(1),a=a.slice(1));let o=[],s=[],c=JD(a);for(let e=0;e<r.dataSetsValues[0].data.length;e++){let t=a[e]?.value,n=i[e],c=n?H(n.value,{format:n.format,locale:r.locale}):``,l=t===null?void 0:zo(t,r.locale);l!==void 0&&l<0&&(l=void 0),o.push(c?String(c):``),s.push(l)}let l=C(0,s.length).sort((e,t)=>{let n=s[e],r=s[t];return n===void 0&&r===void 0?0:n===void 0?1:r===void 0?-1:r-n});return r.dataSetsValues[0]={...r.dataSetsValues[0],data:l.map(e=>r.dataSetsValues[0].data[e])},{...r,axisFormats:{...r.axisFormats||{},size:c},labels:l.map(e=>r.labels[e]),bubbleLabels:l.map(e=>o[e]),bubbleSizes:l.map(e=>s[e])}}function OD(e,t){let n=e.yRanges[0],r=e.xRange?t.getVisibleRangeValues(e.xRange):n?Array.from({length:t.getVisibleRangeValues(n).length},()=>mD):[],i=n?t.getVisibleRangeValues(n):[],a=um(r.length,i.length,e.dataSetsHaveTitle||!1);return{labelValues:a?r.slice(1):r,dataSetsValues:[{dataSetId:`0`,label:``,data:a?i.slice(1):i}],shouldRemoveFirstLabel:a}}function kD(e,t){let n=[],r=[],i=[];for(let e=0;e<t.length;e++){let a=t[e];tf(a)&&(n.push(a.value),r.push(e+1)),i.push(e+1)}let a=jD(e,n,r,C(.5,i.length+.55,.2));return a.length?a:void 0}function AD(e,t,n,r,i){let a=[],o=[],s=[],c=t.length;if(c<2)return;switch(r){case`category`:for(let e=0;e<c;e++){let n=t[e];tf(n)&&(a.push(n.value),o.push(e+1)),s.push(e+1)}break;case`linear`:for(let e=0;e<t.length;e++){let r=Number(n[e]);if(isNaN(r))continue;let i=t[e];tf(i)&&(a.push(i.value),o.push(r)),s.push(r)}break;case`time`:for(let e=0;e<t.length;e++){let r=L({value:n[e]},i),c=t[e];tf(c)&&(a.push(c.value),o.push(r)),s.push(r)}break}let l=Math.min(...s),u=Math.max(...s);if(u===l)return;let d=5*s.length,f=(u-l)/d,p=jD(e,a,o,C(l,u+f/2,f));if(p.length)return p}function jD(e,t,n,r){if(t.length<2||n.length<2||r.length===0)return[];let{normalizedLabels:i,normalizedNewLabels:a}=MD(n,r,e);try{switch(e.type){case`polynomial`:{let n=e.order;if(!n)return r.map(e=>({x:e,y:NaN}));if(n===1)return NS([t],[i],[a],!0)[0].map((e,t)=>({x:r[t],y:e}));let o=OS(t,i,n,!0).flat();return a.map((e,t)=>({x:r[t],y:AS(o,e,n)}))}case`exponential`:{let e=[],n=[];for(let r=0;r<t.length;r++)t[r]>0&&(e.push(Math.log(t[r])),n.push(i[r]));return n.length?jS(NS([e],[n],[a],!0))[0].map((e,t)=>({x:r[t],y:e})):r.map(e=>({x:e,y:NaN}))}case`logarithmic`:return NS([t],MS([i]),MS([a]),!0)[0].map((e,t)=>({x:r[t],y:e}));case`trailingMovingAverage`:return PS(t,n,e.window);default:return r.map(e=>({x:e,y:NaN}))}}catch{return r.map(e=>({x:e,y:NaN}))}}function MD(e,t,n){let r=[],i=[];if(n.type===`logarithmic`){let n=Math.max(...e.map(Math.abs));r=e.map(e=>e/n),i=t.map(e=>e/n)}else{let n=Math.max(...e),a=n-Math.min(...e);r=e.map(e=>(e-n)/a),i=t.map(e=>(e-n)/a)}return{normalizedLabels:r,normalizedNewLabels:i}}function ND(e,t){return PD(e,t)&&BD()?`time`:FD(e,t)?`linear`:`category`}function PD(e,t){return!e.labelsAsText&&LD(t)}function FD(e,t){return!e.labelsAsText&&RD(t)}function ID(e){return LD(e)||RD(e)}function LD(e){if(!RD(e))return!1;let t=JD(e.labelValues);return!!(t&&jm.test(t))}function RD(e){let t=e.labelValues;return!(t.some(e=>!tf(e)&&e.value)||t.every(e=>!e.value))}let zD=!1;function BD(){if(!window.Chart)return!1;let e=new window.Chart._adapters._date({})._id===`luxon`;return!e&&!zD&&(zD=!0,console.warn(`'chartjs-adapter-luxon' time adapter is not installed. Time scale axes are disabled.`)),e}function VD(e,t){let n=C(0,Math.max(e.length,...t.map(e=>e.data?.length||0))).filter(e=>t.some(t=>tf(t.data[e])&&t.data[e].value>0));return{labels:n.map(t=>e[t]||``),dataSetsValues:t.map(e=>({...e,data:n.map(t=>tf(e.data[t])&&e.data[t].value>0?e.data[t]:mD)}))}}function HD(e,t){if(e.length===0||e.every(e=>!e))return{labels:e,dataSetsValues:t};let n=[...e],r=x(t);for(let e=0;e<n.length;e++)if(!n[e]){n[e]=Kt(n,e);for(let t of r)t.data[e]=mD}return{labels:n,dataSetsValues:r}}function UD(e,t){let n=C(0,Math.max(e.length,...t.map(e=>e.data?.length||0))).filter(n=>{let r=e[n],i=t.map(e=>e.data?.[n]);return r||i.some(tf)});return{labels:n.map(t=>e[t]||``),dataSetsValues:t.map(e=>({...e,data:n.map(t=>tf(e.data[t])?e.data[t]:mD)}))}}function WD(e,t){let n=C(0,Math.max(e.length,...t.map(e=>e.data?.length||0))).filter(n=>{let r=e[n],i=t.map(e=>e.data?.[n]);return tf(r)&&tf(i[0])});return{labels:n.map(t=>e[t]||``),dataSetsValues:t.map(e=>({...e,data:n.map(t=>tf(e.data[t])?e.data[t]:mD)}))}}function GD(e,t){let n=Math.max(e.length,...t.map(e=>e.data?.length||0)),r=e=>e===null||e===``,i=C(0,n).filter(n=>{let i=t.map(e=>e.data?.[n]);if(r(i[0]?.value))return!1;let a=!1;for(let e of i)if(a||=r(e?.value),a&&!r(e?.value))return!1;return e[n]&&tf(e[n])});return{labels:i.map(t=>e[t]),dataSetsValues:t.map(e=>({...e,data:i.map(t=>e.data[t])}))}}function KD(e,t){let n=[],r=[];for(let t=0;t<e.length;t++)Number(e[t].value)<=0?r.push(t):Number(e[t].value)>0&&n.push(t);let i=n.length?n:r;return{labels:i.map(t=>e[t]),dataSetsValues:t.map(e=>({...e,data:i.map(t=>e.data[t])}))}}function qD(e,t){let n=e=>typeof e==`number`?e:0,r=new Set(e),i={};r.forEach(e=>{i[e]=Array(t.length)});for(let r of C(0,e.length)){let a=e[r];for(let e of C(0,t.length)){let o=t[e].data[r];i[a][e]?i[a][e].value+=n(o?.value):i[a][e]={...o,value:n(o?.value)}}}return{labels:Array.from(r),dataSetsValues:t.map((e,t)=>({...e,data:Array.from(r).map(e=>i[e][t])}))}}function JD(e){return e.find(({format:e})=>e!==void 0)?.format}function YD(e,t,n){let r=t.filter(t=>n===`right`==(e?.[t.dataSetId]?.yAxisId===`y1`));for(let e of r){let t=e.data.find(({format:e})=>e!==void 0&&!fc(e));if(t)return t.format}}function XD(e,t){return e.map(e=>{let n=[],r=0,i=t===`asc`?C(0,e.data.length):C(0,e.data.length).reverse();for(let t of i){let i=e.data[t];tf(i)?(r+=i.value,n[t]={...i,value:r}):n[t]=mD}return{...e,data:n}})}function ZD(e,t){let{title:n,legendPosition:r}=e,i=n&&n.text||r===`top`;return t.isDashboard()&&!i?30:0}function QD(e,t){return{padding:{left:20,right:20,top:Math.max(15,t.topPadding||0),bottom:10}}}function $D(e,t){let n=e.legendPosition;return{padding:{left:20+(n===`left`?70:0),right:20+(n===`right`?70:0),top:Math.max(15,t.topPadding||0),bottom:10}}}let eO=.2;function tO(e,t){let n=e.datasetIndex;for(let e=0;e<t.length;e++){if(e===n)continue;let r=t[e];for(let t of[`borderColor`,`backgroundColor`])t in r&&(r[t]=dp(r[t],e===n?1:eO))}}function nO(e){for(let t of e)for(let e of[`borderColor`,`backgroundColor`])e in t&&(t[e]=dp(t[e],1))}function rO(e,t){let n=e.datasetIndex;for(let e=0;e<t.length;e++){let r=t[e],i=dp(r.borderColor,e===n?1:eO);r.borderColor=i,r.pointBackgroundColor=i,r.backgroundColor=dp(r.backgroundColor,et*(e===n?1:eO))}}function iO(e){for(let t of e){let e=dp(t.borderColor,1);t.borderColor=e,t.pointBackgroundColor=e,t.backgroundColor=dp(t.backgroundColor,et)}}function aO(e,t){let n=t[0],r=n.hoverBackgroundColor,i=n.hoverBorderColor;!Array.isArray(r)||!Array.isArray(i)||(n.backgroundColor=r.map((t,n)=>dp(t,n===e.datasetIndex?1:eO)),n.borderColor=i.map((t,n)=>dp(t,n===e.datasetIndex?1:eO)))}function oO(e){let t=e[0],n=t.hoverBackgroundColor,r=t.hoverBorderColor;!Array.isArray(n)||!Array.isArray(r)||(t.backgroundColor=[...n],t.borderColor=[...r])}function sO(e,t){let n=t.datasetIndex;n!==void 0&&(e.isDatasetVisible(n)?e.hide(n):e.show(n))}function cO(e,t){for(let n of t){let t=n.backgroundColor;if(!t)return;t.forEach((t,n,r)=>{r[n]=dp(t,n===e.index?1:eO)})}}function lO(e){for(let t of e){let e=t.backgroundColor;if(!e)return;e.forEach((e,t,n)=>{n[t]=dp(e,1)})}}function uO(e,t){let n=t.index;n!==void 0&&e.toggleDataVisibility(n)}function dO({legendPosition:e}){return{display:e!==`none`,position:e===`none`?void 0:e}}function fO(e,t){return{...SO({highlightItem:tO,unHighlightItems:nO,toggleDataVisibility:sO}),...dO(e),...wO(om(e.background),{lineWidth:3})}}function pO(e,t){return{...dO(e),...wO(om(e.background),{pointStyle:`rect`,lineWidth:3})}}function mO(e,t){let n=e.fillArea,r=n?`rect`:`line`,i=n?2:3;return{...SO({highlightItem:rO,unHighlightItems:iO,toggleDataVisibility:sO}),...dO(e),...wO(om(e.background),{pointStyle:r,lineWidth:i})}}function hO(e,t){let{dataSetsValues:n}=t,r=gm(new Ap(Math.max(0,...n.map(e=>e?.data?.length??0)),e.slicesColors),n),i=om(e.background);return{...SO({highlightItem:cO,unHighlightItems:lO,toggleDataVisibility:uO}),...dO(e),labels:{usePointStyle:!0,generateLabels:e=>(e.data.labels?.map((t,n)=>({text:_m(String(t)),strokeStyle:r[n],fillStyle:r[n],pointStyle:`rect`,lineWidth:2,fontColor:i,index:n,hidden:!e.getDataVisibility?.(n)}))||[]).filter(e=>e.text),filter:(e,t)=>`datasetIndex`in e?!t.datasets[e.datasetIndex].hidden:!0}}}function gO(e,t){return{...SO({highlightItem:rO,unHighlightItems:iO,toggleDataVisibility:sO}),...dO(e),...EO(om(e.background),{pointStyle:`circle`,strokeStyle:e.background||`#ffffff`,lineWidth:8})}}function _O(e,t){return e.bubbleColor.color===`multiple`?{...CO,...dO(e),...TO(om(e.background),{pointStyle:`circle`,strokeStyle:e.background||`#ffffff`,lineWidth:8},t.bubbleLabels)}:{display:!1}}function vO(e,t){return{...SO({highlightItem:tO,unHighlightItems:nO,toggleDataVisibility:sO}),...dO(e),...wO(om(e.background),{lineWidth:3})}}function yO(e,t){let n=om(e.background),r=e.negativeValuesColor||`#EA6175`,i=e.positiveValuesColor||`#4EA7F2`,a=e.subTotalValuesColor||`#AAAAAA`;return{...dO(e),labels:{usePointStyle:!0,generateLabels:()=>{let t=[{text:P(`Positive values`),fontColor:n,fillStyle:i,strokeStyle:i,pointStyle:`rect`},{text:P(`Negative values`),fontColor:n,fillStyle:r,strokeStyle:r,pointStyle:`rect`}];return(e.showSubTotals||e.firstValueAsSubtotal)&&t.push({text:P(`Subtotals`),fontColor:n,fillStyle:a,strokeStyle:a,pointStyle:`rect`}),t},filter:(e,t)=>`datasetIndex`in e?!t.datasets[e.datasetIndex].hidden:!0},onClick:()=>{}}}function bO(e,t){let n=e.fillArea??!1,r=n?`rect`:`line`,i=n?2:3;return{...SO({highlightItem:rO,unHighlightItems:iO,toggleDataVisibility:sO}),...dO(e),...wO(om(e.background),{pointStyle:r,lineWidth:i})}}function xO(e,t){let n=om(e.background);return{...dO(e),labels:{usePointStyle:!0,generateLabels:e=>{let t=e.data.datasets.at(-1);return t?t.groupColors.map(({color:e,label:t})=>({text:_m(t),fontColor:n,fillStyle:e,strokeStyle:e,pointStyle:`rect`})):[]}}}}function SO({highlightItem:e,unHighlightItems:t,toggleDataVisibility:n}){return{onHover:(t,n,r)=>{if(!n.hidden){let t=r.chart.data.datasets;e(n,t),r.chart.update()}let i=t.native?.target;i&&i instanceof HTMLElement&&(i.style.cursor=`pointer`)},onLeave:(e,n,r)=>{if(!n.hidden){let e=r.chart.data.datasets;t(e),r.chart.update()}let i=e.native?.target;i&&i instanceof HTMLElement&&(i.style.cursor=`default`)},onClick:(r,i,a)=>{r.type!==`click`||!a.legendItems||(a.chart.options.animation&&(a.chart.options.animation=!1),n(a.chart,i),i.hidden?e(i,a.chart.data.datasets):t(a.chart.data.datasets),a.chart.update(),r.native.preventDefault(),r.native.stopPropagation())}}}let CO={...SO({highlightItem:aO,unHighlightItems:oO,toggleDataVisibility:sO}),onClick:(e,t,n)=>{if(e.type!==`click`)return;let r=t.datasetIndex;if(r===void 0)return;let i=n.chart.getDatasetMeta(0),a=i.data[r].hidden;i.data[r].hidden=!a,n.chart.update(),e.native.preventDefault(),e.native.stopPropagation()}};function wO(e,t){return{labels:{color:e,usePointStyle:!0,generateLabels:n=>n.data.datasets.map((r,i)=>vm(r.xAxisID)?{text:_m(r.label),fontColor:e,strokeStyle:r.borderColor,hidden:!n.isDatasetVisible(i),pointStyle:`line`,datasetIndex:i,lineWidth:3}:{text:_m(r.label),fontColor:e,strokeStyle:r.borderColor,fillStyle:r.backgroundColor,hidden:!n.isDatasetVisible(i),pointStyle:r.type===`line`?`line`:`rect`,datasetIndex:i,...t}).filter(e=>e.text),filter:(e,t)=>`datasetIndex`in e?!t.datasets[e.datasetIndex].hidden:!0}}}function TO(e,t,n){return{labels:{color:e,usePointStyle:!0,generateLabels:r=>{if(!r.data.datasets[0])return[];let i=r.data.datasets[0].backgroundColor,a=typeof i==`string`?r.data.datasets[0].data.map(()=>i):i;return r.data.datasets[0].data.map((i,o)=>({text:n[o],fontColor:e,strokeStyle:a?.[o],fillStyle:a?.[o],hidden:r.getDatasetMeta(0).data[o].hidden,pointStyle:`rect`,datasetIndex:o,...t})).filter(e=>e.text)},filter:(e,t)=>!0}}}function EO(e,t){return{labels:{color:e,usePointStyle:!0,generateLabels:n=>n.data.datasets.map((r,i)=>vm(r.xAxisID)?{text:_m(r.label),fontColor:e,strokeStyle:r.borderColor,hidden:!n.isDatasetVisible(i),pointStyle:`line`,datasetIndex:i,lineWidth:3}:{text:_m(r.label),fontColor:e,strokeStyle:r.borderColor,fillStyle:r.pointBackgroundColor,hidden:!n.isDatasetVisible(i),pointStyle:`circle`,datasetIndex:i,lineWidth:8,...t}).filter(e=>e.text),filter:(e,t)=>`datasetIndex`in e?!t.datasets[e.datasetIndex].hidden:!0}}}let DO={showValues:!1,showLabels:!0,valuesDesign:{align:`center`,fontSize:13}};function OO(e,t){let{axisFormats:n,locale:r}=t;return{type:e.type,horizontal:`horizontal`in e&&e.horizontal,showValues:`showValues`in e?!!e.showValues:!1,background:()=>e.background,callback:(t,i)=>{let a=NO(e,i);return pm(n,r,e.humanize)(t,a)}}}function kO(e,t){let{locale:n,axisFormats:r}=t,i=(t,n,r)=>e.background,a=t.dataSetsValues.flat().flatMap(e=>e?.data.filter(tf)).map(e=>e.value);if(a.length){let t=Math.min(...a),n=Math.max(...a),r=Qm(e.colorScale??AC(`oranges`),t,n);i=(t,n,i)=>{let a=n._dataset.values[i];return a===void 0?e.background:om(r(a))}}return{type:`calendar`,horizontal:!1,showValues:`showValues`in e?!!e.showValues:!1,background:i,callback:(e,t,i)=>{let a=t._dataset.values[i];return a===void 0?``:Tc({value:a,format:r?.y},n)}}}function AO(e,t){let{axisFormats:n,locale:r}=t;return{callback:pm(n,r,e.humanize),showLabels:e.showLabels??DO.showLabels,showValues:e.showValues??DO.showValues,style:{fontSize:e.valuesDesign?.fontSize??DO.valuesDesign.fontSize,align:e.valuesDesign?.align??DO.valuesDesign.align,bold:e.valuesDesign?.bold??DO.valuesDesign.bold,italic:e.valuesDesign?.italic??DO.valuesDesign.italic,textColor:e.valuesDesign?.color??DO.valuesDesign.color}}}function jO(e,t){let{axisFormats:n,locale:r}=t;return{type:`pyramid`,horizontal:!0,showValues:`showValues`in e?!!e.showValues:!1,background:()=>e.background,callback:(e,t)=>(e=Math.abs(Number(e)),e===0?``:pm(n,r)(e,t.xAxisID||`x`))}}function MO(e,t){let{axisFormats:n,locale:r,dataSetsValues:i}=t,a=i.reduce((e,t)=>(e.push((e.at(-1)||-1)+t.data.length+1),e),[]);return{type:`waterfall`,showValues:`showValues`in e?!!e.showValues:!1,background:()=>e.background,callback:(t,i,o)=>{let s=i._dataset.data[o],c=s[1]-s[0],l=c>=0?`+`:``;return e.showSubTotals&&a.includes(o)&&l===`+`&&(l=``),`${l}${pm(n,r,e.humanize)(c,i.yAxisID)}`}}}function NO(e,t){return t.rAxisID?t.rAxisID:(`horizontal`in e&&e.horizontal?t.xAxisID:t.yAxisID)||`y`}function PO({title:e,legendPosition:t,background:n},r){let i=sm(n);return{display:!!e.text,text:e.text?r.dynamicTranslate(e.text):``,color:e?.color??i,align:e.align===`center`?`center`:e.align===`right`?`end`:`start`,font:{size:e.fontSize??16,weight:e.bold?`bold`:`normal`,style:e.italic?`italic`:`normal`},padding:{bottom:t===`top`?0:20}}}let FO;function IO(e,t={}){return LO(e,t).innerHTML}function LO(e,n={}){FO||=new t.App({templates:`
|
|
36
|
+
`))}extractAttr(e,t,n){let r=e.attributes[t];r||this.handleMissingValue(e,`attribute "${t}"`,n);let i=r?.value?r.value:n?.default;return i===void 0?void 0:new Ix(i)}extractTextContent(e,t){if(t?.default!==void 0&&typeof t.default!=`string`)throw Error(`extractTextContent default value should be a string`);let n=e?.attributes[`xml:space`]?.value===`preserve`,r=e?.textContent;return(!e||r===null)&&this.handleMissingValue(e,`text content`,t),r&&=n?r:r.trim(),r?By(r):t?.default}extractChildAttr(e,t,n,r){let i;i=typeof t==`number`?e.children[t]:this.querySelector(e,t),i||this.handleMissingValue(e,typeof t==`number`?`child at index ${t}`:`child <${t}>`,r);let a=i?this.extractAttr(i,n,r)?.asString():r?.default;return a===void 0?void 0:new Ix(a)}extractChildTextContent(e,t,n){if(n?.default!==void 0&&typeof n.default!=`string`)throw Error(`extractTextContent default value should be a string`);let r=this.querySelector(e,t);return r||this.handleMissingValue(e,`child <${t}>`,n),r?this.extractTextContent(r,n):n?.default}handleMissingValue(e,t,n){if(n?.required)if(n?.default!==void 0)this.warningManager.addParsingWarning(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, replacing it by the default value ${n.default}`);else throw Error(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, and no default value was set`)}extractColor(e,t,n){if(!e)return n?{rgb:n}:void 0;let r=this.extractAttr(e,`theme`)?.asString(),i;if(r!==void 0){if(!t||!t.clrScheme)throw Error(`Color referencing a theme but no theme was provided`);i=this.getThemeColor(r,t.clrScheme)}else i=this.extractAttr(e,`rgb`)?.asString(),i=i===`FF000000`?void 0:i;return{rgb:i||n,auto:this.extractAttr(e,`auto`)?.asBool(),indexed:this.extractAttr(e,`indexed`)?.asNum(),tint:this.extractAttr(e,`tint`)?.asNum()}}getTargetXmlFile(e){if(!e)throw Error(`Undefined target file`);let t=this.processRelationshipTargetName(e.target),n=this.getListOfXMLFiles().find(e=>e.file.fileName.endsWith(t));if(!n||!n.file)throw Error(`Cannot find target file`);return n}getTargetImageFile(e){if(!e)throw Error(`Undefined target file`);let t=this.processRelationshipTargetName(e.target),n=this.xlsxFileStructure.images.find(e=>e.fileName.endsWith(t));if(!n)throw Error(`Cannot find target file`);return n}querySelector(e,t){let n=Fx(t);return e.querySelector(n)}querySelectorAll(e,t){let n=Fx(t);return e.querySelectorAll(n)}getThemeColor(e,t){switch(e){case`0`:return`FFFFFF`;case`1`:return`000000`;case`2`:return t[3].value;case`3`:return t[2].value;default:return t[e].value}}processRelationshipTargetName(e){return e.replace(/\.+\//,``)}},Rx=class extends Lx{getExternalBook(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`externalBook`},e=>({rId:this.extractAttr(e,`r:id`,{required:!0}).asString(),sheetNames:this.mapOnElements({parent:e,query:`sheetName`},e=>this.extractAttr(e,`val`,{required:!0}).asString()),datasets:this.extractExternalSheetData(e)}))[0]}extractExternalSheetData(e){return this.mapOnElements({parent:e,query:`sheetData`},e=>{let t=this.mapOnElements({parent:e,query:`cell`},e=>({xc:this.extractAttr(e,`r`,{required:!0}).asString(),value:this.extractChildTextContent(e,`v`,{required:!0})})),n={};for(let e of t)n[e.xc]=e.value;return{sheetId:this.extractAttr(e,`sheetId`,{required:!0}).asNum(),data:n}})}},zx=class extends Lx{getTheme(){return{clrScheme:this.mapOnElements({query:`a:clrScheme`,parent:this.rootFile.file.xml,children:!0},e=>({name:e.tagName,value:this.extractChildAttr(e,0,`val`,{required:!0,default:Rp}).asString(),lastClr:this.extractChildAttr(e,0,`lastClr`,{default:Rp}).asString()}))}}getSharedStrings(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`si`},e=>this.mapOnElements({parent:e,query:`t`},e=>this.extractTextContent(e)||``).join(``))}getNamedRanges(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`definedNames definedName`},e=>({name:this.extractAttr(e,`name`,{required:!0}).asString(),value:this.extractTextContent(e)||``}))}},Bx=class extends Lx{theme;constructor(e,t,n,r){super(e,t,n),this.theme=r}extractConditionalFormattings(){let e=this.mapOnElements({parent:this.rootFile.file.xml,query:`worksheet > conditionalFormatting`},e=>({sqref:this.extractAttr(e,`sqref`,{required:!0}).asString().split(` `),pivot:this.extractAttr(e,`pivot`)?.asBool(),cfRules:this.extractCFRules(e,this.theme)}));return e.push(...this.mapOnElements({parent:this.rootFile.file.xml,query:`extLst x14:conditionalFormatting`},e=>({sqref:this.extractChildTextContent(e,`xm:sqref`,{required:!0}).split(` `),pivot:this.extractAttr(e,`xm:pivot`)?.asBool(),cfRules:this.extractCFRules(e,this.theme)}))),e}extractCFRules(e,t){return this.mapOnElements({parent:e,query:`cfRule, x14:cfRule`},e=>({type:this.extractAttr(e,`type`,{required:!0}).asString(),priority:this.extractAttr(e,`priority`,{required:!0}).asNum(),colorScale:this.extractCfColorScale(e,t),formula:this.extractCfFormula(e),iconSet:this.extractCfIconSet(e),dxfId:this.extractAttr(e,`dxfId`)?.asNum(),stopIfTrue:this.extractAttr(e,`stopIfTrue`)?.asBool(),aboveAverage:this.extractAttr(e,`aboveAverage`)?.asBool(),percent:this.extractAttr(e,`percent`)?.asBool(),bottom:this.extractAttr(e,`bottom`)?.asBool(),operator:this.extractAttr(e,`operator`)?.asString(),text:this.extractAttr(e,`text`)?.asString(),timePeriod:this.extractAttr(e,`timePeriod`)?.asString(),rank:this.extractAttr(e,`rank`)?.asNum(),stdDev:this.extractAttr(e,`stdDev`)?.asNum(),equalAverage:this.extractAttr(e,`equalAverage`)?.asBool(),dataBar:this.extractCfDataBar(e,t)}))}extractCfFormula(e){return this.mapOnElements({parent:e,query:`formula`},e=>this.extractTextContent(e,{required:!0}))}extractCfColorScale(e,t){let n=this.querySelector(e,`colorScale`);if(n)return{colors:this.mapOnElements({parent:n,query:`color`},e=>this.extractColor(e,t,`ffffff`)),cfvos:this.extractCFVos(n)}}extractCfDataBar(e,t){let n=this.querySelector(e,`dataBar`);if(n)return{color:this.extractColor(n.querySelector(`color`),t,`EFF7FF`),cfvos:this.extractCFVos(n)}}extractCfIconSet(e){let t=this.querySelector(e,`iconSet, x14:iconSet`);if(t)return{iconSet:this.extractAttr(t,`iconSet`,{default:`3TrafficLights1`}).asString(),showValue:this.extractAttr(t,`showValue`,{default:!0}).asBool(),percent:this.extractAttr(t,`percent`,{default:!0}).asBool(),reverse:this.extractAttr(t,`reverse`)?.asBool(),custom:this.extractAttr(t,`custom`)?.asBool(),cfvos:this.extractCFVos(t),cfIcons:this.extractCfIcons(t)}}extractCfIcons(e){let t=this.mapOnElements({parent:e,query:`cfIcon, x14:cfIcon`},e=>({iconSet:this.extractAttr(e,`iconSet`,{required:!0}).asString(),iconId:this.extractAttr(e,`iconId`,{required:!0}).asNum()}));return t.length===0?void 0:t}extractCFVos(e){return this.mapOnElements({parent:e,query:`cfvo, x14:cfvo`},e=>({type:this.extractAttr(e,`type`,{required:!0}).asString(),gte:this.extractAttr(e,`gte`,{default:!0})?.asBool(),value:e.attributes.val?this.extractAttr(e,`val`)?.asString():this.extractChildTextContent(e,`f, xm:f`)}))}},Vx=class extends Lx{theme;constructor(e,t,n,r){super(e,t,n),this.theme=r}extractDataValidations(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`worksheet > dataValidations > dataValidation`},e=>({type:this.extractAttr(e,`type`,{required:!0}).asString(),operator:this.extractAttr(e,`operator`,{default:`between`})?.asString(),sqref:this.extractAttr(e,`sqref`,{required:!0}).asString().split(` `),errorStyle:this.extractAttr(e,`errorStyle`)?.asString(),formula1:this.extractDataValidationFormula(e,1)[0],formula2:this.extractDataValidationFormula(e,2)[0],showErrorMessage:this.extractAttr(e,`showErrorMessage`)?.asBool(),errorTitle:this.extractAttr(e,`errorTitle`)?.asString(),error:this.extractAttr(e,`error`)?.asString(),showInputMessage:this.extractAttr(e,`showInputMessage`)?.asBool(),promptTitle:this.extractAttr(e,`promptTitle`)?.asString(),prompt:this.extractAttr(e,`prompt`)?.asString(),allowBlank:this.extractAttr(e,`allowBlank`)?.asBool()}))}extractDataValidationFormula(e,t){return this.mapOnElements({parent:e,query:`formula${t}`},e=>this.extractTextContent(e,{required:!0}))}};let Hx={bg1:`lt1`,tx1:`dk1`,bg2:`lt2`,tx2:`dk2`};var Ux=class extends Lx{extractChart(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`c:chartSpace`},e=>{let t=this.getChartType(e);if(!Pv[t])throw Error(`Unsupported chart type ${t}`);if(Pv[t]===`combo`)return this.extractComboChart(e);let n=this.mapOnElements({parent:e,query:`c:chart > c:title a:t`},e=>e.textContent||``).join(``),r=this.extractTitleStyle(e,`c:chart > c:title a:p a:pPr a:defRPr`),i=this.extractChildAttr(e,`c:grouping`,`val`,{default:`clustered`}).asString(),a=this.extractChildAttr(e,`c:barDir`,`val`,{default:`col`}).asString(),o=this.extractChildAttr(e,`c:holeSize`,`val`,{default:`0`}).asNum(),s=[...this.querySelectorAll(e,`c:chart c:showVal`)].some(e=>e.attributes.getNamedItem(`val`)?.value===`1`),c=[];if(Pv[t]===`pie`){let t=this.querySelector(e,`c:ser`);if(t){let e=Array.from(this.querySelectorAll(t,`c:dPt`)),n={};for(let t of e){let e=this.extractChildAttr(t,`c:idx`,`val`,{required:!0}).asNum(),r=this.extractDrawingFillColor(t);typeof e==`number`&&r&&(n[e]=r)}if(Object.keys(n).length){let e=Math.max(...Object.keys(n).map(Number));for(let t=0;t<=e;++t)c.push(n[t]||``)}}}return{title:{text:n,...r},type:Pv[t],axesDesign:this.extractAxesDesign(e),dataSets:this.extractChartDatasets(this.querySelectorAll(e,`c:${t}`),t),labelRange:this.extractLabelRange(t,e),backgroundColor:this.extractChildAttr(e,`c:chartSpace > c:spPr a:srgbClr`,`val`,{default:`ffffff`}).asString(),legendPosition:Nv[this.extractChildAttr(e,`c:legendPos`,`val`,{default:`none`}).asString()],stacked:i===`stacked`,fontColor:`000000`,horizontal:a===`bar`,isDoughnut:o>0,pieHolePercentage:o,showValues:s,slicesColors:c.length?c:void 0}})[0]}extractLabelRange(e,t){return e===`scatterChart`?this.extractChildTextContent(t,`c:ser c:strRef c:f`)||this.extractChildTextContent(t,`c:ser c:numRef c:f`):this.extractChildTextContent(t,`c:ser c:cat c:f`)}extractComboChart(e){let t=this.mapOnElements({parent:e,query:`c:title a:t`},e=>e.textContent||``).join(``),n=this.extractTitleStyle(e,`c:chart > c:title a:p a:pPr a:defRPr`),r=this.extractChildAttr(e,`c:grouping`,`val`,{default:`clustered`}).asString(),i=[...this.querySelectorAll(e,`c:chart c:showVal`)].some(e=>e.attributes.getNamedItem(`val`)?.value===`1`);return{title:{text:t,...n},type:`combo`,axesDesign:this.extractAxesDesign(e),dataSets:[...this.extractChartDatasets(this.querySelectorAll(e,`c:barChart`),`comboChart`),...this.extractChartDatasets(this.querySelectorAll(e,`c:lineChart`),`comboChart`)],labelRange:this.extractChildTextContent(e,`c:ser c:cat c:f`),backgroundColor:this.extractChildAttr(e,`c:chartSpace > c:spPr a:srgbClr`,`val`,{default:`ffffff`}).asString(),legendPosition:Nv[this.extractChildAttr(e,`c:legendPos`,`val`,{default:`none`}).asString()],stacked:r===`stacked`,fontColor:`000000`,showValues:i}}extractTitleStyle(e,t){let n=this.querySelector(e,t);if(!n)return{};let r=n.getAttribute(`b`),i=r===`1`||r===`true`?!0:void 0,a=n.getAttribute(`i`),o=a===`1`||a===`true`?!0:void 0,s=n.getAttribute(`sz`);return{bold:i,italic:o,fontSize:s?Math.round(parseInt(s)/100):void 0,color:this.extractDrawingFillColor(n)}}extractDrawingFillColor(e){let t=this.querySelector(e,`a:solidFill a:srgbClr`);if(t){let e=t.getAttribute(`val`);return e&&Xf(e)?Yf(e):void 0}let n=this.querySelector(e,`a:solidFill a:schemeClr`);if(n)return this.resolveSchemeColor(n)}resolveSchemeColor(e){let t=e.getAttribute(`val`);if(!t)return;let n=this.xlsxFileStructure.theme;if(!n)return;let r=Hx[t]??t,i=this.querySelector(n.file.xml,`a:clrScheme a:${r}`);if(!i)return;let a,o=this.querySelector(i,`a:srgbClr`);if(o){let e=o.getAttribute(`val`);a=e&&Xf(e)?Yf(e):void 0}else{let e=this.querySelector(i,`a:sysClr`);if(e){let t=e.getAttribute(`lastClr`);a=t&&Xf(t)?Yf(t):void 0}}if(!a)return;let s=this.querySelector(e,`a:lumMod`)?.getAttribute(`val`),c=this.querySelector(e,`a:lumOff`)?.getAttribute(`val`);if(s!==void 0||c!==void 0){let e=s?parseInt(s)/1e5:1,t=c?parseInt(c)/1e5:0;a=Gy(a,e,t)}return a}extractAxisTitleDesign(e){if(e===null)return;let t=this.mapOnElements({parent:e,query:`c:title a:t`},e=>e.textContent||``).join(``);if(t)return{text:t,...this.extractTitleStyle(e,`c:title a:p a:pPr a:defRPr`)}}extractAxesDesign(e){let t=this.querySelector(e,`c:catAx`),n=this.querySelector(e,`c:valAx`),r=t?this.extractChildAttr(t,`c:axPos`,`val`)?.asString():void 0,i=r===`l`||r===`r`,a=i?n:t,o=i?t:n,s=this.extractAxisTitleDesign(a),c=this.extractAxisTitleDesign(o);if(!s&&!c)return;let l={};return s&&(l.x={title:s}),c&&(l.y={title:c}),l}extractChartDatasets(e,t){return Array.from(e).map(e=>t===`scatterChart`?this.extractScatterChartDatasets(e):this.mapOnElements({parent:e,query:`c:ser`},e=>{let t={},n=this.extractChildTextContent(e,`c:tx c:f`);if(n)t={reference:n};else{let n=this.extractChildTextContent(e,`c:tx c:v`);n&&(t={text:n})}let r=this.querySelectorAll(e,`c:spPr`),i=r.length?this.extractDrawingFillColor(r[0]):void 0;return{label:t,range:this.extractChildTextContent(e,`c:val c:f`,{required:!0}),backgroundColor:i,trend:this.extractChartTrendline(e)}})).flat()}extractChartTrendline(e){let t=this.querySelector(e,`c:trendline`);if(!t)return;let n=this.extractChildAttr(t,`c:trendlineType`,`val`),r=this.extractDrawingFillColor(t);return{type:n?n.asString():void 0,order:this.extractChildAttr(t,`c:order`,`val`)?.asNum(),window:this.extractChildAttr(t,`c:period`,`val`)?.asNum(),color:r}}extractScatterChartDatasets(e){return this.mapOnElements({parent:e,query:`c:ser`},e=>{let t={},n=this.querySelectorAll(e,`c:spPr`),r=n.length?this.extractDrawingFillColor(n[0]):void 0,i=this.extractChildTextContent(e,`c:tx c:f`);if(i)t={reference:i};else{let n=this.extractChildTextContent(e,`c:tx c:v`);n&&(t={text:n})}return{label:t,range:this.extractChildTextContent(e,`c:yVal c:f`,{required:!0}),trend:this.extractChartTrendline(e),backgroundColor:r}})}getChartType(e){let t=this.querySelector(e,`c:plotArea`);if(!t)throw Error(`Missing plot area in the chart definition.`);let n;for(let e of t.children){let t=Nx(e.tagName);ov.some(e=>e===t)&&(n?n!==t&&(n=`comboChart`):n=t)}if(n)return n;throw Error(`Unknown chart type`)}};let Wx=`oneCellAnchor`,Gx=`twoCellAnchor`;var Kx=class extends Lx{extractFigures(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`xdr:wsDr`,children:!0},e=>{let t=Nx(e.tagName),n=this.extractFigureAnchorsByType(e,t),r=this.querySelector(e,`c:chart`),i=this.querySelector(e,`a:blip`);if(!r&&!i)throw Error(`Only chart and image figures are currently supported.`);return{anchors:n,data:r?this.extractChart(r):this.extractImage(e),figureSize:t===Wx?this.extractFigureSizeFromSizeTag(e,`xdr:ext`):void 0}})}extractFigureAnchorsByType(e,t){switch(t){case Wx:return[this.extractFigureAnchor(`xdr:from`,e)];case Gx:return[this.extractFigureAnchor(`xdr:from`,e),this.extractFigureAnchor(`xdr:to`,e)];default:throw Error(`${t} is not supported for xlsx drawings. `)}}extractFigureSizeFromSizeTag(e,t){let n=this.querySelector(e,t);if(!n)throw Error(`Missing size element '${t}'`);return{cx:this.extractAttr(n,`cx`,{required:!0}).asNum(),cy:this.extractAttr(n,`cy`,{required:!0}).asNum()}}extractFigureAnchor(e,t){let n=this.querySelector(t,e);if(!n)throw Error(`Missing anchor element ${e}`);return{col:Number(this.extractChildTextContent(n,`xdr:col`,{required:!0})),colOffset:Number(this.extractChildTextContent(n,`xdr:colOff`,{required:!0})),row:Number(this.extractChildTextContent(n,`xdr:row`,{required:!0})),rowOffset:Number(this.extractChildTextContent(n,`xdr:rowOff`,{required:!0}))}}extractChart(e){let t=this.extractAttr(e,`r:id`,{required:!0}).asString(),n=new Ux(this.getTargetXmlFile(this.relationships[t]),this.xlsxFileStructure,this.warningManager).extractChart();if(!n)throw Error(`Unable to extract chart definition`);return n}extractImage(e){let t=this.querySelector(e,`a:blip`),n=this.extractAttr(t,`r:embed`,{required:!0}).asString(),r=this.getTargetImageFile(this.relationships[n]);if(!r)throw Error(`Unable to extract image`);let i=r.fileName.split(`.`).at(-1),a=Nx(e.tagName),o=a===Gx?this.querySelector(e,`a:xfrm`):e,s=a===Gx?`a:ext`:`xdr:ext`,c=this.extractFigureSizeFromSizeTag(o,s);return{imageSrc:r.imageSrc,mimetype:i?Vv[i]:void 0,size:c}}},qx=class extends Lx{getPivotTable(){return this.mapOnElements({query:`:root`,parent:this.rootFile.file.xml},e=>({name:this.extractAttr(e,`name`,{required:!0}).asString(),rowGrandTotals:this.extractAttr(e,`rowGrandTotals`,{default:!0}).asBool(),location:this.extractPivotLocation(e),style:this.extractPivotStyleInfo(e)}))[0]}extractPivotLocation(e){return this.mapOnElements({query:`location`,parent:e},e=>({ref:this.extractAttr(e,`ref`,{required:!0}).asString(),firstHeaderRow:this.extractAttr(e,`firstHeaderRow`,{required:!0}).asNum(),firstDataRow:this.extractAttr(e,`firstDataRow`,{required:!0}).asNum(),firstDataCol:this.extractAttr(e,`firstDataCol`,{required:!0}).asNum()}))[0]}extractPivotStyleInfo(e){return this.mapOnElements({query:`pivotTableStyleInfo`,parent:e},e=>({name:this.extractAttr(e,`name`,{required:!0}).asString(),showRowHeaders:this.extractAttr(e,`showRowHeaders`,{required:!0}).asBool(),showColHeaders:this.extractAttr(e,`showColHeaders`,{required:!0}).asBool(),showRowStripes:this.extractAttr(e,`showRowStripes`,{required:!0}).asBool(),showColStripes:this.extractAttr(e,`showColStripes`,{required:!0}).asBool(),showLastColumn:this.extractAttr(e,`showLastColumn`)?.asBool()}))[0]}},Jx=class extends Lx{getTable(){return this.mapOnElements({query:`table`,parent:this.rootFile.file.xml},e=>({displayName:this.extractAttr(e,`displayName`,{required:!0}).asString(),name:this.extractAttr(e,`name`)?.asString(),id:this.extractAttr(e,`id`,{required:!0}).asString(),ref:this.extractAttr(e,`ref`,{required:!0}).asString(),headerRowCount:this.extractAttr(e,`headerRowCount`,{default:1}).asNum(),totalsRowCount:this.extractAttr(e,`totalsRowCount`,{default:0}).asNum(),cols:this.extractTableCols(e),style:this.extractTableStyleInfo(e),autoFilter:this.extractTableAutoFilter(e)}))[0]}extractTableCols(e){return this.mapOnElements({query:`tableColumn`,parent:e},e=>({id:this.extractAttr(e,`id`,{required:!0}).asString(),name:this.extractAttr(e,`name`,{required:!0}).asString(),colFormula:this.extractChildTextContent(e,`calculatedColumnFormula`)}))}extractTableStyleInfo(e){return this.mapOnElements({query:`tableStyleInfo`,parent:e},e=>({name:this.extractAttr(e,`name`)?.asString(),showFirstColumn:this.extractAttr(e,`showFirstColumn`)?.asBool(),showLastColumn:this.extractAttr(e,`showLastColumn`)?.asBool(),showRowStripes:this.extractAttr(e,`showRowStripes`)?.asBool(),showColumnStripes:this.extractAttr(e,`showColumnStripes`)?.asBool()}))[0]}extractTableAutoFilter(e){return this.mapOnElements({query:`autoFilter`,parent:e},e=>({columns:this.extractFilterColumns(e),zone:this.extractAttr(e,`ref`,{required:!0}).asString()}))[0]}extractFilterColumns(e){return this.mapOnElements({query:`tableColumn`,parent:e},t=>({colId:this.extractAttr(e,`colId`,{required:!0}).asNum(),hiddenButton:this.extractAttr(e,`hiddenButton`,{default:!1}).asBool(),filters:this.extractSimpleFilter(t)}))}extractSimpleFilter(e){return this.mapOnElements({query:`filter`,parent:e},e=>({val:this.extractAttr(e,`val`,{required:!0}).asString()}))}},Yx=class extends Lx{theme;constructor(e,t,n,r){super(e,t,n),this.theme=r}getSheet(){return this.mapOnElements({query:`worksheet`,parent:this.rootFile.file.xml},e=>{let t=this.getSheetWorkbookInfo();return{sheetName:this.extractSheetName(),sheetViews:this.extractSheetViews(e),sheetFormat:this.extractSheetFormat(e),sheetProperties:this.extractSheetProperties(e),cols:this.extractCols(e),rows:this.extractRows(e),sharedFormulas:this.extractSharedFormulas(e),merges:this.extractMerges(e),cfs:this.extractConditionalFormats(),dataValidations:this.extractDataValidations(),figures:this.extractFigures(e),hyperlinks:this.extractHyperLinks(e),tables:this.extractTables(e),pivotTables:this.extractPivotTables(),isVisible:t.state===`visible`,isLocked:this.extractProtection(e)}})[0]}extractSheetViews(e){return this.mapOnElements({parent:e,query:`sheetView`},e=>{let t=this.querySelector(e,`pane`);return{tabSelected:this.extractAttr(e,`tabSelected`,{default:!1}).asBool(),showFormulas:this.extractAttr(e,`showFormulas`,{default:!1}).asBool(),showGridLines:this.extractAttr(e,`showGridLines`,{default:!0}).asBool(),showRowColHeaders:this.extractAttr(e,`showRowColHeaders`,{default:!0}).asBool(),pane:{xSplit:t?this.extractAttr(t,`xSplit`,{default:0}).asNum():0,ySplit:t?this.extractAttr(t,`ySplit`,{default:0}).asNum():0}}})}extractSheetName(){let e=Ry(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find(t=>t.target===e).id;for(let e of this.querySelectorAll(this.xlsxFileStructure.workbook.file.xml,`sheet`))if(e.attributes[`r:id`].value===t)return e.attributes.name.value;throw Error(`Missing sheet name`)}getSheetWorkbookInfo(){let e=Ry(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find(t=>t.target===e).id,n=this.mapOnElements({parent:this.xlsxFileStructure.workbook.file.xml,query:`sheet`},e=>({relationshipId:this.extractAttr(e,`r:id`,{required:!0}).asString(),sheetId:this.extractAttr(e,`sheetId`,{required:!0}).asString(),sheetName:this.extractAttr(e,`name`,{required:!0}).asString(),state:this.extractAttr(e,`state`,{default:`visible`}).asString()})).find(e=>e.relationshipId===t);if(!n)throw Error(`Cannot find corresponding workbook sheet`);return n}extractConditionalFormats(){return new Bx(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractConditionalFormattings()}extractDataValidations(){return new Vx(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractDataValidations()}extractFigures(e){return this.mapOnElements({parent:e,query:`drawing`},e=>{let t=this.extractAttr(e,`r:id`,{required:!0})?.asString();return new Kx(this.getTargetXmlFile(this.relationships[t]),this.xlsxFileStructure,this.warningManager).extractFigures()})[0]||[]}extractTables(e){return this.mapOnElements({query:`tablePart`,parent:e},e=>{let t=this.extractAttr(e,`r:id`,{required:!0})?.asString();return new Jx(this.getTargetXmlFile(this.relationships[t]),this.xlsxFileStructure,this.warningManager).getTable()})}extractPivotTables(){try{return Object.values(this.relationships).filter(e=>e.type.endsWith(`pivotTable`)).map(e=>new qx(this.getTargetXmlFile(e),this.xlsxFileStructure,this.warningManager).getPivotTable())}catch(e){return this.catchErrorOnElement(e),[]}}extractMerges(e){return this.mapOnElements({parent:e,query:`mergeCell`},e=>this.extractAttr(e,`ref`,{required:!0}).asString())}extractSheetFormat(e){let t=this.querySelector(e,`sheetFormatPr`);if(t)return{defaultColWidth:this.extractAttr(t,`defaultColWidth`,{default:`8.43`}).asNum(),defaultRowHeight:this.extractAttr(t,`defaultRowHeight`,{default:`12.75`}).asNum()}}extractSheetProperties(e){let t=this.querySelector(e,`sheetPr`);if(t)return{outlinePr:this.extractSheetOutlineProperties(t),tabColor:this.extractColor(this.querySelector(t,`tabColor`),this.theme)}}extractSheetOutlineProperties(e){let t=this.querySelector(e,`outlinePr`);if(t)return{summaryBelow:this.extractAttr(t,`summaryBelow`,{default:!0}).asBool(),summaryRight:this.extractAttr(t,`summaryRight`,{default:!0}).asBool()}}extractCols(e){return this.mapOnElements({parent:e,query:`cols col`},e=>({width:this.extractAttr(e,`width`)?.asNum(),customWidth:this.extractAttr(e,`customWidth`)?.asBool(),bestFit:this.extractAttr(e,`bestFit`)?.asBool(),hidden:this.extractAttr(e,`hidden`)?.asBool(),min:this.extractAttr(e,`min`,{required:!0})?.asNum(),max:this.extractAttr(e,`max`,{required:!0})?.asNum(),styleIndex:this.extractAttr(e,`style`)?.asNum(),outlineLevel:this.extractAttr(e,`outlineLevel`)?.asNum(),collapsed:this.extractAttr(e,`collapsed`)?.asBool()}))}extractRows(e){let t=new Set;return this.mapOnElements({parent:e,query:`sheetData row`},e=>({index:this.extractAttr(e,`r`,{required:!0})?.asNum(),cells:this.extractCells(e,t),height:this.extractAttr(e,`ht`)?.asNum(),customHeight:this.extractAttr(e,`customHeight`)?.asBool(),hidden:this.extractAttr(e,`hidden`)?.asBool(),styleIndex:this.extractAttr(e,`s`)?.asNum(),outlineLevel:this.extractAttr(e,`outlineLevel`)?.asNum(),collapsed:this.extractAttr(e,`collapsed`)?.asBool()}))}extractCells(e,t){return this.mapOnElements({parent:e,query:`c`},e=>{let n=this.extractAttr(e,`r`,{required:!0})?.asString(),r=this.extractCellFormula(e);if(r?.ref&&r.sharedIndex===void 0){let e=Un(r.ref);for(let{col:r,row:i}of ur(e)){let e=E(r,i);e!==n&&t.add(e)}}let i=t.has(n);return{xc:n,styleIndex:this.extractAttr(e,`s`)?.asNum(),type:wv[this.extractAttr(e,`t`,{default:`n`})?.asString()],value:i?void 0:this.extractChildTextContent(e,`v`)??void 0,formula:i?void 0:r}})}extractCellFormula(e){let t=this.querySelector(e,`f`);if(!t)return;let n=this.extractTextContent(t),r=this.extractAttr(t,`si`)?.asNum(),i=this.extractAttr(t,`ref`)?.asString();if(!((n===void 0||n.trim()===``)&&r===void 0))return{content:n,sharedIndex:r,ref:i}}extractHyperLinks(e){return this.mapOnElements({parent:e,query:`hyperlink`},e=>{let t=this.extractAttr(e,`r:id`)?.asString();return{xc:this.extractAttr(e,`ref`,{required:!0})?.asString(),location:this.extractAttr(e,`location`)?.asString(),display:this.extractAttr(e,`display`)?.asString(),relTarget:t?this.relationships[t].target:void 0}})}extractSharedFormulas(e){let t=this.querySelectorAll(e,`f[si][ref]`),n={};for(let e of t){let t=this.extractAttr(e,`si`,{required:!0}).asNum();n[t]=this.extractTextContent(e,{required:!0})}let r=[];for(let e=0;e<Object.keys(n).length;e++)n[e]?r.push(n[e]):(this.warningManager.addParsingWarning(`Missing shared formula ${e}, replacing it by empty formula`),r.push(``));return r}extractProtection(e){let t=this.querySelector(e,`sheetProtection`);return t?this.extractAttr(t,`sheet`,{default:!1}).asBool():!1}},Xx=class extends Lx{theme;constructor(e,t,n){super(e.styles,e,t),this.theme=n}getNumFormats(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`numFmt`},e=>this.extractNumFormats(e))}extractNumFormats(e){return{id:this.extractAttr(e,`numFmtId`,{required:!0}).asNum(),format:this.extractAttr(e,`formatCode`,{required:!0,default:``}).asString()}}getFonts(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`font`},e=>this.extractFont(e))}extractFont(e){let t=this.extractChildAttr(e,`name`,`val`,{default:`Arial`}).asString(),n=this.extractChildAttr(e,`sz`,`val`,{default:qe.toString()}).asNum(),r=this.extractColor(this.querySelector(e,`color`),this.theme),i=this.querySelector(e,`i`)||void 0,a=i&&i.attributes.val?.value!==`0`,o=this.querySelector(e,`b`)||void 0,s=o&&o.attributes.val?.value!==`0`,c=this.querySelector(e,`strike`)||void 0,l=c&&c.attributes.val?.value!==`0`,u=this.querySelector(e,`u`)||void 0;return{name:t,size:n,color:r,italic:a,bold:s,underline:u&&u.attributes.val?.value!==`none`,strike:l}}getFills(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`fill`},e=>this.extractFill(e))}extractFill(e){let t=e.children[0];return t.tagName===`patternFill`?{patternType:t.attributes.patternType?.value,bgColor:this.extractColor(this.querySelector(t,`bgColor`),this.theme),fgColor:this.extractColor(this.querySelector(t,`fgColor`),this.theme)}:{patternType:`solid`,fgColor:this.extractColor(this.querySelectorAll(t,`color`)[1],this.theme)}}getBorders(){return this.mapOnElements({parent:this.rootFile.file.xml,query:`border`},e=>this.extractBorder(e))}extractBorder(e){let t={left:this.extractSingleBorder(e,`left`,this.theme),right:this.extractSingleBorder(e,`right`,this.theme),top:this.extractSingleBorder(e,`top`,this.theme),bottom:this.extractSingleBorder(e,`bottom`,this.theme),diagonal:this.extractSingleBorder(e,`diagonal`,this.theme)};return t.diagonal&&(t.diagonalUp=this.extractAttr(e,`diagonalUp`)?.asBool(),t.diagonalDown=this.extractAttr(e,`diagonalDown`)?.asBool()),t}extractSingleBorder(e,t,n){let r=this.querySelector(e,t);if(!(!r||!r.attributes.style))return{style:this.extractAttr(r,`style`,{required:!0,default:`thin`}).asString(),color:this.extractColor(r.children[0],n,`000000`)}}extractAlignment(e){return{horizontal:this.extractAttr(e,`horizontal`,{default:`general`}).asString(),vertical:this.extractAttr(e,`vertical`,{default:`bottom`}).asString(),textRotation:this.extractAttr(e,`textRotation`)?.asNum(),wrapText:this.extractAttr(e,`wrapText`)?.asBool(),indent:this.extractAttr(e,`indent`)?.asNum(),relativeIndent:this.extractAttr(e,`relativeIndent`)?.asNum(),justifyLastLine:this.extractAttr(e,`justifyLastLine`)?.asBool(),shrinkToFit:this.extractAttr(e,`shrinkToFit`)?.asBool(),readingOrder:this.extractAttr(e,`readingOrder`)?.asNum()}}getDxfs(){return this.mapOnElements({query:`dxf`,parent:this.rootFile.file.xml},e=>{let t=this.querySelector(e,`font`),n=this.querySelector(e,`fill`),r=this.querySelector(e,`border`),i=this.querySelector(e,`numFmt`),a=this.querySelector(e,`alignment`);return{font:t?this.extractFont(t):void 0,fill:n?this.extractFill(n):void 0,numFmt:i?this.extractNumFormats(i):void 0,alignment:a?this.extractAlignment(a):void 0,border:r?this.extractBorder(r):void 0}})}getStyles(){return this.mapOnElements({query:`cellXfs xf`,parent:this.rootFile.file.xml},e=>{let t=this.querySelector(e,`alignment`);return{fontId:this.extractAttr(e,`fontId`,{required:!0,default:0}).asNum(),fillId:this.extractAttr(e,`fillId`,{required:!0,default:0}).asNum(),borderId:this.extractAttr(e,`borderId`,{required:!0,default:0}).asNum(),numFmtId:this.extractAttr(e,`numFmtId`,{required:!0,default:0}).asNum(),alignment:t?this.extractAlignment(t):void 0}})}};function Zx(e,t){return Qx($x(e,t),t)}function Qx(e,t){let n=[];for(let r of e){let e=eS(r,t);n.push({file:{fileName:r,xml:t[r]},rels:e?{fileName:e,xml:t[e]}:void 0})}return n}function $x(e,t){let n=t[`[Content_Types].xml`].querySelectorAll(`Override[ContentType="${e}"]`),r=[];for(let e of n){let t=e?.attributes.PartName.value;r.push(t.substring(1))}return r}function eS(e,t){if(e===`[Content_Types].xml`)return`_rels/.rels`;let n=``,r=e.split(`/`);for(let e=0;e<r.length-1;e++)n+=r[e]+`/`;return n+=`_rels/`,n+=r[r.length-1]+`.rels`,t[n]||(n=void 0),n}var tS=class{warningManager;xmls;images;constructor(e){this.warningManager=new my,this.xmls={},this.images=[];for(let t of Object.keys(e))if(t.endsWith(`.xml`)||t.endsWith(`.rels`)){let n=Px(e[t]);this.xmls[t]=Ox(new av(n))}else t.includes(`media/image`)&&this.images.push({fileName:t,imageSrc:e[t].imageSrc})}convertXlsx(){let e=this.getXlsxData();return this.convertImportedData(e)}getXlsxData(){let e=this.buildXlsxFileStructure(),t=e.theme?new zx(e.theme,e,this.warningManager).getTheme():void 0,n=e.sharedStrings?new zx(e.sharedStrings,e,this.warningManager).getSharedStrings():[],r=new zx(e.workbook,e,this.warningManager).getNamedRanges(),i=e.sheets.sort((e,t)=>e.file.fileName.localeCompare(t.file.fileName,void 0,{numeric:!0})).map(n=>new Yx(n,e,this.warningManager,t).getSheet()),a=e.externalLinks.map(t=>new Rx(t,e,this.warningManager).getExternalBook()),o=new Xx(e,this.warningManager,t);return{fonts:o.getFonts(),fills:o.getFills(),borders:o.getBorders(),dxfs:o.getDxfs(),numFmts:o.getNumFormats(),styles:o.getStyles(),sheets:i,sharedStrings:n,externalBooks:a,chartIds:[],imageIds:[],namedRanges:r}}buildXlsxFileStructure(){let e={sheets:Zx(Up.sheet,this.xmls),workbook:Zx(Up.workbook,this.xmls)[0]||Zx(Up.macroEnabledWorkbook,this.xmls)[0]||Zx(Up.templateWorkbook,this.xmls)[0]||Zx(Up.macroEnabledTemplateWorkbook,this.xmls)[0]||Zx(Up.excelAddInWorkbook,this.xmls)[0],styles:Zx(Up.styles,this.xmls)[0],sharedStrings:Zx(Up.sharedStrings,this.xmls)[0],theme:Zx(Up.themes,this.xmls)[0],charts:Zx(Up.chart,this.xmls),figures:Zx(Up.drawing,this.xmls),tables:Zx(Up.table,this.xmls),pivots:Zx(Up.pivot,this.xmls),externalLinks:Zx(Up.externalLink,this.xmls),images:this.images};if(!e.workbook.rels)throw Error(P(`Cannot find workbook relations file`));return e}convertImportedData(e){let t={version:`18.4.2`,sheets:Vb(e,this.warningManager),styles:tb(e,this.warningManager),formats:rb(e,this.warningManager),borders:$y(e,this.warningManager),namedRanges:dv(e,this.warningManager),revisionId:Xe};return _x(t,e),Object.keys(e.styles).map(t=>{e.styles[t]=Zt(e.styles[t])}),t}};function nS(e){let t=!1,n=!0;return ss(e,e=>(t=!0,n&&=e,n)),{foundBoolean:t,result:n}}function rS(e){let t=!1,n=!1;return ss(e,e=>(t=!0,n||=e,!n)),{foundBoolean:t,result:n}}function iS(e,t){return es(e,(e,t)=>e+t,0,t)}function aS(e){return $o(e,(e,t)=>vs(t)?e.add(t?.value):e,new Set).size}function oS(e,t){if(!e)throw new I(t)}function sS(e,t=P(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)){if(e===0)throw new ko(t)}function cS(e){return e.length===1||e[0].length===1}function lS(...e){if(e.every(ht)){let t=e[0].length,n=e[0][0].length;for(let r of e)if(r.length!==t||r[0].length!==n)return!1;return!0}return!e.some(e=>Array.isArray(e)&&(e.length!==1||e[0].length!==1))}function uS(e){return e.length===e[0].length}let dS=e=>P(`The function [[FUNCTION_NAME]] expects a number value to be greater than or equal to 1, but receives %s.`,e);function fS(e){let t=Array(e);for(let n=0;n<e;n++)t[n]=Array(e).fill(0),t[n][n]=1;return t}function pS(e){if(e.length<1||e[0].length<1)throw Error(`invertMatrix: an empty matrix cannot be inverted.`);if(e.length!==e[0].length)throw Error(`invertMatrix: only square matrices are invertible`);let t=1,n=e.length,r=fS(n),i=e.map(e=>e.slice());for(let e=0;e<n;e++){let a=i[e][e];if(a===0){for(let a=e+1;a<n;a++)if(i[e][a]!==0){mS(i,e,a),mS(r,e,a),t*=-1;break}if(a=i[e][e],a===0)return{determinant:0}}for(let t=0;t<n;t++)i[t][e]=i[t][e]/a,r[t][e]=r[t][e]/a;t*=a;for(let t=0;t<n;t++){if(t===e)continue;let a=i[e][t];for(let o=0;o<n;o++)i[o][t]-=a*i[o][e],r[o][t]-=a*r[o][e]}}return{inverted:r,determinant:t}}function mS(e,t,n){for(let r=0;r<e.length;r++){let i=e[r][t];e[r][t]=e[r][n],e[r][n]=i}}function hS(e,t){if(e.length<1||t.length<1)throw Error(`multiplyMatrices: empty matrices cannot be multiplied.`);if(e.length!==t[0].length)throw Error(`multiplyMatrices: incompatible matrices size.`);let n=e[0].length,r=t.length,i=e.length,a=Array(r);for(let o=0;o<r;o++){a[o]=Array(n);for(let r=0;r<n;r++){let n=0;for(let a=0;a<i;a++)n+=e[a][r]*t[o][a];a[o][r]=n}}return a}function gS(e){if(!ht(e))return e;if(!_S(e))throw Error(`The value should be a scalar or a 1x1 matrix`);return e[0][0]}function _S(e){return e.length===1&&e[0].length===1}function vS(e){return ht(e)&&!_S(e)}function yS(...e){let t=e[0].length;e.forEach((e,n)=>oS(e.length===t,P(`[[FUNCTION_NAME]] has mismatched dimensions for argument %s (%s vs %s).`,n.toString(),t.toString(),e.length.toString())))}function bS(e,t){let n=0,r=es(e,(e,t)=>(n+=1,e+t),0,t);return sS(n),r/n}function xS(e,t){let n=[];Zo(e,e=>{n.push(e.value)},t),n.sort((e,t)=>e-t);let r=n.length;if(r===0)return;let i=Math.floor(r/2);return r%2==0?(n[i-1]+n[i])/2:n[i]}function SS(e,t){let n=0;for(let r of e)if(ht(r))for(let e of r)for(let t of e)typeof t.value==`number`&&(n+=1);else{let e=r?.value;!No(e)&&(typeof e!=`string`||lo(e,t)||Na(e,t))&&(n+=1)}return n}function CS(e){return $o(e,(e,t)=>t!==void 0&&t.value!==null?e+1:e,0)}function wS(e,t){let n={value:-1/0};return Zo(e,e=>{e.value>=n.value&&(n=e)},t),n.value===-1/0?{value:0}:n}function TS(e,t){let n={value:1/0};return Zo(e,e=>{e.value<=n.value&&(n=e)},t),n.value===1/0?{value:0}:n}function ES(e,t,n){let r=e[0].length?e:[C(1,t.flat().length+1)],i=r.length,a=n[0].length?n:r;return a=a.length===i?as(a):a,{_X:r,_newX:a}}function DS(e,t,n=!0,r=!1){let i=t.flat(),a=i.length,{_X:o}=ES(e,t,[[]]);o=o.length===a?as(o):o.slice(),yS(o[0],i);let s=o.length,c=a-s-+!!n,l=[i],u=as(o.reverse()),d=[];for(let e=0;e<s;e++)if(d.push(0),n){for(let t of o[e])d[e]+=t;d[e]/=a}let f=0;if(n){for(let e of i)f+=e;f/=a}let p=u.map(e=>e.map((e,t)=>e-d[t]));n&&u.forEach(e=>e.push(1));let m=kS(u,l);if(n||m.push([0]),!r)return m;let{inverted:h}=pS(hS(p,as(p)));if(h===void 0)throw new I(P(`Matrix is not invertible`));let g=0,_=0;for(let e=0;e<a;e++){let t=i[e]-f,n=0;for(let t=0;t<s;t++){let r=p[e][t];n+=r*m[t][0]}let r=t-n;g+=r*r,_+=n*n}let v=Math.sqrt(g/c),ee=_/(_+g),y=_/s/(g/c),b=[];for(let e=0;e<s;e++)b.push(v*Math.sqrt(h[e][e]));if(n){let e=hS(h,[d]),t=hS(as([d]),e);b.push(v*Math.sqrt(t[0][0]+1/i.length))}let te=[[m[0][0],b[0],ee,y,_],[m[1][0],b[1],v,c,g]];for(let e=2;e<s;e++)te.push([m[e][0],b[e],``,``,``]);return n?te.push([m[s][0],b[s],``,``,``]):te.push([0,``,``,``,``]),te}function OS(e,t,n,r){yS(t,e),oS(n>=1,P(`Function [[FUNCTION_NAME]] A regression of order less than 1 cannot be possible.`));let i=[e],a=t.map(e=>C(0,n).map(t=>e**+(n-t)));r&&a.forEach(e=>e.push(1));let o=kS(a,i);return r||o.push([0]),o}function kS(e,t){let{inverted:n}=pS(hS(e,as(e)));if(n===void 0)throw new I(P(`Matrix is not invertible`));return as(hS(n,hS(e,t)))}function AS(e,t,n){return e.reduce((e,r,i)=>e+r*t**+(n-i),0)}function jS(e){return e.map(e=>e.map(e=>Math.exp(e)))}function MS(e){return e.map(e=>e.map(e=>Math.log(e)))}function NS(e,t,n,r){let{_X:i,_newX:a}=ES(t,e,n),o=DS(i,e,r,!1),s=o.length-1,c=a.map(e=>{let t=0;for(let n=0;n<s;n++)t+=o[n][0]*e[s-n-1];return t+=o[s][0],[t]});return c.length===n.length?c:as(c)}function PS(e,t,n=2){let r=[];for(let e=0;e<n-1;e++)r.push({x:t[e],y:NaN});for(let i=0;i<=e.length-n;i++){let a=0;for(let t=i;t<i+n;t++)a+=e[t];r.push({x:t[i+n-1],y:a/n})}return r}function FS(e){let[t,n]=e.split(`/`);return Number(n)*100+Number(t)}let IS=new k;function LS(e){return IS.get(e)}let RS={normalizeFunctionValue(e){return L(e,V)},toValueAndFormat(e,t){return{value:L(e,V),format:`dd mmm yyyy`}},toFunctionValue(e){let t=qo(e,V);return`DATE(${t.getFullYear()},${t.getMonth()+1},${t.getDate()})`}},zS={normalizeFunctionValue(e){let t=L(e,V);if(t<1||t>31)throw new I(P(`%s is not a valid day of month (it should be a number between 1 and 31)`,t));return t},toValueAndFormat(e){return{value:L(e,V),format:`0`}},toFunctionValue(e){return`${e}`}},BS={normalizeFunctionValue(e){let t=L(e,V);if(t<1||t>7)throw new I(P(`%s is not a valid day of week (it should be a number between 1 and 7)`,t));return t},toValueAndFormat(e,t){return{value:Zs[(e-1+(t||V).weekStart)%7].toString(),format:`@`}},toFunctionValue(e){return`${e}`}},VS={normalizeFunctionValue(e){let t=L(e,V);if(t<0||t>53)throw new I(P(`%s is not a valid week (it should be a number between 0 and 53)`,t));return t},toValueAndFormat(e){return{value:L(e,V),format:`0`}},toFunctionValue(e){return`${e}`}},HS={normalizeFunctionValue(e){let t=L(e,V);if(t<1||t>12)throw new I(P(`%s is not a valid month (it should be a number between 1 and 12)`,t));return t},toValueAndFormat(e){return{value:Xs[L(e,V)-1].toString(),format:`@`}},toFunctionValue(e){return`${e}`}},US={normalizeFunctionValue(e){return H(L(e,V),{locale:V,format:`mm/yyyy`})},toValueAndFormat(e){return{value:L(e,V),format:`mmmm yyyy`}},toFunctionValue(e){let t=qo(e,V);return`DATE(${t.getFullYear()},${t.getMonth()+1},1)`},toComparableValue(e){return FS(e)}},WS={normalizeFunctionValue(e){let t=L(e,V);if(t<1||t>4)throw new I(P(`%s is not a valid quarter (it should be a number between 1 and 4)`,t));return t},toValueAndFormat(e){return{value:P(`Q%(quarter_number)s`,{quarter_number:e}),format:`@`}},toFunctionValue(e){return`${e}`}},GS={normalizeFunctionValue(e){let t=L(e,V);return t>3e3?qo(t,V).getFullYear():t},toValueAndFormat(e){return{value:L(e,V),format:`0`}},toFunctionValue(e){return`${e}`}},KS={normalizeFunctionValue(e){let t=L(e,V);if(t<0||t>23)throw new I(P(`%s is not a valid hour (it should be a number between 0 and 23)`,t));return t},toValueAndFormat(e){return{value:P(`%(hour_number)sh`,{hour_number:e}),format:`@`}},toFunctionValue(e){return`${e}`}},qS={normalizeFunctionValue(e){let t=L(e,V);if(t<0||t>59)throw new I(P(`%s is not a valid minute (it should be a number between 0 and 59)`,t));return t},toValueAndFormat(e){return{value:P(`%(minute_number)s'`,{minute_number:e}),format:`@`}},toFunctionValue(e){return`${e}`}},JS={normalizeFunctionValue(e){let t=L(e,V);if(t<0||t>59)throw new I(P(`%s is not a valid second (it should be a number between 0 and 59)`,t));return t},toValueAndFormat(e){return{value:P(`%(second_number)s''`,{second_number:e}),format:`@`}},toFunctionValue(e){return`${e}`}};function YS(e){return{normalizeFunctionValue(t){return t===null?null:e.normalizeFunctionValue(t)},toValueAndFormat(t,n){return t===null?{value:P(`(Undefined)`)}:e.toValueAndFormat(t,n)},toFunctionValue(t){return t===null?`false`:e.toFunctionValue(t)},toComparableValue(t){if(t!==null)return e.toComparableValue?.(t)}}}IS.add(`day`,YS(RS)).add(`year`,YS(GS)).add(`day_of_month`,YS(zS)).add(`iso_week_number`,YS(VS)).add(`month_number`,YS(HS)).add(`month`,YS(US)).add(`quarter_number`,YS(WS)).add(`day_of_week`,YS(BS)).add(`hour_number`,YS(KS)).add(`minute_number`,YS(qS)).add(`second_number`,YS(JS));let XS={displayTotals:!0,displayColumnHeaders:!0,displayMeasuresRow:!0,numberOfRows:Number.MAX_VALUE,numberOfColumns:Number.MAX_VALUE,tableStyleId:`None`,bandedRows:!1,bandedColumns:!1,hasFilters:!1,tabularForm:!1},ZS={count:P(`Count`),count_distinct:P(`Count Distinct`),bool_and:P(`Boolean And`),bool_or:P(`Boolean Or`),max:P(`Maximum`),min:P(`Minimum`),avg:P(`Average`),sum:P(`Sum`)},QS=[`max`,`min`,`avg`,`sum`,`count_distinct`,`count`],$S={integer:QS,char:QS,datetime:QS,boolean:[`count_distinct`,`count`,`bool_and`,`bool_or`]},eC={};for(let e in $S){eC[e]={};for(let t of $S[e])eC[e][t]=ZS[t]}let tC={count:e=>({value:CS([e]),format:`0`}),count_distinct:e=>({value:aS([e]),format:`0`}),bool_and:e=>({value:nS([e]).result}),bool_or:e=>({value:rS([e]).result}),max:(e,t)=>wS([e],t),min:(e,t)=>TS([e],t),avg:(e,t)=>({value:bS([e],t),format:Mo(e)}),sum:(e,t)=>({value:iS([e],t),format:Mo(e)})};function nC(e){let t=Object.keys(e);if(!t.length)return 0;let n=t.map(e=>parseInt(e,10));return Math.max(...n)}let rC={year:P(`Year`),quarter:P(`Quarter & Year`),month:P(`Month & Year`),week:P(`Week & Year`),day:P(`Day`),quarter_number:P(`Quarter`),month_number:P(`Month`),iso_week_number:P(`Week`),day_of_month:P(`Day of Month`),day_of_week:P(`Day of Week`),hour_number:P(`Hour`),minute_number:P(`Minute`),second_number:P(`Second`)},iC=[`date`,`datetime`];function aC(e){let[t,n]=e.split(`:`);return n?{fieldName:t,granularity:n}:{fieldName:t}}function oC(e){return iC.includes(e.type)}function sC(e,t,n){let r=[e];n&&r.push(`"${n}"`);for(let{field:e,value:n,type:i}of t){if(e===`measure`){r.push(`"measure"`,`"${n}"`);continue}let{granularity:t}=aC(e),a=fC(n,{type:i,granularity:t});r.push(`"${e}"`,a)}return r}function cC(e,t){let n=0,r=0,i=t.columns.map(e=>e.nameWithGranularity),a=t.rows.map(e=>e.nameWithGranularity);for(;e[n]!==void 0&&e[n]===a[r];)n++,r++;for(r=0;e[n]!==void 0&&e[n]===i[r];)n++,r++;return e.length===n}function lC(e,t){switch(t.type){case`HEADER`:return`=PIVOT.HEADER(${sC(e,t.domain).join(`,`)})`;case`VALUE`:return`=PIVOT.VALUE(${sC(e,t.domain,t.measure).join(`,`)})`;case`MEASURE_HEADER`:return`=PIVOT.HEADER(${sC(e,[...t.domain,{field:`measure`,value:t.measure,type:`char`}]).join(`,`)})`}return``}function uC(e,t){if(t===null||t===`null`)return null;let n=typeof t==`object`?t.value:t;if(No(n))return n;if(e.type===`custom`)return Jo(t)??null;let r=typeof t==`boolean`?R(t).toLocaleLowerCase():R(t);if(r===`null`)return null;if(!mC.contains(e.type))throw new I(P(`Field %(field)s is not supported because of its type (%(type)s)`,{field:e.displayName,type:e.type}));return r.toLowerCase()===`false`?!1:mC.get(e.type)(r,e)}function dC(e,t){return LS(t.granularity??`month`).normalizeFunctionValue(e)}function fC(e,t){return e===null?`"null"`:hC.contains(t.type)?hC.get(t.type)(e,t.granularity):`"${e}"`}function pC(e,t){return LS(t??`month`).toFunctionValue(e)}let mC=new k;mC.add(`date`,dC).add(`datetime`,dC).add(`integer`,e=>L(e,V)).add(`boolean`,e=>z(e)).add(`char`,e=>R(e)).add(`custom`,e=>e);let hC=new k;hC.add(`date`,pC).add(`datetime`,pC).add(`integer`,e=>`${L(e,V)}`).add(`boolean`,e=>z(e)?`TRUE`:`FALSE`).add(`char`,e=>`"${R(e).replace(/"/g,`\\"`)}"`).add(`custom`,e=>typeof e==`string`?`"${e}"`:String(e));function gC(e){return e.displayName+(e.granularity?` (${rC[e.granularity]})`:``)}function _C(e,t){return e.length===0?t:{...t,format:(t.format||`@`)+`* `}}function vC(e,t){try{if(!t.getMeasure(e.measure))return!1;let n=t.definition.columns;for(let r=0;r<e.domain.length;r++){if(n[r].nameWithGranularity!==e.domain[r].field)return!1;let i=t.getPossibleFieldValues(n[r]).map(e=>e.value);if(!i.includes(e.domain[r].value)&&!(e.domain[r].value===null&&i.includes(``)))return!1}return!0}catch{return!1}}function yC(e,t){return _n(e,t.groups.map(e=>e.name),{compute:(e,t)=>`${e}${t}`,start:2})}function bC(e,t){return _n(e,Object.values(t).map(e=>[e?.name,e?.string]).flat().filter(w),{compute:(e,t)=>`${e}${t}`,start:2})}function xC(e,t){let n={};for(let r of Object.values(e.customFields||{}))t[r.parentField]&&(n[r.name]={type:`custom`,isCustomField:!0,name:r.name,string:r.name,customGroups:r.groups,parentField:r.parentField});return n}function SC(e,t){t.groups=t.groups.filter(t=>!t.values.some(t=>e.includes(t)))}function CC(e,t,n){let r=e.rows.some(e=>e.fieldName===t)?e.rows:e.columns,i=r.findIndex(e=>e.fieldName===t);return i===-1||r.some(e=>e.fieldName===n)||r.splice(i,0,{fieldName:n}),e}function wC(e,t,n){return Object.values(e.customFields||{}).find(e=>e.parentField===t.name)||{parentField:t.name,name:bC(t.string,n),groups:[]}}function TC(e,t){let n=t.model.getters.getPivotCellFromPosition(e),r=t.model.getters.getPivotIdFromPosition(e);if(!r||n.type!==`HEADER`)return;let i=t.model.getters.getPivotCoreDefinition(r),a=i.collapsedDomains?.[n.dimension]?[...i.collapsedDomains[n.dimension]]:[],o=a.findIndex(e=>T(e,n.domain));o===-1?a.push(n.domain):a.splice(o,1);let s=i.collapsedDomains?{...i.collapsedDomains}:{COL:[],ROW:[]};s[n.dimension]=a,t.model.dispatch(`UPDATE_PIVOT`,{pivotId:r,pivot:{...i,collapsedDomains:s}})}function EC(e,t,n,r,i,a,o){let s=e.style;return{numberOfRows:t===void 0?s?.numberOfRows??XS.numberOfRows:L(t,o),numberOfColumns:i===void 0?s?.numberOfColumns??XS.numberOfColumns:L(i,o),displayTotals:n===void 0?s?.displayTotals??XS.displayTotals:z(n),displayColumnHeaders:r===void 0?s?.displayColumnHeaders??XS.displayColumnHeaders:z(r),displayMeasuresRow:a===void 0?s?.displayMeasuresRow??XS.displayMeasuresRow:z(a),tableStyleId:s?.tableStyleId||XS.tableStyleId,bandedRows:s?.bandedRows??XS.bandedRows,bandedColumns:s?.bandedColumns??XS.bandedColumns,hasFilters:s?.hasFilters??XS.hasFilters,tabularForm:s?.tabularForm??XS.tabularForm}}function DC(e,t=`>`){let n=e.indexOf(t),r=e.lastIndexOf(t);return!e||!n||n===r?e:`${e.slice(0,n+1)} … ${e.slice(r)}`}function OC(e,t,n){return n.map(n=>{if(n.id===e.id)return t;if(!n.computedBy||e.id===t.id)return n;let r=Xu(n.computedBy.formula,e.id,t.id);return{...n,computedBy:{...n.computedBy,formula:r}}})}let kC=[`line`,`bar`,`pie`,`scorecard`,`gauge`,`scatter`,`bubble`,`combo`,`waterfall`,`pyramid`,`radar`,`geo`,`funnel`,`sunburst`,`treemap`,`calendar`];function AC(e){let t=Np[e];return t===void 0?void 0:{minColor:t[0],midColor:t.length===3?t[1]:void 0,maxColor:t[t.length-1]}}function jC(e){let t=Ql(e),n=[];return{text:``.concat(...t.map(e=>{if(e.type===`REFERENCE`&&al.test(e.value)){let t=e.value.trim();return n.includes(t)||n.push(t),`|${n.indexOf(t)}|`}else return e.value})),dependencies:n}}let MC={am_ET:7,ar_001:6,ar_SY:6,az_AZ:1,eu_ES:1,be_BY:1,bn_IN:1,bs_BA:1,bg_BG:1,ca_ES:1,zh_CN:7,zh_HK:7,zh_TW:7,hr_HR:1,cs_CZ:1,da_DK:1,nl_BE:1,nl_NL:1,en_AU:7,en_CA:7,en_GB:1,en_IN:7,en_NZ:7,et_EE:1,fi_FI:1,fr_BE:1,fr_CA:7,fr_CH:1,fr_FR:1,gl_ES:1,ka_GE:1,de_DE:1,de_CH:1,el_GR:1,gu_IN:7,he_IL:7,hi_IN:7,hu_HU:1,id_ID:7,it_IT:1,ja_JP:7,kab_DZ:6,km_KH:7,ko_KP:1,ko_KR:7,lo_LA:7,lv_LV:1,lt_LT:1,lb_LU:1,mk_MK:1,ml_IN:1,mn_MN:7,ms_MY:1,nb_NO:1,fa_IR:6,pl_PL:1,pt_AO:1,pt_BR:7,pt_PT:1,ro_RO:1,ru_RU:1,sr_RS:7,"sr@latin":7,sk_SK:1,sl_SI:1,es_AR:7,es_BO:1,es_CL:1,es_CO:7,es_CR:1,es_DO:1,es_EC:1,es_GT:7,es_MX:7,es_PA:7,es_PE:7,es_PY:7,es_UY:1,es_VE:7,sw:1,sv_SE:1,th_TH:7,tl_PH:1,tr_TR:1,uk_UA:1,vi_VN:1,sq_AL:1,te_IN:7,en_US:7,my_MM:7,es_ES:1,es_419:1},NC=new k;NC.add(`0.1`,{migrate(e){return e.sheets&&e.sheets[0]&&(e.activeSheet=e.sheets[0].name),e}}).add(`0.2`,{migrate(e){if(e.sheets&&e.sheets.length)for(let t of e.sheets)t.id=t.id||t.name;return e}}).add(`0.3`,{migrate(e){return e.sheets&&e.activeSheet&&(e.activeSheet=e.sheets.find(t=>t.name===e.activeSheet).id),e}}).add(`0.4`,{migrate(e){for(let t of e.sheets||[])t.figures=t.figures||[];return e}}).add(`0.5`,{migrate(e){for(let t of e.sheets||[])for(let e in t.cells||[]){let n=t.cells[e];n.content&&n.content.startsWith(`=`)&&(n.formula=jC(n.content))}return e}}).add(`0.6`,{migrate(e){for(let t of e.sheets||[])for(let e in t.figures||[]){let{dataSets:n,...r}=t.figures[e].data,i=[];for(let e of n)if(e.labelCell){let t=Un(e.dataRange),n=e.labelCell+`:`+E(t.right,t.bottom);i.push(n)}else i.push(e.dataRange);r.dataSetsHaveTitle=!!n[0].labelCell,r.dataSets=i,t.figures[e].data=r}return e}}).add(`0.7`,{migrate(e){let t=[];for(let n of e.sheets||[]){if(!n.name)continue;let e=n.name,r=_n(Et(e,`_`),t,{compute:(e,t)=>`${e}${t}`});n.name=r,t.push(r);let i=t=>{if(t===void 0)return t;let n=t.replace(e,r),i=t;for(;i!==n;)i=n,n=i.replace(e,r);return i};for(let e in n.cells){let t=n.cells[e];t.formula&&(t.formula.dependencies=t.formula.dependencies.map(i))}for(let e of n.figures||[])if(e.tag===`chart`){let t=e.data.dataSets.map(i),n=i(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:n}}for(let e of n.conditionalFormats||[]){e.ranges=e.ranges.map(i);for(let t of[`minimum`,`maximum`,`midpoint`,`upperInflectionPoint`,`lowerInflectionPoint`])e.rule[t]?.type===`formula`&&(e.rule[t].value=i(e.rule[t].value))}}return e}}).add(`0.8`,{migrate(e){for(let t of e.sheets||[])for(let e of t.figures||[])e.data.background=`#FFFFFF`,e.data.verticalAxisPosition=`left`,e.data.legendPosition=`top`,e.data.stacked=!1;return e}}).add(`0.9`,{migrate(e){for(let t of e.sheets||[])for(let e in t.cells||[]){let n=t.cells[e];if(n.formula){let{text:e,dependencies:t}=n.formula;for(let[n,r]of Object.entries(t)){let t=`\\|${n}\\|`;e=e.replace(new RegExp(t,`g`),r)}n.content=e,delete n.formula}}return e}}).add(`0.10`,{migrate(e){let t={};for(let n of e.sheets||[])for(let e in n.cells||[]){let r=n.cells[e];r.format&&=mv(r.format,t)}return e.formats=t,e}}).add(`15.4`,{migrate(e){for(let t of e.sheets||[])t.isVisible=!0;return e}}).add(`15.4.1`,{migrate(e){return PC(e)}}).add(`16.3`,{migrate(e){for(let t in e.borders){let n=e.borders[t];for(let e in n)Array.isArray(n[e])&&(n[e]={style:n[e][0],color:n[e][1]})}return e}}).add(`16.4`,{migrate(e){return e.settings||={},e.settings.locale||(e.settings.locale=V),e}}).add(`16.4.1`,{migrate(e){return PC(e)}}).add(`17.2`,{migrate(e){for(let t of e.sheets||[])t.tables=t.tables||t.filterTables||[],delete t.filterTables;return e}}).add(`17.3`,{migrate(e){return e.pivots||={},e.pivotNextId||=nC(e.pivots)+1,e}}).add(`17.4`,{migrate(e){for(let t of e.sheets||[])for(let e in t.figures||[]){let n=t.figures[e];`title`in n.data&&typeof n.data.title==`string`&&(n.data.title={text:n.data.title});let r=n.data.type;if(![`line`,`bar`,`pie`,`scatter`,`waterfall`,`combo`].includes(r))continue;let{dataSets:i,...a}=t.figures[e].data;a.dataSets=i.map(e=>({dataRange:e})),t.figures[e].data=a}return e}}).add(`18.0`,{migrate(e){return e}}).add(`18.0.1`,{migrate(e){for(let t of Object.values(e.pivots||{}))t.measures=t.measures.map(e=>({id:e.name,fieldName:e.name,aggregator:e.aggregator})),t.columns=t.columns.map(e=>({fieldName:e.name,order:e.order,granularity:e.granularity})),t.rows=t.rows.map(e=>({fieldName:e.name,order:e.order,granularity:e.granularity}));return e}}).add(`18.0.2`,{migrate(e){let t=e.settings?.locale;return t&&(t.weekStart=MC[t.code]||1),e}}).add(`18.0.3`,{migrate(e){for(let t of e.sheets||[]){t.styles={},t.formats={},t.borders={};for(let e in t.cells)t.styles[e]=t.cells[e].style,t.formats[e]=t.cells[e].format,t.borders[e]=t.cells[e].border,delete t.cells[e].style,delete t.cells[e].format,delete t.cells[e].border}return e}}).add(`18.0.4`,{migrate(e){for(let t of e.sheets||[])for(let e of t.figures||[]){if(e.tag!==`chart`||e.data.type!==`gauge`)continue;let t=e.data;t?.sectionRule?.lowerInflectionPoint&&(t.sectionRule.lowerInflectionPoint.operator=`<=`),t?.sectionRule?.upperInflectionPoint&&(t.sectionRule.upperInflectionPoint.operator=`<=`)}return e}}).add(`18.1`,{migrate(e){for(let t of e.sheets||[])for(let e of t.tables||[])e.config||={...$b,hasFilters:!0};return e}}).add(`18.1.1`,{migrate(e){for(let t of e.sheets||[])for(let e in t.cells){let n=t.cells[e];n&&(t.cells[e]=n.content)}return e}}).add(`18.2`,{migrate(e){return e}}).add(`18.3`,{migrate(e){if(!e.pivots)return e;for(let t of Object.values(e.pivots))t.sortedColumn&&(t.measures.map(e=>e.id).includes(t.sortedColumn.measure)||delete t.sortedColumn);return e}}).add(`18.3.1`,{migrate(e){for(let t of e.sheets||[])for(let e of t.figures||[]){let t=e;e.offset={x:t.x||0,y:t.y||0},e.col=0,e.row=0,delete e.x,delete e.y}return e}}).add(`18.4.1`,{migrate(e){let t={textContains:`containsText`,textNotContains:`notContainsText`,textIs:`isEqualText`,textIsEmail:`isEmail`,textIsLink:`isLink`},n={BeginsWith:`beginsWithText`,Between:`isBetween`,ContainsText:`containsText`,EndsWith:`endsWithText`,Equal:`isEqual`,GreaterThan:`isGreaterThan`,GreaterThanOrEqual:`isGreaterOrEqualTo`,IsEmpty:`isEmpty`,IsNotEmpty:`isNotEmpty`,LessThan:`isLessThan`,LessThanOrEqual:`isLessOrEqualTo`,NotBetween:`isNotBetween`,NotContains:`notContainsText`,NotEqual:`isNotEqual`};for(let t of e.sheets||[])for(let e of t.conditionalFormats||[])e.rule.type===`CellIsRule`&&(e.rule.operator=n[e.rule.operator]);for(let n of e.sheets||[])for(let e of n.dataValidationRules||[])e.criterion.type in t&&(e.criterion.type=t[e.criterion.type]);return e}}).add(`18.4.2`,{migrate(e){for(let t of e.sheets||[])for(let e of t.figures||[]){if(e.tag!==`chart`||e.data.type!==`scorecard`)continue;let t=e.data;t.baselineDescr&&={text:t.baselineDescr}}return e}}).add(`18.4.3`,{migrate(e){if(!e.pivots)return e;for(let t in e.pivots){let n=e.pivots[t];if(n.sortedColumn){let e=n.measures.find(e=>e.fieldName===n.sortedColumn?.measure);e&&(n.sortedColumn.measure=e.id)}}return e}}).add(`18.5.1`,{migrate(e){for(let t of e.sheets||[])for(let e of t.figures||[])e.tag===`chart`&&(e.data.chartId=e.id);return e}}).add(`19.1.0`,{migrate(e){for(let t of e.sheets||[])for(let e of t.figures||[])if(e.tag===`chart`&&e.data.type===`geo`&&`colorScale`in e.data&&typeof e.data.colorScale==`string`&&(e.data.colorScale=AC(e.data.colorScale)),e.tag===`carousel`)for(let t of Object.values(e.data.chartDefinitions)||[])t.type===`geo`&&`colorScale`in t&&typeof t.colorScale==`string`&&(t.colorScale=AC(t.colorScale));return e}}).add(`19.3.1`,{migrate(e){for(let t of e.sheets||[])for(let e of t.figures||[])if(e.tag===`chart`&&!(`humanize`in e.data))e.data.humanize=!0;else if(e.tag===`carousel`)for(let t in e.data.chartDefinitions){let n=e.data.chartDefinitions[t];`humanize`in n||(n.humanize=!0)}return e}}).add(`19.3.2`,{migrate(e){function t(e){if(!(`dataSets`in e))return e;e={...e};let t={};return e.dataSource={type:`range`,dataSetsHaveTitle:e.dataSetsHaveTitle,labelRange:e.labelRange,dataSets:e.dataSets.map((e,n)=>{let r=n.toString(),i=e.dataRange;return delete e.dataRange,Object.keys(e).length&&(t[r]={...e}),{dataRange:i,dataSetId:r}})},delete e.dataSetsHaveTitle,delete e.labelRange,delete e.dataSets,e.dataSetStyles=t,e}for(let n of e.sheets||[])for(let e of n.figures||[])if(e.tag===`chart`&&`dataSets`in e.data)e.data=t(e.data);else if(e.tag===`carousel`)for(let n in e.data.chartDefinitions){let r=e.data.chartDefinitions[n];e.data.chartDefinitions[n]=t(r)}return e}});function PC(e){for(let t of e.sheets||[]){let e=[];for(let n of t.filterTables||[]){let t=Un(n.range),r=e.findIndex(e=>rr(e,t));r===-1?e.push(t):e[r]=t}t.filterTables=e.map(e=>({range:Jn(e)}))}return e}function FC(){return IC().at(-1)}function IC(){return NC.getKeys().sort(VC)}let LC=`Sheet1`;function RC(e,t){if(!e)return $C();console.debug(`### Loading data ###`);let n=performance.now();if(e[`[Content_Types].xml`]){let n=new tS(e);if(e=n.convertXlsx(),t)for(let e of n.warningManager.warnings.sort())console.warn(e)}return`version`in e&&(BC(e)&&(e.version=zC[e.version]),e.version!==FC()&&(console.debug(`Migrating data from version`,e.version),e=HC(e))),e=UC(e),console.debug(`Data loaded in`,performance.now()-n,`ms`),console.debug(`###`),e}let zC={25:`18.2`,24:`18.1.1`,23:`18.1`,22:`18.0.4`,21:`18.0.3`,20:`18.0.2`,19:`18.0.1`,18:`18.0`,17:`17.4`,16:`17.3`,15:`17.2`,"14.5":`16.4.1`,14:`16.4`,13:`16.3`,"12.5":`15.4.1`,12:`15.4`,11:`0.10`,10:`0.9`,9:`0.8`,8:`0.7`,7:`0.6`,6:`0.5`,5:`0.4`,4:`0.3`,3:`0.2`,2:`0.1`,1:`0`};function BC(e){return typeof e.version==`number`}function VC(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<Math.max(n.length,r.length);e++){let t=n[e]||0,i=r[e]||0;if(t>i)return 1;if(t<i)return-1}return 0}function HC(e){let t=performance.now(),n=IC(),r=n.findIndex(t=>VC(t,e.version)>=0);if(r===-1)throw Error(`Data version ${e.version} postdates the current version of o-spreadsheet (version ${FC()}). It cannot be loaded.`);for(let t=r+1;t<n.length;t++){let r=n[t];e=NC.get(r).migrate(e)}return console.debug(`Data migrated in`,performance.now()-t,`ms`),e}function UC(e){return e=WC(e),e=GC(e),e}function WC(e){if(e.uniqueFigureIds)return e;let t=new Set,n=new Set;for(let r of e.sheets||[])for(let e of r.figures||[])t.has(e.id)&&(e.id+=G.smallUuid()),t.add(e.id),e.tag===`chart`&&(n.has(e.data?.chartId)&&(e.data.chartId+=G.smallUuid()),n.add(e.data?.chartId));return e.uniqueFigureIds=!0,e}function GC(e){let t=Object.assign($C(),e,{version:FC()});return t.sheets=t.sheets?t.sheets.map((e,t)=>Object.assign(QC(`Sheet${t+1}`,`Sheet${t+1}`),e)):[],t.sheets.length===0&&t.sheets.push(QC(LC,`Sheet1`)),K_(t.settings.locale)||(t.settings.locale=V),t}function KC(e,t){return t=qC(e,t),t=JC(t,`SORT_CELLS`),t=JC(t,`SET_DECIMAL`),t=YC(e,t),t=XC(e,t),t=ZC(e,t),t}function qC(e,t){if(Object.keys(e).length!==0)return t;let n=[],r=[],i=e=>{if(e.type===`CREATE_SHEET`)n.push(e.sheetId);else if(`sheetId`in e&&!n.includes(e.sheetId))return{...e,sheetId:LC};return e};for(let e of t)e.type===`REMOTE_REVISION`?r.push({...e,commands:e.commands.map(i)}):r.push(e);return r}function JC(e,t){let n=[];for(let r of e)r.type===`REMOTE_REVISION`?n.push({...r,commands:r.commands.filter(e=>e.type!==t)}):n.push(r);return n}function YC(e,t){if(!e.version||VC(String(e.version),`18.5.1`)>=0)return t;let n=[],r={};e=RC(x(e));for(let t of e.sheets||[])t.figures?.forEach(e=>{e.tag===`chart`&&(r[e.id]=e.data)});for(let e of t)if(e.type===`REMOTE_REVISION`){let t=[];for(let n of e.commands){let e=n;switch(n.type){case`CREATE_CHART`:r[n.chartId]=n.definition;break;case`UPDATE_CHART`:if(!r[n.chartId]){console.log(`Fix chart definition: chart with id ${n.chartId} not found.`);continue}let t={...r[n.chartId],...n.definition};e={...n,definition:t},delete t.chartId,r[n.chartId]=t;break}t.push(e)}n.push({...e,commands:t})}else n.push(e);return n}function XC(e,t){let n={};for(let t of e.sheets||[])t.figures?.forEach(e=>{n[e.id]=e.offset});for(let e of t)if(e.type===`REMOTE_REVISION`)for(let t of e.commands)switch(t.type){case`UPDATE_FIGURE`:t.offset&&(t.offset.x===void 0&&(t.offset.x=n[t.figureId]||0),t.offset.y===void 0&&(t.offset.y=n[t.figureId]||0),n[t.figureId]=n);break;case`CREATE_IMAGE`:case`CREATE_CHART`:case`CREATE_FIGURE`:n[t.figureId]=t.offset;break}return t}function ZC(e,t){let n={};for(let t of e.sheets||[])n[t.id]=t.name;let r=[];for(let e of t)if(e.type===`REMOTE_REVISION`){let t=[];for(let r of e.commands){switch(r.type){case`DUPLICATE_SHEET`:r.sheetNameTo=r.sheetNameTo??Vu(n[r.sheetId],Object.values(n));break;case`CREATE_SHEET`:n[r.sheetId]=r.name||Bu(Object.values(n));break;case`RENAME_SHEET`:n[r.sheetId]=r.newName||Bu(Object.values(n));break}t.push(r)}r.push({...e,commands:t})}else r.push(e);return t}function QC(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},styles:{},formats:{},borders:{},cols:{},rows:{},merges:[],conditionalFormats:[],dataValidationRules:[],figures:[],tables:[],isVisible:!0}}function $C(e=`Sheet1`){return{version:FC(),sheets:[QC(LC,e)],styles:{},formats:{},borders:{},revisionId:Xe,uniqueFigureIds:!0,settings:{locale:V},pivots:{},pivotNextId:1,customTableStyles:{},namedRanges:{}}}function ew(e,t){return{...QC(e,t),charts:[],images:[],cellValues:{}}}function tw(){return{...$C(),sheets:[ew(LC,`Sheet1`)]}}let nw=(e,t)=>{e.model.dispatch(t.type).isCancelledBecause(`WillRemoveExistingMerge`)&&e.raiseError(R_)},rw={wrongPasteSelection:P(`This operation is not allowed with multiple selections.`),willRemoveExistingMerge:V_.Errors.WillRemoveExistingMerge,wrongFigurePasteOption:P(`Cannot do a special paste of a figure.`),frozenPaneOverlap:P(`This operation is not allowed due to an overlapping frozen pane.`)};function iw(e,t){t.isSuccessful||(t.reasons.includes(`WrongPasteSelection`)?e.raiseError(rw.wrongPasteSelection):t.reasons.includes(`WillRemoveExistingMerge`)?e.raiseError(rw.willRemoveExistingMerge):t.reasons.includes(`WrongFigurePasteOption`)?e.raiseError(rw.wrongFigurePasteOption):t.reasons.includes(`FrozenPaneOverlap`)&&e.raiseError(rw.frozenPaneOverlap))}function aw(e,t,n){iw(e,e.model.dispatch(`PASTE`,{target:t,pasteOption:n}))}async function ow(e,t,n,r){if(n.data&&n.data.version!==FC()&&e.notifyUser({type:`warning`,text:P(`You copied content from a different version of the application. Only text and image content will be pasted.`),sticky:!1}),n.imageBlob){let t=n;try{t.imageData=await e.imageProvider?.uploadFile(n.imageBlob)}catch(t){let n=P(`An error occurred while uploading the image. %s`,t.message);console.error(t),e.raiseError(n)}delete n.imageBlob}iw(e,e.model.dispatch(`PASTE_FROM_OS_CLIPBOARD`,{target:t,clipboardContent:n,pasteOption:r}))}let sw=new k;var cw=class extends Br{mutators=[`open`,`close`];persistentPopover;hoveredCell=this.get(M_);handle(e){switch(e.type){case`ACTIVATE_SHEET`:this.close()}}open({col:e,row:t},n){let r=this.getters.getActiveSheetId();sw.contains(n)&&(this.persistentPopover={col:e,row:t,sheetId:r,type:n})}close(){if(!this.persistentPopover)return`noStateChange`;this.persistentPopover=void 0}get persistentCellPopover(){return this.persistentPopover&&{isOpen:!0,...this.persistentPopover}||{isOpen:!1}}get isOpen(){return this.persistentPopover!==void 0}get cellPopover(){let e=this.getters.getActiveSheetId();if(this.persistentPopover&&this.getters.isVisibleInViewport(this.persistentPopover)){let e=this.getters.getMainCellPosition(this.persistentPopover),t=sw.get(this.persistentPopover.type).onOpen?.(e,this.getters);return t?.isOpen?{...t,anchorRect:this.computePopoverAnchorRect(this.persistentPopover)}:{isOpen:!1}}let{col:t,row:n}=this.hoveredCell;if(t===void 0||n===void 0||!this.getters.isVisibleInViewport({sheetId:e,col:t,row:n}))return{isOpen:!1};let r=this.getters.getMainCellPosition({sheetId:e,col:t,row:n}),i=sw.getAll().map(e=>e.onHover?.(r,this.getters)).find(e=>e?.isOpen);return i?.isOpen?{...i,anchorRect:this.computePopoverAnchorRect(r)}:{isOpen:!1}}computePopoverAnchorRect({col:e,row:t}){let n=this.getters.getActiveSheetId(),r=this.getters.getMerge({sheetId:n,col:e,row:t});return r?this.getters.getVisibleRect(r):this.getters.getVisibleRect(O({col:e,row:t}))}};let lw=function(e){return e.PlainText=`text/plain`,e.Html=`text/html`,e.Image=`image`,e}({}),uw=[`image/avif`,`image/bmp`,`image/gif`,`image/vnd.microsoft.icon`,`image/jpeg`,`image/png`,`image/tiff`,`image/webp`];function dw(e,t){let n=new Set(t.map(e=>e.left)),r=new Set(t.map(e=>e.right)),i=new Set(t.map(e=>e.top)),a=new Set(t.map(e=>e.bottom)),o=i.size===1&&a.size===1||n.size===1&&r.size===1?hr(t):[t[t.length-1]],s=o.map(e=>ur(e)).flat();return{sheetId:e,zones:t,clippedZones:o,columnsIndexes:[...new Set(s.map(e=>e.col))].sort((e,t)=>e-t),rowsIndexes:[...new Set(s.map(e=>e.row))].sort((e,t)=>e-t)}}function fw(e,t,n){let r=Math.max(e.right-t+1,e.left),i=Math.max(e.bottom-n+1,e.top),a=[];for(let o=e.left;o<=r;o+=t)for(let r=e.top;r<=i;r+=n)a.push({left:o,top:r,bottom:r+n-1,right:o+t-1});return a}function pw(e,t){if(!t.length||!t[0].length)return e;let n=t[0].length,r=t.length;return e.map(e=>fw(e,n,r)).flat()}function mw(e){let t;e[`text/html`]&&(t=gw(new DOMParser().parseFromString(e[`text/html`],`text/html`)));let n=e[`text/plain`]||``,r;if(!n.trim()){for(let t of uw)if(e[t]){r=e[t];break}}return{text:n,data:t,imageBlob:r}}function hw(e){return e?.match(/<div data-osheet-clipboard-id=(['"])([^'"]+)\1/)?.[2]}function gw(e){if([...e.documentElement.attributes].some(e=>e.value.includes(`microsoft`)))return;let t=e.querySelector(`div`)?.getAttribute(`data-osheet-clipboard`);return t&&JSON.parse(t)}let _w=(e,t,n,r)=>{e.forEach(({handlerName:e,handler:i})=>{let a=t[e];a&&i.paste(n,a,r)})};function vw(e,t,n,r,i){let a,o=[],s={sheetId:e,zones:t};for(let{handlerName:c,handler:l}of r){let r=n[c];if(!r)continue;let u=l.getPasteTarget(e,t,r,i);u.figureIds&&(s.figureIds={...s.figureIds,...u.figureIds});for(let e of u.zones){if(o.push(e),a===void 0){a=e;continue}a=$n(a,e)}}return{target:s,zone:a,selectedZones:o}}let yw=(e,t,n)=>{let r={col:t[0].left,row:t[0].top};e.getBackToDefault(),e.selectZone({cell:r,zone:$n(...n)},{scrollIntoView:!1})},bw={type:`bar`,title:{},dataSource:{type:`range`,dataSets:[],dataSetsHaveTitle:!1},dataSetStyles:{},legendPosition:`none`,stacked:!1,humanize:!0},xw={type:`line`,title:{},dataSource:{type:`range`,dataSets:[],dataSetsHaveTitle:!1},dataSetStyles:{},legendPosition:`none`,stacked:!1,cumulative:!1,labelsAsText:!1,humanize:!0};function Sw(e,t){return Jn(e.getUnboundedZone(e.getActiveSheetId(),t))}function Cw(e){if(!e.length)return`empty`;let t={number:0,text:0,date:0,percentage:0},n=0,r=`empty`;for(let i of e){let e=null;if(i.type===`number`?e=i.format&&fc(i.format)?`date`:i.format?.includes(`%`)?`percentage`:`number`:i.type===`text`&&(e=`text`),e){let i=++t[e];i>n&&(n=i,r=e)}}return r}function ww(e,t){let n=[];for(let r of Er(e)){let e=t.getEvaluatedCellsInZone(t.getActiveSheetId(),r);n.push({zone:r,type:Cw(e)})}return n}function Tw(e,t){let n=e.getEvaluatedCellsInZone(e.getActiveSheetId(),t).map(e=>e.value?.toString().trim()||``).filter(e=>e);return{uniqueCount:new Set(n).size,totalCount:n.length}}function Ew(e,t){let n=e.getEvaluatedCell({sheetId:e.getActiveSheetId(),col:t.zone.left,row:t.zone.top});return![`number`,`empty`].includes(n.type)}function Dw(e,t){let{type:n,zone:r}=e,i=t.getActiveSheetId(),a=Ew(t,e),o=Sw(t,r),s=t.getEvaluatedCell({sheetId:i,col:r.left,row:r.top});if(br(r)===1)return Aw(r,t);switch(n){case`percentage`:return{type:`pie`,title:a?{text:String(s.value)}:{},dataSource:{type:`range`,dataSets:[{dataRange:o,dataSetId:`0`}],dataSetsHaveTitle:a},dataSetStyles:{},legendPosition:`none`};case`text`:let e=t.getEvaluatedCellsInZone(i,r).reduce((e,t)=>t.value===s.value?e+1:e,0),n=s.value!==null&&e===1;return{type:`pie`,title:n?{text:String(s.value)}:{},dataSource:{type:`range`,dataSets:[{dataRange:o,dataSetId:`0`}],labelRange:o,dataSetsHaveTitle:n},dataSetStyles:{},aggregated:!0,legendPosition:`top`};case`date`:return{...xw,type:`line`,title:a?{text:String(s.value)}:{},dataSource:{type:`range`,dataSets:[{dataRange:o,dataSetId:`0`}],dataSetsHaveTitle:a},dataSetStyles:{}}}return{...bw,title:a?{text:String(s.value)}:{},dataSource:{type:`range`,dataSets:[{dataRange:o,dataSetId:`0`}],dataSetsHaveTitle:a},dataSetStyles:{}}}function Ow(e,t){if(e.length!==2)throw Error(`buildTwoColumnChart expects exactly two columns`);if(e[1].type===`percentage`)return{type:`pie`,title:{},dataSource:{type:`range`,dataSets:[{dataRange:Sw(t,e[1].zone),dataSetId:`0`}],labelRange:Sw(t,e[0].zone),dataSetsHaveTitle:Ew(t,e[1])},dataSetStyles:{},aggregated:!0,legendPosition:`none`};if(e[0].type===`number`&&e[1].type===`number`)return{type:`scatter`,title:{},dataSource:{type:`range`,dataSets:[{dataRange:Sw(t,e[1].zone),dataSetId:`0`}],labelRange:Sw(t,e[0].zone),dataSetsHaveTitle:Ew(t,e[1])},dataSetStyles:{},labelsAsText:!1,legendPosition:`none`};if(e[0].type===`date`&&e[1].type===`number`)return{...xw,type:`line`,dataSource:{type:`range`,dataSets:[{dataRange:Sw(t,e[1].zone),dataSetId:`0`}],labelRange:Sw(t,e[0].zone),dataSetsHaveTitle:Ew(t,e[0])},dataSetStyles:{}};if(e[0].type===`text`&&e[1].type===`number`){let n=e[0],r=e[1],{uniqueCount:i,totalCount:a}=Tw(t,n.zone),o=Ew(t,r);if(i!==a)return{type:`treemap`,title:{},dataSource:{type:`range`,dataSets:[{dataRange:Sw(t,n.zone),dataSetId:`0`}],labelRange:Sw(t,r.zone),dataSetsHaveTitle:o},dataSetStyles:{},legendPosition:`none`}}return{...bw,dataSource:{type:`range`,dataSets:[{dataRange:Sw(t,e[1].zone),dataSetId:`0`}],labelRange:Sw(t,e[0].zone),dataSetsHaveTitle:Ew(t,e[1])},dataSetStyles:{}}}function kw(e,t){if(e.length<3)throw Error(`buildMultiColumnChart expects at least three columns`);let n=e.some(e=>e.type!==`text`&&Ew(t,e)),r=e[e.length-1],i=e.slice(0,e.length-1);if((r.type===`percentage`||r.type===`number`)&&i.every(e=>e.type===`text`)){let e=i.map(({zone:e},n)=>({dataRange:Sw(t,e),dataSetId:n.toString()}));return{type:i.length>=3?`sunburst`:`treemap`,title:{},dataSource:{type:`range`,dataSets:e,dataSetsHaveTitle:n,labelRange:Sw(t,r.zone)},dataSetStyles:{},legendPosition:`none`}}let a=e[0],o=e.slice(1),s=o.map(({zone:e},n)=>({dataRange:Sw(t,e),dataSetId:n.toString()}));return o.every(e=>e.type===`percentage`)?{type:`pie`,title:{},dataSource:{type:`range`,dataSets:s,labelRange:Sw(t,a.zone),dataSetsHaveTitle:n},dataSetStyles:{},aggregated:!1,legendPosition:`top`}:a.type===`date`&&o.every(e=>e.type===`number`)?{...xw,type:`line`,dataSource:{type:`range`,dataSets:s,labelRange:Sw(t,a.zone),dataSetsHaveTitle:n},dataSetStyles:{},legendPosition:`top`}:{...bw,dataSource:{type:`range`,dataSets:s,labelRange:Sw(t,a.zone),dataSetsHaveTitle:n},dataSetStyles:{},legendPosition:`top`}}function Aw(e,t){let n=t.getCell({sheetId:t.getActiveSheetId(),col:e.left,row:e.top});return{type:`scorecard`,title:{},keyValue:Sw(t,e),background:n?.style?.fillColor,baselineMode:Ze,baselineColorUp:Qe,baselineColorDown:$e}}function jw(e,t){let n=ww(e,t);if(n.length===0||n.every(e=>e.type===`empty`)){let e=n.map(({zone:e},n)=>({dataRange:Sw(t,e),dataSetId:n.toString()}));return{...bw,dataSource:{type:`range`,dataSets:e,dataSetsHaveTitle:!1}}}let r=n.filter(e=>e.type!==`empty`);switch(r.length){case 1:return{humanize:!0,...Dw(r[0],t)};case 2:return{humanize:!0,...Ow(r,t)};default:return{humanize:!0,...kw(r,t)}}}function Mw(e,t,n=$b){let r=e.model.getters.getSelectedZones(),i=e.model.getters.canCreateDynamicTableOnZones(t,r);r.length===1&&!i&&br(r[0])===1&&(e.model.selection.selectTableAroundSelection(),r=e.model.getters.getSelectedZones(),i=e.model.getters.canCreateDynamicTableOnZones(t,r));let a=r.map(n=>e.model.getters.getRangeDataFromZone(t,n)),o=e.model.dispatch(`CREATE_TABLE`,{ranges:a,sheetId:t,config:n,tableType:i?`dynamic`:`static`});return o.isCancelledBecause(`TableOverlap`)?e.raiseError(U_.Errors.TableOverlap):o.isCancelledBecause(`NonContinuousTargets`)&&e.raiseError(U_.Errors.NonContinuousTargets),o}function Nw(e,t){e.model.dispatch(`SET_FORMATTING_WITH_PIVOT`,{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function Pw(e,t){e.model.dispatch(`SET_FORMATTING`,{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}let Fw=async e=>Lw(e),Iw=async e=>Lw(e,`asValue`);async function Lw(e,t){let n=await e.clipboard.read();switch(n.status){case`ok`:let r=e.model.getters.getClipboardId(),i=e.model.getters.getSelectedZones();r===hw(n.content[`text/html`])?aw(e,i,t):await ow(e,i,mw(n.content),t),e.model.getters.isCutOperation()&&t!==`asValue`&&await e.clipboard.write({"text/plain":``});break;case`notImplemented`:e.raiseError(P(`Pasting from the context menu is not supported in this browser. Use keyboard shortcuts ctrl+c / ctrl+v instead.`));break;case`permissionDenied`:e.raiseError(P(`Access to the clipboard denied by the browser. Please enable clipboard permission for this page in your browser settings.`));break}}let Rw=e=>Lw(e,`onlyFormat`),zw=e=>{if(e.model.getters.getSelectedZones().length>1)return P(`Clear rows`);let t,n,r=e.model.getters.getActiveRows();if(r.size!==0)t=pn([...r]),n=fn([...r]);else{let r=e.model.getters.getSelectedZones()[0];t=r.top,n=r.bottom}return t===n?P(`Clear row %s`,(t+1).toString()):P(`Clear rows %s - %s`,(t+1).toString(),(n+1).toString())},Bw=e=>{let t=e.model.getters.getActiveSheetId(),n=[...e.model.getters.getActiveRows()].map(n=>e.model.getters.getRowsZone(t,n,n));e.model.dispatch(`DELETE_CONTENT`,{target:n,sheetId:e.model.getters.getActiveSheetId()})},Vw=e=>{if(e.model.getters.getSelectedZones().length>1)return P(`Clear columns`);let t,n,r=e.model.getters.getActiveCols();if(r.size!==0)t=pn([...r]),n=fn([...r]);else{let r=e.model.getters.getSelectedZones()[0];t=r.left,n=r.right}return t===n?P(`Clear column %s`,Cn(t)):P(`Clear columns %s - %s`,Cn(t),Cn(n))},Hw=e=>{let t=e.model.getters.getActiveSheetId(),n=[...e.model.getters.getActiveCols()].map(n=>e.model.getters.getColsZone(t,n,n));e.model.dispatch(`DELETE_CONTENT`,{target:n,sheetId:e.model.getters.getActiveSheetId()})},Uw=e=>{if(e.model.getters.getSelectedZones().length>1)return P(`Delete rows`);let t,n,r=e.model.getters.getActiveRows();if(r.size!==0)t=pn([...r]),n=fn([...r]);else{let r=e.model.getters.getSelectedZones()[0];t=r.top,n=r.bottom}return t===n?P(`Delete row %s`,(t+1).toString()):P(`Delete rows %s - %s`,(t+1).toString(),(n+1).toString())},Ww=e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){let n=e.model.getters.getSelectedZones()[0];for(let e=n.top;e<=n.bottom;e++)t.push(e)}e.model.dispatch(`REMOVE_COLUMNS_ROWS`,{sheetId:e.model.getters.getActiveSheetId(),sheetName:e.model.getters.getActiveSheetName(),dimension:`ROW`,elements:t})},Gw=(e,t)=>{if(e===`COL`&&t.model.getters.getActiveRows().size>0||e===`ROW`&&t.model.getters.getActiveCols().size>0)return!1;let n=t.model.getters.getActiveSheetId(),r=t.model.getters.getElementsFromSelection(e),i=t.model.getters.checkElementsIncludeAllVisibleHeaders(n,e,r),a=t.model.getters.checkElementsIncludeAllNonFrozenHeaders(n,e,r);return!i&&!a},Kw=e=>{if(e.model.getters.getSelectedZones().length>1)return P(`Delete columns`);let t,n,r=e.model.getters.getActiveCols();if(r.size!==0)t=pn([...r]),n=fn([...r]);else{let r=e.model.getters.getSelectedZones()[0];t=r.left,n=r.right}return t===n?P(`Delete column %s`,Cn(t)):P(`Delete columns %s - %s`,Cn(t),Cn(n))},qw=e=>{let t=e.model.getters.getActiveSheetId(),n=e.model.getters.getElementsFromSelection(`ROW`);return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,`ROW`,n)},Jw=e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){let n=e.model.getters.getSelectedZones()[0];for(let e=n.left;e<=n.right;e++)t.push(e)}e.model.dispatch(`REMOVE_COLUMNS_ROWS`,{sheetId:e.model.getters.getActiveSheetId(),sheetName:e.model.getters.getActiveSheetName(),dimension:`COL`,elements:t})},Yw=e=>{let t=e.model.getters.getActiveSheetId(),n=e.model.getters.getElementsFromSelection(`COL`);return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,`COL`,n)},Xw=e=>{let t=e.model.getters.getActiveRows(),n,r;if(t.size)n=pn([...t]),r=t.size;else{let t=e.model.getters.getSelectedZones()[0];n=t.top,r=t.bottom-t.top+1}e.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:e.model.getters.getActiveSheetId(),sheetName:e.model.getters.getActiveSheetName(),position:`before`,base:n,quantity:r,dimension:`ROW`})},Zw=e=>{let t=e.model.getters.getActiveRows(),n,r;if(t.size)n=fn([...t]),r=t.size;else{let t=e.model.getters.getSelectedZones()[0];n=t.bottom,r=t.bottom-t.top+1}e.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:e.model.getters.getActiveSheetId(),sheetName:e.model.getters.getActiveSheetName(),position:`after`,base:n,quantity:r,dimension:`ROW`})},Qw=e=>{let t=e.model.getters.getActiveCols(),n,r;if(t.size)n=pn([...t]),r=t.size;else{let t=e.model.getters.getSelectedZones()[0];n=t.left,r=t.right-t.left+1}e.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:e.model.getters.getActiveSheetId(),sheetName:e.model.getters.getActiveSheetName(),position:`before`,dimension:`COL`,base:n,quantity:r})},$w=e=>{let t=e.model.getters.getActiveCols(),n,r;if(t.size)n=fn([...t]),r=t.size;else{let t=e.model.getters.getSelectedZones()[0];n=t.right,r=t.right-t.left+1}e.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:e.model.getters.getActiveSheetId(),sheetName:e.model.getters.getActiveSheetName(),position:`after`,dimension:`COL`,base:n,quantity:r})},eT=e=>{let t=e.model.getters.getElementsFromSelection(`COL`),n=t[0],r=t[t.length-1];return t.length===1?P(`Hide column %s`,Cn(n).toString()):r-n+1===t.length?P(`Hide columns %s - %s`,Cn(n).toString(),Cn(r).toString()):P(`Hide columns`)},tT=e=>{let t=e.model.getters.getElementsFromSelection(`ROW`),n=t[0],r=t[t.length-1];return t.length===1?P(`Hide row %s`,(n+1).toString()):r-n+1===t.length?P(`Hide rows %s - %s`,(n+1).toString(),(r+1).toString()):P(`Hide rows`)},nT=e=>{let t=e.model.getters,n=G.smallUuid(),r=t.getActiveSheetId(),i=t.getSelectedZones();i.length===1&&br(i[0])===1&&(e.model.selection.selectTableAroundSelection(),i=t.getSelectedZones());let a={width:536,height:335},{col:o,row:s,offset:c}=kg(t,a);e.model.dispatch(`CREATE_CHART`,{sheetId:r,figureId:n,chartId:G.smallUuid(),col:o,row:s,offset:c,size:a,definition:jw(i,e.model.getters)}).isSuccessful&&(e.model.dispatch(`SELECT_FIGURE`,{figureId:n}),e.openSidePanel(`ChartPanel`))},rT=e=>{let t=e.model.getters,n=G.smallUuid(),r=t.getActiveSheetId(),i={width:536,height:335},{col:a,row:o,offset:s}=kg(t,i);e.model.dispatch(`CREATE_CAROUSEL`,{sheetId:r,figureId:n,col:a,row:o,offset:s,size:i,definition:{items:[]}}).isSuccessful&&(e.model.dispatch(`SELECT_FIGURE`,{figureId:n}),e.openSidePanel(`CarouselPanel`,{figureId:n}))},iT=e=>{let t=G.smallUuid(),n=G.smallUuid();e.model.dispatch(`INSERT_NEW_PIVOT`,{pivotId:t,newSheetId:n}).isSuccessful&&e.openSidePanel(`PivotSidePanel`,{pivotId:t})},aT=e=>e.model.getters.getPivotIds().map((t,n)=>({id:`reinsert_dynamic_pivot_${e.model.getters.getPivotFormulaId(t)}`,name:e.model.getters.getPivotDisplayName(t),sequence:n,execute:e=>{let n=e.model.getters.getSelectedZone(),r=e.model.getters.getPivot(t).getCollapsedTableStructure().export();e.model.dispatch(`INSERT_PIVOT_WITH_TABLE`,{pivotId:t,table:r,col:n.left,row:n.top,sheetId:e.model.getters.getActiveSheetId(),pivotMode:`dynamic`}),e.model.dispatch(`REFRESH_PIVOT`,{id:t})},isVisible:e=>e.model.getters.getPivot(t).isValid()})),oT=e=>e.model.getters.getPivotIds().map((t,n)=>({id:`reinsert_static_pivot_${e.model.getters.getPivotFormulaId(t)}`,name:e.model.getters.getPivotDisplayName(t),sequence:n,execute:e=>{let n=e.model.getters.getSelectedZone(),r=e.model.getters.getPivot(t).getExpandedTableStructure();if(r.numberOfCells>5e5){e.notifyUser({type:`warning`,text:G_(r.numberOfCells,e.model.getters.getLocale()),sticky:!0});return}e.model.dispatch(`INSERT_PIVOT_WITH_TABLE`,{pivotId:t,table:r.export(),col:n.left,row:n.top,sheetId:e.model.getters.getActiveSheetId(),pivotMode:`static`}),e.model.dispatch(`REFRESH_PIVOT`,{id:t})},isVisible:e=>e.model.getters.getPivot(t).isValid()})),sT=async e=>{if(e.imageProvider){let t=e.model.getters.getActiveSheetId(),n=G.smallUuid(),r=await e.imageProvider.requestImage(),i=Ag(e.model.getters,r.size),{col:a,row:o,offset:s}=kg(e.model.getters,i);e.model.dispatch(`CREATE_IMAGE`,{sheetId:t,figureId:n,col:a,row:o,offset:s,size:i,definition:r})}},cT=e=>Nw(e,`0.00%`),lT=e=>{let t=e.model.getters.getActiveSheetId(),n=e.model.getters.getSelectedZones(),r=e.model.getters.getConditionalFormats(t),i=e.model.getters.getRulesSelection(t,n);return i.length===1?e.openSidePanel(`ConditionalFormattingEditor`,{cf:r.find(e=>e.id===i[0]),isNewCf:!1}):e.openSidePanel(`ConditionalFormatting`)},uT=e=>{let{col:t,row:n}=e.model.getters.getActivePosition();e.getStore(cw).open({col:t,row:n},`LinkEditor`)},dT=e=>{let t=e.model.getters.getActiveSheetId(),{col:n,row:r}=e.model.getters.getActivePosition(),i=e.model.getters.getEvaluatedCell({sheetId:t,col:n,row:r});return i&&i.link?P(`Edit link`):P(`Insert link`)},fT=e=>e.model.getters.getFirstTableInSelection()?.config.hasFilters||!1,pT=e=>{let t=e.model.getters.getActiveSheetId(),n=e.model.getters.getSelectedZones(),r=e.model.getters.getTablesOverlappingZones(t,n);return r.length===1&&!r[0].isPivotTable},mT=e=>wr(e.model.getters.getSelectedZones()),hT=e=>{let t=e.model.getters.getActiveSheetId(),n=e.model.getters.getFirstTableInSelection();n?e.model.dispatch(`UPDATE_TABLE`,{sheetId:t,zone:n.range.zone,config:{hasFilters:!0}}):Mw(e,t,{...$b,hasFilters:!0,bandedRows:!1,styleId:`TableStyleLight11`})},gT=e=>{let t=e.model.getters.getActiveSheetId(),n=e.model.getters.getFirstTableInSelection();n&&e.model.dispatch(`UPDATE_TABLE`,{sheetId:t,zone:n.range.zone,config:{hasFilters:!1}})},_T=e=>{Mw(e,e.model.getters.getActiveSheetId()).isSuccessful&&e.openSidePanel(`TableSidePanel`,{})},vT=e=>{let t=e.model.getters.getFirstTableInSelection();t&&e.model.dispatch(`REMOVE_TABLE`,{sheetId:e.model.getters.getActiveSheetId(),target:[t.range.zone]})},yT=e=>e.model.getters.getSelectedZones().length===1,bT=(e,t)=>{if(!yT(e))return!1;let n=t===`COL`?e.model.getters.getActiveCols():e.model.getters.getActiveRows(),r=t===`COL`?e.model.getters.getActiveRows():e.model.getters.getActiveCols(),i=e.model.getters.getActiveSheetId(),a=nr(e.model.getters.getSelectedZone(),e.model.getters.getSheetZone(i));return rn(n)&&(r.size===0||a)},xT={name:e=>fT(e)?P(`Remove selected filters`):P(`Add filters`),isEnabled:e=>mT(e),execute:e=>fT(e)?gT(e):hT(e),icon:`o-spreadsheet-Icon.FILTER_ICON_ACTIVE`},ST={name:e=>{let t=nE(e);return t===1?P(`Insert row`):P(`Insert %s rows`,t.toString())},isVisible:e=>bT(e,`ROW`),icon:`o-spreadsheet-Icon.INSERT_ROW`},CT={name:e=>{let t=nE(e);return t===1?P(`Insert row above`):P(`Insert %s rows above`,t.toString())},execute:Xw,isVisible:e=>bT(e,`ROW`),icon:`o-spreadsheet-Icon.INSERT_ROW_BEFORE`},wT={...CT,name:e=>{let t=nE(e);return t===1?P(`Row above`):P(`%s Rows above`,t.toString())}},TT={...CT,name:e=>{let t=nE(e);return t===1?P(`Insert row`):P(`Insert %s rows`,t.toString())},isVisible:yT,icon:`o-spreadsheet-Icon.INSERT_ROW_BEFORE`},ET={execute:Zw,name:e=>{let t=nE(e);return t===1?P(`Insert row below`):P(`Insert %s rows below`,t.toString())},isVisible:e=>bT(e,`ROW`),icon:`o-spreadsheet-Icon.INSERT_ROW_AFTER`},DT={...ET,name:e=>{let t=nE(e);return t===1?P(`Row below`):P(`%s Rows below`,t.toString())}},OT={name:e=>{let t=rE(e);return t===1?P(`Insert column`):P(`Insert %s columns`,t.toString())},isVisible:e=>bT(e,`COL`),icon:`o-spreadsheet-Icon.INSERT_COL`},kT={name:e=>{let t=rE(e);return t===1?P(`Insert column left`):P(`Insert %s columns left`,t.toString())},execute:Qw,isVisible:e=>bT(e,`COL`),icon:`o-spreadsheet-Icon.INSERT_COL_BEFORE`},AT={...kT,name:e=>{let t=rE(e);return t===1?P(`Column left`):P(`%s Columns left`,t.toString())}},jT={...kT,name:e=>{let t=rE(e);return t===1?P(`Insert column`):P(`Insert %s columns`,t.toString())},isVisible:yT,icon:`o-spreadsheet-Icon.INSERT_COL_BEFORE`},MT={name:e=>{let t=rE(e);return t===1?P(`Insert column right`):P(`Insert %s columns right`,t.toString())},execute:$w,isVisible:e=>bT(e,`COL`),icon:`o-spreadsheet-Icon.INSERT_COL_AFTER`},NT={...MT,name:e=>{let t=rE(e);return t===1?P(`Column right`):P(`%s Columns right`,t.toString())},execute:$w},PT={name:P(`Insert cells`),isVisible:e=>yT(e)&&e.model.getters.getActiveCols().size===0&&e.model.getters.getActiveRows().size===0,icon:`o-spreadsheet-Icon.INSERT_CELL`},FT={name:P(`Insert cells and shift down`),execute:e=>{let t=e.model.getters.getSelectedZone();iw(e,e.model.dispatch(`INSERT_CELL`,{zone:t,shiftDimension:`ROW`}))},isVisible:e=>e.model.getters.getActiveRows().size===0&&e.model.getters.getActiveCols().size===0,icon:`o-spreadsheet-Icon.INSERT_CELL_SHIFT_DOWN`},IT={name:P(`Insert cells and shift right`),execute:e=>{let t=e.model.getters.getSelectedZone();iw(e,e.model.dispatch(`INSERT_CELL`,{zone:t,shiftDimension:`COL`}))},isVisible:e=>e.model.getters.getActiveRows().size===0&&e.model.getters.getActiveCols().size===0,icon:`o-spreadsheet-Icon.INSERT_CELL_SHIFT_RIGHT`},LT={name:P(`Chart`),execute:nT,isEnabled:e=>!e.isSmall,icon:`o-spreadsheet-Icon.INSERT_CHART`},RT={name:P(`Carousel`),execute:rT,isEnabled:e=>!e.isSmall,icon:`o-spreadsheet-Icon.CAROUSEL`},zT={name:P(`Pivot table`),execute:iT,isEnabled:e=>!e.isSmall,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.PIVOT`},BT={name:P(`Image`),shortcut:`Ctrl+O`,execute:sT,isVisible:e=>e.imageProvider!==void 0,isEnabled:e=>!e.isSmall,icon:`o-spreadsheet-Icon.INSERT_IMAGE`},VT={name:()=>P(`Table`),shortcut:`Alt+T`,execute:_T,isVisible:e=>mT(e)&&!e.model.getters.getFirstTableInSelection(),isEnabled:e=>!e.isSmall,icon:`o-spreadsheet-Icon.PAINT_TABLE`},HT={name:P(`Function`),icon:`o-spreadsheet-Icon.FORMULA`},UT={name:P(`SUM`),execute:e=>e.startCellEdition(`=SUM(`)},WT={name:P(`AVERAGE`),execute:e=>e.startCellEdition(`=AVERAGE(`)},GT={name:P(`COUNT`),execute:e=>e.startCellEdition(`=COUNT(`)},KT={name:P(`MAX`),execute:e=>e.startCellEdition(`=MAX(`)},qT={name:P(`MIN`),execute:e=>e.startCellEdition(`=MIN(`)},JT={name:P(`All`),children:[YT]};function YT(){return tE(il.getKeys().filter(e=>!il.get(e).hidden))}let XT=()=>{let e=il.content;return[...new Set(il.getAll().filter(e=>!e.hidden).map(e=>e.category))].filter(w).sort().map((t,n)=>({name:t,children:tE(Object.keys(e).filter(n=>e[n].category===t&&!e[n].hidden)),sequence:60+n}))},ZT={name:P(`Link`),shortcut:`Ctrl+Shift+K`,execute:uT,icon:`o-spreadsheet-Icon.INSERT_LINK`},QT={name:P(`Checkbox`),execute:e=>{let t=e.model.getters.getSelectedZones(),n=e.model.getters.getActiveSheetId(),r=t.map(t=>e.model.getters.getRangeDataFromZone(n,t));e.model.dispatch(`ADD_DATA_VALIDATION_RULE`,{ranges:r,sheetId:n,rule:{id:G.smallUuid(),criterion:{type:`isBoolean`,values:[]}}})},icon:`o-spreadsheet-Icon.INSERT_CHECKBOX`},$T={name:P(`Dropdown list`),execute:e=>{let t=e.model.getters.getSelectedZones(),n=e.model.getters.getActiveSheetId(),r=t.map(t=>e.model.getters.getRangeDataFromZone(n,t)),i=G.smallUuid();e.model.dispatch(`ADD_DATA_VALIDATION_RULE`,{ranges:r,sheetId:n,rule:{id:i,criterion:{type:`isValueInList`,values:[],displayStyle:`chip`}}}),e.model.getters.getDataValidationRule(n,i)&&e.openSidePanel(`DataValidationEditor`,{ruleId:i,onCancel:()=>{e.model.dispatch(`REMOVE_DATA_VALIDATION_RULE`,{sheetId:n,id:i})}})},isEnabled:e=>!e.isSmall,icon:`o-spreadsheet-Icon.INSERT_DROPDOWN`},eE={name:P(`Insert sheet`),shortcut:`Shift+F11`,execute:e=>{let t=e.model.getters.getActiveSheetId(),n=e.model.getters.getSheetIds().indexOf(t)+1,r=G.smallUuid();e.model.dispatch(`CREATE_SHEET`,{sheetId:r,position:n,name:e.model.getters.getNextSheetName()}),e.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:t,sheetIdTo:r})},icon:`o-spreadsheet-Icon.INSERT_SHEET`};function tE(e){return e.sort().map((e,t)=>({name:e,sequence:t*10,execute:t=>t.startCellEdition(`=${e}(`)}))}function nE(e){let t=e.model.getters.getActiveRows();if(t.size)return t.size;{let t=e.model.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function rE(e){let t=e.model.getters.getActiveCols();if(t.size)return t.size;{let t=e.model.getters.getSelectedZones()[0];return t.right-t.left+1}}function iE(e,t){let n=()=>{window.removeEventListener(`pointerup`,r,{capture:!0}),window.removeEventListener(`dragstart`,i),window.removeEventListener(`pointermove`,e),window.removeEventListener(`wheel`,e)},r=e=>{t(e),n()};function i(e){e.preventDefault()}return window.addEventListener(`pointerup`,r,{capture:!0}),window.addEventListener(`dragstart`,i),window.addEventListener(`pointermove`,e),window.addEventListener(`wheel`,e,{passive:!1}),n}function aE(){let e,n=document.body.style.cursor,r=[],i=()=>{e=void 0,document.body.style.cursor=n,r.forEach(e=>e()),r=[]},a=(t,a)=>{let s=()=>{document.body.style.cursor=`move`,e&&(Object.assign(o.itemsStyle,e.getItemStyles()),a.onChange?.())};o.cancel=()=>{o.draggedItemId=void 0,o.itemsStyle={},document.body.style.cursor=n,a.onCancel?.(),i()};let c=(e,t)=>{o.draggedItemId=void 0,o.itemsStyle={},document.body.style.cursor=n,a.onDragEnd?.(e,t),i()};document.body.style.cursor=`move`,o.draggedItemId=a.draggedItemId;let l=t===`horizontal`?new lE(a.scrollableContainerEl):new cE(a.scrollableContainerEl);e=new oE({...a,container:l,onChange:s,onDragEnd:c,onCancel:o.cancel});let u=iE(e.onMouseMove.bind(e),e.onMouseUp.bind(e));r.push(u);let d=e.onScroll.bind(e);a.scrollableContainerEl.addEventListener(`scroll`,d),r.push(()=>a.scrollableContainerEl.removeEventListener(`scroll`,d)),r.push(e.destroy.bind(e))};(0,t.onWillUnmount)(()=>{i()});let o=(0,t.proxy)({itemsStyle:{},draggedItemId:void 0,start:a,cancel:()=>{}});return o}var oE=class{draggedItemId;items;container;initialMousePosition;currentMousePosition;initialScroll;minPosition;maxPosition;edgeScrollIntervalId;onChange;onCancel;onDragEnd;deadZone;constructor(e){this.items=e.items.map(e=>({...e,positionAtStart:e.position})),this.draggedItemId=e.draggedItemId,this.container=e.container,this.onChange=e.onChange,this.onCancel=e.onCancel,this.onDragEnd=e.onDragEnd,this.initialMousePosition=e.initialMousePosition,this.currentMousePosition=e.initialMousePosition,this.initialScroll=this.container.scroll,this.minPosition=this.items[0].position,this.maxPosition=this.items[this.items.length-1].position+this.items[this.items.length-1].size}getItemStyles(){let e={};for(let t of this.items)e[t.id]=this.getItemStyle(t.id);return e}getItemStyle(e){let t=this.container.cssPositionProperty,n={};return n.position=`relative`,n[t]=(this.getItemsPositions()[e]||0)+`px`,n.transition=`${t} 0.5s`,n[`pointer-events`]=`none`,this.draggedItemId===e&&(n.transition=`${t} 0s`,n[`z-index`]=`1000`),W(n)}onScroll(){this.moveDraggedItemToPosition(this.currentMousePosition+this.scrollOffset)}onMouseMove(e){if(e.button>1){this.onCancel();return}let t=this.container.getMousePosition(e);if(this.currentMousePosition=t,t<this.container.start||t>this.container.end){this.startEdgeScroll(t<this.container.start?-1:1);return}else this.stopEdgeScroll();this.moveDraggedItemToPosition(t+this.scrollOffset)}moveDraggedItemToPosition(e){let t=this.getHoveredItemIndex(e,this.items),n=this.items.findIndex(e=>e.id===this.draggedItemId),r=this.items[n];if(this.deadZone&&this.isInZone(e,this.deadZone)){this.onChange(this.getItemsPositions());return}else this.isInZone(e,{start:r.position,end:r.position+r.size})&&(this.deadZone=void 0);if(n===t){this.onChange(this.getItemsPositions());return}let i=Math.min(n,t),a=Math.max(n,t),o=Math.sign(t-n),s=0;for(let e=i;e<=a;e++)e!==n&&(this.items[e].position-=o*r.size,s+=this.items[e].size);r.position+=o*s,this.items.sort((e,t)=>e.position-t.position),this.deadZone=o>0?{start:e,end:r.position}:{start:r.position+r.size,end:e},this.onChange(this.getItemsPositions())}onMouseUp(e){e.button!==0&&this.onCancel(),e.stopPropagation(),e.preventDefault();let t=this.items.findIndex(e=>e.id===this.draggedItemId);return this.onDragEnd(this.draggedItemId,t),this.stopEdgeScroll(),!1}startEdgeScroll(e){this.edgeScrollIntervalId||=window.setInterval(()=>{let t=e*3;this.container.scroll+=t},5)}stopEdgeScroll(){window.clearInterval(this.edgeScrollIntervalId),this.edgeScrollIntervalId=void 0}getHoveredItemIndex(e,t){return e<=this.minPosition?0:e>=this.maxPosition?t.length-1:t.findIndex(t=>t.position+t.size>=e)}getItemsPositions(){let e={};for(let t of this.items){if(t.id!==this.draggedItemId){e[t.id]=t.position-t.positionAtStart;continue}let n=this.currentMousePosition-this.initialMousePosition+this.scrollOffset;n=Math.max(this.minPosition-t.positionAtStart,n),n=Math.min(this.maxPosition-t.positionAtStart-t.size,n),e[t.id]=n}return e}isInZone(e,t){return e>=t.start&&e<=t.end}get scrollOffset(){return this.container.scroll-this.initialScroll}destroy(){this.stopEdgeScroll()}},sE=class{el;constructor(e){this.el=e}get containerRect(){return this.el.getBoundingClientRect()}},cE=class extends sE{get start(){return this.containerRect.top}get end(){return this.containerRect.bottom}get cssPositionProperty(){return`top`}get scroll(){return this.el.scrollTop}set scroll(e){this.el.scrollTop=e}getMousePosition(e){return e.clientY}},lE=class extends sE{get start(){return this.containerRect.left}get end(){return this.containerRect.right}get cssPositionProperty(){return`left`}get scroll(){return this.el.scrollLeft}set scroll(e){this.el.scrollLeft=e}getMousePosition(e){return e.clientX}};function uE(e){(0,t.useEffect)(()=>e()?.focus())}let dE={value:N.or([N.number(),N.string()]),onChange:N.function(),onFocused:N.function().optional(),onBlur:N.function().optional(),onInput:N.function().optional(),class:N.string().optional(),id:N.string().optional(),placeholder:N.string().optional(),autofocus:N.boolean().optional(),alwaysShowBorder:N.boolean().optional(),selectContentOnFocus:N.boolean().optional(),resetOnBlur:N.boolean().optional()};var fE=class extends A{props=(0,t.props)(dE);genericInputRef=t.signal.ref(HTMLInputElement);lastOnChangeValue=this.props.value.toString();setup(){(0,t.useListener)(window,`click`,e=>{let t=this.genericInputRef();!t||e.target===t||t.value===this.props.value.toString()||(this.props.resetOnBlur?t.value=this.props.value.toString():this.save())},{capture:!0}),this.props.autofocus&&uE(this.genericInputRef),(0,t.onWillUpdateProps)(e=>{let t=this.genericInputRef();document.activeElement!==t&&t&&(t.value=e.value),this.lastOnChangeValue=e.value.toString()}),(0,t.onMounted)(()=>{let e=this.genericInputRef();e&&(e.value=this.props.value.toString())})}onKeyDown(e){switch(e.key){case`Enter`:this.save(),e.preventDefault(),e.stopPropagation();break;case`Escape`:let t=this.genericInputRef();t&&(t.value=this.props.value.toString(),t.blur()),e.preventDefault(),e.stopPropagation();break}}save(){let e=(this.genericInputRef()?.value||``).trim();e!==this.lastOnChangeValue&&(this.lastOnChangeValue=e,this.props.onChange(e)),document.activeElement===this.genericInputRef()&&this.genericInputRef()?.blur()}onMouseDown(e){e.target!==document.activeElement&&this.props.selectContentOnFocus&&(e.preventDefault(),e.stopPropagation())}onMouseUp(e){let t=e.target;t!==document.activeElement&&this.props.selectContentOnFocus&&(t.focus(),this.props.selectContentOnFocus&&t.select(),e.preventDefault(),e.stopPropagation())}onFocus(){this.props.onFocused?.()}onBlur(){if(this.props.onBlur?.(),this.props.resetOnBlur){let e=this.genericInputRef();e&&(e.value=this.props.value.toString())}else this.save()}onInput(e){let t=e.target;this.props.onInput?.(t.value)}},pE=class extends fE{static template=`o-spreadsheet-TextInput`;static components={};props=(0,t.props)({...dE,value:N.string(),errorMessage:N.string().optional(),maxLength:N.number().optional()});get inputClass(){return[this.props.class,`w-100 os-input`,this.props.alwaysShowBorder?`o-input-border`:void 0,this.props.errorMessage?`o-invalid`:void 0].filter(w).join(` `)}},mE=class extends A{static template=`o-spreadsheet-ActionButton`;props=(0,t.props)({action:N.ActionSpec(),hasTriangleDownIcon:N.boolean().optional(),selectedColor:N.string().optional(),class:N.string().optional(),onClick:N.function().optional()});actionButton=xe(this.props.action);setup(){(0,t.onWillUpdateProps)(e=>{e.action!==this.props.action&&(this.actionButton=xe(e.action))})}get isVisible(){return this.actionButton.isVisible(this.env)}get isEnabled(){let e=this.actionButton.isEnabledOnLockedSheet||!this.env.model.getters.isCurrentSheetLocked();return this.actionButton.isEnabled(this.env)&&e}get isActive(){return this.actionButton.isActive?.(this.env)}get title(){let e=this.actionButton.name(this.env),t=this.actionButton.description(this.env)||ve(this.actionButton.shortcut);return e+(t?` (${t})`:``)}get iconTitle(){return this.actionButton.icon(this.env)}onClick(e){this.isEnabled&&(this.props.onClick?.(e),this.actionButton.execute?.(this.env))}get buttonStyle(){return this.props.selectedColor?W({"border-bottom":`4px solid ${this.props.selectedColor}`,height:`16px`,"margin-top":`2px`}):``}},hE=class extends A{static template=`o-spreadsheet-ColorPicker`;static components={Popover:y_};props=(0,t.props)({onColorPicked:N.function(),currentColor:N.string().optional(``),maxHeight:N.Pixel().optional(),anchorRect:N.Rect(),disableNoColor:N.boolean().optional()});COLORS=Ve;state=(0,t.proxy)({showGradient:!1,currentHslaColor:Xf(this.props.currentColor)?{...sp(this.props.currentColor),a:1}:{h:0,s:100,l:100,a:1},customHexColor:Xf(this.props.currentColor)?Yf(this.props.currentColor):``});get colorPickerStyle(){return this.props.maxHeight!==void 0&&this.props.maxHeight<=0?W({display:`none`}):``}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:`bottom-left`,verticalOffset:0}}get gradientHueStyle(){return W({background:`hsl(${this.state.currentHslaColor?.h||0} 100% 50%)`})}get sliderStyle(){let e=this.state.currentHslaColor?.h||0;return W({"margin-left":`${S(Math.round(e/360*216),1,216)-18/2}px`})}get pointerStyle(){let{s:e,l:t}=this.state.currentHslaColor||{s:0,l:0},n=Math.round(216*S(e/100,0,1)),r=Math.round(186*S(1-2*t/(200-e),0,1));return W({left:`${-16/2+n}px`,top:`${-16/2+r}px`,background:op(this.state.currentHslaColor)})}get colorPreviewStyle(){return W({"background-color":op(this.state.currentHslaColor)})}get checkmarkColor(){return om(this.props.currentColor)}get isHexColorInputValid(){return!this.state.customHexColor||Xf(this.state.customHexColor)}setCustomGradient({x:e,y:t}){let n=S(e,0,216),r=S(t,0,186),i=n/216,a=r/186,o=100*i,s=100*(1-a)*(1-.5*i);this.updateColor({s:o,l:s})}setCustomHue(e){let t=Math.round(S(360*e/216,0,359));this.updateColor({h:t})}updateColor(e){this.state.currentHslaColor={...this.state.currentHslaColor,...e},this.state.customHexColor=op(this.state.currentHslaColor)}onColorClick(e){e&&this.props.onColorPicked(Yf(e))}resetColor(){this.props.onColorPicked(``)}toggleColorPicker(){this.state.showGradient=!this.state.showGradient}dragGradientPointer(e){let t={x:e.offsetX,y:e.offsetY};this.setCustomGradient(t);let n={x:e.clientX,y:e.clientY};iE(e=>{let r={x:e.clientX,y:e.clientY},i=r.x-n.x,a=r.y-n.y,o={x:t.x+i,y:t.y+a};this.setCustomGradient(o)},()=>{})}dragHuePointer(e){let t=e.offsetX,n=e.clientX;this.setCustomHue(t),iE(e=>{let r=t+(e.clientX-n);this.setCustomHue(r)},()=>{})}setHexColor(e){let t=e.target.value.replace(`##`,`#`).slice(0,7);this.state.customHexColor=t,Xf(t)&&(this.state.currentHslaColor={...sp(t),a:1})}addCustomColor(e){!Zf(this.state.currentHslaColor)||!Xf(this.state.customHexColor)||this.props.onColorPicked(Yf(this.state.customHexColor))}isSameColor(e,t){return up(e,t)}get canUseEyeDropper(){return!!globalThis.EyeDropper&&!this.env.model.getters.isDarkMode()}async activateEyedropper(){if(globalThis.EyeDropper)try{let e=await new globalThis.EyeDropper().open();e&&e.sRGBHex&&this.props.onColorPicked(Yf(e.sRGBHex))}catch(e){if(e.name!==`AbortError`)throw e}}},gE=class extends A{static template=`o-spreadsheet-ColorPickerWidget`;static components={ColorPicker:hE};props=(0,t.props)({currentColor:N.string().optional(),toggleColorPicker:N.function(),showColorPicker:N.boolean(),onColorPicked:N.function(),icon:N.string(),title:N.string().optional(),disabled:N.boolean().optional(),dropdownMaxHeight:N.Pixel().optional(),class:N.string().optional()});colorPickerButtonRef=(0,t.signal)(null);get iconStyle(){return this.props.currentColor?`border-color: ${this.props.currentColor}`:`border-bottom-style: hidden`}get colorPickerAnchorRect(){return y(this.colorPickerButtonRef())}},_E=class extends A{static template=`o-spreadsheet-NumberEditor`;static components={Popover:y_};props=(0,t.props)({currentValue:N.number(),onValueChange:N.function(),onToggle:N.function().optional(),onFocusInput:N.function().optional(()=>()=>{}),class:N.string(),valueIcon:N.string().optional(),min:N.number(),max:N.number(),title:N.string(),valueList:N.array(N.number())});dropdown=(0,t.proxy)({isOpen:!1});inputRef=t.signal.ref(HTMLInputElement);rootEditorRef=(0,t.signal)(null);valueListRef=(0,t.signal)(null);DOMFocusableElementStore;setup(){this.DOMFocusableElementStore=j(c_),Fi(window,`click`,this.onExternalClick,{capture:!0}),(0,t.onWillUpdateProps)(e=>{let t=this.inputRef();t&&document.activeElement!==t&&(t.value=e.currentValue)}),(0,t.onMounted)(()=>{let e=this.inputRef();e&&(e.value=this.props.currentValue.toString())})}get popoverProps(){return{anchorRect:y(this.rootEditorRef()),positioning:`bottom-left`,verticalOffset:0}}onExternalClick(e){let t=this.valueListRef(),n=this.rootEditorRef();t&&n&&!_(t,e)&&!_(n,e)&&this.closeList()}toggleList(){this.dropdown.isOpen?this.closeList():(this.props.onToggle?.(),this.inputRef()?.focus())}closeList(){this.dropdown.isOpen=!1}setValue(e){let t=S(Math.floor(parseFloat(e)),this.props.min,this.props.max);this.props.onValueChange(t),this.closeList()}setValueFromInput(e){this.setValue(e.target.value)}setValueFromList(e){this.setValue(e)}get currentValue(){return`${this.props.currentValue}`}onInputFocused(e){this.dropdown.isOpen=!0,e.target.select()}onInputKeydown(e){if(e.key===`Enter`||e.key===`Escape`){this.closeList();let t=e.target;e.key===`Escape`&&(t.value=`${this.props.currentValue}`),this.props.onToggle?.()}if(e.key===`Tab`){e.preventDefault(),e.stopPropagation(),this.closeList(),this.DOMFocusableElementStore.focus();return}}},vE=class extends A{static template=`o-spreadsheet-FontSizeEditor`;static components={NumberEditor:_E};props=(0,t.props)({currentFontSize:N.number(),onFontSizeChanged:N.function(),onToggle:N.function().optional(),onFocusInput:N.function().optional(()=>()=>{}),class:N.string()});fontSizes=ot},yE=class extends A{static template=`o-spreadsheet.TextStyler`;static components={ColorPickerWidget:gE,ActionButton:mE,FontSizeEditor:vE};props=(0,t.props)({style:N.ChartStyle(),updateStyle:N.function(),defaultStyle:N.object().optional(),hasVerticalAlign:N.boolean().optional(),hasHorizontalAlign:N.boolean().optional(),hasBackgroundColor:N.boolean().optional(),class:N.string().optional()});openedEl=null;setup(){Fi(window,`click`,this.onExternalClick)}state=(0,t.proxy)({activeTool:``});updateFontSize(e){this.props.updateStyle?.({...this.props.style,fontSize:e})}toggleDropdownTool(e,t){let n=this.state.activeTool===e;this.closeMenus(),this.state.activeTool=n?``:e,this.openedEl=n?null:t.target}onExternalClick(e){this.openedEl!==e.target&&this.closeMenus()}onTextColorChange(e){this.props.updateStyle?.({...this.props.style,color:e}),this.closeMenus()}onFillColorChange(e){this.props.updateStyle?.({...this.props.style,fillColor:e}),this.closeMenus()}updateAlignment(e){this.props.updateStyle?.({...this.props.style,align:e}),this.closeMenus()}updateVerticalAlignment(e){this.props.updateStyle?.({...this.props.style,verticalAlign:e}),this.closeMenus()}toggleBold(){this.props.updateStyle?.({...this.props.style,bold:!this.bold})}toggleItalic(){this.props.updateStyle?.({...this.props.style,italic:!this.italic})}closeMenus(){this.state.activeTool=``,this.openedEl=null}get align(){return this.props.style.align??this.props.defaultStyle?.align}get verticalAlign(){return this.props.style.verticalAlign||this.props.defaultStyle?.verticalAlign}get bold(){return this.props.style.bold??this.props.defaultStyle?.bold}get italic(){return this.props.style.italic??this.props.defaultStyle?.italic}get currentFontSize(){return this.props.style.fontSize??this.props.defaultStyle?.fontSize??Ue.fontSize}get boldButtonAction(){return{name:P(`Bold`),execute:()=>this.toggleBold(),isActive:()=>this.bold||!1,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.BOLD`}}get italicButtonAction(){return{name:P(`Italic`),execute:()=>this.toggleItalic(),isActive:()=>this.italic||!1,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ITALIC`}}get horizontalAlignButtonAction(){let e=`o-spreadsheet-Icon.ALIGN_LEFT`;return this.align===`center`?e=`o-spreadsheet-Icon.ALIGN_CENTER`:this.align===`right`&&(e=`o-spreadsheet-Icon.ALIGN_RIGHT`),{name:P(`Horizontal alignment`),icon:e,isEnabledOnLockedSheet:!0}}get horizontalAlignActions(){return[{name:P(`Left`),execute:()=>this.updateAlignment(`left`),isActive:()=>this.align===`left`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_LEFT`},{name:P(`Center`),execute:()=>this.updateAlignment(`center`),isActive:()=>this.align===`center`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_CENTER`},{name:P(`Right`),execute:()=>this.updateAlignment(`right`),isActive:()=>this.align===`right`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_RIGHT`}]}get verticalAlignButtonAction(){let e=`o-spreadsheet-Icon.ALIGN_MIDDLE`;return this.verticalAlign===`top`?e=`o-spreadsheet-Icon.ALIGN_TOP`:this.verticalAlign===`bottom`&&(e=`o-spreadsheet-Icon.ALIGN_BOTTOM`),{name:P(`Vertical alignment`),icon:e,isEnabledOnLockedSheet:!0}}get verticalAlignActions(){return[{name:P(`Top`),execute:()=>this.updateVerticalAlignment(`top`),isActive:()=>this.verticalAlign===`top`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_TOP`},{name:P(`Middle`),execute:()=>this.updateVerticalAlignment(`middle`),isActive:()=>this.verticalAlign===`middle`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_MIDDLE`},{name:P(`Bottom`),execute:()=>this.updateVerticalAlignment(`bottom`),isActive:()=>this.verticalAlign===`bottom`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_BOTTOM`}]}},bE=class extends A{static template=`o-spreadsheet-CogWheelMenu`;static components={MenuPopover:C_};props=(0,t.props)({items:N.array(N.ActionSpec())});buttonRef=(0,t.signal)(null);menuState=(0,t.proxy)({isOpen:!1,anchorRect:null,menuItems:[]});menuId=G.uuidv4();toggleMenu(e){e.closedMenuId!==this.menuId&&(this.menuState.isOpen=!this.menuState.isOpen,this.menuState.anchorRect=b(this.buttonRef()),this.menuState.menuItems=_e(this.props.items))}},Z=class extends A{static template=`o_spreadsheet.Section`;props=(0,t.props)({class:N.string().optional(),title:N.string().optional(),slots:N.object()})},xE=class extends A{static template=`o-spreadsheet-CarouselPanel`;static components={Section:Z,TextInput:pE,TextStyler:yE,CogWheelMenu:bE};props=(0,t.props)({onCloseSidePanel:N.function(),figureId:N.UID()});DEFAULT_CAROUSEL_TITLE_STYLE=ut;dragAndDrop=aE();previewListRef=(0,t.signal)(null);setup(){let e=[...this.carouselItems];(0,t.onWillUpdateProps)(()=>{T(this.carouselItems,e)||this.dragAndDrop.cancel(),e=[...this.carouselItems]})}get carouselItems(){return this.env.model.getters.getCarousel(this.props.figureId).items}get title(){return this.env.model.getters.getCarousel(this.props.figureId).title}get carousel(){return this.env.model.getters.getCarousel(this.props.figureId)}getPreviewDivStyle(e){return this.dragAndDrop.itemsStyle[this.getItemId(e)]||``}getItemId(e){return e.type===`chart`?e.chartId:`transparent-carousel`}addNewChartToCarousel(){this.env.model.dispatch(`ADD_NEW_CHART_TO_CAROUSEL`,{figureId:this.props.figureId,sheetId:this.carouselSheetId})}get hasDataView(){return this.carouselItems.some(e=>e.type===`carouselDataView`)}isCarouselItemActive(e){return T(this.env.model.getters.getSelectedCarouselItem(this.props.figureId),e)}addDataViewToCarousel(){let e=this.env.model.getters.getCarousel(this.props.figureId);this.updateItems([...e.items,{type:`carouselDataView`}])}activateCarouselItem(e){this.env.model.dispatch(`UPDATE_CAROUSEL_ACTIVE_ITEM`,{figureId:this.props.figureId,sheetId:this.carouselSheetId,item:e})}editCarouselItem(e){e.type===`chart`&&(this.activateCarouselItem(e),this.env.model.dispatch(`SELECT_FIGURE`,{figureId:this.props.figureId}),this.env.openSidePanel(`ChartPanel`,{chartId:e.chartId}))}renameCarouselItem(e,t){let n=t.trim();if(!n||n===this.getItemTitle(e).toString())return;let r=[...this.carouselItems],i=this.carouselItems.findIndex(t=>T(t,e));i!==-1&&(r[i]={...e,title:n},this.updateItems(r))}deleteCarouselItem(e){let t=this.env.model.getters.getCarousel(this.props.figureId).items.filter(t=>!T(t,e));this.updateItems(t)}popOutCarouselItem(e){e.type===`chart`&&this.env.model.dispatch(`POPOUT_CHART_FROM_CAROUSEL`,{sheetId:this.carouselSheetId,carouselId:this.props.figureId,chartId:e.chartId})}duplicateCarouselChart(e){e.type===`chart`&&this.env.model.dispatch(`DUPLICATE_CAROUSEL_CHART`,{sheetId:this.carouselSheetId,carouselId:this.props.figureId,chartId:e.chartId,duplicatedChartId:G.smallUuid()})}onDragHandleMouseDown(e,t){if(t.button!==0)return;let n=this.previewListRef();if(!n)return;let r=Array.from(n.children).map(e=>b(e)),i=this.carouselItems.map((e,t)=>({id:this.getItemId(e),size:r[t].height,position:r[t].y}));this.dragAndDrop.start(`vertical`,{draggedItemId:this.getItemId(e),initialMousePosition:t.clientY,items:i,scrollableContainerEl:n,onDragEnd:(t,n)=>this.onDragEnd(e,n)})}onDragEnd(e,t){let n=this.carouselItems.findIndex(t=>T(t,e));if(n===-1||n===t)return;let r=[...this.env.model.getters.getCarousel(this.props.figureId).items];r.splice(n,1),r.splice(t,0,e),this.updateItems(r)}getItemTitle(e){return Wg(this.env.model.getters,e)}getItemPreview(e){return Ug(this.env.model.getters,e)}updateItems(e){this.env.model.dispatch(`UPDATE_CAROUSEL`,{figureId:this.props.figureId,sheetId:this.carouselSheetId,definition:{...this.carousel,items:e}})}updateTitleText(e){let t=this.env.model.getters.getCarousel(this.props.figureId);this.env.model.dispatch(`UPDATE_CAROUSEL`,{figureId:this.props.figureId,sheetId:this.carouselSheetId,definition:{...t,title:{...t.title,text:e}}})}updateTitleStyle(e){let t=this.env.model.getters.getCarousel(this.props.figureId);this.env.model.dispatch(`UPDATE_CAROUSEL`,{figureId:this.props.figureId,sheetId:this.carouselSheetId,definition:{...t,title:{...t.title,...e}}})}get carouselAddChartInfoMessage(){return P(`Add a chart to the carousel. You can also add a chart by dragging and dropping it over the carousel figure.`)}getCogWheelMenuItems(e){let t=[];return e.type===`chart`&&(t.push({name:P(`Edit chart`),execute:()=>this.editCarouselItem(e),icon:`o-spreadsheet-Icon.EDIT`}),t.push({name:P(`Pop out chart`),execute:()=>this.popOutCarouselItem(e),icon:`o-spreadsheet-Icon.EXTERNAL`}),t.push({name:P(`Duplicate chart`),execute:()=>this.duplicateCarouselChart(e),icon:`o-spreadsheet-Icon.COPY`})),t.push({name:P(`Delete item`),execute:()=>this.deleteCarouselItem(e),icon:`o-spreadsheet-Icon.TRASH`}),t}get carouselSheetId(){let e=this.env.model.getters.getFigureSheetId(this.props.figureId);if(!e)throw Error(`Could not find the sheetId of the carousel figure`);return e}get carouselDataViewMessage(){return P(`The data view makes the carousel transparent, revealing the data underneath.`)}};let SE=new k;var CE=class extends A{static template=`o-spreadsheet.Checkbox`;props=(0,t.props)({label:N.string().optional(),value:N.boolean().optional(!1),className:N.string().optional(),name:N.string().optional(),title:N.string().optional(),disabled:N.boolean().optional(),onChange:N.function()});onChange(e){let t=e.target.checked;this.props.onChange(t)}};let wE={chartId:N.UID(),definition:N.object({}),canUpdateChart:N.function(),updateChart:N.function()},TE={ArrowDown:`down`,ArrowLeft:`left`,ArrowRight:`right`,ArrowUp:`up`};function EE(e,t){let n=TE[e.key];e.shiftKey?t.resizeAnchorZone(n,le(e)?`end`:1):t.moveAnchorCell(n,le(e)?`end`:1)}function DE(e,t,n){let{anchor:{zone:r,cell:i}}=e.getSelection(),a={...i},o=br(r);do a=OE(a,r,n),o--;while(o>0&&!kE(e,a));o>0&&t.updateAnchorCell(a.col,a.row,{scrollIntoView:!0})}function OE(e,t,n){let{col:r,row:i}=e;switch(n){case`right`:r<t.right?r++:(r=t.left,i=i<t.bottom?i+1:t.top);break;case`left`:r>t.left?r--:(r=t.right,i=i>t.top?i-1:t.bottom);break;case`down`:i<t.bottom?i++:(i=t.top,r=r<t.right?r+1:t.left);break;case`up`:i>t.top?i--:(i=t.bottom,r=r>t.left?r-1:t.right);break}return{col:r,row:i}}function kE(e,t){let n=e.getActiveSheetId();if(e.isHeaderHidden(n,`COL`,t.col)||e.isHeaderHidden(n,`ROW`,t.row))return!1;let r=e.getMainCellPosition({sheetId:n,col:t.col,row:t.row});return r.col===t.col&&r.row===t.row}function AE(e,t,n){let{x:r,y:i,width:a,height:o}=n;if(a<0||o<0)return;let s=t.color||`#017E84`,{ctx:c}=e;c.save(),t.noBorder||(t.dashed&&c.setLineDash([5,3]),c.strokeStyle=s,t.thinLine?(c.lineWidth=1,c.strokeRect(r,i,a,o)):(c.lineWidth=2,c.strokeRect(r+.5,i+.5,a,o))),t.noFill||(c.fillStyle=dp(Yf(s),t.fillAlpha??.12),c.fillRect(r,i,a,o)),c.restore()}var jE=class extends Br{mutators=[`register`,`unRegister`];providers=[];constructor(e){super(e),this.onDispose(()=>{this.providers=[]})}get renderingLayers(){return[`Highlights`]}get highlights(){let e=this.getters.getActiveSheetId();return this.providers.flatMap(e=>e.highlights).filter(t=>t.range.sheetId===e).map(e=>{let{numberOfRows:t,numberOfCols:n}=sr(e.range.zone),r=t*n===1?this.getters.expandZone(e.range.sheetId,e.range.zone):e.range.unboundedZone;return{...e,range:this.model.getters.getRangeFromZone(e.range.sheetId,r)}})}register(e){this.providers.push(e)}unRegister(e){this.providers=this.providers.filter(t=>t!==e)}drawLayer(e,t){if(t===`Highlights`)for(let t of this.highlights)AE(e,t,e.viewports.getVisibleRect(e.sheetId,t.range.zone))}},ME=class{mutators=[`focus`,`unfocus`];focusedElement=null;focus(e){this.focusedElement=e}unfocus(e){this.focusedElement&&this.focusedElement===e&&(this.focusedElement=null)}},NE=class extends Br{initialRanges;inputHasSingleRange;colors;disabledRanges;mutators=[`resetWithRanges`,`focusById`,`unfocus`,`addEmptyRange`,`removeRange`,`changeRange`,`reset`,`confirm`,`updateColors`,`updateDisabledRanges`,`toggleEditMode`];ranges=[];focusedRangeIndex=null;mode=`text-edit`;inputSheetId;focusStore=this.get(ME);highlightStore=this.get(jE);constructor(e,t=[],n=!1,r=[],i=[]){if(super(e),this.initialRanges=t,this.inputHasSingleRange=n,this.colors=r,this.disabledRanges=i,n&&t.length>1)throw Error(`Input with a single range cannot be instantiated with several range references.`);this.inputSheetId=this.getters.getActiveSheetId(),this.resetWithRanges(t),this.highlightStore.register(this),this.onDispose(()=>{this.unfocus(),this.highlightStore.unRegister(this)})}handleEvent(e){if(this.focusedRangeIndex===null)return;let t=this.inputSheetId,n=this.getters.getActiveSheetId(),r=e.options.unbounded?this.getters.getUnboundedZone(n,e.anchor.zone):e.anchor.zone,i=this.getters.getRangeFromZone(n,r);if(e.mode===`newAnchor`&&!this.inputHasSingleRange&&this.ranges[this.focusedRangeIndex].xc.trim()!==``){let e=this.getters.getSelectionRangeString(i,t);this.insertNewRange(this.ranges.length,[e]),this.focusLast()}else{let e=i.parts,n=this.ranges[this.focusedRangeIndex].xc.trim();n&&(e=this.getters.getRangeFromSheetXC(t,n).parts);let r={...i,parts:e},a=this.getters.getSelectionRangeString(r,t);this.setRange(this.focusedRangeIndex,[a])}this.mode=`select-range`}handle(e){switch(e.type){case`ACTIVATE_SHEET`:if(e.sheetIdFrom!==e.sheetIdTo){let{col:t,row:n}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0}),r=this.getters.expandZone(e.sheetIdTo,O({col:t,row:n}));this.model.selection.resetAnchor(this,{cell:{col:t,row:n},zone:r})}break;case`START_CHANGE_HIGHLIGHT`:let t=this.getters.getActiveSheetId(),n=this.getters.expandZone(t,e.zone),r=this.ranges.findIndex(e=>{let{xc:r,sheetName:i}=_l(e.xc),a=i||this.getters.getSheetName(this.inputSheetId);if(this.getters.getSheetName(t)!==a)return!1;let o=this.getters.getRangeFromSheetXC(t,r);return nr(this.getters.expandZone(t,o.zone),n)});if(r!==-1){this.focus(r);let{left:e,top:t}=n;this.model.selection.resetAnchor(this,{cell:{col:e,row:t},zone:n})}break}}changeRange(e,t){if(this.inputHasSingleRange&&t.split(`,`).length>1)return;let n=this.getIndex(e);if(n!==null&&this.focusedRangeIndex!==n&&this.focus(n),n!==null){let e=t.replace(/^,+/,``).split(`,`).map(e=>e.trim());this.setRange(n,e),this.captureSelection()}}addEmptyRange(){this.inputHasSingleRange&&this.ranges.length===1||(this.insertNewRange(this.ranges.length,[``]),this.focusLast())}removeRange(e){if(this.ranges.length===1)return;let t=this.getIndex(e);t!==null&&this.removeRangeByIndex(t)}updateColors(e){this.colors=e;let t=new Ap(this.ranges.length,this.colors);this.ranges=this.ranges.map(e=>({...e,color:t.next()}))}updateDisabledRanges(e){this.disabledRanges=e}confirm(){for(let e of this.selectionInputs)e.xc===``&&this.removeRange(e.id);let e=this.getters.getActiveSheetId();this.inputSheetId!==e&&this.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:e,sheetIdTo:this.inputSheetId}),this.selectionInputValues.join()!==this.initialRanges.join()&&this.resetWithRanges(this.selectionInputValues),this.initialRanges=this.selectionInputValues,this.unfocus()}reset(){this.resetWithRanges(this.initialRanges),this.confirm()}get selectionInputValues(){return this.cleanInputs(this.ranges.map(e=>e.xc?e.xc:``))}get selectionInputs(){return this.ranges.map((e,t)=>Object.assign({},e,{color:this.hasMainFocus&&this.focusedRangeIndex!==null&&this.getters.isRangeValid(e.xc)?e.color:null,isFocused:this.hasMainFocus&&this.focusedRangeIndex===t,isValidRange:e.xc===``||this.getters.isRangeValid(e.xc),disabled:this.disabledRanges?.[t]}))}get isResettable(){return this.initialRanges.join()!==this.ranges.map(e=>e.xc).join()}get isConfirmable(){return this.selectionInputs.every(e=>e.isValidRange)}get hasFocus(){return this.selectionInputs.some(e=>e.isFocused)}get hasMainFocus(){let e=this.focusStore.focusedElement;return!!e&&e===this}get highlights(){return this.hasMainFocus?this.ranges.map(e=>this.inputToHighlights(e)).flat():[]}focusById(e){let t=this.getIndex(e);if(this.focusedRangeIndex!==t||this.mode===`select-range`){this.focus(t),this.mode=`text-edit`;return}return`noStateChange`}focus(e){this.focusStore.focus(this),this.focusedRangeIndex=e,this.captureSelection()}focusLast(){this.focus(this.ranges.length-1)}unfocus(){this.focusedRangeIndex=null,this.focusStore.unfocus(this),this.model.selection.release(this)}captureSelection(){if(this.focusedRangeIndex===null)return;let e=this.ranges[this.focusedRangeIndex],t=this.getters.getActiveSheetId(),n=this.getters.getRangeFromSheetXC(t,e?.xc||`A1`).zone;this.model.selection.capture(this,{cell:{col:n.left,row:n.top},zone:n},{handleEvent:this.handleEvent.bind(this),release:this.unfocus.bind(this)})}resetWithRanges(e){e.length&&e.every(e=>this.getters.isRangeValid(e))&&(this.initialRanges=e),this.ranges=[],this.insertNewRange(0,e),this.ranges.length===0&&(this.insertNewRange(this.ranges.length,[``]),this.focusLast())}setContent(e,t){this.ranges[e]={...this.ranges[e],xc:t}}insertNewRange(e,t){let n=Math.max(0,...this.ranges.map(e=>Number(e.id))),r=new Ap(this.ranges.length,this.colors);for(let t=0;t<e;t++)r.next();this.ranges.splice(e,0,...t.map((e,t)=>({xc:e,id:n+t+1,color:r.next()})))}setRange(e,t){let[,...n]=t;this.setContent(e,t[0]),this.insertNewRange(e+1,n),n.length&&this.focus(e+n.length)}removeRangeByIndex(e){this.ranges.splice(e,1),this.focusedRangeIndex!==null&&this.focusLast()}inputToHighlights({xc:e,color:t}){return this.cleanInputs([e]).filter(e=>this.getters.isRangeValid(e)).filter(e=>this.shouldBeHighlighted(this.inputSheetId,e)).map(e=>{let{sheetName:n}=_l(e),r=n&&this.getters.getSheetIdByName(n)||this.inputSheetId;return{range:this.getters.getRangeFromSheetXC(r,e),color:t,interactive:!0}})}cleanInputs(e){return e.map(e=>e.split(`,`)).flat().map(e=>e.trim()).filter(e=>e!==``)}shouldBeHighlighted(e,t){let{sheetName:n}=_l(t),r=this.getters.getSheetIdByName(n),i=this.getters.getActiveSheet().id;return this.getters.isRangeValid(t)&&(r===i||r===void 0&&i===e)}getIndex(e){let t=this.ranges.findIndex(t=>t.id===e);return t>=0?t:null}toggleEditMode(){this.mode=this.mode===`select-range`?`text-edit`:`select-range`}},PE=class extends A{static template=`o-spreadsheet-SelectionInput`;props=(0,t.props)({ranges:N.array(N.string()),hasSingleRange:N.boolean().optional(),required:N.boolean().optional(),autofocus:N.boolean().optional(),isInvalid:N.boolean().optional(),class:N.string().optional(),onSelectionChanged:N.function().optional(),onSelectionConfirmed:N.function().optional(),onSelectionReordered:N.function().optional(),onSelectionRemoved:N.function().optional(),onInputFocused:N.function().optional(),colors:N.ArrayOf().optional([]),disabledRanges:N.array(N.boolean()).optional([]),disabledRangeTitle:N.string().optional()});state=(0,t.proxy)({isMissing:!1});dragAndDrop=aE();focusedInputRef=t.signal.ref(HTMLInputElement);unfocusedInputRef=t.signal.ref(HTMLInputElement);selectionRef=(0,t.signal)(null);DOMFocusableElementStore;store;get ranges(){return this.store.selectionInputs}get canAddRange(){return!this.props.hasSingleRange}get isInvalid(){return this.props.isInvalid||this.state.isMissing}get isConfirmable(){return this.store.isConfirmable}get isResettable(){return this.store.isResettable}get hasDisabledRanges(){return this.store.disabledRanges.some(Boolean)}setup(){(0,t.onWillStart)(()=>{}),(0,t.onWillUpdateProps)(async()=>{}),this.DOMFocusableElementStore=j(c_),this.store=qi(NE,this.props.ranges,this.props.hasSingleRange||!1,this.props.colors,this.props.disabledRanges),this.props.autofocus&&(this.store.focusById(this.store.selectionInputs[0]?.id),this.props.onInputFocused?.()),(0,t.useEffect)(()=>{this.focusedInputRef()?.focus()}),Ii(()=>{let e=this.selectionRef();(this.store.isResettable||this.store.hasFocus)&&e?.offsetParent===null&&this.reset()}),(0,t.onWillUpdateProps)(e=>{e.ranges.join()!==this.store.selectionInputValues.join()&&this.triggerChange(),e.ranges.join()!==this.props.ranges.join()&&e.ranges.join()!==this.store.selectionInputValues.join()&&this.store.resetWithRanges(e.ranges),e.colors?.join()!==this.props.colors?.join()&&e.colors?.join()!==this.store.colors.join()&&this.store.updateColors(e.colors||[]),!T(e.disabledRanges,this.props.disabledRanges)&&!T(e.disabledRanges,this.store.disabledRanges)&&this.store.updateDisabledRanges(e.disabledRanges||[])})}startDragAndDrop(e,t){if(t.button!==0||t.target.tagName===`SELECT`)return;let n=this.getRangeElementsRects(),r=this.ranges.map(e=>e.id),i=r.map((e,t)=>({id:e.toString(),size:n[t].height,position:n[t].y}));this.dragAndDrop.start(`vertical`,{draggedItemId:e.toString(),initialMousePosition:t.clientY,items:i,scrollableContainerEl:this.selectionRef(),onDragEnd:(t,n)=>{let i=r.findIndex(t=>t===e);if(i===n)return;let a=C(0,r.length);a.splice(i,1),a.splice(n,0,i),this.props.onSelectionReordered?.(a),this.props.onSelectionConfirmed?.(),this.store.confirm()}})}getRangeElementsRects(){return Array.from(this.selectionRef().children).map(e=>e.getBoundingClientRect())}getColor(e){let t={};return e.color&&(t.color=e.color),this.store.mode===`select-range`&&(t[`caret-color`]=`transparent`),W(t)}triggerChange(){let e=this.store.selectionInputValues;this.props.onSelectionChanged?.(e)}onKeydown(e){e.key===`F2`?(e.preventDefault(),e.stopPropagation(),this.store.toggleEditMode()):e.key.startsWith(`Arrow`)?(e.stopPropagation(),this.store.mode===`select-range`&&(e.preventDefault(),EE(e,this.env.model.selection))):e.key===`Enter`?(e.target.blur(),this.isConfirmable&&this.confirm()):e.key===`Escape`&&(this.reset(),this.DOMFocusableElementStore.focus())}extractRanges(e){return this.props.hasSingleRange?e.split(`,`)[0]:e}focus(e){this.state.isMissing=!1,this.store.focusById(e),this.props.onInputFocused?.()}addEmptyInput(){this.store.addEmptyRange()}removeInput(e){let t=this.store.selectionInputs.findIndex(t=>t.id===e);this.ranges.find(t=>t.id===e)?.xc&&(this.props.onSelectionRemoved?.(t),this.props.onSelectionConfirmed?.()),this.store.removeRange(e)}onInputChanged(e,t){let n=t.target,r=this.extractRanges(n.value);this.store.changeRange(e,r),this.triggerChange()}reset(){this.store.reset(),this.triggerChange()}confirm(){this.store.confirm();let e=this.store.selectionInputs.some(e=>this.env.model.getters.isRangeValid(e.xc));this.props.required&&!e&&(this.state.isMissing=!0),this.props.onSelectionChanged?.(this.store.selectionInputValues),this.props.onSelectionConfirmed?.()}},FE=class extends A{static template=`o-spreadsheet.ChartDataSeries`;static components={SelectionInput:PE,Section:Z};props=(0,t.props)({ranges:N.ArrayOf(),dataSetStyles:N.DataSetStyle().optional(),hasSingleRange:N.boolean().optional(),onSelectionChanged:N.function(),onSelectionReordered:N.function().optional(),onSelectionRemoved:N.function().optional(),onSelectionConfirmed:N.function(),maxNumberOfUsedRanges:N.number().optional(),title:N.string().optional(),datasetOrientation:N.or([N.literal(`rows`),N.literal(`columns`)]).optional(),canChangeDatasetOrientation:N.boolean().optional(),onFlipAxis:N.function().optional()});get ranges(){return this.props.ranges.map(e=>e.dataRange)}setup(){(0,t.onWillUpdateProps)(async()=>{})}get disabledRanges(){return this.props.ranges.map((e,t)=>this.props.maxNumberOfUsedRanges?t>=this.props.maxNumberOfUsedRanges:!1)}get colors(){return this.props.ranges.map(e=>this.props.dataSetStyles?.[e.dataSetId]?.backgroundColor)}get title(){return this.props.title?this.props.title:this.props.hasSingleRange?P(`Data range`):P(`Data series`)}},IE=class extends A{static template=`o-spreadsheet.ChartLabelRange`;static components={SelectionInput:PE,Checkbox:CE,Section:Z};props=(0,t.props)({title:N.string().optional(P(`Categories / Labels`)),range:N.string(),class:N.string().optional(),isInvalid:N.boolean(),onSelectionChanged:N.function(),onSelectionConfirmed:N.function(),options:N.ArrayOf().optional([])});get sectionClass(){return`o-data-labels`+(this.props.class?` ${this.props.class}`:``)}},LE=class extends A{static template=`o-spreadsheet-ChartDataSourceComponent`;static components={ChartDataSeries:FE,ChartLabelRange:IE};props=(0,t.props)({chartId:N.UID(),definition:N.ChartDefinitionWithDataSource(),updateChart:N.function(),canUpdateChart:N.function(),dataSeriesTitle:N.string().optional(),labelRangeTitle:N.string().optional(),getLabelRangeOptions:N.function().optional()});get DataSourceComponent(){let e=this.props.definition.dataSource.type;return SE.get(e)}},RE=class extends A{static template=`o-spreadsheet-ValidationMessages`;props=(0,t.props)({messages:N.array(N.string()).optional(),msgType:N.or([N.literal(`warning`),N.literal(`error`),N.literal(`info`)]),slots:N.object().optional()});get divClasses(){return this.props.msgType===`warning`?`o-validation-warning`:this.props.msgType===`info`?`o-validation-info`:`o-validation-error`}},zE=class extends A{static template=`o-spreadsheet.ChartErrorSection`;static components={Section:Z,ValidationMessages:RE};props=(0,t.props)({messages:N.array(N.string())})},BE=class extends A{static template=`o-spreadsheet-GenericChartConfigPanel`;static components={ChartDataSourceComponent:LE,Section:Z,Checkbox:CE,ChartErrorSection:zE};props=(0,t.props)(wE);chartTerms=I_;state=(0,t.proxy)({errorMessages:[]});onErrorMessagesChanged(e){this.state.errorMessages=e}get errorMessages(){return this.state.errorMessages}getLabelRangeOptions(){return[this.getAggregateLabelRangeOption()]}getAggregateLabelRangeOption(){return{name:`aggregated`,label:this.chartTerms.AggregatedChart,value:(`aggregated`in this.props.definition?this.props.definition.aggregated:!1)??!1,onChange:e=>{this.props.updateChart(this.props.chartId,{aggregated:e})}}}},VE=class extends BE{static template=`o-spreadsheet-BarConfigPanel`;get stackedLabel(){return this.props.definition.horizontal?this.chartTerms.StackedBarChart:this.chartTerms.StackedColumnChart}onUpdateStacked(e){this.props.updateChart(this.props.chartId,{stacked:e})}getLabelRangeOptions(){return[this.getAggregateLabelRangeOption()]}},HE=class extends A{static template=`o-spreadsheet-Collapse`;props=(0,t.props)({isCollapsed:N.boolean()});contentRef=(0,t.signal)(null);setup(){(0,t.onMounted)(()=>{this.props.isCollapsed&&this.contentRef()?.classList.add(`d-none`)}),(0,t.onWillUpdateProps)(e=>{e.isCollapsed!==this.props.isCollapsed&&this.startTransition(e.isCollapsed)})}startTransition(e){let t=this.contentRef();if(!t)return;t.classList.remove(`d-none`),t.classList.add(`overflow-hidden`);let n=e?t.scrollHeight:0,r=e?0:t.scrollHeight,i=t.animate([{maxHeight:n+`px`},{maxHeight:r+`px`}],{duration:350,easing:`ease`});i.onfinish=()=>{t.classList.remove(`overflow-hidden`),this.props.isCollapsed&&t.classList.add(`d-none`)}}},UE=class extends A{static template=`o-spreadsheet-SidePanelCollapsible`;static components={Collapse:HE};props=(0,t.props)({title:N.string().optional(),isInitiallyCollapsed:N.boolean().optional(),class:N.string().optional()});state=(0,t.proxy)({isCollapsed:!!this.props.isInitiallyCollapsed});toggle(){this.state.isCollapsed=!this.state.isCollapsed}},WE=class extends A{static template=`o-spreadsheet.ChartAnnotation`;static components={SidePanelCollapsible:UE,Section:Z,TextInput:pE};props=(0,t.props)(wE);editorRef=(0,t.signal)(null);state=(0,t.proxy)({annotationTextInput:this.props.definition.annotationText||``,isOverflowing:!1});setup(){Ii((e,t)=>{e&&!e.matches(`:focus`)&&e.innerText!==(t||``)&&(e.innerText=t||``,this.state.annotationTextInput=t||``,this.updateOverflowState(e))},()=>[this.editorRef(),this.props.definition.annotationText]),Ii(e=>{if(!e)return;let t=new ResizeObserver(()=>this.updateOverflowState(e));return t.observe(e),this.updateOverflowState(e),()=>t.disconnect()},()=>[this.editorRef()])}updateOverflowState(e){this.state.isOverflowing=e.scrollHeight>e.clientHeight}get annotationPlaceholder(){return P(`Add a description text`)}checkLength(e){e.target.innerText.length>=2e3&&!e.inputType.startsWith(`delete`)&&e.preventDefault()}onInput(e){let t=e.target,n=t.innerText.trim();n===``?(t.replaceChildren(),this.state.annotationTextInput=``):n.length>2e3?(t.innerText=n.substring(0,2e3),this.state.annotationTextInput=t.innerText.trim()):this.state.annotationTextInput=n,this.updateOverflowState(t)}onBlur(){this.props.updateChart(this.props.chartId,{annotationText:this.state.annotationTextInput})}updateAnnotationLink(e){e&&=zd(e),this.props.updateChart(this.props.chartId,{annotationLink:e})}},GE=class extends fE{static template=`o-spreadsheet-NumberInput`;static components={};props=(0,t.props)({...dE,min:N.number().optional(),max:N.number().optional()});debouncedOnChange=Vt(this.props.onChange.bind(this),100,!0);save(){let e=(this.genericInputRef()?.value||``).trim();e!==this.props.value.toString()&&this.debouncedOnChange(e)}get inputClass(){return[this.props.class,`o-input`].join(` `)}},KE=class extends GE{static template=`o-spreadsheet-DateInput`},qE=class extends A{static template=`o-spreadsheet.BadgeSelection`;props=(0,t.props)({choices:N.ArrayOf(),onChange:N.function(),selectedValue:N.string()})},JE=class extends A{static template=`o-spreadsheet.ChartTitle`;static components={Section:Z,TextStyler:yE,TextInput:pE};props=(0,t.props)({title:N.string().optional(``),placeholder:N.string().optional(``),updateTitle:N.function(),name:N.string().optional(),style:N.TitleDesign(),defaultStyle:N.object().optional(),updateStyle:N.function()});updateTitle(e){this.props.updateTitle(e)}},YE=class extends A{static template=`o-spreadsheet-AxisDesignEditor`;static components={Section:Z,ChartTitle:JE,BadgeSelection:qE,Checkbox:CE,NumberInput:GE,DateInput:KE};props=(0,t.props)({chartId:N.UID(),definition:N.ChartWithAxisDefinition(),updateChart:N.function(),axesList:N.ArrayOf()});state=(0,t.proxy)({currentAxis:`x`});defaultFontSize=12;get axisTitleStyle(){return this.props.definition.axesDesign?.[this.state.currentAxis]?.title??{}}get badgeAxes(){return this.props.axesList.map(e=>({value:e.id,label:e.name}))}getAxisTitle(){return(this.props.definition.axesDesign??{})[this.state.currentAxis]?.title?.text||``}updateAxisTitle(e){let t=x(this.props.definition.axesDesign)??{};t[this.state.currentAxis]={...t[this.state.currentAxis],title:{...t?.[this.state.currentAxis]?.title,text:e}},this.props.updateChart(this.props.chartId,{axesDesign:t})}updateAxisTitleStyle(e){let t=x(this.props.definition.axesDesign)??{};t[this.state.currentAxis]={...t[this.state.currentAxis],title:e},this.props.updateChart(this.props.chartId,{axesDesign:t})}get axisMin(){let e=this.currentAxisDesign?.min;return(this.isTimeAxis?this.formatAxisBoundary(e):e)??``}get axisMax(){let e=this.currentAxisDesign?.max;return(this.isTimeAxis?this.formatAxisBoundary(e):e)??``}get isMajorGridEnabled(){let e=this.currentAxisDesign?.gridLines;return e===void 0?this.getDefaultMajorGridValue(this.state.currentAxis):e===`major`||e===`both`}get isMinorGridEnabled(){return this.currentAxisDesign?.gridLines===`minor`||this.currentAxisDesign?.gridLines===`both`}get isValueAxis(){return`horizontal`in this.props.definition&&this.props.definition.horizontal?this.state.currentAxis===`x`:this.state.currentAxis!==`x`}get majorGridLabel(){return this.state.currentAxis===`x`?P(`Major vertical gridlines`):P(`Major horizontal gridlines`)}get minorGridLabel(){return this.state.currentAxis===`x`?P(`Minor vertical gridlines`):P(`Minor horizontal gridlines`)}updateAxisMin(e){let t=e===``?void 0:Number(e);if(t===void 0||!isNaN(t)){let e=x(this.props.definition.axesDesign)??{};e[this.state.currentAxis]={...e[this.state.currentAxis],min:t},this.props.updateChart(this.props.chartId,{axesDesign:e})}}updateTimeAxisMin(e){let t=this.parseTimeAxisBoundaryValue(e);if(t===null)return;let n=x(this.props.definition.axesDesign)??{};n[this.state.currentAxis]={...n[this.state.currentAxis],min:t},this.props.updateChart(this.props.chartId,{axesDesign:n})}updateAxisMax(e){let t=e===``?void 0:Number(e);if(t===void 0||!isNaN(t)){let e=x(this.props.definition.axesDesign)??{};e[this.state.currentAxis]={...e[this.state.currentAxis],max:t},this.props.updateChart(this.props.chartId,{axesDesign:e})}}updateTimeAxisMax(e){let t=this.parseTimeAxisBoundaryValue(e);if(t===null)return;let n=x(this.props.definition.axesDesign)??{};n[this.state.currentAxis]={...n[this.state.currentAxis],max:t},this.props.updateChart(this.props.chartId,{axesDesign:n})}toggleMajorGrid(e){let t=x(this.props.definition.axesDesign)??{},n=`none`;n=this.isMinorGridEnabled?e?`both`:`minor`:e?`major`:`none`,t[this.state.currentAxis]={...t[this.state.currentAxis],gridLines:n},this.props.updateChart(this.props.chartId,{axesDesign:t})}toggleMinorGrid(e){let t=x(this.props.definition.axesDesign)??{},n=`none`;n=this.isMajorGridEnabled?e?`both`:`major`:e?`minor`:`none`,t[this.state.currentAxis]={...t[this.state.currentAxis],gridLines:n},this.props.updateChart(this.props.chartId,{axesDesign:t})}get currentAxisDesign(){return this.props.definition.axesDesign?.[this.state.currentAxis]}getDefaultMajorGridValue(e){let{useLeftAxis:t,useRightAxis:n}=fm(this.props.definition);if(e===`x`){if(`horizontal`in this.props.definition&&this.props.definition.horizontal||this.props.definition.type===`scatter`)return!0}else if(e===`y`)return!0;else if(e===`y1`)return!t&&n;return!1}get isCategoricalAxis(){if(this.isValueAxis)return!1;let e=this.getXAxisType();return e===void 0||e===`category`}get isTimeAxis(){return this.state.currentAxis===`x`&&this.getXAxisType()===`time`}get canChangeMinorGridVisibility(){if(this.isValueAxis)return!0;if(this.isCategoricalAxis)return!1;let e=this.props.definition.type;return e===`line`||e===`scatter`}parseTimeAxisBoundaryValue(e){let t=L(e,this.env.model.getters.getLocale());return Number.isNaN(t)?null:t}formatAxisBoundary(e){if(e!==void 0)return H(e,{format:`yyyy-mm-dd`,locale:this.env.model.getters.getLocale()})}getXAxisType(){return this.env.model.getters.getChartRuntime(this.props.chartId)?.chartJsConfig.options?.scales?.x?.type}},XE=class extends A{static template=`o-spreadsheet.RadioSelection`;props=(0,t.props)({choices:N.ArrayOf(),onChange:N.function(),selectedValue:N.string(),name:N.string(),direction:N.or([N.literal(`horizontal`),N.literal(`vertical`)]).optional(`horizontal`)})},ZE=class extends A{static template=`o-spreadsheet.RoundColorPicker`;static components={Section:Z,ColorPicker:hE};props=(0,t.props)({currentColor:N.string().optional(),title:N.string().optional(),onColorPicked:N.function(),disableNoColor:N.boolean().optional()});colorPickerButtonRef=(0,t.signal)(null);state;setup(){this.state=(0,t.proxy)({pickerOpened:!1}),Fi(window,`click`,this.closePicker)}closePicker(){this.state.pickerOpened=!1}togglePicker(){this.state.pickerOpened=!this.state.pickerOpened}onColorPicked(e){this.props.onColorPicked(e),this.state.pickerOpened=!1}get colorPickerAnchorRect(){return y(this.colorPickerButtonRef())}get buttonStyle(){return W({background:this.props.currentColor})}},QE=class extends A{static template=`o-spreadsheet-GeneralDesignEditor`;static components={RoundColorPicker:ZE,ChartTitle:JE,Section:Z,SidePanelCollapsible:UE,RadioSelection:XE};props=(0,t.props)({chartId:N.UID(),definition:N.ChartDefinition(),canUpdateChart:N.function(),updateChart:N.function(),defaultChartTitleFontSize:N.number().optional(16)});state;setup(){this.state=(0,t.proxy)({activeTool:``})}get title(){return this.props.definition.title}toggleDropdownTool(e,t){let n=this.state.activeTool===e;this.state.activeTool=n?``:e}updateBackgroundColor(e){this.props.updateChart(this.props.chartId,{background:e})}updateTitle(e){let t={...this.title,text:e};this.props.updateChart(this.props.chartId,{title:t})}updateChartTitleStyle(e){let t={...this.title,...e};this.props.updateChart(this.props.chartId,{title:t}),this.state.activeTool=``}},$E=class extends A{static template=`o-spreadsheet-ChartHumanizeNumbers`;static components={Checkbox:CE};props=(0,t.props)(wE);get title(){let e=this.env.model.getters.getLocale();return P(`E.g. 1234567 -> %(value)s`,{value:H(1234567,{format:Ec({value:1234567},void 0,e),locale:e})})}},eD=class extends A{static template=`o-spreadsheet-ChartLegend`;static components={Section:Z,Select:w_};props=(0,t.props)({chartId:N.string(),definition:N.ChartDefinitionWithDataSource(),canUpdateChart:N.function(),updateChart:N.function(),isDisabled:N.boolean().optional(!1)});updateLegendPosition(e){this.props.updateChart(this.props.chartId,{legendPosition:e})}get legendValues(){return[{value:`none`,label:P(`None`)},{value:`top`,label:P(`Top`)},{value:`bottom`,label:P(`Bottom`)},{value:`left`,label:P(`Left`)},{value:`right`,label:P(`Right`)}]}},tD=class extends A{static template=`o-spreadsheet-SeriesDesignEditor`;static components={SidePanelCollapsible:UE,Section:Z,RoundColorPicker:ZE,Select:w_};props=(0,t.props)({chartId:N.UID(),definition:N.ChartDefinitionWithDataSource(),updateChart:N.function(),canUpdateChart:N.function()});state=(0,t.proxy)({dataSetId:this.getDataSeries()[0]?.dataSetId||``});getRuntime(){let e=this.env.model.getters.getChartRuntime(this.props.chartId);if(!e||!(`customizableSeries`in e))throw Error(`SeriesDesignEditor: chart runtime is not compatible with series customization.`);return e}getDataSeries(){return this.getRuntime().customizableSeries}updateEditedSeries(e){this.state.dataSetId=e}updateDataSeriesColor(e){let t={...this.props.definition.dataSetStyles};t[this.state.dataSetId]={...t[this.state.dataSetId],backgroundColor:e},this.props.updateChart(this.props.chartId,{dataSetStyles:t})}getDataSeriesColor(){let e=this.props.definition.dataSetStyles?.[this.state.dataSetId]?.backgroundColor,t=this.getDataSeries(),n=t.findIndex(e=>e.dataSetId===this.state.dataSetId);return e?Yf(e):Dp(n,Op(t.length))}updateDataSeriesLabel(e){let t=e.target.value,n={...this.props.definition.dataSetStyles};n[this.state.dataSetId]={...n[this.state.dataSetId],label:t},this.props.updateChart(this.props.chartId,{dataSetStyles:n})}getDataSeriesLabel(){return this.props.definition.dataSetStyles?.[this.state.dataSetId]?.label||this.getDataSeries().find(e=>e.dataSetId===this.state.dataSetId)?.label||``}get selectOptions(){return this.getDataSeries().map(({label:e,dataSetId:t})=>({value:t,label:e}))}},nD=class extends A{static template=`o-spreadsheet-SeriesWithAxisDesignEditor`;static components={SeriesDesignEditor:tD,Checkbox:CE,RadioSelection:XE,Section:Z,RoundColorPicker:ZE,NumberInput:GE,Select:w_};props=(0,t.props)({chartId:N.UID(),definition:N.ChartDefinitionWithDataSource(),updateChart:N.function(),canUpdateChart:N.function()});axisChoices=hm;updateDataSeriesAxis(e,t){let n={...this.props.definition.dataSetStyles};n[e]={...n[e],yAxisId:t===`left`?`y`:`y1`},this.props.updateChart(this.props.chartId,{dataSetStyles:n})}getDataSerieAxis(e){let t=this.props.definition.dataSetStyles;return t?.[e]&&t[e]?.yAxisId===`y1`?`right`:`left`}get canHaveTwoVerticalAxis(){return!(`horizontal`in this.props.definition&&this.props.definition.horizontal)}toggleDataTrend(e,t){let n={...this.props.definition.dataSetStyles};n[e]={...n[e],trend:{type:`polynomial`,order:1,...n[e]?.trend,display:t}},this.props.updateChart(this.props.chartId,{dataSetStyles:n})}getTrendLineConfiguration(e){return this.props.definition.dataSetStyles?.[e]?.trend}getTrendType(e){return e?e.type===`polynomial`&&e.order===1?`linear`:e.type:``}onChangeTrendType(e,t){let n;switch(t){case`linear`:case`polynomial`:n={type:`polynomial`,order:t===`linear`?1:this.getMaxPolynomialDegree(e)};break;case`exponential`:case`logarithmic`:case`trailingMovingAverage`:n={type:t};break;default:return}this.updateTrendLineValue(e,n)}get trendOptions(){return[{value:`linear`,label:P(`Linear`)},{value:`polynomial`,label:P(`Polynomial`)},{value:`exponential`,label:P(`Exponential`)},{value:`logarithmic`,label:P(`Logarithmic`)},{value:`trailingMovingAverage`,label:P(`Trailing moving average`)}]}getPolynomialDegrees(e){return C(1,this.getMaxPolynomialDegree(e)+1).map(e=>({value:e.toString(),label:e.toString()}))}onChangePolynomialDegree(e,t){this.updateTrendLineValue(e,{order:parseInt(t)})}getMaxPolynomialDegree(e){let t=this.env.model.getters.getChartRuntime(this.props.chartId),n=t.customizableSeries.findIndex(t=>t.dataSetId===e);return Math.min(10,t.chartJsConfig.data.datasets[n].data.length-1)}get defaultWindowSize(){return 2}onChangeMovingAverageWindow(e,t){let n=parseInt(t)||2;n<=1&&(n=2),this.updateTrendLineValue(e,{window:n})}getDataSeriesColor(e){let t=this.props.definition.dataSetStyles;if(!t?.[e])return``;let n=t[e]?.backgroundColor,r=this.env.model.getters.getChartRuntime(this.props.chartId),i=r.customizableSeries.findIndex(t=>t.dataSetId===e);return n?Yf(n):Dp(i,Op(r.customizableSeries.length))}getTrendLineColor(e){return this.getTrendLineConfiguration(e)?.color??dp(this.getDataSeriesColor(e),.5)}updateTrendLineColor(e,t){this.updateTrendLineValue(e,{color:t})}updateTrendLineValue(e,t){let n={...this.props.definition.dataSetStyles};n[e]={...n[e],trend:{...n[e]?.trend,...t}},this.props.updateChart(this.props.chartId,{dataSetStyles:n})}},rD=class extends A{static template=`o-spreadsheet-ChartShowValues`;static components={Checkbox:CE};props=(0,t.props)({chartId:N.UID(),definition:N.ChartDefinitionWithDataSource(),canUpdateChart:N.function(),updateChart:N.function(),defaultValue:N.boolean().optional()})},iD=class extends A{static template=`o-spreadsheet-ChartWithAxisDesignPanel`;static components={GeneralDesignEditor:QE,ChartAnnotation:WE,SidePanelCollapsible:UE,Section:Z,AxisDesignEditor:YE,SeriesWithAxisDesignEditor:nD,ChartLegend:eD,ChartShowValues:rD,ChartHumanizeNumbers:$E};props=(0,t.props)(wE);get axesList(){let{useLeftAxis:e,useRightAxis:t}=fm(this.props.definition),n=[{id:`x`,name:P(`Horizontal axis`)}];return e&&n.push({id:`y`,name:P(t?`Left axis`:`Vertical axis`)}),t&&n.push({id:`y1`,name:P(e?`Right axis`:`Vertical axis`)}),n}},aD=class extends iD{static template=`o-spreadsheet-GenericZoomableChartDesignPanel`;static components={...iD.components,Checkbox:CE};onToggleZoom(e){this.props.updateChart(this.props.chartId,{zoomable:e})}},oD=class extends aD{static template=`o-spreadsheet-BarChartDesignPanel`;get isZoomable(){return!this.props.definition.horizontal}},sD=class extends A{static template=`o-spreadsheet-BubbleChartConfigPanel`;static components={ChartDataSeries:FE,ChartLabelRange:IE,ChartErrorSection:zE};props=(0,t.props)(wE);state=(0,t.proxy)({datasetDispatchResult:void 0,labelsDispatchResult:void 0,xRangeDispatchResult:void 0,sizeRangeDispatchResult:void 0});yRanges=[];labelRange;datasetOrientation;xRange;sizeRange;setup(){let e=this.props.definition;this.yRanges=e.yRanges||[],this.labelRange=e.labelRange,this.xRange=e.xRange,this.sizeRange=e.sizeRange,this.datasetOrientation=this.computeDatasetOrientation()}get errorMessages(){return[...this.state.datasetDispatchResult?.reasons||[],...this.state.xRangeDispatchResult?.reasons||[],...this.state.labelsDispatchResult?.reasons||[],...this.state.sizeRangeDispatchResult?.reasons||[]].filter(e=>e!==`NoChanges`).map(e=>I_.Errors[e]||I_.Errors.Unexpected)}get isLabelInvalid(){return!!this.state.labelsDispatchResult?.isCancelledBecause(`InvalidLabelRange`)}get isXDataInvalid(){return!!this.state.xRangeDispatchResult?.isCancelledBecause(`InvalidXRange`)}get isYDataInvalid(){return!!this.state.datasetDispatchResult?.isCancelledBecause(`InvalidYRange`)}get isBubbleSizeRangeInvalid(){return!!this.state.sizeRangeDispatchResult?.isCancelledBecause(`InvalidBubbleSizeRange`)}get dataSetsHaveTitleLabel(){return this.datasetOrientation===`rows`?P(`Use col %(column_name)s as headers`,{column_name:Cn(this.calculateHeaderPosition()||0)}):P(`Use row %(row_position)s as headers`,{row_position:this.calculateHeaderPosition()||``})}getDataSeriesRanges(){return this.yRanges.map((e,t)=>({dataRange:e,dataSetId:`${t}`}))}onDataSeriesRangesChanged(e){this.yRanges=e,this.state.datasetDispatchResult=this.props.canUpdateChart(this.props.chartId,{yRanges:this.yRanges})}onDataSeriesConfirmed(){this.datasetOrientation=this.computeDatasetOrientation(),this.state.datasetDispatchResult=this.props.updateChart(this.props.chartId,{yRanges:this.yRanges})}onDataSeriesReordered(e){this.yRanges=e.map(e=>this.yRanges[e]),this.state.datasetDispatchResult=this.props.updateChart(this.props.chartId,{yRanges:this.yRanges})}onDataSeriesRemoved(e){this.yRanges=this.yRanges.filter((t,n)=>n!==e),this.state.datasetDispatchResult=this.props.updateChart(this.props.chartId,{yRanges:this.yRanges})}onLabelRangeChanged(e){this.labelRange=e[0],this.state.labelsDispatchResult=this.props.canUpdateChart(this.props.chartId,{labelRange:this.labelRange})}onLabelRangeConfirmed(){this.state.labelsDispatchResult=this.props.updateChart(this.props.chartId,{labelRange:this.labelRange})}onUpdateDataSetsHaveTitle(e){this.props.updateChart(this.props.chartId,{dataSetsHaveTitle:e})}onXDataRangeChanged(e){this.xRange=e[0],this.state.xRangeDispatchResult=this.props.canUpdateChart(this.props.chartId,{xRange:this.xRange})}onXDataRangeConfirmed(){this.state.xRangeDispatchResult=this.props.updateChart(this.props.chartId,{xRange:this.xRange})}onBubbleSizeRangeChanged(e){this.sizeRange=e[0],this.state.sizeRangeDispatchResult=this.props.canUpdateChart(this.props.chartId,{sizeRange:this.sizeRange})}onBubbleSizeRangeConfirmed(){this.state.sizeRangeDispatchResult=this.props.updateChart(this.props.chartId,{sizeRange:this.sizeRange})}getLabelRangeOptions(){let e=this.props.definition;return[{name:`dataSetsHaveTitle`,label:this.dataSetsHaveTitleLabel,value:e.dataSetsHaveTitle,onChange:this.onUpdateDataSetsHaveTitle.bind(this)}]}calculateHeaderPosition(){if(this.isYDataInvalid)return;let e=this.yRanges[0]??this.xRange??``,t=this.env.model.getters,n=wu(t,t.getActiveSheetId(),e||``)?.zone;if(n)return this.datasetOrientation===`rows`?n.left:n.top+1}computeDatasetOrientation(){let e=!1,t=!1;for(let n of this.yRanges){let r=this.env.model.getters,i=wu(r,r.getActiveSheetId(),n)?.zone;if(!i)return;i.top===i.bottom&&(e=!0),i.left===i.right&&(t=!0)}if(e&&!t)return`rows`;if(!e&&t)return`columns`}},cD=class extends A{static template=`o-spreadsheet-BubbleChartDesignPanel`;static components={GeneralDesignEditor:QE,SidePanelCollapsible:UE,Section:Z,AxisDesignEditor:YE,ChartLegend:eD,ChartShowValues:rD,ChartHumanizeNumbers:$E,RadioSelection:XE,RoundColorPicker:ZE,Checkbox:CE,ChartAnnotation:WE};props=(0,t.props)(wE);get axesList(){return[{id:`x`,name:P(`Horizontal axis`)},{id:this.verticalAxisPosition===`right`?`y1`:`y`,name:P(`Vertical axis`)}]}colorModeChoices=[{value:`single`,label:P(`Single color`)},{value:`multiple`,label:P(`Multiple colors`)}];axisChoices=hm;get colorMode(){return this.props.definition.bubbleColor.color===`multiple`?`multiple`:`single`}onColorModeChange(e){this.updateBubbleColor(e===`multiple`?`multiple`:yp)}get verticalAxisPosition(){return this.props.definition.verticalAxisPosition??`left`}updateVerticalAxisPosition(e){this.props.updateChart(this.props.chartId,{verticalAxisPosition:e})}updateBubbleColor(e){let t=this.props.definition.bubbleColor;this.props.updateChart(this.props.chartId,{bubbleColor:{...t,color:e}})}get currentBubbleColor(){return this.colorMode===`multiple`?yp:this.props.definition.bubbleColor.color}get areBubblesTransparent(){return this.props.definition.bubbleColor.transparent||!1}updateBubbleTransparency(e){let t=this.props.definition.bubbleColor;this.props.updateChart(this.props.chartId,{bubbleColor:{...t,transparent:e}})}};function lD(e){return e=Yf(e).replace(`#`,``),e.length===8?e.slice(6)+e.slice(0,6):e}let uD=Symbol(`NULL`);function dD(e,t,n){let r=e.granularity||`month`;if(!(r in fD))throw Error(`Unknown date granularity: ${r}`);let i=typeof t==`number`||typeof t==`string`?t:uD;if(!fD[r].set.has(t)){fD[r].set.add(t);let a=null;if(typeof t==`number`||typeof t==`string`){let e=qo(t,n);switch(r){case`year`:a=e.getFullYear();break;case`quarter_number`:a=Math.floor(e.getMonth()/3)+1;break;case`month_number`:a=e.getMonth()+1;break;case`month`:a=Math.floor(L(t,n));break;case`iso_week_number`:a=e.getIsoWeek();break;case`day_of_month`:a=e.getDate();break;case`day`:a=Math.floor(L(t,n));break;case`day_of_week`:a=(e.getDay()+7-n.weekStart)%7+1;break;case`hour_number`:a=e.getHours();break;case`minute_number`:a=e.getMinutes();break;case`second_number`:a=e.getSeconds();break}}fD[r].values[i]=uC(e,a)}return fD[r].values[i]}let fD={year:{set:new Set,values:{}},quarter_number:{set:new Set,values:{}},month_number:{set:new Set,values:{}},month:{set:new Set,values:{}},iso_week_number:{set:new Set,values:{}},day_of_month:{set:new Set,values:{}},day:{set:new Set,values:{}},day_of_week:{set:new Set,values:{}},hour_number:{set:new Set,values:{}},minute_number:{set:new Set,values:{}},second_number:{set:new Set,values:{}}};function pD(){for(let e in fD)fD[e].set.clear(),fD[e].values={}}let mD=Object.freeze({value:null}),hD=Object.freeze({value:0});function gD(e,{labelValues:t,dataSetsValues:n},r){let i=r.getLocale(),a=t.map(({value:e,format:t})=>H(e,{format:t,locale:i}));({labels:a,dataSetsValues:n}=UD(a,n)),e.aggregated&&({labels:a,dataSetsValues:n}=qD(a,n));let o=YD(e.dataSetStyles,n,`left`),s=YD(e.dataSetStyles,n,`right`),c=e.horizontal?{x:o||s}:{y:o,y1:s},l=[];for(let t in n){let{data:r,dataSetId:i}=n[t],a=e.dataSetStyles?.[i]?.trend;if(!a?.display||e.horizontal){l.push(void 0);continue}let o=kD(a,r);l.push(o)}return{dataSetsValues:n,trendDataSetsValues:l,axisFormats:c,labels:a,locale:r.getLocale(),topPadding:ZD(e,r),background:ym(e,r)}}function _D(e,t){switch(t){case`day_of_week`:return Zs[e-1].toString();case`hour_number`:{let t=String(e%12).padStart(2,`0`);return P(e<12?`%(hour)s AM`:`%(hour)s PM`,{hour:t})}case`month_number`:return Xs[e-1].toString();case`iso_week_number`:return P(`W%(weekNumber)s`,{weekNumber:String(e).padStart(2,`0`)});case`quarter_number`:return P(`Q%(value)s`,{value:e});default:return e.toString()}}function vD(e,t,n,r,i){let a={},o=[],s=[],c=[];for(let l=0;l<e?.length;l++){let u=L(dD({granularity:n,type:`date`,displayName:`date`},e[l].value,V),i);u in a||(o.push(u),a[u]={});let d=L(dD({granularity:r,type:`date`,displayName:`date`},e[l].value,V),i);c.includes(d)||(s.push(d),c.push(d)),d in a[u]||(a[u][d]={value:0});let f=t[l];tf(f)&&(a[u][d].value+=f.value)}return o.sort((e,t)=>e-t),s.sort((e,t)=>t-e),{dataSetsValues:s.map(e=>({data:o.map(t=>a?.[t]?.[e]),label:_D(e,r),hidden:!1,dataSetId:`0`})),labels:o.map(e=>({value:_D(e,n)}))}}function yD(e,{labelValues:t,dataSetsValues:n},r){let i=t,a=r.getLocale();({labels:i,dataSetsValues:n}=WD(i,n));let o={y:YD(e.dataSetStyles,n,`left`)};return{labels:i,dataSetsValues:n}=vD(i,n[0]?.data??[],e.horizontalGroupBy??`day_of_week`,e.verticalGroupBy??`hour_number`,a),{dataSetsValues:n,axisFormats:o,labels:i.map(({value:e})=>String(e??``)),locale:r.getLocale(),topPadding:ZD(e,r),background:ym(e,r)}}function bD(e,{labelValues:t,dataSetsValues:n},r){let i=gD(e,{labelValues:t,dataSetsValues:n.slice(0,2)},r),a=i.dataSetsValues.filter(e=>!e.hidden),o=[];if(a[0]){let e=a[0].data.map(e=>tf(e)&&e.value>0?e:hD);o.push({...a[0],data:e})}if(a[1]){let e=a[1].data.map(e=>tf(e)&&e.value>0?{value:-e.value}:hD);o.push({...a[1],data:e})}return{...i,dataSetsValues:o}}function xD(e,{labelValues:t,dataSetsValues:n},r){let i=ND(e,{labelValues:t,dataSetsValues:n}),a=i===`linear`?t.map(({value:e})=>String(e??``)):t.map(({value:e,format:t})=>H(e,{format:t,locale:r.getLocale()}));({labels:a,dataSetsValues:n}=UD(a,n)),i===`time`&&({labels:a,dataSetsValues:n}=HD(a,n)),e.aggregated&&({labels:a,dataSetsValues:n}=qD(a,n)),e.cumulative&&(n=XD(n,`asc`));let o={y:YD(e.dataSetStyles,n,`left`),y1:YD(e.dataSetStyles,n,`right`),x:JD(t)},s=[];for(let t in n){let{data:o,dataSetId:c}=n[t],l=e.dataSetStyles?.[c]?.trend;if(!l?.display){s.push(void 0);continue}s.push(AD(l,o,a,i,r.getLocale()))}return{dataSetsValues:n,axisFormats:o,labels:a,locale:r.getLocale(),trendDataSetsValues:s,axisType:i,topPadding:ZD(e,r),background:ym(e,r)}}function SD(e,{labelValues:t,dataSetsValues:n},r){let i=t.map(({value:e,format:t})=>H(e,{format:t,locale:r.getLocale()}));({labels:i,dataSetsValues:n}=UD(i,n)),e.aggregated&&({labels:i,dataSetsValues:n}=qD(i,n)),{dataSetsValues:n,labels:i}=VD(i,n);let a=YD(e.dataSetStyles,n,`left`);return{dataSetsValues:n,axisFormats:{y:a},labels:i,locale:r.getLocale(),topPadding:ZD(e,r),background:ym(e,r)}}function CD(e,{labelValues:t,dataSetsValues:n},r){let i=t.map(({value:e,format:t})=>H(e,{format:t,locale:r.getLocale()}));({labels:i,dataSetsValues:n}=UD(i,n)),e.aggregated&&({labels:i,dataSetsValues:n}=qD(i,n));let a={r:YD(e.dataSetStyles,n,`left`)||YD(e.dataSetStyles,n,`right`)};return{dataSetsValues:n,axisFormats:a,labels:i,locale:r.getLocale(),background:ym(e,r)}}function wD(e,{labelValues:t,dataSetsValues:n},r){n=n.slice(0,1);let i=t.map(({value:e,format:t})=>H(e,{format:t,locale:r.getLocale()}));({labels:i,dataSetsValues:n}=qD(i,n));let a=YD(e.dataSetStyles,n,`left`)||YD(e.dataSetStyles,n,`right`);return{dataSetsValues:n,axisFormats:{y:a},labels:i,locale:r.getLocale(),availableRegions:r.getGeoChartAvailableRegions(),geoFeatureNameToId:r.geoFeatureNameToId,getGeoJsonFeatures:r.getGeoJsonFeatures,background:ym(e,r)}}function TD(e,{labelValues:t,dataSetsValues:n},r){let i=t.map(({value:e,format:t})=>H(e,{format:t,locale:r.getLocale()}));({labels:i,dataSetsValues:n}=UD(i,n)),e.aggregated&&({labels:i,dataSetsValues:n}=qD(i,n)),e.cumulative&&(n=XD(n,`desc`));let a=YD(e.dataSetStyles,n,`left`)||YD(e.dataSetStyles,n,`right`);return{dataSetsValues:n,axisFormats:{x:a},labels:i,locale:r.getLocale(),background:ym(e,r)}}function ED(e,{labelValues:t,dataSetsValues:n},r){let i=t;return{labels:i,dataSetsValues:n}=KD(i,n),{labels:i,dataSetsValues:n}=GD(i,n),{dataSetsValues:n,axisFormats:{y:JD(i)},labels:i.map(({value:e})=>String(e??``)),locale:r.getLocale(),background:ym(e,r)}}function DD(e,t){let n=OD(e,t),r=xD(e,n,t),i=e.labelRange?t.getVisibleRangeValues(e.labelRange):[],a=e.sizeRange?t.getVisibleRangeValues(e.sizeRange):[];n.shouldRemoveFirstLabel&&(i=i.slice(1),a=a.slice(1));let o=[],s=[],c=JD(a);for(let e=0;e<r.dataSetsValues[0].data.length;e++){let t=a[e]?.value,n=i[e],c=n?H(n.value,{format:n.format,locale:r.locale}):``,l=t===null?void 0:zo(t,r.locale);l!==void 0&&l<0&&(l=void 0),o.push(c?String(c):``),s.push(l)}let l=C(0,s.length).sort((e,t)=>{let n=s[e],r=s[t];return n===void 0&&r===void 0?0:n===void 0?1:r===void 0?-1:r-n});return r.dataSetsValues[0]={...r.dataSetsValues[0],data:l.map(e=>r.dataSetsValues[0].data[e])},{...r,axisFormats:{...r.axisFormats||{},size:c},labels:l.map(e=>r.labels[e]),bubbleLabels:l.map(e=>o[e]),bubbleSizes:l.map(e=>s[e])}}function OD(e,t){let n=e.yRanges[0],r=e.xRange?t.getVisibleRangeValues(e.xRange):n?Array.from({length:t.getVisibleRangeValues(n).length},()=>mD):[],i=n?t.getVisibleRangeValues(n):[],a=um(r.length,i.length,e.dataSetsHaveTitle||!1);return{labelValues:a?r.slice(1):r,dataSetsValues:[{dataSetId:`0`,label:``,data:a?i.slice(1):i}],shouldRemoveFirstLabel:a}}function kD(e,t){let n=[],r=[],i=[];for(let e=0;e<t.length;e++){let a=t[e];tf(a)&&(n.push(a.value),r.push(e+1)),i.push(e+1)}let a=jD(e,n,r,C(.5,i.length+.55,.2));return a.length?a:void 0}function AD(e,t,n,r,i){let a=[],o=[],s=[],c=t.length;if(c<2)return;switch(r){case`category`:for(let e=0;e<c;e++){let n=t[e];tf(n)&&(a.push(n.value),o.push(e+1)),s.push(e+1)}break;case`linear`:for(let e=0;e<t.length;e++){let r=Number(n[e]);if(isNaN(r))continue;let i=t[e];tf(i)&&(a.push(i.value),o.push(r)),s.push(r)}break;case`time`:for(let e=0;e<t.length;e++){let r=L({value:n[e]},i),c=t[e];tf(c)&&(a.push(c.value),o.push(r)),s.push(r)}break}let l=Math.min(...s),u=Math.max(...s);if(u===l)return;let d=5*s.length,f=(u-l)/d,p=jD(e,a,o,C(l,u+f/2,f));if(p.length)return p}function jD(e,t,n,r){if(t.length<2||n.length<2||r.length===0)return[];let{normalizedLabels:i,normalizedNewLabels:a}=MD(n,r,e);try{switch(e.type){case`polynomial`:{let n=e.order;if(!n)return r.map(e=>({x:e,y:NaN}));if(n===1)return NS([t],[i],[a],!0)[0].map((e,t)=>({x:r[t],y:e}));let o=OS(t,i,n,!0).flat();return a.map((e,t)=>({x:r[t],y:AS(o,e,n)}))}case`exponential`:{let e=[],n=[];for(let r=0;r<t.length;r++)t[r]>0&&(e.push(Math.log(t[r])),n.push(i[r]));return n.length?jS(NS([e],[n],[a],!0))[0].map((e,t)=>({x:r[t],y:e})):r.map(e=>({x:e,y:NaN}))}case`logarithmic`:return NS([t],MS([i]),MS([a]),!0)[0].map((e,t)=>({x:r[t],y:e}));case`trailingMovingAverage`:return PS(t,n,e.window);default:return r.map(e=>({x:e,y:NaN}))}}catch{return r.map(e=>({x:e,y:NaN}))}}function MD(e,t,n){let r=[],i=[];if(n.type===`logarithmic`){let n=Math.max(...e.map(Math.abs));r=e.map(e=>e/n),i=t.map(e=>e/n)}else{let n=Math.max(...e),a=n-Math.min(...e);r=e.map(e=>(e-n)/a),i=t.map(e=>(e-n)/a)}return{normalizedLabels:r,normalizedNewLabels:i}}function ND(e,t){return PD(e,t)&&BD()?`time`:FD(e,t)?`linear`:`category`}function PD(e,t){return!e.labelsAsText&&LD(t)}function FD(e,t){return!e.labelsAsText&&RD(t)}function ID(e){return LD(e)||RD(e)}function LD(e){if(!RD(e))return!1;let t=JD(e.labelValues);return!!(t&&jm.test(t))}function RD(e){let t=e.labelValues;return!(t.some(e=>!tf(e)&&e.value)||t.every(e=>!e.value))}let zD=!1;function BD(){if(!window.Chart)return!1;let e=new window.Chart._adapters._date({})._id===`luxon`;return!e&&!zD&&(zD=!0,console.warn(`'chartjs-adapter-luxon' time adapter is not installed. Time scale axes are disabled.`)),e}function VD(e,t){let n=C(0,Math.max(e.length,...t.map(e=>e.data?.length||0))).filter(e=>t.some(t=>tf(t.data[e])&&t.data[e].value>0));return{labels:n.map(t=>e[t]||``),dataSetsValues:t.map(e=>({...e,data:n.map(t=>tf(e.data[t])&&e.data[t].value>0?e.data[t]:mD)}))}}function HD(e,t){if(e.length===0||e.every(e=>!e))return{labels:e,dataSetsValues:t};let n=[...e],r=x(t);for(let e=0;e<n.length;e++)if(!n[e]){n[e]=Kt(n,e);for(let t of r)t.data[e]=mD}return{labels:n,dataSetsValues:r}}function UD(e,t){let n=C(0,Math.max(e.length,...t.map(e=>e.data?.length||0))).filter(n=>{let r=e[n],i=t.map(e=>e.data?.[n]);return r||i.some(tf)});return{labels:n.map(t=>e[t]||``),dataSetsValues:t.map(e=>({...e,data:n.map(t=>tf(e.data[t])?e.data[t]:mD)}))}}function WD(e,t){let n=C(0,Math.max(e.length,...t.map(e=>e.data?.length||0))).filter(n=>{let r=e[n],i=t.map(e=>e.data?.[n]);return tf(r)&&tf(i[0])});return{labels:n.map(t=>e[t]||``),dataSetsValues:t.map(e=>({...e,data:n.map(t=>tf(e.data[t])?e.data[t]:mD)}))}}function GD(e,t){let n=Math.max(e.length,...t.map(e=>e.data?.length||0)),r=e=>e===null||e===``,i=C(0,n).filter(n=>{let i=t.map(e=>e.data?.[n]);if(r(i[0]?.value))return!1;let a=!1;for(let e of i)if(a||=r(e?.value),a&&!r(e?.value))return!1;return e[n]&&tf(e[n])});return{labels:i.map(t=>e[t]),dataSetsValues:t.map(e=>({...e,data:i.map(t=>e.data[t])}))}}function KD(e,t){let n=[],r=[];for(let t=0;t<e.length;t++)Number(e[t].value)<=0?r.push(t):Number(e[t].value)>0&&n.push(t);let i=n.length?n:r;return{labels:i.map(t=>e[t]),dataSetsValues:t.map(e=>({...e,data:i.map(t=>e.data[t])}))}}function qD(e,t){let n=e=>typeof e==`number`?e:0,r=new Set(e),i={};r.forEach(e=>{i[e]=Array(t.length)});for(let r of C(0,e.length)){let a=e[r];for(let e of C(0,t.length)){let o=t[e].data[r];i[a][e]?i[a][e].value+=n(o?.value):i[a][e]={...o,value:n(o?.value)}}}return{labels:Array.from(r),dataSetsValues:t.map((e,t)=>({...e,data:Array.from(r).map(e=>i[e][t])}))}}function JD(e){return e.find(({format:e})=>e!==void 0)?.format}function YD(e,t,n){let r=t.filter(t=>n===`right`==(e?.[t.dataSetId]?.yAxisId===`y1`));for(let e of r){let t=e.data.find(({format:e})=>e!==void 0&&!fc(e));if(t)return t.format}}function XD(e,t){return e.map(e=>{let n=[],r=0,i=t===`asc`?C(0,e.data.length):C(0,e.data.length).reverse();for(let t of i){let i=e.data[t];tf(i)?(r+=i.value,n[t]={...i,value:r}):n[t]=mD}return{...e,data:n}})}function ZD(e,t){let{title:n,legendPosition:r}=e,i=n&&n.text||r===`top`;return t.isDashboard()&&!i?30:0}function QD(e,t){return{padding:{left:20,right:20,top:Math.max(15,t.topPadding||0),bottom:10}}}function $D(e,t){let n=e.legendPosition;return{padding:{left:20+(n===`left`?70:0),right:20+(n===`right`?70:0),top:Math.max(15,t.topPadding||0),bottom:10}}}let eO=.2;function tO(e,t){let n=e.datasetIndex;for(let e=0;e<t.length;e++){if(e===n)continue;let r=t[e];for(let t of[`borderColor`,`backgroundColor`])t in r&&(r[t]=dp(r[t],e===n?1:eO))}}function nO(e){for(let t of e)for(let e of[`borderColor`,`backgroundColor`])e in t&&(t[e]=dp(t[e],1))}function rO(e,t){let n=e.datasetIndex;for(let e=0;e<t.length;e++){let r=t[e],i=dp(r.borderColor,e===n?1:eO);r.borderColor=i,r.pointBackgroundColor=i,r.backgroundColor=dp(r.backgroundColor,et*(e===n?1:eO))}}function iO(e){for(let t of e){let e=dp(t.borderColor,1);t.borderColor=e,t.pointBackgroundColor=e,t.backgroundColor=dp(t.backgroundColor,et)}}function aO(e,t){let n=t[0],r=n.hoverBackgroundColor,i=n.hoverBorderColor;!Array.isArray(r)||!Array.isArray(i)||(n.backgroundColor=r.map((t,n)=>dp(t,n===e.datasetIndex?1:eO)),n.borderColor=i.map((t,n)=>dp(t,n===e.datasetIndex?1:eO)))}function oO(e){let t=e[0],n=t.hoverBackgroundColor,r=t.hoverBorderColor;!Array.isArray(n)||!Array.isArray(r)||(t.backgroundColor=[...n],t.borderColor=[...r])}function sO(e,t){let n=t.datasetIndex;n!==void 0&&(e.isDatasetVisible(n)?e.hide(n):e.show(n))}function cO(e,t){for(let n of t){let t=n.backgroundColor;if(!t)return;t.forEach((t,n,r)=>{r[n]=dp(t,n===e.index?1:eO)})}}function lO(e){for(let t of e){let e=t.backgroundColor;if(!e)return;e.forEach((e,t,n)=>{n[t]=dp(e,1)})}}function uO(e,t){let n=t.index;n!==void 0&&e.toggleDataVisibility(n)}function dO({legendPosition:e}){return{display:e!==`none`,position:e===`none`?void 0:e}}function fO(e,t){return{...SO({highlightItem:tO,unHighlightItems:nO,toggleDataVisibility:sO}),...dO(e),...wO(om(e.background),{lineWidth:3})}}function pO(e,t){return{...dO(e),...wO(om(e.background),{pointStyle:`rect`,lineWidth:3})}}function mO(e,t){let n=e.fillArea,r=n?`rect`:`line`,i=n?2:3;return{...SO({highlightItem:rO,unHighlightItems:iO,toggleDataVisibility:sO}),...dO(e),...wO(om(e.background),{pointStyle:r,lineWidth:i})}}function hO(e,t){let{dataSetsValues:n}=t,r=gm(new Ap(Math.max(0,...n.map(e=>e?.data?.length??0)),e.slicesColors),n),i=om(e.background);return{...SO({highlightItem:cO,unHighlightItems:lO,toggleDataVisibility:uO}),...dO(e),labels:{usePointStyle:!0,generateLabels:e=>(e.data.labels?.map((t,n)=>({text:_m(String(t)),strokeStyle:r[n],fillStyle:r[n],pointStyle:`rect`,lineWidth:2,fontColor:i,index:n,hidden:!e.getDataVisibility?.(n)}))||[]).filter(e=>e.text),filter:(e,t)=>`datasetIndex`in e?!t.datasets[e.datasetIndex].hidden:!0}}}function gO(e,t){return{...SO({highlightItem:rO,unHighlightItems:iO,toggleDataVisibility:sO}),...dO(e),...EO(om(e.background),{pointStyle:`circle`,strokeStyle:e.background||`#ffffff`,lineWidth:8})}}function _O(e,t){return e.bubbleColor.color===`multiple`?{...CO,...dO(e),...TO(om(e.background),{pointStyle:`circle`,strokeStyle:e.background||`#ffffff`,lineWidth:8},t.bubbleLabels)}:{display:!1}}function vO(e,t){return{...SO({highlightItem:tO,unHighlightItems:nO,toggleDataVisibility:sO}),...dO(e),...wO(om(e.background),{lineWidth:3})}}function yO(e,t){let n=om(e.background),r=e.negativeValuesColor||`#EA6175`,i=e.positiveValuesColor||`#4EA7F2`,a=e.subTotalValuesColor||`#AAAAAA`;return{...dO(e),labels:{usePointStyle:!0,generateLabels:()=>{let t=[{text:P(`Positive values`),fontColor:n,fillStyle:i,strokeStyle:i,pointStyle:`rect`},{text:P(`Negative values`),fontColor:n,fillStyle:r,strokeStyle:r,pointStyle:`rect`}];return(e.showSubTotals||e.firstValueAsSubtotal)&&t.push({text:P(`Subtotals`),fontColor:n,fillStyle:a,strokeStyle:a,pointStyle:`rect`}),t},filter:(e,t)=>`datasetIndex`in e?!t.datasets[e.datasetIndex].hidden:!0},onClick:()=>{}}}function bO(e,t){let n=e.fillArea??!1,r=n?`rect`:`line`,i=n?2:3;return{...SO({highlightItem:rO,unHighlightItems:iO,toggleDataVisibility:sO}),...dO(e),...wO(om(e.background),{pointStyle:r,lineWidth:i})}}function xO(e,t){let n=om(e.background);return{...dO(e),labels:{usePointStyle:!0,generateLabels:e=>{let t=e.data.datasets.at(-1);return t?t.groupColors.map(({color:e,label:t})=>({text:_m(t),fontColor:n,fillStyle:e,strokeStyle:e,pointStyle:`rect`})):[]}}}}function SO({highlightItem:e,unHighlightItems:t,toggleDataVisibility:n}){return{onHover:(t,n,r)=>{if(!n.hidden){let t=r.chart.data.datasets;e(n,t),r.chart.update()}let i=t.native?.target;i&&i instanceof HTMLElement&&(i.style.cursor=`pointer`)},onLeave:(e,n,r)=>{if(!n.hidden){let e=r.chart.data.datasets;t(e),r.chart.update()}let i=e.native?.target;i&&i instanceof HTMLElement&&(i.style.cursor=`default`)},onClick:(r,i,a)=>{r.type!==`click`||!a.legendItems||(a.chart.options.animation&&(a.chart.options.animation=!1),n(a.chart,i),i.hidden?e(i,a.chart.data.datasets):t(a.chart.data.datasets),a.chart.update(),r.native.preventDefault(),r.native.stopPropagation())}}}let CO={...SO({highlightItem:aO,unHighlightItems:oO,toggleDataVisibility:sO}),onClick:(e,t,n)=>{if(e.type!==`click`)return;let r=t.datasetIndex;if(r===void 0)return;let i=n.chart.getDatasetMeta(0),a=i.data[r].hidden;i.data[r].hidden=!a,n.chart.update(),e.native.preventDefault(),e.native.stopPropagation()}};function wO(e,t){return{labels:{color:e,usePointStyle:!0,generateLabels:n=>n.data.datasets.map((r,i)=>vm(r.xAxisID)?{text:_m(r.label),fontColor:e,strokeStyle:r.borderColor,hidden:!n.isDatasetVisible(i),pointStyle:`line`,datasetIndex:i,lineWidth:3}:{text:_m(r.label),fontColor:e,strokeStyle:r.borderColor,fillStyle:r.backgroundColor,hidden:!n.isDatasetVisible(i),pointStyle:r.type===`line`?`line`:`rect`,datasetIndex:i,...t}).filter(e=>e.text),filter:(e,t)=>`datasetIndex`in e?!t.datasets[e.datasetIndex].hidden:!0}}}function TO(e,t,n){return{labels:{color:e,usePointStyle:!0,generateLabels:r=>{if(!r.data.datasets[0])return[];let i=r.data.datasets[0].backgroundColor,a=typeof i==`string`?r.data.datasets[0].data.map(()=>i):i;return r.data.datasets[0].data.map((i,o)=>({text:n[o],fontColor:e,strokeStyle:a?.[o],fillStyle:a?.[o],hidden:r.getDatasetMeta(0).data[o].hidden,pointStyle:`rect`,datasetIndex:o,...t})).filter(e=>e.text)},filter:(e,t)=>!0}}}function EO(e,t){return{labels:{color:e,usePointStyle:!0,generateLabels:n=>n.data.datasets.map((r,i)=>vm(r.xAxisID)?{text:_m(r.label),fontColor:e,strokeStyle:r.borderColor,hidden:!n.isDatasetVisible(i),pointStyle:`line`,datasetIndex:i,lineWidth:3}:{text:_m(r.label),fontColor:e,strokeStyle:r.borderColor,fillStyle:r.pointBackgroundColor,hidden:!n.isDatasetVisible(i),pointStyle:`circle`,datasetIndex:i,lineWidth:8,...t}).filter(e=>e.text),filter:(e,t)=>`datasetIndex`in e?!t.datasets[e.datasetIndex].hidden:!0}}}let DO={showValues:!1,showLabels:!0,valuesDesign:{align:`center`,fontSize:13}};function OO(e,t){let{axisFormats:n,locale:r}=t;return{type:e.type,horizontal:`horizontal`in e&&e.horizontal,showValues:`showValues`in e?!!e.showValues:!1,background:()=>e.background,callback:(t,i)=>{let a=NO(e,i);return pm(n,r,e.humanize)(t,a)}}}function kO(e,t){let{locale:n,axisFormats:r}=t,i=(t,n,r)=>e.background,a=t.dataSetsValues.flat().flatMap(e=>e?.data.filter(tf)).map(e=>e.value);if(a.length){let t=Math.min(...a),n=Math.max(...a),r=Qm(e.colorScale??AC(`oranges`),t,n);i=(t,n,i)=>{let a=n._dataset.values[i];return a===void 0?e.background:om(r(a))}}return{type:`calendar`,horizontal:!1,showValues:`showValues`in e?!!e.showValues:!1,background:i,callback:(e,t,i)=>{let a=t._dataset.values[i];return a===void 0?``:Tc({value:a,format:r?.y},n)}}}function AO(e,t){let{axisFormats:n,locale:r}=t;return{callback:pm(n,r,e.humanize),showLabels:e.showLabels??DO.showLabels,showValues:e.showValues??DO.showValues,style:{fontSize:e.valuesDesign?.fontSize??DO.valuesDesign.fontSize,align:e.valuesDesign?.align??DO.valuesDesign.align,bold:e.valuesDesign?.bold??DO.valuesDesign.bold,italic:e.valuesDesign?.italic??DO.valuesDesign.italic,textColor:e.valuesDesign?.color??DO.valuesDesign.color}}}function jO(e,t){let{axisFormats:n,locale:r}=t;return{type:`pyramid`,horizontal:!0,showValues:`showValues`in e?!!e.showValues:!1,background:()=>e.background,callback:(e,t)=>(e=Math.abs(Number(e)),e===0?``:pm(n,r)(e,t.xAxisID||`x`))}}function MO(e,t){let{axisFormats:n,locale:r,dataSetsValues:i}=t,a=i.reduce((e,t)=>(e.push((e.at(-1)||-1)+t.data.length+1),e),[]);return{type:`waterfall`,showValues:`showValues`in e?!!e.showValues:!1,background:()=>e.background,callback:(t,i,o)=>{let s=i._dataset.data[o],c=s[1]-s[0],l=c>=0?`+`:``;return e.showSubTotals&&a.includes(o)&&l===`+`&&(l=``),`${l}${pm(n,r,e.humanize)(c,i.yAxisID)}`}}}function NO(e,t){return t.rAxisID?t.rAxisID:(`horizontal`in e&&e.horizontal?t.xAxisID:t.yAxisID)||`y`}function PO({title:e,legendPosition:t,background:n},r){let i=sm(n);return{display:!!e.text,text:e.text?r.dynamicTranslate(e.text):``,color:e?.color??i,align:e.align===`center`?`center`:e.align===`right`?`end`:`start`,font:{size:e.fontSize??16,weight:e.bold?`bold`:`normal`,style:e.italic?`italic`:`normal`},padding:{bottom:t===`top`?0:20}}}let FO;function IO(e,t={}){return LO(e,t).innerHTML}function LO(e,n={}){FO||=new t.App({templates:`
|
|
37
37
|
<templates>
|
|
38
38
|
<t t-name="o-spreadsheet-CustomTooltip">
|
|
39
39
|
<div
|
|
@@ -954,4 +954,4 @@ If you meant to create a named range, named range cannot have the same name as a
|
|
|
954
954
|
<Relationships xmlns="${Bp.Relationships}">
|
|
955
955
|
<Relationship ${J(e)} />
|
|
956
956
|
</Relationships>
|
|
957
|
-
`),`_rels/.rels`)}function tK(e){let t={},n=[];for(let r of e.sheets){let e=r.name.slice(0,31);e=_n(e,n,{compute:(e,t)=>e.slice(0,31-String(t).length)+t}),n.push(e),e!==r.name&&(t[r.name]=e,r.name=e)}if(!Object.keys(t).length)return e;let r=Object.keys(t).sort((e,t)=>t.length-e.length),i=JSON.stringify(e);for(let e of r){let n=RegExp(`'?${xt(e)}'?!`,`g`);i=i.replaceAll(n,n=>{let r=t[e];return n.replace(e,r)})}return JSON.parse(i)}function nK(e){for(let t of e.sheets)t.tables=t.tables.filter(e=>sr(Un(e.range)).numberOfRows>1);return e}var rK=class e extends Ui{corePlugins=[];statefulUIPlugins=[];range;session;isReplayingCommand=!1;renderers={};status=0;config;corePluginConfig;coreViewPluginConfig;uiPluginConfig;state;selection;getters;coreGetters;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},t={},n=[],r=!1){let i=performance.now();console.debug(`##### Model creation #####`),super(),bo(),n=KC(e,n);let a=RC(e,r);this.state=new hW,this.config=this.setupConfig(t),this.getters={isReadonly:()=>this.config.mode===`readonly`||this.config.mode===`dashboard`,isDashboard:()=>this.config.mode===`dashboard`},this.session=this.setupSession(a.revisionId),this.coreGetters={},this.range=new dW(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.copyFormulaStringForSheet=this.range.copyFormulaStringForSheet.bind(this.range),this.selection=new pW(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(let e of QV.getAll())this.setupCorePlugin(e,a);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(n);for(let e of tH.getAll()){let t=this.setupCoreViewPlugin(e);this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of eH.getAll()){let t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of $V.getAll()){let t=this.setupUiPlugin(e);this.handlers.push(t),this.uiHandlers.push(t)}if(this.config.mode!==`export_verification`&&(this.dispatch(`START`),this.selection.observe(this,{handleEvent:()=>this.trigger(`update`)}),this.setupSessionEvents(),this.joinSession(),t.snapshotRequested||e[`[Content_Types].xml`]&&!this.getters.isReadonly())){let e=performance.now();console.debug(`Snapshot requested`),this.session.snapshot(this.exportData()),console.debug(`Snapshot taken in`,performance.now()-e,`ms`)}console.debug(`Model created in`,performance.now()-i,`ms`),console.debug(`######`)}joinSession(){this.session.join(this.config.client)}async leaveSession({shouldSnapshot:e}={shouldSnapshot:!0}){let t=e&&!this.getters.isReadonly()?Gt(()=>this.exportData()):void 0;await this.session.leave(t)}setupUiPlugin(e){let t=new e(this.uiPluginConfig);for(let n of e.getters){if(!(n in t))throw Error(`Invalid getter name: ${n} for plugin ${t.constructor}`);if(n in this.getters)throw Error(`Getter "${n}" is already defined.`);this.getters[n]=t[n].bind(t)}for(let n of e.layers)this.renderers[n]||(this.renderers[n]=[]),this.renderers[n].push(t);return t}setupCoreViewPlugin(e){let t=new e(this.coreViewPluginConfig);for(let n of e.getters){if(!(n in t))throw Error(`Invalid getter name: ${n} for plugin ${t.constructor}`);if(n in this.getters)throw Error(`Getter "${n}" is already defined.`);this.getters[n]=t[n].bind(t)}return t}setupCorePlugin(e,t){let n=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in n))throw Error(`Invalid getter name: ${t} for plugin ${n.constructor}`);if(t in this.coreGetters)throw Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=n[t].bind(n)}n.import(t),this.corePlugins.push(n),this.coreHandlers.push(n),this.handlers.push(n)}onRemoteRevisionReceived({commands:e}){for(let t of e){let e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new sV(cW({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{if(!this.checkDispatchAllowedRemoteCommand(e).isSuccessful){this.dispatchToHandlers(this.coreHandlers,{type:`UNDO`,commands:[e]});return}this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1}}),this.config.transportService,e,new $U(this.getters))}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){let t=e.client||{id:G.smallUuid(),name:P(`Anonymous`).toString()},n=e.transportService||new qH,r=e.mode===`readonly`||e.mode===`dashboard`||e.mode===`export_verification`;return{...e,mode:e.mode||`normal`,custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:r?new eW(n):n,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){let t=e.loadLocales||(()=>Promise.resolve(xs));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,custom:this.config.custom,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,colorScheme:this.config.colorScheme}}checkDispatchAllowed(e){let t=Pd(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return this.processCommandResults(t)}processCommandResults(e){return e.some(e=>e!==`Success`)?new Id(e.flat()):Id.Success}checkDispatchAllowedRemoteCommand(e){let t=this.coreHandlers.map(t=>t.allowDispatch(e));return this.processCommandResults(t)}checkDispatchAllowedCoreCommand(e){return this.handlers.map(t=>t.allowDispatch(e))}checkDispatchAllowedLocalCommand(e){return this.uiHandlers.map(t=>t.allowDispatch(e))}finalize(){this.status=3;for(let e of this.handlers)e.finalize();this.status=0,this.trigger(`command-finalized`)}canDispatch=(e,t)=>this.checkDispatchAllowed(iK(e,t));dispatch=(e,t)=>{let n=iK(e,t),r=this.status;if(this.getters.isReadonly()&&!Fd(n))return new Id(`Readonly`);if(!this.session.canApplyOptimisticUpdate())return new Id(`WaitingSessionConfirmation`);switch(r){case 0:let t=this.checkDispatchAllowed(n);if(!t.isSuccessful)return this.trigger(`update`),this.trigger(`command-rejected`,{command:n,result:t}),t;this.status=1;let{changes:r,commands:i}=this.state.recordChanges(()=>{let t=performance.now();Pd(n)&&this.state.addCommand(n),this.dispatchToHandlers(this.handlers,n),this.finalize();let r=performance.now()-t;r>5&&console.debug(e,r,`ms`)});this.session.save(n,i,r),this.status=0,this.trigger(`update`);break;case 1:if(Pd(n)){let e=this.checkDispatchAllowed(n);if(!e.isSuccessful)return e;this.state.addCommand(n)}this.dispatchToHandlers(this.handlers,n);break;case 3:throw Error(`Cannot dispatch commands in the finalize state`);case 2:if(Pd(n))throw Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,n)}return Id.Success};dispatchFromCorePlugin=(e,t)=>{let n=iK(e,t),r=this.status;this.status=2;let i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,n),this.status=r,Id.Success};dispatchToHandlers(e,t){let n=Pd(t);for(let r of e)!n&&r instanceof cv||r.beforeHandle(t);for(let r of e)!n&&r instanceof cv||r.handle(t);this.trigger(`command-dispatched`,t)}drawLayer(e,t){let n=this.renderers[t];if(n)for(let r of n)e.ctx.save(),r.drawLayer(e,t),e.ctx.restore()}exportData(){let t=this._exportData(!0),n=this._exportData(!1),r={...this.config,mode:`export_verification`,client:{id:`exporter`,name:`exporter`},snapshotRequested:!1,transportService:new qH};return T(n,new e(x(t),r)._exportData(!1))?t:(n.isNotSquishable=!0,n)}_exportData(e){let t=$C();for(let n of this.handlers)n instanceof cv&&n.export(t,e);return t.revisionId=this.session.getRevisionId()||`START_REVISION`,t=x(t),t}updateMode(e){this.config.mode=e,this.trigger(`update`)}async exportXLSX(){this.dispatch(`EVALUATE_CELLS`);let e=tw();for(let t of this.handlers)t instanceof sv&&await t.exportForExcel(e);return e=x(e),KG(e)}};function iK(e,t={}){let n=x(t);return n.type=e,n}var aK=class extends fV{queuedBordersToAdd={};copy(e){let t=e.sheetId;if(e.zones.length===0)return;let{rowsIndexes:n,columnsIndexes:r}=e,i=[];for(let e of n){let n=[];for(let i of r){let r={col:i,row:e,sheetId:t};n.push(this.getters.getCellBorder(r))}i.push(n)}return{borders:i}}paste(e,t,n){let r=e.sheetId;if(n.pasteOption===`asValue`)return;let i=e.zones;if(!n.isCutOperation)this.pasteFromCopy(r,i,t.borders);else{let{left:e,top:n}=i[0];this.pasteZone(r,e,n,t.borders)}this.executeQueuedChanges(r)}pasteZone(e,t,n,r){for(let[i,a]of r.entries())for(let[r,o]of a.entries()){let a={col:t+r,row:n+i,sheetId:e};this.pasteBorder(o,a)}}pasteBorder(e,t){let n={...this.getters.getCellBorder(t),...e},r=JSON.stringify(n);this.queuedBordersToAdd[r]||(this.queuedBordersToAdd[r]=[]),this.queuedBordersToAdd[r].push(O(t))}executeQueuedChanges(e){for(let t in this.queuedBordersToAdd){let n=this.queuedBordersToAdd[t],r=JSON.parse(t),i=D(n,[]);this.dispatch(`SET_BORDERS_ON_TARGET`,{sheetId:e,target:i,border:r})}this.queuedBordersToAdd={}}},oK=class extends dV{copy(e){}getCopyRect(e){return p_(...e.figureIds.map(t=>this.getters.getFigure(e.sheetId,t)).filter(w).map(t=>this.getters.getFigureUI(e.sheetId,t)))}},sK=class extends oK{copy(e){let t=e.sheetId,n=[],r=this.getCopyRect(e);for(let i of e.figureIds){let e=this.getters.getFigure(t,i);if(!e)throw Error(`No figure for the given id: ${i}`);if(e.tag!==`carousel`)continue;let a={...e},o=this.getters.getCarousel(i),{x:s,y:c}=this.getters.getFigureUI(t,e),l={};for(let e of o.items)if(e.type===`chart`){let t=this.getters.getChart(e.chartId);if(!t)throw Error(`No chart for the given id: ${e.chartId}`);l[e.chartId]=t}n.push({figureId:i,copiedFigure:a,copiedCarousel:o,copiedCharts:l,copiedSheetId:t,offset:{x:s-r.x,y:c-r.y}})}return{figures:n,figureIds:e.figureIds}}getPasteTarget(e,t,n,r){let i={};for(let e of n.figures)i[e.figureId]=G.smallUuid();return{zones:[],figureIds:i,sheetId:e}}paste(e,t,n){if(!e.figureIds)return;let{zones:r}=e,i=e.sheetId;for(let a of t.figures){let o=e.figureIds[a.figureId],{width:s,height:c}=a.copiedFigure,{col:l,row:u,offset:d}=jg(this.getters,i,{col:r[0].left,row:r[0].top},{...a.copiedFigure,offset:a.offset});this.dispatch(`CREATE_CAROUSEL`,{figureId:o,sheetId:i,definition:{items:[]},col:l,row:u,offset:d,size:{height:c,width:s}});let f=x(a.copiedCarousel.items);for(let e of f){if(e.type!==`chart`)continue;let t=a.copiedCharts[e.chartId],n=G.smallUuid(),r=hk.fromDefinition(this.getters,i,t.copyInSheetId(i)).getDefinition();this.dispatch(`CREATE_CHART`,{figureId:o,chartId:n,sheetId:i,definition:r}),e.chartId=n}this.dispatch(`UPDATE_CAROUSEL`,{sheetId:i,figureId:o,definition:{...a.copiedCarousel,items:f}}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:a.copiedSheetId,figureId:a.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:o,selectMultiple:t.figureIds.length>1})}}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}},cK=class extends oK{copy(e){let t=e.sheetId,n=[],r=this.getCopyRect(e);for(let i of e.figureIds){let e=this.getters.getFigure(t,i);if(!e)throw Error(`No figure for the given id: ${i}`);if(e.tag!==`chart`)continue;let a={...e},{x:o,y:s}=this.getters.getFigureUI(t,e),c=this.getters.getChartFromFigureId(i);if(!c)throw Error(`No chart for the given id: ${i}`);n.push({figureId:i,copiedFigure:a,copiedChart:c,offset:{x:o-r.x,y:s-r.y}})}return{figures:n,figureIds:e.figureIds}}getPasteTarget(e,t,n,r){let i={};for(let e of n.figures)i[e.figureId]=G.smallUuid();return{zones:[],figureIds:i,sheetId:e}}paste(e,t,n){if(!e.figureIds)return;let{zones:r}=e,i=e.sheetId;for(let a of t.figures){let o=e.figureIds[a.figureId],{width:s,height:c}=a.copiedFigure,l=a.copiedChart,u=hk.fromDefinition(this.getters,i,l.copyInSheetId(i)).getDefinition();u=hk.fromStrDefinition(this.getters,i,u).getDefinition();let{col:d,row:f,offset:p}=jg(this.getters,i,{col:r[0].left,row:r[0].top},{...a.copiedFigure,offset:a.offset});this.dispatch(`CREATE_CHART`,{figureId:o,chartId:G.smallUuid(),sheetId:i,definition:u,col:d,row:f,offset:p,size:{height:c,width:s}}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:a.copiedChart.sheetId,figureId:a.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:o,selectMultiple:t.figureIds.length>1})}}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}},lK=class extends fV{queuedChanges={};copy(e){if(!e.zones.length)return;let{rowsIndexes:t,columnsIndexes:n}=e,r=e.sheetId,i=[];for(let e of t){let t=[];for(let i of n){let n=Array.from(this.getters.getRulesByCell(r,i,e));t.push({position:{col:i,row:e,sheetId:r},rules:n})}i.push(t)}return{cfRules:i}}paste(e,t,n){if(this.queuedChanges={},n.pasteOption===`asValue`)return;let r=e.zones,i=e.sheetId;n.isCutOperation?this.pasteFromCut(i,r,t):this.pasteFromCopy(i,r,t.cfRules,n),this.executeQueuedChanges()}pasteFromCut(e,t,n){let r=t[0];this.pasteZone(e,r.left,r.top,n.cfRules,{isCutOperation:!0})}pasteZone(e,t,n,r,i){for(let[a,o]of r.entries())for(let[r,s]of o.entries()){let o={col:t+r,row:n+a,sheetId:e};this.pasteCf(s,o,i?.isCutOperation)}}pasteCf(e,t,n){if(e?.rules&&e.rules.length>0){let r=O(e.position),i=O(t);for(let a of e.rules){let o=[];if(n&&o.push(r),e.position.sheetId===t.sheetId)this.adaptCFRules(e.position.sheetId,a,[i],o);else{this.adaptCFRules(e.position.sheetId,a,[],o);let n=this.getCFToCopyTo(t.sheetId,a);this.adaptCFRules(t.sheetId,n,[i],[])}}}}adaptCFRules(e,t,n,r){this.queuedChanges[e]||(this.queuedChanges[e]=[]);let i=this.queuedChanges[e].find(e=>e.cf.id===t.id);i?(i.toAdd.push(...n),i.toRemove.push(...r)):this.queuedChanges[e].push({toAdd:n,toRemove:r,cf:t})}executeQueuedChanges(){for(let e in this.queuedChanges)for(let{toAdd:t,toRemove:n,cf:r}of this.queuedChanges[e]){let i=this.getters.getAdaptedCfRanges(e,r,t,n);if(i){if(i.length===0){this.dispatch(`REMOVE_CONDITIONAL_FORMAT`,{id:r.id,sheetId:e});continue}this.dispatch(`ADD_CONDITIONAL_FORMAT`,{cf:{id:r.id,rule:r.rule,stopIfTrue:r.stopIfTrue},ranges:i,sheetId:e})}}}getCFToCopyTo(e,t){let n=this.getters.getConditionalFormats(e).find(e=>e.stopIfTrue===t.stopIfTrue&&T(e.rule,t.rule)),r=this.queuedChanges[e];return!n&&r&&(n=r.find(e=>e.cf.stopIfTrue===t.stopIfTrue&&T(e.cf.rule,t.rule))?.cf),n||{...t,id:G.smallUuid(),ranges:[]}}},uK=class extends fV{queuedChanges={};copy(e){let{rowsIndexes:t,columnsIndexes:n}=e,r=e.sheetId,i=[];for(let e of t){let t=[];for(let i of n){let n={sheetId:r,col:i,row:e},a=this.getters.getValidationRuleForCell(n);t.push({position:n,rule:a})}i.push(t)}return{dvRules:i}}paste(e,t,n){if(this.queuedChanges={},n.pasteOption)return;let r=e.zones,i=e.sheetId;n.isCutOperation?this.pasteFromCut(i,r,t):this.pasteFromCopy(i,r,t.dvRules),this.executeQueuedChanges()}pasteFromCut(e,t,n){let r=t[0];this.pasteZone(e,r.left,r.top,n.dvRules,{isCutOperation:!0})}pasteZone(e,t,n,r,i){for(let[a,o]of r.entries())for(let[r,s]of o.entries()){let o={col:t+r,row:n+a,sheetId:e};this.pasteDataValidation(s,o,i?.isCutOperation)}}pasteDataValidation(e,t,n){if(e){let r=O(t),i=O(e.position),a=e.rule;if(!a){let e=this.getters.getValidationRuleForCell(t);e&&this.adaptDataValidationRule(t.sheetId,e,[],[r]);return}let o=[];if(n&&o.push(i),e.position.sheetId===t.sheetId){let n=this.getDataValidationRuleToCopyTo(t.sheetId,a,!1);this.adaptDataValidationRule(e.position.sheetId,n,[r],o)}else{let n=this.getters.getValidationRuleForCell(e.position);n&&this.adaptDataValidationRule(e.position.sheetId,n,[],o);let i=this.getDataValidationRuleToCopyTo(t.sheetId,a);this.adaptDataValidationRule(t.sheetId,i,[r],[])}}}getDataValidationRuleToCopyTo(e,t,n=!0){let r=this.getters.getDataValidationRules(e).find(e=>T(t.criterion,e.criterion)&&t.isBlocking===e.isBlocking),i=this.queuedChanges[e];return!r&&i&&(r=i.find(e=>T(t.criterion,e.rule.criterion)&&t.isBlocking===e.rule.isBlocking)?.rule),r||{...t,id:n?G.smallUuid():t.id,ranges:[]}}adaptDataValidationRule(e,t,n,r){this.queuedChanges[e]||(this.queuedChanges[e]=[]);let i=this.queuedChanges[e].find(e=>e.rule.id===t.id);i?(i.toAdd.push(...n),i.toRemove.push(...r)):this.queuedChanges[e].push({toAdd:n,toRemove:r,rule:t})}executeQueuedChanges(){for(let e in this.queuedChanges)for(let{toAdd:t,toRemove:n,rule:r}of this.queuedChanges[e]){let i=D([...D(r.ranges.map(e=>e.zone),n),...t],[]);if(i.length===0){this.dispatch(`REMOVE_DATA_VALIDATION_RULE`,{sheetId:e,id:r.id});continue}this.dispatch(`ADD_DATA_VALIDATION_RULE`,{rule:{id:r.id,criterion:r.criterion,isBlocking:r.isBlocking},ranges:i.map(t=>this.getters.getRangeDataFromZone(e,t)),sheetId:e})}}},dK=class extends fV{copy(e){let t={style:{},format:{},width:e.columnsIndexes.length,height:e.rowsIndexes.length,sheetId:e.sheetId,zones:e.clippedZones};t.format={sheetDefault:this.getters.getDefaultFormat(e.sheetId,`SHEET`,void 0)??``,colDefault:[],rowDefault:[]};let n=0;for(let r of e.columnsIndexes){let i=this.getters.getDefaultFormat(e.sheetId,`COL`,r);i&&t.format.colDefault&&(t.format.colDefault[n]=i),n++}let r=0;for(let n of e.rowsIndexes){let i=this.getters.getDefaultFormat(e.sheetId,`ROW`,n);i&&t.format.rowDefault&&(t.format.rowDefault[r]=i),r++}for(let n in Ue){t.style[n]={sheetDefault:this.getters.getDefaultStyle(e.sheetId,n,`SHEET`,void 0)??Ue[n],colDefault:{},rowDefault:{}};let r=0;for(let i of e.columnsIndexes){let a=this.getters.getDefaultStyle(e.sheetId,n,`COL`,i);a!==void 0&&(t.style[n].colDefault[r]=a),r++}let i=0;for(let r of e.rowsIndexes){let a=this.getters.getDefaultStyle(e.sheetId,n,`ROW`,r);a!==void 0&&(t.style[n].rowDefault[i]=a),i++}}return t}clearStyleFormat(e,t){this.dispatch(`SET_FORMATTING`,{sheetId:e,target:[t],format:``})}paste(e,t,n){let r=e.sheetId;if(n.pasteOption===`asValue`)return;let i=e.zones;if(n.isCutOperation){this.clearClippedZones(t);let{left:e,top:n}=i[0];this.pasteStyle(r,e,n,t.width,t.height,t.style),this.pasteFormat(r,e,n,t.width,t.height,t.format)}else for(let e of i)for(let n of fw(e,t.width,t.height))this.pasteStyle(r,n.left,n.top,t.width,t.height,t.style),this.pasteFormat(r,n.left,n.top,t.width,t.height,t.format)}clearClippedZones(e){this.dispatch(`CLEAR_FORMATTING`,{sheetId:e.sheetId,target:e.zones})}pasteStyle(e,t,n,r,i,a){let o=Sn({}),s={},c=0;function l(e,t){let n=`${e.left}:${e.right}:${e.top}:${e.bottom}`;s[n]=[e,c++],o.set(n,{...o.get(n),...t})}l({left:t,right:t+r-1,top:n,bottom:n+i-1},Ue);for(let e in a)l({left:t,right:t+r-1,top:n,bottom:n+i-1},{[e]:a[e].sheetDefault});for(let e in a)for(let r in a[e].colDefault){let o=parseInt(r);l({left:t+o,right:t+o,top:n,bottom:n+i-1},{[e]:a[e].colDefault[r]})}for(let e in a)for(let i in a[e].rowDefault){let o=parseInt(i);l({left:t,right:t+r-1,top:n+o,bottom:n+o},{[e]:a[e].rowDefault[i]})}let u=[];for(let[e,[t,n]]of Object.entries(s)){let r=o.get(e);Bt(r)||u.push([n,t,r])}u.sort((e,t)=>e[0]-t[0]);for(let[t,n,r]of u)this.dispatch(`SET_FORMATTING`,{sheetId:e,target:[n],style:r})}pasteFormat(e,t,n,r,i,a){let o={},s={},c=0;function l(e,t){let n=`${e.left}:${e.right}:${e.top}:${e.bottom}`;s[n]=[e,c++],o[n]=t}l({left:t,right:t+r-1,top:n,bottom:n+i-1},a.sheetDefault??``);for(let e in a.colDefault){let r=parseInt(e);l({left:t+r,right:t+r,top:n,bottom:n+i-1},a.colDefault[e])}for(let e in a.rowDefault){let i=parseInt(e);l({left:t,right:t+r-1,top:n+i,bottom:n+i},a.rowDefault[e])}let u=[];for(let[e,[t,n]]of Object.entries(s)){let r=o[e];u.push([n,t,r])}u.sort((e,t)=>e[0]-t[0]);for(let[t,n,r]of u)this.dispatch(`SET_FORMATTING`,{sheetId:e,target:[n],format:r})}},fK=class extends oK{copy(e){let t=e.sheetId,n=[],r=this.getCopyRect(e);for(let i of e.figureIds){let e=this.getters.getFigure(t,i);if(!e)throw Error(`No figure for the given id: ${i}`);if(e.tag!==`image`)continue;let a={...e},{x:o,y:s}=this.getters.getFigureUI(t,e),c=x(this.getters.getImage(i));n.push({figureId:i,copiedFigure:a,copiedImage:c,sheetId:t,offset:{x:o-r.x,y:s-r.y}})}return{figures:n,figureIds:e.figureIds}}getPasteTarget(e,t,n,r){let i={};for(let e of n.figures)i[e.figureId]=G.smallUuid();return{sheetId:e,zones:[],figureIds:i}}paste(e,t,n){if(!e.figureIds)return;let{zones:r}=e;for(let i of t.figures){let a=e.figureIds[i.figureId],o=this.getters.getActiveSheetId(),{width:s,height:c}=i.copiedFigure,l=x(i.copiedImage),{col:u,row:d,offset:f}=jg(this.getters,o,{col:r[0].left,row:r[0].top},{...i.copiedFigure,offset:i.offset});this.dispatch(`CREATE_IMAGE`,{figureId:a,sheetId:o,col:u,row:d,offset:f,size:{height:c,width:s},definition:l}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:i.sheetId,figureId:i.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:a,selectMultiple:t.figureIds.length>1})}}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}},pK=class extends fV{copy(e){let t=this.getters.getActiveSheetId(),{rowsIndexes:n,columnsIndexes:r}=e,i=[];for(let e of n){let n=[];for(let i of r){let r={col:i,row:e,sheetId:t};n.push(this.getters.getMerge(r))}i.push(n)}return{merges:i,sheetId:t}}paste(e,t,n){if(n.isCutOperation){let e=t.merges.flat().filter(w);this.dispatch(`REMOVE_MERGE`,{sheetId:t.sheetId,target:e})}this.pasteFromCopy(e.sheetId,e.zones,t.merges,n)}pasteZone(e,t,n,r){for(let[i,a]of r.entries())for(let[r,o]of a.entries()){let a={col:t+r,row:n+i,sheetId:e};this.pasteMerge(o,a)}}pasteMerge(e,t){if(!e||this.getters.isInMerge(t))return;let{sheetId:n,col:r,row:i}=t;this.dispatch(`ADD_MERGE`,{sheetId:n,force:!0,target:[{left:r,top:i,right:r+e.right-e.left,bottom:i+e.bottom-e.top}]})}},mK=class extends fV{copy(e){return{zones:e.clippedZones,sheetId:e.sheetId}}paste(e,t,n){if(n.isCutOperation){let n=e.zones[0];this.dispatch(`MOVE_RANGES`,{target:t.zones,sheetId:t.sheetId,sheetName:this.getters.getSheetName(t.sheetId),targetSheetId:e.sheetId,col:n.left,row:n.top})}}},hK=class extends fV{isPasteAllowed(e,t,n,r){if(!(`cells`in n))return`Success`;let{xSplit:i,ySplit:a}=this.getters.getPaneDivisions(e);return Sr(pw(t,n.cells),i,a)?`FrozenPaneOverlap`:`Success`}},gK=class extends fV{copy(e,t,n=`copyPaste`){let r=e.sheetId,{rowsIndexes:i,columnsIndexes:a,zones:o}=e,s=new Set,c=[];for(let e of i){let l=[];c.push(l);for(let c of a){let a={col:c,row:e,sheetId:r},u=this.getters.getTable(a);if(!u){l.push({});continue}let d=this.getters.getCoreTable(a),f=d?.range.zone,p;if(!s.has(u.id)&&d&&f&&o.some(e=>or(f,e))){s.add(u.id);let{numberOfRows:e}=sr(f);for(let n=f.top;n<=f.bottom;n++)!t&&!i.includes(n)&&e--;let n=d.range,r=this.getters.extendRange(d.range,`ROW`,n.zone.top+e-1-n.zone.bottom);p={range:this.getters.getRangeData(r),config:d.config,type:d.type}}if(u.isPivotTable){let t=u.range.zone.top===e&&u.range.zone.left===c,n=o.some(e=>or(u.range.zone,e));(t||n)&&s.add(u.id)}n!==`shiftCells`&&l.push({table:p,style:this.getTableStyleToCopy(a),isWholeTableCopied:s.has(u.id)})}}return{tableCells:c,sheetId:e.sheetId}}getTableStyleToCopy(e){let t=Zt({...this.getters.getCellTableStyle(e),hideGridLines:!1}),n=this.getters.getCellStyle(e),r=this.getters.getCellTableBorder(e),i=this.getters.getCellBorder(e);return{style:{...t,...Zt(n)},border:{...r,...Zt(i)}}}paste(e,t,n){let r=e.zones,i=e.sheetId;n.isCutOperation?this.pasteFromCut(i,r,t,n):this.pasteFromCopy(i,r,t.tableCells,n)}pasteFromCut(e,t,n,r){for(let e of n.tableCells)for(let t of e)t.table&&this.dispatch(`REMOVE_TABLE`,{sheetId:n.sheetId,target:[this.getters.getRangeFromRangeData(t.table.range).zone]});let i=t[0];this.pasteZone(e,i.left,i.top,n.tableCells,r)}pasteZone(e,t,n,r,i){for(let a=0;a<r.length;a++){let o=r[a];for(let r=0;r<o.length;r++){let s=o[r];if(!s)continue;let c={col:t+r,row:n+a,sheetId:e};this.pasteTableCell(e,s,c,i)}}if(r.length===1)for(let i=0;i<r[0].length;i++)this.dispatch(`AUTOFILL_TABLE_COLUMN`,{col:t+i,row:n,sheetId:e})}pasteTableCell(e,t,n,r){if(t.table&&!r?.pasteOption){let{range:r}=t.table,i=sr(this.getters.getRangeFromRangeData(r).zone),a={left:n.col,top:n.row,right:n.col+i.numberOfCols-1,bottom:n.row+i.numberOfRows-1};this.dispatch(`CREATE_TABLE`,{sheetId:n.sheetId,ranges:[this.getters.getRangeDataFromZone(e,a)],config:t.table.config,tableType:t.table.type})}this.getters.getCoreTable(n)||r?.pasteOption===`asValue`||(!r?.pasteOption&&!t.isWholeTableCopied||r?.pasteOption===`onlyFormat`)&&(t.style?.style&&this.dispatch(`UPDATE_CELL`,{...n,style:t.style.style}),t.style?.border&&this.dispatch(`SET_BORDER`,{...n,border:t.style.border}))}};XL.figureHandlers.add(`chart`,cK).add(`image`,fK).add(`carousel`,sK),XL.cellHandlers.add(`dataValidation`,uK).add(`default`,dK).add(`cell`,pV).add(`sheet`,hK).add(`merge`,pK).add(`border`,aK).add(`table`,gK).add(`conditionalFormat`,lK).add(`references`,mK);var _K=class extends A{static maxSize={maxHeight:80};static template=`o-spreadsheet-ErrorToolTip`;props=(0,t.props)({cellPosition:N.CellPosition(),onClosed:N.function().optional()});get dataValidationErrorMessage(){return this.env.model.getters.getInvalidDataValidationMessage(this.props.cellPosition)}get evaluationError(){let e=this.env.model.getters.getEvaluatedCell(this.props.cellPosition);if(e.message)return e}get errorOriginPositionString(){if(this.env.model.getters.isDashboard())return``;let e=this.evaluationError?.errorOriginPosition;if(!e||T(e,this.props.cellPosition))return``;let t=e.sheetId;return this.env.model.getters.getRangeString(this.env.model.getters.getRangeFromZone(t,O(e)),this.env.model.getters.getActiveSheetId())}selectCell(){let e=this.evaluationError?.errorOriginPosition;if(!e)return;let t=this.env.model.getters.getActiveSheetId();e.sheetId!==t&&this.env.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:t,sheetIdTo:e.sheetId}),this.env.model.selection.selectCell(e.col,e.row)}get isSpillErrorBecauseOfMissingHeaders(){let e=this.evaluationError;return e?.value===F.SpilledBlocked&&!e.errorOriginPosition&&!this.env.model.getters.getSpreadZone(this.props.cellPosition,{ignoreSpillError:!0})}getMissingHeadersForSpread(){if(!this.isSpillErrorBecauseOfMissingHeaders)return;let e=this.env.model.getters.getCell(this.props.cellPosition);if(!e||!e.isFormula)return;let t=e.compiledFormula.toFormulaString(this.env.model.getters);return xn(this.env.model.getters,this.props.cellPosition,t)}addMissingHeaders({missingCols:e,missingRows:t}){let n=this.props.cellPosition.sheetId;e>0&&this.env.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:n,sheetName:this.env.model.getters.getSheetName(n),dimension:`COL`,base:this.env.model.getters.getNumberCols(n)-1,position:`after`,quantity:e+20}),t>0&&this.env.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:n,sheetName:this.env.model.getters.getSheetName(n),dimension:`ROW`,base:this.env.model.getters.getNumberRows(n)-1,position:`after`,quantity:t+50})}getAddMissingHeadersButtonText(e){return e.missingCols>0&&e.missingRows>0?P(`Add missing columns and rows`):e.missingCols>0?P(`Add missing columns`):P(`Add missing rows`)}};let vK={onHover:(e,t)=>{let n=t.getEvaluatedCell(e);return n.type===`error`&&n.message||t.getInvalidDataValidationMessage(e)?{isOpen:!0,props:{cellPosition:e},Component:_K,cellCorner:`top-right`}:{isOpen:!1}}};var yK=class extends A{static template=`o-spreadsheet-FilterMenu`;static components={FilterMenuValueList:eN,SidePanelCollapsible:UE,FilterMenuCriterion:QM};props=(0,t.props)({filterPosition:N.Position(),onClosed:N.function().optional()});state;criterionCategory=`text`;updatedCriterionValue;setup(){(0,t.onWillUpdateProps)(e=>{T(e.filterPosition,this.props.filterPosition)||(this.updatedCriterionValue=void 0,this.criterionCategory=this.getCriterionCategory(e.filterPosition),this.state.values=this.getFilterHiddenValues(e.filterPosition))}),this.state=(0,t.proxy)({values:this.getFilterHiddenValues(this.props.filterPosition)}),this.criterionCategory=this.getCriterionCategory(this.props.filterPosition)}get isSortable(){if(!this.table)return!1;let e=this.env.model.getters.getCoreTableMatchingTopLeft(this.table.range.sheetId,this.table.range.zone);return!this.env.model.getters.isReadonly()&&e?.type!==`dynamic`}get table(){let e=this.env.model.getters.getActiveSheetId(),t=this.props.filterPosition;return this.env.model.getters.getTable({sheetId:e,...t})}get filterValueType(){let e=this.env.model.getters.getActiveSheetId(),t=this.props.filterPosition;return this.env.model.getters.getFilterValue({sheetId:e,...t})?.filterType}getCriterionCategory(e){let t=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getFilter({sheetId:t,...e});if(!n||!n.filteredRange)return`text`;let r={text:0,number:0,date:0},i=n.filteredRange.zone;for(let n=i.top;n<=i.bottom&&!(n>100);n++){let i=this.env.model.getters.getEvaluatedCell({sheetId:t,row:n,col:e.col});i.type===`text`||i.type===`boolean`?r.text++:i.type===`number`&&(i.format&&fc(i.format)?r.date++:r.number++)}let a=Math.max(r.text,r.number,r.date);return Object.keys(r).find(e=>r[e]===a)||`text`}onUpdateHiddenValues(e){this.updatedCriterionValue={filterType:`values`,hiddenValues:e}}onCriterionChanged(e){this.updatedCriterionValue=e}confirm(){if(!this.updatedCriterionValue){this.props.onClosed?.();return}let e=this.props.filterPosition;this.env.model.dispatch(`UPDATE_FILTER`,{...e,sheetId:this.env.model.getters.getActiveSheetId(),value:this.updatedCriterionValue}),this.props.onClosed?.()}get criterionOperators(){return this.criterionCategory===`date`?ZM:this.criterionCategory===`number`?XM:YM}cancel(){this.props.onClosed?.()}sortFilterZone(e){let t=this.props.filterPosition,n=this.table?.range.zone;if(!t||!n||n.top===n.bottom)return;let r=this.env.model.getters.getActiveSheetId(),i={...n,top:n.top+1},a={col:t.col,row:i.top};II(this.env,r,a,i,e,{emptyCellAsZero:!0,sortHeaders:!0}),this.props.onClosed?.()}getFilterHiddenValues(e){let t=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getFilter({sheetId:t,...e});if(!n?.filteredRange)return[];let r=this.env.model.getters.getFilterValue({sheetId:t,...e}),i=ur(n.filteredRange.zone);r?.filterType!==`criterion`&&(i=i.filter(e=>!this.env.model.getters.isRowHidden(t,e.row)));let a=i.map(e=>this.env.model.getters.getEvaluatedCell({sheetId:t,...e}).formattedValue),o=r?.filterType===`values`?r.hiddenValues:[],s=new Set(o.map(Af)),c=new Set,l=[],u=e=>{let t=Af(e);c.has(t)||(l.push({string:e||``,checked:r?.filterType===`criterion`?!1:!s.has(t),normalizedValue:t}),c.add(t))};return a.forEach(u),o.forEach(u),l.sort((e,t)=>e.normalizedValue.localeCompare(t.normalizedValue,void 0,{numeric:!0,sensitivity:`base`}))}getFilterCriterionValue(e){let t=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getFilterCriterionValue({sheetId:t,...e});return n?.filterType===`criterion`?x(n):{filterType:`criterion`,type:`none`,values:[]}}};let bK={onOpen:(e,t)=>({isOpen:!0,props:{filterPosition:e},Component:yK,cellCorner:`bottom-left`})};var xK=class extends A{static template=`o-spreadsheet-LinkDisplay`;props=(0,t.props)({cellPosition:N.CellPosition(),onClosed:N.function().optional()});cellPopovers;setup(){this.cellPopovers=j(cw)}get cell(){let{col:e,row:t}=this.props.cellPosition,n=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getEvaluatedCell({sheetId:n,col:e,row:t})}get link(){if(this.cell.link)return this.cell.link;let{col:e,row:t}=this.props.cellPosition;throw Error(`LinkDisplay Component can only be used with link cells. ${E(e,t)} is not a link.`)}getUrlRepresentation(e){return Wd(e,this.env.model.getters)}openLink(e){Gd(this.link,this.env,ue(e))}edit(){let{col:e,row:t}=this.props.cellPosition;this.env.model.selection.selectCell(e,t),this.cellPopovers.open({col:e,row:t},`LinkEditor`)}unlink(){let e=this.env.model.getters.getActiveSheetId(),{col:t,row:n}=this.props.cellPosition,r=this.env.model.getters.getCellComputedStyle({sheetId:e,col:t,row:n}),i=r?.textColor===`#017E84`?void 0:r?.textColor;this.env.model.dispatch(`UPDATE_CELL`,{col:t,row:n,sheetId:e,content:this.link.label,style:{...r,textColor:i,underline:void 0}})}};let SK={onHover:(e,t)=>{let n=t.getEvaluatedCell(e);return!t.isDashboard()&&n.link&&t.isVisibleInViewport(e)?{isOpen:!0,Component:xK,props:{cellPosition:e},cellCorner:`bottom-left`}:{isOpen:!1}}};var CK=class extends A{static template=`o-spreadsheet-LinkEditor`;static components={MenuPopover:C_};props=(0,t.props)({cellPosition:N.CellPosition(),onClosed:N.function().optional()});static size={maxHeight:500};urlInput=(0,t.signal)(null);suggestionListRef=(0,t.signal)(null);urlInputContainer=(0,t.signal)(null);state=(0,t.proxy)(this.defaultState);setup(){this.computeLinks(),(0,t.onMounted)(()=>this.urlInput()?.focus())}computeLinks(){this.state.selectedIndex=null,this.state.linksByCategory=this.linkProposalByCategory,this.state.linksList=Object.values(this.state.linksByCategory).flat()}get linkProposalByCategory(){let e={},t=-1,n=this.state.url;for(let r of Bd.getKeys()){let i=Bd.get(r),a=i.getLinkProposals?.(this.env)||[],o=n&&this.state.isUrlEditable?nA(n,a,e=>i.urlRepresentation(e.url,this.env.model.getters)):a;o.length!==0&&(e[i.title]=o.map(e=>{t++;let n=i.urlRepresentation(e.url,this.env.model.getters),r=t;return{text:n,icon:e.icon,index:r,onSelect:()=>{this.state.url=e.url,this.state.label=e.label,this.state.isUrlEditable=e.isUrlEditable,this.state.selectedIndex=r,this.urlInputContainer()?.focus()}}}))}return e}get defaultState(){let{col:e,row:t}=this.props.cellPosition,n=this.env.model.getters.getActiveSheetId(),r=this.env.model.getters.getEvaluatedCell({sheetId:n,col:e,row:t});return r.link?{url:r.link.url,label:r.formattedValue,isUrlEditable:r.link.isUrlEditable,selectedIndex:null,linksByCategory:{},linksList:[]}:{label:r.formattedValue,url:``,isUrlEditable:!0,selectedIndex:null,linksByCategory:{},linksList:[]}}getUrlRepresentation(e){return Wd(e,this.env.model.getters)}removeLink(){this.state.url=``,this.state.isUrlEditable=!0,this.computeLinks()}save(){let{col:e,row:t}=this.props.cellPosition,n=this.env.model.getters.getLocale(),r=this.state.label?q_(this.state.label,n):this.state.url;this.env.model.dispatch(`UPDATE_CELL`,{col:e,row:t,sheetId:this.env.model.getters.getActiveSheetId(),content:Pt(r,this.state.url)}),this.props.onClosed?.()}cancel(){this.props.onClosed?.()}onKeyDown(e){switch(e.key){case`Enter`:this.state.url&&this.save(),e.stopPropagation(),e.preventDefault();break;case`Escape`:this.cancel(),e.stopPropagation();break}}onInputKeyDown(e){switch(e.key){case`Enter`:if(this.state.selectedIndex!==null){let t=this.state.linksList[this.state.selectedIndex];if(t){let n=this.state.url;t.onSelect(),this.state.url!==n&&(e.stopPropagation(),e.preventDefault())}}break;case`ArrowDown`:this.state.selectedIndex=this.state.selectedIndex===null||this.state.selectedIndex===this.state.linksList.length-1?0:(this.state.selectedIndex+1)%this.state.linksList.length,this.showSelectedProposal(),e.stopPropagation(),e.preventDefault();break;case`ArrowUp`:this.state.selectedIndex!==null&&(this.state.selectedIndex=this.state.selectedIndex===0?this.state.linksList.length-1:(this.state.selectedIndex-1)%this.state.linksList.length,this.showSelectedProposal(),e.stopPropagation(),e.preventDefault());break}}showSelectedProposal(){this.suggestionListRef()?.querySelector(`.suggestion-item[data-index="${this.state.selectedIndex}"]`)?.scrollIntoView({block:`nearest`})}};sw.add(`ErrorToolTip`,vK).add(`LinkCell`,SK).add(`LinkEditor`,{onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:CK,cellCorner:`bottom-left`})}).add(`FilterMenu`,bK),rA.add(`dataValidation`,{displayAllOnInitialContent:!0,canBeToggled:!1,getProposals(e,t){if(vn(t)||!this.composer.currentEditedCell)return[];let n=this.composer.currentEditedCell,r=this.getters.getValidationRuleForCell(n);if(!r||r.criterion.type!==`isValueInList`&&r.criterion.type!==`isValueInRange`)return[];let i=this.composer.currentEditedCell.sheetId,a=r.criterion.type===`isValueInRange`?this.getters.getDataValidationRangeValues(i,r.criterion):r.criterion.values.map(e=>({label:e,value:e}));if(r.criterion.displayStyle!==`chip`)return a.map(e=>({text:e.value,fuzzySearchKey:e.label,htmlContent:[{value:e.label}]}));let o=r.criterion.colors;return a.map(e=>{let t=o?.[e.value];return{text:e.value,htmlContent:[{value:e.label,color:vp(t||`#E7E9ED`),backgroundColor:t||`#E7E9ED`,classes:[`badge rounded-pill fs-6 fw-normal w-100 mt-1 text-start`]}],fuzzySearchKey:e.label}})},selectProposal(e,t){this.composer.setCurrentContent(t.text),this.composer.stopEdition()}}),rA.add(`functions_and_named_ranges`,{sequence:100,autoSelectFirstProposal:!0,maxDisplayedProposals:10,getProposals(e){if(e.type!==`SYMBOL`)return[];let t=e.value;if(!vn(this.composer.currentContent))return[];let n=Object.entries(il.content).filter(([e,{hidden:t}])=>!t).map(([e,{description:n}])=>({type:`function`,text:e,icon:`o-spreadsheet-Icon.FX_SVG`,description:n,htmlContent:iN(t,e,Me,`o-semi-bold`)}));return n.push(...this.getters.getNamedRanges().map(e=>({type:`named_range`,text:e.name,description:this.getters.getRangeString(e.range),icon:`o-spreadsheet-Icon.NAMED_RANGE`,htmlContent:iN(t,e.name,Me,`o-semi-bold`)}))),n.sort((e,t)=>e.text.length-t.text.length||e.text.localeCompare(t.text)),n},selectProposal(e,t){let n=e.end,r=e.end;[`SYMBOL`,`FUNCTION`].includes(e.type)&&(n=e.start);let i=this.composer.currentTokens,a=t.text;if(t.type===`function`){a+=`(`;let t=i.map(e=>e.start).indexOf(e.start);t+1<i.length&&i[t+1]?.type===`LEFT_PAREN`&&r++}this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(a)}});function wK(e,t){for(let n=0;n<t.length;n++){let r=t[n].proposalValues;r===void 0||r.length===0||rA.add(`${e}_function_${t[n].name}_argument_proposals`,{sequence:50,autoSelectFirstProposal:!0,selectProposal:TK,getProposals:t=>{let i=t.functionContext;if(!i||i.parent.toUpperCase()!==e.toUpperCase()||i.argPosition!==n)return;let a=[],o=``;for(let{value:e,label:t}of r){switch(typeof e){case`string`:o=`"${e}"`;break;case`number`:o=e.toString();break;case`boolean`:o=e?`TRUE`:`FALSE`;break;default:}a.push({text:o,description:t,htmlContent:[{value:o,color:typeof e==`string`?pt.STRING:pt.NUMBER}],fuzzySearchKey:o,alwaysExpanded:!0})}return a}})}}function TK(e,t){let n=e.end,r=e.end;[`LEFT_PAREN`,`ARG_SEPARATOR`].includes(e.type)||(n=e.start),this.composer.stopComposerRangeSelection(),this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t.text)}il.getAll().forEach(e=>wK(e.name,e.args)),rA.add(`pivot_ids`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||![`PIVOT.VALUE`,`PIVOT.HEADER`,`PIVOT`].includes(t.parent.toUpperCase())||t.argPosition!==0)return;let n=this.getters.getPivotIds();if(!n.includes(e.value))return n.map(e=>{let t=this.getters.getPivotCoreDefinition(e),n=`${this.getters.getPivotFormulaId(e)}`;return{text:n,description:t.name,htmlContent:[{value:n,color:pt.NUMBER}],fuzzySearchKey:n+t.name,alwaysExpanded:!0}}).filter(w)},selectProposal:TK}),rA.add(`pivot_measures`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(t?.parent.toUpperCase()!==`PIVOT.VALUE`||t.argPosition!==1)return[];let n=iP(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return[];let i=this.getters.getPivot(r);return i.init(),i.isValid()?i.definition.measures.map(e=>{if(e.fieldName===`__count`){let e=`"__count"`;return{text:e,description:P(`Count`),htmlContent:[{value:e,color:pt.STRING}],fuzzySearchKey:P(`Count`)+e}}return tP(e)}).filter(w):[]},selectProposal:TK}),rA.add(`pivot_group_fields`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!EK(e)&&!DK(e))return;let n=iP(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return;let i=this.getters.getPivot(r);i.init();let a=i.getFields(),{columns:o,rows:s}=i.definition,c=t.args;t?.parent.toUpperCase()===`PIVOT.VALUE`?(c=c.filter((e,t)=>t%2==0),c=c.slice(1,t.argPosition)):c=c.filter((e,t)=>t%2==1);let l=c.map(e=>e?.value).filter(w),u=o.map(e=>e.nameWithGranularity),d=s.map(e=>e.nameWithGranularity),f=[],p=[`ARG_SEPARATOR`,`SPACE`].includes(e.type)?l.at(-1):l.at(-2),m=kR.get(i.type);if(m&&p?.startsWith(`#`)&&(p=p.slice(1)),p===void 0&&(f.push(u[0]),f.push(d[0])),d.includes(p)){let e=d[d.indexOf(p)+1];f.push(e),f.push(u[0])}if(u.includes(p)){let e=u[u.indexOf(p)+1];f.push(e)}let h=f.filter(w);return h.map(e=>{let[t,n]=e.split(`:`),r=a[t];return r?eP(r,n):void 0}).concat(h.map(e=>{if(!m)return;let t=a[e.split(`:`)[0]];if(!t)return;let n=`"#${e}"`;return{text:n,description:P(`%s (positional)`,t.string)+(t.help?` (${t.help})`:``),htmlContent:[{value:n,color:pt.STRING}],fuzzySearchKey:t.string+n}})).filter(w)},selectProposal:TK});function EK(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==0}function DK(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==1}rA.add(`pivot_group_values`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!e||!OK(e)&&!kK(e))return;let n=iP(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return;let i=this.getters.getPivot(r);if(!i.isValid())return;let a=t.argPosition,o=e.functionContext?.args[a-1]?.value;if(!o)return;let s;try{s=i.definition.getDimension(o)}catch{return}return s.granularity===`month_number`?Object.values(Xs).map((e,t)=>({text:`${t+1}`,fuzzySearchKey:e.toString(),description:e.toString(),htmlContent:[{value:`${t+1}`,color:pt.NUMBER}]})):s.granularity===`quarter_number`?[1,2,3,4].map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:P(`Quarter %s`,e),htmlContent:[{value:`${e}`,color:pt.NUMBER}]})):s.granularity===`day_of_month`?C(1,32).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:pt.NUMBER}]})):s.granularity===`iso_week_number`?C(0,54).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:pt.NUMBER}]})):s.granularity===`day_of_week`?C(1,8).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:pt.NUMBER}]})):s.granularity===`hour_number`?C(0,24).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:pt.NUMBER}]})):s.granularity===`minute_number`?C(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:pt.NUMBER}]})):s.granularity===`second_number`?C(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:pt.NUMBER}]})):i.getPossibleFieldValues(s).map(({value:e,label:t})=>{let n=typeof e==`string`,r=n?`"${e}"`:e.toString(),i=n?pt.STRING:pt.NUMBER,a=t===e?``:t;return{text:r,description:a,htmlContent:[{value:r,color:i}],fuzzySearchKey:r+a}})},selectProposal:TK});function OK(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==1}function kK(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==0}rA.add(`sheet_names`,{sequence:150,autoSelectFirstProposal:!0,getProposals(e){return e.type===`SYMBOL`||e.type===`UNKNOWN`&&e.value.startsWith(`'`)?this.getters.getSheetIds().map(e=>{let t=Tt(this.getters.getSheetName(e));return{text:t,fuzzySearchKey:t.startsWith(`'`)?t:`'`+t}}):[]},selectProposal(e,t){let n=e.start,r=e.end;this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t.text+`!`)}});function AK(e){return e.yRanges.length&&!dl.test(e.yRanges[0])?`InvalidYRange`:e.xRange&&!dl.test(e.xRange)?`InvalidXRange`:e.labelRange&&!dl.test(e.labelRange)?`InvalidLabelRange`:e.sizeRange&&!dl.test(e.sizeRange)?`InvalidBubbleSizeRange`:`Success`}let jK={sequence:40,allowedDefinitionKeys:[...Rh.commonKeys,`yRanges`,`xRange`,`labelRange`,`sizeRange`,`dataSetsHaveTitle`,`verticalAxisPosition`,`labelsAsText`,`bubbleColor`,`legendPosition`,`axesDesign`,`showValues`],fromStrDefinition(e,t,n){let r=e.yRanges.map(e=>wu(n,t,e)).filter(w),i=wu(n,t,e.xRange),a=wu(n,t,e.labelRange),o=wu(n,t,e.sizeRange);return{...e,yRanges:r,xRange:i,labelRange:a,sizeRange:o}},toStrDefinition(e,t,n){return{...e,yRanges:e.yRanges.map(e=>n.getRangeString(e,t)),xRange:e.xRange?n.getRangeString(e.xRange,t):void 0,labelRange:e.labelRange?n.getRangeString(e.labelRange,t):void 0,sizeRange:e.sizeRange?n.getRangeString(e.sizeRange,t):void 0}},validateDefinition(e,t){return e.checkValidations(t,AK)},transformDefinition(e,t,{adaptRangeString:n}){let r=e=>{if(!e)return;let{changeType:r,range:i}=n(t,e);return r===`REMOVE`?void 0:i};return{...e,yRanges:e.yRanges.map(r).filter(w),xRange:r(e.xRange),sizeRange:r(e.sizeRange),labelRange:r(e.labelRange)}},getDefinitionFromContextCreation(e,t){let n=e.dataSource?.type===`range`;return{background:e.background,yRanges:n?e.dataSource.dataSets?.map(e=>e.dataRange)??[]:[],verticalAxisPosition:e.dataSetStyles?.[0]?.verticalAxisPosition,dataSetsHaveTitle:n?e.dataSource.dataSetsHaveTitle??!1:!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`bubble`,labelRange:e.bubbleLabelRange||void 0,labelsAsText:e.labelsAsText??!1,xRange:e.auxiliaryRange||void 0,sizeRange:e.bubbleSizeRange||void 0,axesDesign:e.axesDesign,showValues:e.showValues,humanize:e.humanize,annotationText:e.annotationText,annotationLink:e.annotationLink,bubbleColor:e.bubbleColorMode||{color:`multiple`}}},getContextCreation(e,t){return{...e,dataSource:{type:`range`,dataSets:e.yRanges.map((e,t)=>({dataSetId:`${t}`,dataRange:e}))},bubbleLabelRange:e.labelRange,auxiliaryRange:e.xRange,bubbleSizeRange:e.sizeRange,bubbleColorMode:e.bubbleColor}},getDefinitionForExcel:()=>void 0,updateRanges(e,t){let n=e.yRanges.map(e=>tm(e,t)).filter(w),r=tm(e.xRange,t),i=tm(e.labelRange,t),a=tm(e.sizeRange,t);return{...e,yRanges:n,xRange:r,labelRange:i,sizeRange:a}},duplicateInDuplicatedSheet(e,t,n){let r=e=>em(t,n,e);return{...e,yRanges:e.yRanges.map(r).filter(w),xRange:r(e.xRange),labelRange:r(e.labelRange),sizeRange:r(e.sizeRange)}},copyInSheetId:e=>e,getRuntime(e,t){let n=DD(t,e);return{chartJsConfig:{type:`line`,data:{datasets:ch(t,n),labels:n.labels},options:{...Sg,layout:QD(t,n),scales:Um(t,n),plugins:{title:PO(t,e),legend:_O(t,n),tooltip:VO(t,n),chartShowValuesPlugin:OO(t,n),background:{color:t.background}}}}}}};function MK(e){return!wk.includes(e.horizontalGroupBy)||!wk.includes(e.verticalGroupBy)?`InvalidChartDefinition`:`Success`}let NK={sequence:110,dataSeriesLimit:1,allowedDefinitionKeys:[...Rh.commonKeys,`dataSource`,`dataSetStyles`,`showValues`,`colorScale`,`missingValueColor`,`axesDesign`,`horizontalGroupBy`,`verticalGroupBy`,`legendPosition`],validateDefinition(e,t){return e.checkValidations(t,MK)},fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,updateRanges:e=>e,getContextCreation:e=>e,getDefinitionFromContextCreation(e,t){let n=`left`;return e.legendPosition===`right`&&(n=`right`),{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},title:e.title||{text:``},type:`calendar`,showValues:e.showValues,axesDesign:e.axesDesign,legendPosition:n,horizontalGroupBy:`day_of_week`,verticalGroupBy:`month_number`,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractData:n}){let r=yD(t,n(),e),{labels:i,datasets:a}=ih(t,r);return{chartJsConfig:{type:`calendar`,data:{labels:i,datasets:a},options:{...Sg,indexAxis:`x`,layout:$D(t,r),scales:Lm(t,a),plugins:{title:PO(t,e),legend:{display:!1},tooltip:zO(t,r),chartShowValuesPlugin:kO(t,r),chartColorScalePlugin:Rm(t,r),background:{color:r.background}}}}}}},PK={sequence:15,allowedDefinitionKeys:[...Rh.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`aggregated`,`axesDesign`,`showValues`,`hideDataMarkers`,`zoomable`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getDefinitionForExcel(e,t,{dataSets:n,labelRange:r}){return{...t,backgroundColor:lD(t.background||`#FFFFFF`),fontColor:lD(om(t.background)),dataSets:n,labelRange:r,verticalAxis:fm(t)}},getDefinitionFromContextCreation(e,t){let n=e.dataSetStyles??{};if(e.dataSource?.type===`range`){let t=e.dataSource?.dataSets?.[0]?.dataSetId;for(let r of e.dataSource?.dataSets||[])n[r.dataSetId]={...e.dataSetStyles?.[r.dataSetId]||{},type:r.dataSetId===t?`bar`:`line`}}return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:n,aggregated:e.aggregated,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`combo`,axesDesign:e.axesDesign,showValues:e.showValues,hideDataMarkers:e.hideDataMarkers,zoomable:e.zoomable,humanize:e.humanize,annotationText:e.annotationText,annotationLink:e.annotationLink}},getRuntime(e,t,{extractData:n},r,i){let a=gD(t,n(),e);return{chartJsConfig:{type:`bar`,data:{labels:a.labels,datasets:dh(t,a)},options:{...Sg,layout:QD(t,a),scales:Im(t,a),plugins:{title:PO(t,e),legend:vO(t,a),tooltip:RO(t,a),chartShowValuesPlugin:OO(t,a),background:{color:a.background}},...i}},customizableSeries:a.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},FK={sequence:100,dataSeriesLimit:1,allowedDefinitionKeys:[...Rh.commonKeys,`dataSource`,`dataSetStyles`,`axesDesign`,`legendPosition`,`horizontal`,`aggregated`,`showValues`,`funnelColors`,`cumulative`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},aggregated:e.aggregated??!1,legendPosition:`none`,title:e.title||{text:``},type:`funnel`,showValues:e.showValues,axesDesign:e.axesDesign,funnelColors:e.funnelColors,horizontal:!0,cumulative:e.cumulative??!0,humanize:e.humanize,annotationText:e.annotationText,annotationLink:e.annotationLink}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractData:n},r,i){let a=TD(t,n(),e);return{chartJsConfig:{type:`funnel`,data:{labels:a.labels,datasets:mh(t,a)},options:{...Sg,indexAxis:`y`,layout:QD(t,a),scales:Jm(t,a),plugins:{title:PO(t,e),legend:{display:!1},tooltip:qO(t,a),chartShowValuesPlugin:OO(t,a),background:{color:a.background}},...i}}}}},IK={sequence:90,dataSeriesLimit:1,allowedDefinitionKeys:[...Rh.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`colorScale`,`missingValueColor`,`region`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`geo`,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractData:n},r,i){let a=wD(t,n(),e);return{chartJsConfig:{type:`choropleth`,data:{datasets:ph(t,a)},options:{...Sg,layout:QD(t,a),scales:qm(t,a),plugins:{title:PO(t,e),tooltip:KO(t,a),legend:{display:!1},background:{color:a.background}},...i}}}}},LK={sequence:80,dataSeriesLimit:2,allowedDefinitionKeys:[...Rh.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showValues`,`aggregated`,`axesDesign`,`stacked`,`horizontal`],fromStrDefinition:e=>({...e,horizontal:!0,stacked:!0}),toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},aggregated:e.aggregated??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`pyramid`,axesDesign:e.axesDesign,horizontal:!0,stacked:!0,showValues:e.showValues,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel(e,t,{dataSets:n,labelRange:r}){if(t.dataSource.type!==`range`)return;let i=bD(t,yk(e,t.dataSource),e),{dataSetsValues:a}=i,o=Math.max(...a.map(e=>Math.max(...e.data.map(e=>tf(e)?Math.abs(e.value):-1/0))));return{...t,horizontal:!0,backgroundColor:lD(i.background||`#FFFFFF`),fontColor:lD(om(i.background)),dataSets:n,labelRange:r,verticalAxis:fm(t),maxValue:o}},getRuntime(e,t,{extractData:n},r,i){let a=bD(t,n(),e);return{chartJsConfig:{type:`bar`,data:{labels:a.labels,datasets:nh(t,a)},options:{...Sg,indexAxis:`y`,layout:QD(t,a),scales:Gm(t,a),plugins:{title:PO(t,e),legend:pO(t,a),tooltip:WO(t,a),chartShowValuesPlugin:jO(t,a),background:{color:a.background}},...i}},customizableSeries:a.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},RK={sequence:80,allowedDefinitionKeys:[...Rh.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showValues`,`aggregated`,`stacked`,`fillArea`,`hideDataMarkers`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},stacked:e.stacked??!1,aggregated:e.aggregated??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`radar`,fillArea:e.fillArea??!1,showValues:e.showValues??!1,hideDataMarkers:e.hideDataMarkers,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel(e,t,{dataSets:n,labelRange:r}){return{...t,backgroundColor:lD(t.background||`#FFFFFF`),fontColor:lD(om(t.background)),dataSets:n,labelRange:r}},getRuntime(e,t,{extractData:n},r,i){let a=CD(t,n(),e);return{chartJsConfig:{type:`radar`,data:{labels:a.labels,datasets:fh(t,a)},options:{...Sg,layout:QD(t,a),scales:Km(t,a),plugins:{title:PO(t,e),legend:bO(t,a),tooltip:GO(t,a),chartShowValuesPlugin:OO(t,a),background:{color:a.background}},...i}},customizableSeries:a.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},zK={sequence:60,allowedDefinitionKeys:[...Rh.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showValues`,`labelsAsText`,`aggregated`,`axesDesign`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},labelsAsText:e.labelsAsText??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`scatter`,aggregated:e.aggregated??!1,axesDesign:e.axesDesign,showValues:e.showValues,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel(e,t,{dataSets:n,labelRange:r}){return{...t,backgroundColor:lD(t.background||`#FFFFFF`),fontColor:lD(om(t.background)),dataSets:n,labelRange:r,verticalAxis:fm(t)}},getRuntime(e,t,{extractData:n},r,i){let a=xD(t,n(),e);return{chartJsConfig:{type:`line`,data:{labels:a.labels,datasets:sh(t,a)},options:{...Sg,layout:QD(t,a),scales:Hm(t,a),plugins:{title:PO(t,e),legend:gO(t,a),tooltip:BO(t,a),chartShowValuesPlugin:OO(t,a),background:{color:a.background}},...i}},customizableSeries:a.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},BK={sequence:30,allowedDefinitionKeys:[...Rh.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showValues`,`showLabels`,`valuesDesign`,`groupColors`,`pieHolePercentage`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getDefinitionFromContextCreation(e,t){return{background:e.background,dataSetStyles:e.dataSetStyles??{},dataSource:t.fromHierarchicalContextCreation(e),legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`sunburst`,showValues:e.showValues,showLabels:e.showLabels,valuesDesign:e.valuesDesign,groupColors:e.groupColors,humanize:e.humanize,pieHolePercentage:e.pieHolePercentage,annotationLink:e.annotationLink,annotationText:e.annotationText}},getContextCreation(e,t,n){return{...e,...t.getHierarchicalContextCreation(n)}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractHierarchicalData:n},r,i){let a=ED(t,n(),e);return{chartJsConfig:{type:`doughnut`,data:{datasets:gh(t,a)},options:{cutout:t.pieHolePercentage===void 0?`25%`:`${t.pieHolePercentage}%`,...Sg,layout:QD(t,a),plugins:{title:PO(t,e),legend:xO(t,a),tooltip:JO(t,a),sunburstLabelsPlugin:AO(t,a),sunburstHoverPlugin:{enabled:!0},background:{color:a.background}},...i}}}}},VK={sequence:100,allowedDefinitionKeys:[...Rh.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showHeaders`,`headerDesign`,`showLabels`,`valuesDesign`,`coloringOptions`,`showValues`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getDefinitionFromContextCreation(e,t){return{background:e.background,dataSetStyles:e.dataSetStyles??{},dataSource:t.fromHierarchicalContextCreation(e),legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`treemap`,showValues:e.showValues,showHeaders:e.showHeaders,headerDesign:e.headerDesign,showLabels:e.showLabels,valuesDesign:e.valuesDesign,coloringOptions:e.treemapColoringOptions,humanize:e.humanize,annotationText:e.annotationText,annotationLink:e.annotationLink}},getContextCreation(e,t,n){return{...e,treemapColoringOptions:e.coloringOptions,...t.getHierarchicalContextCreation(n)}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractHierarchicalData:n},r,i){let a=ED(t,n(),e);return{chartJsConfig:{type:`treemap`,data:{labels:a.labels,datasets:xh(t,a)},options:{...Sg,layout:QD(t,a),plugins:{title:PO(t,e),legend:{display:!1},tooltip:YO(t,a),background:{color:a.background}},...i}}}}};wb.add(`bar`,$O),wb.add(`combo`,PK),wb.add(`line`,uk),wb.add(`pie`,dk),wb.add(`scorecard`,Jh),wb.add(`gauge`,ak),wb.add(`scatter`,zK),wb.add(`waterfall`,fk),wb.add(`pyramid`,LK),wb.add(`radar`,RK),wb.add(`geo`,IK),wb.add(`funnel`,FK),wb.add(`sunburst`,BK),wb.add(`treemap`,VK),wb.add(`calendar`,NK),wb.add(`bubble`,jK),Vg.add(`line`,{matcher:e=>e.type===`line`&&!e.stacked&&!e.fillArea,displayName:P(`Line`),chartType:`line`,chartSubtype:`line`,subtypeDefinition:{stacked:!1,fillArea:!1},category:`line`,preview:`o-spreadsheet-ChartPreview.LINE_CHART`}).add(`stacked_line`,{matcher:e=>e.type===`line`&&!e.fillArea&&!!e.stacked,displayName:P(`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=>e.type===`line`&&!e.stacked&&!!e.fillArea,displayName:P(`Area`),chartType:`line`,chartSubtype:`area`,subtypeDefinition:{stacked:!1,fillArea:!0},category:`area`,preview:`o-spreadsheet-ChartPreview.AREA_CHART`}).add(`stacked_area`,{matcher:e=>e.type===`line`&&e.stacked&&!!e.fillArea,displayName:P(`Stacked Area`),chartType:`line`,chartSubtype:`stacked_area`,subtypeDefinition:{stacked:!0,fillArea:!0},category:`area`,preview:`o-spreadsheet-ChartPreview.STACKED_AREA_CHART`}).add(`scatter`,{displayName:P(`Scatter`),chartType:`scatter`,chartSubtype:`scatter`,category:`misc`,preview:`o-spreadsheet-ChartPreview.SCATTER_CHART`}).add(`bubble`,{displayName:P(`Bubble`),chartType:`bubble`,chartSubtype:`bubble`,category:`misc`,preview:`o-spreadsheet-ChartPreview.BUBBLE_CHART`}).add(`column`,{matcher:e=>e.type===`bar`&&!e.stacked&&!e.horizontal,displayName:P(`Column`),chartType:`bar`,chartSubtype:`column`,subtypeDefinition:{stacked:!1,horizontal:!1},category:`column`,preview:`o-spreadsheet-ChartPreview.COLUMN_CHART`}).add(`stacked_column`,{matcher:e=>e.type===`bar`&&e.stacked&&!e.horizontal,displayName:P(`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=>e.type===`bar`&&!e.stacked&&!!e.horizontal,displayName:P(`Bar`),chartType:`bar`,chartSubtype:`bar`,subtypeDefinition:{horizontal:!0,stacked:!1},category:`bar`,preview:`o-spreadsheet-ChartPreview.BAR_CHART`}).add(`stacked_bar`,{matcher:e=>e.type===`bar`&&e.stacked&&!!e.horizontal,displayName:P(`Stacked Bar`),chartType:`bar`,chartSubtype:`stacked_bar`,subtypeDefinition:{horizontal:!0,stacked:!0},category:`bar`,preview:`o-spreadsheet-ChartPreview.STACKED_BAR_CHART`}).add(`combo`,{displayName:P(`Combo`),chartSubtype:`combo`,chartType:`combo`,category:`line`,preview:`o-spreadsheet-ChartPreview.COMBO_CHART`}).add(`pie`,{matcher:e=>e.type===`pie`&&!e.isDoughnut,displayName:P(`Pie`),chartSubtype:`pie`,chartType:`pie`,subtypeDefinition:{isDoughnut:!1},category:`pie`,preview:`o-spreadsheet-ChartPreview.PIE_CHART`}).add(`doughnut`,{matcher:e=>e.type===`pie`&&!!e.isDoughnut,displayName:P(`Doughnut`),chartSubtype:`doughnut`,chartType:`pie`,subtypeDefinition:{isDoughnut:!0},category:`pie`,preview:`o-spreadsheet-ChartPreview.DOUGHNUT_CHART`}).add(`gauge`,{displayName:P(`Gauge`),chartSubtype:`gauge`,chartType:`gauge`,category:`misc`,preview:`o-spreadsheet-ChartPreview.GAUGE_CHART`}).add(`scorecard`,{displayName:P(`Scorecard`),chartSubtype:`scorecard`,chartType:`scorecard`,category:`misc`,preview:`o-spreadsheet-ChartPreview.SCORECARD_CHART`}).add(`waterfall`,{displayName:P(`Waterfall`),chartSubtype:`waterfall`,chartType:`waterfall`,category:`misc`,preview:`o-spreadsheet-ChartPreview.WATERFALL_CHART`}).add(`pyramid`,{displayName:P(`Population Pyramid`),chartSubtype:`pyramid`,chartType:`pyramid`,category:`misc`,preview:`o-spreadsheet-ChartPreview.POPULATION_PYRAMID_CHART`}).add(`radar`,{matcher:e=>e.type===`radar`&&!e.fillArea,displayName:P(`Radar`),chartSubtype:`radar`,chartType:`radar`,subtypeDefinition:{fillArea:!1},category:`misc`,preview:`o-spreadsheet-ChartPreview.RADAR_CHART`}).add(`filled_radar`,{matcher:e=>e.type===`radar`&&!!e.fillArea,displayName:P(`Filled Radar`),chartType:`radar`,chartSubtype:`filled_radar`,subtypeDefinition:{fillArea:!0},category:`misc`,preview:`o-spreadsheet-ChartPreview.FILLED_RADAR_CHART`}).add(`geo`,{displayName:P(`Geo Chart`),chartSubtype:`geo`,chartType:`geo`,category:`misc`,preview:`o-spreadsheet-ChartPreview.GEO_CHART`}).add(`funnel`,{displayName:P(`Funnel`),chartSubtype:`funnel`,chartType:`funnel`,category:`misc`,preview:`o-spreadsheet-ChartPreview.FUNNEL_CHART`}).add(`sunburst`,{matcher:e=>e.type===`sunburst`,displayName:P(`Sunburst`),chartSubtype:`sunburst`,chartType:`sunburst`,category:`hierarchical`,preview:`o-spreadsheet-ChartPreview.SUNBURST_CHART`}).add(`treemap`,{matcher:e=>e.type===`treemap`,displayName:P(`Tree Map`),chartType:`treemap`,chartSubtype:`treemap`,category:`hierarchical`,preview:`o-spreadsheet-ChartPreview.TREE_MAP_CHART`}).add(`calendar`,{displayName:P(`Calendar`),chartSubtype:`calendar`,chartType:`calendar`,category:`misc`,preview:`o-spreadsheet-ChartPreview.CALENDAR_CHART`}),Nz.add(`filter_icon`,(e,t)=>{if(e.isFilterHeader(t)){let n=e.isFilterActive(t),r=ep(e.getCellComputedStyle(t).fillColor||`#fff`)<.45;return{type:`filter_icon`,svg:Ny(n,r,!1),hoverSvg:Ny(n,r,!0),priority:3,horizontalAlign:`right`,size:17,margin:2,position:t,onClick:(e,t)=>{let n=t.getStore(cw),r=n.persistentCellPopover;if(r.isOpen&&r.col===e.col&&r.row===e.row&&r.type===`FilterMenu`){n.close();return}n.open(e,`FilterMenu`)}}}});var HK=l({ARRAYTOTEXT:()=>_q,ARRAY_CONSTRAIN:()=>GK,ARRAY_LITERAL:()=>KK,ARRAY_ROW:()=>qK,CHOOSECOLS:()=>JK,CHOOSEROWS:()=>YK,EXPAND:()=>XK,FLATTEN:()=>ZK,FREQUENCY:()=>QK,HSTACK:()=>$K,MDETERM:()=>eq,MINVERSE:()=>tq,MMULT:()=>nq,SUMPRODUCT:()=>rq,SUMX2MY2:()=>aq,SUMX2PY2:()=>oq,SUMXMY2:()=>sq,TOCOL:()=>uq,TOROW:()=>dq,TRANSPOSE:()=>fq,VSTACK:()=>pq,WRAPCOLS:()=>mq,WRAPROWS:()=>hq});function UK(e,t){let n=e.map(B),r=n.map(e=>e?.[0]?.length??0),i=Math.max(...r);if(t?.requireSameRowCount){let e=r[0];if(r.some(t=>t!==e))return new I(P(`All ranges in [[FUNCTION_NAME]] must have the same number of rows (got %s).`,r.join(`, `)))}let a=[];for(let e of n)for(let t=0;t<e.length;t++){let n=Array(i).fill({value:null});for(let r=0;r<e[t].length;r++)n[r]=e[t][r];a.push(n)}return a}function WK(e,t){let n=e.map(B),r=n.map(e=>e?.length??0),i=Math.max(...r);if(t?.requireSameColCount){let e=r[0];if(r.some(t=>t!==e))return new I(P(`All ranges in [[FUNCTION_NAME]] must have the same number of columns (got %s).`,r.join(`, `)))}let a=ns(i,n.reduce((e,t)=>e+(t?.[0]?.length??0),0),()=>({value:null})),o=0;for(let e of n){for(let t=0;t<e.length;t++)for(let n=0;n<e[t].length;n++)a[t][o+n]=e[t][n];o+=e[0]?.length??0}return a}let GK={description:P(`Returns a result array constrained to a specific width and height.`),args:[U(`input_range (any, range<any>)`,P(`The range to constrain.`)),U(`rows (number)`,P(`The number of rows in the constrained array.`)),U(`columns (number)`,P(`The number of columns in the constrained array.`))],compute:function(e,t,n){let r=B(e),i=Ho(t?.value,this.locale),a=Ho(n?.value,this.locale);if(i<=0)return new I(P(`The rows argument (%s) must be strictly positive.`,i.toString()));if(a<=0)return new I(P(`The columns argument (%s) must be strictly positive.`,a.toString()));let o=Math.min(i,r[0].length);return ns(Math.min(a,r.length),o,(e,t)=>r[e][t])},isExported:!1},KK={description:P(`Appends ranges vertically and in sequence to return a larger array. All ranges must have the same number of columns.`),args:[U(`range (any, range<any>, repeating)`,P(`The range to be appended.`))],compute:function(...e){return WK(e,{requireSameColCount:!0})},isExported:!1,hidden:!0},qK={description:P(`Appends ranges horizontally and in sequence to return a larger array. All ranges must have the same number of rows.`),args:[U(`range (any, range<any>, repeating)`,P(`The range to be appended.`))],compute:function(...e){return UK(e,{requireSameRowCount:!0})},isExported:!1,hidden:!0},JK={description:P(`Creates a new array from the selected columns in the existing range.`),args:[U(`array (any, range<any>)`,P(`The array that contains the columns to be returned.`)),U(`col_num (number, range<number>, repeating)`,P(`The column index of the column to be returned.`))],compute:function(e,...t){let n=B(e),r=_s(t,e=>Ho(e?.value,this.locale)),i=r.filter(e=>e===0||n.length<Math.abs(e));if(i.length!==0)return new I(P(`The columns arguments must be between -%s and %s (got %s), excluding 0.`,n.length.toString(),n.length.toString(),i.join(`,`)));let a=Array(r.length);for(let e=0;e<r.length;e++)r[e]>0?a[e]=n[r[e]-1]:a[e]=n[n.length+r[e]];return a},isExported:!0},YK={description:P(`Creates a new array from the selected rows in the existing range.`),args:[U(`array (any, range<any>)`,P(`The array that contains the rows to be returned.`)),U(`row_num (number, range<number>, repeating)`,P(`The row index of the row to be returned.`))],compute:function(e,...t){let n=B(e),r=_s(t,e=>Ho(e?.value,this.locale)),i=n.length,a=r.filter(e=>e===0||n[0].length<Math.abs(e));return a.length===0?ns(i,r.length,(e,t)=>r[t]>0?n[e][r[t]-1]:n[e][n[e].length+r[t]]):new I(P(`The rows arguments must be between -%s and %s (got %s), excluding 0.`,n[0].length.toString(),n[0].length.toString(),a.join(`,`)))},isExported:!0},XK={description:P(`Expands or pads an array to specified row and column dimensions.`),args:[U(`array (any, range<any>)`,P(`The array to expand.`)),U(`rows (number)`,P(`The number of rows in the expanded array. If missing, rows will not be expanded.`)),U(`columns (number, optional)`,P(`The number of columns in the expanded array. If missing, columns will not be expanded.`)),U(`pad_with (any, default=0)`,P(`The value with which to pad.`))],compute:function(e,t,n,r={value:0}){let i=B(e),a=Ho(t?.value,this.locale),o=n===void 0?i.length:Ho(n.value,this.locale);return a<i[0].length?new I(P(`The rows arguments (%s) must be greater or equal than the number of rows of the array.`,a.toString())):o<i.length?new I(P(`The columns arguments (%s) must be greater or equal than the number of columns of the array.`,o.toString())):ns(o,a,(e,t)=>e>=i.length||t>=i[e].length?r:i[e][t])},isExported:!0},ZK={description:P(`Flattens all the values from one or more ranges into a single column.`),args:[U(`range (any, range<any>, repeating)`,P(`The range to flatten.`))],compute:function(...e){return[_s(e,e=>e===void 0?{value:``}:e)]},isExported:!1},QK={description:P(`Calculates the frequency distribution of a range.`),args:[U(`data (range<number>)`,P(`The array of ranges containing the values to be counted.`)),U(`classes (number, range<number>)`,P(`The range containing the set of classes.`))],compute:function(e,t){let n=_s([e],e=>e.value).filter(e=>typeof e==`number`),r=_s([t],e=>e.value).filter(e=>typeof e==`number`).map((e,t)=>({initialIndex:t,value:e,count:0})).sort((e,t)=>e.value-t.value);r.push({initialIndex:r.length,value:1/0,count:0});let i=n.sort((e,t)=>e-t),a=0;for(let e of i){for(;e>r[a].value&&a<r.length-1;)a++;r[a].count++}return[r.sort((e,t)=>e.initialIndex-t.initialIndex).map(e=>e.count)]},isExported:!0},$K={description:P(`Appends ranges horizontally and in sequence to return a larger array.`),args:[U(`range (any, range<any>, repeating)`,P(`The range to be appended.`))],compute:function(...e){return UK(e)},isExported:!0},eq={description:P(`Returns the matrix determinant of a square matrix.`),args:[U(`square_matrix (number, range<number>)`,P(`An range with an equal number of rows and columns representing a matrix whose determinant will be calculated.`))],compute:function(e){let t=Bo(e,`square_matrix`);return uS(t)?pS(t).determinant:new I(P(`The argument square_matrix must have the same number of columns and rows.`))},isExported:!0},tq={description:P(`Returns the multiplicative inverse of a square matrix.`),args:[U(`square_matrix (number, range<number>)`,P(`An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated.`))],compute:function(e){let t=Bo(e,`square_matrix`);if(!uS(t))return new I(P(`The argument square_matrix must have the same number of columns and rows.`));let{inverted:n}=pS(t);return n||new I(P(`The matrix is not invertible.`))},isExported:!0},nq={description:P(`Calculates the matrix product of two matrices.`),args:[U(`matrix1 (number, range<number>)`,P(`The first matrix in the matrix multiplication operation.`)),U(`matrix2 (number, range<number>)`,P(`The second matrix in the matrix multiplication operation.`))],compute:function(e,t){let n=Bo(e,`matrix1`),r=Bo(t,`matrix2`);return n.length===0||r.length===0?new I(P(`The first and second arguments of [[FUNCTION_NAME]] must be non-empty matrices.`)):n.length===r[0].length?hS(n,r):new I(P(`In [[FUNCTION_NAME]], the number of columns of the first matrix (%s) must be equal to the number of rows of the second matrix (%s).`,n.length.toString(),r[0].length.toString()))},isExported:!0},rq={description:P(`Calculates the sum of the products of corresponding entries in equal-sized ranges.`),args:[U(`range (number, range<number>, repeating)`,P(`The range whose entries will be multiplied with corresponding entries in the other range.`))],compute:function(...e){if(!lS(...e))return new I(P(`All the ranges must have the same dimensions.`));let t=e.map(B),n=0;for(let e=0;e<t[0].length;e++)for(let r=0;r<t[0][e].length;r++){if(!t.every(t=>typeof t[e][r].value==`number`))continue;let i=1;for(let n of t)i*=L(n[e][r],this.locale);n+=i}return n},isExported:!0};function iq(e,t,n){if(!lS(e,t))return new I(P(`The arguments array_x and array_y must have the same dimensions.`));let r=B(e),i=B(t),a=!1,o=0;for(let e in r)for(let t in r[e]){let s=r[e][t].value,c=i[e][t].value;typeof s!=`number`||typeof c!=`number`||(a=!0,o+=n(s,c))}return a?o:new I(P(`The arguments array_x and array_y must contain at least one pair of numbers.`))}let aq={description:P(`Calculates the sum of the difference of the squares of the values in two array.`),args:[U(`array_x (number, range<number>)`,P(`The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.`)),U(`array_y (number, range<number>)`,P(`The array or range of values whose squares will be subtracted from the squares of corresponding entries in array_x and added together.`))],compute:function(e,t){return iq(e,t,(e,t)=>e**2-t**2)},isExported:!0},oq={description:P(`Calculates the sum of the sum of the squares of the values in two array.`),args:[U(`array_x (number, range<number>)`,P(`The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.`)),U(`array_y (number, range<number>)`,P(`The array or range of values whose squares will be added to the squares of corresponding entries in array_x and added together.`))],compute:function(e,t){return iq(e,t,(e,t)=>e**2+t**2)},isExported:!0},sq={description:P(`Calculates the sum of squares of the differences of values in two array.`),args:[U(`array_x (number, range<number>)`,P(`The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.`)),U(`array_y (number, range<number>)`,P(`The array or range of values that will be subtracted from corresponding entries in array_x, the result squared, and all such results added together.`))],compute:function(e,t){return iq(e,t,(e,t)=>(e-t)**2)},isExported:!0},cq=[U(`array (any, range<any>)`,P(`The array which will be transformed.`)),U(`ignore (number, default=0)`,P(`Whether to ignore certain types of values. By default, no values are ignored.`),[{value:0,label:P(`Keep all values (default)`)},{value:1,label:P(`Ignore blanks`)},{value:2,label:P(`Ignore errors`)},{value:3,label:P(`Ignore blanks and errors`)}]),U(`scan_by_column (number, default=false)`,P(`Scan the array by column. By default, the array is scanned by row.`),[{value:!1,label:P(`Scan by row (default)`)},{value:!0,label:P(`Scan by column`)}])];function lq(e){let t=Math.trunc(e);if(t===0)return()=>!0;if(t===1)return e=>e.value!==null;if(t===2)return e=>!No(e.value);if(t===3)return e=>e.value!==null&&!No(e.value);throw new I(P(`Argument ignore must be between 0 and 3`))}let uq={description:P(`Transforms a range of cells into a single column.`),args:cq,compute:function(e,t={value:0},n={value:!1}){let r=B(e),i=L(t.value,this.locale),a=(z(n.value)?r:as(r)).flat().filter(lq(i));return a.length===0?new Eo(P(`No results for the given arguments of TOCOL.`)):[a]},isExported:!0},dq={description:P(`Transforms a range of cells into a single row.`),args:cq,compute:function(e,t={value:0},n={value:!1}){let r=B(e),i=L(t.value,this.locale),a=(z(n.value)?r:as(r)).flat().filter(lq(i)).map(e=>[e]);return a.length===0||a[0].length===0?new Eo(P(`No results for the given arguments of TOROW.`)):a},isExported:!0},fq={description:P(`Transposes the rows and columns of a range.`),args:[U(`range (any, range<any>)`,P(`The range to be transposed.`))],compute:function(e){let t=B(e),n=t[0].length,r=t.length;return ns(n,r,(e,n)=>t[n][e])},isExported:!0},pq={description:P(`Appends ranges vertically and in sequence to return a larger array.`),args:[U(`range (any, range<any>, repeating)`,P(`The range to be appended.`))],compute:function(...e){return WK(e)},isExported:!0},mq={description:P(`Wraps the provided row or column of cells by columns after a specified number of elements to form a new array.`),args:[U(`range (any, range<any>)`,P(`The range to wrap.`)),U(`wrap_count (number)`,P(`The maximum number of cells for each column, rounded down to the nearest whole number.`)),U(`pad_with (any, default=0)`,P(`The value with which to fill the extra cells in the range.`))],compute:function(e,t,n={value:0}){let r=B(e),i=Ho(t?.value,this.locale);if(!cS(r))return new I(P(`Argument range must be a single row or column.`));if(i<1)return new I(P(`The wrap_count (%s) must be strictly positive.`,i),F.InvalidNumber);let a=r.flat();return ns(Math.ceil(a.length/i),i,(e,t)=>{let r=e*i+t;return r<a.length?a[r]:n})},isExported:!0},hq={description:P(`Wraps the provided row or column of cells by rows after a specified number of elements to form a new array.`),args:[U(`range (any, range<any>)`,P(`The range to wrap.`)),U(`wrap_count (number)`,P(`The maximum number of cells for each row, rounded down to the nearest whole number.`)),U(`pad_with (any, default=0)`,P(`The value with which to fill the extra cells in the range.`))],compute:function(e,t,n={value:0}){let r=B(e),i=Ho(t?.value,this.locale);if(!cS(r))return new I(P(`Argument range must be a single row or column.`));if(i<1)return new I(P(`The wrap_count (%s) must be strictly positive.`,i),F.InvalidNumber);let a=r.flat();return ns(i,Math.ceil(a.length/i),(e,t)=>{let r=t*i+e;return r<a.length?a[r]:n})},isExported:!0},gq=[{value:0,label:P(`Concise format\xA0(default)`)},{value:1,label:P(`Strict format`)}],_q={description:P(`returns an array of text values from any specified range. It passes text values unchanged, and converts non-text values to text.`),args:[U(`array (range)`,P(`The array to convert into text`)),U(`format (number, default=0)`,P(`The format of the returned data.`),gq)],compute:function(e,t={value:0}){let n=L(t,this.locale),r=B(e);if(n===1)return Qk(r,``,this.locale);if(n===0){let e=this.locale.decimalSeparator===`,`?`/`:`,`;return as(r).flatMap(e=>e.map(e=>No(e.value)?e.value:R(e))).join(e)}else return new I(P(`Format must be 0 or 1`))},isExported:!0};var vq=l({ABS:()=>bq,ACOS:()=>xq,ACOSH:()=>Sq,ACOT:()=>Cq,ACOTH:()=>wq,ASIN:()=>Tq,ASINH:()=>Eq,ATAN:()=>Dq,ATAN2:()=>Oq,ATANH:()=>kq,CEILING:()=>Aq,CEILING_MATH:()=>Mq,CEILING_PRECISE:()=>Nq,COS:()=>Pq,COSH:()=>Fq,COT:()=>Iq,COTH:()=>Lq,COUNTBLANK:()=>Rq,COUNTIF:()=>zq,COUNTIFS:()=>Bq,COUNTUNIQUE:()=>Vq,COUNTUNIQUEIFS:()=>Hq,CSC:()=>Uq,CSCH:()=>Wq,DECIMAL:()=>Gq,DEGREES:()=>Kq,EXP:()=>qq,FLOOR:()=>Jq,FLOOR_MATH:()=>Xq,FLOOR_PRECISE:()=>Zq,INT:()=>NJ,ISEVEN:()=>Qq,ISODD:()=>eJ,ISO_CEILING:()=>$q,LN:()=>tJ,LOG:()=>nJ,MOD:()=>iJ,MUNIT:()=>aJ,ODD:()=>oJ,PI:()=>sJ,POWER:()=>cJ,PRODUCT:()=>lJ,RAND:()=>uJ,RANDARRAY:()=>dJ,RANDBETWEEN:()=>fJ,ROUND:()=>pJ,ROUNDDOWN:()=>mJ,ROUNDUP:()=>hJ,SEC:()=>gJ,SECH:()=>_J,SEQUENCE:()=>vJ,SIN:()=>yJ,SINH:()=>bJ,SQRT:()=>xJ,SUBTOTAL:()=>TJ,SUM:()=>EJ,SUMIF:()=>DJ,SUMIFS:()=>OJ,TAN:()=>kJ,TANH:()=>AJ,TRUNC:()=>MJ});let yq=/^-?[a-z0-9]+$/i,bq={description:P(`Absolute value of a number.`),args:[U(`value (number)`,P(`The number of which to return the absolute value.`))],compute:function(e){return Math.abs(L(e,this.locale))},isExported:!0},xq={description:P(`Inverse cosine of a value, in radians.`),args:[U(`value (number)`,P(`The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.`))],compute:function(e){let t=L(e,this.locale);return Math.abs(t)>1?new I(P(`The value (%s) must be between -1 and 1 inclusive.`,t)):Math.acos(t)},isExported:!0},Sq={description:P(`Inverse hyperbolic cosine of a number.`),args:[U(`value (number)`,P(`The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.`))],compute:function(e){let t=L(e,this.locale);return t<1?new I(P(`The value (%s) must be greater than or equal to 1.`,t)):Math.acosh(t)},isExported:!0},Cq={description:P(`Inverse cotangent of a value.`),args:[U(`value (number)`,P(`The value for which to calculate the inverse cotangent.`))],compute:function(e){let t=L(e,this.locale);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},wq={description:P(`Inverse hyperbolic cotangent of a value.`),args:[U(`value (number)`,P(`The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.`))],compute:function(e){let t=L(e,this.locale);return Math.abs(t)<=1?new I(P(`The value (%s) cannot be between -1 and 1 inclusive.`,t)):Math.log((t+1)/(t-1))/2},isExported:!0},Tq={description:P(`Inverse sine of a value, in radians.`),args:[U(`value (number)`,P(`The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.`))],compute:function(e){let t=L(e,this.locale);return Math.abs(t)>1?new I(P(`The value (%s) must be between -1 and 1 inclusive.`,t)):Math.asin(t)},isExported:!0},Eq={description:P(`Inverse hyperbolic sine of a number.`),args:[U(`value (number)`,P(`The value for which to calculate the inverse hyperbolic sine.`))],compute:function(e){return Math.asinh(L(e,this.locale))},isExported:!0},Dq={description:P(`Inverse tangent of a value, in radians.`),args:[U(`value (number)`,P(`The value for which to calculate the inverse tangent.`))],compute:function(e){return Math.atan(L(e,this.locale))},isExported:!0},Oq={description:P(`Angle from the X axis to a point (x,y), in radians.`),args:[U(`x (number)`,P(`The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.`)),U(`y (number)`,P(`The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.`))],compute:function(e,t){let n=L(e,this.locale),r=L(t,this.locale);return n===0&&r===0?new ko(P(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):Math.atan2(r,n)},isExported:!0},kq={description:P(`Inverse hyperbolic tangent of a number.`),args:[U(`value (number)`,P(`The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.`))],compute:function(e){let t=L(e,this.locale);return Math.abs(t)>=1?new I(P(`The value (%s) must be between -1 and 1 exclusive.`,t)):Math.atanh(t)},isExported:!0},Aq={description:P(`Rounds number up to nearest multiple of factor.`),args:[U(`value (number)`,P(`The value to round up to the nearest integer multiple of factor.`)),U(`factor (number, default=1)`,P(`The number to whose multiples value will be rounded.`))],compute:function(e,t={value:1}){let n=L(e,this.locale),r=L(t,this.locale);return r<0&&n>0?new I(P(`The factor (%s) must be positive when the value (%s) is positive.`,r,n)):{value:r?Math.ceil(n/r)*r:0,format:e?.format}},isExported:!0};function jq(e,t,n=0){return t===0?0:(t=Math.abs(t),e>=0?Math.ceil(e/t)*t:n===0?-Math.floor(Math.abs(e)/t)*t:-Math.ceil(Math.abs(e)/t)*t)}let Mq={description:P(`Rounds number up to nearest multiple of factor.`),args:[U(`number (number)`,P(`The value to round up to the nearest integer multiple of significance.`)),U(`significance (number, default=1)`,P(`The number to whose multiples number will be rounded. The sign of significance will be ignored.`)),U(`mode (number, default=0)`,P(`If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero.`))],compute:function(e,t={value:1},n={value:0}){let r=L(t,this.locale);return{value:jq(L(e,this.locale),r,L(n,this.locale)),format:e?.format}},isExported:!0},Nq={description:P(`Rounds number up to nearest multiple of factor.`),args:[U(`number (number)`,P(`The value to round up to the nearest integer multiple of significance.`)),U(`significance (number, default=1)`,P(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){let n=L(t,this.locale);return{value:jq(L(e,this.locale),n),format:e?.format}},isExported:!0},Pq={description:P(`Cosine of an angle provided in radians.`),args:[U(`angle (number)`,P(`The angle to find the cosine of, in radians.`))],compute:function(e){return Math.cos(L(e,this.locale))},isExported:!0},Fq={description:P(`Hyperbolic cosine of any real number.`),args:[U(`value (number)`,P(`Any real value to calculate the hyperbolic cosine of.`))],compute:function(e){return Math.cosh(L(e,this.locale))},isExported:!0},Iq={description:P(`Cotangent of an angle provided in radians.`),args:[U(`angle (number)`,P(`The angle to find the cotangent of, in radians.`))],compute:function(e){let t=L(e,this.locale);return t===0?new ko(P(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):1/Math.tan(t)},isExported:!0},Lq={description:P(`Hyperbolic cotangent of any real number.`),args:[U(`value (number)`,P(`Any real value to calculate the hyperbolic cotangent of.`))],compute:function(e){let t=L(e,this.locale);return t===0?new ko(P(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):1/Math.tanh(t)},isExported:!0},Rq={description:P(`Number of empty values.`),args:[U(`value (any, range, repeating)`,P(`Value or range in which to count the number of blanks.`))],compute:function(...e){return $o(e,(e,t)=>t===void 0||t.value===null||t.value===``?e+1:e,0)},isExported:!0},zq={description:P(`A conditional count across a range.`),args:[U(`range (range)`,P(`The range that is tested against criterion.`)),U(`criterion (string)`,P(`The pattern or test to apply to range.`))],compute:function(...e){let t=0;return ds(e,(e,n)=>{t+=1},this.locale),t},isExported:!0},Bq={description:P(`Count values depending on multiple criteria.`),args:[U(`criteria_range (any, range, repeating)`,P(`Range over which to evaluate criteria.`)),U(`criterion (string, repeating)`,P(`Criteria to check.`))],compute:function(...e){let t=0;return ds(e,(e,n)=>{t+=1},this.locale),t},isExported:!0},Vq={description:P(`Counts number of unique values in a range.`),args:[U(`value (any, range, repeating)`,P(`Value or range to consider for uniqueness.`))],compute:function(...e){return aS(e)}},Hq={description:P(`Counts number of unique values in a range, filtered by a set of criteria.`),args:[U(`range (range)`,P(`The range of cells from which the number of unique values will be counted.`)),U(`criteria_range (any, range, repeating)`,P(`Range over which to evaluate criteria.`)),U(`criterion (string, repeating)`,P(`Criteria to check.`))],compute:function(e,...t){let n=new Set;return ds(t,(t,r)=>{let i=e[t]?.[r];vs(i)&&n.add(i.value)},this.locale),n.size}},Uq={description:P(`Cosecant of an angle provided in radians.`),args:[U(`angle (number)`,P(`The angle to find the cosecant of, in radians.`))],compute:function(e){let t=L(e,this.locale);return t===0?new ko(P(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):1/Math.sin(t)},isExported:!0},Wq={description:P(`Hyperbolic cosecant of any real number.`),args:[U(`value (number)`,P(`Any real value to calculate the hyperbolic cosecant of.`))],compute:function(e){let t=L(e,this.locale);return t===0?new ko(P(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):1/Math.sinh(t)},isExported:!0},Gq={description:P(`Converts from another base to decimal.`),args:[U(`value (string)`,P(`The number to convert.`)),U(`base (number)`,P(`The base to convert the value from.`))],compute:function(e,t){let n=L(t,this.locale);if(n=Math.floor(n),2>n||n>36)return new I(P(`The base (%s) must be between 2 and 36 inclusive.`,n));let r=R(e);if(r===``)return 0;if(!yq.test(r))return new I(P(`The value (%s) must be a valid base %s representation.`,r,n));let i=r.replace(`-`,``);for(let e of i)if(parseInt(e,36)>=n)return new I(P(`The value (%s) must be a valid base %s representation.`,r,n));let a=parseInt(r,n);return isNaN(a)?new I(P(`The value (%s) must be a valid base %s representation.`,r,n)):a},isExported:!0},Kq={description:P(`Converts an angle value in radians to degrees.`),args:[U(`angle (number)`,P(`The angle to convert from radians to degrees.`))],compute:function(e){return L(e,this.locale)*180/Math.PI},isExported:!0},qq={description:P(`Euler's number, e (~2.718) raised to a power.`),args:[U(`value (number)`,P(`The exponent to raise e.`))],compute:function(e){return Math.exp(L(e,this.locale))},isExported:!0},Jq={description:P(`Rounds number down to nearest multiple of factor.`),args:[U(`value (number)`,P(`The value to round down to the nearest integer multiple of factor.`)),U(`factor (number, default=1)`,P(`The number to whose multiples value will be rounded.`))],compute:function(e,t={value:1}){let n=L(e,this.locale),r=L(t,this.locale);return r<0&&n>0?new I(P(`The factor (%s) must be positive when the value (%s) is positive.`,r,n)):{value:r?Math.floor(n/r)*r:0,format:e?.format}},isExported:!0};function Yq(e,t,n=0){return t===0?0:(t=Math.abs(t),e>=0?Math.floor(e/t)*t:n===0?-Math.ceil(Math.abs(e)/t)*t:-Math.floor(Math.abs(e)/t)*t)}let Xq={description:P(`Rounds number down to nearest multiple of factor.`),args:[U(`number (number)`,P(`The value to round down to the nearest integer multiple of significance.`)),U(`significance (number, default=1)`,P(`The number to whose multiples number will be rounded. The sign of significance will be ignored.`)),U(`mode (number, default=0)`,P(`If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero.`))],compute:function(e,t={value:1},n={value:0}){let r=L(t,this.locale);return{value:Yq(L(e,this.locale),r,L(n,this.locale)),format:e?.format}},isExported:!0},Zq={description:P(`Rounds number down to nearest multiple of factor.`),args:[U(`number (number)`,P(`The value to round down to the nearest integer multiple of significance.`)),U(`significance (number, default=1)`,P(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){let n=L(t,this.locale);return{value:Yq(L(e,this.locale),n),format:e?.format}},isExported:!0},Qq={description:P(`Whether the provided value is even.`),args:[U(`value (number)`,P(`The value to be verified as even.`))],compute:function(e){let t=Vo(e,this.locale);return!(Math.floor(Math.abs(t))&1)},isExported:!0},$q={description:P(`Rounds number up to nearest multiple of factor.`),args:[U(`number (number)`,P(`The value to round up to the nearest integer multiple of significance.`)),U(`significance (number, default=1)`,P(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){return{value:jq(L(e,this.locale),L(t,this.locale)),format:e?.format}},isExported:!0},eJ={description:P(`Whether the provided value is even.`),args:[U(`value (number)`,P(`The value to be verified as even.`))],compute:function(e){let t=Vo(e,this.locale);return!!(Math.floor(Math.abs(t))&1)},isExported:!0},tJ={description:P(`The logarithm of a number, base e (euler's number).`),args:[U(`value (number)`,P(`The value for which to calculate the logarithm, base e.`))],compute:function(e){let t=L(e,this.locale);return t<=0?new I(P(`The value (%s) must be strictly positive.`,t)):Math.log(t)},isExported:!0},nJ={description:P(`The logarithm of a number, for a given base.`),args:[U(`value (number)`,P(`The value for which to calculate the logarithm.`)),U(`base (number, default=10)`,P(`The base of the logarithm.`))],compute:function(e,t={value:10}){let n=L(e,this.locale),r=L(t,this.locale);return n<=0?new I(P(`The value (%s) must be strictly positive.`,n)):r<=0?new I(P(`The base (%s) must be strictly positive.`,r)):r===1?new I(P(`The base must be different from 1.`)):Math.log10(n)/Math.log10(r)},isExported:!0};function rJ(e,t){sS(t,P(`The divisor must be different from 0.`));let n=e%t;return n>0&&t<0||n<0&&t>0?n+t:n}let iJ={description:P(`Modulo (remainder) operator.`),args:[U(`dividend (number)`,P(`The number to be divided to find the remainder.`)),U(`divisor (number)`,P(`The number to divide by.`))],compute:function(e,t){let n=L(t,this.locale);return{value:rJ(L(e,this.locale),n),format:e?.format}},isExported:!0},aJ={description:P(`Returns a n x n unit matrix, where n is the input dimension.`),args:[U(`dimension (number)`,P(`An integer specifying the dimension size of the unit matrix. It must be positive.`))],compute:function(e){let t=Ho(e,this.locale);return t<1?new I(P(`The argument dimension must be positive`)):fS(t)},isExported:!0},oJ={description:P(`Rounds a number up to the nearest odd integer.`),args:[U(`value (number)`,P(`The value to round to the next greatest odd number.`))],compute:function(e){let t=L(e,this.locale),n=Math.ceil(Math.abs(t));return n=n&1?n:n+1,{value:t<0?-n:n,format:e?.format}},isExported:!0},sJ={description:P(`The number pi.`),args:[],compute:function(){return Math.PI},isExported:!0},cJ={description:P(`A number raised to a power.`),args:[U(`base (number)`,P(`The number to raise to the exponent power.`)),U(`exponent (number)`,P(`The exponent to raise base to.`))],compute:function(e,t){let n=L(e,this.locale),r=L(t,this.locale);return n<0&&!Number.isInteger(r)?new I(P(`The exponent (%s) must be an integer when the base is negative.`,r)):{value:n**+r,format:e?.format}},isExported:!0},lJ={description:P(`Result of multiplying a series of numbers together.`),args:[U(`factor (number, range<number>, repeating)`,P(`Number or range to calculate for the product.`))],compute:function(...e){let t=0,n=1;for(let r of e)if(ht(r))for(let e of r)for(let r of e){let e=r.value;if(typeof e==`number`&&(n*=e,t+=1),No(e))return r}else r!==void 0&&r.value!==null&&(n*=Vo(r,this.locale),t+=1);return{value:t===0?0:n,format:Mo(e[0])}},isExported:!0},uJ={description:P(`A random number between 0 inclusive and 1 exclusive.`),args:[],compute:function(){return Math.random()},isExported:!0},dJ={description:P(`Returns a grid of random numbers between 0 inclusive and 1 exclusive.`),args:[U(`rows (number, default=1)`,P(`The number of rows to be returned.`)),U(`columns (number, default=1)`,P(`The number of columns to be returned.`)),U(`min (number, default=0)`,P(`The minimum number you would like returned.`)),U(`max (number, default=1)`,P(`The maximum number you would like returned.`)),U(`whole_number (boolean, default=FALSE)`,P(`Return a whole number or a decimal value.`),[{value:!1,label:P(`Decimal (default)`)},{value:!0,label:P(`Integer`)}])],compute:function(e={value:1},t={value:1},n={value:0},r={value:1},i={value:!1}){let a=Ho(t,this.locale),o=Ho(e,this.locale),s=L(n,this.locale),c=L(r,this.locale),l=z(i);if(a<1)return new I(P(`The number of columns (%s) must be positive.`,a));if(o<1)return new I(P(`The number of rows (%s) must be positive.`,o));if(s>c)return new I(P(`The maximum (%s) must be greater than or equal to the minimum (%s).`,c,s));if(l&&(!Number.isInteger(s)||!Number.isInteger(c)))return new I(P(`The maximum (%s) and minimum (%s) must be integers when whole_number is TRUE.`,c.toString(),s.toString()));let u=Array(a);for(let e=0;e<a;e++){u[e]=Array(o);for(let t=0;t<o;t++)l?u[e][t]=Math.floor(Math.random()*(c-s+1)+s):u[e][t]=s+Math.random()*(c-s)}return u},isExported:!0},fJ={description:P(`Random integer between two values, inclusive.`),args:[U(`low (number)`,P(`The low end of the random range.`)),U(`high (number)`,P(`The high end of the random range.`))],compute:function(e,t){let n=L(e,this.locale);Number.isInteger(n)||(n=Math.ceil(n));let r=L(t,this.locale);return Number.isInteger(r)||(r=Math.floor(r)),n>r?new I(P(`The high (%s) must be greater than or equal to the low (%s).`,r,n)):{value:n+Math.floor((r-n+1)*Math.random()),format:e?.format}},isExported:!0},pJ={description:P(`Rounds a number according to standard rules.`),args:[U(`value (number)`,P(`The value to round to places number of places.`)),U(`places (number, default=0)`,P(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=L(e,this.locale),r=L(t,this.locale),i=Math.abs(n),a;return r===0?a=Math.round(i):(Number.isInteger(r)||(r=Math.trunc(r)),a=Math.round(i*10**r)/10**r),{value:n>=0?a:-a,format:e?.format}},isExported:!0},mJ={description:P(`Rounds down a number.`),args:[U(`value (number)`,P(`The value to round to places number of places, always rounding down.`)),U(`places (number, default=0)`,P(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=L(e,this.locale),r=L(t,this.locale),i=Math.abs(n),a;return r===0?a=Math.floor(i):(Number.isInteger(r)||(r=Math.trunc(r)),a=Math.floor(i*10**r)/10**r),{value:n>=0?a:-a,format:e?.format}},isExported:!0},hJ={description:P(`Rounds up a number.`),args:[U(`value (number)`,P(`The value to round to places number of places, always rounding up.`)),U(`places (number, default=0)`,P(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=L(e,this.locale),r=L(t,this.locale),i=Math.abs(n),a;return r===0?a=Math.ceil(i):(Number.isInteger(r)||(r=Math.trunc(r)),a=Math.ceil(i*10**r)/10**r),{value:n>=0?a:-a,format:e?.format}},isExported:!0},gJ={description:P(`Secant of an angle provided in radians.`),args:[U(`angle (number)`,P(`The angle to find the secant of, in radians.`))],compute:function(e){return 1/Math.cos(L(e,this.locale))},isExported:!0},_J={description:P(`Hyperbolic secant of any real number.`),args:[U(`value (number)`,P(`Any real value to calculate the hyperbolic secant of.`))],compute:function(e){return 1/Math.cosh(L(e,this.locale))},isExported:!0},vJ={description:P(`Returns a sequence of numbers.`),args:[U(`rows (number)`,P(`The number of rows to return`)),U(`columns (number, optional, default=1)`,P(`The number of columns to return`)),U(`start (number, optional, default=1)`,P(`The first number in the sequence`)),U(`step (number, optional, default=1)`,P(`The amount to increment each value in the sequence`))],compute:function(e,t={value:1},n={value:1},r={value:1}){let i=L(n,this.locale),a=L(r,this.locale),o=Ho(e,this.locale),s=Ho(t,this.locale);return s<1?new I(P(`The number of columns (%s) must be positive.`,s)):o<1?new I(P(`The number of rows (%s) must be positive.`,o)):ns(s,o,(e,t)=>({value:i+t*s*a+e*a}))},isExported:!0},yJ={description:P(`Sine of an angle provided in radians.`),args:[U(`angle (number)`,P(`The angle to find the sine of, in radians.`))],compute:function(e){return Math.sin(L(e,this.locale))},isExported:!0},bJ={description:P(`Hyperbolic sine of any real number.`),args:[U(`value (number)`,P(`Any real value to calculate the hyperbolic sine of.`))],compute:function(e){return Math.sinh(L(e,this.locale))},isExported:!0},xJ={description:P(`Positive square root of a positive number.`),args:[U(`value (number)`,P(`The number for which to calculate the positive square root.`))],compute:function(e){let t=L(e,this.locale);return t<0?new I(P(`The value (%s) must be positive or null.`,t)):{value:Math.sqrt(t),format:e?.format}},isExported:!0},SJ={1:`AVERAGE`,2:`COUNT`,3:`COUNTA`,4:`MAX`,5:`MIN`,6:`PRODUCT`,7:`STDEV`,8:`STDEVP`,9:`SUM`,10:`VAR`,11:`VARP`},CJ=Object.entries(SJ).map(([e,t])=>({value:parseInt(e),label:P(`%s (include manually-hidden rows)`,t)})),wJ=Object.entries(SJ).map(([e,t])=>({value:parseInt(e)+100,label:P(`%s (exclude manually-hidden rows)`,t)})),TJ={description:P(`Returns a subtotal for a vertical range of cells using a specified aggregation function.`),args:[U(`function_code (number)`,P(`The function to use in subtotal aggregation.`),[...CJ,...wJ]),U(`ref (any, range<any>, repeating)`,P(`Range or reference for which you want the subtotal.`))],compute:function(e,...t){let n=Ho(e,this.locale),r=!0;if(n>100&&(n-=100,r=!1),n<1||n>11)return new I(P(`The function code (%s) must be between 1 to 11 or 101 to 111.`,n));let i=[];for(let e of t){let t=B(e),n=t[0][0]?.position;if(n===void 0)return new To(Io);let a=n.col+t.length-1,o=n.row+t[0].length-1,s=n.sheetId;for(let e=n.row;e<=o;e++)if(!this.getters.isRowFiltered(s,e)&&!(!r&&this.getters.isRowHiddenByUser(s,e)))for(let t=n.col;t<=a;t++){let n=this.getters.getCorrespondingFormulaCell({sheetId:s,col:t,row:e});(!n||!bn(n,`SUBTOTAL`))&&i.push(this.getFormulaResult({sheetId:s,col:t,row:e}))}}return this[SJ[n]].apply(this,[[i]])},isExported:!0},EJ={description:P(`Sum of a series of numbers and/or cells.`),args:[U(`value (number, range<number>, repeating)`,P(`Number or range to add together.`))],compute:function(...e){let t=e[0];return{value:iS(e,this.locale),format:Mo(t)}},isExported:!0},DJ={description:P(`A conditional sum across a range.`),args:[U(`criteria_range (range)`,P(`The range which is tested against criterion.`)),U(`criterion (string)`,P(`The pattern or test to apply to range.`)),U(`sum_range (range, default=criteria_range)`,P(`The range to be summed, if different from range.`))],compute:function(e,t,n){n===void 0&&(n=e);let r=0;return ds([e,t],(e,t)=>{let i=n[e]?.[t]?.value;typeof i==`number`&&(r+=i)},this.locale),r},isExported:!0},OJ={description:P(`Sums a range depending on multiple criteria.`),args:[U(`sum_range (range)`,P(`The range to sum.`)),U(`criteria_range (any, range, repeating)`,P(`Range to check.`)),U(`criterion (string, repeating)`,P(`Criteria to check.`))],compute:function(e,...t){let n=0;return ds(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n+=i)},this.locale),n},isExported:!0},kJ={description:P(`Tangent of an angle provided in radians.`),args:[U(`angle (number)`,P(`The angle to find the tangent of, in radians.`))],compute:function(e){return Math.tan(L(e,this.locale))},isExported:!0},AJ={description:P(`Hyperbolic tangent of any real number.`),args:[U(`value (number)`,P(`Any real value to calculate the hyperbolic tangent of.`))],compute:function(e){return Math.tanh(L(e,this.locale))},isExported:!0};function jJ(e,t){return t===0?Math.trunc(e):(Number.isInteger(t)||(t=Math.trunc(t)),Math.trunc(e*10**t)/10**t)}let MJ={description:P(`Truncates a number.`),args:[U(`value (number)`,P(`The value to be truncated.`)),U(`places (number, default=0)`,P(`The number of significant digits to the right of the decimal point to retain.`))],compute:function(e,t={value:0}){return{value:jJ(L(e,this.locale),L(t,this.locale)),format:e?.format}},isExported:!0},NJ={description:P(`Rounds a number down to the nearest integer that is less than or equal to it.`),args:[U(`value (number)`,P(`The number to round down to the nearest integer.`))],compute:function(e){return Math.floor(L(e,this.locale))},isExported:!0};var PJ=l({AVEDEV:()=>WJ,AVERAGE:()=>GJ,AVERAGEA:()=>YJ,AVERAGEIF:()=>XJ,AVERAGEIFS:()=>ZJ,AVERAGE_WEIGHTED:()=>JJ,CORREL:()=>yY,COUNT:()=>QJ,COUNTA:()=>$J,COVAR:()=>eY,COVARIANCE_P:()=>tY,COVARIANCE_S:()=>nY,FORECAST:()=>rY,GROWTH:()=>iY,INTERCEPT:()=>aY,LARGE:()=>oY,LINEST:()=>sY,LOGEST:()=>cY,MATTHEWS:()=>lY,MAX:()=>uY,MAXA:()=>dY,MAXIFS:()=>fY,MEDIAN:()=>pY,MIN:()=>mY,MINA:()=>hY,MINIFS:()=>gY,PEARSON:()=>vY,PERCENTILE:()=>bY,PERCENTILE_EXC:()=>xY,PERCENTILE_INC:()=>SY,POLYFIT_COEFFS:()=>CY,POLYFIT_FORECAST:()=>wY,QUARTILE:()=>TY,QUARTILE_EXC:()=>EY,QUARTILE_INC:()=>DY,RANK:()=>OY,RSQ:()=>kY,SLOPE:()=>AY,SMALL:()=>jY,SPEARMAN:()=>MY,STDEV:()=>NY,STDEVA:()=>IY,STDEVP:()=>LY,STDEVPA:()=>RY,STDEV_P:()=>PY,STDEV_S:()=>FY,STEYX:()=>zY,TREND:()=>BY,VAR:()=>VY,VARA:()=>WY,VARP:()=>GY,VARPA:()=>KY,VAR_P:()=>HY,VAR_S:()=>UY});let FJ=[{value:!0,label:P(`b is calculated normally`)},{value:!1,label:P(`b is forced to 1`)}],IJ=[{value:!1,label:P(`do not return additional regression statistics`)},{value:!0,label:P(`return additional regression statistics`)}],LJ=[{value:1,label:P(`order 1 (Linear)`)},{value:2,label:P(`order 2 (Quadratic)`)},{value:3,label:P(`order 3 (Cubic)`)},{value:4,label:P(`order 4 (Quartic)`)},{value:5,label:P(`order 5 (Quintic)`)},{value:6,label:P(`order 6 (Sextic)`)}],RJ=[{value:!0,label:P(`Compute intercept`)},{value:!1,label:P(`Force intercept to 0`)}],zJ=[{value:0,label:P(`Minimum value`)},{value:1,label:P(`First quartile (25th percentile)`)},{value:2,label:P(`Median value (50th percentile)`)},{value:3,label:P(`Third quartile (75th percentile)`)},{value:4,label:P(`Maximum value`)}];function BJ(e,t){let n=[],r=[],i=0,a=0;Xo([e],e=>{n.push(e),i+=1}),Xo([t],e=>{r.push(e),a+=1}),oS(i===a,P(`[[FUNCTION_NAME]] has mismatched argument count %s vs %s.`,i,a));let o=[],s=[];for(let e=0;e<i;e++){let t=n[e]?.value,i=r[e]?.value;typeof t==`number`&&typeof i==`number`&&(s.push(t),o.push(i))}return{flatDataX:o,flatDataY:s}}function VJ(e,t,n){let{flatDataX:r,flatDataY:i}=BJ(e,t),a=i.length;sS(a),n&&sS(a-1);let o=0,s=0;for(let e=0;e<a;e++)o+=i[e],s+=r[e];let c=o/a,l=s/a,u=0;for(let e=0;e<a;e++)u+=(i[e]-c)*(r[e]-l);return u/(a-+!!n)}function HJ(e,t,n,r){let i=0,a=n?ts:es,o=a(e,(e,t)=>(i+=1,e+t),0,r);sS(i),t&&sS(i-1);let s=o/i;return a(e,(e,t)=>e+(t-s)**2,0,r)/(i-+!!t)}function UJ(e,t,n,r){let i=L(t,r);oS(n?0<=i&&i<=1:0<i&&i<1,P(`Function [[FUNCTION_NAME]] parameter 2 value is out of range.`));let a=[],o,s=0;return Xo(e,e=>{let t=e?.value;typeof t==`number`&&(o=fs(a,e,`nextSmaller`,`asc`,a.length,(e,t)=>e[t]),a.splice(o+1,0,t),s++)}),oS(s!==0,ys),n||oS(1/(s+1)<=i&&i<=s/(s+1),P(`Function [[FUNCTION_NAME]] parameter 2 value is out of range.`)),po(a,i,n)}let WJ={description:P(`Average magnitude of deviations from mean.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the sample.`))],compute:function(...e){let t=0,n=es(e,(e,n)=>(t+=1,e+n),0,this.locale);if(t===0)return new ko(P(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`));let r=n/t;return es(e,(e,t)=>e+Math.abs(r-t),0,this.locale)/t},isExported:!0},GJ={description:P(`Numerical average value in a dataset, ignoring text.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to consider when calculating the average value.`))],compute:function(...e){return{value:bS(e,this.locale),format:Mo(e[0])}},isExported:!0},KJ=P(`[[FUNCTION_NAME]] has mismatched range sizes.`),qJ=P(`[[FUNCTION_NAME]] expects the weight to be positive or equal to 0.`),JJ={description:P(`Weighted average.`),args:[U(`values (number, range<number>, repeating)`,P(`Value to average.`)),U(`weights (number, range<number>, repeating)`,P(`Weight for each corresponding value.`))],compute:function(...e){let t=0,n=0;for(let r=0;r<e.length-1;r+=2){let i=e[r],a=e[r+1];if(!lS(i,a))return new I(KJ);if(ht(i))for(let e=0;e<i.length;e++)for(let r=0;r<i[0].length;r++){let o=i[e][r].value,s=ht(a)?a?.[e][r].value:L(a,this.locale),c=typeof o==`number`,l=typeof s==`number`;if(c&&l){if(s<0)return new I(qJ);t+=o*s,n+=s;continue}if(c!==l)return new I(P(`[[FUNCTION_NAME]] expects number values.`))}else{let e=L(i,this.locale),r=ht(a)?a?.[0][0].value:L(a,this.locale);if(typeof r==`number`){if(r<0)return new I(qJ);t+=e*r,n+=r}}}return n===0?new ko(P(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:t/n,format:Mo(e[0])}}},YJ={description:P(`Numerical average value in a dataset.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to consider when calculating the average value.`))],compute:function(...e){let t=0,n=ts(e,(e,n)=>(t+=1,e+n),0,this.locale);return t===0?new ko(P(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:n/t,format:Mo(e[0])}},isExported:!0},XJ={description:P(`Average of values depending on criteria.`),args:[U(`criteria_range (number, range<number>)`,P(`The range to check against criterion.`)),U(`criterion (string)`,P(`The pattern or test to apply to criteria_range.`)),U(`average_range (number, range<number>, default=criteria_range)`,P(`The range to average. If not included, criteria_range is used for the average instead.`))],compute:function(e,t,n){let r=B(n===void 0?e:n),i=0,a=0;return ds([e,t],(e,t)=>{let n=r[e]?.[t]?.value;typeof n==`number`&&(i+=1,a+=n)},this.locale),i===0?new ko(P(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):a/i},isExported:!0},ZJ={description:P(`Average of values depending on multiple criteria.`),args:[U(`average_range (range)`,P(`The range to average.`)),U(`criteria_range (any, range, repeating)`,P(`Range to check.`)),U(`criterion (string, repeating)`,P(`Criterion to check.`))],compute:function(e,...t){let n=B(e),r=0,i=0;return ds(t,(e,t)=>{let a=n[e]?.[t]?.value;typeof a==`number`&&(r+=1,i+=a)},this.locale),r===0?new ko(P(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):i/r},isExported:!0},QJ={description:P(`The number of numeric values in dataset.`),args:[U(`value (number, any, range<number>, repeating)`,P(`Value or range to consider when counting.`))],compute:function(...e){return SS(e,this.locale)},isExported:!0},$J={description:P(`The number of values in a dataset.`),args:[U(`value (any, range, repeating)`,P(`Value or range to consider when counting.`))],compute:function(...e){return CS(e)},isExported:!0},eY={description:P(`The covariance of a dataset.`),args:[U(`data_y (any, range)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (any, range)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return VJ(e,t,!1)},isExported:!0},tY={description:P(`The covariance of a dataset.`),args:[U(`data_y (any, range)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (any, range)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return VJ(e,t,!1)},isExported:!0},nY={description:P(`The sample covariance of a dataset.`),args:[U(`data_y (any, range)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (any, range)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return VJ(e,t,!0)},isExported:!0},rY={description:P(`Calculates the expected y-value for a specified x based on a linear regression of a dataset.`),args:[U(`x (number, range<number>)`,P(`The value(s) on the x-axis to forecast.`)),U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t,n){let{flatDataX:r,flatDataY:i}=BJ(t,n);return r.length===0||i.length===0?new Eo(ys):NS([i],[r],rs(B(e),e=>L(e,this.locale)),!0)},isExported:!0},iY={description:P(`Fits points to exponential growth trend.`),args:[U(`known_data_y (range<number>)`,P(`The array or range containing dependent (y) values that are already known, used to curve fit an ideal exponential growth curve.`)),U(`known_data_x (range<number>, default={1;2;3;...})`,P(`The values of the independent variable(s) corresponding with known_data_y.`)),U(`new_data_x (any, range, default=known_data_x)`,P(`The data points to return the y values for on the ideal curve fit.`)),U(`b (boolean, default=TRUE)`,P(`Given a general exponential form of y = b*m^x for a curve fit, calculates b if TRUE or forces b to be 1 and only calculates the m values if FALSE.`),FJ)],compute:function(e,t=[[]],n=[[]],r={value:!0}){return e.length===0||e[0].length===0?new I(bs(`known_data_y`)):jS(NS(MS(Bo(e,`known_data_y`)),Bo(t,`known_data_x`),Bo(n,`new_data_y`),z(r)))}},aY={description:P(`Compute the intercept of the linear regression.`),args:[U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=BJ(e,t);if(n.length===0||r.length===0)return new Eo(ys);let[[],[i]]=DS([n],[r]);return i},isExported:!0},oY={description:P(`Nth largest element from a data set.`),args:[U(`data (any, range)`,P(`Array or range containing the dataset to consider.`)),U(`n (number)`,P(`The rank from largest to smallest of the element to return.`))],compute:function(e,t){let n=Math.trunc(L(t?.value,this.locale)),r=[],i,a=0;Xo([e],e=>{typeof e?.value==`number`&&(i=fs(r,e,`nextSmaller`,`asc`,r.length,(e,t)=>e[t].value),r.splice(i+1,0,e),a++,a>n&&(r.shift(),a--))});let o=r.shift();return o===void 0?new I(ys):a<n?new I(P(`Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.`,n)):o},isExported:!0},sY={description:P(`Given partial data about a linear trend, calculates various parameters about the ideal linear trend using the least-squares method.`),args:[U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>, default={1;2;3;...})`,P(`The range representing the array or matrix of independent data.`)),U(`calculate_b (boolean, default=TRUE)`,P(`A flag specifying whether to compute the slope or not`),FJ),U(`verbose (boolean, default=FALSE)`,P(`A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept`),IJ)],compute:function(e,t=[[]],n={value:!0},r={value:!1}){return e.length===0||e[0].length===0?new I(bs(`data_y`)):DS(Bo(t,`data_x`),Bo(e,`data_y`),z(n),z(r))},isExported:!0},cY={description:P(`Given partial data about an exponential growth curve, calculates various parameters about the best fit ideal exponential growth curve.`),args:[U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>, optional, default={1;2;3;...})`,P(`The range representing the array or matrix of independent data.`)),U(`calculate_b (boolean, default=TRUE)`,P(`A flag specifying whether to compute the slope or not`),FJ),U(`verbose (boolean, default=FALSE)`,P(`A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept`),IJ)],compute:function(e,t=[[]],n={value:!0},r={value:!1}){if(e.length===0||e[0].length===0)return new I(bs(`data_y`));let i=DS(Bo(t,`data_x`),MS(Bo(e,`data_y`)),z(n),z(r));for(let e=0;e<i.length;e++)i[e][0]=Math.exp(i[e][0]);return i},isExported:!0},lY={description:P(`Compute the Matthews correlation coefficient of a dataset.`),args:[U(`data_x (range)`,P(`The range representing the array or matrix of observed data.`)),U(`data_y (range)`,P(`The range representing the array or matrix of predicted data.`))],compute:function(e,t){let n=e.flat(),r=t.flat();if(yS(n,r),n.length===0||r.length===0)return new Eo(ys);let i=n.length,a=0,o=0,s=0,c=0;for(let e=0;e<i;++e){let t=z(n[e]);t===z(r[e])?t?o++:a++:t?c++:s++}return(o*a-s*c)/Math.sqrt((o+s)*(o+c)*(a+s)*(a+c))},isExported:!1},uY={description:P(`Maximum value in a numeric dataset.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to consider when calculating the maximum value.`))],compute:function(...e){return wS(e,this.locale)},isExported:!0},dY={description:P(`Maximum numeric value in a dataset.`),args:[U(`value (any, range, repeating)`,P(`Value or range to consider when calculating the maximum value.`))],compute:function(...e){let t=ts(e,(e,t)=>Math.max(t,e),-1/0,this.locale);return{value:t===-1/0?0:t,format:Mo(e[0])}},isExported:!0},fY={description:P(`Returns the maximum value in a range of cells, filtered by a set of criteria.`),args:[U(`range (range)`,P(`The range of cells from which the maximum will be determined.`)),U(`criteria_range (any, range, repeating)`,P(`Range to evaluate criteria.`)),U(`criterion (string, repeating)`,P(`Criteria to check.`))],compute:function(e,...t){let n=-1/0;return ds(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n=n<i?i:n)},this.locale),n===-1/0?0:n},isExported:!0},pY={description:P(`Median value in a numeric dataset.`),args:[U(`value (any, range, repeating)`,P(`Value or range to consider when calculating the median value.`))],compute:function(...e){let t=[];return Zo(e,e=>{t.push(e)},this.locale),{value:UJ(t,{value:.5},!0,this.locale),format:Mo(t[0])}},isExported:!0},mY={description:P(`Minimum value in a numeric dataset.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to consider when calculating the minimum value.`))],compute:function(...e){return TS(e,this.locale)},isExported:!0},hY={description:P(`Minimum numeric value in a dataset.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to consider when calculating the minimum value.`))],compute:function(...e){let t=ts(e,(e,t)=>Math.min(t,e),1/0,this.locale);return{value:t===1/0?0:t,format:Mo(e[0])}},isExported:!0},gY={description:P(`Returns the minimum value in a range of cells, filtered by a set of criteria.`),args:[U(`range (range)`,P(`The range of cells from which the minimum will be determined.`)),U(`criteria_range (any, range, repeating)`,P(`Range to evaluate criteria.`)),U(`criterion (string, repeating)`,P(`Criterion to check.`))],compute:function(e,...t){let n=1/0;return ds(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n=n>i?i:n)},this.locale),n===1/0?0:n},isExported:!0};function _Y(e,t){let{flatDataX:n,flatDataY:r}=BJ(e,t);if(n.length===0||r.length===0)return new Eo(ys);let i=n.length,a=0,o=0,s=0,c=0,l=0;for(let e=0;e<i;e++){let t=n[e],i=r[e];a+=t,o+=i,s+=t*i,c+=t*t,l+=i*i}let u=Math.sqrt((i*c-a*a)*(i*l-o*o));return u===0?new ko:(i*s-a*o)/u}let vY={description:P(`Compute the Pearson product-moment correlation coefficient of a dataset.`),args:[U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return _Y(e,t)},isExported:!0},yY=vY,bY={description:P(`Value at a given percentile of a dataset.`),args:[U(`data (any, range)`,P(`The array or range containing the dataset to consider.`)),U(`percentile (number)`,P(`The percentile whose value within data will be calculated and returned.`))],compute:function(e,t){return SY.compute.bind(this)(e,t)},isExported:!0},xY={description:P(`Value at a given percentile of a dataset exclusive of 0 and 1.`),args:[U(`data (any, range)`,P(`The array or range containing the dataset to consider.`)),U(`percentile (number)`,P(`The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.`))],compute:function(e,t){return{value:UJ([e],t,!1,this.locale),format:Mo(e)}},isExported:!0},SY={description:P(`Value at a given percentile of a dataset.`),args:[U(`data (any, range)`,P(`The array or range containing the dataset to consider.`)),U(`percentile (number)`,P(`The percentile whose value within data will be calculated and returned.`))],compute:function(e,t){return{value:UJ([e],t,!0,this.locale),format:Mo(e)}},isExported:!0},CY={description:P(`Compute the coefficients of polynomial regression of the dataset.`),args:[U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>)`,P(`The range representing the array or matrix of independent data.`)),U(`order (number)`,P(`The order of the polynomial to fit the data, between 1 and 6.`),LJ),U(`intercept (boolean, default=TRUE)`,P(`A flag specifying whether to compute the intercept or not.`),RJ)],compute:function(e,t,n,r={value:!0}){let{flatDataX:i,flatDataY:a}=BJ(e,t);return i.length===0||a.length===0?new Eo(ys):OS(a,i,L(n,this.locale),z(r))},isExported:!1},wY={description:P(`Predict value by computing a polynomial regression of the dataset.`),args:[U(`x (number, range<number>)`,P(`The value(s) on the x-axis to forecast.`)),U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>)`,P(`The range representing the array or matrix of independent data.`)),U(`order (number)`,P(`The order of the polynomial to fit the data, between 1 and 6.`),LJ),U(`intercept (boolean, default=TRUE)`,P(`A flag specifying whether to compute the intercept or not.`),RJ)],compute:function(e,t,n,r,i={value:!0}){let a=L(r,this.locale),{flatDataX:o,flatDataY:s}=BJ(t,n);if(o.length===0||s.length===0)return new Eo(ys);let c=OS(s,o,a,z(i)).flat();return rs(B(e),e=>AS(c,L(e,this.locale),a))},isExported:!1},TY={description:P(`Value nearest to a specific quartile of a dataset.`),args:[U(`data (any, range)`,P(`The array or range containing the dataset to consider.`)),U(`quartile_number (number)`,P(`Which quartile value to return.`),zJ)],compute:function(e,t){return DY.compute.bind(this)(e,t)},isExported:!0},EY={description:P(`Value nearest to a specific quartile of a dataset exclusive of 0 and 4.`),args:[U(`data (any, range)`,P(`The array or range containing the dataset to consider.`)),U(`quartile_number (number)`,P(`Which quartile value, exclusive of 0 and 4, to return.`),[{value:1,label:P(`First quartile (25th percentile)`)},{value:2,label:P(`Median value (50th percentile)`)},{value:3,label:P(`Third quartile (75th percentile)`)}])],compute:function(e,t){let n={value:.25*Math.trunc(L(t,this.locale))};return{value:UJ([e],n,!1,this.locale),format:Mo(e)}},isExported:!0},DY={description:P(`Value nearest to a specific quartile of a dataset.`),args:[U(`data (any, range)`,P(`The array or range containing the dataset to consider.`)),U(`quartile_number (number)`,P(`Which quartile value to return.`),zJ)],compute:function(e,t){let n={value:.25*Math.trunc(L(t,this.locale))};return{value:UJ([e],n,!0,this.locale),format:Mo(e)}},isExported:!0},OY={description:P(`Returns the rank of a specified value in a dataset.`),args:[U(`value (number)`,P(`The value whose rank will be determined.`)),U(`data (range)`,P(`The range containing the dataset to consider.`)),U(`is_ascending (boolean, default=FALSE)`,P(`Whether to consider the values in data in descending or ascending order.`),[{value:!1,label:P(`Descending`)},{value:!0,label:P(`Ascending`)}])],compute:function(e,t,n={value:!1}){let r=z(n),i=L(e,this.locale),a=1,o=!1;for(let e of t)for(let t of e){if(typeof t.value!=`number`)continue;let e=L(t,this.locale);e===i?o=!0:e>i!==r&&a++}return o?a:new Eo(P(`Value not found in the given data.`))},isExported:!0},kY={description:P(`Compute the square of r, the Pearson product-moment correlation coefficient of a dataset.`),args:[U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let n=_Y(e,t);return typeof n==`number`?n**2:n},isExported:!0},AY={description:P(`Compute the slope of the linear regression.`),args:[U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=BJ(e,t);if(n.length===0||r.length===0)return new Eo(ys);let[[i]]=DS([n],[r]);return i},isExported:!0},jY={description:P(`Nth smallest element in a data set.`),args:[U(`data (any, range)`,P(`The array or range containing the dataset to consider.`)),U(`n (number)`,P(`The rank from smallest to largest of the element to return.`))],compute:function(e,t){let n=Math.trunc(L(t?.value,this.locale)),r=[],i,a=0;Xo([e],e=>{typeof e?.value==`number`&&(i=fs(r,e,`nextSmaller`,`asc`,r.length,(e,t)=>e[t].value),r.splice(i+1,0,e),a++,a>n&&(r.pop(),a--))});let o=r.pop();return o===void 0?new I(ys):a<n?new I(P(`Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.`,n)):o},isExported:!0},MY={description:P(`Compute the Spearman rank correlation coefficient of a dataset.`),args:[U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=BJ(t,e);if(n.length===0||r.length===0)return new Eo(ys);let i=n.length,a=n.map((e,t)=>[e,r[t]]);a.sort((e,t)=>e[0]-t[0]);for(let e=0;e<i;++e)a[e][0]=e;a.sort((e,t)=>e[1]-t[1]);let o=0;for(let e=0;e<i;++e)o+=(a[e][0]-e)**2;return 1-6*o/(i**3-i)},isExported:!1},NY={description:P(`Standard deviation.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the sample.`))],compute:function(...e){return Math.sqrt(VY.compute.bind(this)(...e))},isExported:!0},PY={description:P(`Standard deviation of entire population.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the population.`))],compute:function(...e){return Math.sqrt(HY.compute.bind(this)(...e))},isExported:!0},FY={description:P(`Standard deviation.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the sample.`))],compute:function(...e){return Math.sqrt(UY.compute.bind(this)(...e))},isExported:!0},IY={description:P(`Standard deviation of sample (text as 0).`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the sample.`))],compute:function(...e){return Math.sqrt(WY.compute.bind(this)(...e))},isExported:!0},LY={description:P(`Standard deviation of entire population.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the population.`))],compute:function(...e){return Math.sqrt(GY.compute.bind(this)(...e))},isExported:!0},RY={description:P(`Standard deviation of entire population (text as 0).`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the population.`))],compute:function(...e){return Math.sqrt(KY.compute.bind(this)(...e))},isExported:!0},zY={description:P(`Calculates the standard error of the predicted y-value for each x in the regression of a dataset.`),args:[U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=BJ(e,t);return n.length===0||r.length===0?new Eo(ys):DS([n],[r],!0,!0)[1][2]},isExported:!0},BY={description:P(`Fits points to linear trend derived via least-squares.`),args:[U(`known_data_y (number, range<number>)`,P(`The array or range containing dependent (y) values that are already known, used to curve fit an ideal linear trend.`)),U(`known_data_x (number, range<number>, optional, default={1;2;3;...})`,P(`The values of the independent variable(s) corresponding with known_data_y.`)),U(`new_data_x (number, range<number>, optional, default=known_data_x)`,P(`The data points to return the y values for on the ideal curve fit.`)),U(`b (boolean, optional, default=TRUE)`,P(`Given a general linear form of y = m*x+b for a curve fit, calculates b if TRUE or forces b to be 0 and only calculates the m values if FALSE, i.e. forces the curve fit to pass through the origin.`),FJ)],compute:function(e,t=[[]],n=[[]],r={value:!0}){return e.length===0||e[0].length===0?new I(bs(`known_data_y`)):NS(Bo(e,`known_data_y`),Bo(t,`known_data_x`),Bo(n,`new_data_y`),z(r))}},VY={description:P(`Variance.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the sample.`))],compute:function(...e){return HJ(e,!0,!1,this.locale)},isExported:!0},HY={description:P(`Variance of entire population.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the population.`))],compute:function(...e){return HJ(e,!1,!1,this.locale)},isExported:!0},UY={description:P(`Variance.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the sample.`))],compute:function(...e){return HJ(e,!0,!1,this.locale)},isExported:!0},WY={description:P(`Variance of sample (text as 0).`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the sample.`))],compute:function(...e){return HJ(e,!0,!0,this.locale)},isExported:!0},GY={description:P(`Variance of entire population.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the population.`))],compute:function(...e){return HJ(e,!1,!1,this.locale)},isExported:!0},KY={description:P(`Variance of entire population (text as 0).`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the population.`))],compute:function(...e){return HJ(e,!1,!0,this.locale)},isExported:!0};var qY=l({DAVERAGE:()=>XY,DCOUNT:()=>ZY,DCOUNTA:()=>QY,DGET:()=>$Y,DMAX:()=>eX,DMIN:()=>tX,DPRODUCT:()=>nX,DSTDEV:()=>rX,DSTDEVP:()=>iX,DSUM:()=>aX,DVAR:()=>oX,DVARP:()=>sX});function JY(e,t,n,r){let i=new Map,a=e.length;for(let t=a-1;t>=0;t--)i.set(R(e[t][0]).toUpperCase(),t);let o=t?.value;if(typeof o!=`number`&&typeof o!=`string`)throw new I(P(`The field must be a number or a string`));let s;if(typeof o==`number`){if(s=Math.trunc(o)-1,s<0||a-1<s)throw new I(P(`The field (%(fieldValue)s) must be one of %(dimRowDB)s or must be a number between 1 and %s inclusive.`,{fieldValue:o.toString(),dimRowDB:a.toString()}))}else{let e=R(t).toUpperCase();if(s=i.get(e)??-1,s===-1)throw new I(P(`The field (%s) must be one of %s.`,R(t),[...i.keys()].toString()))}let c=n[0].length;if(c<2)throw new I(P(`The criteria range contains %s row, it must be at least 2 rows.`,c.toString()));let l=new Set,u=e[0].length;for(let t=1;t<c;t++){let a=[],o=!0;for(let r=0;r<n.length;r++){let s=R(n[r][0]).toUpperCase(),c=i.get(s),l=n[r][t];if(l.value!==null)if(c!==void 0)a.push([e[c].slice(1,u)]),a.push(l);else{o=!1;break}}if(o)if(a.length>0)ds(a,(e,t)=>{l.add(t)},r,!0);else{l=new Set(Array(u-1).keys());break}}let d=e[s];return[...l].map(e=>d[e+1])}let YY=[U(`database (range)`,P(`The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.`)),U(`field (number, string)`,P(`Indicates which column in database contains the values to be extracted and operated on.`)),U(`criteria (range)`,P(`An array or range containing zero or more criteria to filter the database values by before operating.`))],XY={description:P(`Average of a set of values from a table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return GJ.compute.bind(this)([r])},isExported:!0},ZY={description:P(`Counts values from a table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return QJ.compute.bind(this)([r])},isExported:!0},QY={description:P(`Counts values and text from a table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return $J.compute.bind(this)([r])},isExported:!0},$Y={description:P(`Single value from a table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return r.length===0?new I(P(`No match found in DGET evaluation.`)):r.length>1?new I(P(`More than one match found in DGET evaluation.`)):r[0]},isExported:!0},eX={description:P(`Maximum of values from a table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return uY.compute.bind(this)([r])},isExported:!0},tX={description:P(`Minimum of values from a table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return mY.compute.bind(this)([r])},isExported:!0},nX={description:P(`Product of values from a table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return lJ.compute.bind(this)([r])},isExported:!0},rX={description:P(`Standard deviation of population sample from table.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return NY.compute.bind(this)([r])},isExported:!0},iX={description:P(`Standard deviation of entire population from table.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return LY.compute.bind(this)([r])},isExported:!0},aX={description:P(`Sum of values from a table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return EJ.compute.bind(this)([r])},isExported:!0},oX={description:P(`Variance of population sample from table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return VY.compute.bind(this)([r])},isExported:!0},sX={description:P(`Variance of a population from a table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return GY.compute.bind(this)([r])},isExported:!0},cX=P(`The cashflow_amounts and cashflow_dates ranges must have the same dimensions.`),lX=P(`There must be both positive and negative values in cashflow_amounts.`),uX=e=>P(`The cost (%s) must be positive or null.`,e),dX=e=>P(`The cost (%s) must be strictly positive.`,e),fX=e=>P(`The frequency (%s) must be one of %s`,e,[1,2,4].toString()),pX=e=>P(`The day_count_convention (%s) must be between 0 and 4 inclusive.`,e),mX=e=>P(`The depreciation factor (%s) must be strictly positive.`,e),hX=e=>P(`The discount (%s) must be different from -1.`,e),gX=e=>P(`The discount (%s) must be strictly positive.`,e),_X=e=>P(`The discount (%s) must be smaller than 1.`,e),vX=e=>P(`The effective_rate (%s) must be strictly positive.`,e),yX=e=>P(`The end_period (%s) must be positive or null.`,e),bX=(e,t)=>P(`The end_period (%(end)s) must be smaller or equal to the life (%(life)s).`,{end:e,life:t}),xX=e=>P(`All the dates should be greater or equal to the first date in cashflow_dates (%s).`,e),SX=(e,t)=>P(`The first_period (%(first)s) must be smaller or equal to the last_period (%(last)s).`,{first:e,last:t}),CX=e=>P(`The first_period (%s) must be strictly positive.`,e),wX=e=>P(`The future_value (%s) must be strictly positive.`,e),TX=e=>P(`The investment (%s) must be strictly positive.`,e),EX=e=>P(`The issue (%s) must be positive or null.`,e),DX=(e,t)=>P(`The last_period (%(last)s) must be smaller or equal to the number_of_periods (%(nPeriods)s).`,{last:e,nPeriods:t}),OX=e=>P(`The last_period (%s) must be strictly positive.`,e),kX=e=>P(`The life (%s) must be strictly positive.`,e),AX=(e,t)=>P(`The maturity (%(maturity)s) must be strictly greater than the settlement (%(settlement)s).`,{maturity:t,settlement:e}),jX=e=>P(`The month (%s) must be between 1 and 12 inclusive.`,e),MX=e=>P(`The nominal_rate (%s) must be strictly positive.`,e),NX=e=>P(`The number_of_periods (%s) must be different from zero.`,e),PX=e=>P(`The number_of_periods (%s) must be strictly positive.`,e),FX=e=>P(`The period must be between 1 and number_of_periods (%s)`,e),IX=(e,t)=>P(`The period (%(period)s) must be less than or equal to %(lifeLimit)s.`,{period:e,lifeLimit:t}),LX=e=>P(`The period (%s) must be positive or null.`,e),RX=e=>P(`The periods_by_year (%s) must be strictly positive.`,e),zX=(e,t)=>P(`The period (%(period)s) must be less than or equal life (%(life)s).`,{period:e,life:t}),BX=e=>P(`The period (%s) must be strictly positive.`,e),VX=e=>P(`The present_value (%s) must be strictly positive.`,e),HX=e=>P(`The price (%s) must be strictly positive.`,e),UX=(e,t)=>P(`The purchase_date (%(purchaseDate)s) must be before the first_period_end (%(firstPeriodEnd)s).`,{purchaseDate:e,firstPeriodEnd:t}),WX=e=>P(`The purchase_date (%s) must be positive or null.`,e),GX=e=>P(`The rate_guess (%s) must be strictly greater than -1.`,e),KX=e=>P(`The rate (%s) must be positive or null.`,e),qX=e=>P(`The rate (%s) must be strictly positive.`,e),JX=e=>P(`The redemption (%s) must be strictly positive.`,e),YX=e=>P(`The salvage (%s) must be positive or null.`,e),XX=(e,t)=>P(`The salvage (%(salvage)s) must be smaller or equal than the cost (%(cost)s).`,{salvage:e,cost:t}),ZX=(e,t)=>P(`The settlement date (%(settlement)s) must be greater or equal to the issue date (%(issue)s).`,{settlement:e,issue:t}),QX=(e,t)=>P(`The settlement date (%(settlement)s) must at most one year after the maturity date (%(maturity)s).`,{settlement:e,maturity:t}),$X=(e,t)=>P(`The settlement date (%(settlement)s) must be strictly greater than the issue date (%(issue)s).`,{settlement:e,issue:t}),eZ=e=>P(`The start_period (%s) must be positive or null.`,e),tZ=(e,t)=>P(`The start_period (%(start)s) must be smaller or equal to the end_period (%(end)s).`,{start:e,end:t}),nZ=e=>P(`The unit (%s) must be strictly positive.`,e),rZ=e=>P(`The yield (%s) must be positive or null.`,e);function iZ(e){return e.some(e=>e>0)&&e.some(e=>e<0)}function aZ(e){return![0,1,2,3,4].includes(e)}function oZ(e){return![1,2,4].includes(e)}function sZ(e,t,n){let r=qo(e,n),i=qo(t,n),a=qo(e,n);return a.setFullYear(r.getFullYear()+1),i.getTime()<=a.getTime()}let cZ=[{value:0,label:P(`US (NASD) 30/360`)},{value:1,label:P(`Actual/Actual`)},{value:2,label:P(`Actual/360`)},{value:3,label:P(`Actual/365`)},{value:4,label:P(`European 30/360`)}];var lZ=l({DATE:()=>dZ,DATEDIF:()=>fZ,DATEVALUE:()=>pZ,DAY:()=>mZ,DAYS:()=>hZ,DAYS360:()=>gZ,EDATE:()=>_Z,EOMONTH:()=>vZ,HOUR:()=>yZ,ISOWEEKNUM:()=>bZ,MINUTE:()=>xZ,MONTH:()=>SZ,MONTH_END:()=>zZ,MONTH_START:()=>RZ,NETWORKDAYS:()=>CZ,NETWORKDAYS_INTL:()=>EZ,NOW:()=>DZ,QUARTER:()=>BZ,QUARTER_END:()=>HZ,QUARTER_START:()=>VZ,SECOND:()=>OZ,TIME:()=>kZ,TIMEVALUE:()=>AZ,TODAY:()=>jZ,WEEKDAY:()=>MZ,WEEKNUM:()=>NZ,WORKDAY:()=>PZ,WORKDAY_INTL:()=>FZ,YEAR:()=>IZ,YEARFRAC:()=>LZ,YEAR_END:()=>WZ,YEAR_START:()=>UZ}),uZ=function(e){return e.WHOLE_YEARS=`Y`,e.WHOLE_MONTHS=`M`,e.WHOLE_DAYS=`D`,e.DAYS_WITHOUT_WHOLE_MONTHS=`MD`,e.MONTH_WITHOUT_WHOLE_YEARS=`YM`,e.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR=`YD`,e}(uZ||{});let dZ={description:P(`Converts year/month/day into a date.`),args:[U(`year (number)`,P(`The year component of the date.`)),U(`month (number)`,P(`The month component of the date.`)),U(`day (number)`,P(`The day component of the date.`))],compute:function(e,t,n){let r=Math.trunc(L(e,this.locale)),i=Math.trunc(L(t,this.locale)),a=Math.trunc(L(n,this.locale));if(r<0||r>9999)return new I(P(`The year (%s) must be between 0 and 9999 inclusive.`,r.toString()));r<1900&&(r+=1900);let o=Wa(new _a(r,i-1,a));return o<0?new I(P(`The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.`)):{value:o,format:this.locale.dateFormat}},isExported:!0},fZ={description:P(`Calculates the number of days, months, or years between two dates.`),args:[U(`start_date (date)`,P(`The start date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.`)),U(`end_date (date)`,P(`The end date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.`)),U(`unit (string)`,P(`A text abbreviation for unit of time.`),[{value:`Y`,label:P(`The number of whole years between start_date and end_date`)},{value:`M`,label:P(`The number of whole months between start_date and end_date`)},{value:`D`,label:P(`The number of days between start_date and end_date`)},{value:`MD`,label:P(`The number of days between start_date and end_date after subtracting whole months`)},{value:`YM`,label:P(`The number of whole months between start_date and end_date after subtracting whole years`)},{value:`YD`,label:P(`The number of days between start_date and end_date, assuming start_date and end_date were no more than one year apart`)}])],compute:function(e,t,n){let r=R(n).toUpperCase();if(!Object.values(uZ).includes(r))return new I(Ro(Object.values(uZ),R(n)));let i=Math.trunc(L(e,this.locale)),a=Math.trunc(L(t,this.locale)),o=Ua(i),s=Ua(a);if(a<i)return new I(P(`start_date (%s) should be on or before end_date (%s).`,o.toLocaleDateString(),s.toLocaleDateString()));switch(r){case`Y`:return $a(o,s);case`M`:return Za(o,s);case`D`:return Qa(o,s);case`YM`:return Za(o,s)-$a(o,s)*12;case`MD`:let e=s.getDate()-o.getDate();return e<0&&(e=Ka(new _a(s.getFullYear(),s.getMonth()-1,1))-Math.abs(e)),e;case`YD`:{if(eo(i,a))return Qa(o,s);let e=new _a(o.getFullYear(),s.getMonth(),s.getDate()),t=Qa(o,e);return t<0&&(e.setFullYear(o.getFullYear()+1),t=Qa(o,e)),t}}},isExported:!0},pZ={description:P(`Converts a date string to a date value.`),args:[U(`date_string (string)`,P(`The string representing the date.`))],compute:function(e){let t=R(e),n=Na(t,this.locale);return n===null?new I(P(`The date_string (%s) cannot be parsed to date/time.`,t.toString())):Math.trunc(n.value)},isExported:!0},mZ={description:P(`Day of the month that a specific date falls on.`),args:[U(`date (string)`,P(`The date from which to extract the day.`))],compute:function(e){return qo(e,this.locale).getDate()},isExported:!0},hZ={description:P(`Number of days between two dates.`),args:[U(`end_date (date)`,P(`The end of the date range.`)),U(`start_date (date)`,P(`The start of the date range.`))],compute:function(e,t){let n=qo(e,this.locale),r=qo(t,this.locale),i=n.getTime()-r.getTime();return Math.round(i/ya)},isExported:!0},gZ={description:P(`Number of days between two dates on a 360-day year (months of 30 days).`),args:[U(`start_date (date)`,P(`The start date to consider in the calculation.`)),U(`end_date (date)`,P(`The end date to consider in the calculation.`)),U(`method (boolean, default=false)`,P(`An indicator of what day count method to use.`),[{value:!1,label:P(`U.S. NASD method (default)`)},{value:!0,label:P(`European method`)}])],compute:function(e,t,n={value:!1}){let r=Math.trunc(L(e,this.locale)),i=Math.trunc(L(t,this.locale)),a=Xa(r,i,z(n)?4:0);return Math.sign(i-r)*Math.round(a*360)},isExported:!0},_Z={description:P(`Date a number of months before/after another date.`),args:[U(`start_date (date)`,P(`The date from which to calculate the result.`)),U(`months (number)`,P(`The number of months before (negative) or after (positive) 'start_date' to calculate.`))],compute:function(e,t){return{value:Wa(Ja(qo(e,this.locale),Math.trunc(L(t,this.locale)),!1)),format:this.locale.dateFormat}},isExported:!0},vZ={description:P(`Last day of a month before or after a date.`),args:[U(`start_date (date)`,P(`The date from which to calculate the result.`)),U(`months (number)`,P(`The number of months before (negative) or after (positive) 'start_date' to consider.`))],compute:function(e,t){let n=qo(e,this.locale),r=Math.trunc(L(t,this.locale));return{value:Wa(new _a(n.getFullYear(),n.getMonth()+r+1,0)),format:this.locale.dateFormat}},isExported:!0},yZ={description:P(`Hour component of a specific time.`),args:[U(`time (date)`,P(`The time from which to calculate the hour component.`))],compute:function(e){return qo(e,this.locale).getHours()},isExported:!0},bZ={description:P(`ISO week number of the year.`),args:[U(`date (date)`,P(`The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.`))],compute:function(e){let t=qo(e,this.locale),n=t.getFullYear(),r=1;for(;new _a(n,0,r).getDay()!==4;)r+=1;let i=new _a(n,0,r-3),a=31;for(;new _a(n,11,a).getDay()!==4;)--a;let o=new _a(n,11,a+3),s;s=i.getTime()<=t.getTime()?t.getTime()<=o.getTime()?0:1:-1;let c;switch(s){case 0:c=i;break;case 1:c=new _a(n,11,a+3+1);break;case-1:let e=1;for(;new _a(n-1,0,e).getDay()!==4;)e+=1;c=new _a(n-1,0,e-3);break}let l=(t.getTime()-c.getTime())/ya;return Math.floor(l/7)+1},isExported:!0},xZ={description:P(`Minute component of a specific time.`),args:[U(`time (date)`,P(`The time from which to calculate the minute component.`))],compute:function(e){return qo(e,this.locale).getMinutes()},isExported:!0},SZ={description:P(`Month of the year a specific date falls in`),args:[U(`date (date)`,P(`The date from which to extract the month.`))],compute:function(e){return qo(e,this.locale).getMonth()+1},isExported:!0},CZ={description:P(`Net working days between two provided days.`),args:[U(`start_date (date)`,P(`The start date of the period from which to calculate the number of net working days.`)),U(`end_date (date)`,P(`The end date of the period from which to calculate the number of net working days.`)),U(`holidays (date, range<date>, optional)`,P(`A range or array constant containing the date serial numbers to consider holidays.`))],compute:function(e,t,n){return EZ.compute.bind(this)(e,t,{value:1},n)},isExported:!0};function wZ(e){let t=e?.value;if(typeof t==`string`){oS(t.length===7&&[...t].every(e=>e===`0`||e===`1`),P(`When weekend is a string (%s) it must be composed of "0" or "1".`,t));let e=[];for(let n=0;n<7;n++)t[n]===`1`&&e.push((n+1)%7);return e}if(typeof t==`number`)return oS(1<=t&&t<=7||11<=t&&t<=17,P(`The weekend (%s) must be a string or a number in the range 1-7 or 11-17.`,t.toString())),t<=7?[t-2==-1?6:t-2,t-1]:[t-11];throw new I(P(`The weekend must be a number or a string.`))}let TZ=[{value:1,label:P(`Saturday/Sunday are weekends`)},{value:2,label:P(`Sunday/Monday are weekends`)},{value:3,label:P(`Monday/Tuesday are weekends`)},{value:4,label:P(`Tuesday/Wednesday are weekends`)},{value:5,label:P(`Wednesday/Thursday are weekends`)},{value:6,label:P(`Thursday/Friday are weekends`)},{value:7,label:P(`Friday/Saturday are weekends`)},{value:11,label:P(`Sunday is the only weekend`)},{value:12,label:P(`Monday is the only weekend`)},{value:13,label:P(`Tuesday is the only weekend`)},{value:14,label:P(`Wednesday is the only weekend`)},{value:15,label:P(`Thursday is the only weekend`)},{value:16,label:P(`Friday is the only weekend`)},{value:17,label:P(`Saturday is the only weekend`)}],EZ={description:P(`Net working days between two dates (specifying weekends).`),args:[U(`start_date (date)`,P(`The start date of the period from which to calculate the number of net working days.`)),U(`end_date (date)`,P(`The end date of the period from which to calculate the number of net working days.`)),U(`weekend (any, default=1)`,P(`A number or string representing which days of the week are considered weekends.`),TZ),U(`holidays (date, range<date>, optional)`,P(`A range or array constant containing the dates to consider as holidays.`))],compute:function(e,t,n={value:1},r){let i=qo(e,this.locale),a=qo(t,this.locale),o=wZ(n),s=new Set;r!==void 0&&Xo([r],e=>{let t=qo(e,this.locale);s.add(t.getTime())});let c=i.getTime()>a.getTime(),l=_a.fromTimestamp((c?i:a).getTime()),u=_a.fromTimestamp((c?a:i).getTime()),d=l.getTime(),f=u.getTime(),p=0;for(;f<=d;)!o.includes(u.getDay())&&!s.has(f)&&(p+=1),u.setDate(u.getDate()+1),f=u.getTime();return c?-p:p},isExported:!0},DZ={description:P(`Current date and time as a date value.`),args:[],compute:function(){let e=_a.now(),t=e.getTime()-va.getTime(),n=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return{value:Math.floor(t/ya)+n,format:iv(this.locale)}},isExported:!0},OZ={description:P(`Minute component of a specific time.`),args:[U(`time (date)`,P(`The time from which to calculate the second component.`))],compute:function(e){return qo(e,this.locale).getSeconds()},isExported:!0},kZ={description:P(`Converts hour/minute/second into a time.`),args:[U(`hour (number)`,P(`The hour component of the time.`)),U(`minute (number)`,P(`The minute component of the time.`)),U(`second (number)`,P(`The second component of the time.`))],compute:function(e,t,n){let r=Math.trunc(L(e,this.locale)),i=Math.trunc(L(t,this.locale)),a=Math.trunc(L(n,this.locale));return i+=Math.floor(a/60),a=a%60+(a<0?60:0),r+=Math.floor(i/60),i=i%60+(i<0?60:0),r%=24,r<0?new I(P(`The function [[FUNCTION_NAME]] result cannot be negative`)):{value:r/24+i/1440+a/(1440*60),format:this.locale.timeFormat}},isExported:!0},AZ={description:P(`Converts a time string into its serial number representation.`),args:[U(`time_string (string)`,P(`The string that holds the time representation.`))],compute:function(e){let t=R(e),n=Na(t,this.locale);if(n===null)return new I(P(`The time_string (%s) cannot be parsed to date/time.`,t));let r=n.value-Math.trunc(n.value);return r<0?1+r:r},isExported:!0},jZ={description:P(`Current date as a date value.`),args:[],compute:function(){let e=_a.now();return{value:Wa(new _a(e.getFullYear(),e.getMonth(),e.getDate())),format:this.locale.dateFormat}},isExported:!0},MZ={description:P(`Day of the week of the date provided (as number).`),args:[U(`date (date)`,P(`The date for which to determine the day of the week. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),U(`type (number, default=1)`,P(`A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.`),[{value:1,label:P(`Numbers 1 (Sunday) trough 7 (Saturday)`)},{value:2,label:P(`Numbers 1 (Monday) trough 7 (Sunday)`)},{value:3,label:P(`Numbers 0 (Monday) trough 6 (Sunday)`)},{value:11,label:P(`Numbers 1 (Monday) trough 7 (Sunday)`)},{value:12,label:P(`Numbers 1 (Tuesday) trough 7 (Monday)`)},{value:13,label:P(`Numbers 1 (Wednesday) trough 7 (Tuesday)`)},{value:14,label:P(`Numbers 1 (Thursday) trough 7 (Wednesday)`)},{value:15,label:P(`Numbers 1 (Friday) trough 7 (Thursday)`)},{value:16,label:P(`Numbers 1 (Saturday) trough 7 (Friday)`)},{value:17,label:P(`Numbers 1 (Sunday) trough 7 (Saturday)`)}])],compute:function(e,t={value:1}){let n=qo(e,this.locale),r=Math.round(L(t,this.locale)),i=n.getDay();if(!(1<=r&&r<=3)&&!(11<=r&&r<=17))return new I(P(`The type (%s) must be between 1 and 3 or between 11 and 17.`,r));switch(r){case 1:return i+1;case 2:return i===0?7:i;case 3:return i===0?6:i-1}let a=r-10,o=(i+1-a+7)%7;return o===0?7:o},isExported:!0},NZ={description:P(`Week number of the year.`),args:[U(`date (date)`,P(`The date for which to determine the week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),U(`type (number, default=1)`,P(`A number representing the day that a week starts on. Sunday = 1.`),[{value:1,label:P(`Sunday`)},{value:2,label:P(`Monday`)},{value:11,label:P(`Monday`)},{value:12,label:P(`Tuesday`)},{value:13,label:P(`Wednesday`)},{value:14,label:P(`Thursday`)},{value:15,label:P(`Friday`)},{value:16,label:P(`Saturday`)},{value:17,label:P(`Sunday`)},{value:21,label:P(`ISO week number (Monday as first day of the week)`)}])],compute:function(e,t={value:1}){let n=qo(e,this.locale),r=Math.round(L(t,this.locale));if(![1,2,11,12,13,14,15,16,17,21].includes(r))return new I(P(`The type (%s) is out of range.`,r.toString()));if(r===21)return bZ.compute.bind(this)(e);let i;i=r===1||r===2?r-1:r-10==7?0:r-10;let a=n.getFullYear(),o=1,s=new _a(a,0,o);for(;s.getDay()!==i;)o+=1,s=new _a(a,0,o);let c=(n.getTime()-s.getTime())/ya;return c<0?1:Math.floor(c/7)+(o===1?1:2)},isExported:!0},PZ={description:P(`Date after a number of workdays.`),args:[U(`start_date (date)`,P(`The date from which to begin counting.`)),U(`num_days (number)`,P(`The number of working days to advance from start_date. If negative, counts backwards.`)),U(`holidays (date, range<date>, optional)`,P(`A range or array constant containing the dates to consider holidays.`))],compute:function(e,t,n={value:null}){return FZ.compute.bind(this)(e,t,{value:1},n)},isExported:!0},FZ={description:P(`Date after a number of workdays (specifying weekends).`),args:[U(`start_date (date)`,P(`The date from which to begin counting.`)),U(`num_days (number)`,P(`The number of working days to advance from start_date. If negative, counts backwards.`)),U(`weekend (any, default=1)`,P(`A number or string representing which days of the week are considered weekends.`),TZ),U(`holidays (date, range<date>, optional)`,P(`A range or array constant containing the dates to consider holidays.`))],compute:function(e,t,n={value:1},r){let i=qo(e,this.locale),a=Math.trunc(L(t,this.locale));if(n.value===`1111111`)return new I(P(`The weekend must be different from '1111111'.`));let o=wZ(n),s=new Set;r!==void 0&&Xo([r],e=>{let t=qo(e,this.locale);s.add(t.getTime())});let c=_a.fromTimestamp(i.getTime()),l=c.getTime(),u=Math.sign(a),d=Math.abs(a);for(;d>0;)c.setDate(c.getDate()+u),l=c.getTime(),!o.includes(c.getDay())&&!s.has(l)&&--d;let f=l-va.getTime();return{value:Math.round(f/ya),format:this.locale.dateFormat}},isExported:!0},IZ={description:P(`Year specified by a given date.`),args:[U(`date (date)`,P(`The date from which to extract the year.`))],compute:function(e){return qo(e,this.locale).getFullYear()},isExported:!0},LZ={description:P(`Exact number of years between two dates.`),args:[U(`start_date (date)`,P(`The start date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),U(`end_date (date)`,P(`The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),U(`day_count_convention (number, default=0)`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n={value:0}){let r=Math.trunc(L(e,this.locale)),i=Math.trunc(L(t,this.locale)),a=Math.trunc(L(n,this.locale));return r<0?new I(P(`The start_date (%s) must be positive or null.`,r)):i<0?new I(P(`The end_date (%s) must be positive or null.`,i)):0>a||a>4?new I(P(`The day_count_convention (%s) must be between 0 and 4 inclusive.`,a)):Xa(r,i,a)}},RZ={description:P(`First day of the month a date falls in.`),args:[U(`date (date)`,P(`The date from which to calculate the result.`))],compute:function(e){let t=qo(e,this.locale);return{value:Wa(new _a(t.getFullYear(),t.getMonth(),1)),format:this.locale.dateFormat}}},zZ={description:P(`Last day of the month a date falls in.`),args:[U(`date (date)`,P(`The date from which to calculate the result.`))],compute:function(e){return vZ.compute.bind(this)(e,{value:0})}},BZ={description:P(`Quarter of the year a specific date falls in`),args:[U(`date (date)`,P(`The date from which to extract the quarter.`))],compute:function(e){return Math.ceil((qo(e,this.locale).getMonth()+1)/3)}},VZ={description:P(`First day of the quarter of the year a specific date falls in.`),args:[U(`date (date)`,P(`The date from which to calculate the start of quarter.`))],compute:function(e){let t=BZ.compute.bind(this)(e);return{value:Wa(new _a(IZ.compute.bind(this)(e),(t-1)*3,1)),format:this.locale.dateFormat}}},HZ={description:P(`Last day of the quarter of the year a specific date falls in.`),args:[U(`date (date)`,P(`The date from which to calculate the end of quarter.`))],compute:function(e){let t=BZ.compute.bind(this)(e);return{value:Wa(new _a(IZ.compute.bind(this)(e),t*3,0)),format:this.locale.dateFormat}}},UZ={description:P(`First day of the year a specific date falls in.`),args:[U(`date (date)`,P(`The date from which to calculate the start of the year.`))],compute:function(e){return{value:Wa(new _a(IZ.compute.bind(this)(e),0,1)),format:this.locale.dateFormat}}},WZ={description:P(`Last day of the year a specific date falls in.`),args:[U(`date (date)`,P(`The date from which to calculate the end of the year.`))],compute:function(e){return{value:Wa(new _a(IZ.compute.bind(this)(e)+1,0,0)),format:this.locale.dateFormat}}};var GZ=l({DELTA:()=>KZ});let KZ={description:P(`Compare two numeric values, returning 1 if they're equal.`),args:[U(`number1 (number)`,P(`The first number to compare.`)),U(`number2 (number, default=0)`,P(`The second number to compare.`))],compute:function(e,t={value:0}){return+(L(e,this.locale)===L(t,this.locale))},isExported:!0};var qZ=l({FILTER:()=>YZ,SORT:()=>XZ,SORTN:()=>ZZ,UNIQUE:()=>QZ});function JZ(e,t,...n){for(let e=0;e<n.length;e++){let t=e%2==0?`sort_column`:`is_ascending`;oS(n[e]!==void 0,P(`Value for parameter %s is missing in [[FUNCTION_NAME]].`,t))}let r=[],i=[],a=e.length;for(let o=0;o<n.length;o+=2){r.push(z(gS(n[o+1])?.value)?`asc`:`desc`);let s=n[o];if(ht(s)&&(s.length>1||s[0].length>1))oS(s.length===1&&s[0].length===a,P(`Wrong size for %s. Expected a range of size 1x%s. Got %sx%s.`,`sort_column${o+1}`,a,s.length,s[0].length)),i.push(s.flat().map(e=>e.value));else{let n=L(gS(s)?.value,t);if(n<1||n>e[0].length)return e;i.push(e.map(e=>e[n-1].value))}}if(i.length===0)for(let t=0;t<e[0].length;t++)i.push(e.map(e=>e[t].value)),r.push(`asc`);let o={desc:NV(`desc`),asc:NV(`asc`)},s=C(0,e.length);return s.sort((e,t)=>{for(let[n,a]of i.entries()){let i=a[e],s=a[t],c={value:i,type:i===null?`empty`:typeof i==`string`?`text`:typeof i},l={value:s,type:s===null?`empty`:typeof s==`string`?`text`:typeof s},u=o[r[n]](c,l);if(u!==0)return u}return 0}),s.map(t=>e[t])}let YZ={description:P(`Returns a filtered version of the source range, returning only rows or columns that meet the specified conditions.`),args:[U(`range (any, range<any>)`,P(`The data to be filtered.`)),U(`condition (boolean, range<boolean>, repeating)`,P(`Column or row containing true or false values corresponding to the range.`))],compute:function(e,...t){let n=B(e),r=t.map(e=>rs(B(e),e=>e.value));for(let e of r)if(!cS(e))return new I(P(`The arguments condition must be a single column or row.`));if(!lS(...t))return new I(P(`The arguments conditions must have the same dimensions.`));let i=r.map(e=>e.flat()),a=r[0].length===1?`row`:`col`;if(n=a===`row`?as(n):n,i.some(e=>e.length!==n.length))return new I(P(`FILTER has mismatched sizes on the range and conditions.`));let o=[];for(let e=0;e<n.length;e++){let t=n[e];i.every(t=>(typeof t[e]==`boolean`||typeof t[e]==`number`)&&t[e])&&o.push(t)}return o.length?a===`row`?as(o):o:new Eo(P(`No match found in FILTER evaluation`))},isExported:!1},XZ={description:P(`Sorts the rows of a given array or range by the values in one or more columns.`),args:[U(`range (range)`,P(`The data to be sorted.`)),U(`sort_column (any, range<number>, repeating, optional)`,P(`The index of the column in range or a range outside of range containing the value by which to sort.`)),U(`is_ascending (boolean, repeating, optional)`,P(`TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.`),[{value:!0,label:P(`Ascending`)},{value:!1,label:P(`Descending`)}])],compute:function(e,...t){return as(JZ(as(e),this.locale,...t))},isExported:!0},ZZ={description:P(`Returns the first n items in a data set after performing a sort.`),args:[U(`range (range)`,P(`The data to be sorted.`)),U(`n (number)`,P(`The number of items to return.`)),U(`display_ties_mode (number, default=0)`,P(`A number representing the way to display ties.`)),U(`sort_column (number, range<number>, repeating, optional)`,P(`The index of the column in range or a range outside of range containing the value by which to sort.`)),U(`is_ascending (boolean, repeating, optional)`,P(`TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.`),[{value:!0,label:P(`Ascending`)},{value:!1,label:P(`Descending`)}])],compute:function(e,t,...n){let r=L(t?.value??1,this.locale),i=n.length%2==0?0:L(n[0]?.value,this.locale),a=n.length%2==0?n:n.slice(1);if(r<0)return new I(P(`Wrong value of 'n'. Expected a positive number. Got %s.`,r));if(i<0||i>3)return new I(P(`Wrong value of 'display_ties_mode'. Expected a positive number between 0 and 3. Got %s.`,i));let o=JZ(as(e),this.locale,...a),s=(e,t)=>JSON.stringify(o[e].map(e=>e.value))===JSON.stringify(o[t].map(e=>e.value));switch(i){case 0:return as(o.slice(0,r));case 1:for(let e=r;e<o.length;e++)if(!s(e,r-1))return as(o.slice(0,e));return as(o);case 2:{let e=[o[0]];for(let t=1;t<o.length;t++)for(let n=0;n<t&&!s(t,n);n++)n===t-1&&e.push(o[t]);return as(e.slice(0,r))}case 3:{let e=[o[0]],t=1;for(let n=1;n<o.length&&(s(n,n-1)||t++,!(t>r));n++)e.push(o[n]);return as(e)}}},isExported:!1},QZ={description:P(`Unique rows in the provided source range.`),args:[U(`range (any, range<any>)`,P(`The data to filter by unique entries.`)),U(`by_column (boolean, default=FALSE)`,P(`Whether to filter the data by columns or by rows.`),[{value:!0,label:P(`Return unique columns`)},{value:!1,label:P(`Return unique rows`)}]),U(`exactly_once (boolean, default=FALSE)`,P(`Whether to return only entries with no duplicates.`),[{value:!0,label:P(`Return items that appear exactly once`)},{value:!1,label:P(`Return every distinct item`)}])],compute:function(e={value:``},t,n){if(!ht(e))return[[e]];let r=z(t?.value)||!1,i=z(n?.value)||!1;r||(e=as(e));let a=new Map;for(let t of e){let e=JSON.stringify(t.map(e=>e.value)),n=a.get(e);n?n.count++:a.set(e,{data:t,count:1})}let o=[];for(let e of a.values())i&&e.count>1||o.push(e.data);return o.length?r?o:as(o):new I(P(`No unique values found`))},isExported:!0};var $Z=l({ACCRINTM:()=>iQ,AMORLINC:()=>aQ,COUPDAYBS:()=>sQ,COUPDAYS:()=>oQ,COUPDAYSNC:()=>cQ,COUPNCD:()=>lQ,COUPNUM:()=>uQ,COUPPCD:()=>dQ,CUMIPMT:()=>fQ,CUMPRINC:()=>pQ,DB:()=>mQ,DDB:()=>gQ,DISC:()=>_Q,DOLLARDE:()=>vQ,DOLLARFR:()=>yQ,DURATION:()=>bQ,EFFECT:()=>xQ,FV:()=>CQ,FVSCHEDULE:()=>wQ,INTRATE:()=>TQ,IPMT:()=>DQ,IRR:()=>kQ,ISPMT:()=>AQ,MDURATION:()=>jQ,MIRR:()=>MQ,NOMINAL:()=>NQ,NPER:()=>PQ,NPV:()=>IQ,PDURATION:()=>LQ,PMT:()=>zQ,PPMT:()=>VQ,PRICE:()=>UQ,PRICEDISC:()=>WQ,PRICEMAT:()=>GQ,PV:()=>HQ,RATE:()=>qQ,RECEIVED:()=>JQ,RRI:()=>YQ,SLN:()=>XQ,SYD:()=>ZQ,TBILLEQ:()=>e$,TBILLPRICE:()=>$Q,TBILLYIELD:()=>t$,VDB:()=>n$,XIRR:()=>r$,XNPV:()=>i$,YIELD:()=>a$,YIELDDISC:()=>o$,YIELDMAT:()=>s$});let eQ=[{value:1,label:P(`Annual`)},{value:2,label:P(`Semi-annual`)},{value:4,label:P(`Quarterly`)}],tQ=[{value:0,label:P(`End of period (default)`)},{value:1,label:P(`Beginning of period`)}],nQ=[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`frequency (number)`,P(`The number of interest or coupon payments per year (1, 2, or 4).`),eQ),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)];function rQ(e,t,n,r,i=1e-10,a){let o=n,s,c,l,u=!1,d=0,f;do{if(l=e(o),isNaN(l)){oS(d<r&&a!==void 0,P(`Function [[FUNCTION_NAME]] didn't find any result.`)),d++,o=a(f),f=o;continue}s=o-l/t(o),c=Math.abs(s-o),o=s,u=c<i||Math.abs(l)<i,oS(d<r,P(`Function [[FUNCTION_NAME]] didn't find any result.`)),d++}while(!u);return o}let iQ={description:P(`Accrued interest of security paying at maturity.`),args:[U(`issue (date)`,P(`The date the security was initially issued.`)),U(`maturity (date)`,P(`The maturity date of the security.`)),U(`rate (number)`,P(`The annualized rate of interest.`)),U(`redemption (number)`,P(`The redemption amount per 100 face value, or par.`)),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i={value:0}){let a=Math.trunc(L(e,this.locale)),o=Math.trunc(L(t,this.locale)),s=L(r,this.locale),c=L(n,this.locale),l=Math.trunc(L(i,this.locale));if(a<0)return new I(EX(a));if(a>=o)return new I(AX(a,o));if(aZ(l))return new I(pX(l));if(s<=0)return new I(JX(s));if(c<=0)return new I(qX(c));let u=Xa(a,o,l);return s*c*u},isExported:!0},aQ={description:P(`Depreciation for an accounting period.`),args:[U(`cost (number)`,P(`The initial cost of the asset.`)),U(`purchase_date (date)`,P(`The date the asset was purchased.`)),U(`first_period_end (date)`,P(`The date the first period ended.`)),U(`salvage (number)`,P(`The value of the asset at the end of depreciation.`)),U(`period (number)`,P(`The single period within life for which to calculate depreciation.`)),U(`rate (number)`,P(`The deprecation rate.`)),U(`day_count_convention (number, optional)`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=L(e,this.locale),c=Math.trunc(L(t,this.locale)),l=Math.trunc(L(n,this.locale)),u=L(r,this.locale),d=L(i,this.locale),f=L(a,this.locale),p=Math.trunc(L(o,this.locale));if(s<=0)return new I(dX(s));if(c<0)return new I(WX(c));if(u<0)return new I(YX(u));if(u>s)return new I(XX(u,s));if(d<0)return new I(LX(d));if(f<=0)return new I(qX(f));if(aZ(p))return new I(pX(p));if(c>l)return new I(UX(c,l));let m=d<1&&d>0?1:Math.trunc(d),h=s*f,g=Xa(c,l,p),_=c===l?h:h*g,v=s-_-h*m;return v>=u?m===0?_:h:u-v<h?h-(u-v):0},isExported:!0},oQ={description:P(`Days in coupon period containing settlement date.`),args:nQ,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(L(e,this.locale)),a=Math.trunc(L(t,this.locale)),o=Math.trunc(L(n,this.locale)),s=Math.trunc(L(r,this.locale));if(i>=a)return new I(AX(i,a));if(oZ(o))return new I(fX(o));if(aZ(s))return new I(pX(s));if(s===1){let i=dQ.compute.bind(this)(e,t,n,r).value,a=lQ.compute.bind(this)(e,t,n,r).value;return L(a,this.locale)-L(i,this.locale)}return(s===3?365:360)/o},isExported:!0},sQ={description:P(`Days from settlement until next coupon.`),args:nQ,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(L(e,this.locale)),a=Math.trunc(L(t,this.locale)),o=Math.trunc(L(n,this.locale)),s=Math.trunc(L(r,this.locale));if(i>=a)return new I(AX(i,a));if(oZ(o))return new I(fX(o));if(aZ(s))return new I(pX(s));let c=dQ.compute.bind(this)(e,t,n,r).value,l=L(c,this.locale);if([1,2,3].includes(s))return i-l;if(s===4){let e=Xa(l,i,s);return Math.round(e*360)}let u=qo(i,this.locale),d=qo(l,this.locale),f=d.getFullYear(),p=u.getFullYear(),m=d.getMonth()+1,h=u.getMonth()+1,g=d.getDate(),_=u.getDate();return m===2&&h===2&&qa(d)&&qa(u)&&(_=30),_===31&&(g===30||g===31)&&(_=30),m===2&&qa(d)&&(g=30),g===31&&(g=30),(p-f)*360+(h-m)*30+(_-g)},isExported:!0},cQ={description:P(`Days from settlement until next coupon.`),args:nQ,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(L(e,this.locale)),a=Math.trunc(L(t,this.locale)),o=Math.trunc(L(n,this.locale)),s=Math.trunc(L(r,this.locale));if(i>=a)return new I(AX(i,a));if(oZ(o))return new I(fX(o));if(aZ(s))return new I(pX(s));let c=lQ.compute.bind(this)(e,t,n,r).value,l=L(c,this.locale);if([1,2,3].includes(s))return l-i;if(s===4){let e=Xa(i,l,s);return Math.round(e*360)}let u=sQ.compute.bind(this)(e,t,n,r);return L(oQ.compute.bind(this)(e,t,n,r),this.locale)-L(u,this.locale)},isExported:!0},lQ={description:P(`Next coupon date after the settlement date.`),args:nQ,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(L(e,this.locale)),a=Math.trunc(L(t,this.locale)),o=Math.trunc(L(n,this.locale)),s=Math.trunc(L(r,this.locale));if(i>=a)return new I(AX(i,a));if(oZ(o))return new I(fX(o));if(aZ(s))return new I(pX(s));let c=12/o,l=uQ.compute.bind(this)(e,t,n,r);return{value:Wa(Ja(qo(a,this.locale),-(L(l,this.locale)-1)*c,!0)),format:this.locale.dateFormat}},isExported:!0},uQ={description:P(`Number of coupons between settlement and maturity.`),args:nQ,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(L(e,this.locale)),a=Math.trunc(L(t,this.locale)),o=Math.trunc(L(n,this.locale)),s=Math.trunc(L(r,this.locale));if(i>=a)return new I(AX(i,a));if(oZ(o))return new I(fX(o));if(aZ(s))return new I(pX(s));let c=1,l=a,u=12/o;for(;l>i;)l=Wa(Ja(qo(l,this.locale),-u,!1)),c++;return c-1},isExported:!0},dQ={description:P(`Last coupon date prior to or on the settlement date.`),args:nQ,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(L(e,this.locale)),a=Math.trunc(L(t,this.locale)),o=Math.trunc(L(n,this.locale)),s=Math.trunc(L(r,this.locale));if(i>=a)return new I(AX(i,a));if(oZ(o))return new I(fX(o));if(aZ(s))return new I(pX(s));let c=12/o,l=uQ.compute.bind(this)(e,t,n,r);return{value:Wa(Ja(qo(a,this.locale),-l*c,!0)),format:this.locale.dateFormat}},isExported:!0},fQ={description:P(`Cumulative interest paid over a set of periods.`),args:[U(`rate (number)`,P(`The interest rate.`)),U(`number_of_periods (number)`,P(`The number of payments to be made.`)),U(`present_value (number)`,P(`The current value of the annuity.`)),U(`first_period (number)`,P(`The number of the payment period to begin the cumulative calculation.`)),U(`last_period (number)`,P(`The number of the payment period to end the cumulative calculation.`)),U(`end_or_beginning (number, default=0)`,P(`The timing of the payment payments are due for each period.`),tQ)],compute:function(e,t,n,r,i,a={value:0}){let o=L(r,this.locale),s=L(i,this.locale),c=L(e,this.locale),l=L(n,this.locale),u=L(t,this.locale),d=+!!z(a);if(u<=0)return new I(PX(u));if(o<=0)return new I(CX(o));if(s<=0)return new I(OX(s));if(o>s)return new I(SX(o,s));if(s>u)return new I(DX(s,u));if(c<=0)return new I(qX(c));if(l<=0)return new I(VX(l));let f=0;for(let e=o;e<=s;e++)f+=EQ(c,e,u,l,0,d);return f},isExported:!0},pQ={description:P(`Cumulative principal paid over a set of periods.`),args:[U(`rate (number)`,P(`The interest rate.`)),U(`number_of_periods (number)`,P(`The number of payments to be made.`)),U(`present_value (number)`,P(`The current value of the annuity.`)),U(`first_period (number)`,P(`The number of the payment period to begin the cumulative calculation.`)),U(`last_period (number)`,P(`The number of the payment period to end the cumulative calculation.`)),U(`end_or_beginning (number, default=0)`,P(`The timing of the payment payments are due for each period.`),tQ)],compute:function(e,t,n,r,i,a={value:0}){let o=L(r,this.locale),s=L(i,this.locale),c=L(e,this.locale),l=L(n,this.locale),u=L(t,this.locale),d=+!!z(a);if(u<=0)return new I(PX(u));if(o<=0)return new I(CX(o));if(s<=0)return new I(OX(s));if(o>s)return new I(SX(o,s));if(s>u)return new I(DX(s,u));if(c<=0)return new I(qX(c));if(l<=0)return new I(VX(l));let f=0;for(let e=o;e<=s;e++)f+=BQ(c,e,u,l,0,d);return f},isExported:!0},mQ={description:P(`Depreciation via declining balance method.`),args:[U(`cost (number)`,P(`The initial cost of the asset.`)),U(`salvage (number)`,P(`The value of the asset at the end of depreciation.`)),U(`life (number)`,P(`The number of periods over which the asset is depreciated.`)),U(`period (number)`,P(`The single period within life for which to calculate depreciation.`)),U(`month (number, optional)`,P(`The number of months in the first year of depreciation.`))],compute:function(e,t,n,r,...i){let a=L(e,this.locale),o=L(t,this.locale),s=L(n,this.locale),c=Math.trunc(L(r,this.locale)),l=i.length?Math.trunc(L(i[0],this.locale)):12,u=s+(l===12?0:1);if(a<0)return new I(uX(a));if(o<0)return new I(YX(o));if(c<=0)return new I(BX(c));if(s<=0)return new I(kX(s));if(1>l||l>12)return new I(jX(l));if(c>u)return new I(IX(c,u));let d=l/12,f=1-(o/a)**(1/s);f=Math.round(f*1e3)/1e3;let p=a,m=a*(1-f*d);for(let e=1;e<c;e++)p=m,m=p*(1-f),e===s&&(m=p*(1-f*(1-d)));return{value:p-m,format:`#,##0.00`}},isExported:!0},hQ=`#,##0.00`,gQ={description:P(`Depreciation via double-declining balance method.`),args:[U(`cost (number)`,P(`The initial cost of the asset.`)),U(`salvage (number)`,P(`The value of the asset at the end of depreciation.`)),U(`life (number)`,P(`The number of periods over which the asset is depreciated.`)),U(`period (number)`,P(`The single period within life for which to calculate depreciation.`)),U(`factor (number, default=2)`,P(`The factor by which depreciation decreases.`))],compute:function(e,t,n,r,i={value:2}){let a=L(e,this.locale),o=L(t,this.locale),s=L(n,this.locale),c=L(r,this.locale),l=L(i,this.locale);if(a<0)return new I(uX(a));if(o<0)return new I(YX(o));if(c<=0)return new I(BX(c));if(s<=0)return new I(kX(s));if(c>s)return new I(zX(c,s));if(l<=0)return new I(mX(l));if(a===0||o>=a)return{value:0,format:hQ};let u=l/s;if(u>1)return{value:c===1?a-o:0,format:hQ};if(c<=1)return{value:a*u,format:hQ};let d=a*(1-u)**(c-1),f=a*(1-u)**c,p=f<o?d-o:d-f;return{value:Math.max(p,0),format:hQ}},isExported:!0},_Q={description:P(`Discount rate of a security based on price.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`price (number)`,P(`The price at which the security is bought per 100 face value.`)),U(`redemption (number)`,P(`The redemption amount per 100 face value, or par.`)),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(L(e,this.locale)),o=Math.trunc(L(t,this.locale)),s=L(n,this.locale),c=L(r,this.locale),l=Math.trunc(L(i,this.locale));if(a>=o)return new I(AX(a,o));if(aZ(l))return new I(pX(l));if(s<=0)return new I(HX(s));if(c<=0)return new I(JX(c));let u=Xa(a,o,l);return(c-s)/c/u},isExported:!0},vQ={description:P(`Convert a decimal fraction to decimal value.`),args:[U(`fractional_price (number)`,P(`The price quotation given using fractional decimal conventions.`)),U(`unit (number)`,P(`The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.`))],compute:function(e,t){let n=L(e,this.locale),r=Math.trunc(L(t,this.locale));if(r<=0)return new I(nZ(r));let i=Math.trunc(n);return i+(n-i)*(10**Math.ceil(Math.log10(r))/r)},isExported:!0},yQ={description:P(`Convert a decimal value to decimal fraction.`),args:[U(`decimal_price (number)`,P(`The price quotation given as a decimal value.`)),U(`unit (number)`,P(`The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.`))],compute:function(e,t){let n=L(e,this.locale),r=Math.trunc(L(t,this.locale));if(r<=0)return new I(nZ(r));let i=Math.trunc(n);return i+(n-i)*(r/10**Math.ceil(Math.log10(r)))},isExported:!0},bQ={description:P(`Number of periods for an investment to reach a value.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`rate (number)`,P(`The annualized rate of interest.`)),U(`yield (number)`,P(`The expected annual yield of the security.`)),U(`frequency (number)`,P(`The number of interest or coupon payments per year (1, 2, or 4).`),eQ),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i,a={value:0}){let o=Math.trunc(L(e,this.locale)),s=Math.trunc(L(t,this.locale)),c=L(n,this.locale),l=L(r,this.locale),u=Math.trunc(L(i,this.locale)),d=Math.trunc(L(a,this.locale));if(o>=s)return new I(AX(o,s));if(oZ(u))return new I(fX(u));if(aZ(d))return new I(pX(d));if(c<0)return new I(KX(c));if(l<0)return new I(rZ(l));let f=Xa(o,s,d),p=f-Math.trunc(f)||1/u,m=Math.ceil(f*u),h=c/u,g=l/u,_=0,v=0;for(let e=1;e<=m;e++){let t=(h+ +(e===m))/(1+g)**e;v+=(p+(e-1)/u)*t,_+=t}return _===0?0:v/_},isExported:!0},xQ={description:P(`Annual effective interest rate.`),args:[U(`nominal_rate (number)`,P(`The nominal interest rate per year.`)),U(`periods_per_year (number)`,P(`The number of compounding periods per year.`))],compute:function(e,t){let n=L(e,this.locale),r=Math.trunc(L(t,this.locale));return n<=0?new I(MX(n)):r<=0?new I(RX(r)):(1+n/r)**+r-1},isExported:!0};function SQ(e,t,n,r,i){return e===0?-(r+n*t):-r*(1+e)**t-n*(1+e*i)*((1+e)**t-1)/e}let CQ={description:P(`Future value of an annuity investment.`),args:[U(`rate (number)`,P(`The interest rate.`)),U(`number_of_periods (number)`,P(`The number of payments to be made.`)),U(`payment_amount (number)`,P(`The amount per period to be paid.`)),U(`present_value (number, default=0)`,P(`The current value of the annuity.`)),U(`end_or_beginning (number, default=0)`,P(`The timing of the payment payments are due for each period.`),tQ)],compute:function(e,t,n,r={value:0},i={value:0}){return r||=0,i||=0,{value:SQ(L(e,this.locale),L(t,this.locale),L(n,this.locale),L(r,this.locale),+!!z(i)),format:`#,##0.00`}},isExported:!0},wQ={description:P(`Future value of principal from series of rates.`),args:[U(`principal (number)`,P(`The amount of initial capital or value to compound against.`)),U(`rate_schedule (number, range<number>)`,P(`A series of interest rates to compound against the principal.`))],compute:function(e,t){let n=L(e,this.locale);return $o([t],(e,t)=>e*(1+L(t,this.locale)),n)},isExported:!0},TQ={description:P(`Calculates effective interest rate.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`investment (number)`,P(`The amount invested in the security.`)),U(`redemption (number)`,P(`The amount to be received at maturity.`)),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i={value:0}){let a=Math.trunc(L(e,this.locale)),o=Math.trunc(L(t,this.locale)),s=L(r,this.locale),c=L(n,this.locale),l=Math.trunc(L(i,this.locale));if(a>=o)return new I(AX(a,o));if(c<=0)return new I(TX(c));if(s<=0)return new I(JX(s));if(aZ(l))return new I(pX(l));let u=Xa(a,o,l);return(s-c)/c/u},isExported:!0};function EQ(e,t,n,r,i,a){return RQ(e,n,r,i,a)-BQ(e,t,n,r,i,a)}let DQ={description:P(`Payment on the principal of an investment.`),args:[U(`rate (number)`,P(`The annualized rate of interest.`)),U(`period (number)`,P(`The amortization period, in terms of number of periods.`)),U(`number_of_periods (number)`,P(`The number of payments to be made.`)),U(`present_value (number)`,P(`The current value of the annuity.`)),U(`future_value (number, default=0)`,P(`The future value remaining after the final payment has been made.`)),U(`end_or_beginning (number, default=0)`,P(`The timing of the payment payments are due for each period.`),tQ)],compute:function(e,t,n,r,i={value:0},a={value:0}){return{value:EQ(L(e,this.locale),L(t,this.locale),L(n,this.locale),L(r,this.locale),L(i,this.locale),+!!z(a)),format:`#,##0.00`}},isExported:!0},OQ=.1,kQ={description:P(`Internal rate of return given periodic cashflows.`),args:[U(`cashflow_amounts (number, range<number>)`,P(`An array or range containing the income or payments associated with the investment.`)),U(`rate_guess (number, default=${OQ})`,P(`An estimate for what the internal rate of return will be.`))],compute:function(e,t={value:OQ}){let n=L(t,this.locale);if(n<=-1)return new I(GX(n));let r=!1,i=!1,a=[];if(Zo([e],({value:e})=>{e>0&&(r=!0),e<0&&(i=!0),a.push(e)},this.locale),!r||!i)return new I(lX);let o=a.shift();function s(e,t,n){let r=n.length,i=0;return n.reduce((t,n)=>(i++,t+n*e**(r-i)),t*e**r)}function c(e,t,n){let r=n.length,i=0;return n.reduce((t,n)=>(i++,t+n*(r-i)*e**(r-i-1)),t*r*e**(r-1))}function l(e){return s(e,o,a)}function u(e){return c(e,o,a)}return{value:rQ(l,u,n+1,20,1e-5)-1,format:`0%`}},isExported:!0},AQ={description:P(`Returns the interest paid at a particular period of an investment.`),args:[U(`rate (number)`,P(`The interest rate.`)),U(`period (number)`,P(`The period for which you want to view the interest payment.`)),U(`number_of_periods (number)`,P(`The number of payments to be made.`)),U(`present_value (number)`,P(`The current value of the annuity.`))],compute:function(e,t,n,r){let i=L(e,this.locale),a=L(t,this.locale),o=L(n,this.locale),s=L(r,this.locale);return o===0?new I(NX(o)):-1*(s-a/o*s)*i},isExported:!0},jQ={description:P(`Modified Macaulay duration.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`rate (number)`,P(`The annualized rate of interest.`)),U(`yield (number)`,P(`The expected annual yield of the security.`)),U(`frequency (number)`,P(`The number of interest or coupon payments per year (1, 2, or 4).`),eQ),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`))],compute:function(e,t,n,r,i,a={value:0}){let o=bQ.compute.bind(this)(e,t,n,r,i,a),s=L(r,this.locale),c=Math.trunc(L(i,this.locale));return L(o,this.locale)/(1+s/c)},isExported:!0},MQ={description:P(`Modified internal rate of return.`),args:[U(`cashflow_amounts (range<number>)`,P(`A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.`)),U(`financing_rate (number)`,P(`The interest rate paid on funds invested.`)),U(`reinvestment_return_rate (number)`,P(`The return (as a percentage) earned on reinvestment of income received from the investment.`))],compute:function(e,t,n){let r=L(t,this.locale),i=L(n,this.locale),a=as(e).flat().filter(e=>e.value!==null).map(e=>L(e,this.locale)),o=a.length,s=0,c=0;for(let e of C(0,o)){let t=a[e];t>=0?s+=t*(i+1)**(o-e-1):c+=t/(r+1)**e}if(c===0||s===0)return new I(lX);let l=1/(o-1);return(-s/c)**l-1},isExported:!0},NQ={description:P(`Annual nominal interest rate.`),args:[U(`effective_rate (number)`,P(`The effective interest rate per year.`)),U(`periods_per_year (number)`,P(`The number of compounding periods per year.`))],compute:function(e,t){let n=L(e,this.locale),r=Math.trunc(L(t,this.locale));return n<=0?new I(vX(n)):r<=0?new I(RX(r)):((n+1)**(1/r)-1)*r},isExported:!0},PQ={description:P(`Number of payment periods for an investment.`),args:[U(`rate (number)`,P(`The interest rate.`)),U(`payment_amount (number)`,P(`The amount of each payment made.`)),U(`present_value (number)`,P(`The current value of the annuity.`)),U(`future_value (number, default=0)`,P(`The future value remaining after the final payment has been made.`)),U(`end_or_beginning (number, default=0)`,P(`The timing of the payment payments are due for each period.`),tQ)],compute:function(e,t,n,r={value:0},i={value:0}){r||=0,i||=0;let a=L(e,this.locale),o=L(t,this.locale),s=L(n,this.locale),c=L(r,this.locale),l=+!!z(i);if(a===0)return-(c+s)/o;let u=o*(1+a*l)/a;return Math.log((u-c)/(s+u))/Math.log(1+a)},isExported:!0};function FQ(e,t,n,r){let i=0;return es(n,(t,n)=>(i++,t+n/(1+e)**i),t,r)}let IQ={description:P(`The net present value of an investment based on a series of periodic cash flows and a discount rate.`),args:[U(`discount (number)`,P(`The discount rate of the investment over one period.`)),U(`cashflow (number, range<number>, repeating)`,P(`The future cash flows.`))],compute:function(e,...t){let n=L(e,this.locale);return n===-1?new I(hX(n)):{value:FQ(n,0,t,this.locale),format:`#,##0.00`}},isExported:!0},LQ={description:P(`Computes the number of periods needed for an investment to reach a value.`),args:[U(`rate (number)`,P(`The rate at which the investment grows each period.`)),U(`present_value (number)`,P(`The investment's current value.`)),U(`future_value (number)`,P(`The investment's desired future value.`))],compute:function(e,t,n){let r=L(e,this.locale),i=L(t,this.locale),a=L(n,this.locale);return r<=0?new I(qX(r)):i<=0?new I(VX(i)):a<=0?new I(wX(a)):(Math.log(a)-Math.log(i))/Math.log(1+r)},isExported:!0};function RQ(e,t,n,r,i){if(t<=0)throw new I(PX(t));if(e===0)return-(r+n)/t;let a=-(n*(1+e)**t+r);return a=a*e/((1+e*i)*((1+e)**t-1)),a}let zQ={description:P(`Periodic payment for an annuity investment.`),args:[U(`rate (number)`,P(`The annualized rate of interest.`)),U(`number_of_periods (number)`,P(`The number of payments to be made.`)),U(`present_value (number)`,P(`The current value of the annuity.`)),U(`future_value (number, default=0)`,P(`The future value remaining after the final payment has been made.`)),U(`end_or_beginning (number, default=0)`,P(`The timing of the payment payments are due for each period.`),tQ)],compute:function(e,t,n,r={value:0},i={value:0}){let a=L(t,this.locale),o=L(e,this.locale),s=+!!z(i),c=L(r,this.locale);return{value:RQ(o,a,L(n,this.locale),c,s),format:`#,##0.00`}},isExported:!0};function BQ(e,t,n,r,i,a){if(n<=0)throw new I(PX(n));if(t<=0||t>n)throw new I(FX(n));let o=RQ(e,n,r,i,a);return a===1&&t===1?o:o+-SQ(e,a===0?t-1:t-2,o,r+o*a,0)*e}let VQ={description:P(`Payment on the principal of an investment.`),args:[U(`rate (number)`,P(`The annualized rate of interest.`)),U(`period (number)`,P(`The amortization period, in terms of number of periods.`)),U(`number_of_periods (number)`,P(`The number of payments to be made.`)),U(`present_value (number)`,P(`The current value of the annuity.`)),U(`future_value (number, default=0)`,P(`The future value remaining after the final payment has been made.`)),U(`end_or_beginning (number, default=0)`,P(`The timing of the payment payments are due for each period.`),tQ)],compute:function(e,t,n,r,i={value:0},a={value:0}){let o=L(n,this.locale),s=L(e,this.locale),c=L(t,this.locale),l=+!!z(a),u=L(i,this.locale);return{value:BQ(s,c,o,L(r,this.locale),u,l),format:`#,##0.00`}},isExported:!0},HQ={description:P(`Present value of an annuity investment.`),args:[U(`rate (number)`,P(`The interest rate.`)),U(`number_of_periods (number)`,P(`The number of payments to be made.`)),U(`payment_amount (number)`,P(`The amount per period to be paid.`)),U(`future_value (number, default=0)`,P(`The future value remaining after the final payment has been made.`)),U(`end_or_beginning (number, default=0)`,P(`The timing of the payment payments are due for each period.`),tQ)],compute:function(e,t,n,r={value:0},i={value:0}){r||=0,i||=0;let a=L(e,this.locale),o=L(t,this.locale),s=L(n,this.locale),c=L(r,this.locale),l=+!!z(i);return{value:a?-(s*(1+a*l)*((1+a)**o-1)/a+c)/(1+a)**o:-(c+s*o),format:`#,##0.00`}},isExported:!0},UQ={description:P(`Price of a security paying periodic interest.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`rate (number)`,P(`The annualized rate of interest.`)),U(`yield (number)`,P(`The expected annual yield of the security.`)),U(`redemption (number)`,P(`The redemption amount per 100 face value, or par.`)),U(`frequency (number)`,P(`The number of interest or coupon payments per year (1, 2, or 4).`),eQ),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=Math.trunc(L(e,this.locale)),c=Math.trunc(L(t,this.locale)),l=L(n,this.locale),u=L(r,this.locale),d=L(i,this.locale),f=Math.trunc(L(a,this.locale)),p=Math.trunc(L(o,this.locale));if(s>=c)return new I(AX(s,c));if(oZ(f))return new I(fX(f));if(aZ(p))return new I(pX(p));if(l<0)return new I(KX(l));if(u<0)return new I(rZ(u));if(d<=0)return new I(JX(d));let m=Xa(s,c,p)*f,h=Math.ceil(m),g=m-Math.floor(m)||1,_=1+u/f,v=100*l/f;if(h===1)return(v+d)/(g*u/f+1)-v*(1-g);let ee=0;for(let e=1;e<=h;e++)ee+=v/_**(e-1+g);return d/_**(h-1+g)+ee-v*(1-g)},isExported:!0},WQ={description:P(`Price of a discount security.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`discount (number)`,P(`The discount rate of the security at time of purchase.`)),U(`redemption (number)`,P(`The redemption amount per 100 face value, or par.`)),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(L(e,this.locale)),o=Math.trunc(L(t,this.locale)),s=L(n,this.locale),c=L(r,this.locale),l=Math.trunc(L(i,this.locale));if(a>=o)return new I(AX(a,o));if(aZ(l))return new I(pX(l));if(s<=0)return new I(gX(s));if(c<=0)return new I(JX(c));let u=Xa(a,o,l);return c-s*c*u},isExported:!0},GQ={description:P(`Calculates the price of a security paying interest at maturity, based on expected yield.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`issue (date)`,P(`The date the security was initially issued.`)),U(`rate (number)`,P(`The annualized rate of interest.`)),U(`yield (number)`,P(`The expected annual yield of the security.`)),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i,a={value:0}){a||=0;let o=Math.trunc(L(e,this.locale)),s=Math.trunc(L(t,this.locale)),c=Math.trunc(L(n,this.locale)),l=L(r,this.locale),u=L(i,this.locale),d=Math.trunc(L(a,this.locale));if(o<=c)return new I($X(o,c));if(o>=s)return new I(AX(o,s));if(aZ(d))return new I(pX(d));if(l<0)return new I(KX(l));if(u<0)return new I(rZ(u));let f=Xa(o,s,d),p=Xa(o,c,d),m=100+Xa(c,s,d)*l*100,h=1+f*u,g=p*l*100;return m/h-g},isExported:!0},KQ=.1,qQ={description:P(`Interest rate of an annuity investment.`),args:[U(`number_of_periods (number)`,P(`The number of payments to be made.`)),U(`payment_per_period (number)`,P(`The amount per period to be paid.`)),U(`present_value (number)`,P(`The current value of the annuity.`)),U(`future_value (number, default=0)`,P(`The future value remaining after the final payment has been made.`)),U(`end_or_beginning (number, default=0)`,P(`The timing of the payment payments are due for each period.`),tQ),U(`rate_guess (number, default=${KQ})`,P(`An estimate for what the interest rate will be.`))],compute:function(e,t,n,r={value:0},i={value:0},a={value:KQ}){let o=L(e,this.locale),s=L(t,this.locale),c=+!!z(i),l=L(a,this.locale)||KQ,u=L(r,this.locale),d=L(n,this.locale);return o<=0?new I(PX(o)):iZ([s,d,u])?l<=-1?new I(GX(l)):(u-=s*c,d+=s*c,{value:rQ(e=>{let t=(1+e)**+o,n=(t-1)/e;return u+d*t+s*n},e=>{let t=(1+e)**(o-1),n=((1+e)**+o-1)/e,r=o*t/e-n/e;return d*o*t+s*r},l,40,1e-5),format:`0%`}):new I(P(`There must be both positive and negative values in [payment_amount, present_value, future_value].`))},isExported:!0},JQ={description:P(`Amount received at maturity for a security.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`investment (number)`,P(`The amount invested (irrespective of face value of each security).`)),U(`discount (number)`,P(`The discount rate of the security invested in.`)),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(L(e,this.locale)),o=Math.trunc(L(t,this.locale)),s=L(n,this.locale),c=L(r,this.locale),l=Math.trunc(L(i,this.locale));return a>=o?new I(AX(a,o)):aZ(l)?new I(pX(l)):s<=0?new I(TX(s)):c<=0?new I(gX(c)):s/(1-c*Xa(a,o,l))},isExported:!0},YQ={description:P(`Computes the rate needed for an investment to reach a specific value within a specific number of periods.`),args:[U(`number_of_periods (number)`,P(`The number of periods.`)),U(`present_value (number)`,P(`The present value of the investment.`)),U(`future_value (number)`,P(`The future value of the investment.`))],compute:function(e,t,n){let r=L(e,this.locale),i=L(t,this.locale),a=L(n,this.locale);return r<=0?new I(PX(r)):(a/i)**(1/r)-1},isExported:!0},XQ={description:P(`Depreciation of an asset using the straight-line method.`),args:[U(`cost (number)`,P(`The initial cost of the asset.`)),U(`salvage (number)`,P(`The value of the asset at the end of depreciation.`)),U(`life (number)`,P(`The number of periods over which the asset is depreciated.`))],compute:function(e,t,n){let r=L(e,this.locale),i=L(t,this.locale),a=L(n,this.locale);return{value:(r-i)/a,format:`#,##0.00`}},isExported:!0},ZQ={description:P(`Depreciation via sum of years digit method.`),args:[U(`cost (number)`,P(`The initial cost of the asset.`)),U(`salvage (number)`,P(`The value of the asset at the end of depreciation.`)),U(`life (number)`,P(`The number of periods over which the asset is depreciated.`)),U(`period (number)`,P(`The single period within life for which to calculate depreciation.`))],compute:function(e,t,n,r){let i=L(e,this.locale),a=L(t,this.locale),o=L(n,this.locale),s=L(r,this.locale);if(s<=0)return new I(BX(s));if(o<=0)return new I(kX(o));if(s>o)return new I(zX(s,o));let c=o*(o+1)/2,l=o-s+1;return{value:(i-a)*(l/c),format:`#,##0.00`}},isExported:!0};function QQ(e,t,n){return 100*(1-n*Xa(e,t,2))}let $Q={description:P(`Price of a US Treasury bill.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`discount (number)`,P(`The discount rate of the bill at time of purchase.`))],compute:function(e,t,n){let r=Math.trunc(L(e,this.locale)),i=Math.trunc(L(t,this.locale)),a=L(n,this.locale);return r>=i?new I(AX(r,i)):sZ(r,i,this.locale)?a<=0?new I(gX(a)):a>=1?new I(_X(a)):QQ(r,i,a):new I(QX(r,i))},isExported:!0},e$={description:P(`Equivalent rate of return for a US Treasury bill.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`discount (number)`,P(`The discount rate of the bill at time of purchase.`))],compute:function(e,t,n){let r=Math.trunc(L(e,this.locale)),i=Math.trunc(L(t,this.locale)),a=L(n,this.locale);if(r>=i)return new I(AX(r,i));if(!sZ(r,i,this.locale))return new I(QX(r,i));if(a<=0)return new I(gX(a));if(a>=1)return new I(_X(a));let o=hZ.compute.bind(this)({value:i},{value:r});if(o<=182)return 365*a/(360-a*o);let s=QQ(r,i,a)/100,c=o/(o===366?366:365);return(-2*c+2*Math.sqrt(c**2-(2*c-1)*(1-1/s)))/(2*c-1)},isExported:!0},t$={description:P(`The yield of a US Treasury bill based on price.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`price (number)`,P(`The price at which the security is bought per 100 face value.`))],compute:function(e,t,n){let r=Math.trunc(L(e,this.locale)),i=Math.trunc(L(t,this.locale)),a=L(n,this.locale);if(r>=i)return new I(AX(r,i));if(!sZ(r,i,this.locale))return new I(QX(r,i));if(a<=0)return new I(HX(a));let o=Xa(r,i,2);return(100-a)/a*(1/o)},isExported:!0},n$={description:P(`Variable declining balance. WARNING : does not handle decimal periods.`),args:[U(`cost (number)`,P(`The initial cost of the asset.`)),U(`salvage (number)`,P(`The value of the asset at the end of depreciation.`)),U(`life (number)`,P(`The number of periods over which the asset is depreciated.`)),U(`start (number)`,P(`Starting period to calculate depreciation.`)),U(`end (number)`,P(`Ending period to calculate depreciation.`)),U(`factor (number, default=2)`,P(`The number of months in the first year of depreciation.`)),U(`no_switch (number, default=false)`,P(`Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation.`),[{value:!1,label:P(`Switch to straight-line depreciation`)},{value:!0,label:P(`Do not switch to straight-line depreciation`)}])],compute:function(e,t,n,r,i,a={value:2},o={value:!1}){a||=0;let s=L(e,this.locale),c=L(t,this.locale),l=L(n,this.locale),u=Math.trunc(L(r,this.locale)),d=Math.trunc(L(i,this.locale)),f=L(a,this.locale),p=z(o);if(s<0)return new I(uX(s));if(c<0)return new I(YX(c));if(l<=0)return new I(kX(l));if(u<0)return new I(eZ(u));if(d<0)return new I(yX(d));if(u>d)return new I(tZ(u,d));if(d>l)return new I(bX(d,l));if(f<=0)return new I(mX(f));if(s===0)return 0;if(c>=s)return u<1?s-c:0;let m=f/l;if(m>=1)return u<1?s-c:0;let h=s,g=0,_=0,v=!1;for(let e=0;e<d;e++){if(!v||p){let t=h*m,n=l-e,r=(h-c)/n;!p&&r>t?(v=!0,g=r):g=t}let t=Math.max(h-g,c);e>=u&&(_+=h-t),h=t}return _},isExported:!0},r$={description:P(`Internal rate of return given non-periodic cash flows.`),args:[U(`cashflow_amounts (range<number>)`,P(`An range containing the income or payments associated with the investment.`)),U(`cashflow_dates (range<number>)`,P(`An range with dates corresponding to the cash flows in cashflow_amounts.`)),U(`rate_guess (number, default=${KQ})`,P(`An estimate for what the internal rate of return will be.`))],compute:function(e,t,n={value:KQ}){let r=L(n,this.locale);if(!lS(e,t))return new I(cX);let i=e.flat().map(e=>L(e,this.locale)),a=t.flat().map(e=>L(e,this.locale));if(!iZ(i))return new I(lX);if(a.some(e=>e<a[0]))return new I(xX(a[0]));if(r<=-1)return new I(GX(r));let o=new Map;for(let e of C(0,a.length)){let t=a[e];o.has(t)?o.set(t,o.get(t)+i[e]):o.set(t,i[e])}let s=Array.from(o.keys()),c=s.map(e=>o.get(e));return rQ(e=>{let t=c[0];for(let n of C(1,c.length)){let r=(s[0]-s[n])/365;t+=c[n]*(1+e)**r}return t},e=>{let t=0;for(let n of C(1,c.length)){let r=(s[0]-s[n])/365;t+=r*c[n]*(1+e)**(r-1)}return t},r,40,1e-5,e=>e?e/10-.9:-.9)},isExported:!0},i$={description:P(`Net present value given to non-periodic cash flows..`),args:[U(`discount (number)`,P(`The discount rate of the investment over one period.`)),U(`cashflow_amounts (number, range<number>)`,P(`An range containing the income or payments associated with the investment.`)),U(`cashflow_dates (number, range<number>)`,P(`An range with dates corresponding to the cash flows in cashflow_amounts.`))],compute:function(e,t,n){let r=L(e,this.locale);if(!lS(t,n))return new I(cX);let i=B(t).flat().map(e=>Vo(e,this.locale)),a=B(n).flat().map(e=>Vo(e,this.locale));if(a.some(e=>e<a[0]))return new I(xX(a[0]));if(r<=0)return new I(qX(r));if(i.length===1)return i[0];let o=new Map;for(let e of C(0,a.length)){let t=a[e];o.has(t)?o.set(t,o.get(t)+i[e]):o.set(t,i[e])}let s=Array.from(o.keys()),c=s.map(e=>o.get(e)),l=c[0];for(let e of C(1,c.length)){let t=(s[0]-s[e])/365;l+=c[e]*(1+r)**t}return l},isExported:!0},a$={description:P(`Annual yield of a security paying periodic interest.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`rate (number)`,P(`The annualized rate of interest.`)),U(`price (number)`,P(`The price at which the security is bought per 100 face value.`)),U(`redemption (number)`,P(`The redemption amount per 100 face value, or par.`)),U(`frequency (number)`,P(`The number of interest or coupon payments per year (1, 2, or 4).`),eQ),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=Math.trunc(L(e,this.locale)),c=Math.trunc(L(t,this.locale)),l=L(n,this.locale),u=L(r,this.locale),d=L(i,this.locale),f=Math.trunc(L(a,this.locale)),p=Math.trunc(L(o,this.locale));if(s>=c)return new I(AX(s,c));if(oZ(f))return new I(fX(f));if(aZ(p))return new I(pX(p));if(l<0)return new I(KX(l));if(u<=0)return new I(HX(u));if(d<=0)return new I(JX(d));let m=Xa(s,c,p)*f,h=Math.ceil(m),g=m-Math.floor(m)||1,_=100*l/f;if(h===1){let e=u+_*(1-g);return(d+_-e)*f*(1/g)/e}function v(e,t,n,r,i,a){let o=a-(e+i*(1-t))*r**(n-1+t);for(let e=1;e<=n;e++)o+=i*r**(e-1);return o}function ee(e,t,n,r,i){let a=-(e+i*(1-t))*(n-1+t)*r**(n-2+t);for(let e=1;e<=n;e++)a+=i*(e-1)*r**(e-2);return a}function y(e){return v(u,g,h,e,_,d)}function b(e){return ee(u,g,h,e,_)}return(rQ(y,b,1+(l+1)/f,100,1e-5)-1)*f},isExported:!0},o$={description:P(`Annual yield of a discount security.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`price (number)`,P(`The price at which the security is bought per 100 face value.`)),U(`redemption (number)`,P(`The redemption amount per 100 face value, or par.`)),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(L(e,this.locale)),o=Math.trunc(L(t,this.locale)),s=L(n,this.locale),c=L(r,this.locale),l=Math.trunc(L(i,this.locale));if(a>=o)return new I(AX(a,o));if(aZ(l))return new I(pX(l));if(s<=0)return new I(HX(s));if(c<=0)return new I(JX(c));let u=Xa(a,o,l);return(c/s-1)/u},isExported:!0},s$={description:P(`Annual yield of a security paying interest at maturity.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`issue (date)`,P(`The date the security was initially issued.`)),U(`rate (number)`,P(`The annualized rate of interest.`)),U(`price (number)`,P(`The price at which the security is bought.`)),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i,a={value:0}){a||=0;let o=Math.trunc(L(e,this.locale)),s=Math.trunc(L(t,this.locale)),c=Math.trunc(L(n,this.locale)),l=L(r,this.locale),u=L(i,this.locale),d=Math.trunc(L(a,this.locale));if(o>=s)return new I(AX(o,s));if(aZ(d))return new I(pX(d));if(o<c)return new I(ZX(o,c));if(l<0)return new I(KX(l));if(u<=0)return new I(HX(u));let f=Xa(c,s,d),p=Xa(c,o,d),m=Xa(o,s,d);return(100*(1+l*f)/(u+100*l*p)-1)/m},isExported:!0};var c$=l({CELL:()=>u$,ISBLANK:()=>v$,ISERR:()=>d$,ISERROR:()=>f$,ISFORMULA:()=>b$,ISLOGICAL:()=>p$,ISNA:()=>m$,ISNONTEXT:()=>h$,ISNUMBER:()=>g$,ISTEXT:()=>_$,NA:()=>y$});let l$=[{value:`address`,label:P(`Returns an absolute reference as plain text of the top left cell in reference.`)},{value:`col`,label:P(`Returns the column number of the cell in reference.`)},{value:`contents`,label:P(`Returns the value contained in the top left cell in reference.`)},{value:`format`,label:P(`Returns the format of the top left cell in reference.`)},{value:`row`,label:P(`Returns the row number of the top left cell in reference.`)},{value:`type`,label:P(`Returns the type of data in the cell in reference. The following values are returned: "b" for a blank cell, "l" (for label) if the cell contains plain text, and "v" (for value) if the cell contains any other type of data.`)}],u$={description:P(`Gets information about a cell.`),args:[U(`info_type (string)`,P(`The type of information requested.`),l$),U(`reference (any, range<any>)`,P(`The reference to the cell.`))],compute:function(e,t){let n=R(e).toLowerCase();if(!l$.map(e=>e.value).includes(n))return new I(P(`The info_type should be one of %s.`,l$.join(`, `)));let r=B(t)[0][0],i=r.position;if(i===void 0)return new I(P(`The reference is invalid.`));switch(n){case`address`:return(this.__originSheetId===i.sheetId?``:this.getters.getSheetName(i.sheetId)+`!`)+E(i.col,i.row,{colFixed:!0,rowFixed:!0});case`col`:return i.col+1;case`contents`:return r.value;case`format`:return r.format||``;case`row`:return i.row+1;case`type`:return r.value===null?`b`:Pc(r.format)?`l`:typeof r.value==`number`||typeof r.value==`boolean`?`v`:`l`}return``},isExported:!0},d$={description:P(`Whether a value is an error other than #N/A.`),args:[U(`value (any)`,P(`The value to be verified as an error type.`))],compute:function(e){let t=e?.value;return No(t)&&t!==F.NotAvailable},isExported:!0},f$={description:P(`Whether a value is an error.`),args:[U(`value (any)`,P(`The value to be verified as an error type.`))],compute:function(e){let t=e?.value;return No(t)},isExported:!0},p$={description:P("Whether a value is `true` or `false`."),args:[U(`value (any)`,P(`The value to be verified as a logical TRUE or FALSE.`))],compute:function(e){return typeof e?.value==`boolean`},isExported:!0},m$={description:P(`Whether a value is the error #N/A.`),args:[U(`value (any)`,P(`The value to be verified as an error type.`))],compute:function(e){return e?.value===F.NotAvailable},isExported:!0},h$={description:P(`Whether a value is non-textual.`),args:[U(`value (any)`,P(`The value to be checked.`))],compute:function(e){return!_$.compute.bind(this)(e)},isExported:!0},g$={description:P(`Whether a value is a number.`),args:[U(`value (any)`,P(`The value to be verified as a number.`))],compute:function(e){return typeof e?.value==`number`},isExported:!0},_$={description:P(`Whether a value is text.`),args:[U(`value (any)`,P(`The value to be verified as text.`))],compute:function(e){return typeof e?.value==`string`&&No(e?.value)===!1},isExported:!0},v$={description:P(`Whether the referenced cell is empty`),args:[U(`value (any)`,P(`Reference to the cell that will be checked for emptiness.`))],compute:function(e){return e?.value===null},isExported:!0},y$={description:P(`Returns the error value #N/A.`),args:[],compute:function(){return{value:F.NotAvailable}},isExported:!0},b$={description:P(`Checks whether there is a reference to a cell that contains a formula, and returns TRUE or FALSE.`),args:[U(`cell_reference (any)`,P(`A reference to a cell.`))],compute:function(e){return e?.position===void 0?new To(Io):this.getters.getCell(e.position)?.isFormula??!1},isExported:!0};var x$=l({AND:()=>S$,FALSE:()=>C$,IF:()=>w$,IFERROR:()=>T$,IFNA:()=>E$,IFS:()=>D$,NOT:()=>O$,OR:()=>k$,SWITCH:()=>A$,TRUE:()=>j$,XOR:()=>M$});let S$={description:P("Logical `and` operator."),args:[U(`logical_expression (boolean, range<boolean>, repeating)`,P(`Expression or reference to a cell containing a logical value (TRUE/FALSE) or an expression that can be coerced to a logical value.`))],compute:function(...e){let{result:t,foundBoolean:n}=nS(e);return n?t:new I(ys)},isExported:!0},C$={description:P("Logical value `false`."),args:[],compute:function(){return!1},isExported:!0},w$={description:P(`Returns value depending on logical expression.`),args:[U(`logical_expression (boolean, range<boolean>)`,P(`An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.`)),U(`value_if_true (any, range)`,P(`The value the function returns if logical_expression is TRUE.`)),U(`value_if_false (any, range, default=FALSE)`,P(`The value the function returns if logical_expression is FALSE.`))],compute:function(e,t,n){return vS(e)?qc(this,il.get(`IF`),[e,t,n]):(z(gS(e))?t:n)??{value:0}},isExported:!0},T$={description:P(`Value if it is not an error, otherwise 2nd argument.`),args:[U(`value (any, range)`,P(`The value to return if value itself is not an error.`)),U(`value_if_error (any, range, default="empty")`,P(`The value the function returns if value is an error.`))],compute:function(e,t){return vS(e)?qc(this,il.get(`IFERROR`),[e,t]):(No(gS(e)?.value)?t:e)??{value:0}},isExported:!0},E$={description:P(`Value if it is not an #N/A error, otherwise 2nd argument.`),args:[U(`value (any, range)`,P(`The value to return if value itself is not #N/A an error.`)),U(`value_if_error (any, range, default="empty")`,P(`The value the function returns if value is an #N/A error.`))],compute:function(e,t){return vS(e)?qc(this,il.get(`IFNA`),[e,t]):(gS(e)?.value===F.NotAvailable?t:e)??{value:0}},isExported:!0},D$={description:P(`Returns a value depending on multiple logical expressions.`),args:[U(`condition (any, range, repeating)`,P(`The condition to be evaluated. It can be a boolean, a number, an array, or a reference to any of those.`)),U(`value (any, range, repeating)`,P(`The value to be returned if its corresponding condition is TRUE.`))],compute:function(...e){if(e.length%2!=0)return new I(P(`Wrong number of arguments. Expected an even number of arguments.`));for(;e.length>0;){if(vS(e[0]))return qc(this,il.get(`IFS`),e);let t=z(gS(e.shift())),n=e.shift();if(t)return n??{value:0}}return new I(P(`No match.`))},isExported:!0},O$={description:P(`Returns opposite of provided logical value.`),args:[U(`logical_expression (boolean)`,P(`An expression or reference to a cell holding an expression that represents some logical value.`))],compute:function(e){return!z(e)},isExported:!0},k$={description:P("Logical `or` operator."),args:[U(`logical_expression (boolean, range<boolean>, repeating)`,P(`Expression or reference to a cell containing a logical value (TRUE/FALSE) or an expression that can be coerced to a logical value.`))],compute:function(...e){let{result:t,foundBoolean:n}=rS(e);return n?t:new I(ys)},isExported:!0},A$={description:P(`Returns a value by comparing cases to an expression.`),args:[U(`expression (number, boolean, string)`,P(`The value to be checked.`)),U(`case (any, repeating)`,P(`Case to be checked against expression.`)),U(`value (any, repeating)`,P(`Value to be returned if its corresponding case matches expression.`)),U(`default (any, default="empty")`,P(`An optional default value to be returned if none of the cases match expression.`))],compute:function(e,...t){let n=t.length%2==0?Po(e):t.pop();for(let n=0;n<t.length;n+=2){let r=t[n];if(r&&No(r.value))return r;if(e?.value===r?.value)return t[n+1]||{value:0}}return n||{value:0}},isExported:!0},j$={description:P("Logical value `true`."),args:[],compute:function(){return!0},isExported:!0},M$={description:P("Logical `xor` operator."),args:[U(`logical_expression (boolean, range<boolean>, repeating)`,P(`Expression or reference to a cell containing a logical value (TRUE/FALSE) or an expression that can be coerced to a logical value.`))],compute:function(...e){let t=!1,n=!1;return ss(e,e=>(t=!0,n=n?!e:e,!0)),t?n:new I(ys)},isExported:!0};function N$(e,t){let n=t.getPivotId(e);if(!n)throw new I(P(`There is no pivot with id "%s"`,e));return n}function P$(e,t,n){let{measures:r}=n.getPivotCoreDefinition(e);if(!r.find(e=>e.id===t))throw new I(P(`The argument %s is not a valid measure. Here are the measures: %s`,t,`(${r.map(e=>e.id).join(`, `)})`))}function F$(e){if(e.length%2!=0)throw new I(P(`Function PIVOT takes an even number of arguments.`))}function I$(e,t,n){let r=[],i=e.getters.getPivotCoreDefinition(t);if(i.type===`SPREADSHEET`&&i.dataSet){let{sheetId:t,zone:n}=i.dataSet,a=Jn(n),o=e.getters.getRangeFromSheetXC(t,a);if(o===void 0||o.invalidXc||o.invalidSheetName)throw new To;if(e.__originCellPosition&&o.sheetId===e.__originSheetId&&or(O(e.__originCellPosition),n))throw new wo;r.push(o)}for(let i of n)i.computedBy&&r.push(...e.getters.getMeasureFullDependencies(t,i));let a=e.__originCellPosition;a&&r.length&&(e.updateDependencies?.(a),e.addDependencies?.(a,r))}var L$=l({ADDRESS:()=>B$,CHOOSE:()=>r1,COLUMN:()=>V$,COLUMNS:()=>H$,DROP:()=>i1,FORMULATEXT:()=>o1,HLOOKUP:()=>U$,INDEX:()=>W$,INDIRECT:()=>G$,LOOKUP:()=>K$,MATCH:()=>q$,OFFSET:()=>n1,PIVOT:()=>t1,PIVOT_HEADER:()=>e1,PIVOT_VALUE:()=>$$,ROW:()=>J$,ROWS:()=>Y$,TAKE:()=>a1,VLOOKUP:()=>X$,XLOOKUP:()=>Q$});let R$=[{value:!0,label:P(`A1 style (default)`)},{value:!1,label:P(`R1C1 style`)}],z$=[{value:!0,label:P(`Approximate match (default)`)},{value:!1,label:P(`Exact match`)}],B$={description:P(`Returns a cell reference as a string. `),args:[U(`row (number)`,P(`The row number of the cell reference. `)),U(`column (number)`,P(`The column number (not name) of the cell reference. A is column number 1. `)),U(`absolute_relative_mode (number, default=1)`,P(`An indicator of whether the reference is row/column absolute.`),[{value:1,label:P(`Absolute row and column (e.g. $A$1)`)},{value:2,label:P(`Absolute row, relative column (e.g. A$1)`)},{value:3,label:P(`Relative row, absolute column (e.g. $A1)`)},{value:4,label:P(`Relative row and column (e.g. A1)`)}]),U(`use_a1_notation (boolean, default=TRUE)`,P(`A boolean indicating whether to use A1 style notation or R1C1 style notation.`),R$),U(`sheet (string, optional)`,P(`A string indicating the name of the sheet into which the address points.`))],compute:function(e,t,n={value:1},r={value:!0},i){let a=Uo(e,this.locale),o=Uo(t,this.locale);if(a<1)return new I(dS(a));if(o<1)return new I(dS(o));let s=Uo(n,this.locale);if(![1,2,3,4].includes(s))return new I(Lo(1,4,s));let c=z(r),l;if(c){let e={rowFixed:[1,2].includes(s),colFixed:[1,3].includes(s)};l=E(o-1,a-1,e)}else l=([1,2].includes(s)?`R${a}`:`R[${a}]`)+([1,3].includes(s)?`C${o}`:`C[${o}]`);return i===void 0?l:vl(R(i),l)},isExported:!0},V$={description:P(`Column number of a specified cell.`),args:[U(`cell_reference (any, range<any>, default='this cell')`,P(`The cell whose column number will be returned. Column A corresponds to 1. By default, the function use the cell in which the formula is entered.`))],compute:function(e){if(e===void 0)return this.__originCellPosition===void 0?new I(P(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):this.__originCellPosition.col+1;let t=B(e),n=t[0][0];if(n===void 0)return new I(P(`The range is out of bounds.`));if(n.position===void 0)return new To(Io);let r=n.position.col;return t.length===1?r+1:ns(t.length,1,e=>({value:r+e+1}))},isExported:!0},H$={description:P(`Number of columns in a specified array or range.`),args:[U(`range (any, range<any>)`,P(`The range whose column count will be returned.`))],compute:function(e){let t=B(e);return t[0][0]===void 0?new I(P(`The range is out of bounds.`)):t[0][0].value===F.InvalidReference?t[0][0]:t.length},isExported:!0},U$={description:P(`Horizontal lookup`),args:[U(`search_key (string, number, boolean)`,P(`The value to search for. For example, 42, 'Cats', or I24.`)),U(`range (any, range)`,P(`The range to consider for the search. The first row in the range is searched for the key specified in search_key.`)),U(`index (number)`,P(`The row index of the value to be returned, where the first row in range is numbered 1.`)),U(`is_sorted (boolean, default=true)`,P(`Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned.`),z$)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(L(n?.value,this.locale)),a=B(t);if(1>i||i>a[0].length)return new I(P(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[t][0].value,s=a[z(r.value)?fs(a,e,`nextSmaller`,`asc`,a.length,o):ps(a,e,`wildcard`,a.length,o,this.lookupCaches)];return s===void 0?Po(e):s[i-1]},isExported:!0},W$={description:P(`Returns the content of a cell, specified by row and column offset.`),args:[U(`reference (any, range)`,P(`The range of cells from which the values are returned.`)),U(`row (number, default=0)`,P(`The index of the row to be returned from within the reference range of cells.`)),U(`column (number, default=0)`,P(`The index of the column to be returned from within the reference range of cells.`))],compute:function(e,t={value:0},n={value:0}){let r=B(e),i=L(t.value,this.locale),a=L(n.value,this.locale);return a<0||a-1>=r.length||i<0||i-1>=r[0].length?new I(P(`Index out of range.`)):i===0&&a===0?r:i===0?[r[a-1]]:a===0?r.map(e=>[e[i-1]]):r[a-1][i-1]},isExported:!0},G$={description:P(`Returns the content of a cell, specified by a string.`),args:[U(`reference (string)`,P(`The range of cells from which the values are returned.`)),U(`use_a1_notation (boolean, default=TRUE)`,P(`A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).`),R$)],compute:function(e,t={value:!0}){let n=e?.value?.toString();if(!n)return new To(P(`Reference should be defined.`));if(!z(t))return new I(P(`R1C1 notation is not supported.`));let r=this.__originSheetId,i=this.__originCellPosition;i&&this.updateDependencies?.(i);let a=this.getters.getNamedRange(n),o=a?a.range:this.getters.getRangeFromSheetXC(r,n);if(o===void 0||o.invalidXc||o.invalidSheetName)return new To;i&&this.addDependencies?.(i,[o]);let s=[];for(let e=o.zone.left;e<=o.zone.right;e++){let t=[];for(let n=o.zone.top;n<=o.zone.bottom;n++){let r={sheetId:o.sheetId,col:e,row:n};t.push(this.getFormulaResult(r))}s.push(t)}return s.length===1&&s[0].length===1?s[0][0]:s},isExported:!0},K$={description:P(`Look up a value.`),args:[U(`search_key (string, number, boolean)`,P(`The value to search for. For example, 42, 'Cats', or I24.`)),U(`search_array (any, range)`,P(`One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.`)),U(`result_range (any, range, optional)`,P(`The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method.`))],compute:function(e,t,n){let r=B(t),i=B(n),a=r.length,o=r[0].length,s=o>=a,c=fs(r,e,`nextSmaller`,`asc`,s?o:a,s?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value);return c===-1||s&&r[0][c]===void 0||!s&&r[c][o-1]===void 0?Po(e):i[0].length===0?s?r[a-1][c]:r[c][o-1]:(a=i.length,o=i[0].length,a!==1&&o!==1?new I(P(`The result_range must be a single row or a single column.`)):a>1?c>a-1?new I(P(`[[FUNCTION_NAME]] evaluates to an out of range row value %s.`,c+1)):i[c][0]:c>o-1?new I(P(`[[FUNCTION_NAME]] evaluates to an out of range column value %s.`,c+1)):i[0][c])},isExported:!0},q$={description:P(`Position of item in range that matches value.`),args:[U(`search_key (string, number, boolean)`,P(`The value to search for. For example, 42, 'Cats', or I24.`)),U(`range (any, range)`,P(`The one-dimensional array to be searched.`)),U(`search_type (number, default=1)`,P(`The search method is a number 1, 0 or -1 indicating which value to return. 1 finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order.`),[{value:1,label:P(`Ascending order (default)`)},{value:0,label:P(`Exact match`)},{value:-1,label:P(`Descending order`)}])],compute:function(e,t,n={value:1}){let r=L(n,this.locale),i=B(t),a=i.length,o=i[0].length;if(a!==1&&o!==1)return new I(P(`The range must be a single row or a single column.`));let s=-1,c=a===1?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,l=a===1?i[0].length:i.length;switch(r=Math.sign(r),r){case 1:s=fs(i,e,`nextSmaller`,`asc`,l,c);break;case 0:s=ps(i,e,`wildcard`,l,c,this.lookupCaches);break;case-1:s=fs(i,e,`nextGreater`,`desc`,l,c);break}return a===1&&i[0][s]===void 0||a!==1&&i[s]===void 0?Po(e):s+1},isExported:!0},J$={description:P(`Row number of a specified cell.`),args:[U(`cell_reference (any, range<any>, default='this cell')`,P(`The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered.`))],compute:function(e){if(e===void 0)return this.__originCellPosition?.row===void 0?new I(P(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):this.__originCellPosition.row+1;let t=B(e),n=t[0][0];if(n===void 0)return new I(P(`The range is out of bounds.`));if(n.position===void 0)return new To(Io);let r=n.position.row;return t[0].length===1?r+1:ns(1,t[0].length,(e,t)=>({value:r+t+1}))},isExported:!0},Y$={description:P(`Number of rows in a specified array or range.`),args:[U(`range (any, range<any>)`,P(`The range whose row count will be returned.`))],compute:function(e){let t=B(e);return t[0][0]===void 0?new I(P(`The range is out of bounds.`)):t[0][0].value===F.InvalidReference?t[0][0]:t[0].length},isExported:!0},X$={description:P(`Vertical lookup.`),args:[U(`search_key (string, number, boolean)`,P(`The value to search for. For example, 42, 'Cats', or I24.`)),U(`range (any, range)`,P(`The range to consider for the search. The first column in the range is searched for the key specified in search_key.`)),U(`index (number)`,P(`The column index of the value to be returned, where the first column in range is numbered 1.`)),U(`is_sorted (boolean, default=true)`,P(`Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned.`),z$)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(L(n?.value,this.locale)),a=B(t);if(1>i||i>a.length)return new I(P(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[0][t].value,s=z(r.value)?fs(a,e,`nextSmaller`,`asc`,a[0].length,o):ps(a,e,`wildcard`,a[0].length,o,this.lookupCaches),c=a[i-1][s];return c===void 0?Po(e):c},isExported:!0},Z$={0:`strict`,1:`nextGreater`,"-1":`nextSmaller`,2:`wildcard`},Q$={description:P(`Search a range for a match and return the corresponding item from a second range.`),args:[U(`search_key (string,number,boolean)`,P(`The value to search for.`)),U(`lookup_range (any, range)`,P(`The range to consider for the search. Should be a single column or a single row.`)),U(`return_range (any, range)`,P(`The range containing the return value. Should have the same dimensions as lookup_range.`)),U(`if_not_found (any, optional)`,P(`If a valid match is not found, return this value.`)),U(`match_mode (any, default=0)`,P(`Specifies how to match search_key with the items in lookup_range. `),[{value:0,label:P(`Exact match (default)`)},{value:-1,label:P(`Exact match or next smaller item`)},{value:1,label:P(`Exact match or next larger item`)},{value:2,label:P(`Wildcard character match`)}]),U(`search_mode (any, default=1)`,P(`Specifies the search mode to use. By default, a first to last search will be used.`),[{value:1,label:P(`Search first to last (default)`)},{value:-1,label:P(`Search last to first`)},{value:2,label:P(`Binary search (sorted ascending order)`)},{value:-2,label:P(`Binary search (sorted descending order)`)}])],compute:function(e,t,n,r,i={value:0},a={value:1}){let o=Math.trunc(L(i.value,this.locale)),s=Math.trunc(L(a.value,this.locale)),c=B(t),l=B(n);if(c.length!==1&&c[0].length!==1)return new I(P(`lookup_range should be either a single row or single column.`));if(![1,-1,2,-2].includes(s))return new I(P(`search_mode should be a value in [-1, 1, -2, 2].`));if(![-1,0,1,2].includes(o))return new I(P(`match_mode should be a value in [-1, 0, 1, 2].`));let u=c.length===1?`col`:`row`;if(o===2&&[-2,2].includes(s))return new I(P(`The search and match mode combination is not supported for XLOOKUP evaluation.`));if(u===`col`?l[0].length!==c[0].length:l.length!==c.length)return new I(P(`return_range should have the same dimensions as lookup_range.`));let d=u===`col`?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,f=u===`col`?c[0].length:c.length,p=Z$[o],m=s===-1,h=s===2||s===-2?fs(c,e,p,s===2?`asc`:`desc`,f,d):ps(c,e,p,f,d,this.lookupCaches,m);return h===-1?r===void 0?Po(e):[[r]]:u===`col`?l.map(e=>[e[h]]):[l[h]]},isExported:!0},$$={description:P(`Get the value from a pivot.`),args:[U(`pivot_id (number,string)`,P(`ID of the pivot.`)),U(`measure_name (string)`,P(`Name of the measure.`)),U(`domain_field_name (string,repeating,optional)`,P(`Field name.`)),U(`domain_value (number,string,boolean,repeating,optional)`,P(`Value.`))],compute:function(e,t,...n){let r=R(e),i=R(t),a=N$(r,this.getters);P$(a,i,this.getters),F$(n);let o=this.getters.getPivot(a),s=this.getters.getPivotCoreDefinition(a);I$(this,a,s.measures.filter(e=>e.id===i)),o.init({reload:o.needsReevaluation});let c=o.assertIsValid({throwOnError:!1});if(c)return c;if(!o.areDomainArgsFieldsValid(n)){let e=P(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${r})`);return{value:F.GenericError,message:P(`Dimensions don't match the pivot definition`)+`. `+e}}let l=o.parseArgsToPivotDomain(n);return this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(a)?.trackValue(i,l),o.getPivotCellValueAndFormat(i,l)}},e1={description:P(`Get the header of a pivot.`),args:[U(`pivot_id (number,string)`,P(`ID of the pivot.`)),U(`domain_field_name (string,repeating,optional)`,P(`Field name.`)),U(`domain_value (number,string,value,repeating,optional)`,P(`Value.`))],compute:function(e,...t){let n=R(e),r=N$(n,this.getters);F$(t);let i=this.getters.getPivot(r);I$(this,r,[]),i.init({reload:i.needsReevaluation});let a=i.assertIsValid({throwOnError:!1});if(a)return a;if(!i.areDomainArgsFieldsValid(t)){let e=P(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${n})`);return{value:F.GenericError,message:P(`Dimensions don't match the pivot definition`)+`. `+e}}let o=i.parseArgsToPivotDomain(t);this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(r)?.trackHeader(o);let s=o.at(-1);if(s?.field===`measure`)return i.getPivotMeasureValue(R(s.value),o);let{value:c,format:l}=i.getPivotHeaderValueAndFormat(o);return{value:c,format:!s||s.field===`measure`||s.value===`false`?void 0:l}}},t1={description:P(`Get a pivot table.`),args:[U(`pivot_id (string)`,P(`ID of the pivot.`)),U(`row_count (number, optional)`,P(`number of rows`)),U(`include_total (boolean, default=TRUE)`,P(`Whether to include total/sub-totals or not.`)),U(`include_column_titles (boolean, default=TRUE)`,P(`Whether to include the column titles or not.`)),U(`column_count (number, optional)`,P(`number of columns`)),U(`include_measure_titles (boolean, default=TRUE)`,P(`Whether to include the measure titles row or not.`))],compute:function(e,t,n,r,i,a){let o=N$(R(e),this.getters),s=this.getters.getPivot(o),c=this.getters.getPivotCoreDefinition(o),l=EC(c,t,n,r,i,a,this.locale);if(l.numberOfRows<0)return new I(P(`The number of rows must be positive.`));if(l.numberOfColumns<0)return new I(P(`The number of columns must be positive.`));I$(this,o,c.measures),s.init({reload:s.needsReevaluation});let u=s.assertIsValid({throwOnError:!1});if(u)return u;let d=s.getCollapsedTableStructure();if(d.numberOfCells>5e5)return new I(G_(d.numberOfCells,this.locale));let f=d.getPivotCells(l),p=this.getters.getPivotName(o),{numberOfCols:m,numberOfRows:h}=d.getPivotTableDimensions(l);if(h===0)return[[{value:p}]];let g=[];for(let e of C(0,m)){g[e]=[];for(let t of C(0,h)){let n=f[e][t];switch(n.type){case`EMPTY`:g[e].push({value:``});break;case`HEADER`:let t=s.getPivotHeaderValueAndFormat(n.domain);g[e].push(_C(n.domain,t));break;case`MEASURE_HEADER`:g[e].push(s.getPivotMeasureValue(n.measure,n.domain));break;case`VALUE`:g[e].push(s.getPivotCellValueAndFormat(n.measure,n.domain));break;case`ROW_GROUP_NAME`:let r=s.definition.rows.find(e=>e.nameWithGranularity===n.rowField)?.displayName;g[e].push({value:r||``});break}}}return(l.displayColumnHeaders||l.displayMeasuresRow)&&f[0][0].type===`EMPTY`&&(g[0][0]={value:p}),g}},n1={description:P(`Returns a range reference shifted by a specified number of rows and columns from a starting cell reference.`),args:[U(`cell_reference (any, range<any>)`,P(`The starting point from which to count the offset rows and columns.`)),U(`offset_rows (number)`,P(`The number of rows to offset by.`)),U(`offset_columns (number)`,P(`The number of columns to offset by.`)),U(`height (number, default='height of cell_reference')`,P(`The number of rows of the range to return starting at the offset target.`)),U(`width (number, default='width of cell_reference')`,P(`The number of columns of the range to return starting at the offset target.`))],compute:function(e,t,n,r,i){if(e===void 0)return new To(Io);let a=B(e),o=a[0][0];if(o===void 0)return new I(P(`The range is out of bounds.`));if(o.position===void 0)return new To(Io);let s=a[0].length,c=a.length;if(r){let e=L(r,this.locale);if(e<1)return new I(P(`Height value is %(_height)s. It should be greater than or equal to 1.`,{_height:e}));s=e}if(i){let e=L(i,this.locale);if(e<1)return new I(P(`Width value is %(_width)s. It should be greater than or equal to 1.`,{_width:e}));c=e}let l=L(t,this.locale),u=L(n,this.locale),d=this.__originCellPosition;d&&this.updateDependencies?.(d);let f=o.position.col+u,p=o.position.row+l;if(f<0||p<0)return new To(P(`OFFSET evaluates to an out of bounds range.`));let m={left:f,top:p,right:f+c-1,bottom:p+s-1},h=o.position.sheetId,g=this.getters.getRangeFromZone(h,m);return g.invalidXc||g.invalidSheetName?new To:(d&&this.addDependencies?.(d,[g]),ns(c,s,(e,t)=>this.getFormulaResult({sheetId:h,col:f+e,row:p+t})))}},r1={description:P(`Returns an element from a list of choices based on index.`),args:[U(`index (number)`,P(`Which choice to return.`)),U(`choice (any, range<any>, repeating)`,P(`A potential value to return. May be a reference to a cell or an individual value.`))],compute:function(e,...t){let n=Math.floor(L(e,this.locale))-1;return n<0||n>=t.length?new I(P(`Index for CHOOSE is invalid. Valid values are between 1 and %(choices)s inclusive.`,{choices:t.length})):t[n]??new I(P(`Choice is undefined.`))},isExported:!0},i1={description:P(`Excludes a specified number of rows or columns from the start or end of an array.`),args:[U(`array (range)`,P(`The array from which to drop rows or columns`)),U(`rows (number)`,P(`The number of rows to drop. A negative value drops from the end of the array.`)),U(`columns (number, optional)`,P(`The number of columns to exclude. A negative value drops from the end of the array.`))],compute:function(e,t,n){let r=L(t,this.locale),i=L(n,this.locale),a=e;if(Math.abs(i)>=e.length||Math.abs(r)>=e[0].length)return new I(P(`The number of rows or column to exclude must be smaller than the number of elements in the array.`));a=i>=0?a.slice(i):a.slice(0,a.length+i);for(let e=0;e<a.length;e++)r>=0?a[e]=a[e].slice(r):a[e]=a[e].slice(0,a[e].length+r);return a},isExported:!0},a1={description:P(`Returns a specified number of contiguous rows or columns from the start or end of an array.`),args:[U(`array (range)`,P(`The array from which to take rows or columns.`)),U(`rows (number)`,P(`The number of rows to take. A negative value takes from the end of the array.`)),U(`columns (number, optional)`,P(`The number of columns to take. A negative value takes from the end of the array.`))],compute:function(e,t,n){let r=t?L(t,this.locale):e[0].length,i=L(n,this.locale),a=e;if((Math.abs(i)>=e.length||i===0)&&(i=e.length),Math.abs(r)>=e[0].length&&(r=e[0].length),a=i>=0?a.slice(0,i):a.slice(a.length+i,a.length),r===0)return new I(P(`The number of rows can not be zero.`));for(let e=0;e<a.length;e++)r>0?a[e]=a[e].slice(0,r):a[e]=a[e].slice(a[e].length+r,a[e].length);return a},isExported:!0},o1={description:P(`Returns a formula as a string.`),args:[U(`cell_reference (any)`,P(`A reference to a cell.`))],compute:function(e){if(e?.position===void 0)return new To(Io);let t=this.getters.getCell(e.position);return t?.isFormula?t.compiledFormula.toFormulaString(this.getters):new Eo(P(`The cell does not contain a formula.`))},isExported:!0};var s1=l({ADD:()=>c1,CONCAT:()=>l1,DIVIDE:()=>u1,EQ:()=>m1,GT:()=>_1,GTE:()=>v1,LT:()=>y1,LTE:()=>b1,MINUS:()=>x1,MULTIPLY:()=>S1,NE:()=>C1,POW:()=>w1,SPILLED_RANGE:()=>T1,UMINUS:()=>E1,UNARY_PERCENT:()=>D1,UPLUS:()=>O1});let c1={description:P(`Sum of two numbers.`),args:[U(`value1 (number)`,P(`The first addend.`)),U(`value2 (number)`,P(`The second addend.`))],compute:function(e,t){return{value:L(e,this.locale)+L(t,this.locale),format:e?.format||t?.format}}},l1={description:P(`Concatenation of two values.`),args:[U(`value1 (string)`,P(`The value to which value2 will be appended.`)),U(`value2 (string)`,P(`The value to append to value1.`))],compute:function(e,t){return R(e)+R(t)},isExported:!0},u1={description:P(`One number divided by another.`),args:[U(`dividend (number)`,P(`The number to be divided.`)),U(`divisor (number)`,P(`The number to divide by.`))],compute:function(e,t){let n=L(t,this.locale);return n===0?new ko(P(`The divisor must be different from zero.`)):{value:L(e,this.locale)/n,format:e?.format||t?.format}}};function d1(e){return e===void 0||e.value===null}let f1={number:0,string:``,boolean:!1};function p1(e,t,n=2e-16){return Math.abs(e-t)<n}let m1={description:P(`Equal.`),args:[U(`value1 (string, number, boolean)`,P(`The first value.`)),U(`value2 (string, number, boolean)`,P(`The value to test against value1 for equality.`))],compute:function(e,t){if(No(e?.value))return e;if(No(t?.value))return t;let n=d1(e)?f1[typeof t?.value]:e?.value,r=d1(t)?f1[typeof e?.value]:t?.value;return typeof n==`string`&&(n=n.toUpperCase()),typeof r==`string`&&(r=r.toUpperCase()),typeof n==`number`&&typeof r==`number`?{value:p1(n,r)}:{value:n===r}}};function h1(e,t,n){if(No(e?.value))return e;if(No(t?.value))return t;let r=d1(e)?f1[typeof t?.value]??``:e?.value,i=d1(t)?f1[typeof e?.value]??``:t?.value,a=g1[typeof r],o=g1[typeof i];if(a!==o)return{value:n(a,o)};switch(typeof r){case`string`:r=r.toUpperCase();break;case`boolean`:r=Number(r);break}switch(typeof i){case`string`:i=i.toUpperCase();break;case`boolean`:i=Number(i);break}return{value:n(r,i)}}let g1={number:0,string:1,boolean:2},_1={description:P(`Strictly greater than.`),args:[U(`value1 (number, string, boolean)`,P(`The value to test as being greater than value2.`)),U(`value2 (number, string, boolean)`,P(`The second value.`))],compute:function(e,t){return h1(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?!p1(e,t)&&e>t:e>t)}},v1={description:P(`Greater than or equal to.`),args:[U(`value1 (number, string, boolean)`,P(`The value to test as being greater than or equal to value2.`)),U(`value2 (number, string, boolean)`,P(`The second value.`))],compute:function(e,t){return h1(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?p1(e,t)||e>t:e>=t)}},y1={description:P(`Less than.`),args:[U(`value1 (number, string, boolean)`,P(`The value to test as being less than value2.`)),U(`value2 (number, string, boolean)`,P(`The second value.`))],compute:function(e,t){let n=v1.compute.bind(this)(e,t);return No(n.value)?n:{value:!n.value}}},b1={description:P(`Less than or equal to.`),args:[U(`value1 (number, string, boolean)`,P(`The value to test as being less than or equal to value2.`)),U(`value2 (number, string, boolean)`,P(`The second value.`))],compute:function(e,t){let n=_1.compute.bind(this)(e,t);return No(n.value)?n:{value:!n.value}}},x1={description:P(`Difference of two numbers.`),args:[U(`value1 (number)`,P(`The minuend, or number to be subtracted from.`)),U(`value2 (number)`,P(`The subtrahend, or number to subtract from value1.`))],compute:function(e,t){return{value:L(e,this.locale)-L(t,this.locale),format:e?.format||t?.format}}},S1={description:P(`Product of two numbers`),args:[U(`factor1 (number)`,P(`The first multiplicand.`)),U(`factor2 (number)`,P(`The second multiplicand.`))],compute:function(e,t){return{value:L(e,this.locale)*L(t,this.locale),format:e?.format||t?.format}}},C1={description:P(`Not equal.`),args:[U(`value1 (string, number, boolean)`,P(`The first value.`)),U(`value2 (string, number, boolean)`,P(`The value to test against value1 for inequality.`))],compute:function(e,t){let n=m1.compute.bind(this)(e,t);return No(n.value)?n:{value:!n.value}}},w1={description:P(`A number raised to a power.`),args:[U(`base (number)`,P(`The number to raise to the exponent power.`)),U(`exponent (number)`,P(`The exponent to raise base to.`))],compute:function(e,t){return cJ.compute.bind(this)(e,t)}},T1={description:P(`Gets the spilled range of an array formula.`),args:[U(`ref (any, range<any>)`,P(`The reference to get the spilled range from.`))],compute:function(e){if(e===void 0)return new To(Io);let t=B(e);if(t.length!==1||t[0].length!==1)return new I(P(`Only single-cell references are allowed to get the spilled range.`));let n=t[0][0];if(No(n.value))return n;if(n.position===void 0)return new To(Io);let r=this.__originCellPosition;r&&this.updateDependencies?.(r);let i=this.getters.getSpreadZone(n.position);if(i===void 0)return new To;let a=this.getters.getRangeFromZone(this.__originSheetId,i);return r&&this.addDependencies?.(r,[a]),ns(i.right-i.left+1,i.bottom-i.top+1,(e,t)=>this.getFormulaResult({sheetId:a.sheetId,col:i.left+e,row:i.top+t}))},hidden:!0},E1={description:P(`A number with the sign reversed.`),args:[U(`value (number)`,P(`The number to have its sign reversed. Equivalently, the number to multiply by -1.`))],compute:function(e){return{value:-L(e,this.locale),format:e?.format}}},D1={description:P(`Value interpreted as a percentage.`),args:[U(`percentage (number)`,P(`The value to interpret as a percentage.`))],compute:function(e){return L(e,this.locale)/100}},O1={description:P(`A specified number, unchanged.`),args:[U(`value (any)`,P(`The number to return.`))],compute:function(e={value:null}){return e}},$=e=>({transform:t=>t*e,inverseTransform:t=>t/e}),k1={transform:e=>e,inverseTransform:e=>e},A1=1e-10,j1=.0254,M1=j1/72,N1=.3048,P1=.9144,F1=1609.34,I1=1852,L1=946073047258e4,R1={g:{...k1,category:`weight`},u:{...$(166053e-29),category:`weight`},grain:{...$(.0647989),category:`weight`},ozm:{...$(28.3495),category:`weight`},lbm:{...$(453.592),category:`weight`},stone:{...$(6350.29),category:`weight`},sg:{...$(14593.90294),category:`weight`},cwt:{...$(45359.237),category:`weight`},uk_cwt:{...$(50802.3),category:`weight`},ton:{...$(907184.74),category:`weight`},uk_ton:{...$(1016046.9),category:`weight`},m:{...k1,category:`distance`},km:{...$(1e3),category:`distance`},ang:{...$(A1),category:`distance`},Picapt:{...$(M1),category:`distance`},pica:{...$(j1/6),category:`distance`},in:{...$(j1),category:`distance`},ft:{...$(N1),category:`distance`},yd:{...$(P1),category:`distance`},ell:{...$(1.143),category:`distance`},mi:{...$(F1),category:`distance`},survey_mi:{...$(1609.34),category:`distance`},Nmi:{...$(I1),category:`distance`},ly:{...$(L1),category:`distance`},parsec:{...$(0x6da012f95c9fd0),category:`distance`},sec:{...k1,category:`time`},min:{...$(60),category:`time`},hr:{...$(3600),category:`time`},day:{...$(86400),category:`time`},yr:{...$(31556952),category:`time`},Pa:{...k1,category:`pressure`},bar:{...$(1e5),category:`pressure`},mmHg:{...$(133.322),category:`pressure`},Torr:{...$(133.322),category:`pressure`},psi:{...$(6894.76),category:`pressure`},atm:{...$(101325),category:`pressure`},N:{...k1,category:`force`},dyn:{...$(1e-5),category:`force`},pond:{...$(.00980665),category:`force`},lbf:{...$(4.44822),category:`force`},J:{...k1,category:`energy`},eV:{...$(160218e-24),category:`energy`},e:{...$(1e-7),category:`energy`},flb:{...$(1.3558179483),category:`energy`},c:{...$(4.184),category:`energy`},cal:{...$(4.1868),category:`energy`},BTU:{...$(1055.06),category:`energy`},Wh:{...$(3600),category:`energy`},HPh:{...$(2684520),category:`energy`},W:{...k1,category:`power`},PS:{...$(735.499),category:`power`},HP:{...$(745.7),category:`power`},T:{...k1,category:`magnetism`},ga:{...$(1e-4),category:`magnetism`},K:{...k1,category:`temperature`},C:{transform:e=>e+273.15,inverseTransform:e=>e-273.15,category:`temperature`},F:{transform:e=>(e-32)*5/9+273.15,inverseTransform:e=>(e-273.15)*9/5+32,category:`temperature`},Rank:{...$(5/9),category:`temperature`},Reau:{transform:e=>e*1.25+273.15,inverseTransform:e=>(e-273.15)/1.25,category:`temperature`},"m^3":{...k1,category:`volume`,order:3},"ang^3":{...$(A1**3),category:`volume`,order:3},"Picapt^3":{...$(M1**3),category:`volume`,order:3},tsp:{...$(492892e-11),category:`volume`},tspm:{...$(5e-6),category:`volume`},tbs:{...$(14786764825785619e-21),category:`volume`},"in^3":{...$(j1**3),category:`volume`,order:3},oz:{...$(295735295625e-16),category:`volume`},cup:{...$(237e-6),category:`volume`},pt:{...$(.0004731765),category:`volume`},uk_pt:{...$(568261e-9),category:`volume`},qt:{...$(.0009463529),category:`volume`},l:{...$(.001),category:`volume`},uk_qt:{...$(.0011365225),category:`volume`},gal:{...$(.0037854118),category:`volume`},uk_gal:{...$(.00454609),category:`volume`},"ft^3":{...$(N1**3),category:`volume`,order:3},bushel:{...$(.0352390704),category:`volume`},barrel:{...$(.158987295),category:`volume`},"yd^3":{...$(P1**3),category:`volume`,order:3},MTON:{...$(1.13267386368),category:`volume`},GRT:{...$(2.83168),category:`volume`},"mi^3":{...$(F1**3),category:`volume`,order:3},"Nmi^3":{...$(I1**3),category:`volume`,order:3},"ly^3":{...$(L1**3),category:`volume`,order:3},"m^2":{...k1,category:`area`,order:2},"ang^2":{...$(A1**2),category:`area`,order:2},"Picapt^2":{...$(M1**2),category:`area`,order:2},"in^2":{...$(j1**2),category:`area`,order:2},"ft^2":{...$(N1**2),category:`area`,order:2},"yd^2":{...$(P1**2),category:`area`,order:2},ar:{...$(100),category:`area`},Morgen:{...$(2500),category:`area`},uk_acre:{...$(4046.8564224),category:`area`},us_acre:{...$(4046.8726098743),category:`area`},ha:{...$(1e4),category:`area`},"mi^2":{...$(F1**2),category:`area`,order:2},"Nmi^2":{...$(I1**2),category:`area`,order:2},"ly^2":{...$(L1**2),category:`area`,order:2},bit:{...k1,category:`information`},byte:{...$(8),category:`information`},"m/s":{...k1,category:`speed`},"m/hr":{...$(1/3600),category:`speed`},"km/hr":{...$(1/3.6),category:`speed`},mph:{...$(.44704),category:`speed`},kn:{...$(.5144444444),category:`speed`},admkn:{...$(.5147733333),category:`speed`}},z1={shweight:`cwt`,lcwt:`uk_cwt`,hweight:`uk_cwt`,LTON:`uk_ton`,brton:`uk_ton`,pc:`parsec`,Pica:`Picapt`,d:`day`,mn:`min`,s:`sec`,p:`Pa`,at:`atm`,dy:`dyn`,ev:`eV`,hh:`HPh`,wh:`Wh`,btu:`BTU`,h:`HP`,cel:`C`,fah:`F`,kel:`K`,us_pt:`pt`,L:`l`,lt:`l`,ang3:`ang^3`,ft3:`ft^3`,in3:`in^3`,ly3:`ly^3`,m3:`m^3`,mi3:`mi^3`,yd3:`yd^3`,Nmi3:`Nmi^3`,Picapt3:`Picapt^3`,"Pica^3":`Picapt^3`,Pica3:`Picapt^3`,regton:`GRT`,ang2:`ang^2`,ft2:`ft^2`,in2:`in^2`,ly2:`ly^2`,m2:`m^2`,mi2:`mi^2`,Nmi2:`Nmi^2`,Picapt2:`Picapt^2`,"Pica^2":`Picapt^2`,Pica2:`Picapt^2`,yd2:`yd^2`,"m/h":`m/hr`,"m/sec":`m/s`},B1={"":1,Y:1e24,Z:1e21,E:0xde0b6b3a7640000,P:0x38d7ea4c68000,T:0xe8d4a51000,G:1e9,M:1e6,k:1e3,h:100,da:10,e:10,d:.1,c:.01,m:.001,u:1e-6,n:1e-9,p:1e-12,f:1e-15,a:1e-18,z:1e-21,y:1e-21,Yi:2**80,Zi:2**70,Ei:2**60,Pi:2**50,Ti:2**40,Gi:2**30,Mi:2**20,ki:2**10},V1={weight:P(`Weight`),distance:P(`Distance`),time:P(`Time`),pressure:P(`Pressure`),force:P(`Force`),energy:P(`Energy`),power:P(`Power`),magnetism:P(`Magnetism`),temperature:P(`Temperature`),volume:P(`Volume`),area:P(`Area`),information:P(`Information`),speed:P(`Speed`)},H1=Object.entries(R1).map(([e,t])=>({value:e,label:U1(t.category)}));function U1(e){return V1[e]??``}function W1(e){for(let[t,n]of Object.entries(B1)){if(t&&!e.startsWith(t))continue;let r=e.slice(t.length),i=R1[r];if(!i&&z1[r]&&(i=R1[z1[r]]),i)return{...i,factor:i.order?n**+i.order:n}}}var G1=l({CONVERT:()=>K1});let K1={description:P(`Converts a numeric value to a different unit of measure.`),args:[U(`value (number)`,P(`the numeric value in start_unit to convert to end_unit`)),U(`start_unit (string)`,P(`The starting unit, the unit currently assigned to value`),H1),U(`end_unit (string)`,P(`The unit of measure into which to convert value`),H1)],compute:function(e,t,n){let r=L(e,this.locale),i=R(t),a=R(n),o=W1(i),s=W1(a);return o?s?o.category===s.category?{value:s.inverseTransform(o.factor*o.transform(r))/s.factor,format:e?.format}:{value:F.GenericError,message:P(`Incompatible units of measure ('%s' vs '%s')`,U1(o.category),U1(s.category))}:{value:F.GenericError,message:P(`Invalid units of measure ('%s')`,a)}:{value:F.GenericError,message:P(`Invalid units of measure ('%s')`,i)}},isExported:!0};var q1=l({CHAR:()=>Z1,CLEAN:()=>Q1,CONCATENATE:()=>$1,EXACT:()=>e0,FIND:()=>t0,FORMAT_LARGE_NUMBER:()=>n0,JOIN:()=>r0,LEFT:()=>i0,LEN:()=>a0,LOWER:()=>o0,MID:()=>s0,PROPER:()=>c0,REGEXEXTRACT:()=>u0,REGEXREPLACE:()=>d0,REGEXTEST:()=>l0,REPLACE:()=>f0,RIGHT:()=>p0,SEARCH:()=>m0,SPLIT:()=>h0,SUBSTITUTE:()=>g0,TEXT:()=>x0,TEXTAFTER:()=>C0,TEXTBEFORE:()=>w0,TEXTJOIN:()=>_0,TEXTSPLIT:()=>v0,TRIM:()=>y0,UPPER:()=>b0,VALUE:()=>S0});let J1=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,Y1=[{value:0,label:P(`Case-sensitive (default)`)},{value:1,label:P(`Case-insensitive`)}],X1=[{value:0,label:P(`Don't match to end (default)`)},{value:1,label:P(`Match to end`)}],Z1={description:P(`Gets character associated with number.`),args:[U(`table_number (number)`,P(`The number of the character to look up from the current Unicode table in decimal format.`))],compute:function(e){let t=Math.trunc(L(e,this.locale));return t<1?new I(P(`The table_number (%s) is out of range.`,t)):String.fromCharCode(t)},isExported:!0},Q1={description:P(`Remove non-printable characters from a piece of text.`),args:[U(`text (string)`,P(`The text whose non-printable characters are to be removed.`))],compute:function(e){let t=R(e),n=``;for(let e of t)e&&e.charCodeAt(0)>31&&(n+=e);return n},isExported:!0},$1={description:P(`Appends strings to one another.`),args:[U(`string (string, range<string>, repeating)`,P(`String to append in sequence.`))],compute:function(...e){return $o(e,(e,t)=>e+R(t),``)},isExported:!0},e0={description:P(`Tests whether two strings are identical.`),args:[U(`string1 (string)`,P(`The first string to compare.`)),U(`string2 (string)`,P(`The second string to compare.`))],compute:function(e,t){return R(e)===R(t)},isExported:!0},t0={description:P(`First position of string found in text, case-sensitive.`),args:[U(`search_for (string)`,P(`The string to look for within text_to_search.`)),U(`text_to_search (string)`,P(`The text to search for the first occurrence of search_for.`)),U(`starting_at (number, default=1)`,P(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=R(e),i=R(t),a=L(n,this.locale);if(i===``)return new I(P(`The text_to_search must be non-empty.`));if(a<1)return new I(P(`The starting_at (%s) must be greater than or equal to 1.`,a));let o=i.indexOf(r,a-1);return o===-1?new I(P(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)):o+1},isExported:!0},n0={description:P(`Apply a large number format`),args:[U(`value (number)`,P(`The number.`)),U(`unit (string, optional)`,P(`The formatting unit. Use 'k', 'm', or 'b' to force the unit`),[{value:`k`,label:P(`Thousand`)},{value:`m`,label:P(`Million`)},{value:`b`,label:P(`Billion`)}])],compute:function(e,t){return{value:L(e,this.locale),format:Ec(e,t,this.locale)}}},r0={description:P(`Concatenates elements of arrays with delimiter.`),args:[U(`delimiter (string)`,P(`The character or string to place between each concatenated value.`)),U(`value_or_array (string, range<string>, repeating)`,P(`Value to be appended using delimiter.`))],compute:function(e,...t){let n=R(e);return $o(t,(e,t)=>(e?e+n:``)+R(t),``)}},i0={description:P(`Substring from beginning of specified string.`),args:[U(`text (string)`,P(`The string from which the left portion will be returned.`)),U(`number_of_characters (number, optional)`,P(`The number of characters to return from the left side of string.`))],compute:function(e,...t){let n=t.length?L(t[0],this.locale):1;return n<0?new I(P(`The number_of_characters (%s) must be positive or null.`,n)):R(e).substring(0,n)},isExported:!0},a0={description:P(`Length of a string.`),args:[U(`text (string)`,P(`The string whose length will be returned.`))],compute:function(e){return R(e).length},isExported:!0},o0={description:P(`Converts a specified string to lowercase.`),args:[U(`text (string)`,P(`The string to convert to lowercase.`))],compute:function(e){return R(e).toLowerCase()},isExported:!0},s0={description:P(`A segment of a string.`),args:[U(`text (string)`,P(`The string to extract a segment from.`)),U(`starting_at (number)`,P(`The index from the left of string from which to begin extracting. The first character in string has the index 1.`)),U(`extract_length (number)`,P(`The length of the segment to extract.`))],compute:function(e,t,n){let r=R(e),i=L(t,this.locale),a=L(n,this.locale);return i<1?new I(P(`The starting_at argument (%s) must be positive greater than one.`,i.toString())):a<0?new I(P(`The extract_length argument (%s) must be positive or null.`,a)):r.slice(i-1,i+a-1)},isExported:!0},c0={description:P(`Capitalizes each word in a specified string.`),args:[U(`text_to_capitalize (string)`,P(`The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase.`))],compute:function(e){return R(e).replace(J1,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())},isExported:!0},l0={description:P(`Checks whether a string matches the supplied regular expression.`),args:[U(`text (string)`,P(`The string to test.`)),U(`pattern (string)`,P(`The regular expression pattern to match against the text.`)),U(`case_sensitivity (number, default=0)`,P(`Whether the match is case-sensitive.`),[{value:0,label:P(`Case-sensitive`)},{value:1,label:P(`Case-insensitive`)}])],compute:function(e,t,n={value:0}){let r=R(e),i=R(t),a=L(n,this.locale);if(i===``)return!0;if(r===``)return!1;if(a!==0&&a!==1)return new I(P(`The case_sensitivity (%s) must be 0 or 1.`,a));let o=a===1?`gi`:`g`,s;try{s=new RegExp(i,o)}catch{return new I(P(`Invalid regular expression`))}return s.test(r)},isExported:!0},u0={description:P(`Extract text from a string based on the supplied regular expression.`),args:[U(`text (string)`,P(`The string on which you want to extract text.`)),U(`pattern (string)`,P(`The regular expression pattern to match against the text.`)),U(`return_mode (number, default=0)`,P(`0 = first match, 1 = all matches as an array, 2 = capturing groups from the first match as an array.`),[{value:0,label:P(`First match`)},{value:1,label:P(`All matches`)},{value:2,label:P(`Capture groups of first match`)}]),U(`case_sensitivity (number, default=0)`,P(`Whether the match is case-sensitive.`),[{value:0,label:P(`Case-sensitive`)},{value:1,label:P(`Case-insensitive`)}])],compute:function(e,t,n={value:0},r={value:0}){let i=R(e),a=R(t),o=L(n,this.locale),s=L(r,this.locale);if(i===``||a===``)return{value:``};if(o<0||o>2)return new I(P(`The return_mode (%s) must be 0, 1 or 2.`,o));if(s!==0&&s!==1)return new I(P(`The case_sensitivity (%s) must be 0 or 1.`,s));let c=s===1?`gi`:`g`,l;try{l=new RegExp(a,c)}catch{return new I(P(`Invalid regular expression`))}let u=[...i.matchAll(l)];return u.length===0?{value:F.NotAvailable,message:P(`No matches found.`)}:o===0?u[0][0]:o===1?u.map(e=>[e[0]]):u[0].length<2?new I(P(`No capturing groups found.`)):u[0].slice(1).map(e=>[e])},isExported:!0},d0={description:P(`Replace text in a string based on the supplied regular expression.`),args:[U(`text (string)`,P(`The string in which you want to replace text.`)),U(`pattern (string)`,P(`The regular expression pattern to match against the text.`)),U(`replacement (string)`,P(`The text to use as the replacement.`)),U(`occurrence (number, default=0)`,P(`0 = replace all matches. A negative number counts from the end.`)),U(`case_sensitivity (number, default=0)`,P(`Whether the match is case-sensitive.`),[{value:0,label:P(`Case-sensitive`)},{value:1,label:P(`Case-insensitive`)}])],compute:function(e,t,n,r={value:0},i={value:0}){let a=R(e),o=R(t),s=R(n),c=L(r,this.locale),l=L(i,this.locale);if(l!==0&&l!==1)return new I(P(`The case_sensitivity (%s) must be 0 or 1.`,l));let u=l===1?`gi`:`g`,d;try{d=new RegExp(o,u)}catch{return new I(P(`Invalid regular expression`))}if(c!==0){let e=[...a.matchAll(d)];if(e.length===0||Math.abs(c)>e.length)return a;let t=c>0?c-1:e.length+c,n=e[t][0].length,r=e[t].index;return a.substring(0,r)+s+a.substring(r+n)}return a.replace(d,s)},isExported:!0},f0={description:P(`Replaces part of a text string with different text.`),args:[U(`text (string)`,P(`The text, a part of which will be replaced.`)),U(`position (number)`,P(`The position where the replacement will begin (starting from 1).`)),U(`length (number)`,P(`The number of characters in the text to be replaced.`)),U(`new_text (string)`,P(`The text which will be inserted into the original text.`))],compute:function(e,t,n,r){let i=L(t,this.locale);if(i<1)return new I(P(`The position (%s) must be greater than or equal to 1.`,i));let a=L(n,this.locale);if(a<0)return new I(P(`The length (%s) must be positive or zero.`,a));let o=R(e),s=R(r);return o.substring(0,i-1)+s+o.substring(i-1+a)},isExported:!0},p0={description:P(`A substring from the end of a specified string.`),args:[U(`text (string)`,P(`The string from which the right portion will be returned.`)),U(`number_of_characters (number, optional)`,P(`The number of characters to return from the right side of string.`))],compute:function(e,...t){let n=t.length?L(t[0],this.locale):1;if(n<0)return new I(P(`The number_of_characters (%s) must be positive or zero.`,n));let r=R(e),i=r.length;return r.substring(i-n,i)},isExported:!0},m0={description:P(`First position of string found in text, ignoring case.`),args:[U(`search_for (string)`,P(`The string to look for within text_to_search.`)),U(`text_to_search (string)`,P(`The text to search for the first occurrence of search_for.`)),U(`starting_at (number, default=1)`,P(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=R(e).toLowerCase(),i=R(t).toLowerCase(),a=L(n,this.locale);if(i===``)return{value:F.GenericError,message:P(`The text_to_search must be non-empty.`)};if(a<1)return{value:F.GenericError,message:P(`The starting_at (%s) must be greater than or equal to 1.`,a)};let o=i.indexOf(r,a-1);return o===-1?{value:F.GenericError,message:P(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)}:{value:o+1}},isExported:!0},h0={description:P(`Split text by specific character delimiter(s).`),args:[U(`text (string)`,P(`The text to divide.`)),U(`delimiter (string)`,P(`The character or characters to use to split text.`)),U(`split_by_each (boolean, default=true})`,P(`Whether or not to divide text around each character contained in delimiter.`)),U(`remove_empty_text (boolean, default=true)`,P(`Whether or not to remove empty text messages from the split results. The default behavior is to treat consecutive delimiters as one (if TRUE). If FALSE, empty cells values are added between consecutive delimiters.`))],compute:function(e,t,n={value:!0},r={value:!0}){let i=R(e),a=xt(R(t)),o=z(n),s=z(r);if(a.length<=0)return new I(P(`The delimiter (%s) must be not be empty.`,a));let c=o?RegExp(`[${a}]`,`g`):new RegExp(a,`g`),l=i.split(c);return s&&(l=l.filter(e=>e!==``)),as([l])},isExported:!1},g0={description:P(`Replaces existing text with new text in a string.`),args:[U(`text_to_search (string)`,P(`The text within which to search and replace.`)),U(`search_for (string)`,P(`The string to search for within text_to_search.`)),U(`replace_with (string)`,P(`The string that will replace search_for.`)),U(`occurrence_number (number, optional)`,P(`The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced.`))],compute:function(e,t,n,r){let i=L(r,this.locale);if(i<0)return new I(P(`The occurrenceNumber (%s) must be positive or null.`,i));let a=R(e),o=R(t);if(o===``)return a;let s=R(n),c=new RegExp(xt(o),`g`);if(i===0)return a.replace(c,s);let l=0;return a.replace(c,e=>++l===i?s:e)},isExported:!0},_0={description:P(`Combines text from multiple strings and/or arrays.`),args:[U(`delimiter (string)`,P(`A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.`)),U(`ignore_empty (boolean)`,P(`A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.`),[{value:!0,label:P(`Ignore empty cells`)},{value:!1,label:P(`Include empty cells (default)`)}]),U(`texts (string, range<string>, repeating)`,P(`Text item to join.`))],compute:function(e,t={value:!0},...n){let r=R(e),i=z(t),a=0;return $o(n,(e,t)=>i&&R(t)===``?e:(a++?e+r:``)+R(t),``)},isExported:!0},v0={description:P(`Splits text into rows or columns using specified column and row delimiters.`),args:[U(`text (string)`,P(`The text to split.`)),U(`col_delimiter (string, range<string>)`,P(`Character or string to split columns by.`)),U(`row_delimiter (string, range<string>, optional)`,P(`Character or string to split rows by.`)),U(`ignore_empty (boolean, default=false)`,P(`Whether to ignore empty cells.`),[{value:!1,label:P(`Include empty cells (default)`)},{value:!0,label:P(`Ignore empty cells`)}]),U(`match_mode (number, default=0)`,P(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),Y1),U(`pad_with (string, default="${F.NotAvailable}")`,P(`The value to use for padding empty cells.`))],compute:function(e,t,n,r={value:!1},i={value:0},a=new Eo){let o=R(e);if(o.length<=0)return new I(P(`No text to split.`));if(t===void 0&&n===void 0)return new I(P(`At least one delimiter must be provided.`));let s=B(t).flat().map(e=>xt(R(e))),c=B(n).flat().map(e=>xt(R(e)));if(s.some(e=>e===``)||c.some(e=>e===``))return new I(P(`The delimiters cannot be empty values.`));let l=z(r),u=L(i,this.locale);if(![0,1].includes(u))return new I(P(`match_mode should be a value of 0 or 1.`));let d=[],f=u===1?`gi`:`g`,p=c.filter(e=>!s.includes(e)),m=p.length?o.split(new RegExp(p.join(`|`),f)):[o];l&&(m=m.filter(e=>e!==``));let h=new RegExp(s.join(`|`),f);for(let e of m){let t=s.length?e.split(h):[e];l&&(t=t.filter(e=>e!==``)),d.push(t.map(e=>({value:e})))}let g=Math.max(...d.map(e=>e.length));for(let e of d)for(;e.length<g;)e.push(a);return as(d)},isExported:!0},y0={description:P(`Removes space characters.`),args:[U(`text (string)`,P(`The text or reference to a cell containing text to be trimmed.`))],compute:function(e){return ln(R(e))},isExported:!0},b0={description:P(`Converts a specified string to uppercase.`),args:[U(`text (string)`,P(`The string to convert to uppercase.`))],compute:function(e){return R(e).toUpperCase()},isExported:!0},x0={description:P(`Converts a number to text according to a specified format.`),args:[U(`number (number)`,P(`The number, date or time to format.`)),U(`format (string)`,P(`The case-sensitive format of the result, enclosed in quotation marks. Examples: "0.00" rounded to 2 decimal places, "hh:mm:ss" for hour:minutes:seconds.`))],compute:function(e,t){return H(L(e,this.locale),{format:R(t),locale:this.locale})},isExported:!0},S0={description:P(`Converts a string to a numeric value.`),args:[U(`value (number)`,P(`the string to be converted`))],compute:function(e){return L(e,this.locale)},isExported:!0},C0={description:P(`Returns text that occurs after a given substring or delimiter.`),args:[U(`text (string)`,P(`The source text.`)),U(`delimiter (string)`,P(`The substring after which text will be returned.`)),U(`instance_num (number, default=1)`,P(`The desired instance of the delimiter after which we extract the text. A negative number searches from the end.`)),U(`match_mode (number, default=0)`,P(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),Y1),U(`match_end (number, default=0))`,P(`Whether to treat the end of text as a delimiter.`),X1),U(`if_not_found (string, default="${F.NotAvailable}")`,P(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new Eo){let o=R(e),s=L(n,this.locale),c=L(r,this.locale),l=L(i,this.locale);if(s===0)return new I(P(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new I(P(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new I(P(`match_end should have a value of 0 or 1.`));let u=R(t);if(u===``)return Math.sign(s)>0?{value:o}:{value:``};let d=c===1?`gi`:`g`,f=xt(u),p=new RegExp(f,d),m=[...o.matchAll(p)].map(e=>e.index+u.length);if(s<0&&(m=m.reverse()),l&&Math.abs(s)===m.length+1)return Math.sign(s)>0?{value:``}:{value:o};let h=m[Math.abs(s)-1];return h===void 0?a:{value:o.substring(h)}},isExported:!0},w0={description:P(`Returns text that occurs before a given substring or delimiter.`),args:[U(`text (string)`,P(`The source text.`)),U(`delimiter (string)`,P(`The substring after which text will be returned.`)),U(`instance_num (number, default=1)`,P(`The desired instance of the delimiter before which we extract the text. A negative number searches from the end.`)),U(`match_mode (number, default=0)`,P(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),Y1),U(`match_end (number, default=0))`,P(`Whether to match a delimiter against the end of the text.`),X1),U(`if_not_found (string, default="${F.NotAvailable}")`,P(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new Eo){let o=R(e),s=L(n,this.locale),c=L(r,this.locale),l=L(i,this.locale);if(s===0)return new I(P(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new I(P(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new I(P(`match_end should have a value of 0 or 1.`));let u=R(t);if(u===``)return Math.sign(s)>0?{value:``}:{value:o};let d=c===1?`gi`:`g`,f=xt(u),p=new RegExp(f,d),m=[...o.matchAll(p)].map(e=>e.index+u.length);if(s<0&&(m=m.reverse()),l&&Math.abs(s)===m.length+1)return Math.sign(s)>0?{value:o}:{value:``};let h=m[Math.abs(s)-1];return h===void 0?a:{value:o.substring(0,h-u.length)}},isExported:!0};var T0=l({HYPERLINK:()=>E0});let E0={description:P(`Creates a hyperlink in a cell.`),args:[U(`url (string)`,P(`The full URL of the link enclosed in quotation marks.`)),U(`link_label (string, optional)`,P(`The text to display in the cell, enclosed in quotation marks.`))],compute:function(e,t){let n=R(e).trim(),r=R(t)||n;return n===``?r:Pt(r,n)},isExported:!0},D0=[{name:P(`Array`),functions:HK},{name:P(`Database`),functions:qY},{name:P(`Date`),functions:lZ},{name:P(`Filter`),functions:qZ},{name:P(`Financial`),functions:$Z},{name:P(`Info`),functions:c$},{name:P(`Lookup`),functions:L$},{name:P(`Logical`),functions:x$},{name:P(`Math`),functions:vq},{name:P(`Operator`),functions:s1},{name:P(`Statistical`),functions:PJ},{name:P(`Text`),functions:q1},{name:P(`Engineering`),functions:GZ},{name:P(`Web`),functions:T0},{name:P(`Parser`),functions:G1}];for(let e of D0){let t=e.functions;for(let n in t){let r=t[n];r.category=r.category||e.name,n=n.replace(/_/g,`.`),il.add(n,{isExported:!1,...r})}}let O0={},k0={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:26,HEADER_WIDTH:48,DESKTOP_BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:96,DEFAULT_CELL_HEIGHT:23,SCROLLBAR_WIDTH:15},A0={autoCompleteProviders:rA,autofillModifiersRegistry:$z,autofillRulesRegistry:eB,cellMenuRegistry:PI,colMenuRegistry:QI,errorTypes:So,functionRegistry:il,featurePluginRegistry:$V,iconsOnCellRegistry:Nz,statefulUIPluginRegistry:eH,coreViewsPluginRegistry:tH,corePluginRegistry:QV,rowMenuRegistry:aL,sidePanelRegistry:eF,figureRegistry:A_,chartSidePanelComponentRegistry:kA,chartDataSourceSidePanelComponentRegistry:SE,chartComponentRegistry:o_,chartTypeRegistry:wb,chartSubtypeRegistry:Vg,chartDataSourceRegistry:Cb,topbarMenuRegistry:DH,topbarComponentRegistry:KH,topBarToolBarRegistry:JU,clickableCellRegistry:nH,otRegistry:wB,inverseCommandRegistry:aH,urlRegistry:Bd,cellPopoverRegistry:sw,numberFormatMenuRegistry:CH,repeatLocalCommandTransformRegistry:CV,repeatCommandTransformRegistry:SV,clipboardHandlersRegistries:XL,pivotRegistry:KN,pivotTimeAdapterRegistry:IS,pivotSidePanelRegistry:sP,pivotNormalizationValueRegistry:mC,supportedPivotPositionalFormulaRegistry:kR,pivotToFunctionValueRegistry:hC,migrationStepRegistry:NC,chartJsExtensionRegistry:Ur,onIterationEndEvaluationRegistry:Cz,specificRangeTransformRegistry:TB},j0={arg:U,isEvaluationError:No,toBoolean:z,toJsDate:qo,toNumber:L,toString:R,toNormalizedPivotValue:uC,toFunctionPivotValue:fC,toXC:E,toZone:Un,toUnboundedZone:Hn,toCartesian:Mn,numberToLetters:Cn,lettersToNumber:wn,UuidGenerator:G,formatValue:H,createCurrencyFormat:yc,ColorGenerator:Ap,computeTextWidth:yf,createEmptyWorkbookData:$C,createEmptySheet:QC,createEmptyExcelSheet:ew,doesCellContainFunction:bn,rgbaToHex:np,colorToRGBA:rp,positionToZone:O,isDefined:w,isMatrix:ht,lazy:Gt,genericRepeat:GH,createAction:xe,createActions:_e,transformRangeData:Mr,deepEquals:T,overlap:rr,union:$n,isInside:ar,deepCopy:x,expandZoneOnInsertion:Yn,reduceZoneOnDeletion:Qn,unquote:wt,getMaxObjectId:nC,getFirstPivotFunction:ZN,getNumberOfPivotFunctions:$N,parseDimension:aC,isDateOrDatetimeField:oC,makeFieldProposal:eP,periodYearToComparable:FS,insertTokenAfterArgSeparator:nP,insertTokenAfterLeftParenthesis:rP,mergeContiguousZones:kr,getPivotHighlights:UM,pivotTimeAdapter:LS,UNDO_REDO_PIVOT_COMMANDS:Xz,createPivotFormula:lC,areDomainArgsFieldsValid:cC,splitReference:_l,sanitizeSheetName:Et,getUniqueText:_n,isNumber:lo,isDateTime:ja,createCustomFields:xC,schemeToColorScale:AC,isDateTimeFormat:fc,jsDateToNumber:Ga,numberToJsDate:Ua,DateTime:_a,parseFormat:Is,isFormula:vn,domainToColRowDomain:_N,collapseHierarchicalDisplayName:DC,getCanonicalSymbolName:Tt,fuzzyLookup:nA,replaceSymbolInFormula:Xu},M0={isMarkdownLink:Mt,parseMarkdownLink:Ft,markdownLink:Pt,openLink:Gd,urlRepresentation:Wd},N0={Checkbox:CE,Section:Z,Select:w_,RoundColorPicker:ZE,ChartDataSeries:FE,ChartErrorSection:zE,ChartLabelRange:IE,ChartRangeDataSourceComponent:mk,ChartTitle:JE,ChartPanel:NA,ChartFigure:O_,ChartJsComponent:Lh,ClickableCellSortIcon:AR,ZoomableChartJsComponent:Qg,Grid:OR,GridOverlay:nR,ScorecardChart:ig,GaugeChartComponent:i_,LineConfigPanel:mA,BarConfigPanel:VE,PieChartDesignPanel:_A,GenericChartConfigPanel:BE,ChartWithAxisDesignPanel:iD,GenericZoomableChartDesignPanel:aD,LineChartDesignPanel:hA,GaugeChartConfigPanel:Mk,GaugeChartDesignPanel:lA,ScorecardChartConfigPanel:bA,ScorecardChartDesignPanel:xA,GeoChartDesignPanel:fA,RadarChartDesignPanel:vA,WaterfallChartDesignPanel:OA,ComboChartDesignPanel:kk,FunnelChartDesignPanel:jk,SunburstChartDesignPanel:SA,TreeMapChartDesignPanel:DA,ChartTypePicker:jA,FigureComponent:j_,MenuPopover:C_,Popover:y_,SelectionInput:PE,StandaloneComposer:cA,ValidationMessages:RE,AddDimensionButton:aN,PivotDimensionGranularity:sN,PivotDimensionOrder:cN,PivotDimension:nN,PivotLayoutConfigurator:fN,PivotHTMLRenderer:MR,PivotDeferUpdate:GM,PivotTitleSection:pN,CogWheelMenu:bE,TextInput:pE,SidePanelCollapsible:UE,RadioSelection:XE,GeoChartRegionSelectSection:uA,ChartMenu:E_,FullScreenFigure:jR,NumberInput:GE,TopBar:YU,Composer:Uk},P0={useDragAndDropListItems:aE,useHighlights:IA,useHighlightsOnHover:FA},F0={Component:A,useExternalListener:Fi,EnvPlugin:Li,App:Hi},I0={useStoreProvider:Ki,DependencyContainer:Wi,CellPopoverStore:cw,ComposerFocusStore:Hr,CellComposerStore:IL,FindAndReplaceStore:Cj,HighlightStore:jE,DelayedHoveredCellStore:M_,HoveredTableStore:$L,ModelStore:Fr,NotificationStore:iA,RendererStore:zr,SelectionInputStore:NE,SpreadsheetStore:Br,useStore:j,useLocalStore:qi,SidePanelStore:nF,PivotSidePanelStore:aP,PivotMeasureDisplayPanelStore:VM,ClientFocusStore:sL,GridRenderer:dR};function L0(e,t){return il.add(e,t),{addFunction:(e,t)=>L0(e,t)}}let R0={DEFAULT_LOCALE:V,HIGHLIGHT_COLOR:De,PIVOT_STATIC_TABLE_CONFIG:st,PIVOT_INSERT_TABLE_STYLE_ID:ct,ChartTerms:I_,FIGURE_ID_SPLITTER:`??`,GRID_ICON_EDGE_LENGTH:17,GRID_ICON_MARGIN:2,CHART_TYPES:kC,DARK_MODE_FILTER_STRING:mp},z0={...pk,...NR};e.AbstractCellClipboardHandler=fV,e.AbstractChart=Rh,e.AbstractFigureClipboardHandler=oK,e.BadExpressionError=Co,e.CHART_TYPES=kC,e.CellErrorType=F,e.CellValueType=vd,e.CircularDependencyError=wo,e.ClientDisconnectedError=oV,e.ClipboardMIMEType=lw,e.CommandResult=Rd,e.CompiledFormula=dd,e.CorePlugin=cv,e.CoreViewPlugin=aF,e.DEFAULT_LOCALE=V,e.DEFAULT_LOCALES=xs,e.DEFAULT_LOCALE_DIGIT_GROUPING=`[3,0]`,e.DIRECTION=_t,e.DispatchResult=Id,e.DivisionByZeroError=ko,e.EvaluationError=I,e.InvalidReferenceError=To,e.LocalTransportService=qH,e.Model=rK,e.NEXT_VALUE=P_,e.NotAvailableError=Eo,e.NumberTooLargeError=Ao,e.OrderedLayers=Lr,e.PREVIOUS_VALUE=N_,e.PivotRuntimeDefinition=KM,e.Registry=k,e.Revision=aV,e.SPREADSHEET_DIMENSIONS=k0,e.SplillBlockedError=Oo,e.Spreadsheet=QU,e.SpreadsheetPivotTable=PN,e.UIPlugin=dB,e.UnknownFunctionError=Do,e.__info__=O0,e.addFunction=L0,e.addRenderingLayer=Rr,e.astToFormula=ML,e.availableConditionalFormatOperators=cj,e.availableDataValidationOperators=bj,e.availableFiltersOperators=JM,e.borderPositions=gt,e.borderStyles=mt,e.canExecuteInReadonly=Fd,e.categories=D0,e.chartHelpers=z0,e.compatibility=F0,e.components=N0,e.composerFocusTypes=vt,e.constants=R0,e.convertAstNodes=fu,e.coreTypes=Nd,e.createAutocompleteArgumentsProvider=wK,e.errorTypes=So,e.filterDateCriterionOperators=ZM,e.filterNumberCriterionOperators=XM,e.filterTextCriterionOperators=YM,e.findCellInNewZone=gr,e.functionCache=ld,e.getCaretDownSvg=Ey,e.getCaretUpSvg=Dy,e.helpers=j0,e.hooks=P0,e.invalidSubtotalFormulasCommands=Ad,e.invalidateBordersCommands=kd,e.invalidateCFEvaluationCommands=Od,e.invalidateChartEvaluationCommands=Ed,e.invalidateDependenciesCommands=Dd,e.invalidateEvaluationCommands=Td,e.isCoreCommand=Pd,e.isHeadersDependant=bd,e.isMatrix=ht,e.isPositionDependent=Cd,e.isRangeDependant=Sd,e.isSheetDependent=yd,e.isTargetDependent=xd,e.isZoneDependent=wd,e.iterateAstNodes=pu,e.links=M0,e.load=RC,e.lockedSheetAllowedCommands=Md,e.parse=uu,e.parseTokens=du,e.readonlyAllowedCommands=jd,e.registries=A0,e.schemeToColorScale=AC,e.setDefaultSheetViewSize=at,e.setTranslationMethod=yo,e.stores=I0,e.tokenColors=pt,e.tokenize=kl,O0.version=`19.5.0-alpha.0`,O0.date=`2026-06-29T09:01:26.331Z`,O0.hash=`2437c0b`})(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|
|
957
|
+
`),`_rels/.rels`)}function tK(e){let t={},n=[];for(let r of e.sheets){let e=r.name.slice(0,31);e=_n(e,n,{compute:(e,t)=>e.slice(0,31-String(t).length)+t}),n.push(e),e!==r.name&&(t[r.name]=e,r.name=e)}if(!Object.keys(t).length)return e;let r=Object.keys(t).sort((e,t)=>t.length-e.length),i=JSON.stringify(e);for(let e of r){let n=RegExp(`'?${xt(e)}'?!`,`g`);i=i.replaceAll(n,n=>{let r=t[e];return n.replace(e,r)})}return JSON.parse(i)}function nK(e){for(let t of e.sheets)t.tables=t.tables.filter(e=>sr(Un(e.range)).numberOfRows>1);return e}var rK=class e extends Ui{corePlugins=[];statefulUIPlugins=[];range;session;isReplayingCommand=!1;renderers={};status=0;config;corePluginConfig;coreViewPluginConfig;uiPluginConfig;state;selection;getters;coreGetters;handlers=[];uiHandlers=[];coreHandlers=[];constructor(e={},t={},n=[],r=!1){let i=performance.now();console.debug(`##### Model creation #####`),super(),bo(),n=KC(e,n);let a=RC(e,r);this.state=new hW,this.config=this.setupConfig(t),this.getters={isReadonly:()=>this.config.mode===`readonly`||this.config.mode===`dashboard`,isDashboard:()=>this.config.mode===`dashboard`},this.session=this.setupSession(a.revisionId),this.coreGetters={},this.range=new dW(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.copyFormulaStringForSheet=this.range.copyFormulaStringForSheet.bind(this.range),this.selection=new pW(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(let e of QV.getAll())this.setupCorePlugin(e,a);Object.assign(this.getters,this.coreGetters),this.session.loadInitialMessages(n);for(let e of tH.getAll()){let t=this.setupCoreViewPlugin(e);this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t)}for(let e of eH.getAll()){let t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t)}for(let e of $V.getAll()){let t=this.setupUiPlugin(e);this.handlers.push(t),this.uiHandlers.push(t)}if(this.config.mode!==`export_verification`&&(this.dispatch(`START`),this.selection.observe(this,{handleEvent:()=>this.trigger(`update`)}),this.setupSessionEvents(),this.joinSession(),t.snapshotRequested||e[`[Content_Types].xml`]&&!this.getters.isReadonly())){let e=performance.now();console.debug(`Snapshot requested`),this.session.snapshot(this.exportData()),console.debug(`Snapshot taken in`,performance.now()-e,`ms`)}console.debug(`Model created in`,performance.now()-i,`ms`),console.debug(`######`)}joinSession(){this.session.join(this.config.client)}async leaveSession({shouldSnapshot:e}={shouldSnapshot:!0}){let t=e&&!this.getters.isReadonly()?Gt(()=>this.exportData()):void 0;await this.session.leave(t)}setupUiPlugin(e){let t=new e(this.uiPluginConfig);for(let n of e.getters){if(!(n in t))throw Error(`Invalid getter name: ${n} for plugin ${t.constructor}`);if(n in this.getters)throw Error(`Getter "${n}" is already defined.`);this.getters[n]=t[n].bind(t)}for(let n of e.layers)this.renderers[n]||(this.renderers[n]=[]),this.renderers[n].push(t);return t}setupCoreViewPlugin(e){let t=new e(this.coreViewPluginConfig);for(let n of e.getters){if(!(n in t))throw Error(`Invalid getter name: ${n} for plugin ${t.constructor}`);if(n in this.getters)throw Error(`Getter "${n}" is already defined.`);this.getters[n]=t[n].bind(t)}return t}setupCorePlugin(e,t){let n=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in n))throw Error(`Invalid getter name: ${t} for plugin ${n.constructor}`);if(t in this.coreGetters)throw Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=n[t].bind(n)}n.import(t),this.corePlugins.push(n),this.coreHandlers.push(n),this.handlers.push(n)}onRemoteRevisionReceived({commands:e}){for(let t of e){let e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new sV(cW({initialRevisionId:e,recordChanges:this.state.recordChanges.bind(this.state),dispatch:e=>{if(!this.checkDispatchAllowedRemoteCommand(e).isSuccessful){this.dispatchToHandlers(this.coreHandlers,{type:`UNDO`,commands:[e]});return}this.isReplayingCommand=!0,this.dispatchToHandlers(this.coreHandlers,e),this.isReplayingCommand=!1}}),this.config.transportService,e,new $U(this.getters))}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){let t=e.client||{id:G.smallUuid(),name:P(`Anonymous`).toString()},n=e.transportService||new qH,r=e.mode===`readonly`||e.mode===`dashboard`||e.mode===`export_verification`;return{...e,mode:e.mode||`normal`,custom:e.custom||{},external:this.setupExternalConfig(e.external||{}),transportService:r?new eW(n):n,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){let t=e.loadLocales||(()=>Promise.resolve(xs));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,custom:this.config.custom,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,colorScheme:this.config.colorScheme}}checkDispatchAllowed(e){let t=Pd(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return this.processCommandResults(t)}processCommandResults(e){return e.some(e=>e!==`Success`)?new Id(e.flat()):Id.Success}checkDispatchAllowedRemoteCommand(e){let t=this.coreHandlers.map(t=>t.allowDispatch(e));return this.processCommandResults(t)}checkDispatchAllowedCoreCommand(e){return this.handlers.map(t=>t.allowDispatch(e))}checkDispatchAllowedLocalCommand(e){return this.uiHandlers.map(t=>t.allowDispatch(e))}finalize(){this.status=3;for(let e of this.handlers)e.finalize();this.status=0,this.trigger(`command-finalized`)}canDispatch=(e,t)=>this.checkDispatchAllowed(iK(e,t));dispatch=(e,t)=>{let n=iK(e,t),r=this.status;if(this.getters.isReadonly()&&!Fd(n))return new Id(`Readonly`);if(!this.session.canApplyOptimisticUpdate())return new Id(`WaitingSessionConfirmation`);switch(r){case 0:let t=this.checkDispatchAllowed(n);if(!t.isSuccessful)return this.trigger(`update`),this.trigger(`command-rejected`,{command:n,result:t}),t;this.status=1;let{changes:r,commands:i}=this.state.recordChanges(()=>{let t=performance.now();Pd(n)&&this.state.addCommand(n),this.dispatchToHandlers(this.handlers,n),this.finalize();let r=performance.now()-t;r>5&&console.debug(e,r,`ms`)});this.session.save(n,i,r),this.status=0,this.trigger(`update`);break;case 1:if(Pd(n)){let e=this.checkDispatchAllowed(n);if(!e.isSuccessful)return e;this.state.addCommand(n)}this.dispatchToHandlers(this.handlers,n);break;case 3:throw Error(`Cannot dispatch commands in the finalize state`);case 2:if(Pd(n))throw Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,n)}return Id.Success};dispatchFromCorePlugin=(e,t)=>{let n=iK(e,t),r=this.status;this.status=2;let i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,n),this.status=r,Id.Success};dispatchToHandlers(e,t){let n=Pd(t);for(let r of e)!n&&r instanceof cv||r.beforeHandle(t);for(let r of e)!n&&r instanceof cv||r.handle(t);this.trigger(`command-dispatched`,t)}drawLayer(e,t){let n=this.renderers[t];if(n)for(let r of n)e.ctx.save(),r.drawLayer(e,t),e.ctx.restore()}exportData(){let t=this._exportData(!0),n=this._exportData(!1),r={...this.config,mode:`export_verification`,client:{id:`exporter`,name:`exporter`},snapshotRequested:!1,transportService:new qH};return T(n,new e(x(t),r)._exportData(!1))?t:(n.isNotSquishable=!0,n)}_exportData(e){let t=$C();for(let n of this.handlers)n instanceof cv&&n.export(t,e);return t.revisionId=this.session.getRevisionId()||`START_REVISION`,t=x(t),t}updateMode(e){this.config.mode=e,this.trigger(`update`)}async exportXLSX(){this.dispatch(`EVALUATE_CELLS`);let e=tw();for(let t of this.handlers)t instanceof sv&&await t.exportForExcel(e);return e=x(e),KG(e)}};function iK(e,t={}){let n=x(t);return n.type=e,n}var aK=class extends fV{queuedBordersToAdd={};copy(e){let t=e.sheetId;if(e.zones.length===0)return;let{rowsIndexes:n,columnsIndexes:r}=e,i=[];for(let e of n){let n=[];for(let i of r){let r={col:i,row:e,sheetId:t};n.push(this.getters.getCellBorder(r))}i.push(n)}return{borders:i}}paste(e,t,n){let r=e.sheetId;if(n.pasteOption===`asValue`)return;let i=e.zones;if(!n.isCutOperation)this.pasteFromCopy(r,i,t.borders);else{let{left:e,top:n}=i[0];this.pasteZone(r,e,n,t.borders)}this.executeQueuedChanges(r)}pasteZone(e,t,n,r){for(let[i,a]of r.entries())for(let[r,o]of a.entries()){let a={col:t+r,row:n+i,sheetId:e};this.pasteBorder(o,a)}}pasteBorder(e,t){let n={...this.getters.getCellBorder(t),...e},r=JSON.stringify(n);this.queuedBordersToAdd[r]||(this.queuedBordersToAdd[r]=[]),this.queuedBordersToAdd[r].push(O(t))}executeQueuedChanges(e){for(let t in this.queuedBordersToAdd){let n=this.queuedBordersToAdd[t],r=JSON.parse(t),i=D(n,[]);this.dispatch(`SET_BORDERS_ON_TARGET`,{sheetId:e,target:i,border:r})}this.queuedBordersToAdd={}}},oK=class extends dV{copy(e){}getCopyRect(e){return p_(...e.figureIds.map(t=>this.getters.getFigure(e.sheetId,t)).filter(w).map(t=>this.getters.getFigureUI(e.sheetId,t)))}},sK=class extends oK{copy(e){let t=e.sheetId,n=[],r=this.getCopyRect(e);for(let i of e.figureIds){let e=this.getters.getFigure(t,i);if(!e)throw Error(`No figure for the given id: ${i}`);if(e.tag!==`carousel`)continue;let a={...e},o=this.getters.getCarousel(i),{x:s,y:c}=this.getters.getFigureUI(t,e),l={};for(let e of o.items)if(e.type===`chart`){let t=this.getters.getChart(e.chartId);if(!t)throw Error(`No chart for the given id: ${e.chartId}`);l[e.chartId]=t}n.push({figureId:i,copiedFigure:a,copiedCarousel:o,copiedCharts:l,copiedSheetId:t,offset:{x:s-r.x,y:c-r.y}})}return{figures:n,figureIds:e.figureIds}}getPasteTarget(e,t,n,r){let i={};for(let e of n.figures)i[e.figureId]=G.smallUuid();return{zones:[],figureIds:i,sheetId:e}}paste(e,t,n){if(!e.figureIds)return;let{zones:r}=e,i=e.sheetId;for(let a of t.figures){let o=e.figureIds[a.figureId],{width:s,height:c}=a.copiedFigure,{col:l,row:u,offset:d}=jg(this.getters,i,{col:r[0].left,row:r[0].top},{...a.copiedFigure,offset:a.offset});this.dispatch(`CREATE_CAROUSEL`,{figureId:o,sheetId:i,definition:{items:[]},col:l,row:u,offset:d,size:{height:c,width:s}});let f=x(a.copiedCarousel.items);for(let e of f){if(e.type!==`chart`)continue;let t=a.copiedCharts[e.chartId],n=G.smallUuid(),r=hk.fromDefinition(this.getters,i,t.copyInSheetId(i)).getDefinition();this.dispatch(`CREATE_CHART`,{figureId:o,chartId:n,sheetId:i,definition:r}),e.chartId=n}this.dispatch(`UPDATE_CAROUSEL`,{sheetId:i,figureId:o,definition:{...a.copiedCarousel,items:f}}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:a.copiedSheetId,figureId:a.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:o,selectMultiple:t.figureIds.length>1})}}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}},cK=class extends oK{copy(e){let t=e.sheetId,n=[],r=this.getCopyRect(e);for(let i of e.figureIds){let e=this.getters.getFigure(t,i);if(!e)throw Error(`No figure for the given id: ${i}`);if(e.tag!==`chart`)continue;let a={...e},{x:o,y:s}=this.getters.getFigureUI(t,e),c=this.getters.getChartFromFigureId(i);if(!c)throw Error(`No chart for the given id: ${i}`);n.push({figureId:i,copiedFigure:a,copiedChart:c,offset:{x:o-r.x,y:s-r.y}})}return{figures:n,figureIds:e.figureIds}}getPasteTarget(e,t,n,r){let i={};for(let e of n.figures)i[e.figureId]=G.smallUuid();return{zones:[],figureIds:i,sheetId:e}}paste(e,t,n){if(!e.figureIds)return;let{zones:r}=e,i=e.sheetId;for(let a of t.figures){let o=e.figureIds[a.figureId],{width:s,height:c}=a.copiedFigure,l=a.copiedChart,u=hk.fromDefinition(this.getters,i,l.copyInSheetId(i)).getDefinition();u=hk.fromStrDefinition(this.getters,i,u).getDefinition();let{col:d,row:f,offset:p}=jg(this.getters,i,{col:r[0].left,row:r[0].top},{...a.copiedFigure,offset:a.offset});this.dispatch(`CREATE_CHART`,{figureId:o,chartId:G.smallUuid(),sheetId:i,definition:u,col:d,row:f,offset:p,size:{height:c,width:s}}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:a.copiedChart.sheetId,figureId:a.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:o,selectMultiple:t.figureIds.length>1})}}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}},lK=class extends fV{queuedChanges={};copy(e){if(!e.zones.length)return;let{rowsIndexes:t,columnsIndexes:n}=e,r=e.sheetId,i=[];for(let e of t){let t=[];for(let i of n){let n=Array.from(this.getters.getRulesByCell(r,i,e));t.push({position:{col:i,row:e,sheetId:r},rules:n})}i.push(t)}return{cfRules:i}}paste(e,t,n){if(this.queuedChanges={},n.pasteOption===`asValue`)return;let r=e.zones,i=e.sheetId;n.isCutOperation?this.pasteFromCut(i,r,t):this.pasteFromCopy(i,r,t.cfRules,n),this.executeQueuedChanges()}pasteFromCut(e,t,n){let r=t[0];this.pasteZone(e,r.left,r.top,n.cfRules,{isCutOperation:!0})}pasteZone(e,t,n,r,i){for(let[a,o]of r.entries())for(let[r,s]of o.entries()){let o={col:t+r,row:n+a,sheetId:e};this.pasteCf(s,o,i?.isCutOperation)}}pasteCf(e,t,n){if(e?.rules&&e.rules.length>0){let r=O(e.position),i=O(t);for(let a of e.rules){let o=[];if(n&&o.push(r),e.position.sheetId===t.sheetId)this.adaptCFRules(e.position.sheetId,a,[i],o);else{this.adaptCFRules(e.position.sheetId,a,[],o);let n=this.getCFToCopyTo(t.sheetId,a);this.adaptCFRules(t.sheetId,n,[i],[])}}}}adaptCFRules(e,t,n,r){this.queuedChanges[e]||(this.queuedChanges[e]=[]);let i=this.queuedChanges[e].find(e=>e.cf.id===t.id);i?(i.toAdd.push(...n),i.toRemove.push(...r)):this.queuedChanges[e].push({toAdd:n,toRemove:r,cf:t})}executeQueuedChanges(){for(let e in this.queuedChanges)for(let{toAdd:t,toRemove:n,cf:r}of this.queuedChanges[e]){let i=this.getters.getAdaptedCfRanges(e,r,t,n);if(i){if(i.length===0){this.dispatch(`REMOVE_CONDITIONAL_FORMAT`,{id:r.id,sheetId:e});continue}this.dispatch(`ADD_CONDITIONAL_FORMAT`,{cf:{id:r.id,rule:r.rule,stopIfTrue:r.stopIfTrue},ranges:i,sheetId:e})}}}getCFToCopyTo(e,t){let n=this.getters.getConditionalFormats(e).find(e=>e.stopIfTrue===t.stopIfTrue&&T(e.rule,t.rule)),r=this.queuedChanges[e];return!n&&r&&(n=r.find(e=>e.cf.stopIfTrue===t.stopIfTrue&&T(e.cf.rule,t.rule))?.cf),n||{...t,id:G.smallUuid(),ranges:[]}}},uK=class extends fV{queuedChanges={};copy(e){let{rowsIndexes:t,columnsIndexes:n}=e,r=e.sheetId,i=[];for(let e of t){let t=[];for(let i of n){let n={sheetId:r,col:i,row:e},a=this.getters.getValidationRuleForCell(n);t.push({position:n,rule:a})}i.push(t)}return{dvRules:i}}paste(e,t,n){if(this.queuedChanges={},n.pasteOption)return;let r=e.zones,i=e.sheetId;n.isCutOperation?this.pasteFromCut(i,r,t):this.pasteFromCopy(i,r,t.dvRules),this.executeQueuedChanges()}pasteFromCut(e,t,n){let r=t[0];this.pasteZone(e,r.left,r.top,n.dvRules,{isCutOperation:!0})}pasteZone(e,t,n,r,i){for(let[a,o]of r.entries())for(let[r,s]of o.entries()){let o={col:t+r,row:n+a,sheetId:e};this.pasteDataValidation(s,o,i?.isCutOperation)}}pasteDataValidation(e,t,n){if(e){let r=O(t),i=O(e.position),a=e.rule;if(!a){let e=this.getters.getValidationRuleForCell(t);e&&this.adaptDataValidationRule(t.sheetId,e,[],[r]);return}let o=[];if(n&&o.push(i),e.position.sheetId===t.sheetId){let n=this.getDataValidationRuleToCopyTo(t.sheetId,a,!1);this.adaptDataValidationRule(e.position.sheetId,n,[r],o)}else{let n=this.getters.getValidationRuleForCell(e.position);n&&this.adaptDataValidationRule(e.position.sheetId,n,[],o);let i=this.getDataValidationRuleToCopyTo(t.sheetId,a);this.adaptDataValidationRule(t.sheetId,i,[r],[])}}}getDataValidationRuleToCopyTo(e,t,n=!0){let r=this.getters.getDataValidationRules(e).find(e=>T(t.criterion,e.criterion)&&t.isBlocking===e.isBlocking),i=this.queuedChanges[e];return!r&&i&&(r=i.find(e=>T(t.criterion,e.rule.criterion)&&t.isBlocking===e.rule.isBlocking)?.rule),r||{...t,id:n?G.smallUuid():t.id,ranges:[]}}adaptDataValidationRule(e,t,n,r){this.queuedChanges[e]||(this.queuedChanges[e]=[]);let i=this.queuedChanges[e].find(e=>e.rule.id===t.id);i?(i.toAdd.push(...n),i.toRemove.push(...r)):this.queuedChanges[e].push({toAdd:n,toRemove:r,rule:t})}executeQueuedChanges(){for(let e in this.queuedChanges)for(let{toAdd:t,toRemove:n,rule:r}of this.queuedChanges[e]){let i=D([...D(r.ranges.map(e=>e.zone),n),...t],[]);if(i.length===0){this.dispatch(`REMOVE_DATA_VALIDATION_RULE`,{sheetId:e,id:r.id});continue}this.dispatch(`ADD_DATA_VALIDATION_RULE`,{rule:{id:r.id,criterion:r.criterion,isBlocking:r.isBlocking},ranges:i.map(t=>this.getters.getRangeDataFromZone(e,t)),sheetId:e})}}},dK=class extends fV{copy(e){let t={style:{},format:{},width:e.columnsIndexes.length,height:e.rowsIndexes.length,sheetId:e.sheetId,zones:e.clippedZones};t.format={sheetDefault:this.getters.getDefaultFormat(e.sheetId,`SHEET`,void 0)??``,colDefault:[],rowDefault:[]};let n=0;for(let r of e.columnsIndexes){let i=this.getters.getDefaultFormat(e.sheetId,`COL`,r);i&&t.format.colDefault&&(t.format.colDefault[n]=i),n++}let r=0;for(let n of e.rowsIndexes){let i=this.getters.getDefaultFormat(e.sheetId,`ROW`,n);i&&t.format.rowDefault&&(t.format.rowDefault[r]=i),r++}for(let n in Ue){t.style[n]={sheetDefault:this.getters.getDefaultStyle(e.sheetId,n,`SHEET`,void 0)??Ue[n],colDefault:{},rowDefault:{}};let r=0;for(let i of e.columnsIndexes){let a=this.getters.getDefaultStyle(e.sheetId,n,`COL`,i);a!==void 0&&(t.style[n].colDefault[r]=a),r++}let i=0;for(let r of e.rowsIndexes){let a=this.getters.getDefaultStyle(e.sheetId,n,`ROW`,r);a!==void 0&&(t.style[n].rowDefault[i]=a),i++}}return t}clearStyleFormat(e,t){this.dispatch(`SET_FORMATTING`,{sheetId:e,target:[t],format:``})}paste(e,t,n){let r=e.sheetId;if(n.pasteOption===`asValue`)return;let i=e.zones;if(n.isCutOperation){this.clearClippedZones(t);let{left:e,top:n}=i[0];this.pasteStyle(r,e,n,t.width,t.height,t.style),this.pasteFormat(r,e,n,t.width,t.height,t.format)}else for(let e of i)for(let n of fw(e,t.width,t.height))this.pasteStyle(r,n.left,n.top,t.width,t.height,t.style),this.pasteFormat(r,n.left,n.top,t.width,t.height,t.format)}clearClippedZones(e){this.dispatch(`CLEAR_FORMATTING`,{sheetId:e.sheetId,target:e.zones})}pasteStyle(e,t,n,r,i,a){let o=Sn({}),s={},c=0;function l(e,t){let n=`${e.left}:${e.right}:${e.top}:${e.bottom}`;s[n]=[e,c++],o.set(n,{...o.get(n),...t})}l({left:t,right:t+r-1,top:n,bottom:n+i-1},Ue);for(let e in a)l({left:t,right:t+r-1,top:n,bottom:n+i-1},{[e]:a[e].sheetDefault});for(let e in a)for(let r in a[e].colDefault){let o=parseInt(r);l({left:t+o,right:t+o,top:n,bottom:n+i-1},{[e]:a[e].colDefault[r]})}for(let e in a)for(let i in a[e].rowDefault){let o=parseInt(i);l({left:t,right:t+r-1,top:n+o,bottom:n+o},{[e]:a[e].rowDefault[i]})}let u=[];for(let[e,[t,n]]of Object.entries(s)){let r=o.get(e);Bt(r)||u.push([n,t,r])}u.sort((e,t)=>e[0]-t[0]);for(let[t,n,r]of u)this.dispatch(`SET_FORMATTING`,{sheetId:e,target:[n],style:r})}pasteFormat(e,t,n,r,i,a){let o={},s={},c=0;function l(e,t){let n=`${e.left}:${e.right}:${e.top}:${e.bottom}`;s[n]=[e,c++],o[n]=t}l({left:t,right:t+r-1,top:n,bottom:n+i-1},a.sheetDefault??``);for(let e in a.colDefault){let r=parseInt(e);l({left:t+r,right:t+r,top:n,bottom:n+i-1},a.colDefault[e])}for(let e in a.rowDefault){let i=parseInt(e);l({left:t,right:t+r-1,top:n+i,bottom:n+i},a.rowDefault[e])}let u=[];for(let[e,[t,n]]of Object.entries(s)){let r=o[e];u.push([n,t,r])}u.sort((e,t)=>e[0]-t[0]);for(let[t,n,r]of u)this.dispatch(`SET_FORMATTING`,{sheetId:e,target:[n],format:r})}},fK=class extends oK{copy(e){let t=e.sheetId,n=[],r=this.getCopyRect(e);for(let i of e.figureIds){let e=this.getters.getFigure(t,i);if(!e)throw Error(`No figure for the given id: ${i}`);if(e.tag!==`image`)continue;let a={...e},{x:o,y:s}=this.getters.getFigureUI(t,e),c=x(this.getters.getImage(i));n.push({figureId:i,copiedFigure:a,copiedImage:c,sheetId:t,offset:{x:o-r.x,y:s-r.y}})}return{figures:n,figureIds:e.figureIds}}getPasteTarget(e,t,n,r){let i={};for(let e of n.figures)i[e.figureId]=G.smallUuid();return{sheetId:e,zones:[],figureIds:i}}paste(e,t,n){if(!e.figureIds)return;let{zones:r}=e;for(let i of t.figures){let a=e.figureIds[i.figureId],o=this.getters.getActiveSheetId(),{width:s,height:c}=i.copiedFigure,l=x(i.copiedImage),{col:u,row:d,offset:f}=jg(this.getters,o,{col:r[0].left,row:r[0].top},{...i.copiedFigure,offset:i.offset});this.dispatch(`CREATE_IMAGE`,{figureId:a,sheetId:o,col:u,row:d,offset:f,size:{height:c,width:s},definition:l}),n.isCutOperation&&this.dispatch(`DELETE_FIGURE`,{sheetId:i.sheetId,figureId:i.copiedFigure.id}),this.dispatch(`SELECT_FIGURE`,{figureId:a,selectMultiple:t.figureIds.length>1})}}isPasteAllowed(e,t,n,r){return t.length===0?`EmptyTarget`:r?.pasteOption===void 0?`Success`:`WrongFigurePasteOption`}},pK=class extends fV{copy(e){let t=this.getters.getActiveSheetId(),{rowsIndexes:n,columnsIndexes:r}=e,i=[];for(let e of n){let n=[];for(let i of r){let r={col:i,row:e,sheetId:t};n.push(this.getters.getMerge(r))}i.push(n)}return{merges:i,sheetId:t}}paste(e,t,n){if(n.isCutOperation){let e=t.merges.flat().filter(w);this.dispatch(`REMOVE_MERGE`,{sheetId:t.sheetId,target:e})}this.pasteFromCopy(e.sheetId,e.zones,t.merges,n)}pasteZone(e,t,n,r){for(let[i,a]of r.entries())for(let[r,o]of a.entries()){let a={col:t+r,row:n+i,sheetId:e};this.pasteMerge(o,a)}}pasteMerge(e,t){if(!e||this.getters.isInMerge(t))return;let{sheetId:n,col:r,row:i}=t;this.dispatch(`ADD_MERGE`,{sheetId:n,force:!0,target:[{left:r,top:i,right:r+e.right-e.left,bottom:i+e.bottom-e.top}]})}},mK=class extends fV{copy(e){return{zones:e.clippedZones,sheetId:e.sheetId}}paste(e,t,n){if(n.isCutOperation){let n=e.zones[0];this.dispatch(`MOVE_RANGES`,{target:t.zones,sheetId:t.sheetId,sheetName:this.getters.getSheetName(t.sheetId),targetSheetId:e.sheetId,col:n.left,row:n.top})}}},hK=class extends fV{isPasteAllowed(e,t,n,r){if(!(`cells`in n))return`Success`;let{xSplit:i,ySplit:a}=this.getters.getPaneDivisions(e);return Sr(pw(t,n.cells),i,a)?`FrozenPaneOverlap`:`Success`}},gK=class extends fV{copy(e,t,n=`copyPaste`){let r=e.sheetId,{rowsIndexes:i,columnsIndexes:a,zones:o}=e,s=new Set,c=[];for(let e of i){let l=[];c.push(l);for(let c of a){let a={col:c,row:e,sheetId:r},u=this.getters.getTable(a);if(!u){l.push({});continue}let d=this.getters.getCoreTable(a),f=d?.range.zone,p;if(!s.has(u.id)&&d&&f&&o.some(e=>or(f,e))){s.add(u.id);let{numberOfRows:e}=sr(f);for(let n=f.top;n<=f.bottom;n++)!t&&!i.includes(n)&&e--;let n=d.range,r=this.getters.extendRange(d.range,`ROW`,n.zone.top+e-1-n.zone.bottom);p={range:this.getters.getRangeData(r),config:d.config,type:d.type}}if(u.isPivotTable){let t=u.range.zone.top===e&&u.range.zone.left===c,n=o.some(e=>or(u.range.zone,e));(t||n)&&s.add(u.id)}n!==`shiftCells`&&l.push({table:p,style:this.getTableStyleToCopy(a),isWholeTableCopied:s.has(u.id)})}}return{tableCells:c,sheetId:e.sheetId}}getTableStyleToCopy(e){let t=Zt({...this.getters.getCellTableStyle(e),hideGridLines:!1}),n=this.getters.getCellStyle(e),r=this.getters.getCellTableBorder(e),i=this.getters.getCellBorder(e);return{style:{...t,...Zt(n)},border:{...r,...Zt(i)}}}paste(e,t,n){let r=e.zones,i=e.sheetId;n.isCutOperation?this.pasteFromCut(i,r,t,n):this.pasteFromCopy(i,r,t.tableCells,n)}pasteFromCut(e,t,n,r){for(let e of n.tableCells)for(let t of e)t.table&&this.dispatch(`REMOVE_TABLE`,{sheetId:n.sheetId,target:[this.getters.getRangeFromRangeData(t.table.range).zone]});let i=t[0];this.pasteZone(e,i.left,i.top,n.tableCells,r)}pasteZone(e,t,n,r,i){for(let a=0;a<r.length;a++){let o=r[a];for(let r=0;r<o.length;r++){let s=o[r];if(!s)continue;let c={col:t+r,row:n+a,sheetId:e};this.pasteTableCell(e,s,c,i)}}if(r.length===1)for(let i=0;i<r[0].length;i++)this.dispatch(`AUTOFILL_TABLE_COLUMN`,{col:t+i,row:n,sheetId:e})}pasteTableCell(e,t,n,r){if(t.table&&!r?.pasteOption){let{range:r}=t.table,i=sr(this.getters.getRangeFromRangeData(r).zone),a={left:n.col,top:n.row,right:n.col+i.numberOfCols-1,bottom:n.row+i.numberOfRows-1};this.dispatch(`CREATE_TABLE`,{sheetId:n.sheetId,ranges:[this.getters.getRangeDataFromZone(e,a)],config:t.table.config,tableType:t.table.type})}this.getters.getCoreTable(n)||r?.pasteOption===`asValue`||(!r?.pasteOption&&!t.isWholeTableCopied||r?.pasteOption===`onlyFormat`)&&(t.style?.style&&this.dispatch(`UPDATE_CELL`,{...n,style:t.style.style}),t.style?.border&&this.dispatch(`SET_BORDER`,{...n,border:t.style.border}))}};XL.figureHandlers.add(`chart`,cK).add(`image`,fK).add(`carousel`,sK),XL.cellHandlers.add(`dataValidation`,uK).add(`default`,dK).add(`cell`,pV).add(`sheet`,hK).add(`merge`,pK).add(`border`,aK).add(`table`,gK).add(`conditionalFormat`,lK).add(`references`,mK);var _K=class extends A{static maxSize={maxHeight:80};static template=`o-spreadsheet-ErrorToolTip`;props=(0,t.props)({cellPosition:N.CellPosition(),onClosed:N.function().optional()});get dataValidationErrorMessage(){return this.env.model.getters.getInvalidDataValidationMessage(this.props.cellPosition)}get evaluationError(){let e=this.env.model.getters.getEvaluatedCell(this.props.cellPosition);if(e.message)return e}get errorOriginPositionString(){if(this.env.model.getters.isDashboard())return``;let e=this.evaluationError?.errorOriginPosition;if(!e||T(e,this.props.cellPosition))return``;let t=e.sheetId;return this.env.model.getters.getRangeString(this.env.model.getters.getRangeFromZone(t,O(e)),this.env.model.getters.getActiveSheetId())}selectCell(){let e=this.evaluationError?.errorOriginPosition;if(!e)return;let t=this.env.model.getters.getActiveSheetId();e.sheetId!==t&&this.env.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:t,sheetIdTo:e.sheetId}),this.env.model.selection.selectCell(e.col,e.row)}get isSpillErrorBecauseOfMissingHeaders(){let e=this.evaluationError;return e?.value===F.SpilledBlocked&&!e.errorOriginPosition&&!this.env.model.getters.getSpreadZone(this.props.cellPosition,{ignoreSpillError:!0})}getMissingHeadersForSpread(){if(!this.isSpillErrorBecauseOfMissingHeaders)return;let e=this.env.model.getters.getCell(this.props.cellPosition);if(!e||!e.isFormula)return;let t=e.compiledFormula.toFormulaString(this.env.model.getters);return xn(this.env.model.getters,this.props.cellPosition,t)}addMissingHeaders({missingCols:e,missingRows:t}){let n=this.props.cellPosition.sheetId;e>0&&this.env.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:n,sheetName:this.env.model.getters.getSheetName(n),dimension:`COL`,base:this.env.model.getters.getNumberCols(n)-1,position:`after`,quantity:e+20}),t>0&&this.env.model.dispatch(`ADD_COLUMNS_ROWS`,{sheetId:n,sheetName:this.env.model.getters.getSheetName(n),dimension:`ROW`,base:this.env.model.getters.getNumberRows(n)-1,position:`after`,quantity:t+50})}getAddMissingHeadersButtonText(e){return e.missingCols>0&&e.missingRows>0?P(`Add missing columns and rows`):e.missingCols>0?P(`Add missing columns`):P(`Add missing rows`)}};let vK={onHover:(e,t)=>{let n=t.getEvaluatedCell(e);return n.type===`error`&&n.message||t.getInvalidDataValidationMessage(e)?{isOpen:!0,props:{cellPosition:e},Component:_K,cellCorner:`top-right`}:{isOpen:!1}}};var yK=class extends A{static template=`o-spreadsheet-FilterMenu`;static components={FilterMenuValueList:eN,SidePanelCollapsible:UE,FilterMenuCriterion:QM};props=(0,t.props)({filterPosition:N.Position(),onClosed:N.function().optional()});state;criterionCategory=`text`;updatedCriterionValue;setup(){(0,t.onWillUpdateProps)(e=>{T(e.filterPosition,this.props.filterPosition)||(this.updatedCriterionValue=void 0,this.criterionCategory=this.getCriterionCategory(e.filterPosition),this.state.values=this.getFilterHiddenValues(e.filterPosition))}),this.state=(0,t.proxy)({values:this.getFilterHiddenValues(this.props.filterPosition)}),this.criterionCategory=this.getCriterionCategory(this.props.filterPosition)}get isSortable(){if(!this.table)return!1;let e=this.env.model.getters.getCoreTableMatchingTopLeft(this.table.range.sheetId,this.table.range.zone);return!this.env.model.getters.isReadonly()&&e?.type!==`dynamic`}get table(){let e=this.env.model.getters.getActiveSheetId(),t=this.props.filterPosition;return this.env.model.getters.getTable({sheetId:e,...t})}get filterValueType(){let e=this.env.model.getters.getActiveSheetId(),t=this.props.filterPosition;return this.env.model.getters.getFilterValue({sheetId:e,...t})?.filterType}getCriterionCategory(e){let t=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getFilter({sheetId:t,...e});if(!n||!n.filteredRange)return`text`;let r={text:0,number:0,date:0},i=n.filteredRange.zone;for(let n=i.top;n<=i.bottom&&!(n>100);n++){let i=this.env.model.getters.getEvaluatedCell({sheetId:t,row:n,col:e.col});i.type===`text`||i.type===`boolean`?r.text++:i.type===`number`&&(i.format&&fc(i.format)?r.date++:r.number++)}let a=Math.max(r.text,r.number,r.date);return Object.keys(r).find(e=>r[e]===a)||`text`}onUpdateHiddenValues(e){this.updatedCriterionValue={filterType:`values`,hiddenValues:e}}onCriterionChanged(e){this.updatedCriterionValue=e}confirm(){if(!this.updatedCriterionValue){this.props.onClosed?.();return}let e=this.props.filterPosition;this.env.model.dispatch(`UPDATE_FILTER`,{...e,sheetId:this.env.model.getters.getActiveSheetId(),value:this.updatedCriterionValue}),this.props.onClosed?.()}get criterionOperators(){return this.criterionCategory===`date`?ZM:this.criterionCategory===`number`?XM:YM}cancel(){this.props.onClosed?.()}sortFilterZone(e){let t=this.props.filterPosition,n=this.table?.range.zone;if(!t||!n||n.top===n.bottom)return;let r=this.env.model.getters.getActiveSheetId(),i={...n,top:n.top+1},a={col:t.col,row:i.top};II(this.env,r,a,i,e,{emptyCellAsZero:!0,sortHeaders:!0}),this.props.onClosed?.()}getFilterHiddenValues(e){let t=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getFilter({sheetId:t,...e});if(!n?.filteredRange)return[];let r=this.env.model.getters.getFilterValue({sheetId:t,...e}),i=ur(n.filteredRange.zone);r?.filterType!==`criterion`&&(i=i.filter(e=>!this.env.model.getters.isRowHidden(t,e.row)));let a=i.map(e=>this.env.model.getters.getEvaluatedCell({sheetId:t,...e}).formattedValue),o=r?.filterType===`values`?r.hiddenValues:[],s=new Set(o.map(Af)),c=new Set,l=[],u=e=>{let t=Af(e);c.has(t)||(l.push({string:e||``,checked:r?.filterType===`criterion`?!1:!s.has(t),normalizedValue:t}),c.add(t))};return a.forEach(u),o.forEach(u),l.sort((e,t)=>e.normalizedValue.localeCompare(t.normalizedValue,void 0,{numeric:!0,sensitivity:`base`}))}getFilterCriterionValue(e){let t=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getFilterCriterionValue({sheetId:t,...e});return n?.filterType===`criterion`?x(n):{filterType:`criterion`,type:`none`,values:[]}}};let bK={onOpen:(e,t)=>({isOpen:!0,props:{filterPosition:e},Component:yK,cellCorner:`bottom-left`})};var xK=class extends A{static template=`o-spreadsheet-LinkDisplay`;props=(0,t.props)({cellPosition:N.CellPosition(),onClosed:N.function().optional()});cellPopovers;setup(){this.cellPopovers=j(cw)}get cell(){let{col:e,row:t}=this.props.cellPosition,n=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getEvaluatedCell({sheetId:n,col:e,row:t})}get link(){if(this.cell.link)return this.cell.link;let{col:e,row:t}=this.props.cellPosition;throw Error(`LinkDisplay Component can only be used with link cells. ${E(e,t)} is not a link.`)}getUrlRepresentation(e){return Wd(e,this.env.model.getters)}openLink(e){Gd(this.link,this.env,ue(e))}edit(){let{col:e,row:t}=this.props.cellPosition;this.env.model.selection.selectCell(e,t),this.cellPopovers.open({col:e,row:t},`LinkEditor`)}unlink(){let e=this.env.model.getters.getActiveSheetId(),{col:t,row:n}=this.props.cellPosition,r=this.env.model.getters.getCellComputedStyle({sheetId:e,col:t,row:n}),i=r?.textColor===`#017E84`?void 0:r?.textColor;this.env.model.dispatch(`UPDATE_CELL`,{col:t,row:n,sheetId:e,content:this.link.label,style:{...r,textColor:i,underline:void 0}})}};let SK={onHover:(e,t)=>{let n=t.getEvaluatedCell(e);return!t.isDashboard()&&n.link&&t.isVisibleInViewport(e)?{isOpen:!0,Component:xK,props:{cellPosition:e},cellCorner:`bottom-left`}:{isOpen:!1}}};var CK=class extends A{static template=`o-spreadsheet-LinkEditor`;static components={MenuPopover:C_};props=(0,t.props)({cellPosition:N.CellPosition(),onClosed:N.function().optional()});static size={maxHeight:500};urlInput=(0,t.signal)(null);suggestionListRef=(0,t.signal)(null);urlInputContainer=(0,t.signal)(null);state=(0,t.proxy)(this.defaultState);setup(){this.computeLinks(),(0,t.onMounted)(()=>this.urlInput()?.focus())}computeLinks(){this.state.selectedIndex=null,this.state.linksByCategory=this.linkProposalByCategory,this.state.linksList=Object.values(this.state.linksByCategory).flat()}get linkProposalByCategory(){let e={},t=-1,n=this.state.url;for(let r of Bd.getKeys()){let i=Bd.get(r),a=i.getLinkProposals?.(this.env)||[],o=n&&this.state.isUrlEditable?nA(n,a,e=>i.urlRepresentation(e.url,this.env.model.getters)):a;o.length!==0&&(e[i.title]=o.map(e=>{t++;let n=i.urlRepresentation(e.url,this.env.model.getters),r=t;return{text:n,icon:e.icon,index:r,onSelect:()=>{this.state.url=e.url,this.state.label=e.label,this.state.isUrlEditable=e.isUrlEditable,this.state.selectedIndex=r,this.urlInputContainer()?.focus()}}}))}return e}get defaultState(){let{col:e,row:t}=this.props.cellPosition,n=this.env.model.getters.getActiveSheetId(),r=this.env.model.getters.getEvaluatedCell({sheetId:n,col:e,row:t});return r.link?{url:r.link.url,label:r.formattedValue,isUrlEditable:r.link.isUrlEditable,selectedIndex:null,linksByCategory:{},linksList:[]}:{label:r.formattedValue,url:``,isUrlEditable:!0,selectedIndex:null,linksByCategory:{},linksList:[]}}getUrlRepresentation(e){return Wd(e,this.env.model.getters)}removeLink(){this.state.url=``,this.state.isUrlEditable=!0,this.computeLinks()}save(){let{col:e,row:t}=this.props.cellPosition,n=this.env.model.getters.getLocale(),r=this.state.label?q_(this.state.label,n):this.state.url;this.env.model.dispatch(`UPDATE_CELL`,{col:e,row:t,sheetId:this.env.model.getters.getActiveSheetId(),content:Pt(r,this.state.url)}),this.props.onClosed?.()}cancel(){this.props.onClosed?.()}onKeyDown(e){switch(e.key){case`Enter`:this.state.url&&this.save(),e.stopPropagation(),e.preventDefault();break;case`Escape`:this.cancel(),e.stopPropagation();break}}onInputKeyDown(e){switch(e.key){case`Enter`:if(this.state.selectedIndex!==null){let t=this.state.linksList[this.state.selectedIndex];if(t){let n=this.state.url;t.onSelect(),this.state.url!==n&&(e.stopPropagation(),e.preventDefault())}}break;case`ArrowDown`:this.state.selectedIndex=this.state.selectedIndex===null||this.state.selectedIndex===this.state.linksList.length-1?0:(this.state.selectedIndex+1)%this.state.linksList.length,this.showSelectedProposal(),e.stopPropagation(),e.preventDefault();break;case`ArrowUp`:this.state.selectedIndex!==null&&(this.state.selectedIndex=this.state.selectedIndex===0?this.state.linksList.length-1:(this.state.selectedIndex-1)%this.state.linksList.length,this.showSelectedProposal(),e.stopPropagation(),e.preventDefault());break}}showSelectedProposal(){this.suggestionListRef()?.querySelector(`.suggestion-item[data-index="${this.state.selectedIndex}"]`)?.scrollIntoView({block:`nearest`})}};sw.add(`ErrorToolTip`,vK).add(`LinkCell`,SK).add(`LinkEditor`,{onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:CK,cellCorner:`bottom-left`})}).add(`FilterMenu`,bK),rA.add(`dataValidation`,{displayAllOnInitialContent:!0,canBeToggled:!1,getProposals(e,t){if(vn(t)||!this.composer.currentEditedCell)return[];let n=this.composer.currentEditedCell,r=this.getters.getValidationRuleForCell(n);if(!r||r.criterion.type!==`isValueInList`&&r.criterion.type!==`isValueInRange`)return[];let i=this.composer.currentEditedCell.sheetId,a=r.criterion.type===`isValueInRange`?this.getters.getDataValidationRangeValues(i,r.criterion):r.criterion.values.map(e=>({label:e,value:e}));if(r.criterion.displayStyle!==`chip`)return a.map(e=>({text:e.value,fuzzySearchKey:e.label,htmlContent:[{value:e.label}]}));let o=r.criterion.colors;return a.map(e=>{let t=o?.[e.value];return{text:e.value,htmlContent:[{value:e.label,color:vp(t||`#E7E9ED`),backgroundColor:t||`#E7E9ED`,classes:[`badge rounded-pill fs-6 fw-normal w-100 mt-1 text-start`]}],fuzzySearchKey:e.label}})},selectProposal(e,t){this.composer.setCurrentContent(t.text),this.composer.stopEdition()}}),rA.add(`functions_and_named_ranges`,{sequence:100,autoSelectFirstProposal:!0,maxDisplayedProposals:10,getProposals(e){if(e.type!==`SYMBOL`)return[];let t=e.value;if(!vn(this.composer.currentContent))return[];let n=Object.entries(il.content).filter(([e,{hidden:t}])=>!t).map(([e,{description:n}])=>({type:`function`,text:e,icon:`o-spreadsheet-Icon.FX_SVG`,description:n,htmlContent:iN(t,e,Me,`o-semi-bold`)}));return n.push(...this.getters.getNamedRanges().map(e=>({type:`named_range`,text:e.name,description:this.getters.getRangeString(e.range),icon:`o-spreadsheet-Icon.NAMED_RANGE`,htmlContent:iN(t,e.name,Me,`o-semi-bold`)}))),n.sort((e,t)=>e.text.length-t.text.length||e.text.localeCompare(t.text)),n},selectProposal(e,t){let n=e.end,r=e.end;[`SYMBOL`,`FUNCTION`].includes(e.type)&&(n=e.start);let i=this.composer.currentTokens,a=t.text;if(t.type===`function`){a+=`(`;let t=i.map(e=>e.start).indexOf(e.start);t+1<i.length&&i[t+1]?.type===`LEFT_PAREN`&&r++}this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(a)}});function wK(e,t){for(let n=0;n<t.length;n++){let r=t[n].proposalValues;r===void 0||r.length===0||rA.add(`${e}_function_${t[n].name}_argument_proposals`,{sequence:50,autoSelectFirstProposal:!0,selectProposal:TK,getProposals:t=>{let i=t.functionContext;if(!i||i.parent.toUpperCase()!==e.toUpperCase()||i.argPosition!==n)return;let a=[],o=``;for(let{value:e,label:t}of r){switch(typeof e){case`string`:o=`"${e}"`;break;case`number`:o=e.toString();break;case`boolean`:o=e?`TRUE`:`FALSE`;break;default:}a.push({text:o,description:t,htmlContent:[{value:o,color:typeof e==`string`?pt.STRING:pt.NUMBER}],fuzzySearchKey:o,alwaysExpanded:!0})}return a}})}}function TK(e,t){let n=e.end,r=e.end;[`LEFT_PAREN`,`ARG_SEPARATOR`].includes(e.type)||(n=e.start),this.composer.stopComposerRangeSelection(),this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t.text)}il.getAll().forEach(e=>wK(e.name,e.args)),rA.add(`pivot_ids`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||![`PIVOT.VALUE`,`PIVOT.HEADER`,`PIVOT`].includes(t.parent.toUpperCase())||t.argPosition!==0)return;let n=this.getters.getPivotIds();if(!n.includes(e.value))return n.map(e=>{let t=this.getters.getPivotCoreDefinition(e),n=`${this.getters.getPivotFormulaId(e)}`;return{text:n,description:t.name,htmlContent:[{value:n,color:pt.NUMBER}],fuzzySearchKey:n+t.name,alwaysExpanded:!0}}).filter(w)},selectProposal:TK}),rA.add(`pivot_measures`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(t?.parent.toUpperCase()!==`PIVOT.VALUE`||t.argPosition!==1)return[];let n=iP(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return[];let i=this.getters.getPivot(r);return i.init(),i.isValid()?i.definition.measures.map(e=>{if(e.fieldName===`__count`){let e=`"__count"`;return{text:e,description:P(`Count`),htmlContent:[{value:e,color:pt.STRING}],fuzzySearchKey:P(`Count`)+e}}return tP(e)}).filter(w):[]},selectProposal:TK}),rA.add(`pivot_group_fields`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!EK(e)&&!DK(e))return;let n=iP(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return;let i=this.getters.getPivot(r);i.init();let a=i.getFields(),{columns:o,rows:s}=i.definition,c=t.args;t?.parent.toUpperCase()===`PIVOT.VALUE`?(c=c.filter((e,t)=>t%2==0),c=c.slice(1,t.argPosition)):c=c.filter((e,t)=>t%2==1);let l=c.map(e=>e?.value).filter(w),u=o.map(e=>e.nameWithGranularity),d=s.map(e=>e.nameWithGranularity),f=[],p=[`ARG_SEPARATOR`,`SPACE`].includes(e.type)?l.at(-1):l.at(-2),m=kR.get(i.type);if(m&&p?.startsWith(`#`)&&(p=p.slice(1)),p===void 0&&(f.push(u[0]),f.push(d[0])),d.includes(p)){let e=d[d.indexOf(p)+1];f.push(e),f.push(u[0])}if(u.includes(p)){let e=u[u.indexOf(p)+1];f.push(e)}let h=f.filter(w);return h.map(e=>{let[t,n]=e.split(`:`),r=a[t];return r?eP(r,n):void 0}).concat(h.map(e=>{if(!m)return;let t=a[e.split(`:`)[0]];if(!t)return;let n=`"#${e}"`;return{text:n,description:P(`%s (positional)`,t.string)+(t.help?` (${t.help})`:``),htmlContent:[{value:n,color:pt.STRING}],fuzzySearchKey:t.string+n}})).filter(w)},selectProposal:TK});function EK(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==0}function DK(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==1}rA.add(`pivot_group_values`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!e||!OK(e)&&!kK(e))return;let n=iP(e),r=this.getters.getPivotId(n);if(!r||!this.getters.isExistingPivot(r))return;let i=this.getters.getPivot(r);if(!i.isValid())return;let a=t.argPosition,o=e.functionContext?.args[a-1]?.value;if(!o)return;let s;try{s=i.definition.getDimension(o)}catch{return}return s.granularity===`month_number`?Object.values(Xs).map((e,t)=>({text:`${t+1}`,fuzzySearchKey:e.toString(),description:e.toString(),htmlContent:[{value:`${t+1}`,color:pt.NUMBER}]})):s.granularity===`quarter_number`?[1,2,3,4].map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:P(`Quarter %s`,e),htmlContent:[{value:`${e}`,color:pt.NUMBER}]})):s.granularity===`day_of_month`?C(1,32).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:pt.NUMBER}]})):s.granularity===`iso_week_number`?C(0,54).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:pt.NUMBER}]})):s.granularity===`day_of_week`?C(1,8).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:pt.NUMBER}]})):s.granularity===`hour_number`?C(0,24).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:pt.NUMBER}]})):s.granularity===`minute_number`?C(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:pt.NUMBER}]})):s.granularity===`second_number`?C(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:pt.NUMBER}]})):i.getPossibleFieldValues(s).map(({value:e,label:t})=>{let n=typeof e==`string`,r=n?`"${e}"`:e.toString(),i=n?pt.STRING:pt.NUMBER,a=t===e?``:t;return{text:r,description:a,htmlContent:[{value:r,color:i}],fuzzySearchKey:r+a}})},selectProposal:TK});function OK(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==1}function kK(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==0}rA.add(`sheet_names`,{sequence:150,autoSelectFirstProposal:!0,getProposals(e){return e.type===`SYMBOL`||e.type===`UNKNOWN`&&e.value.startsWith(`'`)?this.getters.getSheetIds().map(e=>{let t=Tt(this.getters.getSheetName(e));return{text:t,fuzzySearchKey:t.startsWith(`'`)?t:`'`+t}}):[]},selectProposal(e,t){let n=e.start,r=e.end;this.composer.changeComposerCursorSelection(n,r),this.composer.replaceComposerCursorSelection(t.text+`!`)}});function AK(e){return e.yRanges.length&&!dl.test(e.yRanges[0])?`InvalidYRange`:e.xRange&&!dl.test(e.xRange)?`InvalidXRange`:e.labelRange&&!dl.test(e.labelRange)?`InvalidLabelRange`:e.sizeRange&&!dl.test(e.sizeRange)?`InvalidBubbleSizeRange`:`Success`}let jK={sequence:40,allowedDefinitionKeys:[...Rh.commonKeys,`yRanges`,`xRange`,`labelRange`,`sizeRange`,`dataSetsHaveTitle`,`verticalAxisPosition`,`labelsAsText`,`bubbleColor`,`legendPosition`,`axesDesign`,`showValues`],fromStrDefinition(e,t,n){let r=e.yRanges.map(e=>wu(n,t,e)).filter(w),i=wu(n,t,e.xRange),a=wu(n,t,e.labelRange),o=wu(n,t,e.sizeRange);return{...e,yRanges:r,xRange:i,labelRange:a,sizeRange:o}},toStrDefinition(e,t,n){return{...e,yRanges:e.yRanges.map(e=>n.getRangeString(e,t)),xRange:e.xRange?n.getRangeString(e.xRange,t):void 0,labelRange:e.labelRange?n.getRangeString(e.labelRange,t):void 0,sizeRange:e.sizeRange?n.getRangeString(e.sizeRange,t):void 0}},validateDefinition(e,t){return e.checkValidations(t,AK)},transformDefinition(e,t,{adaptRangeString:n}){let r=e=>{if(!e)return;let{changeType:r,range:i}=n(t,e);return r===`REMOVE`?void 0:i};return{...e,yRanges:e.yRanges.map(r).filter(w),xRange:r(e.xRange),sizeRange:r(e.sizeRange),labelRange:r(e.labelRange)}},getDefinitionFromContextCreation(e,t){let n=e.dataSource?.type===`range`;return{background:e.background,yRanges:n?e.dataSource.dataSets?.map(e=>e.dataRange)??[]:[],verticalAxisPosition:e.dataSetStyles?.[0]?.verticalAxisPosition,dataSetsHaveTitle:n?e.dataSource.dataSetsHaveTitle??!1:!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`bubble`,labelRange:e.bubbleLabelRange||void 0,labelsAsText:e.labelsAsText??!1,xRange:e.auxiliaryRange||void 0,sizeRange:e.bubbleSizeRange||void 0,axesDesign:e.axesDesign,showValues:e.showValues,humanize:e.humanize,annotationText:e.annotationText,annotationLink:e.annotationLink,bubbleColor:e.bubbleColorMode||{color:`multiple`}}},getContextCreation(e,t){return{...e,dataSource:{type:`range`,dataSets:e.yRanges.map((e,t)=>({dataSetId:`${t}`,dataRange:e}))},bubbleLabelRange:e.labelRange,auxiliaryRange:e.xRange,bubbleSizeRange:e.sizeRange,bubbleColorMode:e.bubbleColor}},getDefinitionForExcel:()=>void 0,updateRanges(e,t){let n=e.yRanges.map(e=>tm(e,t)).filter(w),r=tm(e.xRange,t),i=tm(e.labelRange,t),a=tm(e.sizeRange,t);return{...e,yRanges:n,xRange:r,labelRange:i,sizeRange:a}},duplicateInDuplicatedSheet(e,t,n){let r=e=>em(t,n,e);return{...e,yRanges:e.yRanges.map(r).filter(w),xRange:r(e.xRange),labelRange:r(e.labelRange),sizeRange:r(e.sizeRange)}},copyInSheetId:e=>e,getRuntime(e,t){let n=DD(t,e);return{chartJsConfig:{type:`line`,data:{datasets:ch(t,n),labels:n.labels},options:{...Sg,layout:QD(t,n),scales:Um(t,n),plugins:{title:PO(t,e),legend:_O(t,n),tooltip:VO(t,n),chartShowValuesPlugin:OO(t,n),background:{color:t.background}}}}}}};function MK(e){return!wk.includes(e.horizontalGroupBy)||!wk.includes(e.verticalGroupBy)?`InvalidChartDefinition`:`Success`}let NK={sequence:110,dataSeriesLimit:1,allowedDefinitionKeys:[...Rh.commonKeys,`dataSource`,`dataSetStyles`,`showValues`,`colorScale`,`missingValueColor`,`axesDesign`,`horizontalGroupBy`,`verticalGroupBy`,`legendPosition`],validateDefinition(e,t){return e.checkValidations(t,MK)},fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,updateRanges:e=>e,getContextCreation:e=>e,getDefinitionFromContextCreation(e,t){let n=`left`;return e.legendPosition===`right`&&(n=`right`),{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},title:e.title||{text:``},type:`calendar`,showValues:e.showValues,axesDesign:e.axesDesign,legendPosition:n,horizontalGroupBy:`day_of_week`,verticalGroupBy:`month_number`,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractData:n}){let r=yD(t,n(),e),{labels:i,datasets:a}=ih(t,r);return{chartJsConfig:{type:`calendar`,data:{labels:i,datasets:a},options:{...Sg,indexAxis:`x`,layout:$D(t,r),scales:Lm(t,a),plugins:{title:PO(t,e),legend:{display:!1},tooltip:zO(t,r),chartShowValuesPlugin:kO(t,r),chartColorScalePlugin:Rm(t,r),background:{color:r.background}}}}}}},PK={sequence:15,allowedDefinitionKeys:[...Rh.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`aggregated`,`axesDesign`,`showValues`,`hideDataMarkers`,`zoomable`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getDefinitionForExcel(e,t,{dataSets:n,labelRange:r}){return{...t,backgroundColor:lD(t.background||`#FFFFFF`),fontColor:lD(om(t.background)),dataSets:n,labelRange:r,verticalAxis:fm(t)}},getDefinitionFromContextCreation(e,t){let n=e.dataSetStyles??{};if(e.dataSource?.type===`range`){let t=e.dataSource?.dataSets?.[0]?.dataSetId;for(let r of e.dataSource?.dataSets||[])n[r.dataSetId]={...e.dataSetStyles?.[r.dataSetId]||{},type:r.dataSetId===t?`bar`:`line`}}return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:n,aggregated:e.aggregated,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`combo`,axesDesign:e.axesDesign,showValues:e.showValues,hideDataMarkers:e.hideDataMarkers,zoomable:e.zoomable,humanize:e.humanize,annotationText:e.annotationText,annotationLink:e.annotationLink}},getRuntime(e,t,{extractData:n},r,i){let a=gD(t,n(),e);return{chartJsConfig:{type:`bar`,data:{labels:a.labels,datasets:dh(t,a)},options:{...Sg,layout:QD(t,a),scales:Im(t,a),plugins:{title:PO(t,e),legend:vO(t,a),tooltip:RO(t,a),chartShowValuesPlugin:OO(t,a),background:{color:a.background}},...i}},customizableSeries:a.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},FK={sequence:100,dataSeriesLimit:1,allowedDefinitionKeys:[...Rh.commonKeys,`dataSource`,`dataSetStyles`,`axesDesign`,`legendPosition`,`horizontal`,`aggregated`,`showValues`,`funnelColors`,`cumulative`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},aggregated:e.aggregated??!1,legendPosition:`none`,title:e.title||{text:``},type:`funnel`,showValues:e.showValues,axesDesign:e.axesDesign,funnelColors:e.funnelColors,horizontal:!0,cumulative:e.cumulative??!0,humanize:e.humanize,annotationText:e.annotationText,annotationLink:e.annotationLink}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractData:n},r,i){let a=TD(t,n(),e);return{chartJsConfig:{type:`funnel`,data:{labels:a.labels,datasets:mh(t,a)},options:{...Sg,indexAxis:`y`,layout:QD(t,a),scales:Jm(t,a),plugins:{title:PO(t,e),legend:{display:!1},tooltip:qO(t,a),chartShowValuesPlugin:OO(t,a),background:{color:a.background}},...i}}}}},IK={sequence:90,dataSeriesLimit:1,allowedDefinitionKeys:[...Rh.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`colorScale`,`missingValueColor`,`region`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`geo`,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractData:n},r,i){let a=wD(t,n(),e);return{chartJsConfig:{type:`choropleth`,data:{datasets:ph(t,a)},options:{...Sg,layout:QD(t,a),scales:qm(t,a),plugins:{title:PO(t,e),tooltip:KO(t,a),legend:{display:!1},background:{color:a.background}},...i}}}}},LK={sequence:80,dataSeriesLimit:2,allowedDefinitionKeys:[...Rh.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showValues`,`aggregated`,`axesDesign`,`stacked`,`horizontal`],fromStrDefinition:e=>({...e,horizontal:!0,stacked:!0}),toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},aggregated:e.aggregated??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`pyramid`,axesDesign:e.axesDesign,horizontal:!0,stacked:!0,showValues:e.showValues,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel(e,t,{dataSets:n,labelRange:r}){if(t.dataSource.type!==`range`)return;let i=bD(t,yk(e,t.dataSource),e),{dataSetsValues:a}=i,o=Math.max(...a.map(e=>Math.max(...e.data.map(e=>tf(e)?Math.abs(e.value):-1/0))));return{...t,horizontal:!0,backgroundColor:lD(i.background||`#FFFFFF`),fontColor:lD(om(i.background)),dataSets:n,labelRange:r,verticalAxis:fm(t),maxValue:o}},getRuntime(e,t,{extractData:n},r,i){let a=bD(t,n(),e);return{chartJsConfig:{type:`bar`,data:{labels:a.labels,datasets:nh(t,a)},options:{...Sg,indexAxis:`y`,layout:QD(t,a),scales:Gm(t,a),plugins:{title:PO(t,e),legend:pO(t,a),tooltip:WO(t,a),chartShowValuesPlugin:jO(t,a),background:{color:a.background}},...i}},customizableSeries:a.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},RK={sequence:80,allowedDefinitionKeys:[...Rh.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showValues`,`aggregated`,`stacked`,`fillArea`,`hideDataMarkers`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},stacked:e.stacked??!1,aggregated:e.aggregated??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`radar`,fillArea:e.fillArea??!1,showValues:e.showValues??!1,hideDataMarkers:e.hideDataMarkers,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel(e,t,{dataSets:n,labelRange:r}){return{...t,backgroundColor:lD(t.background||`#FFFFFF`),fontColor:lD(om(t.background)),dataSets:n,labelRange:r}},getRuntime(e,t,{extractData:n},r,i){let a=CD(t,n(),e);return{chartJsConfig:{type:`radar`,data:{labels:a.labels,datasets:fh(t,a)},options:{...Sg,layout:QD(t,a),scales:Km(t,a),plugins:{title:PO(t,e),legend:bO(t,a),tooltip:GO(t,a),chartShowValuesPlugin:OO(t,a),background:{color:a.background}},...i}},customizableSeries:a.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},zK={sequence:60,allowedDefinitionKeys:[...Rh.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showValues`,`labelsAsText`,`aggregated`,`axesDesign`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getContextCreation:e=>e,getDefinitionFromContextCreation(e,t){return{background:e.background,dataSource:t.fromContextCreation(e),dataSetStyles:e.dataSetStyles??{},labelsAsText:e.labelsAsText??!1,legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`scatter`,aggregated:e.aggregated??!1,axesDesign:e.axesDesign,showValues:e.showValues,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},getDefinitionForExcel(e,t,{dataSets:n,labelRange:r}){return{...t,backgroundColor:lD(t.background||`#FFFFFF`),fontColor:lD(om(t.background)),dataSets:n,labelRange:r,verticalAxis:fm(t)}},getRuntime(e,t,{extractData:n},r,i){let a=xD(t,n(),e);return{chartJsConfig:{type:`line`,data:{labels:a.labels,datasets:sh(t,a)},options:{...Sg,layout:QD(t,a),scales:Hm(t,a),plugins:{title:PO(t,e),legend:gO(t,a),tooltip:BO(t,a),chartShowValuesPlugin:OO(t,a),background:{color:a.background}},...i}},customizableSeries:a.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},BK={sequence:30,allowedDefinitionKeys:[...Rh.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showValues`,`showLabels`,`valuesDesign`,`groupColors`,`pieHolePercentage`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getDefinitionFromContextCreation(e,t){return{background:e.background,dataSetStyles:e.dataSetStyles??{},dataSource:t.fromHierarchicalContextCreation(e),legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`sunburst`,showValues:e.showValues,showLabels:e.showLabels,valuesDesign:e.valuesDesign,groupColors:e.groupColors,humanize:e.humanize,pieHolePercentage:e.pieHolePercentage,annotationLink:e.annotationLink,annotationText:e.annotationText}},getContextCreation(e,t,n){return{...e,...t.getHierarchicalContextCreation(n)}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractHierarchicalData:n},r,i){let a=ED(t,n(),e);return{chartJsConfig:{type:`doughnut`,data:{datasets:gh(t,a)},options:{cutout:t.pieHolePercentage===void 0?`25%`:`${t.pieHolePercentage}%`,...Sg,layout:QD(t,a),plugins:{title:PO(t,e),legend:xO(t,a),tooltip:JO(t,a),sunburstLabelsPlugin:AO(t,a),sunburstHoverPlugin:{enabled:!0},background:{color:a.background}},...i}}}}},VK={sequence:100,allowedDefinitionKeys:[...Rh.commonKeys,`dataSource`,`legendPosition`,`dataSetStyles`,`showHeaders`,`headerDesign`,`showLabels`,`valuesDesign`,`coloringOptions`,`showValues`],fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,validateDefinition:()=>`Success`,updateRanges:e=>e,getDefinitionFromContextCreation(e,t){return{background:e.background,dataSetStyles:e.dataSetStyles??{},dataSource:t.fromHierarchicalContextCreation(e),legendPosition:e.legendPosition??`top`,title:e.title||{text:``},type:`treemap`,showValues:e.showValues,showHeaders:e.showHeaders,headerDesign:e.headerDesign,showLabels:e.showLabels,valuesDesign:e.valuesDesign,coloringOptions:e.treemapColoringOptions,humanize:e.humanize,annotationText:e.annotationText,annotationLink:e.annotationLink}},getContextCreation(e,t,n){return{...e,treemapColoringOptions:e.coloringOptions,...t.getHierarchicalContextCreation(n)}},getDefinitionForExcel:()=>void 0,getRuntime(e,t,{extractHierarchicalData:n},r,i){let a=ED(t,n(),e);return{chartJsConfig:{type:`treemap`,data:{labels:a.labels,datasets:xh(t,a)},options:{...Sg,layout:QD(t,a),plugins:{title:PO(t,e),legend:{display:!1},tooltip:YO(t,a),background:{color:a.background}},...i}}}}};wb.add(`bar`,$O),wb.add(`combo`,PK),wb.add(`line`,uk),wb.add(`pie`,dk),wb.add(`scorecard`,Jh),wb.add(`gauge`,ak),wb.add(`scatter`,zK),wb.add(`waterfall`,fk),wb.add(`pyramid`,LK),wb.add(`radar`,RK),wb.add(`geo`,IK),wb.add(`funnel`,FK),wb.add(`sunburst`,BK),wb.add(`treemap`,VK),wb.add(`calendar`,NK),wb.add(`bubble`,jK),Vg.add(`line`,{matcher:e=>e.type===`line`&&!e.stacked&&!e.fillArea,displayName:P(`Line`),chartType:`line`,chartSubtype:`line`,subtypeDefinition:{stacked:!1,fillArea:!1},category:`line`,preview:`o-spreadsheet-ChartPreview.LINE_CHART`}).add(`stacked_line`,{matcher:e=>e.type===`line`&&!e.fillArea&&!!e.stacked,displayName:P(`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=>e.type===`line`&&!e.stacked&&!!e.fillArea,displayName:P(`Area`),chartType:`line`,chartSubtype:`area`,subtypeDefinition:{stacked:!1,fillArea:!0},category:`area`,preview:`o-spreadsheet-ChartPreview.AREA_CHART`}).add(`stacked_area`,{matcher:e=>e.type===`line`&&e.stacked&&!!e.fillArea,displayName:P(`Stacked Area`),chartType:`line`,chartSubtype:`stacked_area`,subtypeDefinition:{stacked:!0,fillArea:!0},category:`area`,preview:`o-spreadsheet-ChartPreview.STACKED_AREA_CHART`}).add(`scatter`,{displayName:P(`Scatter`),chartType:`scatter`,chartSubtype:`scatter`,category:`misc`,preview:`o-spreadsheet-ChartPreview.SCATTER_CHART`}).add(`bubble`,{displayName:P(`Bubble`),chartType:`bubble`,chartSubtype:`bubble`,category:`misc`,preview:`o-spreadsheet-ChartPreview.BUBBLE_CHART`}).add(`column`,{matcher:e=>e.type===`bar`&&!e.stacked&&!e.horizontal,displayName:P(`Column`),chartType:`bar`,chartSubtype:`column`,subtypeDefinition:{stacked:!1,horizontal:!1},category:`column`,preview:`o-spreadsheet-ChartPreview.COLUMN_CHART`}).add(`stacked_column`,{matcher:e=>e.type===`bar`&&e.stacked&&!e.horizontal,displayName:P(`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=>e.type===`bar`&&!e.stacked&&!!e.horizontal,displayName:P(`Bar`),chartType:`bar`,chartSubtype:`bar`,subtypeDefinition:{horizontal:!0,stacked:!1},category:`bar`,preview:`o-spreadsheet-ChartPreview.BAR_CHART`}).add(`stacked_bar`,{matcher:e=>e.type===`bar`&&e.stacked&&!!e.horizontal,displayName:P(`Stacked Bar`),chartType:`bar`,chartSubtype:`stacked_bar`,subtypeDefinition:{horizontal:!0,stacked:!0},category:`bar`,preview:`o-spreadsheet-ChartPreview.STACKED_BAR_CHART`}).add(`combo`,{displayName:P(`Combo`),chartSubtype:`combo`,chartType:`combo`,category:`line`,preview:`o-spreadsheet-ChartPreview.COMBO_CHART`}).add(`pie`,{matcher:e=>e.type===`pie`&&!e.isDoughnut,displayName:P(`Pie`),chartSubtype:`pie`,chartType:`pie`,subtypeDefinition:{isDoughnut:!1},category:`pie`,preview:`o-spreadsheet-ChartPreview.PIE_CHART`}).add(`doughnut`,{matcher:e=>e.type===`pie`&&!!e.isDoughnut,displayName:P(`Doughnut`),chartSubtype:`doughnut`,chartType:`pie`,subtypeDefinition:{isDoughnut:!0},category:`pie`,preview:`o-spreadsheet-ChartPreview.DOUGHNUT_CHART`}).add(`gauge`,{displayName:P(`Gauge`),chartSubtype:`gauge`,chartType:`gauge`,category:`misc`,preview:`o-spreadsheet-ChartPreview.GAUGE_CHART`}).add(`scorecard`,{displayName:P(`Scorecard`),chartSubtype:`scorecard`,chartType:`scorecard`,category:`misc`,preview:`o-spreadsheet-ChartPreview.SCORECARD_CHART`}).add(`waterfall`,{displayName:P(`Waterfall`),chartSubtype:`waterfall`,chartType:`waterfall`,category:`misc`,preview:`o-spreadsheet-ChartPreview.WATERFALL_CHART`}).add(`pyramid`,{displayName:P(`Population Pyramid`),chartSubtype:`pyramid`,chartType:`pyramid`,category:`misc`,preview:`o-spreadsheet-ChartPreview.POPULATION_PYRAMID_CHART`}).add(`radar`,{matcher:e=>e.type===`radar`&&!e.fillArea,displayName:P(`Radar`),chartSubtype:`radar`,chartType:`radar`,subtypeDefinition:{fillArea:!1},category:`misc`,preview:`o-spreadsheet-ChartPreview.RADAR_CHART`}).add(`filled_radar`,{matcher:e=>e.type===`radar`&&!!e.fillArea,displayName:P(`Filled Radar`),chartType:`radar`,chartSubtype:`filled_radar`,subtypeDefinition:{fillArea:!0},category:`misc`,preview:`o-spreadsheet-ChartPreview.FILLED_RADAR_CHART`}).add(`geo`,{displayName:P(`Geo Chart`),chartSubtype:`geo`,chartType:`geo`,category:`misc`,preview:`o-spreadsheet-ChartPreview.GEO_CHART`}).add(`funnel`,{displayName:P(`Funnel`),chartSubtype:`funnel`,chartType:`funnel`,category:`misc`,preview:`o-spreadsheet-ChartPreview.FUNNEL_CHART`}).add(`sunburst`,{matcher:e=>e.type===`sunburst`,displayName:P(`Sunburst`),chartSubtype:`sunburst`,chartType:`sunburst`,category:`hierarchical`,preview:`o-spreadsheet-ChartPreview.SUNBURST_CHART`}).add(`treemap`,{matcher:e=>e.type===`treemap`,displayName:P(`Tree Map`),chartType:`treemap`,chartSubtype:`treemap`,category:`hierarchical`,preview:`o-spreadsheet-ChartPreview.TREE_MAP_CHART`}).add(`calendar`,{displayName:P(`Calendar`),chartSubtype:`calendar`,chartType:`calendar`,category:`misc`,preview:`o-spreadsheet-ChartPreview.CALENDAR_CHART`}),Nz.add(`filter_icon`,(e,t)=>{if(e.isFilterHeader(t)){let n=e.isFilterActive(t),r=ep(e.getCellComputedStyle(t).fillColor||`#fff`)<.45;return{type:`filter_icon`,svg:Ny(n,r,!1),hoverSvg:Ny(n,r,!0),priority:3,horizontalAlign:`right`,size:17,margin:2,position:t,onClick:(e,t)=>{let n=t.getStore(cw),r=n.persistentCellPopover;if(r.isOpen&&r.col===e.col&&r.row===e.row&&r.type===`FilterMenu`){n.close();return}n.open(e,`FilterMenu`)}}}});var HK=l({ARRAYTOTEXT:()=>_q,ARRAY_CONSTRAIN:()=>GK,ARRAY_LITERAL:()=>KK,ARRAY_ROW:()=>qK,CHOOSECOLS:()=>JK,CHOOSEROWS:()=>YK,EXPAND:()=>XK,FLATTEN:()=>ZK,FREQUENCY:()=>QK,HSTACK:()=>$K,MDETERM:()=>eq,MINVERSE:()=>tq,MMULT:()=>nq,SUMPRODUCT:()=>rq,SUMX2MY2:()=>aq,SUMX2PY2:()=>oq,SUMXMY2:()=>sq,TOCOL:()=>uq,TOROW:()=>dq,TRANSPOSE:()=>fq,VSTACK:()=>pq,WRAPCOLS:()=>mq,WRAPROWS:()=>hq});function UK(e,t){let n=e.map(B),r=n.map(e=>e?.[0]?.length??0),i=Math.max(...r);if(t?.requireSameRowCount){let e=r[0];if(r.some(t=>t!==e))return new I(P(`All ranges in [[FUNCTION_NAME]] must have the same number of rows (got %s).`,r.join(`, `)))}let a=[];for(let e of n)for(let t=0;t<e.length;t++){let n=Array(i).fill({value:null});for(let r=0;r<e[t].length;r++)n[r]=e[t][r];a.push(n)}return a}function WK(e,t){let n=e.map(B),r=n.map(e=>e?.length??0),i=Math.max(...r);if(t?.requireSameColCount){let e=r[0];if(r.some(t=>t!==e))return new I(P(`All ranges in [[FUNCTION_NAME]] must have the same number of columns (got %s).`,r.join(`, `)))}let a=ns(i,n.reduce((e,t)=>e+(t?.[0]?.length??0),0),()=>({value:null})),o=0;for(let e of n){for(let t=0;t<e.length;t++)for(let n=0;n<e[t].length;n++)a[t][o+n]=e[t][n];o+=e[0]?.length??0}return a}let GK={description:P(`Returns a result array constrained to a specific width and height.`),args:[U(`input_range (any, range<any>)`,P(`The range to constrain.`)),U(`rows (number)`,P(`The number of rows in the constrained array.`)),U(`columns (number)`,P(`The number of columns in the constrained array.`))],compute:function(e,t,n){let r=B(e),i=Ho(t?.value,this.locale),a=Ho(n?.value,this.locale);if(i<=0)return new I(P(`The rows argument (%s) must be strictly positive.`,i.toString()));if(a<=0)return new I(P(`The columns argument (%s) must be strictly positive.`,a.toString()));let o=Math.min(i,r[0].length);return ns(Math.min(a,r.length),o,(e,t)=>r[e][t])},isExported:!1},KK={description:P(`Appends ranges vertically and in sequence to return a larger array. All ranges must have the same number of columns.`),args:[U(`range (any, range<any>, repeating)`,P(`The range to be appended.`))],compute:function(...e){return WK(e,{requireSameColCount:!0})},isExported:!1,hidden:!0},qK={description:P(`Appends ranges horizontally and in sequence to return a larger array. All ranges must have the same number of rows.`),args:[U(`range (any, range<any>, repeating)`,P(`The range to be appended.`))],compute:function(...e){return UK(e,{requireSameRowCount:!0})},isExported:!1,hidden:!0},JK={description:P(`Creates a new array from the selected columns in the existing range.`),args:[U(`array (any, range<any>)`,P(`The array that contains the columns to be returned.`)),U(`col_num (number, range<number>, repeating)`,P(`The column index of the column to be returned.`))],compute:function(e,...t){let n=B(e),r=_s(t,e=>Ho(e?.value,this.locale)),i=r.filter(e=>e===0||n.length<Math.abs(e));if(i.length!==0)return new I(P(`The columns arguments must be between -%s and %s (got %s), excluding 0.`,n.length.toString(),n.length.toString(),i.join(`,`)));let a=Array(r.length);for(let e=0;e<r.length;e++)r[e]>0?a[e]=n[r[e]-1]:a[e]=n[n.length+r[e]];return a},isExported:!0},YK={description:P(`Creates a new array from the selected rows in the existing range.`),args:[U(`array (any, range<any>)`,P(`The array that contains the rows to be returned.`)),U(`row_num (number, range<number>, repeating)`,P(`The row index of the row to be returned.`))],compute:function(e,...t){let n=B(e),r=_s(t,e=>Ho(e?.value,this.locale)),i=n.length,a=r.filter(e=>e===0||n[0].length<Math.abs(e));return a.length===0?ns(i,r.length,(e,t)=>r[t]>0?n[e][r[t]-1]:n[e][n[e].length+r[t]]):new I(P(`The rows arguments must be between -%s and %s (got %s), excluding 0.`,n[0].length.toString(),n[0].length.toString(),a.join(`,`)))},isExported:!0},XK={description:P(`Expands or pads an array to specified row and column dimensions.`),args:[U(`array (any, range<any>)`,P(`The array to expand.`)),U(`rows (number)`,P(`The number of rows in the expanded array. If missing, rows will not be expanded.`)),U(`columns (number, optional)`,P(`The number of columns in the expanded array. If missing, columns will not be expanded.`)),U(`pad_with (any, default=0)`,P(`The value with which to pad.`))],compute:function(e,t,n,r={value:0}){let i=B(e),a=Ho(t?.value,this.locale),o=n===void 0?i.length:Ho(n.value,this.locale);return a<i[0].length?new I(P(`The rows arguments (%s) must be greater or equal than the number of rows of the array.`,a.toString())):o<i.length?new I(P(`The columns arguments (%s) must be greater or equal than the number of columns of the array.`,o.toString())):ns(o,a,(e,t)=>e>=i.length||t>=i[e].length?r:i[e][t])},isExported:!0},ZK={description:P(`Flattens all the values from one or more ranges into a single column.`),args:[U(`range (any, range<any>, repeating)`,P(`The range to flatten.`))],compute:function(...e){return[_s(e,e=>e===void 0?{value:``}:e)]},isExported:!1},QK={description:P(`Calculates the frequency distribution of a range.`),args:[U(`data (range<number>)`,P(`The array of ranges containing the values to be counted.`)),U(`classes (number, range<number>)`,P(`The range containing the set of classes.`))],compute:function(e,t){let n=_s([e],e=>e.value).filter(e=>typeof e==`number`),r=_s([t],e=>e.value).filter(e=>typeof e==`number`).map((e,t)=>({initialIndex:t,value:e,count:0})).sort((e,t)=>e.value-t.value);r.push({initialIndex:r.length,value:1/0,count:0});let i=n.sort((e,t)=>e-t),a=0;for(let e of i){for(;e>r[a].value&&a<r.length-1;)a++;r[a].count++}return[r.sort((e,t)=>e.initialIndex-t.initialIndex).map(e=>e.count)]},isExported:!0},$K={description:P(`Appends ranges horizontally and in sequence to return a larger array.`),args:[U(`range (any, range<any>, repeating)`,P(`The range to be appended.`))],compute:function(...e){return UK(e)},isExported:!0},eq={description:P(`Returns the matrix determinant of a square matrix.`),args:[U(`square_matrix (number, range<number>)`,P(`An range with an equal number of rows and columns representing a matrix whose determinant will be calculated.`))],compute:function(e){let t=Bo(e,`square_matrix`);return uS(t)?pS(t).determinant:new I(P(`The argument square_matrix must have the same number of columns and rows.`))},isExported:!0},tq={description:P(`Returns the multiplicative inverse of a square matrix.`),args:[U(`square_matrix (number, range<number>)`,P(`An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated.`))],compute:function(e){let t=Bo(e,`square_matrix`);if(!uS(t))return new I(P(`The argument square_matrix must have the same number of columns and rows.`));let{inverted:n}=pS(t);return n||new I(P(`The matrix is not invertible.`))},isExported:!0},nq={description:P(`Calculates the matrix product of two matrices.`),args:[U(`matrix1 (number, range<number>)`,P(`The first matrix in the matrix multiplication operation.`)),U(`matrix2 (number, range<number>)`,P(`The second matrix in the matrix multiplication operation.`))],compute:function(e,t){let n=Bo(e,`matrix1`),r=Bo(t,`matrix2`);return n.length===0||r.length===0?new I(P(`The first and second arguments of [[FUNCTION_NAME]] must be non-empty matrices.`)):n.length===r[0].length?hS(n,r):new I(P(`In [[FUNCTION_NAME]], the number of columns of the first matrix (%s) must be equal to the number of rows of the second matrix (%s).`,n.length.toString(),r[0].length.toString()))},isExported:!0},rq={description:P(`Calculates the sum of the products of corresponding entries in equal-sized ranges.`),args:[U(`range (number, range<number>, repeating)`,P(`The range whose entries will be multiplied with corresponding entries in the other range.`))],compute:function(...e){if(!lS(...e))return new I(P(`All the ranges must have the same dimensions.`));let t=e.map(B),n=0;for(let e=0;e<t[0].length;e++)for(let r=0;r<t[0][e].length;r++){if(!t.every(t=>typeof t[e][r].value==`number`))continue;let i=1;for(let n of t)i*=L(n[e][r],this.locale);n+=i}return n},isExported:!0};function iq(e,t,n){if(!lS(e,t))return new I(P(`The arguments array_x and array_y must have the same dimensions.`));let r=B(e),i=B(t),a=!1,o=0;for(let e in r)for(let t in r[e]){let s=r[e][t].value,c=i[e][t].value;typeof s!=`number`||typeof c!=`number`||(a=!0,o+=n(s,c))}return a?o:new I(P(`The arguments array_x and array_y must contain at least one pair of numbers.`))}let aq={description:P(`Calculates the sum of the difference of the squares of the values in two array.`),args:[U(`array_x (number, range<number>)`,P(`The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.`)),U(`array_y (number, range<number>)`,P(`The array or range of values whose squares will be subtracted from the squares of corresponding entries in array_x and added together.`))],compute:function(e,t){return iq(e,t,(e,t)=>e**2-t**2)},isExported:!0},oq={description:P(`Calculates the sum of the sum of the squares of the values in two array.`),args:[U(`array_x (number, range<number>)`,P(`The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.`)),U(`array_y (number, range<number>)`,P(`The array or range of values whose squares will be added to the squares of corresponding entries in array_x and added together.`))],compute:function(e,t){return iq(e,t,(e,t)=>e**2+t**2)},isExported:!0},sq={description:P(`Calculates the sum of squares of the differences of values in two array.`),args:[U(`array_x (number, range<number>)`,P(`The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.`)),U(`array_y (number, range<number>)`,P(`The array or range of values that will be subtracted from corresponding entries in array_x, the result squared, and all such results added together.`))],compute:function(e,t){return iq(e,t,(e,t)=>(e-t)**2)},isExported:!0},cq=[U(`array (any, range<any>)`,P(`The array which will be transformed.`)),U(`ignore (number, default=0)`,P(`Whether to ignore certain types of values. By default, no values are ignored.`),[{value:0,label:P(`Keep all values (default)`)},{value:1,label:P(`Ignore blanks`)},{value:2,label:P(`Ignore errors`)},{value:3,label:P(`Ignore blanks and errors`)}]),U(`scan_by_column (number, default=false)`,P(`Scan the array by column. By default, the array is scanned by row.`),[{value:!1,label:P(`Scan by row (default)`)},{value:!0,label:P(`Scan by column`)}])];function lq(e){let t=Math.trunc(e);if(t===0)return()=>!0;if(t===1)return e=>e.value!==null;if(t===2)return e=>!No(e.value);if(t===3)return e=>e.value!==null&&!No(e.value);throw new I(P(`Argument ignore must be between 0 and 3`))}let uq={description:P(`Transforms a range of cells into a single column.`),args:cq,compute:function(e,t={value:0},n={value:!1}){let r=B(e),i=L(t.value,this.locale),a=(z(n.value)?r:as(r)).flat().filter(lq(i));return a.length===0?new Eo(P(`No results for the given arguments of TOCOL.`)):[a]},isExported:!0},dq={description:P(`Transforms a range of cells into a single row.`),args:cq,compute:function(e,t={value:0},n={value:!1}){let r=B(e),i=L(t.value,this.locale),a=(z(n.value)?r:as(r)).flat().filter(lq(i)).map(e=>[e]);return a.length===0||a[0].length===0?new Eo(P(`No results for the given arguments of TOROW.`)):a},isExported:!0},fq={description:P(`Transposes the rows and columns of a range.`),args:[U(`range (any, range<any>)`,P(`The range to be transposed.`))],compute:function(e){let t=B(e),n=t[0].length,r=t.length;return ns(n,r,(e,n)=>t[n][e])},isExported:!0},pq={description:P(`Appends ranges vertically and in sequence to return a larger array.`),args:[U(`range (any, range<any>, repeating)`,P(`The range to be appended.`))],compute:function(...e){return WK(e)},isExported:!0},mq={description:P(`Wraps the provided row or column of cells by columns after a specified number of elements to form a new array.`),args:[U(`range (any, range<any>)`,P(`The range to wrap.`)),U(`wrap_count (number)`,P(`The maximum number of cells for each column, rounded down to the nearest whole number.`)),U(`pad_with (any, default=0)`,P(`The value with which to fill the extra cells in the range.`))],compute:function(e,t,n={value:0}){let r=B(e),i=Ho(t?.value,this.locale);if(!cS(r))return new I(P(`Argument range must be a single row or column.`));if(i<1)return new I(P(`The wrap_count (%s) must be strictly positive.`,i),F.InvalidNumber);let a=r.flat();return ns(Math.ceil(a.length/i),i,(e,t)=>{let r=e*i+t;return r<a.length?a[r]:n})},isExported:!0},hq={description:P(`Wraps the provided row or column of cells by rows after a specified number of elements to form a new array.`),args:[U(`range (any, range<any>)`,P(`The range to wrap.`)),U(`wrap_count (number)`,P(`The maximum number of cells for each row, rounded down to the nearest whole number.`)),U(`pad_with (any, default=0)`,P(`The value with which to fill the extra cells in the range.`))],compute:function(e,t,n={value:0}){let r=B(e),i=Ho(t?.value,this.locale);if(!cS(r))return new I(P(`Argument range must be a single row or column.`));if(i<1)return new I(P(`The wrap_count (%s) must be strictly positive.`,i),F.InvalidNumber);let a=r.flat();return ns(i,Math.ceil(a.length/i),(e,t)=>{let r=t*i+e;return r<a.length?a[r]:n})},isExported:!0},gq=[{value:0,label:P(`Concise format\xA0(default)`)},{value:1,label:P(`Strict format`)}],_q={description:P(`returns an array of text values from any specified range. It passes text values unchanged, and converts non-text values to text.`),args:[U(`array (range)`,P(`The array to convert into text`)),U(`format (number, default=0)`,P(`The format of the returned data.`),gq)],compute:function(e,t={value:0}){let n=L(t,this.locale),r=B(e);if(n===1)return Qk(r,``,this.locale);if(n===0){let e=this.locale.decimalSeparator===`,`?`/`:`,`;return as(r).flatMap(e=>e.map(e=>No(e.value)?e.value:R(e))).join(e)}else return new I(P(`Format must be 0 or 1`))},isExported:!0};var vq=l({ABS:()=>bq,ACOS:()=>xq,ACOSH:()=>Sq,ACOT:()=>Cq,ACOTH:()=>wq,ASIN:()=>Tq,ASINH:()=>Eq,ATAN:()=>Dq,ATAN2:()=>Oq,ATANH:()=>kq,CEILING:()=>Aq,CEILING_MATH:()=>Mq,CEILING_PRECISE:()=>Nq,COS:()=>Pq,COSH:()=>Fq,COT:()=>Iq,COTH:()=>Lq,COUNTBLANK:()=>Rq,COUNTIF:()=>zq,COUNTIFS:()=>Bq,COUNTUNIQUE:()=>Vq,COUNTUNIQUEIFS:()=>Hq,CSC:()=>Uq,CSCH:()=>Wq,DECIMAL:()=>Gq,DEGREES:()=>Kq,EXP:()=>qq,FLOOR:()=>Jq,FLOOR_MATH:()=>Xq,FLOOR_PRECISE:()=>Zq,INT:()=>NJ,ISEVEN:()=>Qq,ISODD:()=>eJ,ISO_CEILING:()=>$q,LN:()=>tJ,LOG:()=>nJ,MOD:()=>iJ,MUNIT:()=>aJ,ODD:()=>oJ,PI:()=>sJ,POWER:()=>cJ,PRODUCT:()=>lJ,RAND:()=>uJ,RANDARRAY:()=>dJ,RANDBETWEEN:()=>fJ,ROUND:()=>pJ,ROUNDDOWN:()=>mJ,ROUNDUP:()=>hJ,SEC:()=>gJ,SECH:()=>_J,SEQUENCE:()=>vJ,SIN:()=>yJ,SINH:()=>bJ,SQRT:()=>xJ,SUBTOTAL:()=>TJ,SUM:()=>EJ,SUMIF:()=>DJ,SUMIFS:()=>OJ,TAN:()=>kJ,TANH:()=>AJ,TRUNC:()=>MJ});let yq=/^-?[a-z0-9]+$/i,bq={description:P(`Absolute value of a number.`),args:[U(`value (number)`,P(`The number of which to return the absolute value.`))],compute:function(e){return Math.abs(L(e,this.locale))},isExported:!0},xq={description:P(`Inverse cosine of a value, in radians.`),args:[U(`value (number)`,P(`The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.`))],compute:function(e){let t=L(e,this.locale);return Math.abs(t)>1?new I(P(`The value (%s) must be between -1 and 1 inclusive.`,t)):Math.acos(t)},isExported:!0},Sq={description:P(`Inverse hyperbolic cosine of a number.`),args:[U(`value (number)`,P(`The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.`))],compute:function(e){let t=L(e,this.locale);return t<1?new I(P(`The value (%s) must be greater than or equal to 1.`,t)):Math.acosh(t)},isExported:!0},Cq={description:P(`Inverse cotangent of a value.`),args:[U(`value (number)`,P(`The value for which to calculate the inverse cotangent.`))],compute:function(e){let t=L(e,this.locale);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},wq={description:P(`Inverse hyperbolic cotangent of a value.`),args:[U(`value (number)`,P(`The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.`))],compute:function(e){let t=L(e,this.locale);return Math.abs(t)<=1?new I(P(`The value (%s) cannot be between -1 and 1 inclusive.`,t)):Math.log((t+1)/(t-1))/2},isExported:!0},Tq={description:P(`Inverse sine of a value, in radians.`),args:[U(`value (number)`,P(`The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.`))],compute:function(e){let t=L(e,this.locale);return Math.abs(t)>1?new I(P(`The value (%s) must be between -1 and 1 inclusive.`,t)):Math.asin(t)},isExported:!0},Eq={description:P(`Inverse hyperbolic sine of a number.`),args:[U(`value (number)`,P(`The value for which to calculate the inverse hyperbolic sine.`))],compute:function(e){return Math.asinh(L(e,this.locale))},isExported:!0},Dq={description:P(`Inverse tangent of a value, in radians.`),args:[U(`value (number)`,P(`The value for which to calculate the inverse tangent.`))],compute:function(e){return Math.atan(L(e,this.locale))},isExported:!0},Oq={description:P(`Angle from the X axis to a point (x,y), in radians.`),args:[U(`x (number)`,P(`The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.`)),U(`y (number)`,P(`The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.`))],compute:function(e,t){let n=L(e,this.locale),r=L(t,this.locale);return n===0&&r===0?new ko(P(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):Math.atan2(r,n)},isExported:!0},kq={description:P(`Inverse hyperbolic tangent of a number.`),args:[U(`value (number)`,P(`The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.`))],compute:function(e){let t=L(e,this.locale);return Math.abs(t)>=1?new I(P(`The value (%s) must be between -1 and 1 exclusive.`,t)):Math.atanh(t)},isExported:!0},Aq={description:P(`Rounds number up to nearest multiple of factor.`),args:[U(`value (number)`,P(`The value to round up to the nearest integer multiple of factor.`)),U(`factor (number, default=1)`,P(`The number to whose multiples value will be rounded.`))],compute:function(e,t={value:1}){let n=L(e,this.locale),r=L(t,this.locale);return r<0&&n>0?new I(P(`The factor (%s) must be positive when the value (%s) is positive.`,r,n)):{value:r?Math.ceil(n/r)*r:0,format:e?.format}},isExported:!0};function jq(e,t,n=0){return t===0?0:(t=Math.abs(t),e>=0?Math.ceil(e/t)*t:n===0?-Math.floor(Math.abs(e)/t)*t:-Math.ceil(Math.abs(e)/t)*t)}let Mq={description:P(`Rounds number up to nearest multiple of factor.`),args:[U(`number (number)`,P(`The value to round up to the nearest integer multiple of significance.`)),U(`significance (number, default=1)`,P(`The number to whose multiples number will be rounded. The sign of significance will be ignored.`)),U(`mode (number, default=0)`,P(`If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero.`))],compute:function(e,t={value:1},n={value:0}){let r=L(t,this.locale);return{value:jq(L(e,this.locale),r,L(n,this.locale)),format:e?.format}},isExported:!0},Nq={description:P(`Rounds number up to nearest multiple of factor.`),args:[U(`number (number)`,P(`The value to round up to the nearest integer multiple of significance.`)),U(`significance (number, default=1)`,P(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){let n=L(t,this.locale);return{value:jq(L(e,this.locale),n),format:e?.format}},isExported:!0},Pq={description:P(`Cosine of an angle provided in radians.`),args:[U(`angle (number)`,P(`The angle to find the cosine of, in radians.`))],compute:function(e){return Math.cos(L(e,this.locale))},isExported:!0},Fq={description:P(`Hyperbolic cosine of any real number.`),args:[U(`value (number)`,P(`Any real value to calculate the hyperbolic cosine of.`))],compute:function(e){return Math.cosh(L(e,this.locale))},isExported:!0},Iq={description:P(`Cotangent of an angle provided in radians.`),args:[U(`angle (number)`,P(`The angle to find the cotangent of, in radians.`))],compute:function(e){let t=L(e,this.locale);return t===0?new ko(P(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):1/Math.tan(t)},isExported:!0},Lq={description:P(`Hyperbolic cotangent of any real number.`),args:[U(`value (number)`,P(`Any real value to calculate the hyperbolic cotangent of.`))],compute:function(e){let t=L(e,this.locale);return t===0?new ko(P(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):1/Math.tanh(t)},isExported:!0},Rq={description:P(`Number of empty values.`),args:[U(`value (any, range, repeating)`,P(`Value or range in which to count the number of blanks.`))],compute:function(...e){return $o(e,(e,t)=>t===void 0||t.value===null||t.value===``?e+1:e,0)},isExported:!0},zq={description:P(`A conditional count across a range.`),args:[U(`range (range)`,P(`The range that is tested against criterion.`)),U(`criterion (string)`,P(`The pattern or test to apply to range.`))],compute:function(...e){let t=0;return ds(e,(e,n)=>{t+=1},this.locale),t},isExported:!0},Bq={description:P(`Count values depending on multiple criteria.`),args:[U(`criteria_range (any, range, repeating)`,P(`Range over which to evaluate criteria.`)),U(`criterion (string, repeating)`,P(`Criteria to check.`))],compute:function(...e){let t=0;return ds(e,(e,n)=>{t+=1},this.locale),t},isExported:!0},Vq={description:P(`Counts number of unique values in a range.`),args:[U(`value (any, range, repeating)`,P(`Value or range to consider for uniqueness.`))],compute:function(...e){return aS(e)}},Hq={description:P(`Counts number of unique values in a range, filtered by a set of criteria.`),args:[U(`range (range)`,P(`The range of cells from which the number of unique values will be counted.`)),U(`criteria_range (any, range, repeating)`,P(`Range over which to evaluate criteria.`)),U(`criterion (string, repeating)`,P(`Criteria to check.`))],compute:function(e,...t){let n=new Set;return ds(t,(t,r)=>{let i=e[t]?.[r];vs(i)&&n.add(i.value)},this.locale),n.size}},Uq={description:P(`Cosecant of an angle provided in radians.`),args:[U(`angle (number)`,P(`The angle to find the cosecant of, in radians.`))],compute:function(e){let t=L(e,this.locale);return t===0?new ko(P(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):1/Math.sin(t)},isExported:!0},Wq={description:P(`Hyperbolic cosecant of any real number.`),args:[U(`value (number)`,P(`Any real value to calculate the hyperbolic cosecant of.`))],compute:function(e){let t=L(e,this.locale);return t===0?new ko(P(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):1/Math.sinh(t)},isExported:!0},Gq={description:P(`Converts from another base to decimal.`),args:[U(`value (string)`,P(`The number to convert.`)),U(`base (number)`,P(`The base to convert the value from.`))],compute:function(e,t){let n=L(t,this.locale);if(n=Math.floor(n),2>n||n>36)return new I(P(`The base (%s) must be between 2 and 36 inclusive.`,n));let r=R(e);if(r===``)return 0;if(!yq.test(r))return new I(P(`The value (%s) must be a valid base %s representation.`,r,n));let i=r.replace(`-`,``);for(let e of i)if(parseInt(e,36)>=n)return new I(P(`The value (%s) must be a valid base %s representation.`,r,n));let a=parseInt(r,n);return isNaN(a)?new I(P(`The value (%s) must be a valid base %s representation.`,r,n)):a},isExported:!0},Kq={description:P(`Converts an angle value in radians to degrees.`),args:[U(`angle (number)`,P(`The angle to convert from radians to degrees.`))],compute:function(e){return L(e,this.locale)*180/Math.PI},isExported:!0},qq={description:P(`Euler's number, e (~2.718) raised to a power.`),args:[U(`value (number)`,P(`The exponent to raise e.`))],compute:function(e){return Math.exp(L(e,this.locale))},isExported:!0},Jq={description:P(`Rounds number down to nearest multiple of factor.`),args:[U(`value (number)`,P(`The value to round down to the nearest integer multiple of factor.`)),U(`factor (number, default=1)`,P(`The number to whose multiples value will be rounded.`))],compute:function(e,t={value:1}){let n=L(e,this.locale),r=L(t,this.locale);return r<0&&n>0?new I(P(`The factor (%s) must be positive when the value (%s) is positive.`,r,n)):{value:r?Math.floor(n/r)*r:0,format:e?.format}},isExported:!0};function Yq(e,t,n=0){return t===0?0:(t=Math.abs(t),e>=0?Math.floor(e/t)*t:n===0?-Math.ceil(Math.abs(e)/t)*t:-Math.floor(Math.abs(e)/t)*t)}let Xq={description:P(`Rounds number down to nearest multiple of factor.`),args:[U(`number (number)`,P(`The value to round down to the nearest integer multiple of significance.`)),U(`significance (number, default=1)`,P(`The number to whose multiples number will be rounded. The sign of significance will be ignored.`)),U(`mode (number, default=0)`,P(`If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero.`))],compute:function(e,t={value:1},n={value:0}){let r=L(t,this.locale);return{value:Yq(L(e,this.locale),r,L(n,this.locale)),format:e?.format}},isExported:!0},Zq={description:P(`Rounds number down to nearest multiple of factor.`),args:[U(`number (number)`,P(`The value to round down to the nearest integer multiple of significance.`)),U(`significance (number, default=1)`,P(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){let n=L(t,this.locale);return{value:Yq(L(e,this.locale),n),format:e?.format}},isExported:!0},Qq={description:P(`Whether the provided value is even.`),args:[U(`value (number)`,P(`The value to be verified as even.`))],compute:function(e){let t=Vo(e,this.locale);return!(Math.floor(Math.abs(t))&1)},isExported:!0},$q={description:P(`Rounds number up to nearest multiple of factor.`),args:[U(`number (number)`,P(`The value to round up to the nearest integer multiple of significance.`)),U(`significance (number, default=1)`,P(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){return{value:jq(L(e,this.locale),L(t,this.locale)),format:e?.format}},isExported:!0},eJ={description:P(`Whether the provided value is even.`),args:[U(`value (number)`,P(`The value to be verified as even.`))],compute:function(e){let t=Vo(e,this.locale);return!!(Math.floor(Math.abs(t))&1)},isExported:!0},tJ={description:P(`The logarithm of a number, base e (euler's number).`),args:[U(`value (number)`,P(`The value for which to calculate the logarithm, base e.`))],compute:function(e){let t=L(e,this.locale);return t<=0?new I(P(`The value (%s) must be strictly positive.`,t)):Math.log(t)},isExported:!0},nJ={description:P(`The logarithm of a number, for a given base.`),args:[U(`value (number)`,P(`The value for which to calculate the logarithm.`)),U(`base (number, default=10)`,P(`The base of the logarithm.`))],compute:function(e,t={value:10}){let n=L(e,this.locale),r=L(t,this.locale);return n<=0?new I(P(`The value (%s) must be strictly positive.`,n)):r<=0?new I(P(`The base (%s) must be strictly positive.`,r)):r===1?new I(P(`The base must be different from 1.`)):Math.log10(n)/Math.log10(r)},isExported:!0};function rJ(e,t){sS(t,P(`The divisor must be different from 0.`));let n=e%t;return n>0&&t<0||n<0&&t>0?n+t:n}let iJ={description:P(`Modulo (remainder) operator.`),args:[U(`dividend (number)`,P(`The number to be divided to find the remainder.`)),U(`divisor (number)`,P(`The number to divide by.`))],compute:function(e,t){let n=L(t,this.locale);return{value:rJ(L(e,this.locale),n),format:e?.format}},isExported:!0},aJ={description:P(`Returns a n x n unit matrix, where n is the input dimension.`),args:[U(`dimension (number)`,P(`An integer specifying the dimension size of the unit matrix. It must be positive.`))],compute:function(e){let t=Ho(e,this.locale);return t<1?new I(P(`The argument dimension must be positive`)):fS(t)},isExported:!0},oJ={description:P(`Rounds a number up to the nearest odd integer.`),args:[U(`value (number)`,P(`The value to round to the next greatest odd number.`))],compute:function(e){let t=L(e,this.locale),n=Math.ceil(Math.abs(t));return n=n&1?n:n+1,{value:t<0?-n:n,format:e?.format}},isExported:!0},sJ={description:P(`The number pi.`),args:[],compute:function(){return Math.PI},isExported:!0},cJ={description:P(`A number raised to a power.`),args:[U(`base (number)`,P(`The number to raise to the exponent power.`)),U(`exponent (number)`,P(`The exponent to raise base to.`))],compute:function(e,t){let n=L(e,this.locale),r=L(t,this.locale);return n<0&&!Number.isInteger(r)?new I(P(`The exponent (%s) must be an integer when the base is negative.`,r)):{value:n**+r,format:e?.format}},isExported:!0},lJ={description:P(`Result of multiplying a series of numbers together.`),args:[U(`factor (number, range<number>, repeating)`,P(`Number or range to calculate for the product.`))],compute:function(...e){let t=0,n=1;for(let r of e)if(ht(r))for(let e of r)for(let r of e){let e=r.value;if(typeof e==`number`&&(n*=e,t+=1),No(e))return r}else r!==void 0&&r.value!==null&&(n*=Vo(r,this.locale),t+=1);return{value:t===0?0:n,format:Mo(e[0])}},isExported:!0},uJ={description:P(`A random number between 0 inclusive and 1 exclusive.`),args:[],compute:function(){return Math.random()},isExported:!0},dJ={description:P(`Returns a grid of random numbers between 0 inclusive and 1 exclusive.`),args:[U(`rows (number, default=1)`,P(`The number of rows to be returned.`)),U(`columns (number, default=1)`,P(`The number of columns to be returned.`)),U(`min (number, default=0)`,P(`The minimum number you would like returned.`)),U(`max (number, default=1)`,P(`The maximum number you would like returned.`)),U(`whole_number (boolean, default=FALSE)`,P(`Return a whole number or a decimal value.`),[{value:!1,label:P(`Decimal (default)`)},{value:!0,label:P(`Integer`)}])],compute:function(e={value:1},t={value:1},n={value:0},r={value:1},i={value:!1}){let a=Ho(t,this.locale),o=Ho(e,this.locale),s=L(n,this.locale),c=L(r,this.locale),l=z(i);if(a<1)return new I(P(`The number of columns (%s) must be positive.`,a));if(o<1)return new I(P(`The number of rows (%s) must be positive.`,o));if(s>c)return new I(P(`The maximum (%s) must be greater than or equal to the minimum (%s).`,c,s));if(l&&(!Number.isInteger(s)||!Number.isInteger(c)))return new I(P(`The maximum (%s) and minimum (%s) must be integers when whole_number is TRUE.`,c.toString(),s.toString()));let u=Array(a);for(let e=0;e<a;e++){u[e]=Array(o);for(let t=0;t<o;t++)l?u[e][t]=Math.floor(Math.random()*(c-s+1)+s):u[e][t]=s+Math.random()*(c-s)}return u},isExported:!0},fJ={description:P(`Random integer between two values, inclusive.`),args:[U(`low (number)`,P(`The low end of the random range.`)),U(`high (number)`,P(`The high end of the random range.`))],compute:function(e,t){let n=L(e,this.locale);Number.isInteger(n)||(n=Math.ceil(n));let r=L(t,this.locale);return Number.isInteger(r)||(r=Math.floor(r)),n>r?new I(P(`The high (%s) must be greater than or equal to the low (%s).`,r,n)):{value:n+Math.floor((r-n+1)*Math.random()),format:e?.format}},isExported:!0},pJ={description:P(`Rounds a number according to standard rules.`),args:[U(`value (number)`,P(`The value to round to places number of places.`)),U(`places (number, default=0)`,P(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=L(e,this.locale),r=L(t,this.locale),i=Math.abs(n),a;return r===0?a=Math.round(i):(Number.isInteger(r)||(r=Math.trunc(r)),a=Math.round(i*10**r)/10**r),{value:n>=0?a:-a,format:e?.format}},isExported:!0},mJ={description:P(`Rounds down a number.`),args:[U(`value (number)`,P(`The value to round to places number of places, always rounding down.`)),U(`places (number, default=0)`,P(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=L(e,this.locale),r=L(t,this.locale),i=Math.abs(n),a;return r===0?a=Math.floor(i):(Number.isInteger(r)||(r=Math.trunc(r)),a=Math.floor(i*10**r)/10**r),{value:n>=0?a:-a,format:e?.format}},isExported:!0},hJ={description:P(`Rounds up a number.`),args:[U(`value (number)`,P(`The value to round to places number of places, always rounding up.`)),U(`places (number, default=0)`,P(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=L(e,this.locale),r=L(t,this.locale),i=Math.abs(n),a;return r===0?a=Math.ceil(i):(Number.isInteger(r)||(r=Math.trunc(r)),a=Math.ceil(i*10**r)/10**r),{value:n>=0?a:-a,format:e?.format}},isExported:!0},gJ={description:P(`Secant of an angle provided in radians.`),args:[U(`angle (number)`,P(`The angle to find the secant of, in radians.`))],compute:function(e){return 1/Math.cos(L(e,this.locale))},isExported:!0},_J={description:P(`Hyperbolic secant of any real number.`),args:[U(`value (number)`,P(`Any real value to calculate the hyperbolic secant of.`))],compute:function(e){return 1/Math.cosh(L(e,this.locale))},isExported:!0},vJ={description:P(`Returns a sequence of numbers.`),args:[U(`rows (number)`,P(`The number of rows to return`)),U(`columns (number, optional, default=1)`,P(`The number of columns to return`)),U(`start (number, optional, default=1)`,P(`The first number in the sequence`)),U(`step (number, optional, default=1)`,P(`The amount to increment each value in the sequence`))],compute:function(e,t={value:1},n={value:1},r={value:1}){let i=L(n,this.locale),a=L(r,this.locale),o=Ho(e,this.locale),s=Ho(t,this.locale);return s<1?new I(P(`The number of columns (%s) must be positive.`,s)):o<1?new I(P(`The number of rows (%s) must be positive.`,o)):ns(s,o,(e,t)=>({value:i+t*s*a+e*a}))},isExported:!0},yJ={description:P(`Sine of an angle provided in radians.`),args:[U(`angle (number)`,P(`The angle to find the sine of, in radians.`))],compute:function(e){return Math.sin(L(e,this.locale))},isExported:!0},bJ={description:P(`Hyperbolic sine of any real number.`),args:[U(`value (number)`,P(`Any real value to calculate the hyperbolic sine of.`))],compute:function(e){return Math.sinh(L(e,this.locale))},isExported:!0},xJ={description:P(`Positive square root of a positive number.`),args:[U(`value (number)`,P(`The number for which to calculate the positive square root.`))],compute:function(e){let t=L(e,this.locale);return t<0?new I(P(`The value (%s) must be positive or null.`,t)):{value:Math.sqrt(t),format:e?.format}},isExported:!0},SJ={1:`AVERAGE`,2:`COUNT`,3:`COUNTA`,4:`MAX`,5:`MIN`,6:`PRODUCT`,7:`STDEV`,8:`STDEVP`,9:`SUM`,10:`VAR`,11:`VARP`},CJ=Object.entries(SJ).map(([e,t])=>({value:parseInt(e),label:P(`%s (include manually-hidden rows)`,t)})),wJ=Object.entries(SJ).map(([e,t])=>({value:parseInt(e)+100,label:P(`%s (exclude manually-hidden rows)`,t)})),TJ={description:P(`Returns a subtotal for a vertical range of cells using a specified aggregation function.`),args:[U(`function_code (number)`,P(`The function to use in subtotal aggregation.`),[...CJ,...wJ]),U(`ref (any, range<any>, repeating)`,P(`Range or reference for which you want the subtotal.`))],compute:function(e,...t){let n=Ho(e,this.locale),r=!0;if(n>100&&(n-=100,r=!1),n<1||n>11)return new I(P(`The function code (%s) must be between 1 to 11 or 101 to 111.`,n));let i=[];for(let e of t){let t=B(e),n=t[0][0]?.position;if(n===void 0)return new To(Io);let a=n.col+t.length-1,o=n.row+t[0].length-1,s=n.sheetId;for(let e=n.row;e<=o;e++)if(!this.getters.isRowFiltered(s,e)&&!(!r&&this.getters.isRowHiddenByUser(s,e)))for(let t=n.col;t<=a;t++){let n=this.getters.getCorrespondingFormulaCell({sheetId:s,col:t,row:e});(!n||!bn(n,`SUBTOTAL`))&&i.push(this.getFormulaResult({sheetId:s,col:t,row:e}))}}return this[SJ[n]].apply(this,[[i]])},isExported:!0},EJ={description:P(`Sum of a series of numbers and/or cells.`),args:[U(`value (number, range<number>, repeating)`,P(`Number or range to add together.`))],compute:function(...e){let t=e[0];return{value:iS(e,this.locale),format:Mo(t)}},isExported:!0},DJ={description:P(`A conditional sum across a range.`),args:[U(`criteria_range (range)`,P(`The range which is tested against criterion.`)),U(`criterion (string)`,P(`The pattern or test to apply to range.`)),U(`sum_range (range, default=criteria_range)`,P(`The range to be summed, if different from range.`))],compute:function(e,t,n){n===void 0&&(n=e);let r=0;return ds([e,t],(e,t)=>{let i=n[e]?.[t]?.value;typeof i==`number`&&(r+=i)},this.locale),r},isExported:!0},OJ={description:P(`Sums a range depending on multiple criteria.`),args:[U(`sum_range (range)`,P(`The range to sum.`)),U(`criteria_range (any, range, repeating)`,P(`Range to check.`)),U(`criterion (string, repeating)`,P(`Criteria to check.`))],compute:function(e,...t){let n=0;return ds(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n+=i)},this.locale),n},isExported:!0},kJ={description:P(`Tangent of an angle provided in radians.`),args:[U(`angle (number)`,P(`The angle to find the tangent of, in radians.`))],compute:function(e){return Math.tan(L(e,this.locale))},isExported:!0},AJ={description:P(`Hyperbolic tangent of any real number.`),args:[U(`value (number)`,P(`Any real value to calculate the hyperbolic tangent of.`))],compute:function(e){return Math.tanh(L(e,this.locale))},isExported:!0};function jJ(e,t){return t===0?Math.trunc(e):(Number.isInteger(t)||(t=Math.trunc(t)),Math.trunc(e*10**t)/10**t)}let MJ={description:P(`Truncates a number.`),args:[U(`value (number)`,P(`The value to be truncated.`)),U(`places (number, default=0)`,P(`The number of significant digits to the right of the decimal point to retain.`))],compute:function(e,t={value:0}){return{value:jJ(L(e,this.locale),L(t,this.locale)),format:e?.format}},isExported:!0},NJ={description:P(`Rounds a number down to the nearest integer that is less than or equal to it.`),args:[U(`value (number)`,P(`The number to round down to the nearest integer.`))],compute:function(e){return Math.floor(L(e,this.locale))},isExported:!0};var PJ=l({AVEDEV:()=>WJ,AVERAGE:()=>GJ,AVERAGEA:()=>YJ,AVERAGEIF:()=>XJ,AVERAGEIFS:()=>ZJ,AVERAGE_WEIGHTED:()=>JJ,CORREL:()=>yY,COUNT:()=>QJ,COUNTA:()=>$J,COVAR:()=>eY,COVARIANCE_P:()=>tY,COVARIANCE_S:()=>nY,FORECAST:()=>rY,GROWTH:()=>iY,INTERCEPT:()=>aY,LARGE:()=>oY,LINEST:()=>sY,LOGEST:()=>cY,MATTHEWS:()=>lY,MAX:()=>uY,MAXA:()=>dY,MAXIFS:()=>fY,MEDIAN:()=>pY,MIN:()=>mY,MINA:()=>hY,MINIFS:()=>gY,PEARSON:()=>vY,PERCENTILE:()=>bY,PERCENTILE_EXC:()=>xY,PERCENTILE_INC:()=>SY,POLYFIT_COEFFS:()=>CY,POLYFIT_FORECAST:()=>wY,QUARTILE:()=>TY,QUARTILE_EXC:()=>EY,QUARTILE_INC:()=>DY,RANK:()=>OY,RSQ:()=>kY,SLOPE:()=>AY,SMALL:()=>jY,SPEARMAN:()=>MY,STDEV:()=>NY,STDEVA:()=>IY,STDEVP:()=>LY,STDEVPA:()=>RY,STDEV_P:()=>PY,STDEV_S:()=>FY,STEYX:()=>zY,TREND:()=>BY,VAR:()=>VY,VARA:()=>WY,VARP:()=>GY,VARPA:()=>KY,VAR_P:()=>HY,VAR_S:()=>UY});let FJ=[{value:!0,label:P(`b is calculated normally`)},{value:!1,label:P(`b is forced to 1`)}],IJ=[{value:!1,label:P(`do not return additional regression statistics`)},{value:!0,label:P(`return additional regression statistics`)}],LJ=[{value:1,label:P(`order 1 (Linear)`)},{value:2,label:P(`order 2 (Quadratic)`)},{value:3,label:P(`order 3 (Cubic)`)},{value:4,label:P(`order 4 (Quartic)`)},{value:5,label:P(`order 5 (Quintic)`)},{value:6,label:P(`order 6 (Sextic)`)}],RJ=[{value:!0,label:P(`Compute intercept`)},{value:!1,label:P(`Force intercept to 0`)}],zJ=[{value:0,label:P(`Minimum value`)},{value:1,label:P(`First quartile (25th percentile)`)},{value:2,label:P(`Median value (50th percentile)`)},{value:3,label:P(`Third quartile (75th percentile)`)},{value:4,label:P(`Maximum value`)}];function BJ(e,t){let n=[],r=[],i=0,a=0;Xo([e],e=>{n.push(e),i+=1}),Xo([t],e=>{r.push(e),a+=1}),oS(i===a,P(`[[FUNCTION_NAME]] has mismatched argument count %s vs %s.`,i,a));let o=[],s=[];for(let e=0;e<i;e++){let t=n[e]?.value,i=r[e]?.value;typeof t==`number`&&typeof i==`number`&&(s.push(t),o.push(i))}return{flatDataX:o,flatDataY:s}}function VJ(e,t,n){let{flatDataX:r,flatDataY:i}=BJ(e,t),a=i.length;sS(a),n&&sS(a-1);let o=0,s=0;for(let e=0;e<a;e++)o+=i[e],s+=r[e];let c=o/a,l=s/a,u=0;for(let e=0;e<a;e++)u+=(i[e]-c)*(r[e]-l);return u/(a-+!!n)}function HJ(e,t,n,r){let i=0,a=n?ts:es,o=a(e,(e,t)=>(i+=1,e+t),0,r);sS(i),t&&sS(i-1);let s=o/i;return a(e,(e,t)=>e+(t-s)**2,0,r)/(i-+!!t)}function UJ(e,t,n,r){let i=L(t,r);oS(n?0<=i&&i<=1:0<i&&i<1,P(`Function [[FUNCTION_NAME]] parameter 2 value is out of range.`));let a=[],o,s=0;return Xo(e,e=>{let t=e?.value;typeof t==`number`&&(o=fs(a,e,`nextSmaller`,`asc`,a.length,(e,t)=>e[t]),a.splice(o+1,0,t),s++)}),oS(s!==0,ys),n||oS(1/(s+1)<=i&&i<=s/(s+1),P(`Function [[FUNCTION_NAME]] parameter 2 value is out of range.`)),po(a,i,n)}let WJ={description:P(`Average magnitude of deviations from mean.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the sample.`))],compute:function(...e){let t=0,n=es(e,(e,n)=>(t+=1,e+n),0,this.locale);if(t===0)return new ko(P(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`));let r=n/t;return es(e,(e,t)=>e+Math.abs(r-t),0,this.locale)/t},isExported:!0},GJ={description:P(`Numerical average value in a dataset, ignoring text.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to consider when calculating the average value.`))],compute:function(...e){return{value:bS(e,this.locale),format:Mo(e[0])}},isExported:!0},KJ=P(`[[FUNCTION_NAME]] has mismatched range sizes.`),qJ=P(`[[FUNCTION_NAME]] expects the weight to be positive or equal to 0.`),JJ={description:P(`Weighted average.`),args:[U(`values (number, range<number>, repeating)`,P(`Value to average.`)),U(`weights (number, range<number>, repeating)`,P(`Weight for each corresponding value.`))],compute:function(...e){let t=0,n=0;for(let r=0;r<e.length-1;r+=2){let i=e[r],a=e[r+1];if(!lS(i,a))return new I(KJ);if(ht(i))for(let e=0;e<i.length;e++)for(let r=0;r<i[0].length;r++){let o=i[e][r].value,s=ht(a)?a?.[e][r].value:L(a,this.locale),c=typeof o==`number`,l=typeof s==`number`;if(c&&l){if(s<0)return new I(qJ);t+=o*s,n+=s;continue}if(c!==l)return new I(P(`[[FUNCTION_NAME]] expects number values.`))}else{let e=L(i,this.locale),r=ht(a)?a?.[0][0].value:L(a,this.locale);if(typeof r==`number`){if(r<0)return new I(qJ);t+=e*r,n+=r}}}return n===0?new ko(P(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:t/n,format:Mo(e[0])}}},YJ={description:P(`Numerical average value in a dataset.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to consider when calculating the average value.`))],compute:function(...e){let t=0,n=ts(e,(e,n)=>(t+=1,e+n),0,this.locale);return t===0?new ko(P(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:n/t,format:Mo(e[0])}},isExported:!0},XJ={description:P(`Average of values depending on criteria.`),args:[U(`criteria_range (number, range<number>)`,P(`The range to check against criterion.`)),U(`criterion (string)`,P(`The pattern or test to apply to criteria_range.`)),U(`average_range (number, range<number>, default=criteria_range)`,P(`The range to average. If not included, criteria_range is used for the average instead.`))],compute:function(e,t,n){let r=B(n===void 0?e:n),i=0,a=0;return ds([e,t],(e,t)=>{let n=r[e]?.[t]?.value;typeof n==`number`&&(i+=1,a+=n)},this.locale),i===0?new ko(P(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):a/i},isExported:!0},ZJ={description:P(`Average of values depending on multiple criteria.`),args:[U(`average_range (range)`,P(`The range to average.`)),U(`criteria_range (any, range, repeating)`,P(`Range to check.`)),U(`criterion (string, repeating)`,P(`Criterion to check.`))],compute:function(e,...t){let n=B(e),r=0,i=0;return ds(t,(e,t)=>{let a=n[e]?.[t]?.value;typeof a==`number`&&(r+=1,i+=a)},this.locale),r===0?new ko(P(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):i/r},isExported:!0},QJ={description:P(`The number of numeric values in dataset.`),args:[U(`value (number, any, range<number>, repeating)`,P(`Value or range to consider when counting.`))],compute:function(...e){return SS(e,this.locale)},isExported:!0},$J={description:P(`The number of values in a dataset.`),args:[U(`value (any, range, repeating)`,P(`Value or range to consider when counting.`))],compute:function(...e){return CS(e)},isExported:!0},eY={description:P(`The covariance of a dataset.`),args:[U(`data_y (any, range)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (any, range)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return VJ(e,t,!1)},isExported:!0},tY={description:P(`The covariance of a dataset.`),args:[U(`data_y (any, range)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (any, range)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return VJ(e,t,!1)},isExported:!0},nY={description:P(`The sample covariance of a dataset.`),args:[U(`data_y (any, range)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (any, range)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return VJ(e,t,!0)},isExported:!0},rY={description:P(`Calculates the expected y-value for a specified x based on a linear regression of a dataset.`),args:[U(`x (number, range<number>)`,P(`The value(s) on the x-axis to forecast.`)),U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t,n){let{flatDataX:r,flatDataY:i}=BJ(t,n);return r.length===0||i.length===0?new Eo(ys):NS([i],[r],rs(B(e),e=>L(e,this.locale)),!0)},isExported:!0},iY={description:P(`Fits points to exponential growth trend.`),args:[U(`known_data_y (range<number>)`,P(`The array or range containing dependent (y) values that are already known, used to curve fit an ideal exponential growth curve.`)),U(`known_data_x (range<number>, default={1;2;3;...})`,P(`The values of the independent variable(s) corresponding with known_data_y.`)),U(`new_data_x (any, range, default=known_data_x)`,P(`The data points to return the y values for on the ideal curve fit.`)),U(`b (boolean, default=TRUE)`,P(`Given a general exponential form of y = b*m^x for a curve fit, calculates b if TRUE or forces b to be 1 and only calculates the m values if FALSE.`),FJ)],compute:function(e,t=[[]],n=[[]],r={value:!0}){return e.length===0||e[0].length===0?new I(bs(`known_data_y`)):jS(NS(MS(Bo(e,`known_data_y`)),Bo(t,`known_data_x`),Bo(n,`new_data_y`),z(r)))}},aY={description:P(`Compute the intercept of the linear regression.`),args:[U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=BJ(e,t);if(n.length===0||r.length===0)return new Eo(ys);let[[],[i]]=DS([n],[r]);return i},isExported:!0},oY={description:P(`Nth largest element from a data set.`),args:[U(`data (any, range)`,P(`Array or range containing the dataset to consider.`)),U(`n (number)`,P(`The rank from largest to smallest of the element to return.`))],compute:function(e,t){let n=Math.trunc(L(t?.value,this.locale)),r=[],i,a=0;Xo([e],e=>{typeof e?.value==`number`&&(i=fs(r,e,`nextSmaller`,`asc`,r.length,(e,t)=>e[t].value),r.splice(i+1,0,e),a++,a>n&&(r.shift(),a--))});let o=r.shift();return o===void 0?new I(ys):a<n?new I(P(`Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.`,n)):o},isExported:!0},sY={description:P(`Given partial data about a linear trend, calculates various parameters about the ideal linear trend using the least-squares method.`),args:[U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>, default={1;2;3;...})`,P(`The range representing the array or matrix of independent data.`)),U(`calculate_b (boolean, default=TRUE)`,P(`A flag specifying whether to compute the slope or not`),FJ),U(`verbose (boolean, default=FALSE)`,P(`A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept`),IJ)],compute:function(e,t=[[]],n={value:!0},r={value:!1}){return e.length===0||e[0].length===0?new I(bs(`data_y`)):DS(Bo(t,`data_x`),Bo(e,`data_y`),z(n),z(r))},isExported:!0},cY={description:P(`Given partial data about an exponential growth curve, calculates various parameters about the best fit ideal exponential growth curve.`),args:[U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>, optional, default={1;2;3;...})`,P(`The range representing the array or matrix of independent data.`)),U(`calculate_b (boolean, default=TRUE)`,P(`A flag specifying whether to compute the slope or not`),FJ),U(`verbose (boolean, default=FALSE)`,P(`A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept`),IJ)],compute:function(e,t=[[]],n={value:!0},r={value:!1}){if(e.length===0||e[0].length===0)return new I(bs(`data_y`));let i=DS(Bo(t,`data_x`),MS(Bo(e,`data_y`)),z(n),z(r));for(let e=0;e<i.length;e++)i[e][0]=Math.exp(i[e][0]);return i},isExported:!0},lY={description:P(`Compute the Matthews correlation coefficient of a dataset.`),args:[U(`data_x (range)`,P(`The range representing the array or matrix of observed data.`)),U(`data_y (range)`,P(`The range representing the array or matrix of predicted data.`))],compute:function(e,t){let n=e.flat(),r=t.flat();if(yS(n,r),n.length===0||r.length===0)return new Eo(ys);let i=n.length,a=0,o=0,s=0,c=0;for(let e=0;e<i;++e){let t=z(n[e]);t===z(r[e])?t?o++:a++:t?c++:s++}return(o*a-s*c)/Math.sqrt((o+s)*(o+c)*(a+s)*(a+c))},isExported:!1},uY={description:P(`Maximum value in a numeric dataset.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to consider when calculating the maximum value.`))],compute:function(...e){return wS(e,this.locale)},isExported:!0},dY={description:P(`Maximum numeric value in a dataset.`),args:[U(`value (any, range, repeating)`,P(`Value or range to consider when calculating the maximum value.`))],compute:function(...e){let t=ts(e,(e,t)=>Math.max(t,e),-1/0,this.locale);return{value:t===-1/0?0:t,format:Mo(e[0])}},isExported:!0},fY={description:P(`Returns the maximum value in a range of cells, filtered by a set of criteria.`),args:[U(`range (range)`,P(`The range of cells from which the maximum will be determined.`)),U(`criteria_range (any, range, repeating)`,P(`Range to evaluate criteria.`)),U(`criterion (string, repeating)`,P(`Criteria to check.`))],compute:function(e,...t){let n=-1/0;return ds(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n=n<i?i:n)},this.locale),n===-1/0?0:n},isExported:!0},pY={description:P(`Median value in a numeric dataset.`),args:[U(`value (any, range, repeating)`,P(`Value or range to consider when calculating the median value.`))],compute:function(...e){let t=[];return Zo(e,e=>{t.push(e)},this.locale),{value:UJ(t,{value:.5},!0,this.locale),format:Mo(t[0])}},isExported:!0},mY={description:P(`Minimum value in a numeric dataset.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to consider when calculating the minimum value.`))],compute:function(...e){return TS(e,this.locale)},isExported:!0},hY={description:P(`Minimum numeric value in a dataset.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to consider when calculating the minimum value.`))],compute:function(...e){let t=ts(e,(e,t)=>Math.min(t,e),1/0,this.locale);return{value:t===1/0?0:t,format:Mo(e[0])}},isExported:!0},gY={description:P(`Returns the minimum value in a range of cells, filtered by a set of criteria.`),args:[U(`range (range)`,P(`The range of cells from which the minimum will be determined.`)),U(`criteria_range (any, range, repeating)`,P(`Range to evaluate criteria.`)),U(`criterion (string, repeating)`,P(`Criterion to check.`))],compute:function(e,...t){let n=1/0;return ds(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n=n>i?i:n)},this.locale),n===1/0?0:n},isExported:!0};function _Y(e,t){let{flatDataX:n,flatDataY:r}=BJ(e,t);if(n.length===0||r.length===0)return new Eo(ys);let i=n.length,a=0,o=0,s=0,c=0,l=0;for(let e=0;e<i;e++){let t=n[e],i=r[e];a+=t,o+=i,s+=t*i,c+=t*t,l+=i*i}let u=Math.sqrt((i*c-a*a)*(i*l-o*o));return u===0?new ko:(i*s-a*o)/u}let vY={description:P(`Compute the Pearson product-moment correlation coefficient of a dataset.`),args:[U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return _Y(e,t)},isExported:!0},yY=vY,bY={description:P(`Value at a given percentile of a dataset.`),args:[U(`data (any, range)`,P(`The array or range containing the dataset to consider.`)),U(`percentile (number)`,P(`The percentile whose value within data will be calculated and returned.`))],compute:function(e,t){return SY.compute.bind(this)(e,t)},isExported:!0},xY={description:P(`Value at a given percentile of a dataset exclusive of 0 and 1.`),args:[U(`data (any, range)`,P(`The array or range containing the dataset to consider.`)),U(`percentile (number)`,P(`The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.`))],compute:function(e,t){return{value:UJ([e],t,!1,this.locale),format:Mo(e)}},isExported:!0},SY={description:P(`Value at a given percentile of a dataset.`),args:[U(`data (any, range)`,P(`The array or range containing the dataset to consider.`)),U(`percentile (number)`,P(`The percentile whose value within data will be calculated and returned.`))],compute:function(e,t){return{value:UJ([e],t,!0,this.locale),format:Mo(e)}},isExported:!0},CY={description:P(`Compute the coefficients of polynomial regression of the dataset.`),args:[U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>)`,P(`The range representing the array or matrix of independent data.`)),U(`order (number)`,P(`The order of the polynomial to fit the data, between 1 and 6.`),LJ),U(`intercept (boolean, default=TRUE)`,P(`A flag specifying whether to compute the intercept or not.`),RJ)],compute:function(e,t,n,r={value:!0}){let{flatDataX:i,flatDataY:a}=BJ(e,t);return i.length===0||a.length===0?new Eo(ys):OS(a,i,L(n,this.locale),z(r))},isExported:!1},wY={description:P(`Predict value by computing a polynomial regression of the dataset.`),args:[U(`x (number, range<number>)`,P(`The value(s) on the x-axis to forecast.`)),U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>)`,P(`The range representing the array or matrix of independent data.`)),U(`order (number)`,P(`The order of the polynomial to fit the data, between 1 and 6.`),LJ),U(`intercept (boolean, default=TRUE)`,P(`A flag specifying whether to compute the intercept or not.`),RJ)],compute:function(e,t,n,r,i={value:!0}){let a=L(r,this.locale),{flatDataX:o,flatDataY:s}=BJ(t,n);if(o.length===0||s.length===0)return new Eo(ys);let c=OS(s,o,a,z(i)).flat();return rs(B(e),e=>AS(c,L(e,this.locale),a))},isExported:!1},TY={description:P(`Value nearest to a specific quartile of a dataset.`),args:[U(`data (any, range)`,P(`The array or range containing the dataset to consider.`)),U(`quartile_number (number)`,P(`Which quartile value to return.`),zJ)],compute:function(e,t){return DY.compute.bind(this)(e,t)},isExported:!0},EY={description:P(`Value nearest to a specific quartile of a dataset exclusive of 0 and 4.`),args:[U(`data (any, range)`,P(`The array or range containing the dataset to consider.`)),U(`quartile_number (number)`,P(`Which quartile value, exclusive of 0 and 4, to return.`),[{value:1,label:P(`First quartile (25th percentile)`)},{value:2,label:P(`Median value (50th percentile)`)},{value:3,label:P(`Third quartile (75th percentile)`)}])],compute:function(e,t){let n={value:.25*Math.trunc(L(t,this.locale))};return{value:UJ([e],n,!1,this.locale),format:Mo(e)}},isExported:!0},DY={description:P(`Value nearest to a specific quartile of a dataset.`),args:[U(`data (any, range)`,P(`The array or range containing the dataset to consider.`)),U(`quartile_number (number)`,P(`Which quartile value to return.`),zJ)],compute:function(e,t){let n={value:.25*Math.trunc(L(t,this.locale))};return{value:UJ([e],n,!0,this.locale),format:Mo(e)}},isExported:!0},OY={description:P(`Returns the rank of a specified value in a dataset.`),args:[U(`value (number)`,P(`The value whose rank will be determined.`)),U(`data (range)`,P(`The range containing the dataset to consider.`)),U(`is_ascending (boolean, default=FALSE)`,P(`Whether to consider the values in data in descending or ascending order.`),[{value:!1,label:P(`Descending`)},{value:!0,label:P(`Ascending`)}])],compute:function(e,t,n={value:!1}){let r=z(n),i=L(e,this.locale),a=1,o=!1;for(let e of t)for(let t of e){if(typeof t.value!=`number`)continue;let e=L(t,this.locale);e===i?o=!0:e>i!==r&&a++}return o?a:new Eo(P(`Value not found in the given data.`))},isExported:!0},kY={description:P(`Compute the square of r, the Pearson product-moment correlation coefficient of a dataset.`),args:[U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let n=_Y(e,t);return typeof n==`number`?n**2:n},isExported:!0},AY={description:P(`Compute the slope of the linear regression.`),args:[U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=BJ(e,t);if(n.length===0||r.length===0)return new Eo(ys);let[[i]]=DS([n],[r]);return i},isExported:!0},jY={description:P(`Nth smallest element in a data set.`),args:[U(`data (any, range)`,P(`The array or range containing the dataset to consider.`)),U(`n (number)`,P(`The rank from smallest to largest of the element to return.`))],compute:function(e,t){let n=Math.trunc(L(t?.value,this.locale)),r=[],i,a=0;Xo([e],e=>{typeof e?.value==`number`&&(i=fs(r,e,`nextSmaller`,`asc`,r.length,(e,t)=>e[t].value),r.splice(i+1,0,e),a++,a>n&&(r.pop(),a--))});let o=r.pop();return o===void 0?new I(ys):a<n?new I(P(`Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.`,n)):o},isExported:!0},MY={description:P(`Compute the Spearman rank correlation coefficient of a dataset.`),args:[U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=BJ(t,e);if(n.length===0||r.length===0)return new Eo(ys);let i=n.length,a=n.map((e,t)=>[e,r[t]]);a.sort((e,t)=>e[0]-t[0]);for(let e=0;e<i;++e)a[e][0]=e;a.sort((e,t)=>e[1]-t[1]);let o=0;for(let e=0;e<i;++e)o+=(a[e][0]-e)**2;return 1-6*o/(i**3-i)},isExported:!1},NY={description:P(`Standard deviation.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the sample.`))],compute:function(...e){return Math.sqrt(VY.compute.bind(this)(...e))},isExported:!0},PY={description:P(`Standard deviation of entire population.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the population.`))],compute:function(...e){return Math.sqrt(HY.compute.bind(this)(...e))},isExported:!0},FY={description:P(`Standard deviation.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the sample.`))],compute:function(...e){return Math.sqrt(UY.compute.bind(this)(...e))},isExported:!0},IY={description:P(`Standard deviation of sample (text as 0).`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the sample.`))],compute:function(...e){return Math.sqrt(WY.compute.bind(this)(...e))},isExported:!0},LY={description:P(`Standard deviation of entire population.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the population.`))],compute:function(...e){return Math.sqrt(GY.compute.bind(this)(...e))},isExported:!0},RY={description:P(`Standard deviation of entire population (text as 0).`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the population.`))],compute:function(...e){return Math.sqrt(KY.compute.bind(this)(...e))},isExported:!0},zY={description:P(`Calculates the standard error of the predicted y-value for each x in the regression of a dataset.`),args:[U(`data_y (range<number>)`,P(`The range representing the array or matrix of dependent data.`)),U(`data_x (range<number>)`,P(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=BJ(e,t);return n.length===0||r.length===0?new Eo(ys):DS([n],[r],!0,!0)[1][2]},isExported:!0},BY={description:P(`Fits points to linear trend derived via least-squares.`),args:[U(`known_data_y (number, range<number>)`,P(`The array or range containing dependent (y) values that are already known, used to curve fit an ideal linear trend.`)),U(`known_data_x (number, range<number>, optional, default={1;2;3;...})`,P(`The values of the independent variable(s) corresponding with known_data_y.`)),U(`new_data_x (number, range<number>, optional, default=known_data_x)`,P(`The data points to return the y values for on the ideal curve fit.`)),U(`b (boolean, optional, default=TRUE)`,P(`Given a general linear form of y = m*x+b for a curve fit, calculates b if TRUE or forces b to be 0 and only calculates the m values if FALSE, i.e. forces the curve fit to pass through the origin.`),FJ)],compute:function(e,t=[[]],n=[[]],r={value:!0}){return e.length===0||e[0].length===0?new I(bs(`known_data_y`)):NS(Bo(e,`known_data_y`),Bo(t,`known_data_x`),Bo(n,`new_data_y`),z(r))}},VY={description:P(`Variance.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the sample.`))],compute:function(...e){return HJ(e,!0,!1,this.locale)},isExported:!0},HY={description:P(`Variance of entire population.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the population.`))],compute:function(...e){return HJ(e,!1,!1,this.locale)},isExported:!0},UY={description:P(`Variance.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the sample.`))],compute:function(...e){return HJ(e,!0,!1,this.locale)},isExported:!0},WY={description:P(`Variance of sample (text as 0).`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the sample.`))],compute:function(...e){return HJ(e,!0,!0,this.locale)},isExported:!0},GY={description:P(`Variance of entire population.`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the population.`))],compute:function(...e){return HJ(e,!1,!1,this.locale)},isExported:!0},KY={description:P(`Variance of entire population (text as 0).`),args:[U(`value (number, range<number>, repeating)`,P(`Value or range to include in the population.`))],compute:function(...e){return HJ(e,!1,!0,this.locale)},isExported:!0};var qY=l({DAVERAGE:()=>XY,DCOUNT:()=>ZY,DCOUNTA:()=>QY,DGET:()=>$Y,DMAX:()=>eX,DMIN:()=>tX,DPRODUCT:()=>nX,DSTDEV:()=>rX,DSTDEVP:()=>iX,DSUM:()=>aX,DVAR:()=>oX,DVARP:()=>sX});function JY(e,t,n,r){let i=new Map,a=e.length;for(let t=a-1;t>=0;t--)i.set(R(e[t][0]).toUpperCase(),t);let o=t?.value;if(typeof o!=`number`&&typeof o!=`string`)throw new I(P(`The field must be a number or a string`));let s;if(typeof o==`number`){if(s=Math.trunc(o)-1,s<0||a-1<s)throw new I(P(`The field (%(fieldValue)s) must be one of %(dimRowDB)s or must be a number between 1 and %s inclusive.`,{fieldValue:o.toString(),dimRowDB:a.toString()}))}else{let e=R(t).toUpperCase();if(s=i.get(e)??-1,s===-1)throw new I(P(`The field (%s) must be one of %s.`,R(t),[...i.keys()].toString()))}let c=n[0].length;if(c<2)throw new I(P(`The criteria range contains %s row, it must be at least 2 rows.`,c.toString()));let l=new Set,u=e[0].length;for(let t=1;t<c;t++){let a=[],o=!0;for(let r=0;r<n.length;r++){let s=R(n[r][0]).toUpperCase(),c=i.get(s),l=n[r][t];if(l.value!==null)if(c!==void 0)a.push([e[c].slice(1,u)]),a.push(l);else{o=!1;break}}if(o)if(a.length>0)ds(a,(e,t)=>{l.add(t)},r,!0);else{l=new Set(Array(u-1).keys());break}}let d=e[s];return[...l].map(e=>d[e+1])}let YY=[U(`database (range)`,P(`The array or range containing the data to consider, structured in such a way that the first row contains the labels for each column's values.`)),U(`field (number, string)`,P(`Indicates which column in database contains the values to be extracted and operated on.`)),U(`criteria (range)`,P(`An array or range containing zero or more criteria to filter the database values by before operating.`))],XY={description:P(`Average of a set of values from a table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return GJ.compute.bind(this)([r])},isExported:!0},ZY={description:P(`Counts values from a table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return QJ.compute.bind(this)([r])},isExported:!0},QY={description:P(`Counts values and text from a table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return $J.compute.bind(this)([r])},isExported:!0},$Y={description:P(`Single value from a table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return r.length===0?new I(P(`No match found in DGET evaluation.`)):r.length>1?new I(P(`More than one match found in DGET evaluation.`)):r[0]},isExported:!0},eX={description:P(`Maximum of values from a table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return uY.compute.bind(this)([r])},isExported:!0},tX={description:P(`Minimum of values from a table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return mY.compute.bind(this)([r])},isExported:!0},nX={description:P(`Product of values from a table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return lJ.compute.bind(this)([r])},isExported:!0},rX={description:P(`Standard deviation of population sample from table.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return NY.compute.bind(this)([r])},isExported:!0},iX={description:P(`Standard deviation of entire population from table.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return LY.compute.bind(this)([r])},isExported:!0},aX={description:P(`Sum of values from a table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return EJ.compute.bind(this)([r])},isExported:!0},oX={description:P(`Variance of population sample from table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return VY.compute.bind(this)([r])},isExported:!0},sX={description:P(`Variance of a population from a table-like range.`),args:YY,compute:function(e,t,n){let r=JY(e,t,n,this.locale);return GY.compute.bind(this)([r])},isExported:!0},cX=P(`The cashflow_amounts and cashflow_dates ranges must have the same dimensions.`),lX=P(`There must be both positive and negative values in cashflow_amounts.`),uX=e=>P(`The cost (%s) must be positive or null.`,e),dX=e=>P(`The cost (%s) must be strictly positive.`,e),fX=e=>P(`The frequency (%s) must be one of %s`,e,[1,2,4].toString()),pX=e=>P(`The day_count_convention (%s) must be between 0 and 4 inclusive.`,e),mX=e=>P(`The depreciation factor (%s) must be strictly positive.`,e),hX=e=>P(`The discount (%s) must be different from -1.`,e),gX=e=>P(`The discount (%s) must be strictly positive.`,e),_X=e=>P(`The discount (%s) must be smaller than 1.`,e),vX=e=>P(`The effective_rate (%s) must be strictly positive.`,e),yX=e=>P(`The end_period (%s) must be positive or null.`,e),bX=(e,t)=>P(`The end_period (%(end)s) must be smaller or equal to the life (%(life)s).`,{end:e,life:t}),xX=e=>P(`All the dates should be greater or equal to the first date in cashflow_dates (%s).`,e),SX=(e,t)=>P(`The first_period (%(first)s) must be smaller or equal to the last_period (%(last)s).`,{first:e,last:t}),CX=e=>P(`The first_period (%s) must be strictly positive.`,e),wX=e=>P(`The future_value (%s) must be strictly positive.`,e),TX=e=>P(`The investment (%s) must be strictly positive.`,e),EX=e=>P(`The issue (%s) must be positive or null.`,e),DX=(e,t)=>P(`The last_period (%(last)s) must be smaller or equal to the number_of_periods (%(nPeriods)s).`,{last:e,nPeriods:t}),OX=e=>P(`The last_period (%s) must be strictly positive.`,e),kX=e=>P(`The life (%s) must be strictly positive.`,e),AX=(e,t)=>P(`The maturity (%(maturity)s) must be strictly greater than the settlement (%(settlement)s).`,{maturity:t,settlement:e}),jX=e=>P(`The month (%s) must be between 1 and 12 inclusive.`,e),MX=e=>P(`The nominal_rate (%s) must be strictly positive.`,e),NX=e=>P(`The number_of_periods (%s) must be different from zero.`,e),PX=e=>P(`The number_of_periods (%s) must be strictly positive.`,e),FX=e=>P(`The period must be between 1 and number_of_periods (%s)`,e),IX=(e,t)=>P(`The period (%(period)s) must be less than or equal to %(lifeLimit)s.`,{period:e,lifeLimit:t}),LX=e=>P(`The period (%s) must be positive or null.`,e),RX=e=>P(`The periods_by_year (%s) must be strictly positive.`,e),zX=(e,t)=>P(`The period (%(period)s) must be less than or equal life (%(life)s).`,{period:e,life:t}),BX=e=>P(`The period (%s) must be strictly positive.`,e),VX=e=>P(`The present_value (%s) must be strictly positive.`,e),HX=e=>P(`The price (%s) must be strictly positive.`,e),UX=(e,t)=>P(`The purchase_date (%(purchaseDate)s) must be before the first_period_end (%(firstPeriodEnd)s).`,{purchaseDate:e,firstPeriodEnd:t}),WX=e=>P(`The purchase_date (%s) must be positive or null.`,e),GX=e=>P(`The rate_guess (%s) must be strictly greater than -1.`,e),KX=e=>P(`The rate (%s) must be positive or null.`,e),qX=e=>P(`The rate (%s) must be strictly positive.`,e),JX=e=>P(`The redemption (%s) must be strictly positive.`,e),YX=e=>P(`The salvage (%s) must be positive or null.`,e),XX=(e,t)=>P(`The salvage (%(salvage)s) must be smaller or equal than the cost (%(cost)s).`,{salvage:e,cost:t}),ZX=(e,t)=>P(`The settlement date (%(settlement)s) must be greater or equal to the issue date (%(issue)s).`,{settlement:e,issue:t}),QX=(e,t)=>P(`The settlement date (%(settlement)s) must at most one year after the maturity date (%(maturity)s).`,{settlement:e,maturity:t}),$X=(e,t)=>P(`The settlement date (%(settlement)s) must be strictly greater than the issue date (%(issue)s).`,{settlement:e,issue:t}),eZ=e=>P(`The start_period (%s) must be positive or null.`,e),tZ=(e,t)=>P(`The start_period (%(start)s) must be smaller or equal to the end_period (%(end)s).`,{start:e,end:t}),nZ=e=>P(`The unit (%s) must be strictly positive.`,e),rZ=e=>P(`The yield (%s) must be positive or null.`,e);function iZ(e){return e.some(e=>e>0)&&e.some(e=>e<0)}function aZ(e){return![0,1,2,3,4].includes(e)}function oZ(e){return![1,2,4].includes(e)}function sZ(e,t,n){let r=qo(e,n),i=qo(t,n),a=qo(e,n);return a.setFullYear(r.getFullYear()+1),i.getTime()<=a.getTime()}let cZ=[{value:0,label:P(`US (NASD) 30/360`)},{value:1,label:P(`Actual/Actual`)},{value:2,label:P(`Actual/360`)},{value:3,label:P(`Actual/365`)},{value:4,label:P(`European 30/360`)}];var lZ=l({DATE:()=>dZ,DATEDIF:()=>fZ,DATEVALUE:()=>pZ,DAY:()=>mZ,DAYS:()=>hZ,DAYS360:()=>gZ,EDATE:()=>_Z,EOMONTH:()=>vZ,HOUR:()=>yZ,ISOWEEKNUM:()=>bZ,MINUTE:()=>xZ,MONTH:()=>SZ,MONTH_END:()=>zZ,MONTH_START:()=>RZ,NETWORKDAYS:()=>CZ,NETWORKDAYS_INTL:()=>EZ,NOW:()=>DZ,QUARTER:()=>BZ,QUARTER_END:()=>HZ,QUARTER_START:()=>VZ,SECOND:()=>OZ,TIME:()=>kZ,TIMEVALUE:()=>AZ,TODAY:()=>jZ,WEEKDAY:()=>MZ,WEEKNUM:()=>NZ,WORKDAY:()=>PZ,WORKDAY_INTL:()=>FZ,YEAR:()=>IZ,YEARFRAC:()=>LZ,YEAR_END:()=>WZ,YEAR_START:()=>UZ}),uZ=function(e){return e.WHOLE_YEARS=`Y`,e.WHOLE_MONTHS=`M`,e.WHOLE_DAYS=`D`,e.DAYS_WITHOUT_WHOLE_MONTHS=`MD`,e.MONTH_WITHOUT_WHOLE_YEARS=`YM`,e.DAYS_BETWEEN_NO_MORE_THAN_ONE_YEAR=`YD`,e}(uZ||{});let dZ={description:P(`Converts year/month/day into a date.`),args:[U(`year (number)`,P(`The year component of the date.`)),U(`month (number)`,P(`The month component of the date.`)),U(`day (number)`,P(`The day component of the date.`))],compute:function(e,t,n){let r=Math.trunc(L(e,this.locale)),i=Math.trunc(L(t,this.locale)),a=Math.trunc(L(n,this.locale));if(r<0||r>9999)return new I(P(`The year (%s) must be between 0 and 9999 inclusive.`,r.toString()));r<1900&&(r+=1900);let o=Wa(new _a(r,i-1,a));return o<0?new I(P(`The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.`)):{value:o,format:this.locale.dateFormat}},isExported:!0},fZ={description:P(`Calculates the number of days, months, or years between two dates.`),args:[U(`start_date (date)`,P(`The start date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.`)),U(`end_date (date)`,P(`The end date to consider in the calculation. Must be a reference to a cell containing a DATE, a function returning a DATE type, or a number.`)),U(`unit (string)`,P(`A text abbreviation for unit of time.`),[{value:`Y`,label:P(`The number of whole years between start_date and end_date`)},{value:`M`,label:P(`The number of whole months between start_date and end_date`)},{value:`D`,label:P(`The number of days between start_date and end_date`)},{value:`MD`,label:P(`The number of days between start_date and end_date after subtracting whole months`)},{value:`YM`,label:P(`The number of whole months between start_date and end_date after subtracting whole years`)},{value:`YD`,label:P(`The number of days between start_date and end_date, assuming start_date and end_date were no more than one year apart`)}])],compute:function(e,t,n){let r=R(n).toUpperCase();if(!Object.values(uZ).includes(r))return new I(Ro(Object.values(uZ),R(n)));let i=Math.trunc(L(e,this.locale)),a=Math.trunc(L(t,this.locale)),o=Ua(i),s=Ua(a);if(a<i)return new I(P(`start_date (%s) should be on or before end_date (%s).`,o.toLocaleDateString(),s.toLocaleDateString()));switch(r){case`Y`:return $a(o,s);case`M`:return Za(o,s);case`D`:return Qa(o,s);case`YM`:return Za(o,s)-$a(o,s)*12;case`MD`:let e=s.getDate()-o.getDate();return e<0&&(e=Ka(new _a(s.getFullYear(),s.getMonth()-1,1))-Math.abs(e)),e;case`YD`:{if(eo(i,a))return Qa(o,s);let e=new _a(o.getFullYear(),s.getMonth(),s.getDate()),t=Qa(o,e);return t<0&&(e.setFullYear(o.getFullYear()+1),t=Qa(o,e)),t}}},isExported:!0},pZ={description:P(`Converts a date string to a date value.`),args:[U(`date_string (string)`,P(`The string representing the date.`))],compute:function(e){let t=R(e),n=Na(t,this.locale);return n===null?new I(P(`The date_string (%s) cannot be parsed to date/time.`,t.toString())):Math.trunc(n.value)},isExported:!0},mZ={description:P(`Day of the month that a specific date falls on.`),args:[U(`date (string)`,P(`The date from which to extract the day.`))],compute:function(e){return qo(e,this.locale).getDate()},isExported:!0},hZ={description:P(`Number of days between two dates.`),args:[U(`end_date (date)`,P(`The end of the date range.`)),U(`start_date (date)`,P(`The start of the date range.`))],compute:function(e,t){let n=qo(e,this.locale),r=qo(t,this.locale),i=n.getTime()-r.getTime();return Math.round(i/ya)},isExported:!0},gZ={description:P(`Number of days between two dates on a 360-day year (months of 30 days).`),args:[U(`start_date (date)`,P(`The start date to consider in the calculation.`)),U(`end_date (date)`,P(`The end date to consider in the calculation.`)),U(`method (boolean, default=false)`,P(`An indicator of what day count method to use.`),[{value:!1,label:P(`U.S. NASD method (default)`)},{value:!0,label:P(`European method`)}])],compute:function(e,t,n={value:!1}){let r=Math.trunc(L(e,this.locale)),i=Math.trunc(L(t,this.locale)),a=Xa(r,i,z(n)?4:0);return Math.sign(i-r)*Math.round(a*360)},isExported:!0},_Z={description:P(`Date a number of months before/after another date.`),args:[U(`start_date (date)`,P(`The date from which to calculate the result.`)),U(`months (number)`,P(`The number of months before (negative) or after (positive) 'start_date' to calculate.`))],compute:function(e,t){return{value:Wa(Ja(qo(e,this.locale),Math.trunc(L(t,this.locale)),!1)),format:this.locale.dateFormat}},isExported:!0},vZ={description:P(`Last day of a month before or after a date.`),args:[U(`start_date (date)`,P(`The date from which to calculate the result.`)),U(`months (number)`,P(`The number of months before (negative) or after (positive) 'start_date' to consider.`))],compute:function(e,t){let n=qo(e,this.locale),r=Math.trunc(L(t,this.locale));return{value:Wa(new _a(n.getFullYear(),n.getMonth()+r+1,0)),format:this.locale.dateFormat}},isExported:!0},yZ={description:P(`Hour component of a specific time.`),args:[U(`time (date)`,P(`The time from which to calculate the hour component.`))],compute:function(e){return qo(e,this.locale).getHours()},isExported:!0},bZ={description:P(`ISO week number of the year.`),args:[U(`date (date)`,P(`The date for which to determine the ISO week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.`))],compute:function(e){let t=qo(e,this.locale),n=t.getFullYear(),r=1;for(;new _a(n,0,r).getDay()!==4;)r+=1;let i=new _a(n,0,r-3),a=31;for(;new _a(n,11,a).getDay()!==4;)--a;let o=new _a(n,11,a+3),s;s=i.getTime()<=t.getTime()?t.getTime()<=o.getTime()?0:1:-1;let c;switch(s){case 0:c=i;break;case 1:c=new _a(n,11,a+3+1);break;case-1:let e=1;for(;new _a(n-1,0,e).getDay()!==4;)e+=1;c=new _a(n-1,0,e-3);break}let l=(t.getTime()-c.getTime())/ya;return Math.floor(l/7)+1},isExported:!0},xZ={description:P(`Minute component of a specific time.`),args:[U(`time (date)`,P(`The time from which to calculate the minute component.`))],compute:function(e){return qo(e,this.locale).getMinutes()},isExported:!0},SZ={description:P(`Month of the year a specific date falls in`),args:[U(`date (date)`,P(`The date from which to extract the month.`))],compute:function(e){return qo(e,this.locale).getMonth()+1},isExported:!0},CZ={description:P(`Net working days between two provided days.`),args:[U(`start_date (date)`,P(`The start date of the period from which to calculate the number of net working days.`)),U(`end_date (date)`,P(`The end date of the period from which to calculate the number of net working days.`)),U(`holidays (date, range<date>, optional)`,P(`A range or array constant containing the date serial numbers to consider holidays.`))],compute:function(e,t,n){return EZ.compute.bind(this)(e,t,{value:1},n)},isExported:!0};function wZ(e){let t=e?.value;if(typeof t==`string`){oS(t.length===7&&[...t].every(e=>e===`0`||e===`1`),P(`When weekend is a string (%s) it must be composed of "0" or "1".`,t));let e=[];for(let n=0;n<7;n++)t[n]===`1`&&e.push((n+1)%7);return e}if(typeof t==`number`)return oS(1<=t&&t<=7||11<=t&&t<=17,P(`The weekend (%s) must be a string or a number in the range 1-7 or 11-17.`,t.toString())),t<=7?[t-2==-1?6:t-2,t-1]:[t-11];throw new I(P(`The weekend must be a number or a string.`))}let TZ=[{value:1,label:P(`Saturday/Sunday are weekends`)},{value:2,label:P(`Sunday/Monday are weekends`)},{value:3,label:P(`Monday/Tuesday are weekends`)},{value:4,label:P(`Tuesday/Wednesday are weekends`)},{value:5,label:P(`Wednesday/Thursday are weekends`)},{value:6,label:P(`Thursday/Friday are weekends`)},{value:7,label:P(`Friday/Saturday are weekends`)},{value:11,label:P(`Sunday is the only weekend`)},{value:12,label:P(`Monday is the only weekend`)},{value:13,label:P(`Tuesday is the only weekend`)},{value:14,label:P(`Wednesday is the only weekend`)},{value:15,label:P(`Thursday is the only weekend`)},{value:16,label:P(`Friday is the only weekend`)},{value:17,label:P(`Saturday is the only weekend`)}],EZ={description:P(`Net working days between two dates (specifying weekends).`),args:[U(`start_date (date)`,P(`The start date of the period from which to calculate the number of net working days.`)),U(`end_date (date)`,P(`The end date of the period from which to calculate the number of net working days.`)),U(`weekend (any, default=1)`,P(`A number or string representing which days of the week are considered weekends.`),TZ),U(`holidays (date, range<date>, optional)`,P(`A range or array constant containing the dates to consider as holidays.`))],compute:function(e,t,n={value:1},r){let i=qo(e,this.locale),a=qo(t,this.locale),o=wZ(n),s=new Set;r!==void 0&&Xo([r],e=>{let t=qo(e,this.locale);s.add(t.getTime())});let c=i.getTime()>a.getTime(),l=_a.fromTimestamp((c?i:a).getTime()),u=_a.fromTimestamp((c?a:i).getTime()),d=l.getTime(),f=u.getTime(),p=0;for(;f<=d;)!o.includes(u.getDay())&&!s.has(f)&&(p+=1),u.setDate(u.getDate()+1),f=u.getTime();return c?-p:p},isExported:!0},DZ={description:P(`Current date and time as a date value.`),args:[],compute:function(){let e=_a.now(),t=e.getTime()-va.getTime(),n=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return{value:Math.floor(t/ya)+n,format:iv(this.locale)}},isExported:!0},OZ={description:P(`Minute component of a specific time.`),args:[U(`time (date)`,P(`The time from which to calculate the second component.`))],compute:function(e){return qo(e,this.locale).getSeconds()},isExported:!0},kZ={description:P(`Converts hour/minute/second into a time.`),args:[U(`hour (number)`,P(`The hour component of the time.`)),U(`minute (number)`,P(`The minute component of the time.`)),U(`second (number)`,P(`The second component of the time.`))],compute:function(e,t,n){let r=Math.trunc(L(e,this.locale)),i=Math.trunc(L(t,this.locale)),a=Math.trunc(L(n,this.locale));return i+=Math.floor(a/60),a=a%60+(a<0?60:0),r+=Math.floor(i/60),i=i%60+(i<0?60:0),r%=24,r<0?new I(P(`The function [[FUNCTION_NAME]] result cannot be negative`)):{value:r/24+i/1440+a/(1440*60),format:this.locale.timeFormat}},isExported:!0},AZ={description:P(`Converts a time string into its serial number representation.`),args:[U(`time_string (string)`,P(`The string that holds the time representation.`))],compute:function(e){let t=R(e),n=Na(t,this.locale);if(n===null)return new I(P(`The time_string (%s) cannot be parsed to date/time.`,t));let r=n.value-Math.trunc(n.value);return r<0?1+r:r},isExported:!0},jZ={description:P(`Current date as a date value.`),args:[],compute:function(){let e=_a.now();return{value:Wa(new _a(e.getFullYear(),e.getMonth(),e.getDate())),format:this.locale.dateFormat}},isExported:!0},MZ={description:P(`Day of the week of the date provided (as number).`),args:[U(`date (date)`,P(`The date for which to determine the day of the week. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),U(`type (number, default=1)`,P(`A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.`),[{value:1,label:P(`Numbers 1 (Sunday) trough 7 (Saturday)`)},{value:2,label:P(`Numbers 1 (Monday) trough 7 (Sunday)`)},{value:3,label:P(`Numbers 0 (Monday) trough 6 (Sunday)`)},{value:11,label:P(`Numbers 1 (Monday) trough 7 (Sunday)`)},{value:12,label:P(`Numbers 1 (Tuesday) trough 7 (Monday)`)},{value:13,label:P(`Numbers 1 (Wednesday) trough 7 (Tuesday)`)},{value:14,label:P(`Numbers 1 (Thursday) trough 7 (Wednesday)`)},{value:15,label:P(`Numbers 1 (Friday) trough 7 (Thursday)`)},{value:16,label:P(`Numbers 1 (Saturday) trough 7 (Friday)`)},{value:17,label:P(`Numbers 1 (Sunday) trough 7 (Saturday)`)}])],compute:function(e,t={value:1}){let n=qo(e,this.locale),r=Math.round(L(t,this.locale)),i=n.getDay();if(!(1<=r&&r<=3)&&!(11<=r&&r<=17))return new I(P(`The type (%s) must be between 1 and 3 or between 11 and 17.`,r));switch(r){case 1:return i+1;case 2:return i===0?7:i;case 3:return i===0?6:i-1}let a=r-10,o=(i+1-a+7)%7;return o===0?7:o},isExported:!0},NZ={description:P(`Week number of the year.`),args:[U(`date (date)`,P(`The date for which to determine the week number. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),U(`type (number, default=1)`,P(`A number representing the day that a week starts on. Sunday = 1.`),[{value:1,label:P(`Sunday`)},{value:2,label:P(`Monday`)},{value:11,label:P(`Monday`)},{value:12,label:P(`Tuesday`)},{value:13,label:P(`Wednesday`)},{value:14,label:P(`Thursday`)},{value:15,label:P(`Friday`)},{value:16,label:P(`Saturday`)},{value:17,label:P(`Sunday`)},{value:21,label:P(`ISO week number (Monday as first day of the week)`)}])],compute:function(e,t={value:1}){let n=qo(e,this.locale),r=Math.round(L(t,this.locale));if(![1,2,11,12,13,14,15,16,17,21].includes(r))return new I(P(`The type (%s) is out of range.`,r.toString()));if(r===21)return bZ.compute.bind(this)(e);let i;i=r===1||r===2?r-1:r-10==7?0:r-10;let a=n.getFullYear(),o=1,s=new _a(a,0,o);for(;s.getDay()!==i;)o+=1,s=new _a(a,0,o);let c=(n.getTime()-s.getTime())/ya;return c<0?1:Math.floor(c/7)+(o===1?1:2)},isExported:!0},PZ={description:P(`Date after a number of workdays.`),args:[U(`start_date (date)`,P(`The date from which to begin counting.`)),U(`num_days (number)`,P(`The number of working days to advance from start_date. If negative, counts backwards.`)),U(`holidays (date, range<date>, optional)`,P(`A range or array constant containing the dates to consider holidays.`))],compute:function(e,t,n={value:null}){return FZ.compute.bind(this)(e,t,{value:1},n)},isExported:!0},FZ={description:P(`Date after a number of workdays (specifying weekends).`),args:[U(`start_date (date)`,P(`The date from which to begin counting.`)),U(`num_days (number)`,P(`The number of working days to advance from start_date. If negative, counts backwards.`)),U(`weekend (any, default=1)`,P(`A number or string representing which days of the week are considered weekends.`),TZ),U(`holidays (date, range<date>, optional)`,P(`A range or array constant containing the dates to consider holidays.`))],compute:function(e,t,n={value:1},r){let i=qo(e,this.locale),a=Math.trunc(L(t,this.locale));if(n.value===`1111111`)return new I(P(`The weekend must be different from '1111111'.`));let o=wZ(n),s=new Set;r!==void 0&&Xo([r],e=>{let t=qo(e,this.locale);s.add(t.getTime())});let c=_a.fromTimestamp(i.getTime()),l=c.getTime(),u=Math.sign(a),d=Math.abs(a);for(;d>0;)c.setDate(c.getDate()+u),l=c.getTime(),!o.includes(c.getDay())&&!s.has(l)&&--d;let f=l-va.getTime();return{value:Math.round(f/ya),format:this.locale.dateFormat}},isExported:!0},IZ={description:P(`Year specified by a given date.`),args:[U(`date (date)`,P(`The date from which to extract the year.`))],compute:function(e){return qo(e,this.locale).getFullYear()},isExported:!0},LZ={description:P(`Exact number of years between two dates.`),args:[U(`start_date (date)`,P(`The start date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),U(`end_date (date)`,P(`The end date to consider in the calculation. Must be a reference to a cell containing a date, a function returning a date type, or a number.`)),U(`day_count_convention (number, default=0)`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n={value:0}){let r=Math.trunc(L(e,this.locale)),i=Math.trunc(L(t,this.locale)),a=Math.trunc(L(n,this.locale));return r<0?new I(P(`The start_date (%s) must be positive or null.`,r)):i<0?new I(P(`The end_date (%s) must be positive or null.`,i)):0>a||a>4?new I(P(`The day_count_convention (%s) must be between 0 and 4 inclusive.`,a)):Xa(r,i,a)}},RZ={description:P(`First day of the month a date falls in.`),args:[U(`date (date)`,P(`The date from which to calculate the result.`))],compute:function(e){let t=qo(e,this.locale);return{value:Wa(new _a(t.getFullYear(),t.getMonth(),1)),format:this.locale.dateFormat}}},zZ={description:P(`Last day of the month a date falls in.`),args:[U(`date (date)`,P(`The date from which to calculate the result.`))],compute:function(e){return vZ.compute.bind(this)(e,{value:0})}},BZ={description:P(`Quarter of the year a specific date falls in`),args:[U(`date (date)`,P(`The date from which to extract the quarter.`))],compute:function(e){return Math.ceil((qo(e,this.locale).getMonth()+1)/3)}},VZ={description:P(`First day of the quarter of the year a specific date falls in.`),args:[U(`date (date)`,P(`The date from which to calculate the start of quarter.`))],compute:function(e){let t=BZ.compute.bind(this)(e);return{value:Wa(new _a(IZ.compute.bind(this)(e),(t-1)*3,1)),format:this.locale.dateFormat}}},HZ={description:P(`Last day of the quarter of the year a specific date falls in.`),args:[U(`date (date)`,P(`The date from which to calculate the end of quarter.`))],compute:function(e){let t=BZ.compute.bind(this)(e);return{value:Wa(new _a(IZ.compute.bind(this)(e),t*3,0)),format:this.locale.dateFormat}}},UZ={description:P(`First day of the year a specific date falls in.`),args:[U(`date (date)`,P(`The date from which to calculate the start of the year.`))],compute:function(e){return{value:Wa(new _a(IZ.compute.bind(this)(e),0,1)),format:this.locale.dateFormat}}},WZ={description:P(`Last day of the year a specific date falls in.`),args:[U(`date (date)`,P(`The date from which to calculate the end of the year.`))],compute:function(e){return{value:Wa(new _a(IZ.compute.bind(this)(e)+1,0,0)),format:this.locale.dateFormat}}};var GZ=l({DELTA:()=>KZ});let KZ={description:P(`Compare two numeric values, returning 1 if they're equal.`),args:[U(`number1 (number)`,P(`The first number to compare.`)),U(`number2 (number, default=0)`,P(`The second number to compare.`))],compute:function(e,t={value:0}){return+(L(e,this.locale)===L(t,this.locale))},isExported:!0};var qZ=l({FILTER:()=>YZ,SORT:()=>XZ,SORTN:()=>ZZ,UNIQUE:()=>QZ});function JZ(e,t,...n){for(let e=0;e<n.length;e++){let t=e%2==0?`sort_column`:`is_ascending`;oS(n[e]!==void 0,P(`Value for parameter %s is missing in [[FUNCTION_NAME]].`,t))}let r=[],i=[],a=e.length;for(let o=0;o<n.length;o+=2){r.push(z(gS(n[o+1])?.value)?`asc`:`desc`);let s=n[o];if(ht(s)&&(s.length>1||s[0].length>1))oS(s.length===1&&s[0].length===a,P(`Wrong size for %s. Expected a range of size 1x%s. Got %sx%s.`,`sort_column${o+1}`,a,s.length,s[0].length)),i.push(s.flat().map(e=>e.value));else{let n=L(gS(s)?.value,t);if(n<1||n>e[0].length)return e;i.push(e.map(e=>e[n-1].value))}}if(i.length===0)for(let t=0;t<e[0].length;t++)i.push(e.map(e=>e[t].value)),r.push(`asc`);let o={desc:NV(`desc`),asc:NV(`asc`)},s=C(0,e.length);return s.sort((e,t)=>{for(let[n,a]of i.entries()){let i=a[e],s=a[t],c={value:i,type:i===null?`empty`:typeof i==`string`?`text`:typeof i},l={value:s,type:s===null?`empty`:typeof s==`string`?`text`:typeof s},u=o[r[n]](c,l);if(u!==0)return u}return 0}),s.map(t=>e[t])}let YZ={description:P(`Returns a filtered version of the source range, returning only rows or columns that meet the specified conditions.`),args:[U(`range (any, range<any>)`,P(`The data to be filtered.`)),U(`condition (boolean, range<boolean>, repeating)`,P(`Column or row containing true or false values corresponding to the range.`))],compute:function(e,...t){let n=B(e),r=t.map(e=>rs(B(e),e=>e.value));for(let e of r)if(!cS(e))return new I(P(`The arguments condition must be a single column or row.`));if(!lS(...t))return new I(P(`The arguments conditions must have the same dimensions.`));let i=r.map(e=>e.flat()),a=r[0].length===1?`row`:`col`;if(n=a===`row`?as(n):n,i.some(e=>e.length!==n.length))return new I(P(`FILTER has mismatched sizes on the range and conditions.`));let o=[];for(let e=0;e<n.length;e++){let t=n[e];i.every(t=>(typeof t[e]==`boolean`||typeof t[e]==`number`)&&t[e])&&o.push(t)}return o.length?a===`row`?as(o):o:new Eo(P(`No match found in FILTER evaluation`))},isExported:!1},XZ={description:P(`Sorts the rows of a given array or range by the values in one or more columns.`),args:[U(`range (range)`,P(`The data to be sorted.`)),U(`sort_column (any, range<number>, repeating, optional)`,P(`The index of the column in range or a range outside of range containing the value by which to sort.`)),U(`is_ascending (boolean, repeating, optional)`,P(`TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.`),[{value:!0,label:P(`Ascending`)},{value:!1,label:P(`Descending`)}])],compute:function(e,...t){return as(JZ(as(e),this.locale,...t))},isExported:!0},ZZ={description:P(`Returns the first n items in a data set after performing a sort.`),args:[U(`range (range)`,P(`The data to be sorted.`)),U(`n (number)`,P(`The number of items to return.`)),U(`display_ties_mode (number, default=0)`,P(`A number representing the way to display ties.`)),U(`sort_column (number, range<number>, repeating, optional)`,P(`The index of the column in range or a range outside of range containing the value by which to sort.`)),U(`is_ascending (boolean, repeating, optional)`,P(`TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.`),[{value:!0,label:P(`Ascending`)},{value:!1,label:P(`Descending`)}])],compute:function(e,t,...n){let r=L(t?.value??1,this.locale),i=n.length%2==0?0:L(n[0]?.value,this.locale),a=n.length%2==0?n:n.slice(1);if(r<0)return new I(P(`Wrong value of 'n'. Expected a positive number. Got %s.`,r));if(i<0||i>3)return new I(P(`Wrong value of 'display_ties_mode'. Expected a positive number between 0 and 3. Got %s.`,i));let o=JZ(as(e),this.locale,...a),s=(e,t)=>JSON.stringify(o[e].map(e=>e.value))===JSON.stringify(o[t].map(e=>e.value));switch(i){case 0:return as(o.slice(0,r));case 1:for(let e=r;e<o.length;e++)if(!s(e,r-1))return as(o.slice(0,e));return as(o);case 2:{let e=[o[0]];for(let t=1;t<o.length;t++)for(let n=0;n<t&&!s(t,n);n++)n===t-1&&e.push(o[t]);return as(e.slice(0,r))}case 3:{let e=[o[0]],t=1;for(let n=1;n<o.length&&(s(n,n-1)||t++,!(t>r));n++)e.push(o[n]);return as(e)}}},isExported:!1},QZ={description:P(`Unique rows in the provided source range.`),args:[U(`range (any, range<any>)`,P(`The data to filter by unique entries.`)),U(`by_column (boolean, default=FALSE)`,P(`Whether to filter the data by columns or by rows.`),[{value:!0,label:P(`Return unique columns`)},{value:!1,label:P(`Return unique rows`)}]),U(`exactly_once (boolean, default=FALSE)`,P(`Whether to return only entries with no duplicates.`),[{value:!0,label:P(`Return items that appear exactly once`)},{value:!1,label:P(`Return every distinct item`)}])],compute:function(e={value:``},t,n){if(!ht(e))return[[e]];let r=z(t?.value)||!1,i=z(n?.value)||!1;r||(e=as(e));let a=new Map;for(let t of e){let e=JSON.stringify(t.map(e=>e.value)),n=a.get(e);n?n.count++:a.set(e,{data:t,count:1})}let o=[];for(let e of a.values())i&&e.count>1||o.push(e.data);return o.length?r?o:as(o):new I(P(`No unique values found`))},isExported:!0};var $Z=l({ACCRINTM:()=>iQ,AMORLINC:()=>aQ,COUPDAYBS:()=>sQ,COUPDAYS:()=>oQ,COUPDAYSNC:()=>cQ,COUPNCD:()=>lQ,COUPNUM:()=>uQ,COUPPCD:()=>dQ,CUMIPMT:()=>fQ,CUMPRINC:()=>pQ,DB:()=>mQ,DDB:()=>gQ,DISC:()=>_Q,DOLLARDE:()=>vQ,DOLLARFR:()=>yQ,DURATION:()=>bQ,EFFECT:()=>xQ,FV:()=>CQ,FVSCHEDULE:()=>wQ,INTRATE:()=>TQ,IPMT:()=>DQ,IRR:()=>kQ,ISPMT:()=>AQ,MDURATION:()=>jQ,MIRR:()=>MQ,NOMINAL:()=>NQ,NPER:()=>PQ,NPV:()=>IQ,PDURATION:()=>LQ,PMT:()=>zQ,PPMT:()=>VQ,PRICE:()=>UQ,PRICEDISC:()=>WQ,PRICEMAT:()=>GQ,PV:()=>HQ,RATE:()=>qQ,RECEIVED:()=>JQ,RRI:()=>YQ,SLN:()=>XQ,SYD:()=>ZQ,TBILLEQ:()=>e$,TBILLPRICE:()=>$Q,TBILLYIELD:()=>t$,VDB:()=>n$,XIRR:()=>r$,XNPV:()=>i$,YIELD:()=>a$,YIELDDISC:()=>o$,YIELDMAT:()=>s$});let eQ=[{value:1,label:P(`Annual`)},{value:2,label:P(`Semi-annual`)},{value:4,label:P(`Quarterly`)}],tQ=[{value:0,label:P(`End of period (default)`)},{value:1,label:P(`Beginning of period`)}],nQ=[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`frequency (number)`,P(`The number of interest or coupon payments per year (1, 2, or 4).`),eQ),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)];function rQ(e,t,n,r,i=1e-10,a){let o=n,s,c,l,u=!1,d=0,f;do{if(l=e(o),isNaN(l)){oS(d<r&&a!==void 0,P(`Function [[FUNCTION_NAME]] didn't find any result.`)),d++,o=a(f),f=o;continue}s=o-l/t(o),c=Math.abs(s-o),o=s,u=c<i||Math.abs(l)<i,oS(d<r,P(`Function [[FUNCTION_NAME]] didn't find any result.`)),d++}while(!u);return o}let iQ={description:P(`Accrued interest of security paying at maturity.`),args:[U(`issue (date)`,P(`The date the security was initially issued.`)),U(`maturity (date)`,P(`The maturity date of the security.`)),U(`rate (number)`,P(`The annualized rate of interest.`)),U(`redemption (number)`,P(`The redemption amount per 100 face value, or par.`)),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i={value:0}){let a=Math.trunc(L(e,this.locale)),o=Math.trunc(L(t,this.locale)),s=L(r,this.locale),c=L(n,this.locale),l=Math.trunc(L(i,this.locale));if(a<0)return new I(EX(a));if(a>=o)return new I(AX(a,o));if(aZ(l))return new I(pX(l));if(s<=0)return new I(JX(s));if(c<=0)return new I(qX(c));let u=Xa(a,o,l);return s*c*u},isExported:!0},aQ={description:P(`Depreciation for an accounting period.`),args:[U(`cost (number)`,P(`The initial cost of the asset.`)),U(`purchase_date (date)`,P(`The date the asset was purchased.`)),U(`first_period_end (date)`,P(`The date the first period ended.`)),U(`salvage (number)`,P(`The value of the asset at the end of depreciation.`)),U(`period (number)`,P(`The single period within life for which to calculate depreciation.`)),U(`rate (number)`,P(`The deprecation rate.`)),U(`day_count_convention (number, optional)`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=L(e,this.locale),c=Math.trunc(L(t,this.locale)),l=Math.trunc(L(n,this.locale)),u=L(r,this.locale),d=L(i,this.locale),f=L(a,this.locale),p=Math.trunc(L(o,this.locale));if(s<=0)return new I(dX(s));if(c<0)return new I(WX(c));if(u<0)return new I(YX(u));if(u>s)return new I(XX(u,s));if(d<0)return new I(LX(d));if(f<=0)return new I(qX(f));if(aZ(p))return new I(pX(p));if(c>l)return new I(UX(c,l));let m=d<1&&d>0?1:Math.trunc(d),h=s*f,g=Xa(c,l,p),_=c===l?h:h*g,v=s-_-h*m;return v>=u?m===0?_:h:u-v<h?h-(u-v):0},isExported:!0},oQ={description:P(`Days in coupon period containing settlement date.`),args:nQ,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(L(e,this.locale)),a=Math.trunc(L(t,this.locale)),o=Math.trunc(L(n,this.locale)),s=Math.trunc(L(r,this.locale));if(i>=a)return new I(AX(i,a));if(oZ(o))return new I(fX(o));if(aZ(s))return new I(pX(s));if(s===1){let i=dQ.compute.bind(this)(e,t,n,r).value,a=lQ.compute.bind(this)(e,t,n,r).value;return L(a,this.locale)-L(i,this.locale)}return(s===3?365:360)/o},isExported:!0},sQ={description:P(`Days from settlement until next coupon.`),args:nQ,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(L(e,this.locale)),a=Math.trunc(L(t,this.locale)),o=Math.trunc(L(n,this.locale)),s=Math.trunc(L(r,this.locale));if(i>=a)return new I(AX(i,a));if(oZ(o))return new I(fX(o));if(aZ(s))return new I(pX(s));let c=dQ.compute.bind(this)(e,t,n,r).value,l=L(c,this.locale);if([1,2,3].includes(s))return i-l;if(s===4){let e=Xa(l,i,s);return Math.round(e*360)}let u=qo(i,this.locale),d=qo(l,this.locale),f=d.getFullYear(),p=u.getFullYear(),m=d.getMonth()+1,h=u.getMonth()+1,g=d.getDate(),_=u.getDate();return m===2&&h===2&&qa(d)&&qa(u)&&(_=30),_===31&&(g===30||g===31)&&(_=30),m===2&&qa(d)&&(g=30),g===31&&(g=30),(p-f)*360+(h-m)*30+(_-g)},isExported:!0},cQ={description:P(`Days from settlement until next coupon.`),args:nQ,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(L(e,this.locale)),a=Math.trunc(L(t,this.locale)),o=Math.trunc(L(n,this.locale)),s=Math.trunc(L(r,this.locale));if(i>=a)return new I(AX(i,a));if(oZ(o))return new I(fX(o));if(aZ(s))return new I(pX(s));let c=lQ.compute.bind(this)(e,t,n,r).value,l=L(c,this.locale);if([1,2,3].includes(s))return l-i;if(s===4){let e=Xa(i,l,s);return Math.round(e*360)}let u=sQ.compute.bind(this)(e,t,n,r);return L(oQ.compute.bind(this)(e,t,n,r),this.locale)-L(u,this.locale)},isExported:!0},lQ={description:P(`Next coupon date after the settlement date.`),args:nQ,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(L(e,this.locale)),a=Math.trunc(L(t,this.locale)),o=Math.trunc(L(n,this.locale)),s=Math.trunc(L(r,this.locale));if(i>=a)return new I(AX(i,a));if(oZ(o))return new I(fX(o));if(aZ(s))return new I(pX(s));let c=12/o,l=uQ.compute.bind(this)(e,t,n,r);return{value:Wa(Ja(qo(a,this.locale),-(L(l,this.locale)-1)*c,!0)),format:this.locale.dateFormat}},isExported:!0},uQ={description:P(`Number of coupons between settlement and maturity.`),args:nQ,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(L(e,this.locale)),a=Math.trunc(L(t,this.locale)),o=Math.trunc(L(n,this.locale)),s=Math.trunc(L(r,this.locale));if(i>=a)return new I(AX(i,a));if(oZ(o))return new I(fX(o));if(aZ(s))return new I(pX(s));let c=1,l=a,u=12/o;for(;l>i;)l=Wa(Ja(qo(l,this.locale),-u,!1)),c++;return c-1},isExported:!0},dQ={description:P(`Last coupon date prior to or on the settlement date.`),args:nQ,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(L(e,this.locale)),a=Math.trunc(L(t,this.locale)),o=Math.trunc(L(n,this.locale)),s=Math.trunc(L(r,this.locale));if(i>=a)return new I(AX(i,a));if(oZ(o))return new I(fX(o));if(aZ(s))return new I(pX(s));let c=12/o,l=uQ.compute.bind(this)(e,t,n,r);return{value:Wa(Ja(qo(a,this.locale),-l*c,!0)),format:this.locale.dateFormat}},isExported:!0},fQ={description:P(`Cumulative interest paid over a set of periods.`),args:[U(`rate (number)`,P(`The interest rate.`)),U(`number_of_periods (number)`,P(`The number of payments to be made.`)),U(`present_value (number)`,P(`The current value of the annuity.`)),U(`first_period (number)`,P(`The number of the payment period to begin the cumulative calculation.`)),U(`last_period (number)`,P(`The number of the payment period to end the cumulative calculation.`)),U(`end_or_beginning (number, default=0)`,P(`The timing of the payment payments are due for each period.`),tQ)],compute:function(e,t,n,r,i,a={value:0}){let o=L(r,this.locale),s=L(i,this.locale),c=L(e,this.locale),l=L(n,this.locale),u=L(t,this.locale),d=+!!z(a);if(u<=0)return new I(PX(u));if(o<=0)return new I(CX(o));if(s<=0)return new I(OX(s));if(o>s)return new I(SX(o,s));if(s>u)return new I(DX(s,u));if(c<=0)return new I(qX(c));if(l<=0)return new I(VX(l));let f=0;for(let e=o;e<=s;e++)f+=EQ(c,e,u,l,0,d);return f},isExported:!0},pQ={description:P(`Cumulative principal paid over a set of periods.`),args:[U(`rate (number)`,P(`The interest rate.`)),U(`number_of_periods (number)`,P(`The number of payments to be made.`)),U(`present_value (number)`,P(`The current value of the annuity.`)),U(`first_period (number)`,P(`The number of the payment period to begin the cumulative calculation.`)),U(`last_period (number)`,P(`The number of the payment period to end the cumulative calculation.`)),U(`end_or_beginning (number, default=0)`,P(`The timing of the payment payments are due for each period.`),tQ)],compute:function(e,t,n,r,i,a={value:0}){let o=L(r,this.locale),s=L(i,this.locale),c=L(e,this.locale),l=L(n,this.locale),u=L(t,this.locale),d=+!!z(a);if(u<=0)return new I(PX(u));if(o<=0)return new I(CX(o));if(s<=0)return new I(OX(s));if(o>s)return new I(SX(o,s));if(s>u)return new I(DX(s,u));if(c<=0)return new I(qX(c));if(l<=0)return new I(VX(l));let f=0;for(let e=o;e<=s;e++)f+=BQ(c,e,u,l,0,d);return f},isExported:!0},mQ={description:P(`Depreciation via declining balance method.`),args:[U(`cost (number)`,P(`The initial cost of the asset.`)),U(`salvage (number)`,P(`The value of the asset at the end of depreciation.`)),U(`life (number)`,P(`The number of periods over which the asset is depreciated.`)),U(`period (number)`,P(`The single period within life for which to calculate depreciation.`)),U(`month (number, optional)`,P(`The number of months in the first year of depreciation.`))],compute:function(e,t,n,r,...i){let a=L(e,this.locale),o=L(t,this.locale),s=L(n,this.locale),c=Math.trunc(L(r,this.locale)),l=i.length?Math.trunc(L(i[0],this.locale)):12,u=s+(l===12?0:1);if(a<0)return new I(uX(a));if(o<0)return new I(YX(o));if(c<=0)return new I(BX(c));if(s<=0)return new I(kX(s));if(1>l||l>12)return new I(jX(l));if(c>u)return new I(IX(c,u));let d=l/12,f=1-(o/a)**(1/s);f=Math.round(f*1e3)/1e3;let p=a,m=a*(1-f*d);for(let e=1;e<c;e++)p=m,m=p*(1-f),e===s&&(m=p*(1-f*(1-d)));return{value:p-m,format:`#,##0.00`}},isExported:!0},hQ=`#,##0.00`,gQ={description:P(`Depreciation via double-declining balance method.`),args:[U(`cost (number)`,P(`The initial cost of the asset.`)),U(`salvage (number)`,P(`The value of the asset at the end of depreciation.`)),U(`life (number)`,P(`The number of periods over which the asset is depreciated.`)),U(`period (number)`,P(`The single period within life for which to calculate depreciation.`)),U(`factor (number, default=2)`,P(`The factor by which depreciation decreases.`))],compute:function(e,t,n,r,i={value:2}){let a=L(e,this.locale),o=L(t,this.locale),s=L(n,this.locale),c=L(r,this.locale),l=L(i,this.locale);if(a<0)return new I(uX(a));if(o<0)return new I(YX(o));if(c<=0)return new I(BX(c));if(s<=0)return new I(kX(s));if(c>s)return new I(zX(c,s));if(l<=0)return new I(mX(l));if(a===0||o>=a)return{value:0,format:hQ};let u=l/s;if(u>1)return{value:c===1?a-o:0,format:hQ};if(c<=1)return{value:a*u,format:hQ};let d=a*(1-u)**(c-1),f=a*(1-u)**c,p=f<o?d-o:d-f;return{value:Math.max(p,0),format:hQ}},isExported:!0},_Q={description:P(`Discount rate of a security based on price.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`price (number)`,P(`The price at which the security is bought per 100 face value.`)),U(`redemption (number)`,P(`The redemption amount per 100 face value, or par.`)),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(L(e,this.locale)),o=Math.trunc(L(t,this.locale)),s=L(n,this.locale),c=L(r,this.locale),l=Math.trunc(L(i,this.locale));if(a>=o)return new I(AX(a,o));if(aZ(l))return new I(pX(l));if(s<=0)return new I(HX(s));if(c<=0)return new I(JX(c));let u=Xa(a,o,l);return(c-s)/c/u},isExported:!0},vQ={description:P(`Convert a decimal fraction to decimal value.`),args:[U(`fractional_price (number)`,P(`The price quotation given using fractional decimal conventions.`)),U(`unit (number)`,P(`The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.`))],compute:function(e,t){let n=L(e,this.locale),r=Math.trunc(L(t,this.locale));if(r<=0)return new I(nZ(r));let i=Math.trunc(n);return i+(n-i)*(10**Math.ceil(Math.log10(r))/r)},isExported:!0},yQ={description:P(`Convert a decimal value to decimal fraction.`),args:[U(`decimal_price (number)`,P(`The price quotation given as a decimal value.`)),U(`unit (number)`,P(`The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.`))],compute:function(e,t){let n=L(e,this.locale),r=Math.trunc(L(t,this.locale));if(r<=0)return new I(nZ(r));let i=Math.trunc(n);return i+(n-i)*(r/10**Math.ceil(Math.log10(r)))},isExported:!0},bQ={description:P(`Number of periods for an investment to reach a value.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`rate (number)`,P(`The annualized rate of interest.`)),U(`yield (number)`,P(`The expected annual yield of the security.`)),U(`frequency (number)`,P(`The number of interest or coupon payments per year (1, 2, or 4).`),eQ),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i,a={value:0}){let o=Math.trunc(L(e,this.locale)),s=Math.trunc(L(t,this.locale)),c=L(n,this.locale),l=L(r,this.locale),u=Math.trunc(L(i,this.locale)),d=Math.trunc(L(a,this.locale));if(o>=s)return new I(AX(o,s));if(oZ(u))return new I(fX(u));if(aZ(d))return new I(pX(d));if(c<0)return new I(KX(c));if(l<0)return new I(rZ(l));let f=Xa(o,s,d),p=f-Math.trunc(f)||1/u,m=Math.ceil(f*u),h=c/u,g=l/u,_=0,v=0;for(let e=1;e<=m;e++){let t=(h+ +(e===m))/(1+g)**e;v+=(p+(e-1)/u)*t,_+=t}return _===0?0:v/_},isExported:!0},xQ={description:P(`Annual effective interest rate.`),args:[U(`nominal_rate (number)`,P(`The nominal interest rate per year.`)),U(`periods_per_year (number)`,P(`The number of compounding periods per year.`))],compute:function(e,t){let n=L(e,this.locale),r=Math.trunc(L(t,this.locale));return n<=0?new I(MX(n)):r<=0?new I(RX(r)):(1+n/r)**+r-1},isExported:!0};function SQ(e,t,n,r,i){return e===0?-(r+n*t):-r*(1+e)**t-n*(1+e*i)*((1+e)**t-1)/e}let CQ={description:P(`Future value of an annuity investment.`),args:[U(`rate (number)`,P(`The interest rate.`)),U(`number_of_periods (number)`,P(`The number of payments to be made.`)),U(`payment_amount (number)`,P(`The amount per period to be paid.`)),U(`present_value (number, default=0)`,P(`The current value of the annuity.`)),U(`end_or_beginning (number, default=0)`,P(`The timing of the payment payments are due for each period.`),tQ)],compute:function(e,t,n,r={value:0},i={value:0}){return r||=0,i||=0,{value:SQ(L(e,this.locale),L(t,this.locale),L(n,this.locale),L(r,this.locale),+!!z(i)),format:`#,##0.00`}},isExported:!0},wQ={description:P(`Future value of principal from series of rates.`),args:[U(`principal (number)`,P(`The amount of initial capital or value to compound against.`)),U(`rate_schedule (number, range<number>)`,P(`A series of interest rates to compound against the principal.`))],compute:function(e,t){let n=L(e,this.locale);return $o([t],(e,t)=>e*(1+L(t,this.locale)),n)},isExported:!0},TQ={description:P(`Calculates effective interest rate.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`investment (number)`,P(`The amount invested in the security.`)),U(`redemption (number)`,P(`The amount to be received at maturity.`)),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i={value:0}){let a=Math.trunc(L(e,this.locale)),o=Math.trunc(L(t,this.locale)),s=L(r,this.locale),c=L(n,this.locale),l=Math.trunc(L(i,this.locale));if(a>=o)return new I(AX(a,o));if(c<=0)return new I(TX(c));if(s<=0)return new I(JX(s));if(aZ(l))return new I(pX(l));let u=Xa(a,o,l);return(s-c)/c/u},isExported:!0};function EQ(e,t,n,r,i,a){return RQ(e,n,r,i,a)-BQ(e,t,n,r,i,a)}let DQ={description:P(`Payment on the principal of an investment.`),args:[U(`rate (number)`,P(`The annualized rate of interest.`)),U(`period (number)`,P(`The amortization period, in terms of number of periods.`)),U(`number_of_periods (number)`,P(`The number of payments to be made.`)),U(`present_value (number)`,P(`The current value of the annuity.`)),U(`future_value (number, default=0)`,P(`The future value remaining after the final payment has been made.`)),U(`end_or_beginning (number, default=0)`,P(`The timing of the payment payments are due for each period.`),tQ)],compute:function(e,t,n,r,i={value:0},a={value:0}){return{value:EQ(L(e,this.locale),L(t,this.locale),L(n,this.locale),L(r,this.locale),L(i,this.locale),+!!z(a)),format:`#,##0.00`}},isExported:!0},OQ=.1,kQ={description:P(`Internal rate of return given periodic cashflows.`),args:[U(`cashflow_amounts (number, range<number>)`,P(`An array or range containing the income or payments associated with the investment.`)),U(`rate_guess (number, default=${OQ})`,P(`An estimate for what the internal rate of return will be.`))],compute:function(e,t={value:OQ}){let n=L(t,this.locale);if(n<=-1)return new I(GX(n));let r=!1,i=!1,a=[];if(Zo([e],({value:e})=>{e>0&&(r=!0),e<0&&(i=!0),a.push(e)},this.locale),!r||!i)return new I(lX);let o=a.shift();function s(e,t,n){let r=n.length,i=0;return n.reduce((t,n)=>(i++,t+n*e**(r-i)),t*e**r)}function c(e,t,n){let r=n.length,i=0;return n.reduce((t,n)=>(i++,t+n*(r-i)*e**(r-i-1)),t*r*e**(r-1))}function l(e){return s(e,o,a)}function u(e){return c(e,o,a)}return{value:rQ(l,u,n+1,20,1e-5)-1,format:`0%`}},isExported:!0},AQ={description:P(`Returns the interest paid at a particular period of an investment.`),args:[U(`rate (number)`,P(`The interest rate.`)),U(`period (number)`,P(`The period for which you want to view the interest payment.`)),U(`number_of_periods (number)`,P(`The number of payments to be made.`)),U(`present_value (number)`,P(`The current value of the annuity.`))],compute:function(e,t,n,r){let i=L(e,this.locale),a=L(t,this.locale),o=L(n,this.locale),s=L(r,this.locale);return o===0?new I(NX(o)):-1*(s-a/o*s)*i},isExported:!0},jQ={description:P(`Modified Macaulay duration.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`rate (number)`,P(`The annualized rate of interest.`)),U(`yield (number)`,P(`The expected annual yield of the security.`)),U(`frequency (number)`,P(`The number of interest or coupon payments per year (1, 2, or 4).`),eQ),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`))],compute:function(e,t,n,r,i,a={value:0}){let o=bQ.compute.bind(this)(e,t,n,r,i,a),s=L(r,this.locale),c=Math.trunc(L(i,this.locale));return L(o,this.locale)/(1+s/c)},isExported:!0},MQ={description:P(`Modified internal rate of return.`),args:[U(`cashflow_amounts (range<number>)`,P(`A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.`)),U(`financing_rate (number)`,P(`The interest rate paid on funds invested.`)),U(`reinvestment_return_rate (number)`,P(`The return (as a percentage) earned on reinvestment of income received from the investment.`))],compute:function(e,t,n){let r=L(t,this.locale),i=L(n,this.locale),a=as(e).flat().filter(e=>e.value!==null).map(e=>L(e,this.locale)),o=a.length,s=0,c=0;for(let e of C(0,o)){let t=a[e];t>=0?s+=t*(i+1)**(o-e-1):c+=t/(r+1)**e}if(c===0||s===0)return new I(lX);let l=1/(o-1);return(-s/c)**l-1},isExported:!0},NQ={description:P(`Annual nominal interest rate.`),args:[U(`effective_rate (number)`,P(`The effective interest rate per year.`)),U(`periods_per_year (number)`,P(`The number of compounding periods per year.`))],compute:function(e,t){let n=L(e,this.locale),r=Math.trunc(L(t,this.locale));return n<=0?new I(vX(n)):r<=0?new I(RX(r)):((n+1)**(1/r)-1)*r},isExported:!0},PQ={description:P(`Number of payment periods for an investment.`),args:[U(`rate (number)`,P(`The interest rate.`)),U(`payment_amount (number)`,P(`The amount of each payment made.`)),U(`present_value (number)`,P(`The current value of the annuity.`)),U(`future_value (number, default=0)`,P(`The future value remaining after the final payment has been made.`)),U(`end_or_beginning (number, default=0)`,P(`The timing of the payment payments are due for each period.`),tQ)],compute:function(e,t,n,r={value:0},i={value:0}){r||=0,i||=0;let a=L(e,this.locale),o=L(t,this.locale),s=L(n,this.locale),c=L(r,this.locale),l=+!!z(i);if(a===0)return-(c+s)/o;let u=o*(1+a*l)/a;return Math.log((u-c)/(s+u))/Math.log(1+a)},isExported:!0};function FQ(e,t,n,r){let i=0;return es(n,(t,n)=>(i++,t+n/(1+e)**i),t,r)}let IQ={description:P(`The net present value of an investment based on a series of periodic cash flows and a discount rate.`),args:[U(`discount (number)`,P(`The discount rate of the investment over one period.`)),U(`cashflow (number, range<number>, repeating)`,P(`The future cash flows.`))],compute:function(e,...t){let n=L(e,this.locale);return n===-1?new I(hX(n)):{value:FQ(n,0,t,this.locale),format:`#,##0.00`}},isExported:!0},LQ={description:P(`Computes the number of periods needed for an investment to reach a value.`),args:[U(`rate (number)`,P(`The rate at which the investment grows each period.`)),U(`present_value (number)`,P(`The investment's current value.`)),U(`future_value (number)`,P(`The investment's desired future value.`))],compute:function(e,t,n){let r=L(e,this.locale),i=L(t,this.locale),a=L(n,this.locale);return r<=0?new I(qX(r)):i<=0?new I(VX(i)):a<=0?new I(wX(a)):(Math.log(a)-Math.log(i))/Math.log(1+r)},isExported:!0};function RQ(e,t,n,r,i){if(t<=0)throw new I(PX(t));if(e===0)return-(r+n)/t;let a=-(n*(1+e)**t+r);return a=a*e/((1+e*i)*((1+e)**t-1)),a}let zQ={description:P(`Periodic payment for an annuity investment.`),args:[U(`rate (number)`,P(`The annualized rate of interest.`)),U(`number_of_periods (number)`,P(`The number of payments to be made.`)),U(`present_value (number)`,P(`The current value of the annuity.`)),U(`future_value (number, default=0)`,P(`The future value remaining after the final payment has been made.`)),U(`end_or_beginning (number, default=0)`,P(`The timing of the payment payments are due for each period.`),tQ)],compute:function(e,t,n,r={value:0},i={value:0}){let a=L(t,this.locale),o=L(e,this.locale),s=+!!z(i),c=L(r,this.locale);return{value:RQ(o,a,L(n,this.locale),c,s),format:`#,##0.00`}},isExported:!0};function BQ(e,t,n,r,i,a){if(n<=0)throw new I(PX(n));if(t<=0||t>n)throw new I(FX(n));let o=RQ(e,n,r,i,a);return a===1&&t===1?o:o+-SQ(e,a===0?t-1:t-2,o,r+o*a,0)*e}let VQ={description:P(`Payment on the principal of an investment.`),args:[U(`rate (number)`,P(`The annualized rate of interest.`)),U(`period (number)`,P(`The amortization period, in terms of number of periods.`)),U(`number_of_periods (number)`,P(`The number of payments to be made.`)),U(`present_value (number)`,P(`The current value of the annuity.`)),U(`future_value (number, default=0)`,P(`The future value remaining after the final payment has been made.`)),U(`end_or_beginning (number, default=0)`,P(`The timing of the payment payments are due for each period.`),tQ)],compute:function(e,t,n,r,i={value:0},a={value:0}){let o=L(n,this.locale),s=L(e,this.locale),c=L(t,this.locale),l=+!!z(a),u=L(i,this.locale);return{value:BQ(s,c,o,L(r,this.locale),u,l),format:`#,##0.00`}},isExported:!0},HQ={description:P(`Present value of an annuity investment.`),args:[U(`rate (number)`,P(`The interest rate.`)),U(`number_of_periods (number)`,P(`The number of payments to be made.`)),U(`payment_amount (number)`,P(`The amount per period to be paid.`)),U(`future_value (number, default=0)`,P(`The future value remaining after the final payment has been made.`)),U(`end_or_beginning (number, default=0)`,P(`The timing of the payment payments are due for each period.`),tQ)],compute:function(e,t,n,r={value:0},i={value:0}){r||=0,i||=0;let a=L(e,this.locale),o=L(t,this.locale),s=L(n,this.locale),c=L(r,this.locale),l=+!!z(i);return{value:a?-(s*(1+a*l)*((1+a)**o-1)/a+c)/(1+a)**o:-(c+s*o),format:`#,##0.00`}},isExported:!0},UQ={description:P(`Price of a security paying periodic interest.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`rate (number)`,P(`The annualized rate of interest.`)),U(`yield (number)`,P(`The expected annual yield of the security.`)),U(`redemption (number)`,P(`The redemption amount per 100 face value, or par.`)),U(`frequency (number)`,P(`The number of interest or coupon payments per year (1, 2, or 4).`),eQ),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=Math.trunc(L(e,this.locale)),c=Math.trunc(L(t,this.locale)),l=L(n,this.locale),u=L(r,this.locale),d=L(i,this.locale),f=Math.trunc(L(a,this.locale)),p=Math.trunc(L(o,this.locale));if(s>=c)return new I(AX(s,c));if(oZ(f))return new I(fX(f));if(aZ(p))return new I(pX(p));if(l<0)return new I(KX(l));if(u<0)return new I(rZ(u));if(d<=0)return new I(JX(d));let m=Xa(s,c,p)*f,h=Math.ceil(m),g=m-Math.floor(m)||1,_=1+u/f,v=100*l/f;if(h===1)return(v+d)/(g*u/f+1)-v*(1-g);let ee=0;for(let e=1;e<=h;e++)ee+=v/_**(e-1+g);return d/_**(h-1+g)+ee-v*(1-g)},isExported:!0},WQ={description:P(`Price of a discount security.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`discount (number)`,P(`The discount rate of the security at time of purchase.`)),U(`redemption (number)`,P(`The redemption amount per 100 face value, or par.`)),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(L(e,this.locale)),o=Math.trunc(L(t,this.locale)),s=L(n,this.locale),c=L(r,this.locale),l=Math.trunc(L(i,this.locale));if(a>=o)return new I(AX(a,o));if(aZ(l))return new I(pX(l));if(s<=0)return new I(gX(s));if(c<=0)return new I(JX(c));let u=Xa(a,o,l);return c-s*c*u},isExported:!0},GQ={description:P(`Calculates the price of a security paying interest at maturity, based on expected yield.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`issue (date)`,P(`The date the security was initially issued.`)),U(`rate (number)`,P(`The annualized rate of interest.`)),U(`yield (number)`,P(`The expected annual yield of the security.`)),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i,a={value:0}){a||=0;let o=Math.trunc(L(e,this.locale)),s=Math.trunc(L(t,this.locale)),c=Math.trunc(L(n,this.locale)),l=L(r,this.locale),u=L(i,this.locale),d=Math.trunc(L(a,this.locale));if(o<=c)return new I($X(o,c));if(o>=s)return new I(AX(o,s));if(aZ(d))return new I(pX(d));if(l<0)return new I(KX(l));if(u<0)return new I(rZ(u));let f=Xa(o,s,d),p=Xa(o,c,d),m=100+Xa(c,s,d)*l*100,h=1+f*u,g=p*l*100;return m/h-g},isExported:!0},KQ=.1,qQ={description:P(`Interest rate of an annuity investment.`),args:[U(`number_of_periods (number)`,P(`The number of payments to be made.`)),U(`payment_per_period (number)`,P(`The amount per period to be paid.`)),U(`present_value (number)`,P(`The current value of the annuity.`)),U(`future_value (number, default=0)`,P(`The future value remaining after the final payment has been made.`)),U(`end_or_beginning (number, default=0)`,P(`The timing of the payment payments are due for each period.`),tQ),U(`rate_guess (number, default=${KQ})`,P(`An estimate for what the interest rate will be.`))],compute:function(e,t,n,r={value:0},i={value:0},a={value:KQ}){let o=L(e,this.locale),s=L(t,this.locale),c=+!!z(i),l=L(a,this.locale)||KQ,u=L(r,this.locale),d=L(n,this.locale);return o<=0?new I(PX(o)):iZ([s,d,u])?l<=-1?new I(GX(l)):(u-=s*c,d+=s*c,{value:rQ(e=>{let t=(1+e)**+o,n=(t-1)/e;return u+d*t+s*n},e=>{let t=(1+e)**(o-1),n=((1+e)**+o-1)/e,r=o*t/e-n/e;return d*o*t+s*r},l,40,1e-5),format:`0%`}):new I(P(`There must be both positive and negative values in [payment_amount, present_value, future_value].`))},isExported:!0},JQ={description:P(`Amount received at maturity for a security.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`investment (number)`,P(`The amount invested (irrespective of face value of each security).`)),U(`discount (number)`,P(`The discount rate of the security invested in.`)),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(L(e,this.locale)),o=Math.trunc(L(t,this.locale)),s=L(n,this.locale),c=L(r,this.locale),l=Math.trunc(L(i,this.locale));return a>=o?new I(AX(a,o)):aZ(l)?new I(pX(l)):s<=0?new I(TX(s)):c<=0?new I(gX(c)):s/(1-c*Xa(a,o,l))},isExported:!0},YQ={description:P(`Computes the rate needed for an investment to reach a specific value within a specific number of periods.`),args:[U(`number_of_periods (number)`,P(`The number of periods.`)),U(`present_value (number)`,P(`The present value of the investment.`)),U(`future_value (number)`,P(`The future value of the investment.`))],compute:function(e,t,n){let r=L(e,this.locale),i=L(t,this.locale),a=L(n,this.locale);return r<=0?new I(PX(r)):(a/i)**(1/r)-1},isExported:!0},XQ={description:P(`Depreciation of an asset using the straight-line method.`),args:[U(`cost (number)`,P(`The initial cost of the asset.`)),U(`salvage (number)`,P(`The value of the asset at the end of depreciation.`)),U(`life (number)`,P(`The number of periods over which the asset is depreciated.`))],compute:function(e,t,n){let r=L(e,this.locale),i=L(t,this.locale),a=L(n,this.locale);return{value:(r-i)/a,format:`#,##0.00`}},isExported:!0},ZQ={description:P(`Depreciation via sum of years digit method.`),args:[U(`cost (number)`,P(`The initial cost of the asset.`)),U(`salvage (number)`,P(`The value of the asset at the end of depreciation.`)),U(`life (number)`,P(`The number of periods over which the asset is depreciated.`)),U(`period (number)`,P(`The single period within life for which to calculate depreciation.`))],compute:function(e,t,n,r){let i=L(e,this.locale),a=L(t,this.locale),o=L(n,this.locale),s=L(r,this.locale);if(s<=0)return new I(BX(s));if(o<=0)return new I(kX(o));if(s>o)return new I(zX(s,o));let c=o*(o+1)/2,l=o-s+1;return{value:(i-a)*(l/c),format:`#,##0.00`}},isExported:!0};function QQ(e,t,n){return 100*(1-n*Xa(e,t,2))}let $Q={description:P(`Price of a US Treasury bill.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`discount (number)`,P(`The discount rate of the bill at time of purchase.`))],compute:function(e,t,n){let r=Math.trunc(L(e,this.locale)),i=Math.trunc(L(t,this.locale)),a=L(n,this.locale);return r>=i?new I(AX(r,i)):sZ(r,i,this.locale)?a<=0?new I(gX(a)):a>=1?new I(_X(a)):QQ(r,i,a):new I(QX(r,i))},isExported:!0},e$={description:P(`Equivalent rate of return for a US Treasury bill.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`discount (number)`,P(`The discount rate of the bill at time of purchase.`))],compute:function(e,t,n){let r=Math.trunc(L(e,this.locale)),i=Math.trunc(L(t,this.locale)),a=L(n,this.locale);if(r>=i)return new I(AX(r,i));if(!sZ(r,i,this.locale))return new I(QX(r,i));if(a<=0)return new I(gX(a));if(a>=1)return new I(_X(a));let o=hZ.compute.bind(this)({value:i},{value:r});if(o<=182)return 365*a/(360-a*o);let s=QQ(r,i,a)/100,c=o/(o===366?366:365);return(-2*c+2*Math.sqrt(c**2-(2*c-1)*(1-1/s)))/(2*c-1)},isExported:!0},t$={description:P(`The yield of a US Treasury bill based on price.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`price (number)`,P(`The price at which the security is bought per 100 face value.`))],compute:function(e,t,n){let r=Math.trunc(L(e,this.locale)),i=Math.trunc(L(t,this.locale)),a=L(n,this.locale);if(r>=i)return new I(AX(r,i));if(!sZ(r,i,this.locale))return new I(QX(r,i));if(a<=0)return new I(HX(a));let o=Xa(r,i,2);return(100-a)/a*(1/o)},isExported:!0},n$={description:P(`Variable declining balance. WARNING : does not handle decimal periods.`),args:[U(`cost (number)`,P(`The initial cost of the asset.`)),U(`salvage (number)`,P(`The value of the asset at the end of depreciation.`)),U(`life (number)`,P(`The number of periods over which the asset is depreciated.`)),U(`start (number)`,P(`Starting period to calculate depreciation.`)),U(`end (number)`,P(`Ending period to calculate depreciation.`)),U(`factor (number, default=2)`,P(`The number of months in the first year of depreciation.`)),U(`no_switch (number, default=false)`,P(`Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation.`),[{value:!1,label:P(`Switch to straight-line depreciation`)},{value:!0,label:P(`Do not switch to straight-line depreciation`)}])],compute:function(e,t,n,r,i,a={value:2},o={value:!1}){a||=0;let s=L(e,this.locale),c=L(t,this.locale),l=L(n,this.locale),u=Math.trunc(L(r,this.locale)),d=Math.trunc(L(i,this.locale)),f=L(a,this.locale),p=z(o);if(s<0)return new I(uX(s));if(c<0)return new I(YX(c));if(l<=0)return new I(kX(l));if(u<0)return new I(eZ(u));if(d<0)return new I(yX(d));if(u>d)return new I(tZ(u,d));if(d>l)return new I(bX(d,l));if(f<=0)return new I(mX(f));if(s===0)return 0;if(c>=s)return u<1?s-c:0;let m=f/l;if(m>=1)return u<1?s-c:0;let h=s,g=0,_=0,v=!1;for(let e=0;e<d;e++){if(!v||p){let t=h*m,n=l-e,r=(h-c)/n;!p&&r>t?(v=!0,g=r):g=t}let t=Math.max(h-g,c);e>=u&&(_+=h-t),h=t}return _},isExported:!0},r$={description:P(`Internal rate of return given non-periodic cash flows.`),args:[U(`cashflow_amounts (range<number>)`,P(`An range containing the income or payments associated with the investment.`)),U(`cashflow_dates (range<number>)`,P(`An range with dates corresponding to the cash flows in cashflow_amounts.`)),U(`rate_guess (number, default=${KQ})`,P(`An estimate for what the internal rate of return will be.`))],compute:function(e,t,n={value:KQ}){let r=L(n,this.locale);if(!lS(e,t))return new I(cX);let i=e.flat().map(e=>L(e,this.locale)),a=t.flat().map(e=>L(e,this.locale));if(!iZ(i))return new I(lX);if(a.some(e=>e<a[0]))return new I(xX(a[0]));if(r<=-1)return new I(GX(r));let o=new Map;for(let e of C(0,a.length)){let t=a[e];o.has(t)?o.set(t,o.get(t)+i[e]):o.set(t,i[e])}let s=Array.from(o.keys()),c=s.map(e=>o.get(e));return rQ(e=>{let t=c[0];for(let n of C(1,c.length)){let r=(s[0]-s[n])/365;t+=c[n]*(1+e)**r}return t},e=>{let t=0;for(let n of C(1,c.length)){let r=(s[0]-s[n])/365;t+=r*c[n]*(1+e)**(r-1)}return t},r,40,1e-5,e=>e?e/10-.9:-.9)},isExported:!0},i$={description:P(`Net present value given to non-periodic cash flows..`),args:[U(`discount (number)`,P(`The discount rate of the investment over one period.`)),U(`cashflow_amounts (number, range<number>)`,P(`An range containing the income or payments associated with the investment.`)),U(`cashflow_dates (number, range<number>)`,P(`An range with dates corresponding to the cash flows in cashflow_amounts.`))],compute:function(e,t,n){let r=L(e,this.locale);if(!lS(t,n))return new I(cX);let i=B(t).flat().map(e=>Vo(e,this.locale)),a=B(n).flat().map(e=>Vo(e,this.locale));if(a.some(e=>e<a[0]))return new I(xX(a[0]));if(r<=0)return new I(qX(r));if(i.length===1)return i[0];let o=new Map;for(let e of C(0,a.length)){let t=a[e];o.has(t)?o.set(t,o.get(t)+i[e]):o.set(t,i[e])}let s=Array.from(o.keys()),c=s.map(e=>o.get(e)),l=c[0];for(let e of C(1,c.length)){let t=(s[0]-s[e])/365;l+=c[e]*(1+r)**t}return l},isExported:!0},a$={description:P(`Annual yield of a security paying periodic interest.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`rate (number)`,P(`The annualized rate of interest.`)),U(`price (number)`,P(`The price at which the security is bought per 100 face value.`)),U(`redemption (number)`,P(`The redemption amount per 100 face value, or par.`)),U(`frequency (number)`,P(`The number of interest or coupon payments per year (1, 2, or 4).`),eQ),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=Math.trunc(L(e,this.locale)),c=Math.trunc(L(t,this.locale)),l=L(n,this.locale),u=L(r,this.locale),d=L(i,this.locale),f=Math.trunc(L(a,this.locale)),p=Math.trunc(L(o,this.locale));if(s>=c)return new I(AX(s,c));if(oZ(f))return new I(fX(f));if(aZ(p))return new I(pX(p));if(l<0)return new I(KX(l));if(u<=0)return new I(HX(u));if(d<=0)return new I(JX(d));let m=Xa(s,c,p)*f,h=Math.ceil(m),g=m-Math.floor(m)||1,_=100*l/f;if(h===1){let e=u+_*(1-g);return(d+_-e)*f*(1/g)/e}function v(e,t,n,r,i,a){let o=a-(e+i*(1-t))*r**(n-1+t);for(let e=1;e<=n;e++)o+=i*r**(e-1);return o}function ee(e,t,n,r,i){let a=-(e+i*(1-t))*(n-1+t)*r**(n-2+t);for(let e=1;e<=n;e++)a+=i*(e-1)*r**(e-2);return a}function y(e){return v(u,g,h,e,_,d)}function b(e){return ee(u,g,h,e,_)}return(rQ(y,b,1+(l+1)/f,100,1e-5)-1)*f},isExported:!0},o$={description:P(`Annual yield of a discount security.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`price (number)`,P(`The price at which the security is bought per 100 face value.`)),U(`redemption (number)`,P(`The redemption amount per 100 face value, or par.`)),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(L(e,this.locale)),o=Math.trunc(L(t,this.locale)),s=L(n,this.locale),c=L(r,this.locale),l=Math.trunc(L(i,this.locale));if(a>=o)return new I(AX(a,o));if(aZ(l))return new I(pX(l));if(s<=0)return new I(HX(s));if(c<=0)return new I(JX(c));let u=Xa(a,o,l);return(c/s-1)/u},isExported:!0},s$={description:P(`Annual yield of a security paying interest at maturity.`),args:[U(`settlement (date)`,P(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),U(`maturity (date)`,P(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),U(`issue (date)`,P(`The date the security was initially issued.`)),U(`rate (number)`,P(`The annualized rate of interest.`)),U(`price (number)`,P(`The price at which the security is bought.`)),U(`day_count_convention (number, default=0 )`,P(`An indicator of what day count method to use.`),cZ)],compute:function(e,t,n,r,i,a={value:0}){a||=0;let o=Math.trunc(L(e,this.locale)),s=Math.trunc(L(t,this.locale)),c=Math.trunc(L(n,this.locale)),l=L(r,this.locale),u=L(i,this.locale),d=Math.trunc(L(a,this.locale));if(o>=s)return new I(AX(o,s));if(aZ(d))return new I(pX(d));if(o<c)return new I(ZX(o,c));if(l<0)return new I(KX(l));if(u<=0)return new I(HX(u));let f=Xa(c,s,d),p=Xa(c,o,d),m=Xa(o,s,d);return(100*(1+l*f)/(u+100*l*p)-1)/m},isExported:!0};var c$=l({CELL:()=>u$,ISBLANK:()=>v$,ISERR:()=>d$,ISERROR:()=>f$,ISFORMULA:()=>b$,ISLOGICAL:()=>p$,ISNA:()=>m$,ISNONTEXT:()=>h$,ISNUMBER:()=>g$,ISTEXT:()=>_$,NA:()=>y$});let l$=[{value:`address`,label:P(`Returns an absolute reference as plain text of the top left cell in reference.`)},{value:`col`,label:P(`Returns the column number of the cell in reference.`)},{value:`contents`,label:P(`Returns the value contained in the top left cell in reference.`)},{value:`format`,label:P(`Returns the format of the top left cell in reference.`)},{value:`row`,label:P(`Returns the row number of the top left cell in reference.`)},{value:`type`,label:P(`Returns the type of data in the cell in reference. The following values are returned: "b" for a blank cell, "l" (for label) if the cell contains plain text, and "v" (for value) if the cell contains any other type of data.`)}],u$={description:P(`Gets information about a cell.`),args:[U(`info_type (string)`,P(`The type of information requested.`),l$),U(`reference (any, range<any>)`,P(`The reference to the cell.`))],compute:function(e,t){let n=R(e).toLowerCase();if(!l$.map(e=>e.value).includes(n))return new I(P(`The info_type should be one of %s.`,l$.join(`, `)));let r=B(t)[0][0],i=r.position;if(i===void 0)return new I(P(`The reference is invalid.`));switch(n){case`address`:return(this.__originSheetId===i.sheetId?``:this.getters.getSheetName(i.sheetId)+`!`)+E(i.col,i.row,{colFixed:!0,rowFixed:!0});case`col`:return i.col+1;case`contents`:return r.value;case`format`:return r.format||``;case`row`:return i.row+1;case`type`:return r.value===null?`b`:Pc(r.format)?`l`:typeof r.value==`number`||typeof r.value==`boolean`?`v`:`l`}return``},isExported:!0},d$={description:P(`Whether a value is an error other than #N/A.`),args:[U(`value (any)`,P(`The value to be verified as an error type.`))],compute:function(e){let t=e?.value;return No(t)&&t!==F.NotAvailable},isExported:!0},f$={description:P(`Whether a value is an error.`),args:[U(`value (any)`,P(`The value to be verified as an error type.`))],compute:function(e){let t=e?.value;return No(t)},isExported:!0},p$={description:P("Whether a value is `true` or `false`."),args:[U(`value (any)`,P(`The value to be verified as a logical TRUE or FALSE.`))],compute:function(e){return typeof e?.value==`boolean`},isExported:!0},m$={description:P(`Whether a value is the error #N/A.`),args:[U(`value (any)`,P(`The value to be verified as an error type.`))],compute:function(e){return e?.value===F.NotAvailable},isExported:!0},h$={description:P(`Whether a value is non-textual.`),args:[U(`value (any)`,P(`The value to be checked.`))],compute:function(e){return!_$.compute.bind(this)(e)},isExported:!0},g$={description:P(`Whether a value is a number.`),args:[U(`value (any)`,P(`The value to be verified as a number.`))],compute:function(e){return typeof e?.value==`number`},isExported:!0},_$={description:P(`Whether a value is text.`),args:[U(`value (any)`,P(`The value to be verified as text.`))],compute:function(e){return typeof e?.value==`string`&&No(e?.value)===!1},isExported:!0},v$={description:P(`Whether the referenced cell is empty`),args:[U(`value (any)`,P(`Reference to the cell that will be checked for emptiness.`))],compute:function(e){return e?.value===null},isExported:!0},y$={description:P(`Returns the error value #N/A.`),args:[],compute:function(){return{value:F.NotAvailable}},isExported:!0},b$={description:P(`Checks whether there is a reference to a cell that contains a formula, and returns TRUE or FALSE.`),args:[U(`cell_reference (any)`,P(`A reference to a cell.`))],compute:function(e){return e?.position===void 0?new To(Io):this.getters.getCell(e.position)?.isFormula??!1},isExported:!0};var x$=l({AND:()=>S$,FALSE:()=>C$,IF:()=>w$,IFERROR:()=>T$,IFNA:()=>E$,IFS:()=>D$,NOT:()=>O$,OR:()=>k$,SWITCH:()=>A$,TRUE:()=>j$,XOR:()=>M$});let S$={description:P("Logical `and` operator."),args:[U(`logical_expression (boolean, range<boolean>, repeating)`,P(`Expression or reference to a cell containing a logical value (TRUE/FALSE) or an expression that can be coerced to a logical value.`))],compute:function(...e){let{result:t,foundBoolean:n}=nS(e);return n?t:new I(ys)},isExported:!0},C$={description:P("Logical value `false`."),args:[],compute:function(){return!1},isExported:!0},w$={description:P(`Returns value depending on logical expression.`),args:[U(`logical_expression (boolean, range<boolean>)`,P(`An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.`)),U(`value_if_true (any, range)`,P(`The value the function returns if logical_expression is TRUE.`)),U(`value_if_false (any, range, default=FALSE)`,P(`The value the function returns if logical_expression is FALSE.`))],compute:function(e,t,n){return vS(e)?qc(this,il.get(`IF`),[e,t,n]):(z(gS(e))?t:n)??{value:0}},isExported:!0},T$={description:P(`Value if it is not an error, otherwise 2nd argument.`),args:[U(`value (any, range)`,P(`The value to return if value itself is not an error.`)),U(`value_if_error (any, range, default="empty")`,P(`The value the function returns if value is an error.`))],compute:function(e,t){return vS(e)?qc(this,il.get(`IFERROR`),[e,t]):(No(gS(e)?.value)?t:e)??{value:0}},isExported:!0},E$={description:P(`Value if it is not an #N/A error, otherwise 2nd argument.`),args:[U(`value (any, range)`,P(`The value to return if value itself is not #N/A an error.`)),U(`value_if_error (any, range, default="empty")`,P(`The value the function returns if value is an #N/A error.`))],compute:function(e,t){return vS(e)?qc(this,il.get(`IFNA`),[e,t]):(gS(e)?.value===F.NotAvailable?t:e)??{value:0}},isExported:!0},D$={description:P(`Returns a value depending on multiple logical expressions.`),args:[U(`condition (any, range, repeating)`,P(`The condition to be evaluated. It can be a boolean, a number, an array, or a reference to any of those.`)),U(`value (any, range, repeating)`,P(`The value to be returned if its corresponding condition is TRUE.`))],compute:function(...e){if(e.length%2!=0)return new I(P(`Wrong number of arguments. Expected an even number of arguments.`));for(;e.length>0;){if(vS(e[0]))return qc(this,il.get(`IFS`),e);let t=z(gS(e.shift())),n=e.shift();if(t)return n??{value:0}}return new I(P(`No match.`))},isExported:!0},O$={description:P(`Returns opposite of provided logical value.`),args:[U(`logical_expression (boolean)`,P(`An expression or reference to a cell holding an expression that represents some logical value.`))],compute:function(e){return!z(e)},isExported:!0},k$={description:P("Logical `or` operator."),args:[U(`logical_expression (boolean, range<boolean>, repeating)`,P(`Expression or reference to a cell containing a logical value (TRUE/FALSE) or an expression that can be coerced to a logical value.`))],compute:function(...e){let{result:t,foundBoolean:n}=rS(e);return n?t:new I(ys)},isExported:!0},A$={description:P(`Returns a value by comparing cases to an expression.`),args:[U(`expression (number, boolean, string)`,P(`The value to be checked.`)),U(`case (any, repeating)`,P(`Case to be checked against expression.`)),U(`value (any, repeating)`,P(`Value to be returned if its corresponding case matches expression.`)),U(`default (any, default="empty")`,P(`An optional default value to be returned if none of the cases match expression.`))],compute:function(e,...t){let n=t.length%2==0?Po(e):t.pop();for(let n=0;n<t.length;n+=2){let r=t[n];if(r&&No(r.value))return r;if(e?.value===r?.value)return t[n+1]||{value:0}}return n||{value:0}},isExported:!0},j$={description:P("Logical value `true`."),args:[],compute:function(){return!0},isExported:!0},M$={description:P("Logical `xor` operator."),args:[U(`logical_expression (boolean, range<boolean>, repeating)`,P(`Expression or reference to a cell containing a logical value (TRUE/FALSE) or an expression that can be coerced to a logical value.`))],compute:function(...e){let t=!1,n=!1;return ss(e,e=>(t=!0,n=n?!e:e,!0)),t?n:new I(ys)},isExported:!0};function N$(e,t){let n=t.getPivotId(e);if(!n)throw new I(P(`There is no pivot with id "%s"`,e));return n}function P$(e,t,n){let{measures:r}=n.getPivotCoreDefinition(e);if(!r.find(e=>e.id===t))throw new I(P(`The argument %s is not a valid measure. Here are the measures: %s`,t,`(${r.map(e=>e.id).join(`, `)})`))}function F$(e){if(e.length%2!=0)throw new I(P(`Function PIVOT takes an even number of arguments.`))}function I$(e,t,n){let r=[],i=e.getters.getPivotCoreDefinition(t);if(i.type===`SPREADSHEET`&&i.dataSet){let{sheetId:t,zone:n}=i.dataSet,a=Jn(n),o=e.getters.getRangeFromSheetXC(t,a);if(o===void 0||o.invalidXc||o.invalidSheetName)throw new To;if(e.__originCellPosition&&o.sheetId===e.__originSheetId&&or(O(e.__originCellPosition),n))throw new wo;r.push(o)}for(let i of n)i.computedBy&&r.push(...e.getters.getMeasureFullDependencies(t,i));let a=e.__originCellPosition;a&&r.length&&(e.updateDependencies?.(a),e.addDependencies?.(a,r))}var L$=l({ADDRESS:()=>B$,CHOOSE:()=>r1,COLUMN:()=>V$,COLUMNS:()=>H$,DROP:()=>i1,FORMULATEXT:()=>o1,HLOOKUP:()=>U$,INDEX:()=>W$,INDIRECT:()=>G$,LOOKUP:()=>K$,MATCH:()=>q$,OFFSET:()=>n1,PIVOT:()=>t1,PIVOT_HEADER:()=>e1,PIVOT_VALUE:()=>$$,ROW:()=>J$,ROWS:()=>Y$,TAKE:()=>a1,VLOOKUP:()=>X$,XLOOKUP:()=>Q$});let R$=[{value:!0,label:P(`A1 style (default)`)},{value:!1,label:P(`R1C1 style`)}],z$=[{value:!0,label:P(`Approximate match (default)`)},{value:!1,label:P(`Exact match`)}],B$={description:P(`Returns a cell reference as a string. `),args:[U(`row (number)`,P(`The row number of the cell reference. `)),U(`column (number)`,P(`The column number (not name) of the cell reference. A is column number 1. `)),U(`absolute_relative_mode (number, default=1)`,P(`An indicator of whether the reference is row/column absolute.`),[{value:1,label:P(`Absolute row and column (e.g. $A$1)`)},{value:2,label:P(`Absolute row, relative column (e.g. A$1)`)},{value:3,label:P(`Relative row, absolute column (e.g. $A1)`)},{value:4,label:P(`Relative row and column (e.g. A1)`)}]),U(`use_a1_notation (boolean, default=TRUE)`,P(`A boolean indicating whether to use A1 style notation or R1C1 style notation.`),R$),U(`sheet (string, optional)`,P(`A string indicating the name of the sheet into which the address points.`))],compute:function(e,t,n={value:1},r={value:!0},i){let a=Uo(e,this.locale),o=Uo(t,this.locale);if(a<1)return new I(dS(a));if(o<1)return new I(dS(o));let s=Uo(n,this.locale);if(![1,2,3,4].includes(s))return new I(Lo(1,4,s));let c=z(r),l;if(c){let e={rowFixed:[1,2].includes(s),colFixed:[1,3].includes(s)};l=E(o-1,a-1,e)}else l=([1,2].includes(s)?`R${a}`:`R[${a}]`)+([1,3].includes(s)?`C${o}`:`C[${o}]`);return i===void 0?l:vl(R(i),l)},isExported:!0},V$={description:P(`Column number of a specified cell.`),args:[U(`cell_reference (any, range<any>, default='this cell')`,P(`The cell whose column number will be returned. Column A corresponds to 1. By default, the function use the cell in which the formula is entered.`))],compute:function(e){if(e===void 0)return this.__originCellPosition===void 0?new I(P(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):this.__originCellPosition.col+1;let t=B(e),n=t[0][0];if(n===void 0)return new I(P(`The range is out of bounds.`));if(n.position===void 0)return new To(Io);let r=n.position.col;return t.length===1?r+1:ns(t.length,1,e=>({value:r+e+1}))},isExported:!0},H$={description:P(`Number of columns in a specified array or range.`),args:[U(`range (any, range<any>)`,P(`The range whose column count will be returned.`))],compute:function(e){let t=B(e);return t[0][0]===void 0?new I(P(`The range is out of bounds.`)):t[0][0].value===F.InvalidReference?t[0][0]:t.length},isExported:!0},U$={description:P(`Horizontal lookup`),args:[U(`search_key (string, number, boolean)`,P(`The value to search for. For example, 42, 'Cats', or I24.`)),U(`range (any, range)`,P(`The range to consider for the search. The first row in the range is searched for the key specified in search_key.`)),U(`index (number)`,P(`The row index of the value to be returned, where the first row in range is numbered 1.`)),U(`is_sorted (boolean, default=true)`,P(`Indicates whether the row to be searched (the first row of the specified range) is sorted, in which case the closest match for search_key will be returned.`),z$)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(L(n?.value,this.locale)),a=B(t);if(1>i||i>a[0].length)return new I(P(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[t][0].value,s=a[z(r.value)?fs(a,e,`nextSmaller`,`asc`,a.length,o):ps(a,e,`wildcard`,a.length,o,this.lookupCaches)];return s===void 0?Po(e):s[i-1]},isExported:!0},W$={description:P(`Returns the content of a cell, specified by row and column offset.`),args:[U(`reference (any, range)`,P(`The range of cells from which the values are returned.`)),U(`row (number, default=0)`,P(`The index of the row to be returned from within the reference range of cells.`)),U(`column (number, default=0)`,P(`The index of the column to be returned from within the reference range of cells.`))],compute:function(e,t={value:0},n={value:0}){let r=B(e),i=L(t.value,this.locale),a=L(n.value,this.locale);return a<0||a-1>=r.length||i<0||i-1>=r[0].length?new I(P(`Index out of range.`)):i===0&&a===0?r:i===0?[r[a-1]]:a===0?r.map(e=>[e[i-1]]):r[a-1][i-1]},isExported:!0},G$={description:P(`Returns the content of a cell, specified by a string.`),args:[U(`reference (string)`,P(`The range of cells from which the values are returned.`)),U(`use_a1_notation (boolean, default=TRUE)`,P(`A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).`),R$)],compute:function(e,t={value:!0}){let n=e?.value?.toString();if(!n)return new To(P(`Reference should be defined.`));if(!z(t))return new I(P(`R1C1 notation is not supported.`));let r=this.__originSheetId,i=this.__originCellPosition;i&&this.updateDependencies?.(i);let a=this.getters.getNamedRange(n),o=a?a.range:this.getters.getRangeFromSheetXC(r,n);if(o===void 0||o.invalidXc||o.invalidSheetName)return new To;i&&this.addDependencies?.(i,[o]);let s=[];for(let e=o.zone.left;e<=o.zone.right;e++){let t=[];for(let n=o.zone.top;n<=o.zone.bottom;n++){let r={sheetId:o.sheetId,col:e,row:n};t.push(this.getFormulaResult(r))}s.push(t)}return s.length===1&&s[0].length===1?s[0][0]:s},isExported:!0},K$={description:P(`Look up a value.`),args:[U(`search_key (string, number, boolean)`,P(`The value to search for. For example, 42, 'Cats', or I24.`)),U(`search_array (any, range)`,P(`One method of using this function is to provide a single sorted row or column search_array to look through for the search_key with a second argument result_range. The other way is to combine these two arguments into one search_array where the first row or column is searched and a value is returned from the last row or column in the array. If search_key is not found, a non-exact match may be returned.`)),U(`result_range (any, range, optional)`,P(`The range from which to return a result. The value returned corresponds to the location where search_key is found in search_range. This range must be only a single row or column and should not be used if using the search_result_array method.`))],compute:function(e,t,n){let r=B(t),i=B(n),a=r.length,o=r[0].length,s=o>=a,c=fs(r,e,`nextSmaller`,`asc`,s?o:a,s?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value);return c===-1||s&&r[0][c]===void 0||!s&&r[c][o-1]===void 0?Po(e):i[0].length===0?s?r[a-1][c]:r[c][o-1]:(a=i.length,o=i[0].length,a!==1&&o!==1?new I(P(`The result_range must be a single row or a single column.`)):a>1?c>a-1?new I(P(`[[FUNCTION_NAME]] evaluates to an out of range row value %s.`,c+1)):i[c][0]:c>o-1?new I(P(`[[FUNCTION_NAME]] evaluates to an out of range column value %s.`,c+1)):i[0][c])},isExported:!0},q$={description:P(`Position of item in range that matches value.`),args:[U(`search_key (string, number, boolean)`,P(`The value to search for. For example, 42, 'Cats', or I24.`)),U(`range (any, range)`,P(`The one-dimensional array to be searched.`)),U(`search_type (number, default=1)`,P(`The search method is a number 1, 0 or -1 indicating which value to return. 1 finds the largest value less than or equal to search_key when range is sorted in ascending order. 0 finds the exact value when range is unsorted. -1 finds the smallest value greater than or equal to search_key when range is sorted in descending order.`),[{value:1,label:P(`Ascending order (default)`)},{value:0,label:P(`Exact match`)},{value:-1,label:P(`Descending order`)}])],compute:function(e,t,n={value:1}){let r=L(n,this.locale),i=B(t),a=i.length,o=i[0].length;if(a!==1&&o!==1)return new I(P(`The range must be a single row or a single column.`));let s=-1,c=a===1?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,l=a===1?i[0].length:i.length;switch(r=Math.sign(r),r){case 1:s=fs(i,e,`nextSmaller`,`asc`,l,c);break;case 0:s=ps(i,e,`wildcard`,l,c,this.lookupCaches);break;case-1:s=fs(i,e,`nextGreater`,`desc`,l,c);break}return a===1&&i[0][s]===void 0||a!==1&&i[s]===void 0?Po(e):s+1},isExported:!0},J$={description:P(`Row number of a specified cell.`),args:[U(`cell_reference (any, range<any>, default='this cell')`,P(`The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered.`))],compute:function(e){if(e===void 0)return this.__originCellPosition?.row===void 0?new I(P(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):this.__originCellPosition.row+1;let t=B(e),n=t[0][0];if(n===void 0)return new I(P(`The range is out of bounds.`));if(n.position===void 0)return new To(Io);let r=n.position.row;return t[0].length===1?r+1:ns(1,t[0].length,(e,t)=>({value:r+t+1}))},isExported:!0},Y$={description:P(`Number of rows in a specified array or range.`),args:[U(`range (any, range<any>)`,P(`The range whose row count will be returned.`))],compute:function(e){let t=B(e);return t[0][0]===void 0?new I(P(`The range is out of bounds.`)):t[0][0].value===F.InvalidReference?t[0][0]:t[0].length},isExported:!0},X$={description:P(`Vertical lookup.`),args:[U(`search_key (string, number, boolean)`,P(`The value to search for. For example, 42, 'Cats', or I24.`)),U(`range (any, range)`,P(`The range to consider for the search. The first column in the range is searched for the key specified in search_key.`)),U(`index (number)`,P(`The column index of the value to be returned, where the first column in range is numbered 1.`)),U(`is_sorted (boolean, default=true)`,P(`Indicates whether the column to be searched (the first column of the specified range) is sorted, in which case the closest match for search_key will be returned.`),z$)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(L(n?.value,this.locale)),a=B(t);if(1>i||i>a.length)return new I(P(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[0][t].value,s=z(r.value)?fs(a,e,`nextSmaller`,`asc`,a[0].length,o):ps(a,e,`wildcard`,a[0].length,o,this.lookupCaches),c=a[i-1][s];return c===void 0?Po(e):c},isExported:!0},Z$={0:`strict`,1:`nextGreater`,"-1":`nextSmaller`,2:`wildcard`},Q$={description:P(`Search a range for a match and return the corresponding item from a second range.`),args:[U(`search_key (string,number,boolean)`,P(`The value to search for.`)),U(`lookup_range (any, range)`,P(`The range to consider for the search. Should be a single column or a single row.`)),U(`return_range (any, range)`,P(`The range containing the return value. Should have the same dimensions as lookup_range.`)),U(`if_not_found (any, optional)`,P(`If a valid match is not found, return this value.`)),U(`match_mode (any, default=0)`,P(`Specifies how to match search_key with the items in lookup_range. `),[{value:0,label:P(`Exact match (default)`)},{value:-1,label:P(`Exact match or next smaller item`)},{value:1,label:P(`Exact match or next larger item`)},{value:2,label:P(`Wildcard character match`)}]),U(`search_mode (any, default=1)`,P(`Specifies the search mode to use. By default, a first to last search will be used.`),[{value:1,label:P(`Search first to last (default)`)},{value:-1,label:P(`Search last to first`)},{value:2,label:P(`Binary search (sorted ascending order)`)},{value:-2,label:P(`Binary search (sorted descending order)`)}])],compute:function(e,t,n,r,i={value:0},a={value:1}){let o=Math.trunc(L(i.value,this.locale)),s=Math.trunc(L(a.value,this.locale)),c=B(t),l=B(n);if(c.length!==1&&c[0].length!==1)return new I(P(`lookup_range should be either a single row or single column.`));if(![1,-1,2,-2].includes(s))return new I(P(`search_mode should be a value in [-1, 1, -2, 2].`));if(![-1,0,1,2].includes(o))return new I(P(`match_mode should be a value in [-1, 0, 1, 2].`));let u=c.length===1?`col`:`row`;if(o===2&&[-2,2].includes(s))return new I(P(`The search and match mode combination is not supported for XLOOKUP evaluation.`));if(u===`col`?l[0].length!==c[0].length:l.length!==c.length)return new I(P(`return_range should have the same dimensions as lookup_range.`));let d=u===`col`?(e,t)=>e[0][t].value:(e,t)=>e[t][0].value,f=u===`col`?c[0].length:c.length,p=Z$[o],m=s===-1,h=s===2||s===-2?fs(c,e,p,s===2?`asc`:`desc`,f,d):ps(c,e,p,f,d,this.lookupCaches,m);return h===-1?r===void 0?Po(e):[[r]]:u===`col`?l.map(e=>[e[h]]):[l[h]]},isExported:!0},$$={description:P(`Get the value from a pivot.`),args:[U(`pivot_id (number,string)`,P(`ID of the pivot.`)),U(`measure_name (string)`,P(`Name of the measure.`)),U(`domain_field_name (string,repeating,optional)`,P(`Field name.`)),U(`domain_value (number,string,boolean,repeating,optional)`,P(`Value.`))],compute:function(e,t,...n){let r=R(e),i=R(t),a=N$(r,this.getters);P$(a,i,this.getters),F$(n);let o=this.getters.getPivot(a),s=this.getters.getPivotCoreDefinition(a);I$(this,a,s.measures.filter(e=>e.id===i)),o.init({reload:o.needsReevaluation});let c=o.assertIsValid({throwOnError:!1});if(c)return c;if(!o.areDomainArgsFieldsValid(n)){let e=P(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${r})`);return{value:F.GenericError,message:P(`Dimensions don't match the pivot definition`)+`. `+e}}let l=o.parseArgsToPivotDomain(n);return this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(a)?.trackValue(i,l),o.getPivotCellValueAndFormat(i,l)}},e1={description:P(`Get the header of a pivot.`),args:[U(`pivot_id (number,string)`,P(`ID of the pivot.`)),U(`domain_field_name (string,repeating,optional)`,P(`Field name.`)),U(`domain_value (number,string,value,repeating,optional)`,P(`Value.`))],compute:function(e,...t){let n=R(e),r=N$(n,this.getters);F$(t);let i=this.getters.getPivot(r);I$(this,r,[]),i.init({reload:i.needsReevaluation});let a=i.assertIsValid({throwOnError:!1});if(a)return a;if(!i.areDomainArgsFieldsValid(t)){let e=P(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${n})`);return{value:F.GenericError,message:P(`Dimensions don't match the pivot definition`)+`. `+e}}let o=i.parseArgsToPivotDomain(t);this.getters.getActiveSheetId()===this.__originSheetId&&this.getters.getPivotPresenceTracker(r)?.trackHeader(o);let s=o.at(-1);if(s?.field===`measure`)return i.getPivotMeasureValue(R(s.value),o);let{value:c,format:l}=i.getPivotHeaderValueAndFormat(o);return{value:c,format:!s||s.field===`measure`||s.value===`false`?void 0:l}}},t1={description:P(`Get a pivot table.`),args:[U(`pivot_id (string)`,P(`ID of the pivot.`)),U(`row_count (number, optional)`,P(`number of rows`)),U(`include_total (boolean, default=TRUE)`,P(`Whether to include total/sub-totals or not.`)),U(`include_column_titles (boolean, default=TRUE)`,P(`Whether to include the column titles or not.`)),U(`column_count (number, optional)`,P(`number of columns`)),U(`include_measure_titles (boolean, default=TRUE)`,P(`Whether to include the measure titles row or not.`))],compute:function(e,t,n,r,i,a){let o=N$(R(e),this.getters),s=this.getters.getPivot(o),c=this.getters.getPivotCoreDefinition(o),l=EC(c,t,n,r,i,a,this.locale);if(l.numberOfRows<0)return new I(P(`The number of rows must be positive.`));if(l.numberOfColumns<0)return new I(P(`The number of columns must be positive.`));I$(this,o,c.measures),s.init({reload:s.needsReevaluation});let u=s.assertIsValid({throwOnError:!1});if(u)return u;let d=s.getCollapsedTableStructure();if(d.numberOfCells>5e5)return new I(G_(d.numberOfCells,this.locale));let f=d.getPivotCells(l),p=this.getters.getPivotName(o),{numberOfCols:m,numberOfRows:h}=d.getPivotTableDimensions(l);if(h===0)return[[{value:p}]];let g=[];for(let e of C(0,m)){g[e]=[];for(let t of C(0,h)){let n=f[e][t];switch(n.type){case`EMPTY`:g[e].push({value:``});break;case`HEADER`:let t=s.getPivotHeaderValueAndFormat(n.domain);g[e].push(_C(n.domain,t));break;case`MEASURE_HEADER`:g[e].push(s.getPivotMeasureValue(n.measure,n.domain));break;case`VALUE`:g[e].push(s.getPivotCellValueAndFormat(n.measure,n.domain));break;case`ROW_GROUP_NAME`:let r=s.definition.rows.find(e=>e.nameWithGranularity===n.rowField)?.displayName;g[e].push({value:r||``});break}}}return(l.displayColumnHeaders||l.displayMeasuresRow)&&f[0][0].type===`EMPTY`&&(g[0][0]={value:p}),g}},n1={description:P(`Returns a range reference shifted by a specified number of rows and columns from a starting cell reference.`),args:[U(`cell_reference (any, range<any>)`,P(`The starting point from which to count the offset rows and columns.`)),U(`offset_rows (number)`,P(`The number of rows to offset by.`)),U(`offset_columns (number)`,P(`The number of columns to offset by.`)),U(`height (number, default='height of cell_reference')`,P(`The number of rows of the range to return starting at the offset target.`)),U(`width (number, default='width of cell_reference')`,P(`The number of columns of the range to return starting at the offset target.`))],compute:function(e,t,n,r,i){if(e===void 0)return new To(Io);let a=B(e),o=a[0][0];if(o===void 0)return new I(P(`The range is out of bounds.`));if(o.position===void 0)return new To(Io);let s=a[0].length,c=a.length;if(r){let e=L(r,this.locale);if(e<1)return new I(P(`Height value is %(_height)s. It should be greater than or equal to 1.`,{_height:e}));s=e}if(i){let e=L(i,this.locale);if(e<1)return new I(P(`Width value is %(_width)s. It should be greater than or equal to 1.`,{_width:e}));c=e}let l=L(t,this.locale),u=L(n,this.locale),d=this.__originCellPosition;d&&this.updateDependencies?.(d);let f=o.position.col+u,p=o.position.row+l;if(f<0||p<0)return new To(P(`OFFSET evaluates to an out of bounds range.`));let m={left:f,top:p,right:f+c-1,bottom:p+s-1},h=o.position.sheetId,g=this.getters.getRangeFromZone(h,m);return g.invalidXc||g.invalidSheetName?new To:(d&&this.addDependencies?.(d,[g]),ns(c,s,(e,t)=>this.getFormulaResult({sheetId:h,col:f+e,row:p+t})))}},r1={description:P(`Returns an element from a list of choices based on index.`),args:[U(`index (number)`,P(`Which choice to return.`)),U(`choice (any, range<any>, repeating)`,P(`A potential value to return. May be a reference to a cell or an individual value.`))],compute:function(e,...t){let n=Math.floor(L(e,this.locale))-1;return n<0||n>=t.length?new I(P(`Index for CHOOSE is invalid. Valid values are between 1 and %(choices)s inclusive.`,{choices:t.length})):t[n]??new I(P(`Choice is undefined.`))},isExported:!0},i1={description:P(`Excludes a specified number of rows or columns from the start or end of an array.`),args:[U(`array (range)`,P(`The array from which to drop rows or columns`)),U(`rows (number)`,P(`The number of rows to drop. A negative value drops from the end of the array.`)),U(`columns (number, optional)`,P(`The number of columns to exclude. A negative value drops from the end of the array.`))],compute:function(e,t,n){let r=L(t,this.locale),i=L(n,this.locale),a=e;if(Math.abs(i)>=e.length||Math.abs(r)>=e[0].length)return new I(P(`The number of rows or column to exclude must be smaller than the number of elements in the array.`));a=i>=0?a.slice(i):a.slice(0,a.length+i);for(let e=0;e<a.length;e++)r>=0?a[e]=a[e].slice(r):a[e]=a[e].slice(0,a[e].length+r);return a},isExported:!0},a1={description:P(`Returns a specified number of contiguous rows or columns from the start or end of an array.`),args:[U(`array (range)`,P(`The array from which to take rows or columns.`)),U(`rows (number)`,P(`The number of rows to take. A negative value takes from the end of the array.`)),U(`columns (number, optional)`,P(`The number of columns to take. A negative value takes from the end of the array.`))],compute:function(e,t,n){let r=t?L(t,this.locale):e[0].length,i=L(n,this.locale),a=e;if((Math.abs(i)>=e.length||i===0)&&(i=e.length),Math.abs(r)>=e[0].length&&(r=e[0].length),a=i>=0?a.slice(0,i):a.slice(a.length+i,a.length),r===0)return new I(P(`The number of rows can not be zero.`));for(let e=0;e<a.length;e++)r>0?a[e]=a[e].slice(0,r):a[e]=a[e].slice(a[e].length+r,a[e].length);return a},isExported:!0},o1={description:P(`Returns a formula as a string.`),args:[U(`cell_reference (any)`,P(`A reference to a cell.`))],compute:function(e){if(e?.position===void 0)return new To(Io);let t=this.getters.getCell(e.position);return t?.isFormula?t.compiledFormula.toFormulaString(this.getters):new Eo(P(`The cell does not contain a formula.`))},isExported:!0};var s1=l({ADD:()=>c1,CONCAT:()=>l1,DIVIDE:()=>u1,EQ:()=>m1,GT:()=>_1,GTE:()=>v1,LT:()=>y1,LTE:()=>b1,MINUS:()=>x1,MULTIPLY:()=>S1,NE:()=>C1,POW:()=>w1,SPILLED_RANGE:()=>T1,UMINUS:()=>E1,UNARY_PERCENT:()=>D1,UPLUS:()=>O1});let c1={description:P(`Sum of two numbers.`),args:[U(`value1 (number)`,P(`The first addend.`)),U(`value2 (number)`,P(`The second addend.`))],compute:function(e,t){return{value:L(e,this.locale)+L(t,this.locale),format:e?.format||t?.format}}},l1={description:P(`Concatenation of two values.`),args:[U(`value1 (string)`,P(`The value to which value2 will be appended.`)),U(`value2 (string)`,P(`The value to append to value1.`))],compute:function(e,t){return R(e)+R(t)},isExported:!0},u1={description:P(`One number divided by another.`),args:[U(`dividend (number)`,P(`The number to be divided.`)),U(`divisor (number)`,P(`The number to divide by.`))],compute:function(e,t){let n=L(t,this.locale);return n===0?new ko(P(`The divisor must be different from zero.`)):{value:L(e,this.locale)/n,format:e?.format||t?.format}}};function d1(e){return e===void 0||e.value===null}let f1={number:0,string:``,boolean:!1};function p1(e,t,n=2e-16){return Math.abs(e-t)<n}let m1={description:P(`Equal.`),args:[U(`value1 (string, number, boolean)`,P(`The first value.`)),U(`value2 (string, number, boolean)`,P(`The value to test against value1 for equality.`))],compute:function(e,t){if(No(e?.value))return e;if(No(t?.value))return t;let n=d1(e)?f1[typeof t?.value]:e?.value,r=d1(t)?f1[typeof e?.value]:t?.value;return typeof n==`string`&&(n=n.toUpperCase()),typeof r==`string`&&(r=r.toUpperCase()),typeof n==`number`&&typeof r==`number`?{value:p1(n,r)}:{value:n===r}}};function h1(e,t,n){if(No(e?.value))return e;if(No(t?.value))return t;let r=d1(e)?f1[typeof t?.value]??``:e?.value,i=d1(t)?f1[typeof e?.value]??``:t?.value,a=g1[typeof r],o=g1[typeof i];if(a!==o)return{value:n(a,o)};switch(typeof r){case`string`:r=r.toUpperCase();break;case`boolean`:r=Number(r);break}switch(typeof i){case`string`:i=i.toUpperCase();break;case`boolean`:i=Number(i);break}return{value:n(r,i)}}let g1={number:0,string:1,boolean:2},_1={description:P(`Strictly greater than.`),args:[U(`value1 (number, string, boolean)`,P(`The value to test as being greater than value2.`)),U(`value2 (number, string, boolean)`,P(`The second value.`))],compute:function(e,t){return h1(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?!p1(e,t)&&e>t:e>t)}},v1={description:P(`Greater than or equal to.`),args:[U(`value1 (number, string, boolean)`,P(`The value to test as being greater than or equal to value2.`)),U(`value2 (number, string, boolean)`,P(`The second value.`))],compute:function(e,t){return h1(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?p1(e,t)||e>t:e>=t)}},y1={description:P(`Less than.`),args:[U(`value1 (number, string, boolean)`,P(`The value to test as being less than value2.`)),U(`value2 (number, string, boolean)`,P(`The second value.`))],compute:function(e,t){let n=v1.compute.bind(this)(e,t);return No(n.value)?n:{value:!n.value}}},b1={description:P(`Less than or equal to.`),args:[U(`value1 (number, string, boolean)`,P(`The value to test as being less than or equal to value2.`)),U(`value2 (number, string, boolean)`,P(`The second value.`))],compute:function(e,t){let n=_1.compute.bind(this)(e,t);return No(n.value)?n:{value:!n.value}}},x1={description:P(`Difference of two numbers.`),args:[U(`value1 (number)`,P(`The minuend, or number to be subtracted from.`)),U(`value2 (number)`,P(`The subtrahend, or number to subtract from value1.`))],compute:function(e,t){return{value:L(e,this.locale)-L(t,this.locale),format:e?.format||t?.format}}},S1={description:P(`Product of two numbers`),args:[U(`factor1 (number)`,P(`The first multiplicand.`)),U(`factor2 (number)`,P(`The second multiplicand.`))],compute:function(e,t){return{value:L(e,this.locale)*L(t,this.locale),format:e?.format||t?.format}}},C1={description:P(`Not equal.`),args:[U(`value1 (string, number, boolean)`,P(`The first value.`)),U(`value2 (string, number, boolean)`,P(`The value to test against value1 for inequality.`))],compute:function(e,t){let n=m1.compute.bind(this)(e,t);return No(n.value)?n:{value:!n.value}}},w1={description:P(`A number raised to a power.`),args:[U(`base (number)`,P(`The number to raise to the exponent power.`)),U(`exponent (number)`,P(`The exponent to raise base to.`))],compute:function(e,t){return cJ.compute.bind(this)(e,t)}},T1={description:P(`Gets the spilled range of an array formula.`),args:[U(`ref (any, range<any>)`,P(`The reference to get the spilled range from.`))],compute:function(e){if(e===void 0)return new To(Io);let t=B(e);if(t.length!==1||t[0].length!==1)return new I(P(`Only single-cell references are allowed to get the spilled range.`));let n=t[0][0];if(No(n.value))return n;if(n.position===void 0)return new To(Io);let r=this.__originCellPosition;r&&this.updateDependencies?.(r);let i=this.getters.getSpreadZone(n.position);if(i===void 0)return new To;let a=this.getters.getRangeFromZone(this.__originSheetId,i);return r&&this.addDependencies?.(r,[a]),ns(i.right-i.left+1,i.bottom-i.top+1,(e,t)=>this.getFormulaResult({sheetId:a.sheetId,col:i.left+e,row:i.top+t}))},hidden:!0},E1={description:P(`A number with the sign reversed.`),args:[U(`value (number)`,P(`The number to have its sign reversed. Equivalently, the number to multiply by -1.`))],compute:function(e){return{value:-L(e,this.locale),format:e?.format}}},D1={description:P(`Value interpreted as a percentage.`),args:[U(`percentage (number)`,P(`The value to interpret as a percentage.`))],compute:function(e){return L(e,this.locale)/100}},O1={description:P(`A specified number, unchanged.`),args:[U(`value (any)`,P(`The number to return.`))],compute:function(e={value:null}){return e}},$=e=>({transform:t=>t*e,inverseTransform:t=>t/e}),k1={transform:e=>e,inverseTransform:e=>e},A1=1e-10,j1=.0254,M1=j1/72,N1=.3048,P1=.9144,F1=1609.34,I1=1852,L1=946073047258e4,R1={g:{...k1,category:`weight`},u:{...$(166053e-29),category:`weight`},grain:{...$(.0647989),category:`weight`},ozm:{...$(28.3495),category:`weight`},lbm:{...$(453.592),category:`weight`},stone:{...$(6350.29),category:`weight`},sg:{...$(14593.90294),category:`weight`},cwt:{...$(45359.237),category:`weight`},uk_cwt:{...$(50802.3),category:`weight`},ton:{...$(907184.74),category:`weight`},uk_ton:{...$(1016046.9),category:`weight`},m:{...k1,category:`distance`},km:{...$(1e3),category:`distance`},ang:{...$(A1),category:`distance`},Picapt:{...$(M1),category:`distance`},pica:{...$(j1/6),category:`distance`},in:{...$(j1),category:`distance`},ft:{...$(N1),category:`distance`},yd:{...$(P1),category:`distance`},ell:{...$(1.143),category:`distance`},mi:{...$(F1),category:`distance`},survey_mi:{...$(1609.34),category:`distance`},Nmi:{...$(I1),category:`distance`},ly:{...$(L1),category:`distance`},parsec:{...$(0x6da012f95c9fd0),category:`distance`},sec:{...k1,category:`time`},min:{...$(60),category:`time`},hr:{...$(3600),category:`time`},day:{...$(86400),category:`time`},yr:{...$(31556952),category:`time`},Pa:{...k1,category:`pressure`},bar:{...$(1e5),category:`pressure`},mmHg:{...$(133.322),category:`pressure`},Torr:{...$(133.322),category:`pressure`},psi:{...$(6894.76),category:`pressure`},atm:{...$(101325),category:`pressure`},N:{...k1,category:`force`},dyn:{...$(1e-5),category:`force`},pond:{...$(.00980665),category:`force`},lbf:{...$(4.44822),category:`force`},J:{...k1,category:`energy`},eV:{...$(160218e-24),category:`energy`},e:{...$(1e-7),category:`energy`},flb:{...$(1.3558179483),category:`energy`},c:{...$(4.184),category:`energy`},cal:{...$(4.1868),category:`energy`},BTU:{...$(1055.06),category:`energy`},Wh:{...$(3600),category:`energy`},HPh:{...$(2684520),category:`energy`},W:{...k1,category:`power`},PS:{...$(735.499),category:`power`},HP:{...$(745.7),category:`power`},T:{...k1,category:`magnetism`},ga:{...$(1e-4),category:`magnetism`},K:{...k1,category:`temperature`},C:{transform:e=>e+273.15,inverseTransform:e=>e-273.15,category:`temperature`},F:{transform:e=>(e-32)*5/9+273.15,inverseTransform:e=>(e-273.15)*9/5+32,category:`temperature`},Rank:{...$(5/9),category:`temperature`},Reau:{transform:e=>e*1.25+273.15,inverseTransform:e=>(e-273.15)/1.25,category:`temperature`},"m^3":{...k1,category:`volume`,order:3},"ang^3":{...$(A1**3),category:`volume`,order:3},"Picapt^3":{...$(M1**3),category:`volume`,order:3},tsp:{...$(492892e-11),category:`volume`},tspm:{...$(5e-6),category:`volume`},tbs:{...$(14786764825785619e-21),category:`volume`},"in^3":{...$(j1**3),category:`volume`,order:3},oz:{...$(295735295625e-16),category:`volume`},cup:{...$(237e-6),category:`volume`},pt:{...$(.0004731765),category:`volume`},uk_pt:{...$(568261e-9),category:`volume`},qt:{...$(.0009463529),category:`volume`},l:{...$(.001),category:`volume`},uk_qt:{...$(.0011365225),category:`volume`},gal:{...$(.0037854118),category:`volume`},uk_gal:{...$(.00454609),category:`volume`},"ft^3":{...$(N1**3),category:`volume`,order:3},bushel:{...$(.0352390704),category:`volume`},barrel:{...$(.158987295),category:`volume`},"yd^3":{...$(P1**3),category:`volume`,order:3},MTON:{...$(1.13267386368),category:`volume`},GRT:{...$(2.83168),category:`volume`},"mi^3":{...$(F1**3),category:`volume`,order:3},"Nmi^3":{...$(I1**3),category:`volume`,order:3},"ly^3":{...$(L1**3),category:`volume`,order:3},"m^2":{...k1,category:`area`,order:2},"ang^2":{...$(A1**2),category:`area`,order:2},"Picapt^2":{...$(M1**2),category:`area`,order:2},"in^2":{...$(j1**2),category:`area`,order:2},"ft^2":{...$(N1**2),category:`area`,order:2},"yd^2":{...$(P1**2),category:`area`,order:2},ar:{...$(100),category:`area`},Morgen:{...$(2500),category:`area`},uk_acre:{...$(4046.8564224),category:`area`},us_acre:{...$(4046.8726098743),category:`area`},ha:{...$(1e4),category:`area`},"mi^2":{...$(F1**2),category:`area`,order:2},"Nmi^2":{...$(I1**2),category:`area`,order:2},"ly^2":{...$(L1**2),category:`area`,order:2},bit:{...k1,category:`information`},byte:{...$(8),category:`information`},"m/s":{...k1,category:`speed`},"m/hr":{...$(1/3600),category:`speed`},"km/hr":{...$(1/3.6),category:`speed`},mph:{...$(.44704),category:`speed`},kn:{...$(.5144444444),category:`speed`},admkn:{...$(.5147733333),category:`speed`}},z1={shweight:`cwt`,lcwt:`uk_cwt`,hweight:`uk_cwt`,LTON:`uk_ton`,brton:`uk_ton`,pc:`parsec`,Pica:`Picapt`,d:`day`,mn:`min`,s:`sec`,p:`Pa`,at:`atm`,dy:`dyn`,ev:`eV`,hh:`HPh`,wh:`Wh`,btu:`BTU`,h:`HP`,cel:`C`,fah:`F`,kel:`K`,us_pt:`pt`,L:`l`,lt:`l`,ang3:`ang^3`,ft3:`ft^3`,in3:`in^3`,ly3:`ly^3`,m3:`m^3`,mi3:`mi^3`,yd3:`yd^3`,Nmi3:`Nmi^3`,Picapt3:`Picapt^3`,"Pica^3":`Picapt^3`,Pica3:`Picapt^3`,regton:`GRT`,ang2:`ang^2`,ft2:`ft^2`,in2:`in^2`,ly2:`ly^2`,m2:`m^2`,mi2:`mi^2`,Nmi2:`Nmi^2`,Picapt2:`Picapt^2`,"Pica^2":`Picapt^2`,Pica2:`Picapt^2`,yd2:`yd^2`,"m/h":`m/hr`,"m/sec":`m/s`},B1={"":1,Y:1e24,Z:1e21,E:0xde0b6b3a7640000,P:0x38d7ea4c68000,T:0xe8d4a51000,G:1e9,M:1e6,k:1e3,h:100,da:10,e:10,d:.1,c:.01,m:.001,u:1e-6,n:1e-9,p:1e-12,f:1e-15,a:1e-18,z:1e-21,y:1e-21,Yi:2**80,Zi:2**70,Ei:2**60,Pi:2**50,Ti:2**40,Gi:2**30,Mi:2**20,ki:2**10},V1={weight:P(`Weight`),distance:P(`Distance`),time:P(`Time`),pressure:P(`Pressure`),force:P(`Force`),energy:P(`Energy`),power:P(`Power`),magnetism:P(`Magnetism`),temperature:P(`Temperature`),volume:P(`Volume`),area:P(`Area`),information:P(`Information`),speed:P(`Speed`)},H1=Object.entries(R1).map(([e,t])=>({value:e,label:U1(t.category)}));function U1(e){return V1[e]??``}function W1(e){for(let[t,n]of Object.entries(B1)){if(t&&!e.startsWith(t))continue;let r=e.slice(t.length),i=R1[r];if(!i&&z1[r]&&(i=R1[z1[r]]),i)return{...i,factor:i.order?n**+i.order:n}}}var G1=l({CONVERT:()=>K1});let K1={description:P(`Converts a numeric value to a different unit of measure.`),args:[U(`value (number)`,P(`the numeric value in start_unit to convert to end_unit`)),U(`start_unit (string)`,P(`The starting unit, the unit currently assigned to value`),H1),U(`end_unit (string)`,P(`The unit of measure into which to convert value`),H1)],compute:function(e,t,n){let r=L(e,this.locale),i=R(t),a=R(n),o=W1(i),s=W1(a);return o?s?o.category===s.category?{value:s.inverseTransform(o.factor*o.transform(r))/s.factor,format:e?.format}:{value:F.GenericError,message:P(`Incompatible units of measure ('%s' vs '%s')`,U1(o.category),U1(s.category))}:{value:F.GenericError,message:P(`Invalid units of measure ('%s')`,a)}:{value:F.GenericError,message:P(`Invalid units of measure ('%s')`,i)}},isExported:!0};var q1=l({CHAR:()=>Z1,CLEAN:()=>Q1,CONCATENATE:()=>$1,EXACT:()=>e0,FIND:()=>t0,FORMAT_LARGE_NUMBER:()=>n0,JOIN:()=>r0,LEFT:()=>i0,LEN:()=>a0,LOWER:()=>o0,MID:()=>s0,PROPER:()=>c0,REGEXEXTRACT:()=>u0,REGEXREPLACE:()=>d0,REGEXTEST:()=>l0,REPLACE:()=>f0,RIGHT:()=>p0,SEARCH:()=>m0,SPLIT:()=>h0,SUBSTITUTE:()=>g0,TEXT:()=>x0,TEXTAFTER:()=>C0,TEXTBEFORE:()=>w0,TEXTJOIN:()=>_0,TEXTSPLIT:()=>v0,TRIM:()=>y0,UPPER:()=>b0,VALUE:()=>S0});let J1=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,Y1=[{value:0,label:P(`Case-sensitive (default)`)},{value:1,label:P(`Case-insensitive`)}],X1=[{value:0,label:P(`Don't match to end (default)`)},{value:1,label:P(`Match to end`)}],Z1={description:P(`Gets character associated with number.`),args:[U(`table_number (number)`,P(`The number of the character to look up from the current Unicode table in decimal format.`))],compute:function(e){let t=Math.trunc(L(e,this.locale));return t<1?new I(P(`The table_number (%s) is out of range.`,t)):String.fromCharCode(t)},isExported:!0},Q1={description:P(`Remove non-printable characters from a piece of text.`),args:[U(`text (string)`,P(`The text whose non-printable characters are to be removed.`))],compute:function(e){let t=R(e),n=``;for(let e of t)e&&e.charCodeAt(0)>31&&(n+=e);return n},isExported:!0},$1={description:P(`Appends strings to one another.`),args:[U(`string (string, range<string>, repeating)`,P(`String to append in sequence.`))],compute:function(...e){return $o(e,(e,t)=>e+R(t),``)},isExported:!0},e0={description:P(`Tests whether two strings are identical.`),args:[U(`string1 (string)`,P(`The first string to compare.`)),U(`string2 (string)`,P(`The second string to compare.`))],compute:function(e,t){return R(e)===R(t)},isExported:!0},t0={description:P(`First position of string found in text, case-sensitive.`),args:[U(`search_for (string)`,P(`The string to look for within text_to_search.`)),U(`text_to_search (string)`,P(`The text to search for the first occurrence of search_for.`)),U(`starting_at (number, default=1)`,P(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=R(e),i=R(t),a=L(n,this.locale);if(i===``)return new I(P(`The text_to_search must be non-empty.`));if(a<1)return new I(P(`The starting_at (%s) must be greater than or equal to 1.`,a));let o=i.indexOf(r,a-1);return o===-1?new I(P(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)):o+1},isExported:!0},n0={description:P(`Apply a large number format`),args:[U(`value (number)`,P(`The number.`)),U(`unit (string, optional)`,P(`The formatting unit. Use 'k', 'm', or 'b' to force the unit`),[{value:`k`,label:P(`Thousand`)},{value:`m`,label:P(`Million`)},{value:`b`,label:P(`Billion`)}])],compute:function(e,t){return{value:L(e,this.locale),format:Ec(e,t,this.locale)}}},r0={description:P(`Concatenates elements of arrays with delimiter.`),args:[U(`delimiter (string)`,P(`The character or string to place between each concatenated value.`)),U(`value_or_array (string, range<string>, repeating)`,P(`Value to be appended using delimiter.`))],compute:function(e,...t){let n=R(e);return $o(t,(e,t)=>(e?e+n:``)+R(t),``)}},i0={description:P(`Substring from beginning of specified string.`),args:[U(`text (string)`,P(`The string from which the left portion will be returned.`)),U(`number_of_characters (number, optional)`,P(`The number of characters to return from the left side of string.`))],compute:function(e,...t){let n=t.length?L(t[0],this.locale):1;return n<0?new I(P(`The number_of_characters (%s) must be positive or null.`,n)):R(e).substring(0,n)},isExported:!0},a0={description:P(`Length of a string.`),args:[U(`text (string)`,P(`The string whose length will be returned.`))],compute:function(e){return R(e).length},isExported:!0},o0={description:P(`Converts a specified string to lowercase.`),args:[U(`text (string)`,P(`The string to convert to lowercase.`))],compute:function(e){return R(e).toLowerCase()},isExported:!0},s0={description:P(`A segment of a string.`),args:[U(`text (string)`,P(`The string to extract a segment from.`)),U(`starting_at (number)`,P(`The index from the left of string from which to begin extracting. The first character in string has the index 1.`)),U(`extract_length (number)`,P(`The length of the segment to extract.`))],compute:function(e,t,n){let r=R(e),i=L(t,this.locale),a=L(n,this.locale);return i<1?new I(P(`The starting_at argument (%s) must be positive greater than one.`,i.toString())):a<0?new I(P(`The extract_length argument (%s) must be positive or null.`,a)):r.slice(i-1,i+a-1)},isExported:!0},c0={description:P(`Capitalizes each word in a specified string.`),args:[U(`text_to_capitalize (string)`,P(`The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase.`))],compute:function(e){return R(e).replace(J1,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())},isExported:!0},l0={description:P(`Checks whether a string matches the supplied regular expression.`),args:[U(`text (string)`,P(`The string to test.`)),U(`pattern (string)`,P(`The regular expression pattern to match against the text.`)),U(`case_sensitivity (number, default=0)`,P(`Whether the match is case-sensitive.`),[{value:0,label:P(`Case-sensitive`)},{value:1,label:P(`Case-insensitive`)}])],compute:function(e,t,n={value:0}){let r=R(e),i=R(t),a=L(n,this.locale);if(i===``)return!0;if(r===``)return!1;if(a!==0&&a!==1)return new I(P(`The case_sensitivity (%s) must be 0 or 1.`,a));let o=a===1?`gi`:`g`,s;try{s=new RegExp(i,o)}catch{return new I(P(`Invalid regular expression`))}return s.test(r)},isExported:!0},u0={description:P(`Extract text from a string based on the supplied regular expression.`),args:[U(`text (string)`,P(`The string on which you want to extract text.`)),U(`pattern (string)`,P(`The regular expression pattern to match against the text.`)),U(`return_mode (number, default=0)`,P(`0 = first match, 1 = all matches as an array, 2 = capturing groups from the first match as an array.`),[{value:0,label:P(`First match`)},{value:1,label:P(`All matches`)},{value:2,label:P(`Capture groups of first match`)}]),U(`case_sensitivity (number, default=0)`,P(`Whether the match is case-sensitive.`),[{value:0,label:P(`Case-sensitive`)},{value:1,label:P(`Case-insensitive`)}])],compute:function(e,t,n={value:0},r={value:0}){let i=R(e),a=R(t),o=L(n,this.locale),s=L(r,this.locale);if(i===``||a===``)return{value:``};if(o<0||o>2)return new I(P(`The return_mode (%s) must be 0, 1 or 2.`,o));if(s!==0&&s!==1)return new I(P(`The case_sensitivity (%s) must be 0 or 1.`,s));let c=s===1?`gi`:`g`,l;try{l=new RegExp(a,c)}catch{return new I(P(`Invalid regular expression`))}let u=[...i.matchAll(l)];return u.length===0?{value:F.NotAvailable,message:P(`No matches found.`)}:o===0?u[0][0]:o===1?u.map(e=>[e[0]]):u[0].length<2?new I(P(`No capturing groups found.`)):u[0].slice(1).map(e=>[e])},isExported:!0},d0={description:P(`Replace text in a string based on the supplied regular expression.`),args:[U(`text (string)`,P(`The string in which you want to replace text.`)),U(`pattern (string)`,P(`The regular expression pattern to match against the text.`)),U(`replacement (string)`,P(`The text to use as the replacement.`)),U(`occurrence (number, default=0)`,P(`0 = replace all matches. A negative number counts from the end.`)),U(`case_sensitivity (number, default=0)`,P(`Whether the match is case-sensitive.`),[{value:0,label:P(`Case-sensitive`)},{value:1,label:P(`Case-insensitive`)}])],compute:function(e,t,n,r={value:0},i={value:0}){let a=R(e),o=R(t),s=R(n),c=L(r,this.locale),l=L(i,this.locale);if(l!==0&&l!==1)return new I(P(`The case_sensitivity (%s) must be 0 or 1.`,l));let u=l===1?`gi`:`g`,d;try{d=new RegExp(o,u)}catch{return new I(P(`Invalid regular expression`))}if(c!==0){let e=[...a.matchAll(d)];if(e.length===0||Math.abs(c)>e.length)return a;let t=c>0?c-1:e.length+c,n=e[t][0].length,r=e[t].index;return a.substring(0,r)+s+a.substring(r+n)}return a.replace(d,s)},isExported:!0},f0={description:P(`Replaces part of a text string with different text.`),args:[U(`text (string)`,P(`The text, a part of which will be replaced.`)),U(`position (number)`,P(`The position where the replacement will begin (starting from 1).`)),U(`length (number)`,P(`The number of characters in the text to be replaced.`)),U(`new_text (string)`,P(`The text which will be inserted into the original text.`))],compute:function(e,t,n,r){let i=L(t,this.locale);if(i<1)return new I(P(`The position (%s) must be greater than or equal to 1.`,i));let a=L(n,this.locale);if(a<0)return new I(P(`The length (%s) must be positive or zero.`,a));let o=R(e),s=R(r);return o.substring(0,i-1)+s+o.substring(i-1+a)},isExported:!0},p0={description:P(`A substring from the end of a specified string.`),args:[U(`text (string)`,P(`The string from which the right portion will be returned.`)),U(`number_of_characters (number, optional)`,P(`The number of characters to return from the right side of string.`))],compute:function(e,...t){let n=t.length?L(t[0],this.locale):1;if(n<0)return new I(P(`The number_of_characters (%s) must be positive or zero.`,n));let r=R(e),i=r.length;return r.substring(i-n,i)},isExported:!0},m0={description:P(`First position of string found in text, ignoring case.`),args:[U(`search_for (string)`,P(`The string to look for within text_to_search.`)),U(`text_to_search (string)`,P(`The text to search for the first occurrence of search_for.`)),U(`starting_at (number, default=1)`,P(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=R(e).toLowerCase(),i=R(t).toLowerCase(),a=L(n,this.locale);if(i===``)return{value:F.GenericError,message:P(`The text_to_search must be non-empty.`)};if(a<1)return{value:F.GenericError,message:P(`The starting_at (%s) must be greater than or equal to 1.`,a)};let o=i.indexOf(r,a-1);return o===-1?{value:F.GenericError,message:P(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)}:{value:o+1}},isExported:!0},h0={description:P(`Split text by specific character delimiter(s).`),args:[U(`text (string)`,P(`The text to divide.`)),U(`delimiter (string)`,P(`The character or characters to use to split text.`)),U(`split_by_each (boolean, default=true})`,P(`Whether or not to divide text around each character contained in delimiter.`)),U(`remove_empty_text (boolean, default=true)`,P(`Whether or not to remove empty text messages from the split results. The default behavior is to treat consecutive delimiters as one (if TRUE). If FALSE, empty cells values are added between consecutive delimiters.`))],compute:function(e,t,n={value:!0},r={value:!0}){let i=R(e),a=xt(R(t)),o=z(n),s=z(r);if(a.length<=0)return new I(P(`The delimiter (%s) must be not be empty.`,a));let c=o?RegExp(`[${a}]`,`g`):new RegExp(a,`g`),l=i.split(c);return s&&(l=l.filter(e=>e!==``)),as([l])},isExported:!1},g0={description:P(`Replaces existing text with new text in a string.`),args:[U(`text_to_search (string)`,P(`The text within which to search and replace.`)),U(`search_for (string)`,P(`The string to search for within text_to_search.`)),U(`replace_with (string)`,P(`The string that will replace search_for.`)),U(`occurrence_number (number, optional)`,P(`The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced.`))],compute:function(e,t,n,r){let i=L(r,this.locale);if(i<0)return new I(P(`The occurrenceNumber (%s) must be positive or null.`,i));let a=R(e),o=R(t);if(o===``)return a;let s=R(n),c=new RegExp(xt(o),`g`);if(i===0)return a.replace(c,s);let l=0;return a.replace(c,e=>++l===i?s:e)},isExported:!0},_0={description:P(`Combines text from multiple strings and/or arrays.`),args:[U(`delimiter (string)`,P(`A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.`)),U(`ignore_empty (boolean)`,P(`A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.`),[{value:!0,label:P(`Ignore empty cells`)},{value:!1,label:P(`Include empty cells (default)`)}]),U(`texts (string, range<string>, repeating)`,P(`Text item to join.`))],compute:function(e,t={value:!0},...n){let r=R(e),i=z(t),a=0;return $o(n,(e,t)=>i&&R(t)===``?e:(a++?e+r:``)+R(t),``)},isExported:!0},v0={description:P(`Splits text into rows or columns using specified column and row delimiters.`),args:[U(`text (string)`,P(`The text to split.`)),U(`col_delimiter (string, range<string>)`,P(`Character or string to split columns by.`)),U(`row_delimiter (string, range<string>, optional)`,P(`Character or string to split rows by.`)),U(`ignore_empty (boolean, default=false)`,P(`Whether to ignore empty cells.`),[{value:!1,label:P(`Include empty cells (default)`)},{value:!0,label:P(`Ignore empty cells`)}]),U(`match_mode (number, default=0)`,P(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),Y1),U(`pad_with (string, default="${F.NotAvailable}")`,P(`The value to use for padding empty cells.`))],compute:function(e,t,n,r={value:!1},i={value:0},a=new Eo){let o=R(e);if(o.length<=0)return new I(P(`No text to split.`));if(t===void 0&&n===void 0)return new I(P(`At least one delimiter must be provided.`));let s=B(t).flat().map(e=>xt(R(e))),c=B(n).flat().map(e=>xt(R(e)));if(s.some(e=>e===``)||c.some(e=>e===``))return new I(P(`The delimiters cannot be empty values.`));let l=z(r),u=L(i,this.locale);if(![0,1].includes(u))return new I(P(`match_mode should be a value of 0 or 1.`));let d=[],f=u===1?`gi`:`g`,p=c.filter(e=>!s.includes(e)),m=p.length?o.split(new RegExp(p.join(`|`),f)):[o];l&&(m=m.filter(e=>e!==``));let h=new RegExp(s.join(`|`),f);for(let e of m){let t=s.length?e.split(h):[e];l&&(t=t.filter(e=>e!==``)),d.push(t.map(e=>({value:e})))}let g=Math.max(...d.map(e=>e.length));for(let e of d)for(;e.length<g;)e.push(a);return as(d)},isExported:!0},y0={description:P(`Removes space characters.`),args:[U(`text (string)`,P(`The text or reference to a cell containing text to be trimmed.`))],compute:function(e){return ln(R(e))},isExported:!0},b0={description:P(`Converts a specified string to uppercase.`),args:[U(`text (string)`,P(`The string to convert to uppercase.`))],compute:function(e){return R(e).toUpperCase()},isExported:!0},x0={description:P(`Converts a number to text according to a specified format.`),args:[U(`number (number)`,P(`The number, date or time to format.`)),U(`format (string)`,P(`The case-sensitive format of the result, enclosed in quotation marks. Examples: "0.00" rounded to 2 decimal places, "hh:mm:ss" for hour:minutes:seconds.`))],compute:function(e,t){return H(L(e,this.locale),{format:R(t),locale:this.locale})},isExported:!0},S0={description:P(`Converts a string to a numeric value.`),args:[U(`value (number)`,P(`the string to be converted`))],compute:function(e){return L(e,this.locale)},isExported:!0},C0={description:P(`Returns text that occurs after a given substring or delimiter.`),args:[U(`text (string)`,P(`The source text.`)),U(`delimiter (string)`,P(`The substring after which text will be returned.`)),U(`instance_num (number, default=1)`,P(`The desired instance of the delimiter after which we extract the text. A negative number searches from the end.`)),U(`match_mode (number, default=0)`,P(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),Y1),U(`match_end (number, default=0))`,P(`Whether to treat the end of text as a delimiter.`),X1),U(`if_not_found (string, default="${F.NotAvailable}")`,P(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new Eo){let o=R(e),s=L(n,this.locale),c=L(r,this.locale),l=L(i,this.locale);if(s===0)return new I(P(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new I(P(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new I(P(`match_end should have a value of 0 or 1.`));let u=R(t);if(u===``)return Math.sign(s)>0?{value:o}:{value:``};let d=c===1?`gi`:`g`,f=xt(u),p=new RegExp(f,d),m=[...o.matchAll(p)].map(e=>e.index+u.length);if(s<0&&(m=m.reverse()),l&&Math.abs(s)===m.length+1)return Math.sign(s)>0?{value:``}:{value:o};let h=m[Math.abs(s)-1];return h===void 0?a:{value:o.substring(h)}},isExported:!0},w0={description:P(`Returns text that occurs before a given substring or delimiter.`),args:[U(`text (string)`,P(`The source text.`)),U(`delimiter (string)`,P(`The substring after which text will be returned.`)),U(`instance_num (number, default=1)`,P(`The desired instance of the delimiter before which we extract the text. A negative number searches from the end.`)),U(`match_mode (number, default=0)`,P(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),Y1),U(`match_end (number, default=0))`,P(`Whether to match a delimiter against the end of the text.`),X1),U(`if_not_found (string, default="${F.NotAvailable}")`,P(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new Eo){let o=R(e),s=L(n,this.locale),c=L(r,this.locale),l=L(i,this.locale);if(s===0)return new I(P(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new I(P(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new I(P(`match_end should have a value of 0 or 1.`));let u=R(t);if(u===``)return Math.sign(s)>0?{value:``}:{value:o};let d=c===1?`gi`:`g`,f=xt(u),p=new RegExp(f,d),m=[...o.matchAll(p)].map(e=>e.index+u.length);if(s<0&&(m=m.reverse()),l&&Math.abs(s)===m.length+1)return Math.sign(s)>0?{value:o}:{value:``};let h=m[Math.abs(s)-1];return h===void 0?a:{value:o.substring(0,h-u.length)}},isExported:!0};var T0=l({HYPERLINK:()=>E0});let E0={description:P(`Creates a hyperlink in a cell.`),args:[U(`url (string)`,P(`The full URL of the link enclosed in quotation marks.`)),U(`link_label (string, optional)`,P(`The text to display in the cell, enclosed in quotation marks.`))],compute:function(e,t){let n=R(e).trim(),r=R(t)||n;return n===``?r:Pt(r,n)},isExported:!0},D0=[{name:P(`Array`),functions:HK},{name:P(`Database`),functions:qY},{name:P(`Date`),functions:lZ},{name:P(`Filter`),functions:qZ},{name:P(`Financial`),functions:$Z},{name:P(`Info`),functions:c$},{name:P(`Lookup`),functions:L$},{name:P(`Logical`),functions:x$},{name:P(`Math`),functions:vq},{name:P(`Operator`),functions:s1},{name:P(`Statistical`),functions:PJ},{name:P(`Text`),functions:q1},{name:P(`Engineering`),functions:GZ},{name:P(`Web`),functions:T0},{name:P(`Parser`),functions:G1}];for(let e of D0){let t=e.functions;for(let n in t){let r=t[n];r.category=r.category||e.name,n=n.replace(/_/g,`.`),il.add(n,{isExported:!1,...r})}}let O0={},k0={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:26,HEADER_WIDTH:48,DESKTOP_BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:96,DEFAULT_CELL_HEIGHT:23,SCROLLBAR_WIDTH:15},A0={autoCompleteProviders:rA,autofillModifiersRegistry:$z,autofillRulesRegistry:eB,cellMenuRegistry:PI,colMenuRegistry:QI,errorTypes:So,functionRegistry:il,featurePluginRegistry:$V,iconsOnCellRegistry:Nz,statefulUIPluginRegistry:eH,coreViewsPluginRegistry:tH,corePluginRegistry:QV,rowMenuRegistry:aL,sidePanelRegistry:eF,figureRegistry:A_,chartSidePanelComponentRegistry:kA,chartDataSourceSidePanelComponentRegistry:SE,chartComponentRegistry:o_,chartTypeRegistry:wb,chartSubtypeRegistry:Vg,chartDataSourceRegistry:Cb,topbarMenuRegistry:DH,topbarComponentRegistry:KH,topBarToolBarRegistry:JU,clickableCellRegistry:nH,otRegistry:wB,inverseCommandRegistry:aH,urlRegistry:Bd,cellPopoverRegistry:sw,numberFormatMenuRegistry:CH,repeatLocalCommandTransformRegistry:CV,repeatCommandTransformRegistry:SV,clipboardHandlersRegistries:XL,pivotRegistry:KN,pivotTimeAdapterRegistry:IS,pivotSidePanelRegistry:sP,pivotNormalizationValueRegistry:mC,supportedPivotPositionalFormulaRegistry:kR,pivotToFunctionValueRegistry:hC,migrationStepRegistry:NC,chartJsExtensionRegistry:Ur,onIterationEndEvaluationRegistry:Cz,specificRangeTransformRegistry:TB},j0={arg:U,isEvaluationError:No,toBoolean:z,toJsDate:qo,toNumber:L,toString:R,toNormalizedPivotValue:uC,toFunctionPivotValue:fC,toXC:E,toZone:Un,toUnboundedZone:Hn,toCartesian:Mn,numberToLetters:Cn,lettersToNumber:wn,UuidGenerator:G,formatValue:H,createCurrencyFormat:yc,ColorGenerator:Ap,computeTextWidth:yf,createEmptyWorkbookData:$C,createEmptySheet:QC,createEmptyExcelSheet:ew,doesCellContainFunction:bn,rgbaToHex:np,colorToRGBA:rp,positionToZone:O,isDefined:w,isMatrix:ht,lazy:Gt,genericRepeat:GH,createAction:xe,createActions:_e,transformRangeData:Mr,deepEquals:T,overlap:rr,union:$n,isInside:ar,deepCopy:x,expandZoneOnInsertion:Yn,reduceZoneOnDeletion:Qn,unquote:wt,getMaxObjectId:nC,getFirstPivotFunction:ZN,getNumberOfPivotFunctions:$N,parseDimension:aC,isDateOrDatetimeField:oC,makeFieldProposal:eP,periodYearToComparable:FS,insertTokenAfterArgSeparator:nP,insertTokenAfterLeftParenthesis:rP,mergeContiguousZones:kr,getPivotHighlights:UM,pivotTimeAdapter:LS,UNDO_REDO_PIVOT_COMMANDS:Xz,createPivotFormula:lC,areDomainArgsFieldsValid:cC,splitReference:_l,sanitizeSheetName:Et,getUniqueText:_n,isNumber:lo,isDateTime:ja,createCustomFields:xC,schemeToColorScale:AC,isDateTimeFormat:fc,jsDateToNumber:Ga,numberToJsDate:Ua,DateTime:_a,parseFormat:Is,isFormula:vn,domainToColRowDomain:_N,collapseHierarchicalDisplayName:DC,getCanonicalSymbolName:Tt,fuzzyLookup:nA,replaceSymbolInFormula:Xu},M0={isMarkdownLink:Mt,parseMarkdownLink:Ft,markdownLink:Pt,openLink:Gd,urlRepresentation:Wd},N0={Checkbox:CE,Section:Z,Select:w_,RoundColorPicker:ZE,ChartDataSeries:FE,ChartErrorSection:zE,ChartLabelRange:IE,ChartRangeDataSourceComponent:mk,ChartTitle:JE,ChartPanel:NA,ChartFigure:O_,ChartJsComponent:Lh,ClickableCellSortIcon:AR,ZoomableChartJsComponent:Qg,Grid:OR,GridOverlay:nR,ScorecardChart:ig,GaugeChartComponent:i_,LineConfigPanel:mA,BarConfigPanel:VE,PieChartDesignPanel:_A,GenericChartConfigPanel:BE,ChartWithAxisDesignPanel:iD,GenericZoomableChartDesignPanel:aD,LineChartDesignPanel:hA,GaugeChartConfigPanel:Mk,GaugeChartDesignPanel:lA,ScorecardChartConfigPanel:bA,ScorecardChartDesignPanel:xA,GeoChartDesignPanel:fA,RadarChartDesignPanel:vA,WaterfallChartDesignPanel:OA,ComboChartDesignPanel:kk,FunnelChartDesignPanel:jk,SunburstChartDesignPanel:SA,TreeMapChartDesignPanel:DA,ChartTypePicker:jA,FigureComponent:j_,MenuPopover:C_,Popover:y_,SelectionInput:PE,StandaloneComposer:cA,ValidationMessages:RE,AddDimensionButton:aN,PivotDimensionGranularity:sN,PivotDimensionOrder:cN,PivotDimension:nN,PivotLayoutConfigurator:fN,PivotHTMLRenderer:MR,PivotDeferUpdate:GM,PivotTitleSection:pN,CogWheelMenu:bE,TextInput:pE,SidePanelCollapsible:UE,RadioSelection:XE,GeoChartRegionSelectSection:uA,ChartMenu:E_,FullScreenFigure:jR,NumberInput:GE,TopBar:YU,Composer:Uk},P0={useDragAndDropListItems:aE,useHighlights:IA,useHighlightsOnHover:FA},F0={Component:A,useExternalListener:Fi,EnvPlugin:Li,App:Hi},I0={useStoreProvider:Ki,DependencyContainer:Wi,CellPopoverStore:cw,ComposerFocusStore:Hr,CellComposerStore:IL,FindAndReplaceStore:Cj,HighlightStore:jE,DelayedHoveredCellStore:M_,HoveredTableStore:$L,ModelStore:Fr,NotificationStore:iA,RendererStore:zr,SelectionInputStore:NE,SpreadsheetStore:Br,useStore:j,useLocalStore:qi,SidePanelStore:nF,PivotSidePanelStore:aP,PivotMeasureDisplayPanelStore:VM,ClientFocusStore:sL,GridRenderer:dR};function L0(e,t){return il.add(e,t),{addFunction:(e,t)=>L0(e,t)}}let R0={DEFAULT_LOCALE:V,HIGHLIGHT_COLOR:De,PIVOT_STATIC_TABLE_CONFIG:st,PIVOT_INSERT_TABLE_STYLE_ID:ct,ChartTerms:I_,FIGURE_ID_SPLITTER:`??`,GRID_ICON_EDGE_LENGTH:17,GRID_ICON_MARGIN:2,CHART_TYPES:kC,DARK_MODE_FILTER_STRING:mp},z0={...pk,...NR};e.AbstractCellClipboardHandler=fV,e.AbstractChart=Rh,e.AbstractFigureClipboardHandler=oK,e.BadExpressionError=Co,e.CHART_TYPES=kC,e.CellErrorType=F,e.CellValueType=vd,e.CircularDependencyError=wo,e.ClientDisconnectedError=oV,e.ClipboardMIMEType=lw,e.CommandResult=Rd,e.CompiledFormula=dd,e.CorePlugin=cv,e.CoreViewPlugin=aF,e.DEFAULT_LOCALE=V,e.DEFAULT_LOCALES=xs,e.DEFAULT_LOCALE_DIGIT_GROUPING=`[3,0]`,e.DIRECTION=_t,e.DispatchResult=Id,e.DivisionByZeroError=ko,e.EvaluationError=I,e.InvalidReferenceError=To,e.LocalTransportService=qH,e.Model=rK,e.NEXT_VALUE=P_,e.NotAvailableError=Eo,e.NumberTooLargeError=Ao,e.OrderedLayers=Lr,e.PREVIOUS_VALUE=N_,e.PivotRuntimeDefinition=KM,e.Registry=k,e.Revision=aV,e.SPREADSHEET_DIMENSIONS=k0,e.SplillBlockedError=Oo,e.Spreadsheet=QU,e.SpreadsheetPivotTable=PN,e.UIPlugin=dB,e.UnknownFunctionError=Do,e.__info__=O0,e.addFunction=L0,e.addRenderingLayer=Rr,e.astToFormula=ML,e.availableConditionalFormatOperators=cj,e.availableDataValidationOperators=bj,e.availableFiltersOperators=JM,e.borderPositions=gt,e.borderStyles=mt,e.canExecuteInReadonly=Fd,e.categories=D0,e.chartHelpers=z0,e.compatibility=F0,e.components=N0,e.composerFocusTypes=vt,e.constants=R0,e.convertAstNodes=fu,e.coreTypes=Nd,e.createAutocompleteArgumentsProvider=wK,e.errorTypes=So,e.filterDateCriterionOperators=ZM,e.filterNumberCriterionOperators=XM,e.filterTextCriterionOperators=YM,e.findCellInNewZone=gr,e.functionCache=ld,e.getCaretDownSvg=Ey,e.getCaretUpSvg=Dy,e.helpers=j0,e.hooks=P0,e.invalidSubtotalFormulasCommands=Ad,e.invalidateBordersCommands=kd,e.invalidateCFEvaluationCommands=Od,e.invalidateChartEvaluationCommands=Ed,e.invalidateDependenciesCommands=Dd,e.invalidateEvaluationCommands=Td,e.isCoreCommand=Pd,e.isHeadersDependant=bd,e.isMatrix=ht,e.isPositionDependent=Cd,e.isRangeDependant=Sd,e.isSheetDependent=yd,e.isTargetDependent=xd,e.isZoneDependent=wd,e.iterateAstNodes=pu,e.links=M0,e.load=RC,e.lockedSheetAllowedCommands=Md,e.parse=uu,e.parseTokens=du,e.readonlyAllowedCommands=jd,e.registries=A0,e.schemeToColorScale=AC,e.setDefaultSheetViewSize=at,e.setTranslationMethod=yo,e.stores=I0,e.tokenColors=pt,e.tokenize=kl,O0.version=`19.5.0-alpha.1`,O0.date=`2026-07-01T05:05:42.239Z`,O0.hash=`3c78107`})(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|