@odoo/o-spreadsheet 20.1.0-alpha.1 → 20.1.0-alpha.2

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.
@@ -14,7 +14,7 @@ stores.inject(MyMetaStore, storeInstance);
14
14
  `,e.endsWith(`{`)&&n++;return t.trim()}let pd=ul.content,md={"=":`EQ`,"+":`ADD`,"-":`MINUS`,"*":`MULTIPLY`,"/":`DIVIDE`,">=":`GTE`,"<>":`NE`,">":`GT`,"<=":`LTE`,"<":`LT`,"^":`POWER`,"&":`CONCATENATE`},hd={"-":`UMINUS`,"+":`UPLUS`,"%":`UNARY.PERCENT`,"#":`SPILLED.RANGE`},gd={},_d={},vd=new Intl.Collator(`en`,{sensitivity:`accent`});var yd=class e{sheetId;tokens;literalValues;symbols;isBadExpression;normalizedFormula;execute;computeFunctions;rangeDependencies;hasDependencies;constructor(e,t,n,r,i,a,o,s,c){this.sheetId=e,this.tokens=t,this.literalValues=n,this.symbols=r,this.isBadExpression=a,this.normalizedFormula=o,this.execute=s,this.computeFunctions=c,this.hasDependencies=i?.length>0,this.tokens.forEach(e=>{[`REFERENCE`,`NUMBER`,`STRING`,`INVALID_REFERENCE`].includes(e.type)&&(e.value=`__NO_REAL_VALUE__`)}),this.rangeDependencies=i}getTokens(e,t){let n=0,r=0,i=0;return this.isBadExpression||this.tokens.forEach(a=>{switch(a.type){case`REFERENCE`:case`INVALID_REFERENCE`:a.value=e.getRangeString(this.rangeDependencies[n++],this.sheetId,t);break;case`NUMBER`:a.value=this.literalValues.numbers[r++].value.toString();break;case`STRING`:a.value=`"${this.literalValues.strings[i++].value}"`;break}}),this.tokens}getAst(e){return vu(this.getTokens(e))}toFormulaString(e,t){return this.isBadExpression?this.normalizedFormula:$t(this.getTokens(e,t).filter(e=>e.type!==`SPACE`).map(e=>e.value))}getNamedRangesInFormula(e){let t=[];for(let n=0;n<this.tokens.length;n++)if(Qu(this.tokens,n)){let r=e.getNamedRange(this.tokens[n].value);r&&t.push(r)}return t}usesSymbol(e){return this.symbols.some(t=>vd.compare(t,e)===0)}areAllFunctionsExportableToExcel(){return this.isBadExpression?!1:!bu(vu(this.tokens)).some(e=>e.type===`FUNCALL`&&!pd[e.value.toUpperCase()]?.isExported)}getFunctionsFromTokens(e,t){return this.isBadExpression||!e.some(e=>this.usesSymbol(e))?[]:bu(this.getAst(t)).filter(t=>t.type===`FUNCALL`&&e.includes(t.value.toUpperCase())).map(e=>({functionName:e.value.toUpperCase(),args:e.args}))}isFirstNonWhitespaceSymbol(e){let t=this.tokens.find((e,t)=>t>0&&e.type!==`SPACE`);return t?.type===`SYMBOL`&&t.value.toUpperCase()===e}adaptCompiledFormula(t,n){let r=[],i=!1;for(let e of this.rangeDependencies){let n=t(e);r.push(n.range),n.changeType!==`NONE`&&(i=!0)}let a=this.renameNamedRangeTokens(n);return i||a?new e(this.sheetId,a?.newTokens||this.tokens,this.literalValues,a?.newSymbols||this.symbols,r,this.isBadExpression,Sd(a?.newTokens||this.tokens),this.execute,this.computeFunctions):this}renameNamedRangeTokens(e){let t=!1,n=[],r=[];for(let i=0;i<this.tokens.length;i++){let a=this.tokens[i];if(Qu(this.tokens,i)){let n=e(this.tokens[i].value);n!==this.tokens[i].value&&(t=!0,a={...this.tokens[i],value:n})}n.push(a),a.type===`SYMBOL`&&r.push(a.value)}return t?{newSymbols:r,newTokens:n}:void 0}static IsBadExpression(e){return bd(au(e)).isBadExpression}static CopyWithDependencies(t,n,r){return new e(n,t.tokens,t.literalValues,t.symbols,r,t.isBadExpression,t.normalizedFormula,t.execute,t.computeFunctions)}static CopyWithDependenciesAndLiteral(t,n,r,i,a){return new e(n,t.tokens,{numbers:i,strings:a},t.symbols,r,t.isBadExpression,t.normalizedFormula,t.execute,t.computeFunctions)}static CompileForSerializedFormula(t,n){let r=bd(n.tokens);return new e(t,n.tokens,n.literalValues,n.symbols,n.rangeDependencies,n.isBadExpression,n.normalizedFormula,r.execute,r.computeFunctions)}static Compile(t,n,r){let i=bd(au(t));return new e(n,i.tokens,i.literalValues,i.symbols,i.dependencies.map(e=>r.getRangeFromSheetXC(n,e)),i.isBadExpression,i.normalizedFormula,i.execute,i.computeFunctions)}areRangeShapesInLineWithNormalizedFormula(){return Array.from(this.normalizedFormula.matchAll(/\|C\||\|R\|/g)).every((e,t)=>this.rangeDependencies[t].parts.length===1&&e[0]===`|C|`||this.rangeDependencies[t].parts.length===2&&e[0]===`|R|`||this.rangeDependencies[t].invalidXc||this.rangeDependencies[t].invalidSheetName)}};function bd(e){try{return xd(e)}catch(t){if(!(t instanceof F))throw t;return{tokens:e,literalValues:{numbers:[],strings:[]},symbols:[],dependencies:[],execute:function(){return t},computeFunctions:[],isBadExpression:!0,normalizedFormula:e.map(e=>e.value).join(``)}}}function xd(e){let{dependencies:t,literalValues:n,symbols:r}=Cd(e),i=Sd(e);if(!gd[i]){let t=vu([...e]),n=new ud,s=0,c=0,l=0,u=[];if(t.type===`BIN_OPERATION`&&t.value===`:`||t.type===`EMPTY`)throw new Do(N(`Invalid formula`));let d=o(t),f=new cd;f.append(d),f.append(od`return ${d.returnExpression};`),gd[i]=Function(`deps`,`ref`,`range`,`getSymbolValue`,`ctx`,`computeFunctions`,f.toString()),_d[i]=u;function a(e){let{args:t}=e,n=e.value.toUpperCase(),r=pd[n];if(!r)throw new jo(N(`Unknown function: "%s"`,e.value));wd(e);let i=[],a=Xc(r,t.length);for(let e=0;e<t.length;e++){let s=r.args[a[e].index],c=t[e],l=o(c,s.acceptMatrix);if(s.acceptMatrixOnly&&!l.returnsMatrix)throw new Do(N(`Function %s expects the parameter '%s' to be reference to a cell or range.`,n,(e+1).toString()));let u=!s.acceptMatrix&&l.returnsMatrix;i.push({argAST:l,toVectorize:u})}return i}function o(e,t=!1){let i=new cd(n);switch(e.debug&&(i.append(od`debugger;`),i.append(od`ctx["debug"] = true;`)),e.type){case`BOOLEAN`:return i.return(od`{ value: ${e.value} }`);case`NUMBER`:return i.return(od`this.literalValues.numbers[${c++}]`);case`STRING`:return i.return(od`this.literalValues.strings[${s++}]`);case`REFERENCE`:let n=e.value.includes(`:`)||t;return i.return(od`${n?od`range`:od`ref`}(deps[${l++}])`,n);case`FUNCALL`:let d=a(e),f=d.map(e=>e.argAST.assignResultToVariable());i.append(...f);let p=e.value.toUpperCase();if(!Object.hasOwn(pd,p))throw Error(`Unknown function: "${p}"`);let m=ad(p),h=u.length,g=[];for(let e=0;e<d.length;e++)d[e].toVectorize&&g.push(e);u.push(nl(pd[p],f.length,g));let _=pd[p].computeArray!==void 0||g.length>0,v=od`// ${m}`,ee=[od`ctx`,...f.map(e=>e.returnExpression)];return i.return(od`computeFunctions[${h}](${ee}); ${v}`,_);case`ARRAY`:return o(Td(`ARRAY.LITERAL`,e.value.map(e=>Td(`ARRAY.ROW`,e))));case`UNARY_OPERATION`:return o(Td(hd[e.value],[e.operand]));case`BIN_OPERATION`:return o(Td(md[e.value],[e.left,e.right]));case`SYMBOL`:let y=r.indexOf(e.value);return i.return(od`getSymbolValue(this.symbols[${y}], ${t})`,!0);case`EMPTY`:return i.return(od`undefined`)}}}return{execute:gd[i],computeFunctions:_d[i],dependencies:t,literalValues:n,symbols:r,tokens:e,isBadExpression:!1,normalizedFormula:i}}function Sd(e){let t=``;for(let n of e)switch(n.type){case`STRING`:t+=`|S|`;break;case`NUMBER`:t+=`|N|`;break;case`REFERENCE`:case`INVALID_REFERENCE`:n.value.includes(`:`)?t+=`|R|`:t+=`|C|`;break;case`SPACE`:break;default:t+=n.value;break}return t}function Cd(e){let t={numbers:[],strings:[]},n=[],r=[];for(let i of e)switch(i.type){case`INVALID_REFERENCE`:case`REFERENCE`:n.push(i.value);break;case`STRING`:let e=Nt(i.value);t.strings.push({value:e});break;case`NUMBER`:{let e=go(i.value,B);t.numbers.push({value:e});break}case`SYMBOL`:r.push(Nt(i.value,`'`))}return{dependencies:n,literalValues:t,symbols:r}}function wd(e){let t=e.args.length,n=e.value.toUpperCase(),r=pd[n],{nbrArgRepeating:i,minArgRequired:a}=r;if(t<a)throw new Do(N(`Invalid number of arguments for the %(functionName)s function. Expected %(minArgRequired)s minimum, but got %(nbrArgSupplied)s instead.`,{functionName:n,minArgRequired:a,nbrArgSupplied:t}));if(t>r.maxArgPossible)throw new Do(N(`Invalid number of arguments for the %(functionName)s function. Expected %(maxArgPossible)s maximum, but got %(nbrArgSupplied)s instead.`,{functionName:n,maxArgPossible:r.maxArgPossible,nbrArgSupplied:t}));if(i>1){let e=i*Math.floor((t-a)/i),o=t-a-e-r.nbrOptionalNonRepeatingArgs;if(o>0)throw new Do(N(`Invalid number of arguments for the %(functionName)s function. Repeatable arguments should be supplied in groups of %(nbrArgRepeating)s, with up to %(nbrArgOptional)s optional. Got %(nbrValueRemaining)s too many.`,{functionName:n,nbrArgRepeating:i,nbrArgOptional:r.nbrOptionalNonRepeatingArgs,nbrValueRemaining:o}))}}function Td(e,t){return{type:`FUNCALL`,value:e,args:t,tokenStartIndex:0,tokenEndIndex:0}}let Ed=function(e){return e.boolean=`boolean`,e.number=`number`,e.text=`text`,e.empty=`empty`,e.error=`error`,e}({});function Dd(e){return`sheetId`in e}function Od(e){return`dimension`in e&&`sheetId`in e&&`elements`in e}function kd(e){return`target`in e&&`sheetId`in e}function Ad(e){return`ranges`in e}function jd(e){return`col`in e&&`row`in e&&`sheetId`in e}function Md(e){return`sheetId`in e&&`zone`in e}let Nd=new Set([`RENAME_SHEET`,`DELETE_SHEET`,`CREATE_SHEET`,`DUPLICATE_SHEET`,`ADD_COLUMNS_ROWS`,`REMOVE_COLUMNS_ROWS`,`UNDO`,`REDO`,`ADD_MERGE`,`REMOVE_MERGE`,`UPDATE_LOCALE`,`ADD_PIVOT`,`UPDATE_PIVOT`,`INSERT_PIVOT`,`RENAME_PIVOT`,`REMOVE_PIVOT`,`DUPLICATE_PIVOT`,`CREATE_NAMED_RANGE`,`UPDATE_NAMED_RANGE`,`DELETE_NAMED_RANGE`]),Pd=new Set([`EVALUATE_CELLS`,`EVALUATE_CHARTS`,`UPDATE_CELL`,`UNHIDE_COLUMNS_ROWS`,`HIDE_COLUMNS_ROWS`,`GROUP_HEADERS`,`UNGROUP_HEADERS`,`FOLD_ALL_HEADER_GROUPS`,`FOLD_HEADER_GROUP`,`FOLD_HEADER_GROUPS_IN_ZONE`,`UNFOLD_ALL_HEADER_GROUPS`,`UNFOLD_HEADER_GROUP`,`UNFOLD_HEADER_GROUPS_IN_ZONE`,`UPDATE_TABLE`,`UPDATE_FILTER`,`UNDO`,`REDO`]),Fd=new Set([`MOVE_RANGES`]),Id=new Set([`EVALUATE_CELLS`,`ADD_CONDITIONAL_FORMAT`,`REMOVE_CONDITIONAL_FORMAT`,`CHANGE_CONDITIONAL_FORMAT_PRIORITY`]),Ld=new Set([`SET_BORDER`,`SET_ZONE_BORDERS`,`SET_BORDERS_ON_TARGET`]),Rd=new Set([`UNHIDE_COLUMNS_ROWS`,`HIDE_COLUMNS_ROWS`,`GROUP_HEADERS`,`UNGROUP_HEADERS`,`FOLD_ALL_HEADER_GROUPS`,`FOLD_HEADER_GROUP`,`FOLD_HEADER_GROUPS_IN_ZONE`,`UNFOLD_ALL_HEADER_GROUPS`,`UNFOLD_HEADER_GROUP`,`UNFOLD_HEADER_GROUPS_IN_ZONE`,`UPDATE_TABLE`,`UPDATE_FILTER`]),zd=new Set([`START`,`ACTIVATE_SHEET`,`COPY`,`EVALUATE_CELLS`,`EVALUATE_CHARTS`,`SET_FORMULA_VISIBILITY`,`SET_AUTOMATIC_EVALUATION`,`UPDATE_FILTER`,`UPDATE_CHART`,`UPDATE_CHART_REGION`,`UPDATE_CAROUSEL_ACTIVE_ITEM`,`UPDATE_PIVOT`,`UPDATE_COLOR_SCHEME`]),Bd=new Set([`LOCK_SHEET`,`UNLOCK_SHEET`,`MOVE_SHEET`,`DUPLICATE_SHEET`,`CREATE_SHEET`,`HIDE_SHEET`,`SHOW_SHEET`,`COPY`,`START`,`ACTIVATE_SHEET`,`SET_FORMULA_VISIBILITY`,`SELECT_FIGURE`,`EVALUATE_CHARTS`,`EVALUATE_CELLS`,`REQUEST_UNDO`,`REQUEST_REDO`,`REPLACE_SEARCH`,`UPDATE_CAROUSEL_ACTIVE_ITEM`,`DUPLICATE_PIVOT_IN_NEW_SHEET`,`UPDATE_FILTER`,`ACTIVATE_NEXT_SHEET`,`ACTIVATE_PREVIOUS_SHEET`]),Vd=new Set(`UPDATE_CELL.UPDATE_CELL_POSITION.CLEAR_CELL.CLEAR_CELLS.DELETE_CONTENT.ADD_COLUMNS_ROWS.REMOVE_COLUMNS_ROWS.RESIZE_COLUMNS_ROWS.HIDE_COLUMNS_ROWS.UNHIDE_COLUMNS_ROWS.SET_GRID_LINES_VISIBILITY.UNFREEZE_COLUMNS.UNFREEZE_ROWS.FREEZE_COLUMNS.FREEZE_ROWS.UNFREEZE_COLUMNS_ROWS.ADD_MERGE.REMOVE_MERGE.CREATE_SHEET.DELETE_SHEET.DUPLICATE_SHEET.MOVE_SHEET.RENAME_SHEET.COLOR_SHEET.SET_SHEET_BACKGROUND_COLOR.HIDE_SHEET.SHOW_SHEET.LOCK_SHEET.UNLOCK_SHEET.MOVE_RANGES.ADD_CONDITIONAL_FORMAT.REMOVE_CONDITIONAL_FORMAT.CHANGE_CONDITIONAL_FORMAT_PRIORITY.CREATE_FIGURE.DELETE_FIGURE.UPDATE_FIGURE.CREATE_CAROUSEL.UPDATE_CAROUSEL.SET_FORMATTING.CLEAR_FORMATTING.SET_BORDER.SET_ZONE_BORDERS.SET_BORDERS_ON_TARGET.CREATE_CHART.UPDATE_CHART.DELETE_CHART.CREATE_TABLE.REMOVE_TABLE.UPDATE_TABLE.CREATE_TABLE_STYLE.REMOVE_TABLE_STYLE.CREATE_IMAGE.GROUP_HEADERS.UNGROUP_HEADERS.UNFOLD_HEADER_GROUP.FOLD_HEADER_GROUP.FOLD_ALL_HEADER_GROUPS.UNFOLD_ALL_HEADER_GROUPS.UNFOLD_HEADER_GROUPS_IN_ZONE.FOLD_HEADER_GROUPS_IN_ZONE.ADD_DATA_VALIDATION_RULE.REMOVE_DATA_VALIDATION_RULE.UPDATE_LOCALE.CREATE_NAMED_RANGE.UPDATE_NAMED_RANGE.DELETE_NAMED_RANGE.ADD_PIVOT.UPDATE_PIVOT.INSERT_PIVOT.RENAME_PIVOT.REMOVE_PIVOT.DUPLICATE_PIVOT`.split(`.`)),Hd=new Set([`EVALUATE_CELLS`,`EVALUATE_CHARTS`]),Ud=new Set([...Vd,...Hd,`UNDO`,`REDO`,`START`,`UPDATE_FILTER`,`SET_AUTOMATIC_EVALUATION`,`REFRESH_PIVOT`,`PIVOT_START_PRESENCE_TRACKING`,`PIVOT_STOP_PRESENCE_TRACKING`]);function Wd(e){return Vd.has(e.type)}function Gd(e){return Hd.has(e.type)}function Kd(e){return Ud.has(e.type)}function qd(e){return zd.has(e.type)}var Jd=class{reasons;constructor(e=[]){Array.isArray(e)||(e=[e]),e=[...new Set(e)],this.reasons=e.filter(e=>e!==`Success`)}static get Success(){return Yd}get isSuccessful(){return this.reasons.length===0}isCancelledBecause(e){return this.reasons.includes(e)}};let Yd=new Jd,Xd=function(e){return e.Success=`Success`,e.CancelledForUnknownReason=`CancelledForUnknownReason`,e.WillRemoveExistingMerge=`WillRemoveExistingMerge`,e.CannotMoveTableHeader=`CannotMoveTableHeader`,e.MergeIsDestructive=`MergeIsDestructive`,e.CellIsMerged=`CellIsMerged`,e.InvalidTarget=`InvalidTarget`,e.EmptyUndoStack=`EmptyUndoStack`,e.EmptyRedoStack=`EmptyRedoStack`,e.NotEnoughElements=`NotEnoughElements`,e.NotEnoughSheets=`NotEnoughSheets`,e.MissingSheetName=`MissingSheetName`,e.UnchangedSheetName=`UnchangedSheetName`,e.DuplicatedSheetName=`DuplicatedSheetName`,e.DuplicatedSheetId=`DuplicatedSheetId`,e.ForbiddenCharactersInSheetName=`ForbiddenCharactersInSheetName`,e.WrongSheetMove=`WrongSheetMove`,e.WrongSheetPosition=`WrongSheetPosition`,e.InvalidAnchorZone=`InvalidAnchorZone`,e.SelectionOutOfBound=`SelectionOutOfBound`,e.TargetOutOfSheet=`TargetOutOfSheet`,e.WrongCutSelection=`WrongCutSelection`,e.WrongPasteSelection=`WrongPasteSelection`,e.WrongPasteOption=`WrongPasteOption`,e.WrongFigurePasteOption=`WrongFigurePasteOption`,e.EmptyClipboard=`EmptyClipboard`,e.EmptyRange=`EmptyRange`,e.EmptyTarget=`EmptyTarget`,e.InvalidRange=`InvalidRange`,e.InvalidZones=`InvalidZones`,e.InvalidSheetId=`InvalidSheetId`,e.InvalidCellId=`InvalidCellId`,e.InvalidFigureId=`InvalidFigureId`,e.InputAlreadyFocused=`InputAlreadyFocused`,e.MaximumRangesReached=`MaximumRangesReached`,e.MinimumRangesReached=`MinimumRangesReached`,e.InvalidChartDefinition=`InvalidChartDefinition`,e.InvalidDataSet=`InvalidDataSet`,e.InvalidYRange=`InvalidYRange`,e.InvalidXRange=`InvalidXRange`,e.InvalidLabelRange=`InvalidLabelRange`,e.InvalidBubbleSizeRange=`InvalidBubbleSizeRange`,e.InvalidGaugeDataRange=`InvalidGaugeDataRange`,e.EmptyGaugeRangeMin=`EmptyGaugeRangeMin`,e.GaugeRangeMinNaN=`GaugeRangeMinNaN`,e.EmptyGaugeRangeMax=`EmptyGaugeRangeMax`,e.GaugeRangeMaxNaN=`GaugeRangeMaxNaN`,e.GaugeLowerInflectionPointNaN=`GaugeLowerInflectionPointNaN`,e.GaugeUpperInflectionPointNaN=`GaugeUpperInflectionPointNaN`,e.InvalidAutofillSelection=`InvalidAutofillSelection`,e.MinBiggerThanMax=`MinBiggerThanMax`,e.LowerBiggerThanUpper=`LowerBiggerThanUpper`,e.MidBiggerThanMax=`MidBiggerThanMax`,e.MinBiggerThanMid=`MinBiggerThanMid`,e.FirstArgMissing=`FirstArgMissing`,e.SecondArgMissing=`SecondArgMissing`,e.MinNaN=`MinNaN`,e.MidNaN=`MidNaN`,e.MaxNaN=`MaxNaN`,e.ValueUpperInflectionNaN=`ValueUpperInflectionNaN`,e.ValueLowerInflectionNaN=`ValueLowerInflectionNaN`,e.MinInvalidFormula=`MinInvalidFormula`,e.MidInvalidFormula=`MidInvalidFormula`,e.MaxInvalidFormula=`MaxInvalidFormula`,e.ValueUpperInvalidFormula=`ValueUpperInvalidFormula`,e.ValueLowerInvalidFormula=`ValueLowerInvalidFormula`,e.InvalidSortAnchor=`InvalidSortAnchor`,e.InvalidSortZone=`InvalidSortZone`,e.SortZoneWithArrayFormulas=`SortZoneWithArrayFormulas`,e.WaitingSessionConfirmation=`WaitingSessionConfirmation`,e.MergeOverlap=`MergeOverlap`,e.TooManyHiddenElements=`TooManyHiddenElements`,e.Readonly=`Readonly`,e.FigureDoesNotExist=`FigureDoesNotExist`,e.InvalidConditionalFormatId=`InvalidConditionalFormatId`,e.InvalidConditionalFormatType=`InvalidConditionalFormatType`,e.InvalidCellPopover=`InvalidCellPopover`,e.EmptySelectedRange=`EmptySelectedRange`,e.InvalidFreezeQuantity=`InvalidFreezeQuantity`,e.FrozenPaneOverlap=`FrozenPaneOverlap`,e.InvalidFilterZone=`InvalidFilterZone`,e.TableNotFound=`TableNotFound`,e.TableOverlap=`TableOverlap`,e.InvalidTableConfig=`InvalidTableConfig`,e.InvalidTableStyle=`InvalidTableStyle`,e.FilterNotFound=`FilterNotFound`,e.MergeInTable=`MergeInTable`,e.NonContinuousTargets=`NonContinuousTargets`,e.DuplicatedFigureId=`DuplicatedFigureId`,e.InvalidSelectionStep=`InvalidSelectionStep`,e.DuplicatedChartId=`DuplicatedChartId`,e.ChartDoesNotExist=`ChartDoesNotExist`,e.InvalidHeaderIndex=`InvalidHeaderIndex`,e.InvalidQuantity=`InvalidQuantity`,e.MoreThanOneColumnSelected=`MoreThanOneColumnSelected`,e.EmptySplitSeparator=`EmptySplitSeparator`,e.SplitWillOverwriteContent=`SplitWillOverwriteContent`,e.NoSplitSeparatorInSelection=`NoSplitSeparatorInSelection`,e.NoActiveSheet=`NoActiveSheet`,e.InvalidLocale=`InvalidLocale`,e.MoreThanOneRangeSelected=`MoreThanOneRangeSelected`,e.NoColumnsProvided=`NoColumnsProvided`,e.ColumnsNotIncludedInZone=`ColumnsNotIncludedInZone`,e.InvalidHeaderGroupStartEnd=`InvalidHeaderGroupStartEnd`,e.HeaderGroupAlreadyExists=`HeaderGroupAlreadyExists`,e.UnknownHeaderGroup=`UnknownHeaderGroup`,e.UnknownDataValidationRule=`UnknownDataValidationRule`,e.UnknownDataValidationCriterionType=`UnknownDataValidationCriterionType`,e.InvalidDataValidationCriterionValue=`InvalidDataValidationCriterionValue`,e.InvalidNumberOfCriterionValues=`InvalidNumberOfCriterionValues`,e.InvalidCopyPasteSelection=`InvalidCopyPasteSelection`,e.NoChanges=`NoChanges`,e.InvalidInputId=`InvalidInputId`,e.SheetIsHidden=`SheetIsHidden`,e.InvalidTableResize=`InvalidTableResize`,e.PivotIdNotFound=`PivotIdNotFound`,e.PivotIdTaken=`PivotIdTaken`,e.PivotInError=`PivotInError`,e.EmptyName=`EmptyName`,e.ValueCellIsInvalidFormula=`ValueCellIsInvalidFormula`,e.InvalidDefinition=`InvalidDefinition`,e.InvalidColor=`InvalidColor`,e.InvalidPivotDataSet=`InvalidPivotDataSet`,e.InvalidPivotCustomField=`InvalidPivotCustomField`,e.MissingFigureArguments=`MissingFigureArguments`,e.InvalidCarouselItem=`InvalidCarouselItem`,e.SheetLocked=`SheetLocked`,e.NamedRangeNameAlreadyExists=`NamedRangeNameAlreadyExists`,e.NamedRangeInvalidName=`NamedRangeInvalidName`,e.NamedRangeNameLooksLikeCellReference=`NamedRangeNameLooksLikeCellReference`,e.NamedRangeNotFound=`NamedRangeNotFound`,e.SubCommandOnly=`SubCommandOnly`,e.NoChangeInAutomaticEvaluation=`NoChangeInAutomaticEvaluation`,e}({});function Zd(e){return/^https?:\/\//i.test(e)?e:`https://${e}`}let Qd=new O;function $d(e,t){return e=Zd(e),{url:e,label:t||e,isExternal:!0,isUrlEditable:!0}}Qd.add(`sheet_URL`,{match:e=>Kt(e),createLink:(e,t)=>({label:t,url:e,isExternal:!1,isUrlEditable:!1}),urlRepresentation(e,t){let n=Jt(e);return t.tryGetSheetName(n)||N(`Invalid sheet`)},open(e,t){let n=Jt(e);t.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:t.model.getters.getActiveSheetId(),sheetIdTo:n}).isCancelledBecause(`SheetIsHidden`)&&t.notifyUser({type:`warning`,sticky:!1,text:N(`Cannot open the link because the linked sheet is hidden.`)})},sequence:0,title:N(`Sheets`),getLinkProposals(e){return e.model.getters.getSheetIds().map(t=>{let n=e.model.getters.getSheet(t);return{...this.createLink(qt(t),n.name),icon:`o-spreadsheet-Icon.INSERT_SHEET`}})}});let ef={createLink:$d,match:e=>Ht(e),open:e=>window.open(e,`_blank`),urlRepresentation:e=>e,sequence:0,title:N(`Web`)};function tf(e){return Qd.getAll().sort((e,t)=>e.sequence-t.sequence).find(t=>t.match(e))||ef}function nf(e,t){return tf(e.url).urlRepresentation(e.url,t)}function rf(e,t,n){tf(e.url).open(e.url,t,n)}function af(e){if(typeof e==`string`){if(Vt(e)){let{label:t,url:n}=Wt(e);return tf(n).createLink(n,t)}else if(Ht(e))return $d(e)}}function of(e,t,n){return ff({value:Bc(t.format)&&e.parsedValue!==null?e.content:e.parsedValue,format:t.format,origin:n},t.locale,n)}function sf(e,t,n,r,i,a,o){return n.startsWith(`=`)?lf(e,t,n,r,i,a):cf(e,t,n,r,i,o)}function cf(e,t,n,r,i,a){let o=e.getLocale(),s=df(n,o);if(r===void 0&&typeof s==`number`){let e=Cc(n,o);if(a?.avoidAutomaticDateFormat&&e)return{id:t,content:n,style:i,format:r,isFormula:!1,parsedValue:n};r=e||wc(n)}return!Bc(r)&&!n.startsWith(`'`)&&!Lo(n)&&(n=L(s)),{id:t,content:n,style:i,format:r,isFormula:!1,parsedValue:s}}function lf(e,t,n,r,i,a){return uf(t,yd.Compile(n,a,e),r,i)}function uf(e,t,n,r){return{id:e,format:n,style:r,isFormula:!0,compiledFormula:t}}function df(e,t){if(e.startsWith(`=`))throw Error(`Cannot parse "${e}" because it's not a literal value. It's a formula`);if(e.startsWith(`'`))return e.slice(1);if(e===``)return null;if(e.includes(`
15
15
  `))return e;if(mo(e,B))return go(e,B);let n=La(e,t);return n?n.value:Rt(e)?e.toUpperCase()===`TRUE`:e}function ff(e,t=B,n,r,i){let a=af(e.value);if(!a)return Tf(pf(e,t,n,r),e.origin??i);let o=df(a.label,t);return Tf({...pf({value:o,format:e.format||(typeof o==`number`?Cc(a.label,t)||wc(a.label):void 0)},t,n,r),link:a},e.origin??n)}function pf(e,t,n,r){let{value:i,format:a,message:o,errorOriginPosition:s}=e;a=r||a;let c=V(i,{format:a,locale:t});return Lo(i)?wf(i,o,n,s):i===null?xf(a):Bc(a)?yf(L(i),a,c,n):typeof i==`number`?vc(a||``)?Sf(i,a,c,n):bf(i,a,c,n):typeof i==`boolean`?Cf(i,a,c,n):yf(i,a,c,n)}function mf(e){return!!e&&vf(e)===`number`}function hf(e){return!!e&&vf(e)===`text`}function gf(e){return!!e&&vf(e)===`boolean`}function _f(e){return!!e&&vf(e)===`error`}function vf({value:e,format:t}){if(e===null)return`empty`;if(Lo(e))return`error`;if(Bc(t))return`text`;switch(typeof e){case`number`:return`number`;case`boolean`:return`boolean`;case`string`:return`text`}}function yf(e,t,n,r){return{value:e,format:t,formattedValue:n,position:r,type:`text`,isAutoSummable:!0,defaultAlign:`left`}}function bf(e,t,n,r){return{value:e||0,format:t,formattedValue:n,position:r,type:`number`,isAutoSummable:!0,defaultAlign:`right`}}let xf=mn(function(e){return{value:null,format:e,formattedValue:``,type:`empty`,isAutoSummable:!0,defaultAlign:`left`}});function Sf(e,t,n,r){return{value:e,format:t,formattedValue:n,position:r,type:`number`,isAutoSummable:!1,defaultAlign:`right`}}function Cf(e,t,n,r){return{value:e,format:t,formattedValue:n,position:r,type:`boolean`,isAutoSummable:!1,defaultAlign:`center`}}function wf(e,t,n,r){return{value:e,formattedValue:e,message:t,position:n,type:`error`,isAutoSummable:!1,defaultAlign:`center`,errorOriginPosition:r}}function Tf(e,t){return e.value===null||`origin`in e||(e.origin=t),e}let Ef=/rgba?\(|\s+|\)/gi,Df=/^#([A-F\d]{2}){3,4}$/,Of=/^light-dark\(\s*(rgba?\([0-9.,\s]+\)|#[a-f0-9]+)\s*,\s*(rgba?\([0-9.,\s]+\)|#[a-f0-9]+)\s*\)$/i,kf=[`#eb6d00`,`#0074d9`,`#ad8e00`,`#169ed4`,`#b10dc9`,`#00a82d`,`#00a3a3`,`#f012be`,`#3d9970`,`#62A300`,`#ff4136`,`#949494`,`#ff5c9d`];function Af(e,t=1){let n=t===1?``:Math.round(t*255).toString(16).padStart(2,`0`);return Mf(e.toString(16).padStart(6,`0`))+n}function jf(e){return typeof e==`number`?e:Number.parseInt(Mf(e).slice(1,7),16)}function Mf(e){let t=e;if(e.startsWith(`light-dark`)){let t=e.match(Of);if(!t)throw Error(`Invalid light-dark color: ${e}`);return`light-dark(${Mf(t[1])}, ${Mf(t[2])})`}if(e.startsWith(`rgb`)?t=Rf(e):(t=e.replace(`#`,``).toUpperCase(),(t.length===3||t.length===4)&&(t=t.split(``).reduce((e,t)=>e+t+t,``)),t=`#${t}`),!Df.test(t))throw Error(`invalid color input: ${e}`);return t}function Nf(e){try{return Mf(e),!0}catch{return!1}}function Pf(e){try{return Uf(e),!0}catch{return!1}}let Ff=e=>e>=0&&e<=255;function If(e,t,n,r=1){if(!Ff(e)||!Ff(t)||!Ff(n)||r<0||r>1)throw Error(`Invalid RGBA values ${[e,t,n,r]}`);return{a:r,b:n,g:t,r:e}}function Lf(e){let{r:t,g:n,b:r}=Bf(e);t/=255,n/=255,r/=255;let i=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4,a=i(t),o=i(n),s=i(r);return .2126*a+.7152*o+.0722*s}function Rf(e){let t=e.replace(Ef,``).split(`,`),n=255;if(t.length!==3&&t.length!==4)throw Error(`invalid color`);if(t.length===4){let e=parseFloat(t.pop()||`1`);if(isNaN(e))throw Error(`invalid alpha value`);n=Math.round(e*255)}let r=t.map(e=>parseInt(e,10));return n!==255&&r.push(n),`#`+$t(r.map(e=>e.toString(16).padStart(2,`0`))).toUpperCase()}function zf(e){let t=e.r.toString(16),n=e.g.toString(16),r=e.b.toString(16),i=Math.round(e.a*255).toString(16);return t.length===1&&(t=`0`+t),n.length===1&&(n=`0`+n),r.length===1&&(r=`0`+r),i.length===1&&(i=`0`+i),i===`ff`&&(i=``),(`#`+t+n+r+i).toUpperCase()}function Bf(e){e=Mf(e);let t,n,r,i;if(e.length===7)t=parseInt(e[1]+e[2],16),n=parseInt(e[3]+e[4],16),r=parseInt(e[5]+e[6],16),i=255;else if(e.length===9)t=parseInt(e[1]+e[2],16),n=parseInt(e[3]+e[4],16),r=parseInt(e[5]+e[6],16),i=parseInt(e[7]+e[8],16);else throw Error(`Invalid color`);return i=+(i/255).toFixed(3),{a:i,r:t,g:n,b:r}}function Vf(e){e={...e},e.s/=100,e.l/=100;let t=(1-Math.abs(2*e.l-1))*e.s,n=t*(1-Math.abs(e.h/60%2-1)),r=e.l-t/2,i=0,a=0,o=0;return 0<=e.h&&e.h<60?(i=t,a=n,o=0):60<=e.h&&e.h<120?(i=n,a=t,o=0):120<=e.h&&e.h<180?(i=0,a=t,o=n):180<=e.h&&e.h<240?(i=0,a=n,o=t):240<=e.h&&e.h<300?(i=n,a=0,o=t):300<=e.h&&e.h<360&&(i=t,a=0,o=n),i=Math.round((i+r)*255),a=Math.round((a+r)*255),o=Math.round((o+r)*255),{a:e.a,r:i,g:a,b:o}}function Hf(e){let t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=a-i,s=0,c=0,l=0;return s=o===0?0:a===t?(n-r)/o%6:a===n?(r-t)/o+2:(t-n)/o+4,s=Math.round(s*60),s<0&&(s+=360),l=(a+i)/2,c=o===0?0:o/(1-Math.abs(2*l-1)),c=+(c*100).toFixed(1),l=+(l*100).toFixed(1),{a:e.a,h:s,s:c,l}}function Uf(e){return zf(Vf(e))}function Wf(e){return Hf(Bf(e))}function Gf(e,t){let n=Bf(t),r=Bf(e),i=n.a+r.a*(1-n.a);return zf({r:Math.round((n.r*n.a+r.r*r.a*(1-n.a))/i),g:Math.round((n.g*n.a+r.g*r.a*(1-n.a))/i),b:Math.round((n.b*n.a+r.b*r.a*(1-n.a))/i),a:i})}function Kf(e){return Bf(typeof e==`number`?Af(e):e)}function qf(e,t,n=0){if(!(Nf(e)&&Nf(t)))return!1;let r=Bf(e),i=Bf(t);return r.a===i.a?Math.sqrt(((r.r-i.r)/255)**2+((r.g-i.g)/255)**2+((r.b-i.b)/255)**2)<=n:!1}function Jf(e,t){if(e.startsWith(`light-dark`)){let n=e.match(Of);if(!n)throw Error(`Invalid light-dark color: ${e}`);return`light-dark(${Jf(n[1],t)}, ${Jf(n[2],t)})`}return t===1?Mf(e).slice(0,7):zf({...Bf(e),a:t})}function Yf(e,t){let n=Wf(e);return t===1?`#fff`:(n.l=t*(100-n.l)+n.l,Uf(n))}let Xf={invert:1,hueRotate:170,contrast:.85,brightness:1.2},Zf=`invert(${Xf.invert}) hue-rotate(${Xf.hueRotate}deg) contrast(${Xf.contrast}) brightness(${Xf.brightness})`;function Qf(e){let t=e*Math.PI/180,n=Math.cos(t),r=Math.sin(t);return[[.213+n*.787-r*.213,.715-n*.715-r*.715,.072-n*.072+r*.928],[.213-n*.213+r*.143,.715+n*.285+r*.14,.072-n*.072-r*.283],[.213-n*.213-r*.787,.715-n*.715+r*.715,.072+n*.928+r*.072]]}function $f(e){let{r:t,g:n,b:r,a:i}=Bf(e),a=t/255,o=n/255,s=r/255;a/=Xf.brightness,o/=Xf.brightness,s/=Xf.brightness,a=(a-.5)/Xf.contrast+.5,o=(o-.5)/Xf.contrast+.5,s=(s-.5)/Xf.contrast+.5,a=Math.max(0,Math.min(1,a)),o=Math.max(0,Math.min(1,o)),s=Math.max(0,Math.min(1,s));let c=Qf(-Xf.hueRotate),l=Math.max(0,Math.min(1,c[0][0]*a+c[0][1]*o+c[0][2]*s)),u=Math.max(0,Math.min(1,c[1][0]*a+c[1][1]*o+c[1][2]*s)),d=Math.max(0,Math.min(1,c[2][0]*a+c[2][1]*o+c[2][2]*s));return zf({r:Math.round((1-l)*255),g:Math.round((1-u)*255),b:Math.round((1-d)*255),a:i})}function ep(e,t){let n=Wf(e);return t===1?`#000`:(n.s=Math.min(100,t*n.s+n.s),n.l-=t*n.l,Uf(n))}function tp(e){return Lf(e)<.6?Yf(e,.9):ep(e,.75)}let np=`#4EA7F2`,rp=[np,`#EA6175`,`#43C5B1`,`#F4A261`,`#8481DD`,`#FFD86D`],ip=[np,`#3188E6`,`#43C5B1`,`#00A78D`,`#EA6175`,`#CE4257`,`#F4A261`,`#F48935`,`#8481DD`,`#5752D1`,`#FFD86D`,`#FFBC2C`],ap=[np,`#3188E6`,`#056BD9`,`#A76DBC`,`#7F4295`,`#6D2387`,`#EA6175`,`#CE4257`,`#982738`,`#43C5B1`,`#00A78D`,`#0E8270`,`#F4A261`,`#F48935`,`#BE5D10`,`#8481DD`,`#5752D1`,`#3A3580`,`#A4A8B6`,`#7E8290`,`#545B70`,`#FFD86D`,`#FFBC2C`,`#C08A16`],op=[np,`#3188E6`,`#056BD9`,`#155193`,`#A76DBC`,`#7F4295`,`#6D2387`,`#4F1565`,`#EA6175`,`#CE4257`,`#982738`,`#791B29`,`#43C5B1`,`#00A78D`,`#0E8270`,`#105F53`,`#F4A261`,`#F48935`,`#BE5D10`,`#7D380D`,`#8481DD`,`#5752D1`,`#3A3580`,`#26235F`,`#A4A8B6`,`#7E8290`,`#545B70`,`#3F4250`,`#FFD86D`,`#FFBC2C`,`#C08A16`,`#936A12`],sp=[np,`#43C5B1`,`#EA6175`,`#F4A261`,`#8481DD`,`#FFD86D`,`#3188E6`,`#00A78D`,`#CE4257`,`#F48935`,`#5752D1`,`#FFBC2C`],cp=[np,`#A76DBC`,`#EA6175`,`#43C5B1`,`#F4A261`,`#8481DD`,`#A4A8B6`,`#FFD86D`,`#3188E6`,`#7F4295`,`#CE4257`,`#00A78D`,`#F48935`,`#5752D1`,`#7E8290`,`#FFBC2C`,`#056BD9`,`#6D2387`,`#982738`,`#0E8270`,`#BE5D10`,`#3A3580`,`#545B70`,`#C08A16`],lp=[np,`#A76DBC`,`#EA6175`,`#43C5B1`,`#F4A261`,`#8481DD`,`#A4A8B6`,`#FFD86D`,`#3188E6`,`#7F4295`,`#CE4257`,`#00A78D`,`#F48935`,`#5752D1`,`#7E8290`,`#FFBC2C`,`#056BD9`,`#6D2387`,`#982738`,`#0E8270`,`#BE5D10`,`#3A3580`,`#545B70`,`#C08A16`,`#155193`,`#4F1565`,`#791B29`,`#105F53`,`#7D380D`,`#26235F`,`#3F4250`,`#936A12`];function up(e,t){return t[e%t.length]}function dp(e){return e<=6?rp:e<=12?ip:e<=24?ap:op}function fp(e){return e<=6?rp:e<=12?sp:e<=24?cp:lp}var pp=class{preferredColors;currentColorIndex=0;palette;constructor(e,t=[]){this.preferredColors=t,this.palette=dp(e).filter(e=>!t.includes(e))}next(){return this.preferredColors?.[this.currentColorIndex]?this.preferredColors[this.currentColorIndex++]:up(this.currentColorIndex++,this.palette)}},mp=class extends pp{constructor(e,t=[]){super(e,t),this.palette=fp(e).filter(e=>!t.includes(e))}},hp=class{availableColors;colors={};constructor(e=12){this.availableColors=new mp(e)}get(e){return this.colors[e]||(this.colors[e]=this.availableColors.next()),this.colors[e]}};let gp={greys:[`#ffffff`,`#808080`,`#000000`],blues:[`#f7fbff`,`#6aaed6`,`#08306b`],reds:[`#fff5f0`,`#fb694a`,`#67000d`],greens:[`#f7fcf5`,`#73c476`,`#00441b`],oranges:[`#fff5eb`,`#fd8c3b`,`#7f2704`],purples:[`#fcfbfd`,`#9e9ac8`,`#3f007d`],viridis:[`#440154`,`#21918c`,`#fde725`],cividis:[`#00224e`,`#7d7c78`,`#fee838`],rainbow:[`#B41DB4`,`#FFFF00`,`#00FFFF`]},_p=Object.keys(gp);function vp(e){if(e.length<2)throw Error(`Color scale must have at least 2 points`);let t=[...e.sort((e,t)=>e.value-t.value)],n=[];for(let e=1;e<t.length;e++){let r=Kf(t[e-1].color).a,i=Kf(t[e].color).a,a=jf(t[e-1].color),o=jf(t[e].color);n.push({min:t[e-1].value,max:t[e].value,minColor:a,maxColor:o,minColorAlpha:r,maxColorAlpha:i,colorDiff:yp(t[e-1].value,t[e].value,a,o)})}return e=>{if(e<n[0].min)return Af(n[0].minColor,n[0].minColorAlpha);for(let t of n)if(e>=t.min&&e<=t.max)return Af(bp(e,t.min,t.minColor,t.colorDiff),t.maxColorAlpha);return Af(n[n.length-1].maxColor,n[n.length-1].maxColorAlpha)}}function yp(e,t,n,r){let i=t-e,a=(n>>16)%256-(r>>16)%256,o=(n>>8)%256-(r>>8)%256,s=n%256-r%256;return[a/i,o/i,s/i]}function bp(e,t,n,r){let[i,a,o]=r,s=Math.round((n>>16)%256-i*(e-t)),c=Math.round((n>>8)%256-a*(e-t)),l=Math.round(n%256-o*(e-t));return s<<16|c<<8|l}function xp(e,t=1){return t*(e+4)-4}function Sp(e=100,t=100){return new OffscreenCanvas(e,t).getContext(`2d`)}function Cp(e,t,n,r){if(!t||!t.isFormula&&!t.content)return 23;let i=``;try{if(!t.isFormula){let e={format:t.format,locale:n};i=V(df(t.content,n),e)}}catch{i=P.GenericError}return wp(e,i,t.style,r)}function wp(e,t,n,r){return Ep(e,Ip(e,t,n,n?.wrapping===`wrap`?r-8:void 0),n).height+6}function Tp(e,t=!1,n=!1){return`${n?`italic`:``} ${t?`bold`:``} ${e}px ${$e}`}function Ep(e,t,n={},r=`pt`){if(!t.length)return{width:0,height:0};let i=Np(n,r),a=t.map(t=>jp(e,t,i)),o=xp(a[0].height,t.length),s=Math.max(...a.map(e=>e.width));if(!n.rotation)return{height:o,width:s};let c=Math.abs(Math.cos(n.rotation)),l=Math.abs(Math.sin(n.rotation));return{width:s*c+o*l,height:l*s+c*o}}function Dp(e,t,n={},r=`pt`){return Op(e,t,Np(n,r),n.rotation)}function Op(e,t,n,r){let i=jp(e,t,n);if(!r)return i.width;let a=Math.abs(Math.cos(r)),o=Math.abs(Math.sin(r));return i.width*a+i.height*o}let kp={};function Ap(e,t,n,r=`pt`){let i=jp(e,t,Np(n,r));if(!n.rotation)return i;let a=Math.abs(Math.cos(n.rotation)),o=Math.abs(Math.sin(n.rotation));return{width:i.width*a+i.height*o,height:i.height*a+i.width*o}}function jp(e,t,n){if(kp[n]||(kp[n]={}),kp[n][t]===void 0){e.save(),e.font=n;let r=e.measureText(t);e.restore();let i=r.width,a=r.fontBoundingBoxAscent+r.fontBoundingBoxDescent;kp[n][t]={width:i,height:a}}return kp[n][t]}function Mp(e){return Math.round(e*96/72)}function Np(e,t=`pt`,n=400){return`${e.italic?`italic `:``}${e.bold?`bold`:n} ${(t===`pt`?Pp(e):e.fontSize)??Qe}px ${$e}`}function Pp(e){return Mp(e?.fontSize||Qe)}function Fp(e,t,n,r){if(Dp(e,t,r)<=n)return[t];let i=[],a=``;for(let o of t)Dp(e,a+o,r)>n?(i.push(a),a=o):a+=o;return i.push(a),i}function Ip(e,t,n,r){n||={},Vt(t)&&(t=Wt(t).label);let i=[],a=t.includes(`
16
16
  `)?t.split(`
17
- `):[t];for(let t of a){let a=t.includes(` `)?t.split(` `):[t];if(!r){i.push(t);continue}let o=``,s=r;for(let t of a){let a=Fp(e,t,r,n),c=a.pop(),l=Dp(e,c,n);if(a.length)o!==``&&(i.push(o),o=``,s=r),a.forEach(e=>{i.push(e)}),o=c,s=r-l;else{let t=o===``?c:` `+c,a=Dp(e,t,n);a<=s?(o+=t,s-=a):(i.push(o),o=c,s=r-l)}}o!==``&&i.push(o)}return i}function Lp(e,t,n,r=.25){let i=1;if(n(i)>e)return i;if(n(t)<e)return t;let a=(i+t)/2,o=n(a),s=0;for(;Math.abs(o-e)>r&&s<20;)o>=e?t=(i+t)/2:i=(i+t)/2,a=(i+t)/2,o=n(a),s++;return a}function Rp(e){return e?e.toLowerCase().trim():``}let zp=/([0-9\.]*)px/;function Bp(e){return Number(e.match(zp)?.[1])}function Vp(e,t,n){let r=Op(e,t,e.font);if(r<=n)return t;let i=Op(e,`…`,e.font);if(r<=i)return t;let a=t.length;for(;r>=n-i&&a-->0;)t=t.substring(0,a),r=Op(e,t,e.font);return t+`…`}function Hp(e,t,n,r=!1,i=!1,a=Bp(e.font)/10,o=!1){if(o&&(e.save(),e.fillStyle=Yf(e.fillStyle,Ze)),e.fillText(t,n.x,n.y),!r&&!i)return;let s=e.measureText(t),c=s.width,l=s.actualBoundingBoxAscent+s.actualBoundingBoxDescent,u=s.fontBoundingBoxAscent+s.fontBoundingBoxDescent,{x:d,y:f}=n,p=f,m=f;switch(e.textAlign){case`center`:d-=c/2;break;case`right`:d-=c;break}switch(e.textBaseline){case`top`:m+=u-2*a,p+=u/2-a;break;case`middle`:m+=u/2-a;break;case`alphabetic`:m+=2*a,p-=3*a;break;case`bottom`:m=f,p-=l/2-a/2;break}r&&(e.lineWidth=a,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(d,m),e.lineTo(d+c,m),e.stroke()),i&&(e.lineWidth=a,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(d,p),e.lineTo(d+c,p),e.stroke()),o&&e.restore()}function Up(e,t,n,r,i=`pt`){if(Dp(e,n,r,i)<=t)return n;let a=Dp(e,`...`,r,i);if(a>=t)return``;let o=1,s=n.length,c;for(;o<=s;){let l=Math.floor((o+s)/2);c=Dp(e,n.slice(0,l),r,i),c+a>t?s=l-1:o=l+1}let l=n.slice(0,Math.max(0,o-1));return l?l+`...`:``}function Wp(e,t){if(!t.rotation||t.rotation%(Math.PI*2)==0)return e;let{x:n,y:r}=e,i=Math.cos(-t.rotation),a=Math.sin(-t.rotation),o=e.textWidth-8,s=e.textHeight,c=t.align===`center`,l=t.align===`left`==a<0,u=a*s,d=Math.abs(a*o),f=i*s;return t.verticalAlign===`top`?c?(r+=d/2,n-=u/2):l?n-=u:r+=d:!t.verticalAlign||t.verticalAlign===`bottom`?(r+=s-f,c?(r-=d/2,n-=u/2):l&&(n-=u,r-=d)):c?(n-=u/2,r-=s/2,l?r+=u:r-=u):l?(n-=u,r-=d/2):r+=d/2+f/4,{x:i*n-a*r,y:i*r+a*n}}let Gp={id:`chartColorScalePlugin`,afterDatasetsDraw(e,t,n){if(!n.position||n.position===`none`||!n.colorScale.length)return;let r=e.ctx;r.save(),r.textAlign=`center`,r.textBaseline=`middle`,r.miterLimit=1;let i=(e.chartArea.bottom-e.chartArea.top)/2,a=n.position===`left`?20:r.canvas.width-70,o=e.chartArea.top,s=r.createLinearGradient(0,o+i,0,o),c=1/(n.colorScale.length-1);n.colorScale.forEach((e,t)=>{s.addColorStop(t*c,e)}),r.fillStyle=s,r.fillRect(a,o,10,i),r.fillStyle=n.fontColor??`black`,r.font=Tp(12),r.textAlign=`left`;let l=Math.round(n.minValue*100)/100,u=Math.round(n.maxValue*100)/100;n.minValue===n.maxValue&&(--l,u+=1);let d=jc({value:u,format:void 0},n.locale),f=jc({value:l,format:void 0},n.locale);r.fillText(f,a+10+5,o+i-6),r.fillText(d,a+10+5,o+6),r.restore()}};function Kp(){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);return class extends globalThis.Chart.BarController{static id=`funnel`;static defaults={...globalThis.Chart?.BarController.defaults,dataElementType:`funnel`,animation:{duration:e=>e.type===`data`?1e3*(e.raw[1]/Math.max(...e.dataset.data.map(e=>e[1]))):1e3}};updateElements(e,t,n,r){super.updateElements(e,t,n,r);for(let i=t;i<t+n;i++){let t=e[i];this.updateElement(t,i,{nextElement:e[i+1]},r)}}}}function qp(){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);return class extends globalThis.Chart.BarElement{static id=`funnel`;draw(e){e.save();let{x:t,y:n,height:r,nextElement:i,base:a,options:o}=this.getProps([`x`,`y`,`width`,`height`,`nextElement`,`base`,`options`]),s=Jp(this),c=(s-(i?Jp(i):0))/2,l=Math.min(t,a),u=n-r/2;e.fillStyle=o.backgroundColor,e.beginPath(),e.moveTo(l,u),e.lineTo(l+s,u),e.lineTo(l+s-c,u+r),e.lineTo(l+c,u+r),e.closePath(),e.fill(),o.borderWidth&&(e.strokeStyle=o.borderColor,e.lineWidth=o.borderWidth,e.stroke()),e.restore()}inRange(e,t){let{x:n,y:r,height:i,nextElement:a,base:o}=this.getProps([`x`,`y`,`width`,`height`,`nextElement`,`base`,`options`]),s=Jp(this),c=a?Jp(a):0,l=Math.min(n,o),u=r-i/2;if(t<u||t>u+i)return!1;let d=(s-c)/2,f=l+d*(t-u)/i,p=l+s-d*(t-u)/i;return!(e<f||e>p)}}}function Jp(e){let{x:t,base:n}=e.getProps([`x`,`base`]);return Math.max(t,n)-Math.min(t,n)}let Yp=function(e){if(!e.length)return{x:0,y:0};let{x:t,y:n,base:r,width:i,height:a}=e[0].element.getProps([`x`,`y`,`width`,`height`,`base`]),o=Math.min(t,r),s=n-a/2;return{x:o+i*2/3,y:s+a/2}},Xp={id:`geoProjection`,beforeUpdate(e){e.options?.scales?.projection?.projection===`conicConformal`&&e.scales?.projection?.projection?.rotate([100,0])}},Zp={id:`o-spreadsheet-minor-gridlines`,beforeDatasetsDraw(e){let t=e.ctx,n=e.chartArea;if(n)for(let r in e.scales){let i=e.scales[r],a=i.options,o=a?.grid?.minor;if(!o?.display)continue;let s=a?.grid?.display,c=i.ticks;if(!(!c||c.length<2)){t.save(),t.lineWidth=1,t.strokeStyle=o.color??a?.grid?.color??`#e6e6e6`;for(let e=0;e<c.length-1;e++){let r=i.getPixelForTick(e),a=i.getPixelForTick(e+1);if(!(!isFinite(r)||!isFinite(a)))for(let e=+!!s;e<4;e++){let o=e/4,s=Math.round(r+(a-r)*o)+.5;t.beginPath(),i.isHorizontal()?(t.moveTo(s,n.top),t.lineTo(s,n.bottom)):(t.moveTo(n.left,s),t.lineTo(n.right,s)),t.stroke()}}t.restore()}}}},Qp=`000000`,$p={arrows:`3Arrows`,smiley:`3Symbols`,dots:`3TrafficLights1`},em={styleSheet:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,sst:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,Relationships:`http://schemas.openxmlformats.org/package/2006/relationships`,Types:`http://schemas.openxmlformats.org/package/2006/content-types`,worksheet:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,workbook:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,drawing:`http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing`,table:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,revision:`http://schemas.microsoft.com/office/spreadsheetml/2014/revision`,revision3:`http://schemas.microsoft.com/office/spreadsheetml/2016/revision3`,markupCompatibility:`http://schemas.openxmlformats.org/markup-compatibility/2006`},tm=`http://schemas.openxmlformats.org/drawingml/2006/main`,nm=`http://schemas.openxmlformats.org/drawingml/2006/chart`,rm={workbook:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml`,macroEnabledWorkbook:`application/vnd.ms-excel.sheet.macroEnabled.main+xml`,templateWorkbook:`application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml`,macroEnabledTemplateWorkbook:`application/vnd.ms-excel.template.macroEnabled.main+xml`,excelAddInWorkbook:`application/vnd.ms-excel.addin.macroEnabled.main+xml`,sheet:`application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml`,metadata:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml`,sharedStrings:`application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml`,styles:`application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml`,drawing:`application/vnd.openxmlformats-officedocument.drawing+xml`,chart:`application/vnd.openxmlformats-officedocument.drawingml.chart+xml`,themes:`application/vnd.openxmlformats-officedocument.theme+xml`,table:`application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml`,pivot:`application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml`,externalLink:`application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml`},im={document:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument`,sheet:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet`,metadata:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/sheetMetadata`,sharedStrings:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings`,styles:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles`,drawing:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,chart:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart`,theme:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme`,table:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/table`,hyperlink:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink`,image:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/image`},am=`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,om=.75,sm=.143,cm=8.43,lm=12.75,um={FLOOR:[{type:`NUMBER`,value:1}],CEILING:[{type:`NUMBER`,value:1}],ROUND:[{type:`NUMBER`,value:0}],ROUNDUP:[{type:`NUMBER`,value:0}],ROUNDDOWN:[{type:`NUMBER`,value:0}],IFERROR:[{type:`NUMBER`,value:0}]},dm=`ACOT,ACOTH,AGGREGATE,ARABIC,BASE,BETA.DIST,BETA.INV,BINOM.DIST,BINOM.DIST.RANGE,BINOM.INV,BITAND,BITLSHIFT,BITOR,BITRSHIFT,BITXOR,BYCOL,BYROW,CEILING.MATH,CEILING.PRECISE,CHISQ.DIST,CHISQ.DIST.RT,CHISQ.INV,CHISQ.INV.RT,CHISQ.TEST,CHOOSECOLS,CHOOSEROWS,COMBINA,CONCAT,CONFIDENCE.NORM,CONFIDENCE.T,COT,COTH,COVARIANCE.P,COVARIANCE.S,CSC,CSCH,DAYS,DECIMAL,DROP,ERF.PRECISE,ERFC.PRECISE,EXPAND,EXPON.DIST,F.DIST,F.DIST.RT,F.INV,F.INV.RT,F.TEST,FIELDVALUE,FILTERXML,FLOOR.MATH,FLOOR.PRECISE,FORECAST.ETS,FORECAST.ETS.CONFINT,FORECAST.ETS.SEASONALITY,FORECAST.ETS.STAT,FORECAST.LINEAR,FORMULATEXT,GAMMA,GAMMA.DIST,GAMMA.INV,GAMMALN.PRECISE,GAUSS,HSTACK,HYPGEOM.DIST,IFNA,IFS,IMCOSH,IMCOT,IMCSC,IMCSCH,IMSEC,IMSECH,IMSINH,IMTAN,ISFORMULA,ISOMITTED,ISOWEEKNUM,LAMBDA,LET,LOGNORM.DIST,LOGNORM.INV,MAKEARRAY,MAP,MAXIFS,MINIFS,MODE.MULT,MODE.SNGL,MUNIT,NEGBINOM.DIST,NORM.DIST,NORM.INV,NORM.S.DIST,NORM.S.INV,NUMBERVALUE,PDURATION,PERCENTILE.EXC,PERCENTILE.INC,PERCENTRANK.EXC,PERCENTRANK.INC,PERMUTATIONA,PHI,POISSON.DIST,PQSOURCE,PYTHON_STR,PYTHON_TYPE,PYTHON_TYPENAME,QUARTILE.EXC,QUARTILE.INC,QUERYSTRING,RANDARRAY,RANK.AVG,RANK.EQ,REDUCE,RRI,SCAN,SEC,SECH,SEQUENCE,SHEET,SHEETS,SKEW.P,SORTBY,STDEV.P,STDEV.S,SWITCH,T.DIST,T.DIST.2T,T.DIST.RT,T.INV,T.INV.2T,T.TEST,TAKE,TEXTAFTER,TEXTBEFORE,TEXTJOIN,TEXTSPLIT,TOCOL,TOROW,UNICHAR,UNICODE,UNIQUE,VAR.P,VAR.S,VSTACK,WEBSERVICE,WEIBULL.DIST,WRAPCOLS,WRAPROWS,XLOOKUP,XOR,Z.TEST`.split(`,`);function fm(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,$f(t)]))}let pm={chartBackgroundColor:`#FFFFFF`,gridBorderColor:`#CECFCF`,gridBorderColorOnDefaultBackground:`#E2E3E3`,headerBackgroundColor:`#F8F9FA`,headerActiveBackgroundColor:`#595959`,headerSelectedBackgroundColor:`#E8EAED`,headerTextColor:`#666666`,headerBorderColor:`#C0C0C0`,frozenPaneBorderColor:`#DADFE8`,frozenPaneHeaderBorderColor:`#BCBCBC`,singleCellSelectionBackgroundColor:`#D2E1FB44`,multipleCellsSelectionBackgroundColor:`#ACC7FF44`},mm={chartBackgroundColor:`#25262b`,gridBorderColor:`#6B706F`,gridBorderColorOnDefaultBackground:`#4F5254`,headerBackgroundColor:`#262A36`,headerActiveBackgroundColor:`#3A4052`,headerSelectedBackgroundColor:`#4E566E`,headerTextColor:`#A1A6B3`,headerBorderColor:`#7A7F91`,frozenPaneBorderColor:`#7A7F91`,frozenPaneHeaderBorderColor:`#9FA5BD`,singleCellSelectionBackgroundColor:`#696E8044`,multipleCellsSelectionBackgroundColor:`#828AA044`},hm={light:{colorThemeName:`light`,...pm},dark:{colorThemeName:`dark`,...fm(mm)}},gm=`xMovingAverage`,_m={exponential:`exp`,logarithmic:`log`,polynomial:`poly`,trailingMovingAverage:`movingAvg`};function vm(e,t,n){return n?Au(e,t,n):void 0}function ym(e,{applyChange:t}){if(!e)return;let n=t(e);switch(n.changeType){case`REMOVE`:return;default:return n.range}}function bm(e,t,n){let r=[];for(let i of n.dataSets){let{unboundedZone:a,sheetId:o,invalidSheetName:s,invalidXc:c}=e.getRangeFromSheetXC(t,i.dataRange);if(!(s||c))if(a.left!==a.right&&a.top!==a.bottom){if(a.right===void 0)continue;let t=i.dataSetId;for(let i=a.left;i<=a.right;i++){let s={...a,left:i,right:i};r.push({...xm(e,o,s,n.dataSetsHaveTitle?{top:s.top,bottom:s.top,left:s.left,right:s.left}:void 0),dataSetId:t}),t=`${t}_${i}`}}else r.push({...xm(e,o,a,n.dataSetsHaveTitle?{top:a.top,bottom:a.top,left:a.left,right:a.left}:void 0),dataSetId:i.dataSetId})}return r}function xm(e,t,n,r){if(n.left!==n.right&&n.top!==n.bottom)throw Error(`Zone should be a single column or row: ${or(n)}`);if(r){let i=or(n),a=or(r);return{labelCell:e.getRangeFromSheetXC(t,a),dataRange:e.getRangeFromSheetXC(t,i)}}else return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,or(n))}}function Sm(e,t,n){let r=n.labelCell?.zone,i=n.dataRange.zone;if(r){let{numberOfRows:e,numberOfCols:t}=yr(i);e===1?i={...i,left:i.left+1}:t===1&&(i={...i,top:i.top+1})}let a=t[n.dataSetId]??{},o=wu({...n.dataRange,zone:i},e.getSheetSize),s={};a.label?s={text:a.label}:n.labelCell&&(s={reference:e.getRangeString(n.labelCell,`forceSheetReference`,{useBoundedReference:!0})});let c;return a.trend?.type&&(c={type:a.trend.type===`polynomial`&&a.trend.order===1?`linear`:_m[a.trend.type],color:a.trend.color,order:a.trend.order?Math.min(a.trend.order,6):void 0,window:a.trend.window||2}),{label:s,range:e.getRangeString(o,`forceSheetReference`,{useBoundedReference:!0}),backgroundColor:a.backgroundColor,rightYAxis:a.yAxisId===`y1`,trend:c}}function Cm(e,t,n){if(!t)return;let r={...t.zone};n&&t.zone.bottom>t.zone.top&&(r.top+=1);let i=wu({...t,zone:r},e.getSheetSize);return e.getRangeString(i,`forceSheetReference`,{useBoundedReference:!0})}function wm(e){return e&&Lf(e)<.3?`#FFFFFF`:`#000000`}function Tm(e){return e&&Lf(e)<.3?`#C8C8C8`:`#666666`}function Em(e){return e.dataSets.find(e=>!vl.test(e.dataRange))!==void 0||e.dataSets.map(e=>er(e.dataRange)).some(e=>e.top!==e.bottom&&Ar(e))?`InvalidDataSet`:`Success`}function Dm(e){return e.labelRange&&!vl.test(e.labelRange||``)?`InvalidLabelRange`:`Success`}function Om(e,t,n){return n&&!!t&&e>=t}function km(e){let t=!1,n=!1;if(`horizontal`in e&&e.horizontal)return{useLeftAxis:!0,useRightAxis:!1};let r=`dataSetStyles`in e?e.dataSetStyles??{}:{};for(let e of Object.values(r))e?.yAxisId===`y1`?n=!0:t=!0;return t||=!n,{useLeftAxis:t,useRightAxis:n}}function Am(e,t,n=!1){return(r,i)=>{let a=e?.[i];return jm({format:a,locale:t},n)(r)}}function jm(e,t=!1){return n=>{if(n=Number(n),isNaN(n))return n;let{locale:r,format:i}=e;return Pm(t?jc({value:n,format:i},r):V(n,{locale:r,format:!i&&Math.abs(n)>=1e3?`#,##`:i}))}}let Mm=[{value:`left`,label:N(`Left`)},{value:`right`,label:N(`Right`)}];function Nm(e,t){let n=[],r=xn(t.map(e=>e.data.length));for(let t=0;t<=r;t++)n.push(e.next());return n}function Pm(e,t=20){return e?e.length>t?e.substring(0,t)+`…`:e:``}function Fm(e){return e===`x1`||e===`xMovingAverage`}function Im({background:e},t){return e||hm[t].chartBackgroundColor}function Lm(e,t){return e.type===`bar`&&t.type===`line`}let Rm={id:`chartShowValuesPlugin`,afterDatasetsDraw(e,t,n){if(n.showValues&&e._metasets?.[0]?.data)switch(n.type){case`pie`:Jm(e,n);break;case`line`:case`scatter`:Hm(e,n);break;case`combo`:case`waterfall`:Um(e,n);break;case`radar`:Vm(e,n);break;case`bar`:n.horizontal?Km(e,n):Bm(e,n);break;case`pyramid`:Km(e,n);break;case`calendar`:Wm(e,n);break;case`bubble`:Gm(e,n);break;case`funnel`:qm(e,n);break}}};function zm(e){let{chart:t,options:n,getNumberValue:r,direction:i}=e,a=t.ctx;a.save(),a.textAlign=`center`,a.textBaseline=`middle`,a.miterLimit=1;let o={};for(let s of t._metasets)if(!(Fm(s.xAxisID)||s.hidden))for(let c=0;c<s._parsed.length;c++){let l=r(s,c);if(l===void 0||isNaN(l))continue;let u=s.data[c],d=u.options.backgroundColor;if(!d||Bf(d).a!==1)continue;let f=n.callback(l,s,c),p=Ym(f,a),m={dataset:s,chartElement:u,numberValue:l,valueIndex:c,textSize:p,options:n,chart:t},h=e.getValuePosition(m);if(e.shouldSkipValue?.(m))continue;if(i===`vertical`){let e=Math.round(h.x);o[e]||(o[e]=[]);for(let t of o[e]||[])Math.abs(t-h.y)<13&&(h.y=t+13*(l<0?1:-1));o[e].push(h.y)}else{let e=Math.round(h.y);o[e]||(o[e]=[]);for(let t of o[e])Math.abs(t-h.x)<p.width&&(h.x=l<0?t-p.width-3:t+p.width+3);o[e].push(h.x)}let{strokeColor:g,textColor:_}=e.getTextColors(m);g&&(a.strokeStyle=g,a.lineWidth=3,a.strokeText(f,h.x,h.y)),a.fillStyle=_,a.lineWidth=1,a.fillText(f,h.x,h.y)}a.restore()}function Bm(e,t){zm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t].y),getValuePosition:Qm,shouldSkipValue:({dataset:e})=>Lm(t,e),getTextColors:Xm})}function Vm(e,t){zm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t].r),getValuePosition:({chartElement:e})=>({x:e.x,y:e.y-10}),shouldSkipValue:()=>!1,getTextColors:Zm})}function Hm(e,t){zm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t].y),getValuePosition:({chartElement:e})=>({x:e.x,y:e.y-10}),shouldSkipValue:()=>!1,getTextColors:Zm})}function Um(e,t){zm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t].y),getValuePosition:e=>e.dataset.type===`line`?{x:e.chartElement.x,y:e.chartElement.y-10}:Qm(e),shouldSkipValue:()=>!1,getTextColors:e=>e.dataset.type===`line`?Zm(e):Xm(e)})}function Wm(e,t){zm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>e._parsed[t].y,getValuePosition:({chartElement:e})=>({x:e.x,y:e.y+e.height/2}),shouldSkipValue:({chartElement:e,textSize:t})=>t.height+2>Math.abs(e.height)-2,getTextColors:({chartElement:e})=>({strokeColor:void 0,textColor:wm(e.options.backgroundColor)})})}function Gm(e,t){let n=(e,t)=>{let n=e.options.radius??globalThis.Chart?.defaults.elements.point.radius??3;return t.height<n*2};zm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>e._parsed[t].y,getValuePosition:({chartElement:e,textSize:t})=>({x:e.x,y:n(e,t)?e.y:e.y-10}),shouldSkipValue:()=>!1,getTextColors:e=>n(e.chartElement,e.textSize)?Xm(e):Zm(e)})}function Km(e,t){zm({chart:e,options:t,direction:`horizontal`,getNumberValue:(e,t)=>e._parsed[t].x,getValuePosition:({chartElement:t,numberValue:n,textSize:r,dataset:i})=>{let a=e.scales[i.xAxisID].getPixelForValue(0),o=Math.abs(t.x-a),s,c=n<0?-1:1;return s=o<r.width?a+c*(r.width/2+3):t.x-c*(t.width/2),{x:s,y:t.y}},shouldSkipValue:({dataset:e})=>Lm(t,e),getTextColors:Xm})}function qm(e,t){zm({chart:e,options:t,direction:`horizontal`,getNumberValue:(e,t)=>e._parsed[t].x,getValuePosition:({chartElement:e})=>({x:e.x-e.width/2,y:e.y}),shouldSkipValue:()=>!1,getTextColors:Xm})}function Jm(e,t){let n=e=>{let{startAngle:t,endAngle:n,innerRadius:r,outerRadius:i}=e;return{midAngle:(t+n)/2,midRadius:(r+i)/2}};zm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t]),getValuePosition:({chartElement:e})=>{let{midAngle:t,midRadius:r}=n(e);return{x:e.x+r*Math.cos(t),y:e.y+r*Math.sin(t)}},shouldSkipValue:({chartElement:e,textSize:t})=>{let{midRadius:r}=n(e),i=e.endAngle-e.startAngle,a=2*r*Math.tan(i/2);return i<Math.PI/2&&(t.width>=a||a<t.height)},getTextColors:Xm})}function Ym(e,t){return jp(t,e,Np({fontSize:globalThis.Chart?.defaults.font.size??12},`px`))}function Xm(e){let{dataset:t,numberValue:n,valueIndex:r,chartElement:i,options:a}=e;return{strokeColor:i.options.backgroundColor,textColor:a.background(n,t,r)||`#ffffff`}}function Zm(e){let{dataset:t,numberValue:n,valueIndex:r,chartElement:i,options:a}=e;return{strokeColor:a.background(n,t,r)||`#ffffff`,textColor:i.options.backgroundColor}}function Qm(e){let{chartElement:t,numberValue:n,dataset:r,textSize:i,chart:a}=e,o=a.scales[r.yAxisID].getPixelForValue(0),s=Math.abs(o-t.y),c=n<0?-1:1,l=0;return l=s<i.height?o-c*(i.height/2):t.y+c*(t.height/2),{x:t.x,y:l}}let $m={showHeaders:!0,headerDesign:{align:`center`,fillColor:`#808080`,bold:!0,fontSize:15},showValues:!0,showLabels:!0,valuesDesign:{align:`left`,verticalAlign:`bottom`,fontSize:12},coloringOptions:{type:`categoryColor`,colors:[],useValueBasedGradient:!0}},eh={second:1e3,minute:1e3*60,hour:1e3*3600,day:1e3*3600*24,month:1e3*3600*24*30,year:1e3*3600*24*365},th={inSeconds:function(e){return Math.floor(e/eh.second)},inMinutes:function(e){return Math.floor(e/eh.minute)},inHours:function(e){return Math.floor(e/eh.hour)},inDays:function(e){return Math.floor(e/eh.day)},inMonths:function(e){return Math.floor(e/eh.month)},inYears:function(e){return Math.floor(e/eh.year)}},nh=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function rh(e,t,n){let r=ih(t),i=oh(e,r,n),a={};return i&&(a[i]=r),{parser:r,displayFormats:a,unit:i??!1,tooltipFormat:r}}function ih(e){let t=e.indexOf(`h`);return e=t>=0?e.slice(0,t).replace(/m/g,`M`)+e.slice(t):e.replace(/m/g,`M`),e.includes(`a`)||(e=e.replace(/h/g,`H`)),e}function ah(e){return e.includes(`s`)?`second`:e.includes(`m`)?`minute`:e.includes(`h`)||e.includes(`H`)?`hour`:e.includes(`d`)?`day`:e.includes(`M`)?`month`:`year`}function oh(e,t,n){let r=e.map(e=>La(e,n)?.jsDate);if(r.some(e=>e===void 0)||e.length<2)return;let i=r.map(e=>e.getTime()),a=xn(i)-Sn(i),o=ah(t);return eh.second>=eh[o]&&th.inSeconds(a)<180?`second`:eh.minute>=eh[o]&&th.inMinutes(a)<180?`minute`:eh.hour>=eh[o]&&th.inHours(a)<96?`hour`:eh.day>=eh[o]&&th.inDays(a)<90?`day`:eh.month>=eh[o]&&th.inMonths(a)<36?`month`:`year`}function sh(e,t){let n={},{trendDataSetsValues:r,locale:i,axisFormats:a,axisType:o}=t,s={stacked:e.stacked,locale:i};if(e.horizontal)n.x=xh(e,`bottom`,`values`,o,{...s,format:a?.x}),n.y={...xh(e,`left`,`labels`,`linear`,s),grid:{display:!1}};else{n.x={...xh(e,`bottom`,`labels`,o,s),grid:{display:!1}};let t={...s,format:a?.y};n.y=xh(e,`left`,`values`,`linear`,t);let r={...s,format:a?.y1};n.y1=xh(e,`right`,`values`,`linear`,r)}if(n=sn(n),r&&r.length&&r.some(w)){let e=Math.max(...r.map(e=>e?.length||0));n.x1={...n.x,labels:Array(e).fill(``),offset:!1,display:!1},n[gm]={...n.x,offset:!0,display:!1}}return n}function ch(e,t){let n=t.map(e=>e.label||``),r=wm(e.background);return{y:{title:bh(e.axesDesign?.y),stacked:!0,min:0,max:n.length,ticks:{stepSize:.5,color:r,callback:function(e,t,r){if(t%2!=0)return n[Math.floor((t-1)/2)]}},grid:{display:!1},border:{display:!1}},x:{title:bh(e.axesDesign?.x),stacked:!0,grid:{display:!1},position:`top`,ticks:{color:r},border:{display:!1}}}}function lh(e,t){let{dataSetsValues:n}=t;if(!n.length||e.legendPosition===`none`)return;let r=n.flatMap(e=>e.data).filter(mf).map(e=>e.value),i=Math.min(...r),a=Math.max(...r),o=[];return o=typeof e.colorScale==`object`?[e.colorScale.minColor,e.colorScale.midColor,e.colorScale.maxColor].filter(w):[...gp[e.colorScale??`oranges`]],{position:e.legendPosition===`right`?`right`:`left`,colorScale:o,fontColor:wm(e.background),minValue:i,maxValue:a,locale:t.locale}}function uh(e,t){let{locale:n,axisType:r,trendDataSetsValues:i,labels:a,axisFormats:o}=t,s=o?.x,c=e.stacked,l={x:xh(e,`bottom`,`labels`,r,{locale:n}),y:xh(e,`left`,`values`,`linear`,{locale:n,stacked:c,format:o?.y}),y1:xh(e,`right`,`values`,`linear`,{locale:n,stacked:c,format:o?.y1})};if(l=sn(l),r===`time`&&a&&s){let t={type:`time`,time:rh(a,s,n),min:V(e.axesDesign?.x?.min??``,{format:s,locale:n}),max:V(e.axesDesign?.x?.max??``,{format:s,locale:n})};Object.assign(l.x,t),l.x.ticks.maxTicksLimit=15,delete l?.x?.ticks?.callback}else r===`linear`&&(l.x.type=`linear`,l.x.ticks.callback=e.humanize?e=>jc({value:e,format:s},n):e=>V(e,{format:s,locale:n}));if(i&&i.length&&i.some(w)&&(l.x1={...l.x,display:!1},l[gm]={...l.x,display:!1},r===`category`||r===`time`)){let e=Math.max(...i.map(e=>e?.length||0));l.x1.type=`category`,l.x1.labels=C(0,e).map(e=>e.toString()),l.x1.offset=!1,l[gm].type=`category`,l[gm].offset=!1}return l}function dh(e){return Lf(e||`#ffffff`)>.5?`#cccccc`:`#999999`}function fh(e){return Lf(e||`#ffffff`)>.5?`#e6e6e6`:`#333333`}function ph(e,t){let n=uh(e,t),r=n?.x??{},i=e.axesDesign?.x,a=i?.gridLines!==`none`&&i?.gridLines!==`minor`;return{...n,x:{...r,grid:{...r.grid,color:dh(e.background),display:a}}}}function mh(e,t){let n=ph(e,t),r=e.verticalAxisPosition||`left`;return{...n,y:{...n.y,position:r}}}function hh(e,t){let{locale:n,axisFormats:r,axisType:i}=t,a=r?.y||r?.y1,o=e.axesDesign?.y,s={x:{...xh(e,`bottom`,`labels`,i,{locale:n}),grid:{display:!1}},y:{position:e.verticalAxisPosition,ticks:{color:wm(e.background),callback:jm({locale:n,format:a},e.humanize)},title:bh(e.axesDesign?.y),min:o?.min,max:o?.max,grid:{lineWidth:e=>e.tick.value===0?2:1,display:o?.gridLines!==`none`&&o?.gridLines!==`minor`,color:dh(e.background)}}};return(o?.gridLines===`minor`||o?.gridLines===`both`)&&(s.y.grid.minor={display:!0,color:fh(e.background)}),s}function gh(e,t){let{dataSetsValues:n}=t,r=sh(e,t),i=r.x.ticks.callback;r.x.ticks.callback=e=>i(Math.abs(e));let a=Math.max(...n.map(e=>Math.max(...e.data.filter(mf).map(e=>Math.abs(e.value)))));return r.x.suggestedMin=-a,r.x.suggestedMax=a,r}function _h(e,t){let{locale:n,axisFormats:r,dataSetsValues:i}=t,a=Math.min(...i.map(e=>Math.min(...e.data.filter(mf).map(e=>e.value))));return{r:{beginAtZero:!0,ticks:{callback:jm({format:r?.r,locale:n},e.humanize),backdropColor:e.background||`#FFFFFF`},pointLabels:{color:wm(e.background),callback:e=>Pm(e)},suggestedMin:a<0?a-1:0}}}function vh(e,t){let{locale:n,axisFormats:r,availableRegions:i}=t,a=wh(e.legendPosition),o=e.region?i.find(t=>t.id===e.region):i[0],s=r?.y||r?.y1;return{projection:{projection:o?.defaultProjection||`mercator`,axis:`x`},color:{axis:`x`,display:e.legendPosition!==`none`,border:{color:ze},grid:{color:ze},ticks:{color:wm(e.background),callback:jm({locale:n,format:s},e.humanize)},legend:{position:a,align:a.includes(`right`)?`left`:`right`,margin:Ch(e)},interpolate:Sh(e.colorScale??He),missing:e.missingValueColor||`#ffffff`}}}function yh(e,t){let n=t.dataSetsValues[0];return{x:{display:!1},y:{grid:{offset:!1},ticks:{callback:function(e){return Pm(this.getLabelForValue(e))}},border:{display:!1}},percentages:{position:`right`,border:{display:!1},ticks:{callback:function(e,r,i){let a=n.data?.[r],o=n.data?.[0];return!o?.value||a?.value===null||!mf(a)||!mf(o)?``:V(a.value/o.value,{format:`0%`,locale:t.locale})}},grid:{display:!1}}}}function bh(e){if(e?.title?.text){let{text:t,color:n,align:r,italic:i,bold:a}=e.title;return{display:!0,text:t,color:n,font:{style:i?`italic`:`normal`,weight:a?`bold`:`normal`,size:e.title.fontSize??12},align:r===`left`?`start`:r===`right`?`end`:`center`}}}function xh(e,t,n,r,i){let{useLeftAxis:a,useRightAxis:o}=km(e);if(t===`left`&&!a||t===`right`&&!o)return;let s=wm(e.background),c;if(c=t===`bottom`?e.axesDesign?.x:t===`left`?e.axesDesign?.y:e.axesDesign?.y1,n===`values`){let n=!(t===`right`&&a),o=c?.gridLines?c?.gridLines===`major`||c?.gridLines===`both`:n,l=!(r===`category`||r===void 0)&&(c?.gridLines===`minor`||c?.gridLines===`both`),u=jm(i,e.humanize),d={position:t,title:bh(c),beginAtZero:!c?.min,stacked:i?.stacked,ticks:{color:s,callback:u},min:c?.min,max:c?.max,grid:{display:o,color:dh(e.background)}};return l&&(d.grid.minor={display:!0,color:fh(e.background)}),d}else{let t={ticks:{padding:5,color:s,callback:function(e,t,n){return Pm(this.getLabelForValue(e))}},min:c?.min,max:c?.max,grid:{display:c?.gridLines===`major`||c?.gridLines===`both`,color:dh(e.background)},stacked:i?.stacked,title:bh(c)};return(c?.gridLines===`minor`||c?.gridLines===`both`)&&(t.grid.minor={display:!0,color:fh(e.background)}),t}}function Sh(e,t=0,n=1){if(t===n){let t=e.midColor??e.minColor;return e=>t}let r=[{value:t,color:e.minColor}];return e.midColor&&r.push({value:(t+n)/2,color:e.midColor}),r.push({value:n,color:e.maxColor}),vp(r)}function Ch(e){switch(e.legendPosition){case`top`:case`right`:return{top:e.title.text?45:15,left:20,right:20};case`bottom`:case`left`:case`none`:return{left:20,right:20,bottom:10}}}function wh(e){switch(e){case`top`:return`top-left`;case`right`:return`top-right`;case`bottom`:return`bottom-right`;case`left`:return`bottom-left`;case`none`:return`bottom-left`}}let Th=`nullValue`;function Eh(e,t){let{dataSetsValues:n,background:r}=t,i=[],a=Yh(e.dataSetStyles,n),o=[];for(let s in n){let{label:c,data:l,hidden:u,dataSetId:d}=n[s];c=e.dataSetStyles?.[d]?.label??c;let f=a.next(),p={label:c,data:l.map(e=>mf(e)?e.value:NaN),hidden:u,borderColor:e.background||r,borderWidth:+!!e.stacked,backgroundColor:f,yAxisID:e.horizontal?`y`:e.dataSetStyles?.[d]?.yAxisId??`y`,xAxisID:`x`,barPercentage:.9,categoryPercentage:n.length>1?.8:1,borderRadius:2};i.push(p);let m=e.dataSetStyles?.[d]?.trend,h=t.trendDataSetsValues?.[s];!m?.display||e.horizontal||!h||o.push(qh(p,m,h))}i.push(...o);let s=Dh(e,n);return s&&i.push(s),i}function Dh(e,t){let n=t.filter(e=>!e.hidden);if(!e.stacked||!e.showTotalLine||n.length<2)return;let r=C(0,Math.max(...n.map(e=>e.data.length))).map(e=>{let t;for(let r of n){let n=r.data[e];mf(n)&&(t=(t??0)+n.value)}return t??NaN}),i=Lf(e.background||`#FFFFFF`)<.3?`#e9ecef`:`#343a40`;return{type:`line`,label:N(`Sum`),data:r,order:-1,tension:0,fill:!1,pointRadius:3,borderWidth:2,backgroundColor:i,borderColor:i,pointBackgroundColor:i,xAxisID:`x`,yAxisID:`y`}}function Oh(e,t){let{labels:n,dataSetsValues:r,background:i}=t,a=r.map(e=>e.data).flat().filter(mf).map(e=>e.value),o=Math.max(...a),s=Math.min(...a),c=Sh(e.colorScale??He,s,o),l=[];for(let t of r)l.push({label:t.label,data:t.data.map(e=>1),backgroundColor:t.data.map(t=>mf(t)?c(t.value):e.missingValueColor||`#00000000`),borderColor:e.background||i,borderSkipped:!1,borderWidth:1,barPercentage:1,categoryPercentage:1,values:t.data.map(e=>mf(e)?e.value:void 0)});return{labels:n,datasets:l}}function kh(e,t){let{dataSetsValues:n,labels:r}=t,i=e.negativeValuesColor||`#EA6175`,a=e.positiveValuesColor||`#4EA7F2`,o=e.subTotalValuesColor||`#AAAAAA`,s=[],c=[],l={label:``,data:c,backgroundColor:s},u=[],d=0;for(let t of n)if(!t.hidden){for(let l=0;l<t.data.length;l++){let f=t.data[l];if(u.push(r[l]),!mf(f)){c.push([d,d]),s.push(``);continue}c.push([d,f.value+d]);let p=f.value>=0?a:i;l===0&&t===n[0]&&e.firstValueAsSubtotal&&(p=o),s.push(p),d+=f.value}e.showSubTotals&&(u.push(N(`Subtotal`)),c.push([0,d]),s.push(o))}return{datasets:[l],labels:u}}function Ah(e,t){let{dataSetsValues:n,axisType:r,labels:i}=t,a=[],o=!!e.fillArea,s=!!e.stacked,c=[],l=Yh(e.dataSetStyles,n);for(let u=0;u<n.length;u++){let{label:d,data:f,hidden:p,dataSetId:m}=n[u];d=e.dataSetStyles?.[m]?.label??d;let h=[],g=l.next();h=r&&[`linear`,`time`].includes(r)?f.map((e,t)=>({x:i[t]===``?NaN:i[t]??NaN,y:mf(e)?e.value:NaN})):f.map(e=>mf(e)?e.value:NaN);let _=e.dataSetStyles?.[m],v={label:d,data:h,hidden:p,tension:0,borderColor:g,backgroundColor:o?Jf(g,ct):g,pointBackgroundColor:g,fill:o?Jh(u,s):!1,pointRadius:e.hideDataMarkers?0:3,yAxisID:_?.yAxisId||`y`};a.push(v);let ee=_?.trend,y=t.trendDataSetsValues?.[u];!ee?.display||!y||c.push(qh(v,ee,y))}return a.push(...c),a}function jh(e,t){let n=Ah(e,t);for(let e of n)Fm(e.xAxisID)||(e.showLine=!1);return n}function Mh(e,t){let n,r;if(e.bubbleColor.color===`multiple`){let i=new pp(t.bubbleSizes.length);r=[];for(let e=0;e<t.bubbleSizes.length;e++)r.push(i.next());n=r.map(t=>Jf(t,e.bubbleColor.transparent?.5:1))}else r=e.bubbleColor.color,n=Jf(r,e.bubbleColor.transparent?.5:1);let i=Nh(t.bubbleSizes),a=[];for(let e=0;e<t.bubbleSizes.length;e++){let n=t.dataSetsValues[0].data[e];a.push({x:t.labels[e],y:mf(n)?n.value:NaN})}return[{label:t.dataSetsValues[0]?.label,data:a,backgroundColor:n,borderColor:r,hoverBackgroundColor:n,hoverBorderColor:r,yAxisID:`y`,pointRadius:i,pointHoverRadius:i,showLine:!1}]}function Nh(e){if(!e.length)return[];let t=e.filter(e=>Number.isFinite(e)&&e>0),n=t.length?Math.min(...t):0,r=(t.length?Math.max(...t):0)-n;return t.length?e.map(e=>e===void 0||!Number.isFinite(e)||e<0?0:e===0?2:r===0?10:10+S((e-n)/r,0,1)*20):e.map(()=>2)}function Ph(e,t){let{dataSetsValues:n}=t,r=[],i=Nm(new pp(Math.max(0,...n.map(e=>e?.data?.length??0)),e.slicesColors),n);for(let{label:t,data:a,hidden:o}of n){if(o)continue;let n={label:t,data:a.map(e=>mf(e)?e.value:NaN),borderColor:e.background||`#FFFFFF`,backgroundColor:i,hoverOffset:10};r.push(n)}return r}function Fh(e,t){let{dataSetsValues:n}=t,r=[],i=Yh(e.dataSetStyles,n),a=[],o=n.filter(({dataSetId:t})=>(e.dataSetStyles?.[t]?.type??`line`)===`bar`);for(let s=0;s<n.length;s++){let{label:c,data:l,hidden:u,dataSetId:d}=n[s];c=e.dataSetStyles?.[d]?.label||c;let f=e.dataSetStyles?.[d],p=i.next(),m=s===0?`bar`:`line`,h=f?.type??m,g={label:c,data:l.map(e=>mf(e)?e.value:null),hidden:u,borderColor:p,backgroundColor:p,yAxisID:e.dataSetStyles?.[d]?.yAxisId||`y`,xAxisID:`x`,type:h,order:h===`bar`?n.length+s:s,pointRadius:e.hideDataMarkers?0:3};g.type===`bar`&&(g.barPercentage=.9,g.categoryPercentage=o.length>1?.8:1,g.borderRadius=2),r.push(g);let _=e.dataSetStyles?.[d]?.trend,v=t.trendDataSetsValues?.[s];!_?.display||!v||a.push(qh(g,_,v))}return r.push(...a),r}function Ih(e,t){let{dataSetsValues:n}=t,r=[],i=e.fillArea??!1,a=Yh(e.dataSetStyles,n);for(let t=0;t<n.length;t++){let{label:o,data:s,hidden:c}=n[t];e.dataSetStyles?.[t]?.label&&(o=e.dataSetStyles[t].label);let l=a.next(),u={label:o,data:s.map(e=>mf(e)?e.value:null),hidden:c,borderColor:l,backgroundColor:l,pointBackgroundColor:l,pointRadius:e.hideDataMarkers?0:3};i&&(u.backgroundColor=Jf(l,ct),u.fill=`start`),r.push(u)}return r}function Lh(e,t){let{availableRegions:n,dataSetsValues:r,labels:i}=t,a=e.region||n[0]?.id,o=a?t.getGeoJsonFeatures(a):void 0,s={outline:o,showOutline:!!o,data:[]};if(o&&a){let e={};if(r[0])for(let n=0;n<r[0].data.length;n++){let o=r[0].data[n];if(!i[n]||o===void 0)continue;let s=t.geoFeatureNameToId(a,i[n]);s&&(e[s]={value:mf(o)?o.value:0,label:i[n]})}for(let t of o)t.id&&s.data.push({feature:{...t,properties:{name:e[t.id]?.label}},value:e[t.id]?.value})}return[s]}function Rh(e,t){let n=t.dataSetsValues[0],{labels:r,background:i}=t;if(!n)return[];let{label:a,data:o}=n;return a=e.dataSetStyles?.[0]?.label||a,[{label:a,data:o.map(e=>{if(!mf(e))return 0;let t=e.value;return t<=0?[0,0]:[-t,t]}),backgroundColor:zh(r,e.funnelColors),yAxisID:`y`,xAxisID:`x`,barPercentage:1,categoryPercentage:1,borderColor:e.background||i,borderWidth:3}]}function zh(e,t){let n=new pp(e.length,t);return e.map(()=>n.next())}function Bh(e,t){let{dataSetsValues:n,labels:r,background:i}=t,a=Wh(Hh(n,r)),o=a[0]||[],s=new pp(o.length,e.groupColors||[]),c=o.map(e=>({label:e.label,color:s.next()})),l=[];for(let t=a.length-1;t>=0;t--){let n={groupColors:c,parsing:{key:`value`},data:a[t],borderColor:t=>{let n=t.type===`data`?t.raw:void 0;return!n||n.label===`nullValue`?Ie:e.background||i},backgroundColor:e=>{let t=e.type===`data`?e.raw:void 0;if(!t||t.label===`nullValue`)return Ie;let n=t.groups[0];return c.find(e=>e.label===n)?.color},hoverOffset:10};l.push(n)}return l}function Vh(e,t){let n=[],r=Math.max(...e.map(e=>e.data.length));for(let i=0;i<r;i++){n[i]={};for(let t=0;t<e.length;t++){let r=e[t].data[i]?.value,a=r===null?Th:String(r);n[i][t]=a}n[i].value=Number(t[i])}return n}function Hh(e,t){return Uh(Vh(e,t),0,e.length,[])}function Uh(e,t,n,r){if(t>=n)return[];let i=Object.groupBy(e,e=>e[t]);return Object.keys(i).map(e=>{let a=i[e]?.reduce((e,t)=>e+Number(t.value),0)||0,o=[...r,e];return{label:e,value:a,children:Uh(i[e]||[],t+1,n,[...r,e]),groups:o,depth:t}}).sort((e,t)=>t.value-e.value)}function Wh(e){let t=[],n=[...e];for(;n.length>0;){let e=n.shift();e&&(t[e.depth]||(t[e.depth]=[]),t[e.depth].push(e),e.children&&n.push(...e.children))}return t}function Gh(e,t){let{dataSetsValues:n,labels:r,locale:i,axisFormats:a}=t,o={locale:i,format:a?.y};if(n.length===0)return[];let s=Hh(n,r).sort((e,t)=>t.value-e.value),c=Xh(e,s),l=[],u=Math.max(...n.map(e=>e.data.length));for(let e=0;e<u;e++){l[e]={};for(let t=0;t<n.length;t++)l[e][t]=n[t].data[e].value?String(n[t].data[e].value):void 0;l[e].value=Number(r[e])}let d=e.showLabels??$m.showLabels,f=e.showValues??$m.showValues,p=e.coloringOptions||$m.coloringOptions,m;return p?.type===`colorScale`&&(m=Zh(s,p)),[{data:[],tree:l,labels:{display:d||f,overflow:`hidden`,...Kh(e.valuesDesign,$m.valuesDesign),formatter:e=>[d?e.raw.g:void 0,f?V(e.raw.v,o):void 0].filter(w)},captions:{display:e.showHeaders??$m.showHeaders,padding:6,...Kh(e.headerDesign,$m.headerDesign)},key:`value`,groups:C(0,n.length).map(e=>String(e)),borderWidth:0,spacing:1,displayMode:`headerBoxes`,groupColors:c,backgroundColor:t=>{if(t.type!==`data`)return`transparent`;if(!t.raw.isLeaf)return e.headerDesign?.fillColor||$m.headerDesign?.fillColor;if(p.type===`colorScale`)return m?.(t.raw.v)||`#FF0000`;if(p.type===`categoryColor`)return Qh(t,s,p,c);throw Error(`Unsupported coloring option type}`)}}]}function Kh(e,t){let n=e=>{let t=e.element.options.backgroundColor;return Lf(t)>.7?`#666666`:`#FFFFFF`};return{align:e?.align??t?.align,position:e?.verticalAlign??t?.verticalAlign,color:e?.color||n,hoverColor:e?.color||n,font:{weight:e?.bold??t?.bold?`bold`:`normal`,style:e?.italic??t?.italic?`italic`:`normal`,size:e?.fontSize??t?.fontSize}}}function qh(e,t,n){let r=Bf(e.backgroundColor);r.a=1;let i=t.color||Yf(zf(r),.5);return{type:`line`,xAxisID:t.type===`trailingMovingAverage`?gm:`x1`,yAxisID:e.yAxisID,label:e.label?N(`Trend line for %s`,e.label):``,data:n,order:-1,showLine:!0,pointRadius:0,backgroundColor:i,borderColor:i,borderDash:[5,5],borderWidth:void 0,fill:!1,pointBackgroundColor:i}}function Jh(e,t){return t?e===0?`origin`:`-1`:`origin`}function Yh(e,t){let n=t.map(t=>e?.[t.dataSetId]?.backgroundColor),r=t.length;return new pp(r,n)}function Xh(e,t){let n=e.coloringOptions?.type===`categoryColor`?e.coloringOptions.colors:[],r=new pp(t.length,n);return t.map(e=>({label:e.label,color:r.next()}))}function Zh(e,t){if(e.length===0)return;let n=Wh(e),r=n[n.length-1],i=Math.min(...r.map(e=>e.value)),a=Math.max(...r.map(e=>e.value));if(Number.isFinite(i)&&Number.isFinite(a)){let e=[{value:i,color:t.minColor}];if(t.midColor){let n=(i+a)/2;e.push({value:n,color:t.midColor})}return e.push({value:a,color:t.maxColor}),vp(e)}}function Qh(e,t,n,r){let i=e.raw._data.children[0][0],a=r.find(e=>e.label===i)?.color;if(!a||!n.useValueBasedGradient)return a||`#FF0000`;let o=t.find(e=>e.label===i);if(!o||!o.children.length)return a;let s=Wh(o.children),c=s[s.length-1],l=Math.max(...c.map(e=>e.value)),u=Math.min(...c.map(e=>e.value));return u===l||!isFinite(u)||!isFinite(l)?a:Yf(a,((Number(e.raw.v)||0)-l)/(u-l)*.5)}let $h={id:`sunburstHoverPlugin`,afterEvent(e,t,n){if(!n.enabled)return;let r=e.getActiveElements(),i=r.map(e=>({datasetIndex:e.datasetIndex,index:e.index}));for(let t of r){let n=e.data.datasets[t.datasetIndex].data[t.index];for(let t=0;t<e.data.datasets.length;t++){let r=e.data.datasets[t];for(let e=0;e<r.data.length;e++){let a=r.data[e];eg(n.groups,a.groups)&&i.push({datasetIndex:t,index:e})}}}i=i.filter(t=>{let{datasetIndex:n,index:r}=t;return e.data.datasets[n].data[r].label!==Th}),e.setActiveElements(i);for(let t of e.getSortedVisibleDatasetMetas())for(let e of t.data){let t=e.$context,{datasetIndex:n,index:r,dataset:a,raw:o}=t;if(o.label===`nullValue`)continue;let s=typeof a.backgroundColor==`function`?a.backgroundColor(t):a.backgroundColor;i.length&&!i.some(e=>e.datasetIndex===n&&e.index===r)?e.options.backgroundColor=Yf(s,.5):e.options.backgroundColor=s}}};function eg(e,t){return t.length>e.length&&e.every((e,n)=>e===t[n])}let tg={id:`sunburstLabelsPlugin`,afterDatasetsDraw(e,t,n){if(!n.showValues&&!n.showLabels||e.config.type!==`doughnut`)return;let r=e.ctx;ng(e,n,r)}};function ng(e,t,n){let r=t.style,i=r.fontSize||13,a=i+3;for(let o of e._metasets)for(let s=0;s<o._dataset.data.length;s++){let c=o._dataset.data[s];if(c.label===`nullValue`)continue;let l=[t.showLabels?c.label:void 0,t.showValues?t.callback(c.value,`y`):void 0].filter(w),u=o.data[s],{startAngle:d,endAngle:f,innerRadius:p,outerRadius:m,circumference:h}=u,g=u.options.offset/4,_=g*(1-Math.sin(Math.min(Math.PI,h||0)));p+=_,m+=_;let v=(d+f)/2,ee=(p+m)/2,y=(m-p)*.9,b=f-d;if((b>=Math.PI?m:Math.sin(b/2)*p*2)<l.length*a)continue;n.save();let te={x:Math.cos(v)*g,y:Math.sin(v)*g},ne=e.chartArea.left+e.chartArea.width/2+te.x,re=e.chartArea.top+e.chartArea.height/2+te.y;n.translate(ne,re);let ie;v>Math.PI/2?(n.rotate(v-Math.PI),ie=-ee):(ie=ee,n.rotate(v));let ae=u.options.backgroundColor,oe=Lf(ae)>.7?`#666666`:`#FFFFFF`;n.fillStyle=r.textColor||oe,n.textAlign=`center`,n.textBaseline=`middle`,n.font=Tp(i,r.bold,r.italic);let se=-((l.length-1)*a)/2;for(let e=0;e<l.length;e++){let t=Up(n,y,l[e],r,`px`);n.fillText(t,ie,se+e*a)}n.restore()}}let rg={id:`waterfallLinesPlugin`,beforeDraw(e,t,n){if(!n.showConnectorLines)return;let r=e._metasets?.[0]?.data;if(!r)return;let i=e.ctx;i.save(),i.setLineDash([3,2]);for(let e=0;e<r.length;e++){let t=r[e];if(t.height===0)continue;let n=ag(r,e);if(!n)break;let a=ig(t),o=ig(n),s=t.$context.raw,c=s[1]-s[0],l=Math.round(c<0?a.bottom-1:a.top),u=Math.round(a.right),d=Math.round(o.left);i.strokeStyle=`#999`,i.beginPath(),i.moveTo(u+1,l+.5),i.lineTo(d,l+.5),i.stroke()}i.restore()}};function ig(e){let t=e.base<e.y;return{left:e.x-e.width/2,right:e.x+e.width/2,bottom:t?e.base+e.height:e.y+e.height,top:t?e.base:e.y}}function ag(e,t){return e.find((e,n)=>n>t&&e.height!==0)}let og={id:`zoomWindowPlugin`,afterDatasetsDraw:function(e,t,n){if(!n.getLowerBound||!n.getUpperBound)return;let{ctx:r,chartArea:{left:i,right:a,top:o,bottom:s}}=e,c=n.getLowerBound()??i,l=n.getUpperBound()??a;c>l&&([c,l]=[l,c]),c=Math.max(i,c),l=Math.min(a,l),c===i&&--c,l===a&&(l+=1),r.save(),r.fillStyle=`rgba(255,255,255,0.5)`,r.beginPath(),r.rect(i,s,c-i,o-s),r.rect(l,s,a-l,o-s),r.fill(),r.beginPath(),r.strokeStyle=`#bbb`,r.rect(c,s,l-c,o-s),r.stroke(),r.lineWidth=2,r.beginPath(),r.moveTo(c-3,(o+s)/2-7),r.lineTo(c-3,(o+s)/2+7),r.stroke(),r.beginPath(),r.moveTo(l+3,(o+s)/2-7),r.lineTo(l+3,(o+s)/2+7),r.stroke(),r.restore()}};ri.add(`chartShowValuesPlugin`,{register:e=>e.register(Rm),unregister:e=>e.unregister(Rm)}),ri.add(`chartMinorGridPlugin`,{register:e=>e.register(Zp),unregister:e=>e.unregister(Zp)}),ri.add(`waterfallLinesPlugin`,{register:e=>e.register(rg),unregister:e=>e.unregister(rg)}),ri.add(`funnelController`,{register:e=>e.register(Kp()),unregister:e=>e.unregister(Kp())}),ri.add(`funnelElement`,{register:e=>e.register(qp()),unregister:e=>e.unregister(qp())}),ri.add(`funnelTooltipPositioner`,{register:e=>e.Tooltip.positioners.funnelTooltipPositioner=Yp,unregister:e=>e.Tooltip.positioners.funnelTooltipPositioner=void 0}),ri.add(`sunburstLabelsPlugin`,{register:e=>e.register(tg),unregister:e=>e.unregister(tg)}),ri.add(`sunburstHoverPlugin`,{register:e=>e.register($h),unregister:e=>e.unregister($h)}),ri.add(`chartColorScalePlugin`,{register:e=>e.register(Gp),unregister:e=>e.unregister(Gp)}),ri.add(`calendarController`,{register:e=>e.register(ba()),unregister:e=>e.unregister(ba())}),ri.add(`zoomWindowPlugin`,{register:e=>e.register(og),unregister:e=>e.unregister(og)}),ri.add(`chartBackgroundPlugin`,{register:e=>e.register(ya),unregister:e=>e.unregister(ya)}),ri.add(`geoProjectionPlugin`,{register:e=>e.register(Xp),unregister:e=>e.unregister(Xp)});var sg=class extends k{static template=`o-spreadsheet-ChartJsComponent`;props=(0,t.useProps)({chartId:M.string(),isFullScreen:M.boolean().optional()});canvas=t.signal.ref(HTMLCanvasElement);chart;currentRuntime;animationStore;currentDevicePixelRatio=window.devicePixelRatio;get chartRuntime(){let e=this.env.model.getters.getChartRuntime(this.props.chartId);if(!(`chartJsConfig`in e))throw Error(`Unsupported chart runtime`);return e}setup(){this.shouldAnimate&&(this.animationStore=A(va)),(0,t.onMounted)(()=>{ai();let e=this.chartRuntime;this.currentRuntime=e,this.createChart(x(e))}),(0,t.onWillUnmount)(this.unmount.bind(this)),Vi(()=>{let e=this.chartRuntime;e===this.currentRuntime?this.currentDevicePixelRatio!==window.devicePixelRatio&&(this.currentDevicePixelRatio=window.devicePixelRatio,this.updateChartJs(x(this.currentRuntime))):(e.chartJsConfig.type===this.currentRuntime.chartJsConfig.type?this.updateChartJs(x(e)):(this.chart?.destroy(),this.createChart(x(e))),this.currentRuntime=e)})}unmount(){this.chart?.destroy()}get shouldAnimate(){return this.env.model.getters.isDashboard()}createChart(e){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);let t=e.chartJsConfig;if(this.shouldAnimate&&this.animationStore){let e=this.env.model.getters.getChartDefinition(this.props.chartId)?.type;e&&this.animationStore.animationPlayed[this.animationChartId]!==e&&(t=this.enableAnimationInChartData(t),this.animationStore.disableAnimationForChart(this.animationChartId,e))}let n=this.canvas();if(!n)return;let r=n.getContext(`2d`);this.chart=new globalThis.Chart(r,t)}updateChartJs(e){let t=e.chartJsConfig;if(this.shouldAnimate){let e=this.env.model.getters.getChartDefinition(this.props.chartId)?.type;e&&this.hasChartDataChanged()&&this.animationStore&&(t=this.enableAnimationInChartData(t),this.animationStore.disableAnimationForChart(this.animationChartId,e))}t.data&&t.data.datasets?(this.chart.data=t.data,t.options?.plugins?.title&&(this.chart.config.options.plugins.title=t.options.plugins.title)):this.chart.data.datasets=[],this.chart.config.options=t.options,this.chart.update()}hasChartDataChanged(){return!T(this.getChartDataInRuntime(this.currentRuntime),this.getChartDataInRuntime(this.chartRuntime))}enableAnimationInChartData(e){return{...e,options:{...e.options,animation:{animateRotate:!0}}}}getChartDataInRuntime(e){let t=e.chartJsConfig.data;return{labels:t.labels,dataset:t.datasets.map(e=>({data:e.data,label:e.label,tree:e.tree}))}}get animationChartId(){return this.props.isFullScreen?this.props.chartId+`-fullscreen`:this.props.chartId}};function cg(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 lg(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=cg(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){ug(i,e,a),ug(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 ug(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 dg(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 fg(e){if(!wt(e))return e;if(!pg(e))throw Error(`The value should be a scalar or a 1x1 matrix`);return e[0][0]}function pg(e){return e.length===1&&e[0].length===1}function mg(e){return wt(e)&&!pg(e)}function hg(e){let t=[];for(let n=0;n<e.length;n++)mg(e[n])&&t.push(n);return t}var gg=class{static commonKeys=[`type`,`title`,`background`,`humanize`,`annotationText`,`annotationLink`]};function _g(e,t,n){if(!e)return{scalar:void 0,range:void 0};if(!Dn(e))return{scalar:{value:e},range:void 0};let r=t.evaluateFormulaResult(n,e),i=mg(r)?r[0][0]:fg(r),a,o=Sg(e);return o&&(a=ju(t,n,o),a&&t.getEvaluatedCell({sheetId:a.sheetId,col:a.zone.left,row:a.zone.top}).type===`empty`&&(i=void 0)),{scalar:i,range:a}}function vg(e,t,n,r,i){if(!e)return``;if(n===`text`||typeof t?.value!=`number`||typeof e.value!=`number`)return r?jc(e,i):V(e.value,{format:e.format,locale:i});let{value:a,format:o}=e;return n===`progress`?(a=t.value/a,o=`0.0%`):(a=Math.abs(t.value-a),n===`percentage`&&a!==0&&(a/=e.value),n===`percentage`&&(o=`0.0%`),o||(a=Math.round(a*100)/100)),r?jc({value:a,format:o},i):V(a,{format:o,locale:i})}function yg(e,t,n){return e?.value===void 0||e?.value===null?``:t?jc(e,n):e.format?V(e.value,{format:e.format,locale:n}):String(e.value??``)}function bg(e,t,n,r,i){if(t===`text`||t===`progress`||typeof e?.value!=`number`||typeof n?.value!=`number`)return;let a=n.value-e.value;if(a>0)return r;if(a<0)return i}function xg(e,t,n){if(n===`text`||typeof e?.value!=`number`||typeof t?.value!=`number`)return`neutral`;let r=t.value-e.value;return r>0?`up`:r<0?`down`:`neutral`}function Sg(e){if(!e||!Dn(e))return;let t=e.slice(1);return vl.test(t)?t:void 0}let Cg=globalThis.Path2D,wg=Cg&&new Cg(`M8.6 4.8a.5.5 0 0 1 0 .75l-3.9 3.9a.5 .5 0 0 1 -.75 0l-3.8 -3.9a.5 .5 0 0 1 0 -.75l.4-.4a.5.5 0 0 1 .75 0l2.3 2.4v-5.7c0-.25.25-.5.5-.5h.6c.25 0 .5.25.5.5v5.8l2.3 -2.4a.5.5 0 0 1 .75 0z`),Tg=Cg&&new Cg(`M8.7 5.5a.5.5 0 0 0 0-.75l-3.8-4a.5.5 0 0 0-.75 0l-3.8 4a.5.5 0 0 0 0 .75l.4.4a.5.5 0 0 0 .75 0l2.3-2.4v5.8c0 .25.25.5.5.5h.6c.25 0 .5-.25.5-.5v-5.8l2.2 2.4a.5.5 0 0 0 .75 0z`),Eg={sequence:40,allowedDefinitionKeys:[...gg.commonKeys,`keyValue`,`keyDescr`,`baseline`,`baselineMode`,`baselineDescr`,`baselineColorUp`,`baselineColorDown`],fromStrDefinition:e=>e,validateDefinition(e,t){return`Success`},copyInSheetId:(e,t,n,r)=>{let i=e=>r.copyFormulaStringForSheet(t,n,e,`keepSameReference`);return{...e,keyValue:e.keyValue?i(e.keyValue):e.keyValue,baseline:e.baseline?i(e.baseline):e.baseline}},getDefinitionFromContextCreation(e,t){let n=e.dataSource?.type===`range`?e.dataSource?.dataSets?.[0]?.dataRange:void 0,r=(e.scorecardKeyValueFormula===void 0||Sg(e.scorecardKeyValueFormula))&&n?`=${n}`:e.scorecardKeyValueFormula,i=(e.scorecardBaselineFormula===void 0||Sg(e.scorecardBaselineFormula))&&e.auxiliaryRange?`=${e.auxiliaryRange}`:e.scorecardBaselineFormula;return{background:e.background,type:`scorecard`,keyValue:r,title:e.title||{text:``},baselineMode:at,baselineColorUp:ot,baselineColorDown:st,baseline:i,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},transformDefinition(e,t,{adaptFormulaString:n}){let r,i;return e.baseline&&(r=n(t,e.baseline)),e.keyValue&&(i=n(t,e.keyValue)),{...e,baseline:r,keyValue:i}},duplicateInDuplicatedSheet(e,t,n,r){let i=e=>r.copyFormulaStringForSheet(t,n,e,`moveReference`);return{...e,keyValue:e.keyValue?i(e.keyValue):e.keyValue,baseline:e.baseline?i(e.baseline):e.baseline}},toStrDefinition:e=>e,getContextCreation(e,t){let n=Sg(e.keyValue);return{...e,dataSource:{type:`range`,dataSets:n?[{dataRange:n,dataSetId:`0`}]:[]},auxiliaryRange:Sg(e.baseline),scorecardKeyValueFormula:e.keyValue,scorecardBaselineFormula:e.baseline}},getDefinitionForExcel:()=>void 0,updateRanges(e,t,n){let r=e.baseline?t.adaptFormulaString(n,e.baseline):e.baseline,i=e.keyValue?t.adaptFormulaString(n,e.keyValue):e.keyValue;return e.baseline===r&&e.keyValue===i?e:{...e,baseline:r,keyValue:i}},getFormulas(e,t,n){let r=[];return n.keyValue&&Dn(n.keyValue)&&r.push(yd.Compile(n.keyValue,t,e)),n.baseline&&Dn(n.baseline)&&r.push(yd.Compile(n.baseline,t,e)),r},getRuntime(e,t,n,r,i,a){let o=``,{scalar:s,range:c}=_g(t.keyValue,e,r),l=e.getLocale();o=s==null?``:yg(s,t.humanize??!0,l);let{scalar:u,range:d}=_g(t.baseline,e,r),{background:f,fontColor:p}=e.getStyleOfSingleCellChart(t.background,c,a),m=vg(u,s,t.baselineMode,t.humanize??!0,l),h=t.baselineMode===`progress`&&mo(m,l)?I(m,l):0,g=t.title;return{title:{...g,text:g.text?e.dynamicTranslate(g.text):``},keyValue:o,keyDescr:t.keyDescr?.text?e.dynamicTranslate(t.keyDescr.text):``,baselineDisplay:m,baselineArrow:xg(u,s,t.baselineMode),baselineColor:bg(u,t.baselineMode,s,t.baselineColorUp,t.baselineColorDown),baselineDescr:t.baselineMode!==`progress`&&t.baselineDescr?.text?e.dynamicTranslate(t.baselineDescr.text):``,fontColor:p,background:f,baselineStyle:{...t.baselineMode!==`percentage`&&t.baselineMode!==`progress`&&d?e.getCellComputedStyle({sheetId:d.sheetId,col:d.zone.left,row:d.zone.top}):void 0,fontSize:t.baselineDescr?.fontSize,align:t.baselineDescr?.align},baselineDescrStyle:{textColor:t.baselineDescr?.color,...t.baselineDescr},keyValueStyle:{...c?e.getCellComputedStyle({sheetId:c.sheetId,col:c.zone.left,row:c.zone.top}):void 0,fontSize:t.keyDescr?.fontSize,align:t.keyDescr?.align},keyValueDescrStyle:{textColor:t.keyDescr?.color,...t.keyDescr},progressBar:t.baselineMode===`progress`?{value:h,color:h>0?t.baselineColorUp:t.baselineColorDown}:void 0}}};function Dg(e,t,n=1){let r=t.getContext(`2d`);if(!r)throw Error(`Unable to retrieve 2D context from canvas`);let i=typeof globalThis.devicePixelRatio==`number`?globalThis.devicePixelRatio:1;t.width=i*e.canvas.width*n,t.height=i*e.canvas.height*n,r.scale(i*n,i*n);let a=e.canvas.width-20;if(r.fillStyle=e.canvas.backgroundColor,r.fillRect(0,0,e.canvas.width,e.canvas.height),e.title){r.font=e.title.style.font,r.fillStyle=e.title.style.color;let t=r.textBaseline;r.textBaseline=`middle`,r.fillText(Vp(r,e.title.text,a-e.title.position.x),e.title.position.x,e.title.position.y),r.textBaseline=t}if(e.baseline&&(r.font=e.baseline.style.font,r.fillStyle=e.baseline.style.color,Hp(r,e.baseline.text,e.baseline.position,e.baseline.style.underline,e.baseline.style.strikethrough,void 0,e.baseline.style.highlightText)),e.baselineArrow&&e.baselineArrow.style.size>0&&Cg){r.save(),r.fillStyle=e.baselineArrow.style.highlight?Yf(e.baselineArrow.style.color,Ze):e.baselineArrow.style.color,r.translate(e.baselineArrow.position.x,e.baselineArrow.position.y);let t=e.baselineArrow.style.size/10;switch(r.scale(t,t),e.baselineArrow.direction){case`down`:r.fill(wg);break;case`up`:r.fill(Tg);break}r.restore()}if(e.baselineDescr){let t=e.baselineDescr;r.font=t.style.font,r.fillStyle=t.style.color,Hp(r,Vp(r,t.text,a-t.position.x),t.position,void 0,void 0,void 0,e.baseline?.style.highlightText)}if(e.key&&(r.font=e.key.style.font,r.fillStyle=e.key.style.color,Hp(r,Vp(r,e.key.text,a-e.key.position.x),e.key.position,e.key.style.underline,e.key.style.strikethrough,void 0,e.key.style.highlightText)),e.keyDescr){let t=e.keyDescr;r.font=e.keyDescr?.style.font??t.style.font,r.fillStyle=t.style.color,Hp(r,Vp(r,t.text,a-t.position.x),t.position,void 0,void 0,void 0,e.key?.style.highlightText)}if(e.progressBar){if(r.fillStyle=e.progressBar.style.backgroundColor,r.beginPath(),r.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width,e.progressBar.dimension.height,e.progressBar.dimension.height/2),r.fill(),r.fillStyle=e.progressBar.style.color,r.beginPath(),e.progressBar.value>0)r.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width*Math.max(0,Math.min(1,e.progressBar.value)),e.progressBar.dimension.height,e.progressBar.dimension.height/2);else{let t=e.progressBar.dimension.width*Math.max(0,Math.min(1,-e.progressBar.value));r.roundRect(e.progressBar.position.x+e.progressBar.dimension.width-t,e.progressBar.position.y,t,e.progressBar.dimension.height,e.progressBar.dimension.height/2)}r.fill()}}let Og=.05;function kg(e,t){let n=e||``;return t&&n?` `+n:n}function Ag({width:e,height:t},n){return new jg({width:e,height:t},n).computeDesign()}var jg=class{runtime;context;width;height;constructor({width:e,height:t},n){if(this.runtime=n,this.width=e,this.height=t,typeof OffscreenCanvas>`u`)throw Error(`OffscreenCanvas is not supported in this environment`);let r=new globalThis.OffscreenCanvas(e,t).getContext(`2d`);if(!r)throw Error(`Unable to create scorecard measurement context`);this.context=r}computeDesign(){let e={canvas:{width:this.width,height:this.height,backgroundColor:this.backgroundColor}},t=this.getTextStyles(),n=0;if(this.title){let r,i;switch({height:n,width:i}=this.getFullTextDimensions(this.title,t.title.font),this.runtime.title.align){case`center`:r=(this.width-i)/2;break;case`right`:r=this.width-i-20;break;default:r=20}e.title={text:this.title,style:t.title,position:{x:r,y:10+n/2}}}let r=t.baselineArrow?.size??0,{height:i,width:a}=this.getTextDimensions(this.baseline,t.baselineValue.font);this.baseline||(i=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).height);let o=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).width,s;switch(this.runtime.baselineStyle?.align){case`right`:s=this.width-20-o-a;break;case`left`:s=20+r;break;default:s=(this.width-a-o+r)/2}if(this.baseline&&(e.baseline={text:this.baseline,style:t.baselineValue,position:{x:s,y:this.keyValue?this.height*(1-Og*(this.runtime.progressBar?1:2)):this.height-(this.height-n-i)/2-10}},t.baselineArrow&&!this.runtime.progressBar&&(e.baselineArrow={direction:this.baselineArrow,style:t.baselineArrow,position:{x:e.baseline.position.x-r,y:e.baseline.position.y-(i+r)/2}})),e.baseline&&this.baselineDescr){let n={x:e.baseline.position.x+a,y:e.baseline.position.y};e.baselineDescr={text:this.baselineDescr,style:t.baselineDescr,position:n}}let c=0;this.runtime.progressBar&&(c=this.height*.05,e.progressBar={position:{x:40,y:this.height*(1-2*Og)-i-c},dimension:{height:c,width:this.width-80},value:this.runtime.progressBar.value,style:{color:this.runtime.progressBar.color,backgroundColor:this.secondaryFontColor}});let{width:l,height:u}=this.getFullTextDimensions(this.keyValue,t.keyValue.font),d=this.getTextDimensions(this.keyDescr,t.keyDescr.font).width,f;switch(this.runtime.keyValueStyle?.align){case`right`:f=this.width-20-d-l;break;case`left`:f=20;break;default:f=(this.width-l-d)/2}if(this.keyValue&&(e.key={text:this.keyValue,style:t.keyValue,position:{x:Math.max(20,f),y:this.height*(.5-Og*2)+10/2+(n+u/2)/2}}),e.key&&this.keyDescr){let n={x:e.key.position.x+l,y:e.key.position.y};e.keyDescr={text:this.keyDescr,style:t.keyDescr,position:n}}return e}get title(){return this.runtime.title.text??``}get keyValue(){return this.runtime.keyValue}get keyDescr(){return kg(this.runtime.keyDescr,this.keyValue)}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){return kg(this.runtime.baselineDescr,this.baseline)}get baselineArrow(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get secondaryFontColor(){return Tm(this.backgroundColor)}getTextDimensions(e,t){this.context.font=t;let n=this.context.measureText(e);return{width:n.width,height:n.actualBoundingBoxAscent+n.actualBoundingBoxDescent}}getFullTextDimensions(e,t){this.context.font=t;let n=this.context.measureText(e);return{width:n.width,height:n.fontBoundingBoxAscent+n.fontBoundingBoxDescent}}getTextStyles(){let e=this.runtime.keyValueStyle?.fontSize??32,t=Math.floor(.9*e),n=this.runtime.baselineStyle?.fontSize??16,r=Math.floor(.9*n);return this.runtime.progressBar&&(n/=1.5),{title:{font:Tp(this.runtime.title.fontSize??14,this.runtime.title.bold,this.runtime.title.italic),color:this.runtime.title.color??this.secondaryFontColor},keyValue:{color:this.runtime.keyValueStyle?.textColor||this.runtime.fontColor,font:Tp(e,this.runtime.keyValueStyle?.bold,this.runtime.keyValueStyle?.italic),strikethrough:this.runtime.keyValueStyle?.strikethrough,underline:this.runtime.keyValueStyle?.underline,highlightText:this.runtime.keyHighlight},keyDescr:{color:this.runtime.keyValueDescrStyle?.textColor||this.runtime.fontColor,font:Tp(t,this.runtime.keyValueDescrStyle?.bold,this.runtime.keyValueDescrStyle?.italic),strikethrough:this.runtime.keyValueDescrStyle?.strikethrough,underline:this.runtime.keyValueDescrStyle?.underline,highlightText:this.runtime.keyHighlight},baselineValue:{font:Tp(n,this.runtime.baselineStyle?.bold,this.runtime.baselineStyle?.italic),strikethrough:this.runtime.baselineStyle?.strikethrough,underline:this.runtime.baselineStyle?.underline,color:this.runtime.baselineColor||this.runtime.baselineStyle?.textColor||this.secondaryFontColor,highlightText:this.runtime.baselineHighlight},baselineDescr:{font:Tp(r,this.runtime.baselineDescrStyle?.bold,this.runtime.baselineDescrStyle?.italic),strikethrough:this.runtime.baselineDescrStyle?.strikethrough,underline:this.runtime.baselineDescrStyle?.underline,color:this.runtime.baselineDescrStyle?.textColor??this.secondaryFontColor,highlightText:this.runtime.baselineHighlight},baselineArrow:this.baselineArrow===`neutral`||this.runtime.progressBar?void 0:{size:this.keyValue?.8*n:0,color:this.runtime.baselineColor||this.runtime.baselineStyle?.textColor||this.secondaryFontColor,highlight:this.runtime.baselineHighlight}}}};function Mg(e,t){return Fg(pr(Pg(e),Pg(t)))}function Ng(...e){return Fg(dr(...e.map(Pg)))}function Pg(e){return{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height}}function Fg(e){if(e)return{x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top}}function Ig(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function Lg(e,t){return{height:t.height*e,width:t.width*e,x:t.x*e,y:t.y*e}}var Rg=class{mutators=[`setZoom`];storeGetters=[`getZoomedRect`,`getZoomedEvent`];zoomLevel=1;setZoom(e){if(e>2||e<.5||e===this.zoomLevel)return`noStateChange`;this.zoomLevel=e}getZoomedRect(e){return Lg(this.zoomLevel,e)}getZoomedEvent(e,t){if(t===void 0&&(t=this.getZoomTargetPosition(e,this.zoomLevel)),!t)return{ev:e,clientX:e.clientX,clientY:e.clientY,offsetX:e.offsetX,offsetY:e.offsetY};let n=e.clientX-t.x,r=e.clientY-t.y,i=n/this.zoomLevel,a=r/this.zoomLevel;return{ev:e,clientX:e.clientX-n+i,clientY:e.clientY-r+a,offsetX:i,offsetY:a}}getZoomTargetPosition(e,t){let n=e.target;return!n||!(`classList`in n)||!(n instanceof Element)?null:ee(n,t)}get scrollBarWidth(){return 15/this.zoomLevel}get cssZoom(){return`${this.zoomLevel}`}},zg=class extends k{static template=`o-spreadsheet-ScorecardChart`;props=(0,t.useProps)({chartId:M.string(),isFullScreen:M.boolean().optional()});canvas=t.signal.ref(HTMLCanvasElement);zoomStore;get runtime(){return this.env.model.getters.getChartRuntime(this.props.chartId)}get title(){let e=this.env.model.getters.getChartDefinition(this.props.chartId).title.text;return e?this.env.model.getters.dynamicTranslate(e):``}setup(){this.zoomStore=A(Rg),Vi(this.createChart.bind(this),()=>{let e=this.canvas();if(!e)return[];let t=e.getBoundingClientRect();return[t.width,t.height,this.runtime,e,window.devicePixelRatio]});let e=new ResizeObserver(()=>this.createChart());(0,t.onMounted)(()=>{let t=this.canvas();t&&e.observe(t)}),(0,t.onWillUnmount)(()=>e.disconnect())}config(e,t){return Ag(Lg(1/t,e),this.runtime)}createChart(){let e=this.canvas();if(!e)return;let t=this.zoomStore.zoomLevel;Dg(this.config(e.getBoundingClientRect(),t),e,t)}};let Bg=new O;var Vg=class{mutators=[`notifyUser`,`raiseError`,`askConfirmation`,`updateNotificationCallbacks`];notifyUser=e=>window.alert(e.text);askConfirmation=(e,t,n)=>{window.confirm(e)?t():n?.()};raiseError=(e,t)=>{window.alert(e),t?.()};updateNotificationCallbacks(e){this.notifyUser=e.notifyUser||this.notifyUser,this.raiseError=e.raiseError||this.raiseError,this.askConfirmation=e.askConfirmation||this.askConfirmation}},Hg=class{mutators=[`setSmallThreshhold`];_isSmallCallback=()=>!1;get isSmall(){return this._isSmallCallback()}setSmallThreshhold(e){this._isSmallCallback=e}},U=class extends ei{mutators=[`open`,`replace`,`toggle`,`close`,`changePanelSize`,`resetPanelSize`,`togglePinPanel`,`togglePinnedSidePanel`,`closeMainPanel`,`changeSpreadsheetWidth`,`toggleCollapsePanel`];mainPanel=void 0;secondaryPanel;availableWidth=0;screenWidthStore=this.get(Hg);get isMainPanelOpen(){return this.mainPanel&&this.mainPanel.componentTag?this.computeState(this.mainPanel).isOpen:!1}get isSecondaryPanelOpen(){return this.secondaryPanel&&this.secondaryPanel.componentTag?this.computeState(this.secondaryPanel).isOpen:!1}get mainPanelProps(){return this.mainPanel?this.getPanelProps(this.mainPanel):void 0}get mainPanelKey(){return this.mainPanel?this.getPanelKey(this.mainPanel):void 0}get secondaryPanelProps(){return this.secondaryPanel?this.getPanelProps(this.secondaryPanel):void 0}get secondaryPanelKey(){return this.secondaryPanel?this.getPanelKey(this.secondaryPanel):void 0}get totalPanelSize(){return(this.mainPanel?.size||0)+(this.secondaryPanel?.size??0)}getPanelProps(e){let t=this.computeState(e);return t.isOpen?(e.currentPanelProps=t.props??e.currentPanelProps,t.props??{}):{}}getPanelKey(e){let t=this.computeState(e);if(t.isOpen)return t.key}open(e,t={}){if(this.screenWidthStore.isSmall)return;let n={currentPanelProps:t,componentTag:e,size:350},r=this.computeState(n);if(!r.isOpen)return;if(!this.mainPanel||!this.mainPanel.isPinned||this.mainPanelKey===r.key){this._openPanel(`mainPanel`,n,r);return}let i=this.mainPanel.isCollapsed?350:this.mainPanel.size;if(!this.secondaryPanel&&i+350>this.availableWidth){this.get(Vg).notifyUser({sticky:!1,type:`warning`,text:N(`The window is too small to display multiple side panels.`)});return}this._openPanel(`secondaryPanel`,n,r)}replace(e,t,n={}){let r={currentPanelProps:n,componentTag:e,size:350},i=this.computeState(r);if(!i.isOpen)return;let a=()=>{this.mainPanel?.isCollapsed&&this.toggleCollapsePanel(`mainPanel`)},o=this.mainPanelKey===i.key,s=this.secondaryPanelKey===i.key;if(o&&this.secondaryPanel){this.close(),a();return}if(s){this.closeMainPanel(),this.togglePinPanel(),a();return}let c=this.mainPanelKey===t?`mainPanel`:`secondaryPanel`;this._openPanel(c,r,i)}_openPanel(e,t,n){let r=this[e];r&&t.componentTag!==r.componentTag&&r.currentPanelProps?.onCloseSidePanel?.(),this[e]={currentPanelProps:n.props??{},componentTag:t.componentTag,size:r?.size||350,isCollapsed:r?.isCollapsed||!1,isPinned:r&&`isPinned`in r?r.isPinned:!1},this[e].isCollapsed&&this.toggleCollapsePanel(e)}toggle(e,t={}){let n=this.mainPanel?.isPinned?this.secondaryPanel:this.mainPanel;n&&e===n.componentTag?this.close():this.open(e,t)}close(){if(this.mainPanel?.isPinned){this.secondaryPanel&&=(this.secondaryPanel.currentPanelProps.onCloseSidePanel?.(),void 0);return}this.mainPanel?.currentPanelProps.onCloseSidePanel?.(),this.mainPanel=void 0}closeMainPanel(){this.mainPanel?.currentPanelProps.onCloseSidePanel?.(),this.mainPanel=this.secondaryPanel||void 0,this.secondaryPanel=void 0}changePanelSize(e,t){let n=this[e];if(!n||`isCollapsed`in n&&n.isCollapsed)return;t=Math.max(t,350);let r=e===`mainPanel`?this.secondaryPanel?.size||0:this.mainPanel?.size||0;t>this.availableWidth-r&&(e===`mainPanel`&&this.secondaryPanel&&(this.secondaryPanel.size=Math.max(this.availableWidth-t,350),r=this.secondaryPanel.size),t=Math.max(this.availableWidth-r,350)),n.size=t}resetPanelSize(e){this[e]&&(this[e].size=350)}togglePinPanel(){this.mainPanel&&(this.mainPanel.isPinned=!this.mainPanel.isPinned,!this.mainPanel.isPinned&&this.secondaryPanel&&(this.secondaryPanel?.currentPanelProps.onCloseSidePanel?.(),this.mainPanel=this.secondaryPanel,this.secondaryPanel=void 0))}togglePinnedSidePanel(e,t={}){if(this.mainPanel?.componentTag===e&&this.isMainPanelOpen){this.closeMainPanel();return}if(this.secondaryPanel?.componentTag===e&&this.isSecondaryPanelOpen){this.secondaryPanel?.currentPanelProps.onCloseSidePanel?.(),this.secondaryPanel=void 0;return}this.open(e,t),this.mainPanel?.isPinned||this.togglePinPanel()}toggleCollapsePanel(e){let t=this[e];t&&(t.isCollapsed?(t.isCollapsed=!1,this.changePanelSize(e,350)):(t.isCollapsed=!0,t.size=45))}computeState({componentTag:e,currentPanelProps:t}){let n=Bg.get(e).computeState,r=n?n(this.getters,t):{isOpen:!0,props:t};return r.isOpen?{...r,key:r.key||e}:r}changeSpreadsheetWidth(e){this.availableWidth=e-150,this.secondaryPanel&&e-this.totalPanelSize<150&&(this.secondaryPanel?.currentPanelProps.onCloseSidePanel?.(),this.secondaryPanel=void 0),this.mainPanel&&e-this.totalPanelSize<150&&(this.mainPanel.size=Math.max(e-150,350))}};let Ug=new O;function Wg(e){return 20+120*Math.exp(-.035*(e-1))}var Gg=class{top;bottom;left;right;offsetX;offsetY;canScrollVertically;canScrollHorizontally;viewportWidth;viewportHeight;boundaryLeftX;boundaryTopY;getters;sheetId;boundaries;getFooterSize;constructor(e){if(e.sizeInGrid.width<0||e.sizeInGrid.height<0)throw Error(`Viewport size cannot be negative`);this.getters=e.getters,this.sheetId=e.sheetId,this.boundaries=e.boundaries,this.viewportWidth=e.sizeInGrid.height&&e.sizeInGrid.width,this.viewportHeight=e.sizeInGrid.width&&e.sizeInGrid.height,this.top=e.boundaries.top,this.bottom=e.boundaries.bottom,this.left=e.boundaries.left,this.right=e.boundaries.right,this.offsetX=e.offsets.x,this.offsetY=e.offsets.y,this.canScrollVertically=e.canScrollVertically,this.canScrollHorizontally=e.canScrollHorizontally,this.getFooterSize=e.getFooterSize,this.boundaryLeftX=this.getters.getColDimensions(this.sheetId,this.boundaries.left).start,this.boundaryTopY=this.getters.getRowDimensions(this.sheetId,this.boundaries.top).start,this.adjustViewportOffsetX(),this.adjustViewportOffsetY()}getMaxSize(){let e=this.getters.findLastVisibleColRowIndex(this.sheetId,`COL`,{first:this.boundaries.left,last:this.boundaries.right}),t=this.getters.findLastVisibleColRowIndex(this.sheetId,`ROW`,{first:this.boundaries.top,last:this.boundaries.bottom}),{end:n}=this.getters.getColDimensions(this.sheetId,e),{end:r}=this.getters.getRowDimensions(this.sheetId,t),i=n-this.boundaryLeftX;this.canScrollHorizontally&&(i=Math.max(i,this.viewportWidth));let a=r-this.boundaryTopY;return this.canScrollVertically&&(a=Math.max(a,this.viewportHeight),r+this.getFooterSize()>a&&this.viewportHeight>this.getFooterSize()&&(a+=this.getFooterSize())),{width:i,height:a}}getColIndex(e){return this.searchHeaderIndex(`COL`,e+this.snapCorrection.x,this.left)}getRowIndex(e){return this.searchHeaderIndex(`ROW`,e+this.snapCorrection.y,this.top)}repositionViewport(e){let t=this.sheetId,n=this.getters.getMainCellPosition({sheetId:t,...e}),{col:r,row:i}=this.getters.getNextVisibleCellPosition(n);_r(r,this.boundaries.top,this.boundaries)&&this.repositionViewportX(r),_r(this.boundaries.left,i,this.boundaries)&&this.repositionViewportY(i)}repositionViewportX(e){let t=this.sheetId,{start:n,end:r}=this.getters.getColDimensions(t,e);this.offsetX+this.viewportWidth+this.boundaryLeftX<r?this.offsetX=r-this.viewportWidth-this.boundaryLeftX:this.offsetX+this.boundaryLeftX>n&&(this.offsetX=n-this.boundaryLeftX),this.adjustViewportZoneX()}repositionViewportY(e){let t=this.sheetId,{start:n,end:r}=this.getters.getRowDimensions(t,e);this.offsetY+this.viewportHeight+this.boundaryTopY<r?this.offsetY=r-this.viewportHeight-this.boundaryTopY:this.offsetY+this.boundaryTopY>n&&(this.offsetY=n-this.boundaryTopY),this.adjustViewportZoneY()}willNewOffsetScrollViewport(e,t){return this.canScrollHorizontally&&this.offsetX!==e||this.canScrollVertically&&this.offsetY!==t}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}isZoneVisible(e){return pr(e,this)!==void 0}getVisibleRect(e){let t=pr(e,this),n=this.snapCorrection.x,r=this.snapCorrection.y;if(t)return{x:this.getters.getColRowOffset(`COL`,this.left,t.left,this.sheetId)-(this.left===t.left?0:n),y:this.getters.getColRowOffset(`ROW`,this.top,t.top,this.sheetId)-(this.top===t.top?0:r),width:Math.min(this.getters.getColRowOffset(`COL`,t.left,t.right+1,this.sheetId)-(this.left===t.left?n:0),this.viewportWidth),height:Math.min(this.getters.getColRowOffset(`ROW`,t.top,t.bottom+1,this.sheetId)-(this.top===t.top?r:0),this.viewportHeight)}}getFullRect(e){let t=pr(e,this.boundaries),n=this.snapCorrection.x,r=this.snapCorrection.y;if(t){let t=this.getters.getColRowOffset(`COL`,this.left,e.left,this.sheetId),i=this.getters.getColRowOffset(`ROW`,this.top,e.top,this.sheetId),a=this.getters.getColRowOffset(`COL`,e.left,e.right+1,this.sheetId),o=this.getters.getColRowOffset(`ROW`,e.top,e.bottom+1,this.sheetId);return{x:t-n,y:i-r,width:a,height:o}}}isVisible(e,t){return t<=this.bottom&&t>=this.top&&e>=this.left&&e<=this.right&&!this.getters.isColHidden(this.sheetId,e)&&!this.getters.isRowHidden(this.sheetId,t)}searchHeaderIndex(e,t,n=0){if(this.viewportWidth<=0||this.viewportHeight<=0)return-1;let r=this.sheetId,i=this.getters.getNumberHeaders(r,e),a=n,o=i;for(;a<=o&&a!==i&&o!==-1;){let i=Math.floor((a+o)/2),s=this.getters.getColRowOffset(e,n,i,this.sheetId),c=this.getters.isHeaderHidden(r,e,i)?0:this.getters.getHeaderSize(r,e,i);if(t>=s&&t<s+c)return i;t>=s+c?a=i+1:o=i-1}return-1}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){let{width:e}=this.getMaxSize();this.viewportWidth+this.offsetX>e&&(this.offsetX=Math.max(0,e-this.viewportWidth))}this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){let{height:e}=this.getMaxSize();this.viewportHeight+this.offsetY>e&&(this.offsetY=Math.max(0,e-this.viewportHeight))}this.adjustViewportZoneY()}adjustViewportZoneX(){this.left=this.searchHeaderIndex(`COL`,this.offsetX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex(`COL`,Math.max(this.viewportWidth+this.snapCorrection.x-.1),this.left)),this.viewportWidth&&(this.left===-1&&(this.left=this.boundaries.left),this.right===-1&&(this.right=this.boundaries.right))}adjustViewportZoneY(){this.top=this.searchHeaderIndex(`ROW`,this.offsetY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex(`ROW`,Math.max(this.viewportHeight+this.snapCorrection.y-.1,0),this.top)),this.viewportHeight&&(this.top===-1&&(this.top=this.boundaries.top),this.bottom===-1&&(this.bottom=this.boundaries.bottom))}get snapCorrection(){return{x:Math.abs(this.offsetX-this.getters.getColRowOffset(`COL`,this.boundaries.left,Math.max(0,this.left),this.sheetId)),y:Math.abs(this.offsetY-this.getters.getColRowOffset(`ROW`,this.boundaries.top,Math.max(0,this.top),this.sheetId))}}},Kg=class{getters;viewports={};gridOffsetX=0;gridOffsetY=0;paneDivision;sheetViewWidth;sheetViewHeight;getZoomLevel;getFooterSize;zoneToDisplay;constructor(e){this.getters=e.getters,this.paneDivision=e.paneDivision,this.sheetViewWidth=e.sheetViewWidth,this.sheetViewHeight=e.sheetViewHeight,this.getZoomLevel=e.getZoomLevel,this.getFooterSize=e.getFooterSize,this.zoneToDisplay=e.zoneToDisplay}changeViewportArgs(e){for(let t in e)this[t]=e[t];for(let e of this.getters.getSheetIds())this.resetViewports(e)}getColIndex(e,t){return Math.max(...this.getPositionedViewports(e).map(({viewport:e,viewportX:n})=>t<n||t>n+e.viewportWidth?-1:e.getColIndex(t-n)))}getRowIndex(e,t){return Math.max(...this.getPositionedViewports(e).map(({viewport:e,viewportY:n})=>t<n||t>n+e.viewportHeight?-1:e.getRowIndex(t-n)))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getGridOffset(){return{x:this.gridOffsetX,y:this.gridOffsetY}}getSheetScrollInfo(e){let t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getSheetViewVisibleCols(e){let t=this.getSubViewports(e).map(e=>e);return[...new Set(t.map(e=>C(e.left,e.right+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`COL`,t))}getSheetViewVisibleRows(e){let t=this.getSubViewports(e).map(e=>e);return[...new Set(t.map(e=>C(e.top,e.bottom+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`ROW`,t))}getVisibleCellPositions(e){let t=this.getSheetViewVisibleCols(e),n=this.getSheetViewVisibleRows(e),r=[];for(let i of t)for(let t of n){let n={sheetId:e,col:i,row:t},a=this.getters.getMainCellPosition(n);a.row!==t||a.col!==i||r.push(n)}return r}getMainViewportRect(e){let{width:t,height:n}=this.getMainInternalViewport(e).getMaxSize(),{paneWidth:r,paneHeight:i}=this.getPanesDimensions(e);return{x:r,y:i,width:t,height:n}}getMaximumSheetOffset(e){let{width:t,height:n}=this.getMainViewportRect(e),r=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-r.viewportWidth),maxOffsetY:Math.max(0,n-r.viewportHeight)}}getColRowOffsetInViewport(e,t,n,r){if(r<n)return-this.getColRowOffsetInViewport(e,t,r,n);let i=t===`COL`?this.getSheetViewVisibleCols(e):this.getSheetViewVisibleRows(e),a=i.findIndex(e=>n>=e),o=i.findIndex(e=>r<=e);o=o===-1?i.length:o;let s=i.slice(a,o),c=0;for(let n of s)c+=this.getters.getHeaderSize(e,t,n);return c*this.getZoomLevel()}isVisibleInViewport({sheetId:e,col:t,row:n}){return this.getSubViewports(e).some(e=>e.isVisible(t,n))}isZoneVisibleInViewport(e,t){return this.getSubViewports(e).some(e=>e.isZoneVisible(t))}getEdgeScrollCol(e,t,n,r){let i=!1,a=0,o=0,{xSplit:s}=this.getPaneDivisions(e),{width:c}=this.getSheetViewDimension(),{x:l}=this.getMainViewportCoordinates(e),u=this.getSheetScrollInfo(e).scrollX;return t>c?(i=!0,o=Wg(t-c),a=1):t<l&&r>=l&&u>0?(i=!0,o=Wg(l-t),a=-1):s&&n<l&&t>l&&(i=!0,o=Wg(t),a=`reset`),{canEdgeScroll:i,direction:a,delay:o}}getEdgeScrollRow(e,t,n,r){let i=!1,a=0,o=0,{ySplit:s}=this.getPaneDivisions(e),{height:c}=this.getSheetViewDimension(),{y:l}=this.getMainViewportCoordinates(e),u=this.getSheetScrollInfo(e).scrollY;return t>c?(i=!0,o=Wg(t-c),a=1):t<l&&r>=l&&u>0?(i=!0,o=Wg(l-t),a=-1):s&&n<l&&t>l&&(i=!0,o=Wg(t),a=`reset`),{canEdgeScroll:i,direction:a,delay:o}}getVisibleRect(e,t){let n=this.getVisibleRectWithoutHeaders(e,t);return{...n,x:n.x+this.gridOffsetX,y:n.y+this.gridOffsetY}}getVisibleRectWithZoom(e,t){let n=this.getZoomLevel(),r=this.getVisibleRectWithoutHeaders(e,t);return r.width*=n,r.height*=n,r.x=r.x*n+this.gridOffsetX*n,r.y=r.y*n+this.gridOffsetY*n,r}getVisibleRectWithoutHeaders(e,t){return this.mapViewportsToRect(e,e=>e.getVisibleRect(t))}getRect(e,t){let n=this.mapViewportsToRect(e,e=>e.getFullRect(t));return{...n,x:n.x+this.gridOffsetX,y:n.y+this.gridOffsetY}}getRectWithoutHeaders(e,t){return this.mapViewportsToRect(e,e=>e.getFullRect(t))}getMainViewportCoordinates(e){let{paneWidth:t,paneHeight:n}=this.getPanesDimensions(e);return{x:t,y:n}}getColDimensionsInViewport(e,t){let{top:n}=this.getMainInternalViewport(e),r={left:t,right:t,top:n,bottom:n},{x:i,width:a}=this.getVisibleRect(e,r),o=i-this.gridOffsetX;return{start:o,size:a,end:o+a}}getRowDimensionsInViewport(e,t){let{left:n}=this.getMainInternalViewport(e),r={left:0,right:n,top:t,bottom:t},{y:i,height:a}=this.getVisibleRect(e,r),o=i-this.gridOffsetY;return{start:o,size:a,end:o+a}}getAllSheetViewportsZonesAndRect(e){return this.getPositionedViewports(e).map(({viewport:e,viewportX:t,viewportY:n})=>({zone:e,rect:{x:t+this.gridOffsetX,y:n+this.gridOffsetY,...e.getMaxSize()}}))}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getPanesDimensions(e){let t=this.getViewportZones(e),n=0;if(t.bottomLeft){let r=this.getters.getColDimensions(e,t.bottomLeft.left).start;n=this.getters.getColDimensions(e,t.bottomLeft.right).end-r}let r=0;if(t.topRight){let n=this.getters.getRowDimensions(e,t.topRight.top).start;r=this.getters.getRowDimensions(e,t.topRight.bottom).end-n}return{paneWidth:n,paneHeight:r}}getPositionedViewports(e){this.ensureMainViewportExist(e);let t=this.viewports[e],{paneWidth:n,paneHeight:r}=this.getPanesDimensions(e),i=[];return t.topLeft&&i.push({viewport:t.topLeft,viewportX:0,viewportY:0}),t.topRight&&i.push({viewport:t.topRight,viewportX:n,viewportY:0}),t.bottomLeft&&i.push({viewport:t.bottomLeft,viewportX:0,viewportY:r}),i.push({viewport:t.bottomRight,viewportX:n,viewportY:r}),i}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(w)}checkPositiveDimension(e){return!(e.width<0||e.height<0)}checkValuesAreDifferent(e){let{height:t,width:n}=this.getSheetViewDimension();return!(e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===n&&e.height===t)}checkScrollingDirection(e,{offsetX:t,offsetY:n}){let r=this.getMainInternalViewport(e);return!(!r.canScrollHorizontally&&t>0||!r.canScrollVertically&&n>0)}checkIfViewportsWillChange(e,{offsetX:t,offsetY:n}){let{maxOffsetX:r,maxOffsetY:i}=this.getMaximumSheetOffset(e);return!!this.getSubViewports(e).some(e=>e.willNewOffsetScrollViewport(S(t,0,r),S(n,0,i)))}getMainViewport(e){let t=this.getMainInternalViewport(e);return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}getMainInternalViewport(e){return this.ensureMainViewportExist(e),this.viewports[e].bottomRight}cleanViewports(){let e={};for(let t of this.getters.getSheetIds())e[t]=this.viewports[t];this.viewports=e}resizeSheetView(e){this.sheetViewHeight=e.height,this.sheetViewWidth=e.width,this.gridOffsetX=e.gridOffsetX||0,this.gridOffsetY=e.gridOffsetY||0,this.recomputeViewports()}recomputeViewports(){for(let e of this.getters.getSheetIds())this.resetViewports(e)}setSheetViewOffset(e,t,n){let{maxOffsetX:r,maxOffsetY:i}=this.getMaximumSheetOffset(e);this.getSubViewports(e).forEach(e=>e.setViewportOffset(S(t,0,r),S(n,0,i)))}getViewportOffset(e){return{x:this.viewports[e]?.bottomRight.offsetX||0,y:this.viewports[e]?.bottomRight.offsetY||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;let{paneWidth:t,paneHeight:n}=this.getPanesDimensions(e),r=Math.min(t,this.sheetViewWidth),i=Math.min(n,this.sheetViewHeight),a=Math.max(this.sheetViewWidth-t,0),o=Math.max(this.sheetViewHeight-n,0),{xRatio:s,yRatio:c}=this.getFrozenSheetViewRatio(e),l=s<1,u=c<1,d=this.getViewportOffset(e),f={},p=this.getViewportZones(e),m=p.topLeft;m&&(f.topLeft=new Gg({getters:this.getters,sheetId:e,boundaries:m,sizeInGrid:{width:r,height:i},canScrollHorizontally:!1,canScrollVertically:!1,offsets:{x:0,y:0},getFooterSize:()=>0}));let h=p.topRight;h&&(f.topRight=new Gg({getters:this.getters,sheetId:e,boundaries:h,sizeInGrid:{width:a,height:i},canScrollHorizontally:l,canScrollVertically:!1,offsets:{x:l?d.x:0,y:0},getFooterSize:()=>0}));let g=p.bottomLeft;g&&(f.bottomLeft=new Gg({getters:this.getters,sheetId:e,boundaries:g,sizeInGrid:{width:r,height:o},canScrollHorizontally:!1,canScrollVertically:u,offsets:{x:0,y:u?d.y:0},getFooterSize:this.getFooterSize}));let _=p.bottomRight;f.bottomRight=new Gg({getters:this.getters,sheetId:e,boundaries:_,sizeInGrid:{width:a,height:o},canScrollHorizontally:l,canScrollVertically:u,offsets:{x:l?d.x:0,y:u?d.y:0},getFooterSize:this.getFooterSize}),this.viewports[e]=f}reorganizeViewportZones(e,t){let n=Object.values(t).filter(e=>e!==void 0);if(n.length===1)return{bottomRight:n[0]};if(n.length===4)return t;if(n.length===2){if(t.bottomRight&&(t.topRight||t.bottomLeft))return t;let{topLeft:e,topRight:n,bottomLeft:r}=t;if(e&&n)return{bottomLeft:e,bottomRight:n};if(e&&r)return{topRight:e,bottomRight:r}}throw Error(`ViewportCollection: Malformed viewports for ${e}`)}getViewportZones(e){let{xSplit:t,ySplit:n}=this.getPaneDivisions(e),r=this.getters.getNumberCols(e),i=this.getters.getNumberRows(e),a=this.zoneToDisplay?pr(this.zoneToDisplay,this.getters.getSheetZone(e)):void 0,o={};if(t&&n){let e={left:0,right:t-1,top:0,bottom:n-1};o.topLeft=a?pr(e,a):e}if(n){let e={left:t,right:r-1,top:0,bottom:n-1};o.topRight=a?pr(e,a):e}if(t){let e={left:0,right:t-1,top:n,bottom:i-1};o.bottomLeft=a?pr(e,a):e}let s={left:t,right:r-1,top:n,bottom:i-1};return o.bottomRight=a?pr(s,a):s,this.reorganizeViewportZones(e,o)}refreshViewport(e,t){this.getSubViewports(e).forEach(e=>{e.adjustViewportZone(),e.repositionViewport(t)})}getColIndexLeftOfMainViewport(e,t){if(t>=0)return-1;let n=this.getMainViewport(e).left,r=-this.getSheetScrollInfo(e).scrollX-this.getters.getColRowOffset(`COL`,n,0,e);for(;t<r;n--)r-=this.getters.getColSize(e,n-1);return Math.max(n,0)}getRowIndexTopOfMainViewport(e,t){if(t>=0)return-1;let n=this.getMainViewport(e).top,r=-this.getSheetScrollInfo(e).scrollY-this.getters.getColRowOffset(`ROW`,n,0,e);for(;t<r;n--)r-=this.getters.getRowSize(e,n-1);return Math.max(n,0)}getVisibleFigures(e){let t=[],n=this.getters.getFigures(e),{scrollX:r,scrollY:i}=this.getSheetScrollInfo(e),{x:a,y:o}=this.getMainViewportCoordinates(e),{width:s,height:c}=this.getSheetViewDimensionWithHeaders();for(let l of n){let n=this.getFigureUI(e,l),{x:u,y:d}=n;u>=a&&(u+l.width<r+a||u>s+r+a)||d>=o&&(d+l.height<i+o||d>c+i+o)||t.push(n)}return t}getFigureUI(e,t){let n=t.offset.x+this.getters.getColDimensions(e,t.col).start,r=t.offset.y+this.getters.getRowDimensions(e,t.row).start;return{...t,x:n,y:r}}getPositionAnchorOffset(e,t){let{scrollX:n,scrollY:r}=this.getSheetScrollInfo(e),i=t.x-n,a=t.y-r,o=i>=0?this.getColIndex(e,i):this.getColIndexLeftOfMainViewport(e,i);o<0&&(o=this.getMainInternalViewport(e).searchHeaderIndex(`COL`,i));let s=a>=0?this.getRowIndex(e,a):this.getRowIndexTopOfMainViewport(e,a);s<0&&(s=this.getMainInternalViewport(e).searchHeaderIndex(`ROW`,a));let{x:c,y:l}=this.getRect(e,D({col:o,row:s}));return{col:o,row:s,offset:{x:Math.max(i-c+this.gridOffsetX,0),y:Math.max(a-l+this.gridOffsetY,0)}}}isPixelPositionVisible(e,t){let{scrollX:n,scrollY:r}=this.getSheetScrollInfo(e),{x:i,y:a}=this.getMainViewportCoordinates(e),{width:o,height:s}=this.getSheetViewDimension();return!(t.x>=i&&(t.x<i+n||t.x>o+n+i)||t.y>=a&&(t.y<a+r||t.y>s+r+a))}getFrozenSheetViewRatio(e){let{paneWidth:t,paneHeight:n}=this.getPanesDimensions(e),r=this.sheetViewWidth+this.gridOffsetX,i=this.sheetViewHeight+this.gridOffsetY;return{xRatio:t/r,yRatio:n/i}}mapViewportsToRect(e,t){let n=1/0,r=1/0,i=0,a=0,o=!1;for(let s of this.getPositionedViewports(e)){let e=t(s.viewport);e&&(e.x+=s.viewportX,e.y+=s.viewportY,o=!0,n=Math.min(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x+e.width),a=Math.max(a,e.y+e.height))}return o?{x:n,y:r,width:i-n,height:a-r}:{x:0,y:0,width:0,height:0}}getGridOffsetX(){return this.gridOffsetX}getGridOffsetY(){return this.gridOffsetY}getPaneDivisions(e){return this.paneDivision[e]||{xSplit:0,ySplit:0}}setPaneDivision(e,t){this.paneDivision[e]=t}},W=class extends ei{mutators=[`setViewportOffset`,`resizeSheetView`,`shiftViewportDown`,`shiftViewportUp`,`scrollToCell`,`setDisplayedSheetId`,`setViewportArgs`,`rebuildViewports`];storeGetters=[`getCartesianCoordinates`];zoomStore=this.get(Rg);getHeaderDimensionsCallback=this.getters.getHeaderDimensions;getFooterSizeCallback=this.getFooterSize.bind(this);getZoomLevelCallback=()=>this.zoomStore.zoomLevel;zoneToDisplay=void 0;viewports=new Kg({getters:this.buildViewportGetters(this.getHeaderDimensionsCallback),paneDivision:this.getPaneDivisions(),sheetViewHeight:ft(),sheetViewWidth:ft(),getZoomLevel:this.getZoomLevelCallback,getFooterSize:this.getFooterSizeCallback});sheetsWithDirtyViewports=new Set;displayedSheetId=this.model.getters.getActiveSheetId();constructor(e){super(e),this.viewports.resetViewports(this.displayedSheetId)}handle(e){if(Nd.has(e.type))for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);switch(e.type){case`UNDO`:case`REDO`:this.viewports.cleanViewports();for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e),this.syncPaneDivision(e);break;case`UNFREEZE_ROWS`:case`UNFREEZE_COLUMNS`:case`FREEZE_COLUMNS`:case`FREEZE_ROWS`:case`UNFREEZE_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:case`ADD_COLUMNS_ROWS`:this.sheetsWithDirtyViewports.add(e.sheetId),this.syncPaneDivision(e.sheetId);break;case`DUPLICATE_SHEET`:this.sheetsWithDirtyViewports.add(e.sheetIdTo),this.syncPaneDivision(e.sheetIdTo);break;case`REMOVE_TABLE`:case`UPDATE_TABLE`:case`UPDATE_FILTER`:case`RESIZE_COLUMNS_ROWS`:case`HIDE_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`UNGROUP_HEADERS`:case`GROUP_HEADERS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_ALL_HEADER_GROUPS`:case`FOLD_ALL_HEADER_GROUPS`:this.sheetsWithDirtyViewports.add(e.sheetId);break;case`UPDATE_CELL`:case`SET_FORMATTING`:for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);break;case`DELETE_SHEET`:this.viewports.cleanViewports(),this.sheetsWithDirtyViewports.delete(e.sheetId);break}}finalize(){for(let e of this.sheetsWithDirtyViewports)this.viewports.resetViewports(e);this.sheetsWithDirtyViewports=new Set,this.setViewports()}setViewports(){let e=this.getters.getSheetIds();for(let t of e)this.viewports.viewports[t]?.bottomRight||this.viewports.resetViewports(t)}syncPaneDivision(e){this.viewports.setPaneDivision(e,this.getters.getPaneDivisions(e))}setDisplayedSheetId(e){this.displayedSheetId=e,this.viewports.resetViewports(e)}setViewportOffset(e){let t=this.displayedSheetId;if(!this.viewports.checkScrollingDirection(t,e)||!this.viewports.checkIfViewportsWillChange(t,e))return`noStateChange`;this.viewports.setSheetViewOffset(t,e.offsetX,e.offsetY)}resizeSheetView(e){if(!this.viewports.checkValuesAreDifferent(e)||!this.viewports.checkPositiveDimension(e))return`noStateChange`;this.viewports.resizeSheetView(e)}shiftViewportDown(){let e=this.displayedSheetId,{top:t,viewportHeight:n,boundaryTopY:r}=this.viewports.getMainInternalViewport(e),i=this.getters.getRowDimensions(e,t);this.shiftVertically(i.start+n-r)}shiftViewportUp(){let e=this.displayedSheetId,{top:t,viewportHeight:n,boundaryTopY:r}=this.viewports.getMainInternalViewport(e),i=this.getters.getRowDimensions(e,t);this.shiftVertically(i.end-r-n)}scrollToCell(e,t,n){this.sheetsWithDirtyViewports.has(e)||this.viewports.refreshViewport(e,{col:t,row:n})}get sheetViewDimensionWithHeaders(){return this.viewports.getSheetViewDimensionWithHeaders()}get sheetViewDimension(){return this.viewports.getSheetViewDimension()}get gridOffset(){return this.viewports.getGridOffset()}getCartesianCoordinates(e,t){return[this.viewports.getColIndex(this.displayedSheetId,e),this.viewports.getRowIndex(this.displayedSheetId,t)]}get activeMainViewport(){return this.viewports.getMainViewport(this.displayedSheetId)}get activeSheetScrollInfo(){return this.viewports.getSheetScrollInfo(this.displayedSheetId)}get visibleCols(){return this.viewports.getSheetViewVisibleCols(this.displayedSheetId)}get visibleRows(){return this.viewports.getSheetViewVisibleRows(this.displayedSheetId)}get visibleCellPositions(){return this.viewports.getVisibleCellPositions(this.displayedSheetId)}get mainViewportRect(){return this.viewports.getMainViewportRect(this.displayedSheetId)}get maximumSheetOffset(){return this.viewports.getMaximumSheetOffset(this.displayedSheetId)}get mainViewportCoordinates(){return this.viewports.getMainViewportCoordinates(this.displayedSheetId)}get visibleFigures(){return this.viewports.getVisibleFigures(this.displayedSheetId)}shiftVertically(e){let t=this.displayedSheetId,{top:n}=this.viewports.getMainInternalViewport(t),{scrollX:r}=this.activeSheetScrollInfo;this.viewports.setSheetViewOffset(t,r,e);let{anchor:i}=this.getters.getSelection();if(i.cell.row>=this.getters.getPaneDivisions(t).ySplit){let e=this.viewports.getMainInternalViewport(t).top-n;this.model.selection.selectCell(i.cell.col,i.cell.row+e)}}getPaneDivisions(){let e={};for(let t of this.getters.getSheetIds())e[t]=this.getters.getPaneDivisions(t);return e}getFooterSize(){return this.getters.isReadonly()?0:46}setViewportArgs(e){let t=!1;e.getHeaderDimensions&&(t=!0,this.getHeaderDimensionsCallback=e.getHeaderDimensions),e.getFooterSize&&(t=!0,this.getFooterSizeCallback=e.getFooterSize),e.zoneToDisplay&&!T(e.zoneToDisplay,this.zoneToDisplay)&&(t=!0,this.zoneToDisplay=e.zoneToDisplay),t&&this.rebuildViewports()}rebuildViewports(){this.viewports.changeViewportArgs({getters:this.buildViewportGetters(this.getHeaderDimensionsCallback),paneDivision:this.getPaneDivisions(),sheetViewHeight:this.viewports.getSheetViewDimension().height,sheetViewWidth:this.viewports.getSheetViewDimension().width,getZoomLevel:this.getZoomLevelCallback,getFooterSize:this.getFooterSizeCallback,zoneToDisplay:this.zoneToDisplay})}buildViewportGetters(e){return{findLastVisibleColRowIndex:this.getters.findLastVisibleColRowIndex,isReadonly:this.getters.isReadonly,getMainCellPosition:this.getters.getMainCellPosition,getNextVisibleCellPosition:this.getters.getNextVisibleCellPosition,isColHidden:this.getters.isColHidden,isRowHidden:this.getters.isRowHidden,isHeaderHidden:this.getters.isHeaderHidden,getNumberHeaders:this.getters.getNumberHeaders,getSheetIds:this.getters.getSheetIds,tryGetSheet:this.getters.tryGetSheet,getNumberCols:this.getters.getNumberCols,getNumberRows:this.getters.getNumberRows,getSheetZone:this.getters.getSheetZone,getFigures:this.getters.getFigures,getColDimensions:(t,n)=>e(t,`COL`,n),getRowDimensions:(t,n)=>e(t,`ROW`,n),getHeaderSize:(t,n,r)=>n===`COL`?e(t,`COL`,r).size:e(t,`ROW`,r).size,getColSize:(t,n)=>e(t,`COL`,n).size,getRowSize:(t,n)=>e(t,`ROW`,n).size,getColRowOffset:(t,n,r,i)=>e(i,t,r).start-e(i,t,n).start}}};function qg(e,t,n){let r=e.model.getters.getFigure(t,n);if(!r)throw Error(`Could not find figure with id ${n} in sheet ${t}`);let i=e.model.getters.getFigureUI(t,r);return e.getStore(W).viewports.getPositionAnchorOffset(t,{x:i.x+50,y:i.y+50})}function Jg(e,t){if(t.type===`carouselDataView`)return`o-spreadsheet-Icon.DATA`;let n=e.getChartDefinition(t.chartId);return(Ug.getAll().find(e=>e.matcher?.(n))||Ug.get(n.type)).preview}function Yg(e,t){if(t.title)return e.dynamicTranslate(t.title);if(t.type===`carouselDataView`)return N(`Data`);let n=e.getChartDefinition(t.chartId);return(Ug.getAll().find(e=>e.matcher?.(n))||Ug.get(n.type)).displayName}function Xg(e,t,n){let r=yt,i={...vt,...t.title},a=e.x+r.paddingX,o=Math.max(0,e.width-2*r.paddingX),s=i.text?i.fontSize*r.headerLineHeight:0,c={x:a,y:e.y+r.paddingY+r.headerPaddingTop,width:o,height:Math.max(r.minHeaderHeight,s)},l=c.y+c.height,u=i.text?{x:a,y:l+r.paddingY,width:o,height:r.separatorWidth}:void 0,d=n?.type===`carouselDataView`?r.paddingY:0,f=u||c,p=f.y+f.height+d,m=e.y+e.height-2*r.paddingY;return{headerRect:c,separatorRect:u,contentRect:{x:a,y:p,width:o,height:Math.max(0,m-p)},headerLineHeight:r.headerLineHeight}}let Zg=`#F8F8F8`;function Qg(e,t,n=1,r,i){let a=r??$g(e),o=typeof globalThis.devicePixelRatio==`number`?globalThis.devicePixelRatio:1;e.width=a.width*o,e.height=a.height*o;let s=e.getContext(`2d`);if(!s)throw Error(`Unable to retrieve 2D context from canvas`);s.scale(o*n,o*n);let c=a_({width:a.width/n,height:a.height/n,x:0,y:0},t,s,i);t_(s,c),e_(s,c),r_(s,c),n_(s,c),i_(s,c)}function $g(e){if(e instanceof HTMLCanvasElement){let t=e.getBoundingClientRect();return{width:t.width,height:t.height}}return{width:e.width,height:e.height}}function e_(e,t){e.save();let n=t.gauge,r=n.rect.x+n.rect.width/2,i=n.rect.y+n.rect.height,a=n.rect.height-n.arcWidth/2;if(a<0)return;let o=n.percentage===1?0:Math.PI*(1+n.percentage);e.strokeStyle=Zg,e.beginPath(),e.lineWidth=n.arcWidth,e.arc(r,i,a,o,0),e.stroke(),e.strokeStyle=n.color,e.beginPath(),e.arc(r,i,a,Math.PI,o),e.stroke(),e.restore()}function t_(e,t){e.save(),e.fillStyle=t.backgroundColor,e.fillRect(0,0,t.width,t.height),e.restore()}function n_(e,t){for(let n of[t.minLabel,t.maxLabel,t.gaugeValue])e.save(),e.textAlign=`center`,e.fillStyle=n.color,e.font=`${n.fontSize}px ${$e}`,e.fillText(n.label,n.textPosition.x,n.textPosition.y),e.restore()}function r_(e,t){let{x:n,y:r,width:i,height:a}=t.gauge.rect;for(let o of t.inflectionValues){e.save(),e.translate(n+i/2-.5,r+a-.5),e.rotate(Math.PI/2-o.rotation),e.lineWidth=2,e.strokeStyle=Tm(t.backgroundColor)+`aa`,e.beginPath(),e.moveTo(0,-(a-t.gauge.arcWidth)),e.lineTo(0,-a-3),e.stroke(),e.textAlign=`center`,e.font=`${o.fontSize}px ${$e}`,e.fillStyle=o.color;let s=-a-6-o.offset;e.fillText(o.label,0,s),e.restore()}}function i_(e,t){e.save();let n=t.title;e.font=Tp(n.fontSize,n.bold,n.italic),e.textBaseline=`middle`,e.fillStyle=n.color,e.fillText(n.label,n.textPosition.x,n.textPosition.y),e.restore()}function a_(e,t,n,r){let i=r?.labelFontSize??12,a=t.maxValue,o=t.minValue,s=p_(t,`animated`),c=o_(e,t.title.text),l=c.width/6,u=s?(s-o.value)/(a.value-o.value):0,d={x:e.width/2,y:c.y+c.height-c.height/12},f=80;c.height<300&&(f*=c.height/300);let p=c.width/2,m=t.gaugeValue?.label||`-`;Dp(n,m,{fontSize:f},`px`)>p&&(f=Lp(p,f,e=>Dp(n,m,{fontSize:e},`px`)));let h={x:c.x+l/2,y:c.y+c.height+i},g={x:c.x+c.width-l/2,y:c.y+c.height+i},_=Tm(t.background),v=s_(t,c,_,n,i),ee=0,y=0,b=0;switch(t.title.text&&({width:y,height:b}=Ap(n,t.title.text,{fontSize:16,...t.title},`px`)),t.title.align){case`right`:ee=e.width-y-20;break;case`center`:ee=(e.width-y)/2;break;default:ee=20;break}return{width:e.width,height:e.height,title:{label:t.title.text??``,fontSize:t.title.fontSize??16,textPosition:{x:ee,y:15+b/2},color:t.title.color??_,bold:t.title.bold,italic:t.title.italic},backgroundColor:t.background,gauge:{rect:c,arcWidth:l,percentage:S(u,0,1),color:c_(t)},inflectionValues:v,gaugeValue:{label:m,textPosition:d,fontSize:f,color:_},minLabel:{label:t.minValue.label,textPosition:h,fontSize:i,color:_},maxLabel:{label:t.maxValue.label,textPosition:g,fontSize:i,color:_}}}function o_(e,t){let n=t?25:0,r=e.height-20-n-10,i=e.width-60,a,o;return i>2*r?(a=2*r,o=r):(a=i,o=i/2),{x:30+(i-a)/2,y:n+10+(r-o)/2,width:a,height:o}}function s_(e,t,n,r,i=12){let a=e.maxValue,o=e.minValue,s={x:t.x+t.width/2,y:t.y+t.height},c={fontSize:i},l=[],u=[];for(let d of e.inflectionValues){let e=(d.value-o.value)/(a.value-o.value),f=Dp(r,d.label,c,`px`),p=Math.PI-Math.PI*e,m=f_(p,t.height+6,s.x,s.y,f+2,i),h=u.some(e=>d_(e,m))?i:0;u.push(m),l.push({rotation:p,label:d.label,fontSize:i,color:n,offset:h})}return l}function c_(e){let t=p_(e,`final`);if(t===void 0)return Zg;for(let n=0;n<e.inflectionValues.length;n++){let r=e.inflectionValues[n];if(r.operator===`<`&&t<r.value||r.operator===`<=`&&t<=r.value)return e.colors[n]}return e.colors.at(-1)}function l_(e){return[{start:e.topLeft,end:e.topRight},{start:e.topRight,end:e.bottomRight},{start:e.bottomRight,end:e.bottomLeft},{start:e.bottomLeft,end:e.topLeft}]}function u_(e,t){let n=e.start,r=e.end,i=t.start,a=t.end;function o(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}return o(n,i,a)!==o(r,i,a)&&o(n,r,i)!==o(n,r,a)}function d_(e,t){let n=l_(e),r=l_(t);for(let e of n)for(let t of r)if(u_(e,t))return!0;return!1}function f_(e,t,n,r,i,a){let o=Math.cos(e),s=Math.sin(e),c=o*t,l=s*t,u=i/2*s,d=i/2*o,f={x:c+u+n,y:r-(l-d)},p={x:c-u+n,y:r-(l+d)},m=o*(t+a),h=s*(t+a),g={x:m-u+n,y:r-(h+d)};return{bottomLeft:p,bottomRight:f,topRight:{x:m+u+n,y:r-(h-d)},topLeft:g}}function p_(e,t){return t===`animated`&&e.animationValue!==void 0?e.animationValue:e.gaugeValue?.value}let m_={responsive:!0,maintainAspectRatio:!1,elements:{line:{fill:!1},point:{hitRadius:15}},animation:!1,events:[`mousemove`,`mouseout`,`click`,`touchstart`,`touchmove`,`mouseup`]};function h_(e,t=20){let n=e.data;return n?{...e,data:{...n,labels:__(n.labels,t),datasets:n.datasets?.map(e=>g_(e,t))}}:e}function g_(e,t){let n=e.data;if(!Array.isArray(n)||n.length<=t)return e;let r=n.length,i=v_(r,t),a={...e};for(let e of Object.keys(a)){let t=a[e];Array.isArray(t)&&t.length===r&&(a[e]=i.map(e=>t[e]))}return a}function __(e,t){return!Array.isArray(e)||e.length<=t?e:v_(e.length,t).map(t=>e[t])}function v_(e,t){let n=e/t;return Array.from({length:t},(t,r)=>Math.min(e-1,Math.floor(r*n)))}async function y_(e,t,n,r=`light`){try{let i=S_(t.width,t.height),a=T_(i,e,t,n),o=await w_(r===`dark`?b_(i):i);return a(),o}catch(e){console.log(`Error exporting chart to image URL: `+e.message)}}function b_(e){let t=S_(e.width,e.height),n=t.getContext(`2d`);return!n||!(`filter`in n)?e:(n.filter=Zf,n.drawImage(e,0,0),t)}async function x_(e,t,n,r=`light`){try{let i=S_(t.width,t.height),a=T_(i,e,t,n),o=await C_(r===`dark`?b_(i):i);return a(),o}catch(e){console.log(`Error exporting chart to image file: `+e.message)}return null}function S_(e,t){if(!globalThis.OffscreenCanvas)throw Error(`converting a chart to an image using OffscreenCanvas is not supported in this environment`);return new OffscreenCanvas(e,t)}async function C_(e){return`convertToBlob`in e?e.convertToBlob({type:`image/png`}):new Promise(t=>e.toBlob(t,`image/png`))}async function w_(e){let t=await C_(e);if(t)return new Promise(e=>{let n=new FileReader;n.addEventListener(`load`,()=>{e(n.result)}),n.readAsDataURL(t)})}function T_(e,t,n,r,i=1){if(`chartJsConfig`in t){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);let n=ii();n||ai();let r=x(t.chartJsConfig);if(!globalThis.Chart.registry.controllers.get(r.type))throw console.log(`Chart of type "${r.type}" is not registered in Chart.js library.`),n||oi(),Error(`Chart of type "${r.type}" is not registered in Chart.js library.`);let i=new globalThis.Chart(e,r);return()=>{i.destroy(),n||oi()}}else r===`scorecard`?Dg(Ag(n,t),e,i):r===`gauge`&&Qg(e,t,i,n);return()=>{}}let E_=1e3,D_=1e3;function O_(e,t){let n=e.getStore(W),{scrollX:r,scrollY:i}=n.activeSheetScrollInfo,a=n.sheetViewDimension,o=r+Math.max(0,(a.width-t.width)/2),s=i+Math.max(0,(a.height-t.height)/2),c=e.model.getters.getActiveSheetId();return n.viewports.getPositionAnchorOffset(c,{x:o,y:s})}function k_(e){let t=x(e);if(t.width>E_){let e=E_/t.width;t.width=E_,t.height*=e}if(t.height>D_){let e=D_/t.height;t.height=D_,t.width*=e}return t}function A_(e,t,n,r){let i=e.getMaxAnchorOffset(t,r.height,r.width),{col:a,row:o}=n,s={...r.offset};for(let n=e.getColSize(t,a);s.x>n;n=e.getColSize(t,a))a+=1,s.x-=n;a>i.col&&(a=i.col,s.x=i.offset.x);for(let n=e.getRowSize(t,o);s.y>n;n=e.getRowSize(t,o))o+=1,s.y-=n;return o>i.row&&(o=i.row,s.y=i.offset.y),{col:a,row:o,offset:s}}async function j_(e){return new Promise((t,n)=>{let r=new Image;r.addEventListener(`load`,()=>{let e=document.createElement(`canvas`);e.width=r.width,e.height=r.height,e.getContext(`2d`)?.drawImage(r,0,0),e.toBlob(t,`image/png`)}),r.addEventListener(`error`,n),r.src=e})}function M_({strikethrough:e,underline:t}){return!e&&!t?`none`:`${e?`line-through`:``} ${t?`underline`:``}`}function N_(e){let t=P_(e);return e&&e.fillColor&&(t.background=e.fillColor),t}function P_(e){let t={};if(!e)return t;if(e.bold&&(t[`font-weight`]=`bold`),e.italic&&(t[`font-style`]=`italic`),e.fontSize&&(t[`font-size`]=`${e.fontSize}px`),e.strikethrough||e.underline){let n=e.strikethrough?`line-through`:``;n=e.underline?n+` underline`:n,t[`text-decoration`]=n}return e.textColor&&(t.color=e.textColor),t}function G(e){let t=``;for(let n in e)e[n]&&(t+=`${n}:${e[n]}; `);return t}function F_(e){let t=window.getComputedStyle(e);return{top:parseInt(t.marginTop,10)||0,bottom:parseInt(t.marginBottom,10)||0,left:parseInt(t.marginLeft,10)||0,right:parseInt(t.marginRight,10)||0}}let I_=function(e){return e.PlainText=`text/plain`,e.Html=`text/html`,e.Image=`image`,e}({}),L_=[`image/avif`,`image/bmp`,`image/gif`,`image/vnd.microsoft.icon`,`image/jpeg`,`image/png`,`image/tiff`,`image/webp`];function R_(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?Dr(t):[t[t.length-1]],s=o.map(e=>Sr(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 z_(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 B_(e,t){if(!t.length||!t[0].length)return e;let n=t[0].length,r=t.length;return e.map(e=>z_(e,n,r)).flat()}function V_(e){let t;e[`text/html`]&&(t=U_(new DOMParser().parseFromString(e[`text/html`],`text/html`)));let n=e[`text/plain`]||``,r;if(!n.trim()){for(let t of L_)if(e[t]){r=e[t];break}}return{text:n,data:t,imageBlob:r}}function H_(e){return e?.match(/<div data-osheet-clipboard-id=(['"])([^'"]+)\1/)?.[2]}function U_(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 G_(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=dr(a,e)}}return{target:s,zone:a,selectedZones:o}}let K_=(e,t,n)=>{let r={col:t[0].left,row:t[0].top};e.getBackToDefault(),e.selectZone({cell:r,zone:dr(...n)},{scrollIntoView:!1})};var K=class{static getCrypto(){if(typeof globalThis<`u`&&globalThis.crypto)return globalThis.crypto}static smallUuid(){let e=this.getCrypto();return e?`10000000-1000`.replace(/[01]/g,t=>{let n=Number(t);return(n^e.getRandomValues(new Uint8Array(1))[0]&15>>n/4).toString(16)}):`xxxxxxxx-xxxx`.replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}static uuidv4(){let e=this.getCrypto();return e?`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,t=>{let n=Number(t);return(n^e.getRandomValues(new Uint8Array(1))[0]&15>>n/4).toString(16)}):`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}};function q_(e){if(!e||typeof e!=`object`||!(!e.thousandsSeparator||typeof e.thousandsSeparator==`string`))return!1;for(let t of[`code`,`name`,`decimalSeparator`,`dateFormat`,`timeFormat`,`formulaArgSeparator`])if(!e[t]||typeof e[t]!=`string`)return!1;if(e.formulaArgSeparator===e.decimalSeparator||e.thousandsSeparator===e.decimalSeparator)return!1;try{V(1,{locale:e,format:`#,##0.00`}),V(1,{locale:e,format:e.dateFormat}),V(1,{locale:e,format:e.timeFormat})}catch{return!1}return!0}function J_(e,t){return Dn(e)?Q_(e,t):tv(e,t)}function Y_(e,t){return Dn(e)?Q_(e,t):nv(e,t)}function X_(e,t){return e.startsWith(`=`)?$_(e,t):iv(e,t)}function Z_(e,t){return Dn(e)?Q_(e,t):tv(e,t)}function Q_(e,t){return ev(e.startsWith(`+`)?`=`+e.slice(1):e,t,B)}function $_(e,t){return ev(e,B,t)}function ev(e,t,n){if(t.formulaArgSeparator===n.formulaArgSeparator&&t.decimalSeparator===n.decimalSeparator)return e;let r=Il(e,t),i=``;for(let e of r)e.type===`NUMBER`?i+=e.value.replace(t.decimalSeparator,n.decimalSeparator):e.type===`ARG_SEPARATOR`?i+=n.formulaArgSeparator:e.type===`ARRAY_ROW_SEPARATOR`?i+=n.formulaArgSeparator===`;`?`\\`:`;`:i+=e.value;return i}function tv(e,t){return t.decimalSeparator===`.`||!mo(e,t)?e:(t.thousandsSeparator&&(e=e.replaceAll(t.thousandsSeparator,``)),e.replace(t.decimalSeparator,`.`))}function nv(e,t){if(Fa(e,t)){let n=I(e,t),r=B.dateFormat;return Number.isInteger(n)||(r+=` `+B.timeFormat),V(n,{locale:B,format:r})}return tv(e,t)}function rv(e,t){if(t.decimalSeparator===`.`||!mo(e,B))return e;let n=xc(B);return e.replace(n,e=>e.replace(`.`,t.decimalSeparator))}function iv(e,t){if(Fa(e,B)){let n=I(e,B),r=t.dateFormat;return Number.isInteger(n)||(r+=` `+t.timeFormat),V(n,{locale:t,format:r})}return rv(e,t)}function av(e){return e.dateFormat+` `+e.timeFormat}var ov=class{xmlString;constructor(e){this.xmlString=e}toString(){return this.xmlString}};let sv=[`areaChart`,`area3DChart`,`lineChart`,`line3DChart`,`stockChart`,`radarChart`,`scatterChart`,`pieChart`,`pie3DChart`,`doughnutChart`,`barChart`,`bar3DChart`,`ofPieChart`,`surfaceChart`,`surface3DChart`,`bubbleChart`,`comboChart`,`radarChart`];var cv=class{static getters=[];history;constructor(e){this.history=Object.assign(Object.create(e),{update:e.addChange.bind(e,this),selectCell:()=>{}})}exportForExcel(e){}allowDispatch(e){return`Success`}beforeHandle(e){}handle(e){}finalize(){}batchValidations(...e){return t=>e.map(e=>e.call(this,t)).flat()}chainValidations(...e){return t=>{for(let n of e){let e=n.call(this,t);Array.isArray(e)||(e=[e]);let r=e.filter(e=>e!==`Success`);if(r.length)return r}return`Success`}}checkValidations(e,...t){return this.batchValidations(...t)(e)}},lv=class extends cv{getters;dispatch;canDispatch;constructor({getters:e,stateObserver:t,range:n,dispatch:r,canDispatch:i,formulasPlugin:a}){super(t),n.addRangeProvider(this.adaptRanges.bind(this)),a.addFormulaProvider(this.getFormulas.bind(this)),this.getters=e,this.dispatch=r,this.canDispatch=i}import(e){}export(e,t){}adaptRanges(e){}getFormulas(){return[]}};let uv=/^[\p{L}\p{N}_.]+$/u;var dv=class extends lv{static getters=[`getNamedRange`,`getNamedRangeFromZone`,`getNamedRanges`];namedRanges=[];adaptRanges({applyChange:e}){let t=[],n=!1;for(let r of this.namedRanges){let i=e(r.range);switch(i.changeType){case`REMOVE`:n=!0;break;case`RESIZE`:case`MOVE`:case`CHANGE`:n=!0,t.push({...r,range:i.range});break;case`NONE`:t.push(r)}}n&&this.history.update(`namedRanges`,t)}allowDispatch(e){switch(e.type){case`CREATE_NAMED_RANGE`:return this.checkValidNewNamedRangeName(e.name);case`UPDATE_NAMED_RANGE`:return this.checkValidations(e,()=>this.checkNamedRangeExists(e.oldRangeName),()=>e.newRangeName===e.oldRangeName?`Success`:this.checkValidNewNamedRangeName(e.newRangeName));case`DELETE_NAMED_RANGE`:return this.checkNamedRangeExists(e.name)}return`Success`}handle(e){switch(e.type){case`CREATE_NAMED_RANGE`:{let t=this.getters.getRangeFromRangeData(e.ranges[0]),n=[...this.namedRanges,{name:e.name,range:t}];this.history.update(`namedRanges`,n);break}case`UPDATE_NAMED_RANGE`:{let t=this.getNamedRangeIndex(e.oldRangeName);if(t!==-1){let n=this.getters.getRangeFromRangeData(e.ranges[0]);this.history.update(`namedRanges`,t,{name:e.newRangeName,range:n})}break}case`DELETE_NAMED_RANGE`:{let t=this.getNamedRangeIndex(e.name);if(t!==-1){let e=[...this.namedRanges];e.splice(t,1),this.history.update(`namedRanges`,e)}break}}}getNamedRange(e){return this.namedRanges[this.getNamedRangeIndex(e)]}getNamedRangeFromZone(e,t){for(let n of this.namedRanges){let r=n.range;if(r.sheetId===e&&T(r.unboundedZone,t))return n}}getNamedRanges(){return this.namedRanges}getNamedRangeIndex(e){return this.namedRanges.findIndex(t=>t&&t.name.toLowerCase()===e.toLowerCase())}import(e){for(let t in e.namedRanges||{})this.namedRanges.push({name:t,range:this.getters.getRangeFromSheetXC(void 0,e.namedRanges[t])})}export(e){e.namedRanges={};for(let t of this.namedRanges){let n=this.getters.getRangeString(t.range);e.namedRanges[t.name]=n}}exportForExcel(e){this.export(e)}checkValidNewNamedRangeName(e){return this.getNamedRange(e)?`NamedRangeNameAlreadyExists`:!uv.test(e)||mo(e,B)||[`TRUE`,`FALSE`].includes(e.toUpperCase())?`NamedRangeInvalidName`:vl.test(e)?`NamedRangeNameLooksLikeCellReference`:`Success`}checkNamedRangeExists(e){return this.getNamedRange(e)?`Success`:`NamedRangeNotFound`}};function fv(e,t){let n={};for(let r of e.namedRanges){if(!r.value.split(`!`)[0]?.replace(/'/g,``)){t.addConversionWarning(`Named range "${r.name}" does not specify a sheet and will be ignored.`);continue}if(!uv.test(r.name)){t.addConversionWarning(`Named range "${r.name}" has an invalid name and will be ignored.`);continue}n[r.name]=r.value}return n}let pv=new WeakMap,mv=new WeakMap;function hv(e,t){pv.has(t)||(pv.set(t,new Map),mv.set(t,0));let n=pv.get(t),r=vv(e);if(n.has(r)){let i=n.get(r);return t[i]=e,i}let i=mv.get(t)+1;return n.set(r,i),mv.set(t,i),t[i]=e,i}function gv(e){let t={};for(let n in e){let r=Wn(e[n].map(D));for(let e of r)t[or(e)]=Number(n)}return t}function*_v(e,t){for(let n in t){let r=tr(n),i=t[n];for(let t=r.top;t<=r.bottom;t++)for(let n=r.left;n<=r.right;n++)yield[{sheetId:e,col:n,row:t},i]}}function vv(e){if(e===null)return`null`;if(e===void 0)return`undefined`;if(typeof e!=`object`)return String(e);if(Array.isArray(e)){let t=e.length,n=`[`;for(let r=0;r<t;r++)r>0&&(n+=`,`),n+=vv(e[r]);return n+`]`}let t=Object.keys(e).sort(),n=`{`;for(let r of t)e[r]!==void 0&&(n+=`"${r}":${vv(e[r])},`);return n+=`}`,n}let yv=[`thin`,`medium`,`thick`,`dashed`,`dotted`],bv=[`general`,`left`,`center`,`right`],xv=[`top`,`center`,`bottom`],Sv=[`Arial`],Cv=[`solid`,`none`],wv=[`expression`,`cellIs`,`colorScale`,`iconSet`,`containsText`,`notContainsText`,`beginsWith`,`endsWithText`,`containsBlanks`,`notContainsBlanks`],Tv={b:`boolean`,d:`date`,e:`error`,inlineStr:`inlineStr`,n:`number`,s:`sharedString`,str:`str`},Ev={dashDot:`thin`,dashDotDot:`thin`,dashed:`dashed`,dotted:`dotted`,double:`thin`,hair:`thin`,medium:`medium`,mediumDashDot:`thin`,mediumDashDotDot:`thin`,mediumDashed:`thin`,none:void 0,slantDashDot:`thin`,thick:`thick`,thin:`thin`},Dv={general:void 0,left:`left`,center:`center`,right:`right`,fill:`left`,justify:`left`,centerContinuous:`center`,distributed:`center`},Ov={top:`top`,center:`middle`,bottom:`bottom`,justify:`middle`,distributed:`middle`},kv={top:`top`,middle:`center`,bottom:`bottom`},Av={beginsWith:`beginsWithText`,endsWith:`endsWithText`,containsText:`containsText`,notContains:`notContainsText`,between:`isBetween`,notBetween:`isNotBetween`,equal:`isEqual`,notEqual:`isNotEqual`,greaterThan:`isGreaterThan`,greaterThanOrEqual:`isGreaterOrEqualTo`,lessThan:`isLessThan`,lessThanOrEqual:`isLessOrEqualTo`},jv={aboveAverage:void 0,expression:`customFormula`,cellIs:void 0,colorScale:void 0,dataBar:void 0,iconSet:void 0,top10:`top10`,uniqueValues:`uniqueValues`,duplicateValues:`duplicateValues`,containsText:`containsText`,notContainsText:`notContainsText`,beginsWith:`beginsWithText`,endsWith:`endsWithText`,containsBlanks:`isEmpty`,notContainsBlanks:`isNotEmpty`,containsErrors:void 0,notContainsErrors:void 0,timePeriod:void 0},Mv={num:`number`,percent:`percentage`,max:`value`,min:`value`,percentile:`percentile`,formula:`formula`},Nv={NoIcons:void 0,"3Arrows":`arrows`,"3ArrowsGray":`arrows`,"3Symbols":`smiley`,"3Symbols2":`smiley`,"3Signs":`dots`,"3Flags":`dots`,"3TrafficLights1":`dots`,"3TrafficLights2":`dots`,"4Arrows":`arrows`,"4ArrowsGray":`arrows`,"4RedToBlack":`dots`,"4Rating":`smiley`,"4TrafficLights":`dots`,"5Arrows":`arrows`,"5ArrowsGray":`arrows`,"5Rating":`smiley`,"5Quarters":`dots`,"3Stars":`smiley`,"3Triangles":`arrows`,"5Boxes":`dots`},Pv={none:`none`,b:`bottom`,t:`top`,l:`left`,r:`right`,tr:`right`},Fv={areaChart:void 0,area3DChart:void 0,lineChart:`line`,line3DChart:void 0,stockChart:void 0,radarChart:`radar`,scatterChart:`scatter`,pieChart:`pie`,pie3DChart:void 0,doughnutChart:`pie`,barChart:`bar`,bar3DChart:void 0,ofPieChart:void 0,surfaceChart:void 0,surface3DChart:void 0,bubbleChart:void 0,comboChart:`combo`},Iv={exp:`exponential`,log:`logarithmic`,poly:`polynomial`,movingAvg:`trailingMovingAverage`},Lv={1:`AVERAGE`,2:`COUNT`,3:`COUNTA`,4:`MAX`,5:`MIN`,6:`PRODUCT`,7:`STDEV`,8:`STDEVP`,9:`SUM`,10:`VAR`,11:`VARP`,101:`AVERAGE`,102:`COUNT`,103:`COUNTA`,104:`MAX`,105:`MIN`,106:`PRODUCT`,107:`STDEV`,108:`STDEVP`,109:`SUM`,110:`VAR`,111:`VARP`},Rv={0:`General`,1:`0`,2:`0.00`,3:`#,#00`,4:`#,##0.00`,9:`0%`,10:`0.00%`,11:void 0,12:void 0,13:void 0,14:`m/d/yyyy`,15:`m/d/yyyy`,16:`m/d/yyyy`,17:`m/d/yyyy`,18:`hh:mm:ss a`,19:`hh:mm:ss a`,20:`hhhh:mm:ss`,21:`hhhh:mm:ss`,22:`m/d/yy h:mm`,37:void 0,38:void 0,39:void 0,40:void 0,45:`hhhh:mm:ss`,46:`hhhh:mm:ss`,47:`hhhh:mm:ss`,48:void 0,49:`@`},zv={0:1,"0.00":2,"#,#00":3,"#,##0.00":4,"0%":9,"0.00%":10,"0.00E+00":11,"# ?/?":12,"# ??/??":13,"mm-dd-yy":14,"d-mm-yy":15,"mm-yy":16,"mmm-yy":17,"h:mm AM/PM":18,"h:mm:ss AM/PM":19,"h:mm":20,"h:mm:ss":21,"m/d/yy h:mm":22,"#,##0 ;(#,##0)":37,"#,##0 ;[Red](#,##0)":38,"#,##0.00;(#,##0.00)":39,"#,##0.00;[Red](#,##0.00)":40,"mm:ss":45,"[h]:mm:ss":46,"mmss.0":47,"##0.0E+0":48,"@":49,"hh:mm:ss a":19},Bv={0:`000000`,1:`FFFFFF`,2:`FF0000`,3:`00FF00`,4:`0000FF`,5:`FFFF00`,6:`FF00FF`,7:`00FFFF`,8:`000000`,9:`FFFFFF`,10:`FF0000`,11:`00FF00`,12:`0000FF`,13:`FFFF00`,14:`FF00FF`,15:`00FFFF`,16:`800000`,17:`008000`,18:`000080`,19:`808000`,20:`800080`,21:`008080`,22:`C0C0C0`,23:`808080`,24:`9999FF`,25:`993366`,26:`FFFFCC`,27:`CCFFFF`,28:`660066`,29:`FF8080`,30:`0066CC`,31:`CCCCFF`,32:`000080`,33:`FF00FF`,34:`FFFF00`,35:`00FFFF`,36:`800080`,37:`800000`,38:`008080`,39:`0000FF`,40:`00CCFF`,41:`CCFFFF`,42:`CCFFCC`,43:`FFFF99`,44:`99CCFF`,45:`FF99CC`,46:`CC99FF`,47:`FFCC99`,48:`3366FF`,49:`33CCCC`,50:`99CC00`,51:`FFCC00`,52:`FF9900`,53:`FF6600`,54:`666699`,55:`969696`,56:`003366`,57:`339966`,58:`003300`,59:`333300`,60:`993300`,61:`993366`,62:`333399`,63:`333333`,64:`000000`,65:`FFFFFF`},Vv={"image/avif":`avif`,"image/bmp":`bmp`,"image/gif":`gif`,"image/vnd.microsoft.icon":`ico`,"image/jpeg":`jpeg`,"image/png":`png`,"image/tiff":`tiff`,"image/webp":`webp`},Hv={avif:`image/avif`,bmp:`image/bmp`,gif:`image/gif`,ico:`image/vnd.microsoft.icon`,jpeg:`image/jpeg`,png:`image/png`,tiff:`image/tiff`,webp:`image/webp`,jpg:`image/jpeg`},Uv={between:`isBetween`,notBetween:`isNotBetween`,equal:`isEqual`,notEqual:`isNotEqual`,greaterThan:`isGreaterThan`,greaterThanOrEqual:`isGreaterOrEqualTo`,lessThan:`isLessThan`,lessThanOrEqual:`isLessOrEqualTo`},Wv={between:`dateIsBetween`,notBetween:`dateIsNotBetween`,equal:`dateIs`,greaterThan:`dateIsAfter`,greaterThanOrEqual:`dateIsOnOrAfter`,lessThan:`dateIsBefore`,lessThanOrEqual:`dateIsOnOrBefore`};function Gv(e){switch(e){case`isNotEmpty`:return`notContainsBlanks`;case`isEmpty`:return`containsBlanks`;case`notContainsText`:return`notContainsBlanks`;case`containsText`:return`containsText`;case`beginsWithText`:return`beginsWith`;case`endsWithText`:return`endsWith`;case`isGreaterThan`:return`greaterThan`;case`isGreaterOrEqualTo`:return`greaterThanOrEqual`;case`isLessThan`:return`lessThan`;case`isLessOrEqualTo`:return`lessThanOrEqual`;case`isBetween`:return`between`;case`isNotBetween`:return`notBetween`;case`isEqual`:return`equal`;case`isNotEqual`:return`notEqual`;case`customFormula`:return``;case`dateIs`:return``;case`dateIsBefore`:return`lessThan`;case`dateIsAfter`:return`greaterThan`;case`dateIsOnOrAfter`:return`greaterThanOrEqual`;case`dateIsOnOrBefore`:return`lessThanOrEqual`;case`top10`:return`top10`;case`uniqueValues`:return`uniqueValues`;case`duplicateValues`:return`duplicateValues`}}function Kv(e){switch(typeof e){case`boolean`:return`b`;case`string`:return`str`;case`number`:return`n`;default:return}}function qv(e){return Math.round(om*e*100)/100}function Jv(e){return Math.round(sm*e*100)/100}function Yv(e){return e&&Math.round(e/om*100)/100}function Xv(e){return e&&Math.round(e/sm*100)/100}function Zv(e,t,n,r,i){let a=n?e.styles[n]:{},o=r?e.formats[r]:void 0,s={font:{size:a?.fontSize||Qe,color:{rgb:a?.textColor?a.textColor:`000000`},family:2,name:`Arial`},fill:a?.fillColor?{fgColor:{rgb:a.fillColor}}:{reservedAttribute:`none`},numFmt:o?{format:o,id:0}:void 0,border:i||0,alignment:{horizontal:a.align==="default"?void 0:a.align,vertical:a.verticalAlign?kv[a.verticalAlign]:void 0,wrapText:a.wrapping===`wrap`||t?.includes(`
17
+ `):[t];for(let t of a){let a=t.includes(` `)?t.split(` `):[t];if(!r){i.push(t);continue}let o=``,s=r;for(let t of a){let a=Fp(e,t,r,n),c=a.pop(),l=Dp(e,c,n);if(a.length)o!==``&&(i.push(o),o=``,s=r),a.forEach(e=>{i.push(e)}),o=c,s=r-l;else{let t=o===``?c:` `+c,a=Dp(e,t,n);a<=s?(o+=t,s-=a):(i.push(o),o=c,s=r-l)}}o!==``&&i.push(o)}return i}function Lp(e,t,n,r=.25){let i=1;if(n(i)>e)return i;if(n(t)<e)return t;let a=(i+t)/2,o=n(a),s=0;for(;Math.abs(o-e)>r&&s<20;)o>=e?t=(i+t)/2:i=(i+t)/2,a=(i+t)/2,o=n(a),s++;return a}function Rp(e){return e?e.toLowerCase().trim():``}let zp=/([0-9\.]*)px/;function Bp(e){return Number(e.match(zp)?.[1])}function Vp(e,t,n){let r=Op(e,t,e.font);if(r<=n)return t;let i=Op(e,`…`,e.font);if(r<=i)return t;let a=t.length;for(;r>=n-i&&a-->0;)t=t.substring(0,a),r=Op(e,t,e.font);return t+`…`}function Hp(e,t,n,r=!1,i=!1,a=Bp(e.font)/10,o=!1){if(o&&(e.save(),e.fillStyle=Yf(e.fillStyle,Ze)),e.fillText(t,n.x,n.y),!r&&!i)return;let s=e.measureText(t),c=s.width,l=s.actualBoundingBoxAscent+s.actualBoundingBoxDescent,u=s.fontBoundingBoxAscent+s.fontBoundingBoxDescent,{x:d,y:f}=n,p=f,m=f;switch(e.textAlign){case`center`:d-=c/2;break;case`right`:d-=c;break}switch(e.textBaseline){case`top`:m+=u-2*a,p+=u/2-a;break;case`middle`:m+=u/2-a;break;case`alphabetic`:m+=2*a,p-=3*a;break;case`bottom`:m=f,p-=l/2-a/2;break}r&&(e.lineWidth=a,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(d,m),e.lineTo(d+c,m),e.stroke()),i&&(e.lineWidth=a,e.strokeStyle=e.fillStyle,e.beginPath(),e.moveTo(d,p),e.lineTo(d+c,p),e.stroke()),o&&e.restore()}function Up(e,t,n,r,i=`pt`){if(Dp(e,n,r,i)<=t)return n;let a=Dp(e,`...`,r,i);if(a>=t)return``;let o=1,s=n.length,c;for(;o<=s;){let l=Math.floor((o+s)/2);c=Dp(e,n.slice(0,l),r,i),c+a>t?s=l-1:o=l+1}let l=n.slice(0,Math.max(0,o-1));return l?l+`...`:``}function Wp(e,t){if(!t.rotation||t.rotation%(Math.PI*2)==0)return e;let{x:n,y:r}=e,i=Math.cos(-t.rotation),a=Math.sin(-t.rotation),o=e.textWidth-8,s=e.textHeight,c=t.align===`center`,l=t.align===`left`==a<0,u=a*s,d=Math.abs(a*o),f=i*s;return t.verticalAlign===`top`?c?(r+=d/2,n-=u/2):l?n-=u:r+=d:!t.verticalAlign||t.verticalAlign===`bottom`?(r+=s-f,c?(r-=d/2,n-=u/2):l&&(n-=u,r-=d)):c?(n-=u/2,r-=s/2,l?r+=u:r-=u):l?(n-=u,r-=d/2):r+=d/2+f/4,{x:i*n-a*r,y:i*r+a*n}}let Gp={id:`chartColorScalePlugin`,afterDatasetsDraw(e,t,n){if(!n.position||n.position===`none`||!n.colorScale.length)return;let r=e.ctx;r.save(),r.textAlign=`center`,r.textBaseline=`middle`,r.miterLimit=1;let i=(e.chartArea.bottom-e.chartArea.top)/2,a=n.position===`left`?20:r.canvas.width-70,o=e.chartArea.top,s=r.createLinearGradient(0,o+i,0,o),c=1/(n.colorScale.length-1);n.colorScale.forEach((e,t)=>{s.addColorStop(t*c,e)}),r.fillStyle=s,r.fillRect(a,o,10,i),r.fillStyle=n.fontColor??`black`,r.font=Tp(12),r.textAlign=`left`;let l=Math.round(n.minValue*100)/100,u=Math.round(n.maxValue*100)/100;n.minValue===n.maxValue&&(--l,u+=1);let d=jc({value:u,format:void 0},n.locale),f=jc({value:l,format:void 0},n.locale);r.fillText(f,a+10+5,o+i-6),r.fillText(d,a+10+5,o+6),r.restore()}};function Kp(){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);return class extends globalThis.Chart.BarController{static id=`funnel`;static defaults={...globalThis.Chart?.BarController.defaults,dataElementType:`funnel`,animation:{duration:e=>e.type===`data`?1e3*(e.raw[1]/Math.max(...e.dataset.data.map(e=>e[1]))):1e3}};updateElements(e,t,n,r){super.updateElements(e,t,n,r);for(let i=t;i<t+n;i++){let t=e[i];this.updateElement(t,i,{nextElement:e[i+1]},r)}}}}function qp(){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);return class extends globalThis.Chart.BarElement{static id=`funnel`;draw(e){e.save();let{x:t,y:n,height:r,nextElement:i,base:a,options:o}=this.getProps([`x`,`y`,`width`,`height`,`nextElement`,`base`,`options`]),s=Jp(this),c=(s-(i?Jp(i):0))/2,l=Math.min(t,a),u=n-r/2;e.fillStyle=o.backgroundColor,e.beginPath(),e.moveTo(l,u),e.lineTo(l+s,u),e.lineTo(l+s-c,u+r),e.lineTo(l+c,u+r),e.closePath(),e.fill(),o.borderWidth&&(e.strokeStyle=o.borderColor,e.lineWidth=o.borderWidth,e.stroke()),e.restore()}inRange(e,t){let{x:n,y:r,height:i,nextElement:a,base:o}=this.getProps([`x`,`y`,`width`,`height`,`nextElement`,`base`,`options`]),s=Jp(this),c=a?Jp(a):0,l=Math.min(n,o),u=r-i/2;if(t<u||t>u+i)return!1;let d=(s-c)/2,f=l+d*(t-u)/i,p=l+s-d*(t-u)/i;return!(e<f||e>p)}}}function Jp(e){let{x:t,base:n}=e.getProps([`x`,`base`]);return Math.max(t,n)-Math.min(t,n)}let Yp=function(e){if(!e.length)return{x:0,y:0};let{x:t,y:n,base:r,width:i,height:a}=e[0].element.getProps([`x`,`y`,`width`,`height`,`base`]),o=Math.min(t,r),s=n-a/2;return{x:o+i*2/3,y:s+a/2}},Xp={id:`geoProjection`,beforeUpdate(e){e.options?.scales?.projection?.projection===`conicConformal`&&e.scales?.projection?.projection?.rotate([100,0])}},Zp={id:`o-spreadsheet-minor-gridlines`,beforeDatasetsDraw(e){let t=e.ctx,n=e.chartArea;if(n)for(let r in e.scales){let i=e.scales[r],a=i.options,o=a?.grid?.minor;if(!o?.display)continue;let s=a?.grid?.display,c=i.ticks;if(!(!c||c.length<2)){t.save(),t.lineWidth=1,t.strokeStyle=o.color??a?.grid?.color??`#e6e6e6`;for(let e=0;e<c.length-1;e++){let r=i.getPixelForTick(e),a=i.getPixelForTick(e+1);if(!(!isFinite(r)||!isFinite(a)))for(let e=+!!s;e<4;e++){let o=e/4,s=Math.round(r+(a-r)*o)+.5;t.beginPath(),i.isHorizontal()?(t.moveTo(s,n.top),t.lineTo(s,n.bottom)):(t.moveTo(n.left,s),t.lineTo(n.right,s)),t.stroke()}}t.restore()}}}},Qp=`000000`,$p={arrows:`3Arrows`,smiley:`3Symbols`,dots:`3TrafficLights1`},em={styleSheet:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,sst:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,Relationships:`http://schemas.openxmlformats.org/package/2006/relationships`,Types:`http://schemas.openxmlformats.org/package/2006/content-types`,worksheet:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,workbook:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,drawing:`http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing`,table:`http://schemas.openxmlformats.org/spreadsheetml/2006/main`,revision:`http://schemas.microsoft.com/office/spreadsheetml/2014/revision`,revision3:`http://schemas.microsoft.com/office/spreadsheetml/2016/revision3`,markupCompatibility:`http://schemas.openxmlformats.org/markup-compatibility/2006`},tm=`http://schemas.openxmlformats.org/drawingml/2006/main`,nm=`http://schemas.openxmlformats.org/drawingml/2006/chart`,rm={workbook:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml`,macroEnabledWorkbook:`application/vnd.ms-excel.sheet.macroEnabled.main+xml`,templateWorkbook:`application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml`,macroEnabledTemplateWorkbook:`application/vnd.ms-excel.template.macroEnabled.main+xml`,excelAddInWorkbook:`application/vnd.ms-excel.addin.macroEnabled.main+xml`,sheet:`application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml`,metadata:`application/vnd.openxmlformats-officedocument.spreadsheetml.sheetMetadata+xml`,sharedStrings:`application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml`,styles:`application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml`,drawing:`application/vnd.openxmlformats-officedocument.drawing+xml`,chart:`application/vnd.openxmlformats-officedocument.drawingml.chart+xml`,themes:`application/vnd.openxmlformats-officedocument.theme+xml`,table:`application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml`,pivot:`application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml`,externalLink:`application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml`},im={document:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument`,sheet:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet`,metadata:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/sheetMetadata`,sharedStrings:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings`,styles:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles`,drawing:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing`,chart:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart`,theme:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme`,table:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/table`,hyperlink:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink`,image:`http://schemas.openxmlformats.org/officeDocument/2006/relationships/image`},am=`http://schemas.openxmlformats.org/officeDocument/2006/relationships`,om=.75,sm=.143,cm=8.43,lm=12.75,um={FLOOR:[{type:`NUMBER`,value:1}],CEILING:[{type:`NUMBER`,value:1}],ROUND:[{type:`NUMBER`,value:0}],ROUNDUP:[{type:`NUMBER`,value:0}],ROUNDDOWN:[{type:`NUMBER`,value:0}],IFERROR:[{type:`NUMBER`,value:0}]},dm=`ACOT,ACOTH,AGGREGATE,ARABIC,BASE,BETA.DIST,BETA.INV,BINOM.DIST,BINOM.DIST.RANGE,BINOM.INV,BITAND,BITLSHIFT,BITOR,BITRSHIFT,BITXOR,BYCOL,BYROW,CEILING.MATH,CEILING.PRECISE,CHISQ.DIST,CHISQ.DIST.RT,CHISQ.INV,CHISQ.INV.RT,CHISQ.TEST,CHOOSECOLS,CHOOSEROWS,COMBINA,CONCAT,CONFIDENCE.NORM,CONFIDENCE.T,COT,COTH,COVARIANCE.P,COVARIANCE.S,CSC,CSCH,DAYS,DECIMAL,DROP,ERF.PRECISE,ERFC.PRECISE,EXPAND,EXPON.DIST,F.DIST,F.DIST.RT,F.INV,F.INV.RT,F.TEST,FIELDVALUE,FILTERXML,FLOOR.MATH,FLOOR.PRECISE,FORECAST.ETS,FORECAST.ETS.CONFINT,FORECAST.ETS.SEASONALITY,FORECAST.ETS.STAT,FORECAST.LINEAR,FORMULATEXT,GAMMA,GAMMA.DIST,GAMMA.INV,GAMMALN.PRECISE,GAUSS,HSTACK,HYPGEOM.DIST,IFNA,IFS,IMCOSH,IMCOT,IMCSC,IMCSCH,IMSEC,IMSECH,IMSINH,IMTAN,ISFORMULA,ISOMITTED,ISOWEEKNUM,LAMBDA,LET,LOGNORM.DIST,LOGNORM.INV,MAKEARRAY,MAP,MAXIFS,MINIFS,MODE.MULT,MODE.SNGL,MUNIT,NEGBINOM.DIST,NORM.DIST,NORM.INV,NORM.S.DIST,NORM.S.INV,NUMBERVALUE,PDURATION,PERCENTILE.EXC,PERCENTILE.INC,PERCENTRANK.EXC,PERCENTRANK.INC,PERMUTATIONA,PHI,POISSON.DIST,PQSOURCE,PYTHON_STR,PYTHON_TYPE,PYTHON_TYPENAME,QUARTILE.EXC,QUARTILE.INC,QUERYSTRING,RANDARRAY,RANK.AVG,RANK.EQ,REDUCE,RRI,SCAN,SEC,SECH,SEQUENCE,SHEET,SHEETS,SKEW.P,SORTBY,STDEV.P,STDEV.S,SWITCH,T.DIST,T.DIST.2T,T.DIST.RT,T.INV,T.INV.2T,T.TEST,TAKE,TEXTAFTER,TEXTBEFORE,TEXTJOIN,TEXTSPLIT,TOCOL,TOROW,UNICHAR,UNICODE,UNIQUE,VAR.P,VAR.S,VSTACK,WEBSERVICE,WEIBULL.DIST,WRAPCOLS,WRAPROWS,XLOOKUP,XOR,Z.TEST`.split(`,`);function fm(e){return Object.fromEntries(Object.entries(e).map(([e,t])=>[e,$f(t)]))}let pm={chartBackgroundColor:`#FFFFFF`,gridBorderColor:`#CECFCF`,gridBorderColorOnDefaultBackground:`#E2E3E3`,headerBackgroundColor:`#F8F9FA`,headerActiveBackgroundColor:`#595959`,headerSelectedBackgroundColor:`#E8EAED`,headerTextColor:`#666666`,headerBorderColor:`#C0C0C0`,frozenPaneBorderColor:`#DADFE8`,frozenPaneHeaderBorderColor:`#BCBCBC`,singleCellSelectionBackgroundColor:`#D2E1FB44`,multipleCellsSelectionBackgroundColor:`#ACC7FF44`},mm={chartBackgroundColor:`#25262b`,gridBorderColor:`#6B706F`,gridBorderColorOnDefaultBackground:`#4F5254`,headerBackgroundColor:`#262A36`,headerActiveBackgroundColor:`#3A4052`,headerSelectedBackgroundColor:`#4E566E`,headerTextColor:`#A1A6B3`,headerBorderColor:`#7A7F91`,frozenPaneBorderColor:`#7A7F91`,frozenPaneHeaderBorderColor:`#9FA5BD`,singleCellSelectionBackgroundColor:`#696E8044`,multipleCellsSelectionBackgroundColor:`#828AA044`},hm={light:{colorThemeName:`light`,...pm},dark:{colorThemeName:`dark`,...fm(mm)}},gm=`xMovingAverage`,_m={exponential:`exp`,logarithmic:`log`,polynomial:`poly`,trailingMovingAverage:`movingAvg`};function vm(e,t,n){return n?Au(e,t,n):void 0}function ym(e,{applyChange:t}){if(!e)return;let n=t(e);switch(n.changeType){case`REMOVE`:return;default:return n.range}}function bm(e,t,n){let r=[];for(let i of n.dataSets){let{unboundedZone:a,sheetId:o,invalidSheetName:s,invalidXc:c}=e.getRangeFromSheetXC(t,i.dataRange);if(!(s||c))if(a.left!==a.right&&a.top!==a.bottom){if(a.right===void 0)continue;let t=i.dataSetId;for(let i=a.left;i<=a.right;i++){let s={...a,left:i,right:i};r.push({...xm(e,o,s,n.dataSetsHaveTitle?{top:s.top,bottom:s.top,left:s.left,right:s.left}:void 0),dataSetId:t}),t=`${t}_${i}`}}else r.push({...xm(e,o,a,n.dataSetsHaveTitle?{top:a.top,bottom:a.top,left:a.left,right:a.left}:void 0),dataSetId:i.dataSetId})}return r}function xm(e,t,n,r){if(n.left!==n.right&&n.top!==n.bottom)throw Error(`Zone should be a single column or row: ${or(n)}`);if(r){let i=or(n),a=or(r);return{labelCell:e.getRangeFromSheetXC(t,a),dataRange:e.getRangeFromSheetXC(t,i)}}else return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,or(n))}}function Sm(e,t,n){let r=n.labelCell?.zone,i=n.dataRange.zone;if(r){let{numberOfRows:e,numberOfCols:t}=yr(i);e===1?i={...i,left:i.left+1}:t===1&&(i={...i,top:i.top+1})}let a=t[n.dataSetId]??{},o=wu({...n.dataRange,zone:i},e.getSheetSize),s={};a.label?s={text:a.label}:n.labelCell&&(s={reference:e.getRangeString(n.labelCell,`forceSheetReference`,{useBoundedReference:!0})});let c;return a.trend?.type&&(c={type:a.trend.type===`polynomial`&&a.trend.order===1?`linear`:_m[a.trend.type],color:a.trend.color,order:a.trend.order?Math.min(a.trend.order,6):void 0,window:a.trend.window||2}),{label:s,range:e.getRangeString(o,`forceSheetReference`,{useBoundedReference:!0}),backgroundColor:a.backgroundColor,rightYAxis:a.yAxisId===`y1`,trend:c}}function Cm(e,t,n){if(!t)return;let r={...t.zone};n&&t.zone.bottom>t.zone.top&&(r.top+=1);let i=wu({...t,zone:r},e.getSheetSize);return e.getRangeString(i,`forceSheetReference`,{useBoundedReference:!0})}function wm(e){return e&&Lf(e)<.3?`#FFFFFF`:`#000000`}function Tm(e){return e&&Lf(e)<.3?`#C8C8C8`:`#666666`}function Em(e){return e.dataSets.find(e=>!vl.test(e.dataRange))!==void 0||e.dataSets.map(e=>er(e.dataRange)).some(e=>e.top!==e.bottom&&Ar(e))?`InvalidDataSet`:`Success`}function Dm(e){return e.labelRange&&!vl.test(e.labelRange||``)?`InvalidLabelRange`:`Success`}function Om(e,t,n){return n&&!!t&&e>=t}function km(e){let t=!1,n=!1;if(`horizontal`in e&&e.horizontal)return{useLeftAxis:!0,useRightAxis:!1};let r=`dataSetStyles`in e?e.dataSetStyles??{}:{};for(let e of Object.values(r))e?.yAxisId===`y1`?n=!0:t=!0;return t||=!n,{useLeftAxis:t,useRightAxis:n}}function Am(e,t,n=!1){return(r,i)=>{let a=e?.[i];return jm({format:a,locale:t},n)(r)}}function jm(e,t=!1){return n=>{if(n=Number(n),isNaN(n))return n;let{locale:r,format:i}=e;return Pm(t?jc({value:n,format:i},r):V(n,{locale:r,format:!i&&Math.abs(n)>=1e3?`#,##`:i}))}}let Mm=[{value:`left`,label:N(`Left`)},{value:`right`,label:N(`Right`)}];function Nm(e,t){let n=[],r=xn(t.map(e=>e.data.length));for(let t=0;t<=r;t++)n.push(e.next());return n}function Pm(e,t=20){return e?e.length>t?e.substring(0,t)+`…`:e:``}function Fm(e){return e===`x1`||e===`xMovingAverage`}function Im({background:e},t){return e||hm[t].chartBackgroundColor}function Lm(e,t){return e.type===`bar`&&t.type===`line`}let Rm={id:`chartShowValuesPlugin`,afterDatasetsDraw(e,t,n){if(n.showValues&&e._metasets?.[0]?.data)switch(n.type){case`pie`:Jm(e,n);break;case`line`:case`scatter`:Hm(e,n);break;case`combo`:case`waterfall`:Um(e,n);break;case`radar`:Vm(e,n);break;case`bar`:n.horizontal?Km(e,n):Bm(e,n);break;case`pyramid`:Km(e,n);break;case`calendar`:Wm(e,n);break;case`bubble`:Gm(e,n);break;case`funnel`:qm(e,n);break}}};function zm(e){let{chart:t,options:n,getNumberValue:r,direction:i}=e,a=t.ctx;a.save(),a.textAlign=`center`,a.textBaseline=`middle`,a.miterLimit=1;let o={};for(let s of t._metasets)if(!(Fm(s.xAxisID)||s.hidden))for(let c=0;c<s._parsed.length;c++){let l=r(s,c);if(l===void 0||isNaN(l))continue;let u=s.data[c],d=u.options.backgroundColor;if(!d||Bf(d).a!==1)continue;let f=n.callback(l,s,c),p=Ym(f,a),m={dataset:s,chartElement:u,numberValue:l,valueIndex:c,textSize:p,options:n,chart:t},h=e.getValuePosition(m);if(e.shouldSkipValue?.(m))continue;if(i===`vertical`){let e=Math.round(h.x);o[e]||(o[e]=[]);for(let t of o[e]||[])Math.abs(t-h.y)<13&&(h.y=t+13*(l<0?1:-1));o[e].push(h.y)}else{let e=Math.round(h.y);o[e]||(o[e]=[]);for(let t of o[e])Math.abs(t-h.x)<p.width&&(h.x=l<0?t-p.width-3:t+p.width+3);o[e].push(h.x)}let{strokeColor:g,textColor:_}=e.getTextColors(m);g&&(a.strokeStyle=g,a.lineWidth=3,a.strokeText(f,h.x,h.y)),a.fillStyle=_,a.lineWidth=1,a.fillText(f,h.x,h.y)}a.restore()}function Bm(e,t){zm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t].y),getValuePosition:Qm,shouldSkipValue:({dataset:e})=>Lm(t,e),getTextColors:Xm})}function Vm(e,t){zm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t].r),getValuePosition:({chartElement:e})=>({x:e.x,y:e.y-10}),shouldSkipValue:()=>!1,getTextColors:Zm})}function Hm(e,t){zm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t].y),getValuePosition:({chartElement:e})=>({x:e.x,y:e.y-10}),shouldSkipValue:()=>!1,getTextColors:Zm})}function Um(e,t){zm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t].y),getValuePosition:e=>e.dataset.type===`line`?{x:e.chartElement.x,y:e.chartElement.y-10}:Qm(e),shouldSkipValue:()=>!1,getTextColors:e=>e.dataset.type===`line`?Zm(e):Xm(e)})}function Wm(e,t){zm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>e._parsed[t].y,getValuePosition:({chartElement:e})=>({x:e.x,y:e.y+e.height/2}),shouldSkipValue:({chartElement:e,textSize:t})=>t.height+2>Math.abs(e.height)-2,getTextColors:({chartElement:e})=>({strokeColor:void 0,textColor:wm(e.options.backgroundColor)})})}function Gm(e,t){let n=(e,t)=>{let n=e.options.radius??globalThis.Chart?.defaults.elements.point.radius??3;return t.height<n*2};zm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>e._parsed[t].y,getValuePosition:({chartElement:e,textSize:t})=>({x:e.x,y:n(e,t)?e.y:e.y-10}),shouldSkipValue:()=>!1,getTextColors:e=>n(e.chartElement,e.textSize)?Xm(e):Zm(e)})}function Km(e,t){zm({chart:e,options:t,direction:`horizontal`,getNumberValue:(e,t)=>e._parsed[t].x,getValuePosition:({chartElement:t,numberValue:n,textSize:r,dataset:i})=>{let a=e.scales[i.xAxisID].getPixelForValue(0),o=Math.abs(t.x-a),s,c=n<0?-1:1;return s=o<r.width?a+c*(r.width/2+3):t.x-c*(t.width/2),{x:s,y:t.y}},shouldSkipValue:({dataset:e})=>Lm(t,e),getTextColors:Xm})}function qm(e,t){zm({chart:e,options:t,direction:`horizontal`,getNumberValue:(e,t)=>e._parsed[t].x,getValuePosition:({chartElement:e})=>({x:e.x-e.width/2,y:e.y}),shouldSkipValue:()=>!1,getTextColors:Xm})}function Jm(e,t){let n=e=>{let{startAngle:t,endAngle:n,innerRadius:r,outerRadius:i}=e;return{midAngle:(t+n)/2,midRadius:(r+i)/2}};zm({chart:e,options:t,direction:`vertical`,getNumberValue:(e,t)=>Number(e._parsed[t]),getValuePosition:({chartElement:e})=>{let{midAngle:t,midRadius:r}=n(e);return{x:e.x+r*Math.cos(t),y:e.y+r*Math.sin(t)}},shouldSkipValue:({chartElement:e,textSize:t})=>{let{midRadius:r}=n(e),i=e.endAngle-e.startAngle,a=2*r*Math.tan(i/2);return i<Math.PI/2&&(t.width>=a||a<t.height)},getTextColors:Xm})}function Ym(e,t){return jp(t,e,Np({fontSize:globalThis.Chart?.defaults.font.size??12},`px`))}function Xm(e){let{dataset:t,numberValue:n,valueIndex:r,chartElement:i,options:a}=e;return{strokeColor:i.options.backgroundColor,textColor:a.background(n,t,r)||`#ffffff`}}function Zm(e){let{dataset:t,numberValue:n,valueIndex:r,chartElement:i,options:a}=e;return{strokeColor:a.background(n,t,r)||`#ffffff`,textColor:i.options.backgroundColor}}function Qm(e){let{chartElement:t,numberValue:n,dataset:r,textSize:i,chart:a}=e,o=a.scales[r.yAxisID].getPixelForValue(0),s=Math.abs(o-t.y),c=n<0?-1:1,l=0;return l=s<i.height?o-c*(i.height/2):t.y+c*(t.height/2),{x:t.x,y:l}}let $m={showHeaders:!0,headerDesign:{align:`center`,fillColor:`#808080`,bold:!0,fontSize:15},showValues:!0,showLabels:!0,valuesDesign:{align:`left`,verticalAlign:`bottom`,fontSize:12},coloringOptions:{type:`categoryColor`,colors:[],useValueBasedGradient:!0}},eh={second:1e3,minute:1e3*60,hour:1e3*3600,day:1e3*3600*24,month:1e3*3600*24*30,year:1e3*3600*24*365},th={inSeconds:function(e){return Math.floor(e/eh.second)},inMinutes:function(e){return Math.floor(e/eh.minute)},inHours:function(e){return Math.floor(e/eh.hour)},inDays:function(e){return Math.floor(e/eh.day)},inMonths:function(e){return Math.floor(e/eh.month)},inYears:function(e){return Math.floor(e/eh.year)}},nh=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function rh(e,t,n){let r=ih(t),i=oh(e,r,n),a={};return i&&(a[i]=r),{parser:r,displayFormats:a,unit:i??!1,tooltipFormat:r}}function ih(e){let t=e.indexOf(`h`);return e=t>=0?e.slice(0,t).replace(/m/g,`M`)+e.slice(t):e.replace(/m/g,`M`),e.includes(`a`)||(e=e.replace(/h/g,`H`)),e}function ah(e){return e.includes(`s`)?`second`:e.includes(`m`)?`minute`:e.includes(`h`)||e.includes(`H`)?`hour`:e.includes(`d`)?`day`:e.includes(`M`)?`month`:`year`}function oh(e,t,n){let r=e.map(e=>La(e,n)?.jsDate);if(r.some(e=>e===void 0)||e.length<2)return;let i=r.map(e=>e.getTime()),a=xn(i)-Sn(i),o=ah(t);return eh.second>=eh[o]&&th.inSeconds(a)<180?`second`:eh.minute>=eh[o]&&th.inMinutes(a)<180?`minute`:eh.hour>=eh[o]&&th.inHours(a)<96?`hour`:eh.day>=eh[o]&&th.inDays(a)<90?`day`:eh.month>=eh[o]&&th.inMonths(a)<36?`month`:`year`}function sh(e,t){let n={},{trendDataSetsValues:r,locale:i,axisFormats:a,axisType:o}=t,s={stacked:e.stacked,locale:i};if(e.horizontal)n.x=xh(e,`bottom`,`values`,o,{...s,format:a?.x}),n.y={...xh(e,`left`,`labels`,`linear`,s),grid:{display:!1}};else{n.x={...xh(e,`bottom`,`labels`,o,s),grid:{display:!1}};let t={...s,format:a?.y};n.y=xh(e,`left`,`values`,`linear`,t);let r={...s,format:a?.y1};n.y1=xh(e,`right`,`values`,`linear`,r)}if(n=sn(n),r&&r.length&&r.some(w)){let e=Math.max(...r.map(e=>e?.length||0));n.x1={...n.x,labels:Array(e).fill(``),offset:!1,display:!1},n[gm]={...n.x,offset:!0,display:!1}}return n}function ch(e,t){let n=t.map(e=>e.label||``),r=wm(e.background);return{y:{title:bh(e.axesDesign?.y),stacked:!0,min:0,max:n.length,ticks:{stepSize:.5,color:r,callback:function(e,t,r){if(t%2!=0)return n[Math.floor((t-1)/2)]}},grid:{display:!1},border:{display:!1}},x:{title:bh(e.axesDesign?.x),stacked:!0,grid:{display:!1},position:`top`,ticks:{color:r},border:{display:!1}}}}function lh(e,t){let{dataSetsValues:n}=t;if(!n.length||e.legendPosition===`none`)return;let r=n.flatMap(e=>e.data).filter(mf).map(e=>e.value),i=Math.min(...r),a=Math.max(...r),o=[];return o=typeof e.colorScale==`object`?[e.colorScale.minColor,e.colorScale.midColor,e.colorScale.maxColor].filter(w):[...gp[e.colorScale??`oranges`]],{position:e.legendPosition===`right`?`right`:`left`,colorScale:o,fontColor:wm(e.background),minValue:i,maxValue:a,locale:t.locale}}function uh(e,t){let{locale:n,axisType:r,trendDataSetsValues:i,labels:a,axisFormats:o}=t,s=o?.x,c=e.stacked,l={x:xh(e,`bottom`,`labels`,r,{locale:n}),y:xh(e,`left`,`values`,`linear`,{locale:n,stacked:c,format:o?.y}),y1:xh(e,`right`,`values`,`linear`,{locale:n,stacked:c,format:o?.y1})};if(l=sn(l),r===`time`&&a&&s){let t={type:`time`,time:rh(a,s,n),min:V(e.axesDesign?.x?.min??``,{format:s,locale:n}),max:V(e.axesDesign?.x?.max??``,{format:s,locale:n})};Object.assign(l.x,t),l.x.ticks.maxTicksLimit=15,delete l?.x?.ticks?.callback}else r===`linear`&&(l.x.type=`linear`,l.x.ticks.callback=e.humanize?e=>jc({value:e,format:s},n):e=>V(e,{format:s,locale:n}));if(i&&i.length&&i.some(w)&&(l.x1={...l.x,display:!1},l[gm]={...l.x,display:!1},r===`category`||r===`time`)){let e=Math.max(...i.map(e=>e?.length||0));l.x1.type=`category`,l.x1.labels=C(0,e).map(e=>e.toString()),l.x1.offset=!1,l[gm].type=`category`,l[gm].offset=!1}return l}function dh(e){return Lf(e||`#ffffff`)>.5?`#cccccc`:`#999999`}function fh(e){return Lf(e||`#ffffff`)>.5?`#e6e6e6`:`#333333`}function ph(e,t){let n=uh(e,t),r=n?.x??{},i=e.axesDesign?.x,a=i?.gridLines!==`none`&&i?.gridLines!==`minor`;return{...n,x:{...r,grid:{...r.grid,color:dh(e.background),display:a}}}}function mh(e,t){let n=ph(e,t),r=e.verticalAxisPosition||`left`;return{...n,y:{...n.y,position:r}}}function hh(e,t){let{locale:n,axisFormats:r,axisType:i}=t,a=r?.y||r?.y1,o=e.axesDesign?.y,s={x:{...xh(e,`bottom`,`labels`,i,{locale:n}),grid:{display:!1}},y:{position:e.verticalAxisPosition,ticks:{color:wm(e.background),callback:jm({locale:n,format:a},e.humanize)},title:bh(e.axesDesign?.y),min:o?.min,max:o?.max,grid:{lineWidth:e=>e.tick.value===0?2:1,display:o?.gridLines!==`none`&&o?.gridLines!==`minor`,color:dh(e.background)}}};return(o?.gridLines===`minor`||o?.gridLines===`both`)&&(s.y.grid.minor={display:!0,color:fh(e.background)}),s}function gh(e,t){let{dataSetsValues:n}=t,r=sh(e,t),i=r.x.ticks.callback;r.x.ticks.callback=e=>i(Math.abs(e));let a=Math.max(...n.map(e=>Math.max(...e.data.filter(mf).map(e=>Math.abs(e.value)))));return r.x.suggestedMin=-a,r.x.suggestedMax=a,r}function _h(e,t){let{locale:n,axisFormats:r,dataSetsValues:i}=t,a=Math.min(...i.map(e=>Math.min(...e.data.filter(mf).map(e=>e.value))));return{r:{beginAtZero:!0,ticks:{callback:jm({format:r?.r,locale:n},e.humanize),backdropColor:e.background||`#FFFFFF`},pointLabels:{color:wm(e.background),callback:e=>Pm(e)},suggestedMin:a<0?a-1:0}}}function vh(e,t){let{locale:n,axisFormats:r,availableRegions:i}=t,a=wh(e.legendPosition),o=e.region?i.find(t=>t.id===e.region):i[0],s=r?.y||r?.y1;return{projection:{projection:o?.defaultProjection||`mercator`,axis:`x`},color:{axis:`x`,display:e.legendPosition!==`none`,border:{color:ze},grid:{color:ze},ticks:{color:wm(e.background),callback:jm({locale:n,format:s},e.humanize)},legend:{position:a,align:a.includes(`right`)?`left`:`right`,margin:Ch(e)},interpolate:Sh(e.colorScale??He),missing:e.missingValueColor||`#ffffff`}}}function yh(e,t){let n=t.dataSetsValues[0];return{x:{display:!1},y:{grid:{offset:!1},ticks:{callback:function(e){return Pm(this.getLabelForValue(e))}},border:{display:!1}},percentages:{position:`right`,border:{display:!1},ticks:{callback:function(e,r,i){let a=n.data?.[r],o=n.data?.[0];return!o?.value||a?.value===null||!mf(a)||!mf(o)?``:V(a.value/o.value,{format:`0%`,locale:t.locale})}},grid:{display:!1}}}}function bh(e){if(e?.title?.text){let{text:t,color:n,align:r,italic:i,bold:a}=e.title;return{display:!0,text:t,color:n,font:{style:i?`italic`:`normal`,weight:a?`bold`:`normal`,size:e.title.fontSize??12},align:r===`left`?`start`:r===`right`?`end`:`center`}}}function xh(e,t,n,r,i){let{useLeftAxis:a,useRightAxis:o}=km(e);if(t===`left`&&!a||t===`right`&&!o)return;let s=wm(e.background),c;if(c=t===`bottom`?e.axesDesign?.x:t===`left`?e.axesDesign?.y:e.axesDesign?.y1,n===`values`){let n=!(t===`right`&&a),o=c?.gridLines?c?.gridLines===`major`||c?.gridLines===`both`:n,l=!(r===`category`||r===void 0)&&(c?.gridLines===`minor`||c?.gridLines===`both`),u=jm(i,e.humanize),d={position:t,title:bh(c),beginAtZero:!c?.min,stacked:i?.stacked,ticks:{color:s,callback:u},min:c?.min,max:c?.max,grid:{display:o,color:dh(e.background)}};return l&&(d.grid.minor={display:!0,color:fh(e.background)}),d}else{let t={ticks:{padding:5,color:s,callback:function(e,t,n){return Pm(this.getLabelForValue(e))}},min:c?.min,max:c?.max,grid:{display:c?.gridLines===`major`||c?.gridLines===`both`,color:dh(e.background)},stacked:i?.stacked,title:bh(c)};return(c?.gridLines===`minor`||c?.gridLines===`both`)&&(t.grid.minor={display:!0,color:fh(e.background)}),t}}function Sh(e,t=0,n=1){if(t===n){let t=e.midColor??e.minColor;return e=>t}let r=[{value:t,color:e.minColor}];return e.midColor&&r.push({value:(t+n)/2,color:e.midColor}),r.push({value:n,color:e.maxColor}),vp(r)}function Ch(e){switch(e.legendPosition){case`top`:case`right`:return{top:e.title.text?45:15,left:20,right:20};case`bottom`:case`left`:case`none`:return{left:20,right:20,bottom:10}}}function wh(e){switch(e){case`top`:return`top-left`;case`right`:return`top-right`;case`bottom`:return`bottom-right`;case`left`:return`bottom-left`;case`none`:return`bottom-left`}}let Th=`nullValue`;function Eh(e,t){let{dataSetsValues:n,background:r}=t,i=[],a=Yh(e.dataSetStyles,n),o=[];for(let s in n){let{label:c,data:l,hidden:u,dataSetId:d}=n[s];c=e.dataSetStyles?.[d]?.label??c;let f=a.next(),p={label:c,data:l.map(e=>mf(e)?e.value:NaN),hidden:u,borderColor:e.background||r,borderWidth:+!!e.stacked,backgroundColor:f,yAxisID:e.horizontal?`y`:e.dataSetStyles?.[d]?.yAxisId??`y`,xAxisID:`x`,barPercentage:.9,categoryPercentage:n.length>1?.8:1,borderRadius:2};i.push(p);let m=e.dataSetStyles?.[d]?.trend,h=t.trendDataSetsValues?.[s];!m?.display||e.horizontal||!h||o.push(qh(p,m,h))}i.push(...o);let s=Dh(e,n);return s&&i.push(s),i}function Dh(e,t){let n=t.filter(e=>!e.hidden);if(!e.stacked||!e.showTotalLine||n.length<2)return;let r=C(0,Math.max(...n.map(e=>e.data.length))).map(e=>{let t;for(let r of n){let n=r.data[e];mf(n)&&(t=(t??0)+n.value)}return t??NaN}),i=Lf(e.background||`#FFFFFF`)<.3?`#e9ecef`:`#343a40`;return{type:`line`,label:N(`Sum`),data:r,order:-1,tension:0,fill:!1,pointRadius:3,borderWidth:2,backgroundColor:i,borderColor:i,pointBackgroundColor:i,xAxisID:`x`,yAxisID:`y`}}function Oh(e,t){let{labels:n,dataSetsValues:r,background:i}=t,a=r.map(e=>e.data).flat().filter(mf).map(e=>e.value),o=Math.max(...a),s=Math.min(...a),c=Sh(e.colorScale??He,s,o),l=[];for(let t of r)l.push({label:t.label,data:t.data.map(e=>1),backgroundColor:t.data.map(t=>mf(t)?c(t.value):e.missingValueColor||`#00000000`),borderColor:e.background||i,borderSkipped:!1,borderWidth:1,barPercentage:1,categoryPercentage:1,values:t.data.map(e=>mf(e)?e.value:void 0)});return{labels:n,datasets:l}}function kh(e,t){let{dataSetsValues:n,labels:r}=t,i=e.negativeValuesColor||`#EA6175`,a=e.positiveValuesColor||`#4EA7F2`,o=e.subTotalValuesColor||`#AAAAAA`,s=[],c=[],l={label:``,data:c,backgroundColor:s},u=[],d=0;for(let t of n)if(!t.hidden){for(let l=0;l<t.data.length;l++){let f=t.data[l];if(u.push(r[l]),!mf(f)){c.push([d,d]),s.push(``);continue}c.push([d,f.value+d]);let p=f.value>=0?a:i;l===0&&t===n[0]&&e.firstValueAsSubtotal&&(p=o),s.push(p),d+=f.value}e.showSubTotals&&(u.push(N(`Subtotal`)),c.push([0,d]),s.push(o))}return{datasets:[l],labels:u}}function Ah(e,t){let{dataSetsValues:n,axisType:r,labels:i}=t,a=[],o=!!e.fillArea,s=!!e.stacked,c=[],l=Yh(e.dataSetStyles,n);for(let u=0;u<n.length;u++){let{label:d,data:f,hidden:p,dataSetId:m}=n[u];d=e.dataSetStyles?.[m]?.label??d;let h=[],g=l.next();h=r&&[`linear`,`time`].includes(r)?f.map((e,t)=>({x:i[t]===``?NaN:i[t]??NaN,y:mf(e)?e.value:NaN})):f.map(e=>mf(e)?e.value:NaN);let _=e.dataSetStyles?.[m],v={label:d,data:h,hidden:p,tension:0,borderColor:g,backgroundColor:o?Jf(g,ct):g,pointBackgroundColor:g,fill:o?Jh(u,s):!1,pointRadius:e.hideDataMarkers?0:3,yAxisID:_?.yAxisId||`y`};a.push(v);let ee=_?.trend,y=t.trendDataSetsValues?.[u];!ee?.display||!y||c.push(qh(v,ee,y))}return a.push(...c),a}function jh(e,t){let n=Ah(e,t);for(let e of n)Fm(e.xAxisID)||(e.showLine=!1);return n}function Mh(e,t){let n,r;if(e.bubbleColor.color===`multiple`){let i=new pp(t.bubbleSizes.length);r=[];for(let e=0;e<t.bubbleSizes.length;e++)r.push(i.next());n=r.map(t=>Jf(t,e.bubbleColor.transparent?.5:1))}else r=e.bubbleColor.color,n=Jf(r,e.bubbleColor.transparent?.5:1);let i=Nh(t.bubbleSizes),a=[];for(let e=0;e<t.bubbleSizes.length;e++){let n=t.dataSetsValues[0].data[e];a.push({x:t.labels[e],y:mf(n)?n.value:NaN})}return[{label:t.dataSetsValues[0]?.label,data:a,backgroundColor:n,borderColor:r,hoverBackgroundColor:n,hoverBorderColor:r,yAxisID:`y`,pointRadius:i,pointHoverRadius:i,showLine:!1}]}function Nh(e){if(!e.length)return[];let t=e.filter(e=>Number.isFinite(e)&&e>0),n=t.length?Math.min(...t):0,r=(t.length?Math.max(...t):0)-n;return t.length?e.map(e=>e===void 0||!Number.isFinite(e)||e<0?0:e===0?2:r===0?10:10+S((e-n)/r,0,1)*20):e.map(()=>2)}function Ph(e,t){let{dataSetsValues:n}=t,r=[],i=Nm(new pp(Math.max(0,...n.map(e=>e?.data?.length??0)),e.slicesColors),n);for(let{label:t,data:a,hidden:o}of n){if(o)continue;let n={label:t,data:a.map(e=>mf(e)?e.value:NaN),borderColor:e.background||`#FFFFFF`,backgroundColor:i,hoverOffset:10};r.push(n)}return r}function Fh(e,t){let{dataSetsValues:n}=t,r=[],i=Yh(e.dataSetStyles,n),a=[],o=n.filter(({dataSetId:t})=>(e.dataSetStyles?.[t]?.type??`line`)===`bar`);for(let s=0;s<n.length;s++){let{label:c,data:l,hidden:u,dataSetId:d}=n[s];c=e.dataSetStyles?.[d]?.label||c;let f=e.dataSetStyles?.[d],p=i.next(),m=s===0?`bar`:`line`,h=f?.type??m,g={label:c,data:l.map(e=>mf(e)?e.value:null),hidden:u,borderColor:p,backgroundColor:p,yAxisID:e.dataSetStyles?.[d]?.yAxisId||`y`,xAxisID:`x`,type:h,order:h===`bar`?n.length+s:s,pointRadius:e.hideDataMarkers?0:3};g.type===`bar`&&(g.barPercentage=.9,g.categoryPercentage=o.length>1?.8:1,g.borderRadius=2),r.push(g);let _=e.dataSetStyles?.[d]?.trend,v=t.trendDataSetsValues?.[s];!_?.display||!v||a.push(qh(g,_,v))}return r.push(...a),r}function Ih(e,t){let{dataSetsValues:n}=t,r=[],i=e.fillArea??!1,a=Yh(e.dataSetStyles,n);for(let t=0;t<n.length;t++){let{label:o,data:s,hidden:c}=n[t];e.dataSetStyles?.[t]?.label&&(o=e.dataSetStyles[t].label);let l=a.next(),u={label:o,data:s.map(e=>mf(e)?e.value:null),hidden:c,borderColor:l,backgroundColor:l,pointBackgroundColor:l,pointRadius:e.hideDataMarkers?0:3};i&&(u.backgroundColor=Jf(l,ct),u.fill=`start`),r.push(u)}return r}function Lh(e,t){let{availableRegions:n,dataSetsValues:r,labels:i}=t,a=e.region||n[0]?.id,o=a?t.getGeoJsonFeatures(a):void 0,s={outline:o,showOutline:!!o,data:[]};if(o&&a){let e={};if(r[0])for(let n=0;n<r[0].data.length;n++){let o=r[0].data[n];if(!i[n]||o===void 0)continue;let s=t.geoFeatureNameToId(a,i[n]);s&&(e[s]={value:mf(o)?o.value:0,label:i[n]})}for(let t of o)t.id&&s.data.push({feature:{...t,properties:{name:e[t.id]?.label}},value:e[t.id]?.value})}return[s]}function Rh(e,t){let n=t.dataSetsValues[0],{labels:r,background:i}=t;if(!n)return[];let{label:a,data:o}=n;return a=e.dataSetStyles?.[0]?.label||a,[{label:a,data:o.map(e=>{if(!mf(e))return 0;let t=e.value;return t<=0?[0,0]:[-t,t]}),backgroundColor:zh(r,e.funnelColors),yAxisID:`y`,xAxisID:`x`,barPercentage:1,categoryPercentage:1,borderColor:e.background||i,borderWidth:3}]}function zh(e,t){let n=new pp(e.length,t);return e.map(()=>n.next())}function Bh(e,t){let{dataSetsValues:n,labels:r,background:i}=t,a=Wh(Hh(n,r)),o=a[0]||[],s=new pp(o.length,e.groupColors||[]),c=o.map(e=>({label:e.label,color:s.next()})),l=[];for(let t=a.length-1;t>=0;t--){let n={groupColors:c,parsing:{key:`value`},data:a[t],borderColor:t=>{let n=t.type===`data`?t.raw:void 0;return!n||n.label===`nullValue`?Ie:e.background||i},backgroundColor:e=>{let t=e.type===`data`?e.raw:void 0;if(!t||t.label===`nullValue`)return Ie;let n=t.groups[0];return c.find(e=>e.label===n)?.color},hoverOffset:10};l.push(n)}return l}function Vh(e,t){let n=[],r=Math.max(...e.map(e=>e.data.length));for(let i=0;i<r;i++){n[i]={};for(let t=0;t<e.length;t++){let r=e[t].data[i]?.value,a=r===null?Th:String(r);n[i][t]=a}n[i].value=Number(t[i])}return n}function Hh(e,t){return Uh(Vh(e,t),0,e.length,[])}function Uh(e,t,n,r){if(t>=n)return[];let i=Object.groupBy(e,e=>e[t]);return Object.keys(i).map(e=>{let a=i[e]?.reduce((e,t)=>e+Number(t.value),0)||0,o=[...r,e];return{label:e,value:a,children:Uh(i[e]||[],t+1,n,[...r,e]),groups:o,depth:t}}).sort((e,t)=>t.value-e.value)}function Wh(e){let t=[],n=[...e];for(;n.length>0;){let e=n.shift();e&&(t[e.depth]||(t[e.depth]=[]),t[e.depth].push(e),e.children&&n.push(...e.children))}return t}function Gh(e,t){let{dataSetsValues:n,labels:r,locale:i,axisFormats:a}=t,o={locale:i,format:a?.y};if(n.length===0)return[];let s=Hh(n,r).sort((e,t)=>t.value-e.value),c=Xh(e,s),l=[],u=Math.max(...n.map(e=>e.data.length));for(let e=0;e<u;e++){l[e]={};for(let t=0;t<n.length;t++)l[e][t]=n[t].data[e].value?String(n[t].data[e].value):void 0;l[e].value=Number(r[e])}let d=e.showLabels??$m.showLabels,f=e.showValues??$m.showValues,p=e.coloringOptions||$m.coloringOptions,m;return p?.type===`colorScale`&&(m=Zh(s,p)),[{data:[],tree:l,labels:{display:d||f,overflow:`hidden`,...Kh(e.valuesDesign,$m.valuesDesign),formatter:e=>[d?e.raw.g:void 0,f?V(e.raw.v,o):void 0].filter(w)},captions:{display:e.showHeaders??$m.showHeaders,padding:6,...Kh(e.headerDesign,$m.headerDesign)},key:`value`,groups:C(0,n.length).map(e=>String(e)),borderWidth:0,spacing:1,displayMode:`headerBoxes`,groupColors:c,backgroundColor:t=>{if(t.type!==`data`)return`transparent`;if(!t.raw.isLeaf)return e.headerDesign?.fillColor||$m.headerDesign?.fillColor;if(p.type===`colorScale`)return m?.(t.raw.v)||`#FF0000`;if(p.type===`categoryColor`)return Qh(t,s,p,c);throw Error(`Unsupported coloring option type}`)}}]}function Kh(e,t){let n=e=>{let t=e.element.options.backgroundColor;return Lf(t)>.7?`#666666`:`#FFFFFF`};return{align:e?.align??t?.align,position:e?.verticalAlign??t?.verticalAlign,color:e?.color||n,hoverColor:e?.color||n,font:{weight:e?.bold??t?.bold?`bold`:`normal`,style:e?.italic??t?.italic?`italic`:`normal`,size:e?.fontSize??t?.fontSize}}}function qh(e,t,n){let r=Bf(e.backgroundColor);r.a=1;let i=t.color||Yf(zf(r),.5);return{type:`line`,xAxisID:t.type===`trailingMovingAverage`?gm:`x1`,yAxisID:e.yAxisID,label:e.label?N(`Trend line for %s`,e.label):``,data:n,order:-1,showLine:!0,pointRadius:0,backgroundColor:i,borderColor:i,borderDash:[5,5],borderWidth:void 0,fill:!1,pointBackgroundColor:i}}function Jh(e,t){return t?e===0?`origin`:`-1`:`origin`}function Yh(e,t){let n=t.map(t=>e?.[t.dataSetId]?.backgroundColor),r=t.length;return new pp(r,n)}function Xh(e,t){let n=e.coloringOptions?.type===`categoryColor`?e.coloringOptions.colors:[],r=new pp(t.length,n);return t.map(e=>({label:e.label,color:r.next()}))}function Zh(e,t){if(e.length===0)return;let n=Wh(e),r=n[n.length-1],i=Math.min(...r.map(e=>e.value)),a=Math.max(...r.map(e=>e.value));if(Number.isFinite(i)&&Number.isFinite(a)){let e=[{value:i,color:t.minColor}];if(t.midColor){let n=(i+a)/2;e.push({value:n,color:t.midColor})}return e.push({value:a,color:t.maxColor}),vp(e)}}function Qh(e,t,n,r){let i=e.raw._data.children[0][0],a=r.find(e=>e.label===i)?.color;if(!a||!n.useValueBasedGradient)return a||`#FF0000`;let o=t.find(e=>e.label===i);if(!o||!o.children.length)return a;let s=Wh(o.children),c=s[s.length-1],l=Math.max(...c.map(e=>e.value)),u=Math.min(...c.map(e=>e.value));return u===l||!isFinite(u)||!isFinite(l)?a:Yf(a,((Number(e.raw.v)||0)-l)/(u-l)*.5)}let $h={id:`sunburstHoverPlugin`,afterEvent(e,t,n){if(!n.enabled)return;let r=e.getActiveElements(),i=r.map(e=>({datasetIndex:e.datasetIndex,index:e.index}));for(let t of r){let n=e.data.datasets[t.datasetIndex].data[t.index];for(let t=0;t<e.data.datasets.length;t++){let r=e.data.datasets[t];for(let e=0;e<r.data.length;e++){let a=r.data[e];eg(n.groups,a.groups)&&i.push({datasetIndex:t,index:e})}}}i=i.filter(t=>{let{datasetIndex:n,index:r}=t;return e.data.datasets[n].data[r].label!==Th}),e.setActiveElements(i);for(let t of e.getSortedVisibleDatasetMetas())for(let e of t.data){let t=e.$context,{datasetIndex:n,index:r,dataset:a,raw:o}=t;if(o.label===`nullValue`)continue;let s=typeof a.backgroundColor==`function`?a.backgroundColor(t):a.backgroundColor;i.length&&!i.some(e=>e.datasetIndex===n&&e.index===r)?e.options.backgroundColor=Yf(s,.5):e.options.backgroundColor=s}}};function eg(e,t){return t.length>e.length&&e.every((e,n)=>e===t[n])}let tg={id:`sunburstLabelsPlugin`,afterDatasetsDraw(e,t,n){if(!n.showValues&&!n.showLabels||e.config.type!==`doughnut`)return;let r=e.ctx;ng(e,n,r)}};function ng(e,t,n){let r=t.style,i=r.fontSize||13,a=i+3;for(let o of e._metasets)for(let s=0;s<o._dataset.data.length;s++){let c=o._dataset.data[s];if(c.label===`nullValue`)continue;let l=[t.showLabels?c.label:void 0,t.showValues?t.callback(c.value,`y`):void 0].filter(w),u=o.data[s],{startAngle:d,endAngle:f,innerRadius:p,outerRadius:m,circumference:h}=u,g=u.options.offset/4,_=g*(1-Math.sin(Math.min(Math.PI,h||0)));p+=_,m+=_;let v=(d+f)/2,ee=(p+m)/2,y=(m-p)*.9,b=f-d;if((b>=Math.PI?m:Math.sin(b/2)*p*2)<l.length*a)continue;n.save();let te={x:Math.cos(v)*g,y:Math.sin(v)*g},ne=e.chartArea.left+e.chartArea.width/2+te.x,re=e.chartArea.top+e.chartArea.height/2+te.y;n.translate(ne,re);let ie;v>Math.PI/2?(n.rotate(v-Math.PI),ie=-ee):(ie=ee,n.rotate(v));let ae=u.options.backgroundColor,oe=Lf(ae)>.7?`#666666`:`#FFFFFF`;n.fillStyle=r.textColor||oe,n.textAlign=`center`,n.textBaseline=`middle`,n.font=Tp(i,r.bold,r.italic);let se=-((l.length-1)*a)/2;for(let e=0;e<l.length;e++){let t=Up(n,y,l[e],r,`px`);n.fillText(t,ie,se+e*a)}n.restore()}}let rg={id:`waterfallLinesPlugin`,beforeDraw(e,t,n){if(!n.showConnectorLines)return;let r=e._metasets?.[0]?.data;if(!r)return;let i=e.ctx;i.save(),i.setLineDash([3,2]);for(let e=0;e<r.length;e++){let t=r[e];if(t.height===0)continue;let n=ag(r,e);if(!n)break;let a=ig(t),o=ig(n),s=t.$context.raw,c=s[1]-s[0],l=Math.round(c<0?a.bottom-1:a.top),u=Math.round(a.right),d=Math.round(o.left);i.strokeStyle=`#999`,i.beginPath(),i.moveTo(u+1,l+.5),i.lineTo(d,l+.5),i.stroke()}i.restore()}};function ig(e){let t=e.base<e.y;return{left:e.x-e.width/2,right:e.x+e.width/2,bottom:t?e.base+e.height:e.y+e.height,top:t?e.base:e.y}}function ag(e,t){return e.find((e,n)=>n>t&&e.height!==0)}let og={id:`zoomWindowPlugin`,afterDatasetsDraw:function(e,t,n){if(!n.getLowerBound||!n.getUpperBound)return;let{ctx:r,chartArea:{left:i,right:a,top:o,bottom:s}}=e,c=n.getLowerBound()??i,l=n.getUpperBound()??a;c>l&&([c,l]=[l,c]),c=Math.max(i,c),l=Math.min(a,l),c===i&&--c,l===a&&(l+=1),r.save(),r.fillStyle=`rgba(255,255,255,0.5)`,r.beginPath(),r.rect(i,s,c-i,o-s),r.rect(l,s,a-l,o-s),r.fill(),r.beginPath(),r.strokeStyle=`#bbb`,r.rect(c,s,l-c,o-s),r.stroke(),r.lineWidth=2,r.beginPath(),r.moveTo(c-3,(o+s)/2-7),r.lineTo(c-3,(o+s)/2+7),r.stroke(),r.beginPath(),r.moveTo(l+3,(o+s)/2-7),r.lineTo(l+3,(o+s)/2+7),r.stroke(),r.restore()}};ri.add(`chartShowValuesPlugin`,{register:e=>e.register(Rm),unregister:e=>e.unregister(Rm)}),ri.add(`chartMinorGridPlugin`,{register:e=>e.register(Zp),unregister:e=>e.unregister(Zp)}),ri.add(`waterfallLinesPlugin`,{register:e=>e.register(rg),unregister:e=>e.unregister(rg)}),ri.add(`funnelController`,{register:e=>e.register(Kp()),unregister:e=>e.unregister(Kp())}),ri.add(`funnelElement`,{register:e=>e.register(qp()),unregister:e=>e.unregister(qp())}),ri.add(`funnelTooltipPositioner`,{register:e=>e.Tooltip.positioners.funnelTooltipPositioner=Yp,unregister:e=>e.Tooltip.positioners.funnelTooltipPositioner=void 0}),ri.add(`sunburstLabelsPlugin`,{register:e=>e.register(tg),unregister:e=>e.unregister(tg)}),ri.add(`sunburstHoverPlugin`,{register:e=>e.register($h),unregister:e=>e.unregister($h)}),ri.add(`chartColorScalePlugin`,{register:e=>e.register(Gp),unregister:e=>e.unregister(Gp)}),ri.add(`calendarController`,{register:e=>e.register(ba()),unregister:e=>e.unregister(ba())}),ri.add(`zoomWindowPlugin`,{register:e=>e.register(og),unregister:e=>e.unregister(og)}),ri.add(`chartBackgroundPlugin`,{register:e=>e.register(ya),unregister:e=>e.unregister(ya)}),ri.add(`geoProjectionPlugin`,{register:e=>e.register(Xp),unregister:e=>e.unregister(Xp)});var sg=class extends k{static template=`o-spreadsheet-ChartJsComponent`;props=(0,t.useProps)({chartId:M.string(),isFullScreen:M.boolean().optional()});canvas=t.signal.ref(HTMLCanvasElement);chart;currentRuntime;animationStore;currentDevicePixelRatio=window.devicePixelRatio;get chartRuntime(){let e=this.env.model.getters.getChartRuntime(this.props.chartId);if(!(`chartJsConfig`in e))throw Error(`Unsupported chart runtime`);return e}setup(){this.shouldAnimate&&(this.animationStore=A(va)),(0,t.onMounted)(()=>{ai();let e=this.chartRuntime;this.currentRuntime=e,this.createChart(x(e))}),(0,t.onWillUnmount)(this.unmount.bind(this)),Vi(()=>{let e=this.chartRuntime;e===this.currentRuntime?this.currentDevicePixelRatio!==window.devicePixelRatio&&(this.currentDevicePixelRatio=window.devicePixelRatio,this.updateChartJs(x(this.currentRuntime))):(e.chartJsConfig.type===this.currentRuntime.chartJsConfig.type?this.updateChartJs(x(e)):(this.chart?.destroy(),this.createChart(x(e))),this.currentRuntime=e)})}unmount(){this.chart?.destroy()}get shouldAnimate(){return this.env.model.getters.isDashboard()}createChart(e){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);let t=e.chartJsConfig;if(this.shouldAnimate&&this.animationStore){let e=this.env.model.getters.getChartDefinition(this.props.chartId)?.type;e&&this.animationStore.animationPlayed[this.animationChartId]!==e&&(t=this.enableAnimationInChartData(t),this.animationStore.disableAnimationForChart(this.animationChartId,e))}let n=this.canvas();if(!n)return;let r=n.getContext(`2d`);this.chart=new globalThis.Chart(r,t)}updateChartJs(e){let t=e.chartJsConfig;if(this.shouldAnimate){let e=this.env.model.getters.getChartDefinition(this.props.chartId)?.type;e&&this.hasChartDataChanged()&&this.animationStore&&(t=this.enableAnimationInChartData(t),this.animationStore.disableAnimationForChart(this.animationChartId,e))}t.data&&t.data.datasets?(this.chart.data=t.data,t.options?.plugins?.title&&(this.chart.config.options.plugins.title=t.options.plugins.title)):this.chart.data.datasets=[],this.chart.config.options=t.options,this.chart.update()}hasChartDataChanged(){return!T(this.getChartDataInRuntime(this.currentRuntime),this.getChartDataInRuntime(this.chartRuntime))}enableAnimationInChartData(e){return{...e,options:{...e.options,animation:{animateRotate:!0}}}}getChartDataInRuntime(e){let t=e.chartJsConfig.data;return{labels:t.labels,dataset:t.datasets.map(e=>({data:e.data,label:e.label,tree:e.tree}))}}get animationChartId(){return this.props.isFullScreen?this.props.chartId+`-fullscreen`:this.props.chartId}};function cg(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 lg(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=cg(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){ug(i,e,a),ug(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 ug(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 dg(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 fg(e){if(!wt(e))return e;if(!pg(e))throw Error(`The value should be a scalar or a 1x1 matrix`);return e[0][0]}function pg(e){return e.length===1&&e[0].length===1}function mg(e){return wt(e)&&!pg(e)}function hg(e){let t=[];for(let n=0;n<e.length;n++)mg(e[n])&&t.push(n);return t}var gg=class{static commonKeys=[`type`,`title`,`background`,`humanize`,`annotationText`,`annotationLink`]};function _g(e,t,n){if(!e)return{scalar:void 0,range:void 0};if(!Dn(e))return{scalar:{value:e},range:void 0};let r=t.evaluateFormulaResult(n,e),i=mg(r)?r[0][0]:fg(r),a,o=Sg(e);return o&&(a=ju(t,n,o),a&&t.getEvaluatedCell({sheetId:a.sheetId,col:a.zone.left,row:a.zone.top}).type===`empty`&&(i=void 0)),{scalar:i,range:a}}function vg(e,t,n,r,i){if(!e)return``;if(n===`text`||typeof t?.value!=`number`||typeof e.value!=`number`)return r?jc(e,i):V(e.value,{format:e.format,locale:i});let{value:a,format:o}=e;return n===`progress`?(a=t.value/a,o=`0.0%`):(a=Math.abs(t.value-a),n===`percentage`&&a!==0&&(a/=e.value),n===`percentage`&&(o=`0.0%`),o||(a=Math.round(a*100)/100)),r?jc({value:a,format:o},i):V(a,{format:o,locale:i})}function yg(e,t,n){return e?.value===void 0||e?.value===null?``:t?jc(e,n):e.format?V(e.value,{format:e.format,locale:n}):String(e.value??``)}function bg(e,t,n,r,i){if(t===`text`||t===`progress`||typeof e?.value!=`number`||typeof n?.value!=`number`)return;let a=n.value-e.value;if(a>0)return r;if(a<0)return i}function xg(e,t,n){if(n===`text`||typeof e?.value!=`number`||typeof t?.value!=`number`)return`neutral`;let r=t.value-e.value;return r>0?`up`:r<0?`down`:`neutral`}function Sg(e){if(!e||!Dn(e))return;let t=e.slice(1);return vl.test(t)?t:void 0}let Cg=globalThis.Path2D,wg=Cg&&new Cg(`M8.6 4.8a.5.5 0 0 1 0 .75l-3.9 3.9a.5 .5 0 0 1 -.75 0l-3.8 -3.9a.5 .5 0 0 1 0 -.75l.4-.4a.5.5 0 0 1 .75 0l2.3 2.4v-5.7c0-.25.25-.5.5-.5h.6c.25 0 .5.25.5.5v5.8l2.3 -2.4a.5.5 0 0 1 .75 0z`),Tg=Cg&&new Cg(`M8.7 5.5a.5.5 0 0 0 0-.75l-3.8-4a.5.5 0 0 0-.75 0l-3.8 4a.5.5 0 0 0 0 .75l.4.4a.5.5 0 0 0 .75 0l2.3-2.4v5.8c0 .25.25.5.5.5h.6c.25 0 .5-.25.5-.5v-5.8l2.2 2.4a.5.5 0 0 0 .75 0z`),Eg={sequence:40,allowedDefinitionKeys:[...gg.commonKeys,`keyValue`,`keyDescr`,`baseline`,`baselineMode`,`baselineDescr`,`baselineColorUp`,`baselineColorDown`],fromStrDefinition:e=>e,validateDefinition(e,t){return`Success`},copyInSheetId:(e,t,n,r)=>{let i=e=>r.copyFormulaStringForSheet(t,n,e,`keepSameReference`);return{...e,keyValue:e.keyValue?i(e.keyValue):e.keyValue,baseline:e.baseline?i(e.baseline):e.baseline}},getDefinitionFromContextCreation(e,t){let n=e.dataSource?.type===`range`?e.dataSource?.dataSets?.[0]?.dataRange:void 0,r=(e.scorecardKeyValueFormula===void 0||Sg(e.scorecardKeyValueFormula))&&n?`=${n}`:e.scorecardKeyValueFormula,i=(e.scorecardBaselineFormula===void 0||Sg(e.scorecardBaselineFormula))&&e.auxiliaryRange?`=${e.auxiliaryRange}`:e.scorecardBaselineFormula;return{background:e.background,type:`scorecard`,keyValue:r,title:e.title||{text:``},baselineMode:at,baselineColorUp:ot,baselineColorDown:st,baseline:i,humanize:e.humanize,annotationLink:e.annotationLink,annotationText:e.annotationText}},transformDefinition(e,t,{adaptFormulaString:n}){let r,i;return e.baseline&&(r=n(t,e.baseline)),e.keyValue&&(i=n(t,e.keyValue)),{...e,baseline:r,keyValue:i}},duplicateInDuplicatedSheet(e,t,n,r){let i=e=>r.copyFormulaStringForSheet(t,n,e,`moveReference`);return{...e,keyValue:e.keyValue?i(e.keyValue):e.keyValue,baseline:e.baseline?i(e.baseline):e.baseline}},toStrDefinition:e=>e,getContextCreation(e,t){let n=Sg(e.keyValue);return{...e,dataSource:{type:`range`,dataSets:n?[{dataRange:n,dataSetId:`0`}]:[]},auxiliaryRange:Sg(e.baseline),scorecardKeyValueFormula:e.keyValue,scorecardBaselineFormula:e.baseline}},getDefinitionForExcel:()=>void 0,updateRanges(e,t,n){let r=e.baseline?t.adaptFormulaString(n,e.baseline):e.baseline,i=e.keyValue?t.adaptFormulaString(n,e.keyValue):e.keyValue;return e.baseline===r&&e.keyValue===i?e:{...e,baseline:r,keyValue:i}},getFormulas(e,t,n){let r=[];return n.keyValue&&Dn(n.keyValue)&&r.push(yd.Compile(n.keyValue,t,e)),n.baseline&&Dn(n.baseline)&&r.push(yd.Compile(n.baseline,t,e)),r},getRuntime(e,t,n,r,i,a){let o=``,{scalar:s,range:c}=_g(t.keyValue,e,r),l=e.getLocale();o=s==null?``:yg(s,t.humanize??!0,l);let{scalar:u,range:d}=_g(t.baseline,e,r),{background:f,fontColor:p}=e.getStyleOfSingleCellChart(t.background,c,a),m=vg(u,s,t.baselineMode,t.humanize??!0,l),h=t.baselineMode===`progress`&&mo(m,l)?I(m,l):0,g=t.title;return{title:{...g,text:g.text?e.dynamicTranslate(g.text):``},keyValue:o,keyDescr:t.keyDescr?.text?e.dynamicTranslate(t.keyDescr.text):``,baselineDisplay:m,baselineArrow:xg(u,s,t.baselineMode),baselineColor:bg(u,t.baselineMode,s,t.baselineColorUp,t.baselineColorDown),baselineDescr:t.baselineMode!==`progress`&&t.baselineDescr?.text?e.dynamicTranslate(t.baselineDescr.text):``,fontColor:p,background:f,baselineStyle:{...t.baselineMode!==`percentage`&&t.baselineMode!==`progress`&&d?e.getCellComputedStyle({sheetId:d.sheetId,col:d.zone.left,row:d.zone.top}):void 0,fontSize:t.baselineDescr?.fontSize,align:t.baselineDescr?.align},baselineDescrStyle:{textColor:t.baselineDescr?.color,...t.baselineDescr},keyValueStyle:{...c?e.getCellComputedStyle({sheetId:c.sheetId,col:c.zone.left,row:c.zone.top}):void 0,fontSize:t.keyDescr?.fontSize,align:t.keyDescr?.align},keyValueDescrStyle:{textColor:t.keyDescr?.color,...t.keyDescr},progressBar:t.baselineMode===`progress`?{value:h,color:h>0?t.baselineColorUp:t.baselineColorDown}:void 0}}};function Dg(e,t,n=1){let r=t.getContext(`2d`);if(!r)throw Error(`Unable to retrieve 2D context from canvas`);let i=typeof globalThis.devicePixelRatio==`number`?globalThis.devicePixelRatio:1;t.width=i*e.canvas.width*n,t.height=i*e.canvas.height*n,r.scale(i*n,i*n);let a=e.canvas.width-20;if(r.fillStyle=e.canvas.backgroundColor,r.fillRect(0,0,e.canvas.width,e.canvas.height),e.title){r.font=e.title.style.font,r.fillStyle=e.title.style.color;let t=r.textBaseline;r.textBaseline=`middle`,r.fillText(Vp(r,e.title.text,a-e.title.position.x),e.title.position.x,e.title.position.y),r.textBaseline=t}if(e.baseline&&(r.font=e.baseline.style.font,r.fillStyle=e.baseline.style.color,Hp(r,e.baseline.text,e.baseline.position,e.baseline.style.underline,e.baseline.style.strikethrough,void 0,e.baseline.style.highlightText)),e.baselineArrow&&e.baselineArrow.style.size>0&&Cg){r.save(),r.fillStyle=e.baselineArrow.style.highlight?Yf(e.baselineArrow.style.color,Ze):e.baselineArrow.style.color,r.translate(e.baselineArrow.position.x,e.baselineArrow.position.y);let t=e.baselineArrow.style.size/10;switch(r.scale(t,t),e.baselineArrow.direction){case`down`:r.fill(wg);break;case`up`:r.fill(Tg);break}r.restore()}if(e.baselineDescr){let t=e.baselineDescr;r.font=t.style.font,r.fillStyle=t.style.color,Hp(r,Vp(r,t.text,a-t.position.x),t.position,void 0,void 0,void 0,e.baseline?.style.highlightText)}if(e.key&&(r.font=e.key.style.font,r.fillStyle=e.key.style.color,Hp(r,Vp(r,e.key.text,a-e.key.position.x),e.key.position,e.key.style.underline,e.key.style.strikethrough,void 0,e.key.style.highlightText)),e.keyDescr){let t=e.keyDescr;r.font=e.keyDescr?.style.font??t.style.font,r.fillStyle=t.style.color,Hp(r,Vp(r,t.text,a-t.position.x),t.position,void 0,void 0,void 0,e.key?.style.highlightText)}if(e.progressBar){if(r.fillStyle=e.progressBar.style.backgroundColor,r.beginPath(),r.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width,e.progressBar.dimension.height,e.progressBar.dimension.height/2),r.fill(),r.fillStyle=e.progressBar.style.color,r.beginPath(),e.progressBar.value>0)r.roundRect(e.progressBar.position.x,e.progressBar.position.y,e.progressBar.dimension.width*Math.max(0,Math.min(1,e.progressBar.value)),e.progressBar.dimension.height,e.progressBar.dimension.height/2);else{let t=e.progressBar.dimension.width*Math.max(0,Math.min(1,-e.progressBar.value));r.roundRect(e.progressBar.position.x+e.progressBar.dimension.width-t,e.progressBar.position.y,t,e.progressBar.dimension.height,e.progressBar.dimension.height/2)}r.fill()}}let Og=.05;function kg(e,t){let n=e||``;return t&&n?` `+n:n}function Ag({width:e,height:t},n){return new jg({width:e,height:t},n).computeDesign()}var jg=class{runtime;context;width;height;constructor({width:e,height:t},n){if(this.runtime=n,this.width=e,this.height=t,typeof OffscreenCanvas>`u`)throw Error(`OffscreenCanvas is not supported in this environment`);let r=new globalThis.OffscreenCanvas(e,t).getContext(`2d`);if(!r)throw Error(`Unable to create scorecard measurement context`);this.context=r}computeDesign(){let e={canvas:{width:this.width,height:this.height,backgroundColor:this.backgroundColor}},t=this.getTextStyles(),n=0;if(this.title){let r,i;switch({height:n,width:i}=this.getFullTextDimensions(this.title,t.title.font),this.runtime.title.align){case`center`:r=(this.width-i)/2;break;case`right`:r=this.width-i-20;break;default:r=20}e.title={text:this.title,style:t.title,position:{x:r,y:10+n/2}}}let r=t.baselineArrow?.size??0,{height:i,width:a}=this.getTextDimensions(this.baseline,t.baselineValue.font);this.baseline||(i=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).height);let o=this.getTextDimensions(this.baselineDescr,t.baselineDescr.font).width,s;switch(this.runtime.baselineStyle?.align){case`right`:s=this.width-20-o-a;break;case`left`:s=20+r;break;default:s=(this.width-a-o+r)/2}if(this.baseline&&(e.baseline={text:this.baseline,style:t.baselineValue,position:{x:s,y:this.keyValue?this.height*(1-Og*(this.runtime.progressBar?1:2)):this.height-(this.height-n-i)/2-10}},t.baselineArrow&&!this.runtime.progressBar&&(e.baselineArrow={direction:this.baselineArrow,style:t.baselineArrow,position:{x:e.baseline.position.x-r,y:e.baseline.position.y-(i+r)/2}})),e.baseline&&this.baselineDescr){let n={x:e.baseline.position.x+a,y:e.baseline.position.y};e.baselineDescr={text:this.baselineDescr,style:t.baselineDescr,position:n}}let c=0;this.runtime.progressBar&&(c=this.height*.05,e.progressBar={position:{x:40,y:this.height*(1-2*Og)-i-c},dimension:{height:c,width:this.width-80},value:this.runtime.progressBar.value,style:{color:this.runtime.progressBar.color,backgroundColor:this.secondaryFontColor}});let{width:l,height:u}=this.getFullTextDimensions(this.keyValue,t.keyValue.font),d=this.getTextDimensions(this.keyDescr,t.keyDescr.font).width,f;switch(this.runtime.keyValueStyle?.align){case`right`:f=this.width-20-d-l;break;case`left`:f=20;break;default:f=(this.width-l-d)/2}if(this.keyValue&&(e.key={text:this.keyValue,style:t.keyValue,position:{x:Math.max(20,f),y:this.height*(.5-Og*2)+10/2+(n+u/2)/2}}),e.key&&this.keyDescr){let n={x:e.key.position.x+l,y:e.key.position.y};e.keyDescr={text:this.keyDescr,style:t.keyDescr,position:n}}return e}get title(){return this.runtime.title.text??``}get keyValue(){return this.runtime.keyValue}get keyDescr(){return kg(this.runtime.keyDescr,this.keyValue)}get baseline(){return this.runtime.baselineDisplay}get baselineDescr(){return kg(this.runtime.baselineDescr,this.baseline)}get baselineArrow(){return this.runtime.baselineArrow}get backgroundColor(){return this.runtime.background}get secondaryFontColor(){return Tm(this.backgroundColor)}getTextDimensions(e,t){this.context.font=t;let n=this.context.measureText(e);return{width:n.width,height:n.actualBoundingBoxAscent+n.actualBoundingBoxDescent}}getFullTextDimensions(e,t){this.context.font=t;let n=this.context.measureText(e);return{width:n.width,height:n.fontBoundingBoxAscent+n.fontBoundingBoxDescent}}getTextStyles(){let e=this.runtime.keyValueStyle?.fontSize??32,t=Math.floor(.9*e),n=this.runtime.baselineStyle?.fontSize??16,r=Math.floor(.9*n);return this.runtime.progressBar&&(n/=1.5),{title:{font:Tp(this.runtime.title.fontSize??14,this.runtime.title.bold,this.runtime.title.italic),color:this.runtime.title.color??this.secondaryFontColor},keyValue:{color:this.runtime.keyValueStyle?.textColor||this.runtime.fontColor,font:Tp(e,this.runtime.keyValueStyle?.bold,this.runtime.keyValueStyle?.italic),strikethrough:this.runtime.keyValueStyle?.strikethrough,underline:this.runtime.keyValueStyle?.underline,highlightText:this.runtime.keyHighlight},keyDescr:{color:this.runtime.keyValueDescrStyle?.textColor||this.runtime.fontColor,font:Tp(t,this.runtime.keyValueDescrStyle?.bold,this.runtime.keyValueDescrStyle?.italic),strikethrough:this.runtime.keyValueDescrStyle?.strikethrough,underline:this.runtime.keyValueDescrStyle?.underline,highlightText:this.runtime.keyHighlight},baselineValue:{font:Tp(n,this.runtime.baselineStyle?.bold,this.runtime.baselineStyle?.italic),strikethrough:this.runtime.baselineStyle?.strikethrough,underline:this.runtime.baselineStyle?.underline,color:this.runtime.baselineColor||this.runtime.baselineStyle?.textColor||this.secondaryFontColor,highlightText:this.runtime.baselineHighlight},baselineDescr:{font:Tp(r,this.runtime.baselineDescrStyle?.bold,this.runtime.baselineDescrStyle?.italic),strikethrough:this.runtime.baselineDescrStyle?.strikethrough,underline:this.runtime.baselineDescrStyle?.underline,color:this.runtime.baselineDescrStyle?.textColor??this.secondaryFontColor,highlightText:this.runtime.baselineHighlight},baselineArrow:this.baselineArrow===`neutral`||this.runtime.progressBar?void 0:{size:this.keyValue?.8*n:0,color:this.runtime.baselineColor||this.runtime.baselineStyle?.textColor||this.secondaryFontColor,highlight:this.runtime.baselineHighlight}}}};function Mg(e,t){return Fg(pr(Pg(e),Pg(t)))}function Ng(...e){return Fg(dr(...e.map(Pg)))}function Pg(e){return{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height}}function Fg(e){if(e)return{x:e.left,y:e.top,width:e.right-e.left,height:e.bottom-e.top}}function Ig(e,t,n){return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function Lg(e,t){return{height:t.height*e,width:t.width*e,x:t.x*e,y:t.y*e}}var Rg=class{mutators=[`setZoom`];storeGetters=[`getZoomedRect`,`getZoomedEvent`];zoomLevel=1;setZoom(e){if(isNaN(e)||e>2||e<.5||e===this.zoomLevel)return`noStateChange`;this.zoomLevel=e}getZoomedRect(e){return Lg(this.zoomLevel,e)}getZoomedEvent(e,t){if(t===void 0&&(t=this.getZoomTargetPosition(e,this.zoomLevel)),!t)return{ev:e,clientX:e.clientX,clientY:e.clientY,offsetX:e.offsetX,offsetY:e.offsetY};let n=e.clientX-t.x,r=e.clientY-t.y,i=n/this.zoomLevel,a=r/this.zoomLevel;return{ev:e,clientX:e.clientX-n+i,clientY:e.clientY-r+a,offsetX:i,offsetY:a}}getZoomTargetPosition(e,t){let n=e.target;return!n||!(`classList`in n)||!(n instanceof Element)?null:ee(n,t)}get scrollBarWidth(){return 15/this.zoomLevel}get cssZoom(){return`${this.zoomLevel}`}},zg=class extends k{static template=`o-spreadsheet-ScorecardChart`;props=(0,t.useProps)({chartId:M.string(),isFullScreen:M.boolean().optional()});canvas=t.signal.ref(HTMLCanvasElement);zoomStore;get runtime(){return this.env.model.getters.getChartRuntime(this.props.chartId)}get title(){let e=this.env.model.getters.getChartDefinition(this.props.chartId).title.text;return e?this.env.model.getters.dynamicTranslate(e):``}setup(){this.zoomStore=A(Rg),Vi(this.createChart.bind(this),()=>{let e=this.canvas();if(!e)return[];let t=e.getBoundingClientRect();return[t.width,t.height,this.runtime,e,window.devicePixelRatio]});let e=new ResizeObserver(()=>this.createChart());(0,t.onMounted)(()=>{let t=this.canvas();t&&e.observe(t)}),(0,t.onWillUnmount)(()=>e.disconnect())}config(e,t){return Ag(Lg(1/t,e),this.runtime)}createChart(){let e=this.canvas();if(!e)return;let t=this.zoomStore.zoomLevel;Dg(this.config(e.getBoundingClientRect(),t),e,t)}};let Bg=new O;var Vg=class{mutators=[`notifyUser`,`raiseError`,`askConfirmation`,`updateNotificationCallbacks`];notifyUser=e=>window.alert(e.text);askConfirmation=(e,t,n)=>{window.confirm(e)?t():n?.()};raiseError=(e,t)=>{window.alert(e),t?.()};updateNotificationCallbacks(e){this.notifyUser=e.notifyUser||this.notifyUser,this.raiseError=e.raiseError||this.raiseError,this.askConfirmation=e.askConfirmation||this.askConfirmation}},Hg=class{mutators=[`setSmallThreshhold`];_isSmallCallback=()=>!1;get isSmall(){return this._isSmallCallback()}setSmallThreshhold(e){this._isSmallCallback=e}},U=class extends ei{mutators=[`open`,`replace`,`toggle`,`close`,`changePanelSize`,`resetPanelSize`,`togglePinPanel`,`togglePinnedSidePanel`,`closeMainPanel`,`changeSpreadsheetWidth`,`toggleCollapsePanel`];mainPanel=void 0;secondaryPanel;availableWidth=0;screenWidthStore=this.get(Hg);get isMainPanelOpen(){return this.mainPanel&&this.mainPanel.componentTag?this.computeState(this.mainPanel).isOpen:!1}get isSecondaryPanelOpen(){return this.secondaryPanel&&this.secondaryPanel.componentTag?this.computeState(this.secondaryPanel).isOpen:!1}get mainPanelProps(){return this.mainPanel?this.getPanelProps(this.mainPanel):void 0}get mainPanelKey(){return this.mainPanel?this.getPanelKey(this.mainPanel):void 0}get secondaryPanelProps(){return this.secondaryPanel?this.getPanelProps(this.secondaryPanel):void 0}get secondaryPanelKey(){return this.secondaryPanel?this.getPanelKey(this.secondaryPanel):void 0}get totalPanelSize(){return(this.mainPanel?.size||0)+(this.secondaryPanel?.size??0)}getPanelProps(e){let t=this.computeState(e);return t.isOpen?(e.currentPanelProps=t.props??e.currentPanelProps,t.props??{}):{}}getPanelKey(e){let t=this.computeState(e);if(t.isOpen)return t.key}open(e,t={}){if(this.screenWidthStore.isSmall)return;let n={currentPanelProps:t,componentTag:e,size:350},r=this.computeState(n);if(!r.isOpen)return;if(!this.mainPanel||!this.mainPanel.isPinned||this.mainPanelKey===r.key){this._openPanel(`mainPanel`,n,r);return}let i=this.mainPanel.isCollapsed?350:this.mainPanel.size;if(!this.secondaryPanel&&i+350>this.availableWidth){this.get(Vg).notifyUser({sticky:!1,type:`warning`,text:N(`The window is too small to display multiple side panels.`)});return}this._openPanel(`secondaryPanel`,n,r)}replace(e,t,n={}){let r={currentPanelProps:n,componentTag:e,size:350},i=this.computeState(r);if(!i.isOpen)return;let a=()=>{this.mainPanel?.isCollapsed&&this.toggleCollapsePanel(`mainPanel`)},o=this.mainPanelKey===i.key,s=this.secondaryPanelKey===i.key;if(o&&this.secondaryPanel){this.close(),a();return}if(s){this.closeMainPanel(),this.togglePinPanel(),a();return}let c=this.mainPanelKey===t?`mainPanel`:`secondaryPanel`;this._openPanel(c,r,i)}_openPanel(e,t,n){let r=this[e];r&&t.componentTag!==r.componentTag&&r.currentPanelProps?.onCloseSidePanel?.(),this[e]={currentPanelProps:n.props??{},componentTag:t.componentTag,size:r?.size||350,isCollapsed:r?.isCollapsed||!1,isPinned:r&&`isPinned`in r?r.isPinned:!1},this[e].isCollapsed&&this.toggleCollapsePanel(e)}toggle(e,t={}){let n=this.mainPanel?.isPinned?this.secondaryPanel:this.mainPanel;n&&e===n.componentTag?this.close():this.open(e,t)}close(){if(this.mainPanel?.isPinned){this.secondaryPanel&&=(this.secondaryPanel.currentPanelProps.onCloseSidePanel?.(),void 0);return}this.mainPanel?.currentPanelProps.onCloseSidePanel?.(),this.mainPanel=void 0}closeMainPanel(){this.mainPanel?.currentPanelProps.onCloseSidePanel?.(),this.mainPanel=this.secondaryPanel||void 0,this.secondaryPanel=void 0}changePanelSize(e,t){let n=this[e];if(!n||`isCollapsed`in n&&n.isCollapsed)return;t=Math.max(t,350);let r=e===`mainPanel`?this.secondaryPanel?.size||0:this.mainPanel?.size||0;t>this.availableWidth-r&&(e===`mainPanel`&&this.secondaryPanel&&(this.secondaryPanel.size=Math.max(this.availableWidth-t,350),r=this.secondaryPanel.size),t=Math.max(this.availableWidth-r,350)),n.size=t}resetPanelSize(e){this[e]&&(this[e].size=350)}togglePinPanel(){this.mainPanel&&(this.mainPanel.isPinned=!this.mainPanel.isPinned,!this.mainPanel.isPinned&&this.secondaryPanel&&(this.secondaryPanel?.currentPanelProps.onCloseSidePanel?.(),this.mainPanel=this.secondaryPanel,this.secondaryPanel=void 0))}togglePinnedSidePanel(e,t={}){if(this.mainPanel?.componentTag===e&&this.isMainPanelOpen){this.closeMainPanel();return}if(this.secondaryPanel?.componentTag===e&&this.isSecondaryPanelOpen){this.secondaryPanel?.currentPanelProps.onCloseSidePanel?.(),this.secondaryPanel=void 0;return}this.open(e,t),this.mainPanel?.isPinned||this.togglePinPanel()}toggleCollapsePanel(e){let t=this[e];t&&(t.isCollapsed?(t.isCollapsed=!1,this.changePanelSize(e,350)):(t.isCollapsed=!0,t.size=45))}computeState({componentTag:e,currentPanelProps:t}){let n=Bg.get(e).computeState,r=n?n(this.getters,t):{isOpen:!0,props:t};return r.isOpen?{...r,key:r.key||e}:r}changeSpreadsheetWidth(e){this.availableWidth=e-150,this.secondaryPanel&&e-this.totalPanelSize<150&&(this.secondaryPanel?.currentPanelProps.onCloseSidePanel?.(),this.secondaryPanel=void 0),this.mainPanel&&e-this.totalPanelSize<150&&(this.mainPanel.size=Math.max(e-150,350))}};let Ug=new O;function Wg(e){return 20+120*Math.exp(-.035*(e-1))}var Gg=class{top;bottom;left;right;offsetX;offsetY;canScrollVertically;canScrollHorizontally;viewportWidth;viewportHeight;boundaryLeftX;boundaryTopY;getters;sheetId;boundaries;getFooterSize;constructor(e){if(e.sizeInGrid.width<0||e.sizeInGrid.height<0)throw Error(`Viewport size cannot be negative`);this.getters=e.getters,this.sheetId=e.sheetId,this.boundaries=e.boundaries,this.viewportWidth=e.sizeInGrid.height&&e.sizeInGrid.width,this.viewportHeight=e.sizeInGrid.width&&e.sizeInGrid.height,this.top=e.boundaries.top,this.bottom=e.boundaries.bottom,this.left=e.boundaries.left,this.right=e.boundaries.right,this.offsetX=e.offsets.x,this.offsetY=e.offsets.y,this.canScrollVertically=e.canScrollVertically,this.canScrollHorizontally=e.canScrollHorizontally,this.getFooterSize=e.getFooterSize,this.boundaryLeftX=this.getters.getColDimensions(this.sheetId,this.boundaries.left).start,this.boundaryTopY=this.getters.getRowDimensions(this.sheetId,this.boundaries.top).start,this.adjustViewportOffsetX(),this.adjustViewportOffsetY()}getMaxSize(){let e=this.getters.findLastVisibleColRowIndex(this.sheetId,`COL`,{first:this.boundaries.left,last:this.boundaries.right}),t=this.getters.findLastVisibleColRowIndex(this.sheetId,`ROW`,{first:this.boundaries.top,last:this.boundaries.bottom}),{end:n}=this.getters.getColDimensions(this.sheetId,e),{end:r}=this.getters.getRowDimensions(this.sheetId,t),i=n-this.boundaryLeftX;this.canScrollHorizontally&&(i=Math.max(i,this.viewportWidth));let a=r-this.boundaryTopY;return this.canScrollVertically&&(a=Math.max(a,this.viewportHeight),r+this.getFooterSize()>a&&this.viewportHeight>this.getFooterSize()&&(a+=this.getFooterSize())),{width:i,height:a}}getColIndex(e){return this.searchHeaderIndex(`COL`,e+this.snapCorrection.x,this.left)}getRowIndex(e){return this.searchHeaderIndex(`ROW`,e+this.snapCorrection.y,this.top)}repositionViewport(e){let t=this.sheetId,n=this.getters.getMainCellPosition({sheetId:t,...e}),{col:r,row:i}=this.getters.getNextVisibleCellPosition(n);_r(r,this.boundaries.top,this.boundaries)&&this.repositionViewportX(r),_r(this.boundaries.left,i,this.boundaries)&&this.repositionViewportY(i)}repositionViewportX(e){let t=this.sheetId,{start:n,end:r}=this.getters.getColDimensions(t,e);this.offsetX+this.viewportWidth+this.boundaryLeftX<r?this.offsetX=r-this.viewportWidth-this.boundaryLeftX:this.offsetX+this.boundaryLeftX>n&&(this.offsetX=n-this.boundaryLeftX),this.adjustViewportZoneX()}repositionViewportY(e){let t=this.sheetId,{start:n,end:r}=this.getters.getRowDimensions(t,e);this.offsetY+this.viewportHeight+this.boundaryTopY<r?this.offsetY=r-this.viewportHeight-this.boundaryTopY:this.offsetY+this.boundaryTopY>n&&(this.offsetY=n-this.boundaryTopY),this.adjustViewportZoneY()}willNewOffsetScrollViewport(e,t){return this.canScrollHorizontally&&this.offsetX!==e||this.canScrollVertically&&this.offsetY!==t}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}isZoneVisible(e){return pr(e,this)!==void 0}getVisibleRect(e){let t=pr(e,this),n=this.snapCorrection.x,r=this.snapCorrection.y;if(t)return{x:this.getters.getColRowOffset(`COL`,this.left,t.left,this.sheetId)-(this.left===t.left?0:n),y:this.getters.getColRowOffset(`ROW`,this.top,t.top,this.sheetId)-(this.top===t.top?0:r),width:Math.min(this.getters.getColRowOffset(`COL`,t.left,t.right+1,this.sheetId)-(this.left===t.left?n:0),this.viewportWidth),height:Math.min(this.getters.getColRowOffset(`ROW`,t.top,t.bottom+1,this.sheetId)-(this.top===t.top?r:0),this.viewportHeight)}}getFullRect(e){let t=pr(e,this.boundaries),n=this.snapCorrection.x,r=this.snapCorrection.y;if(t){let t=this.getters.getColRowOffset(`COL`,this.left,e.left,this.sheetId),i=this.getters.getColRowOffset(`ROW`,this.top,e.top,this.sheetId),a=this.getters.getColRowOffset(`COL`,e.left,e.right+1,this.sheetId),o=this.getters.getColRowOffset(`ROW`,e.top,e.bottom+1,this.sheetId);return{x:t-n,y:i-r,width:a,height:o}}}isVisible(e,t){return t<=this.bottom&&t>=this.top&&e>=this.left&&e<=this.right&&!this.getters.isColHidden(this.sheetId,e)&&!this.getters.isRowHidden(this.sheetId,t)}searchHeaderIndex(e,t,n=0){if(this.viewportWidth<=0||this.viewportHeight<=0)return-1;let r=this.sheetId,i=this.getters.getNumberHeaders(r,e),a=n,o=i;for(;a<=o&&a!==i&&o!==-1;){let i=Math.floor((a+o)/2),s=this.getters.getColRowOffset(e,n,i,this.sheetId),c=this.getters.isHeaderHidden(r,e,i)?0:this.getters.getHeaderSize(r,e,i);if(t>=s&&t<s+c)return i;t>=s+c?a=i+1:o=i-1}return-1}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){let{width:e}=this.getMaxSize();this.viewportWidth+this.offsetX>e&&(this.offsetX=Math.max(0,e-this.viewportWidth))}this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){let{height:e}=this.getMaxSize();this.viewportHeight+this.offsetY>e&&(this.offsetY=Math.max(0,e-this.viewportHeight))}this.adjustViewportZoneY()}adjustViewportZoneX(){this.left=this.searchHeaderIndex(`COL`,this.offsetX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex(`COL`,Math.max(this.viewportWidth+this.snapCorrection.x-.1),this.left)),this.viewportWidth&&(this.left===-1&&(this.left=this.boundaries.left),this.right===-1&&(this.right=this.boundaries.right))}adjustViewportZoneY(){this.top=this.searchHeaderIndex(`ROW`,this.offsetY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex(`ROW`,Math.max(this.viewportHeight+this.snapCorrection.y-.1,0),this.top)),this.viewportHeight&&(this.top===-1&&(this.top=this.boundaries.top),this.bottom===-1&&(this.bottom=this.boundaries.bottom))}get snapCorrection(){return{x:Math.abs(this.offsetX-this.getters.getColRowOffset(`COL`,this.boundaries.left,Math.max(0,this.left),this.sheetId)),y:Math.abs(this.offsetY-this.getters.getColRowOffset(`ROW`,this.boundaries.top,Math.max(0,this.top),this.sheetId))}}},Kg=class{getters;viewports={};gridOffsetX=0;gridOffsetY=0;paneDivision;sheetViewWidth;sheetViewHeight;getZoomLevel;getFooterSize;zoneToDisplay;constructor(e){this.getters=e.getters,this.paneDivision=e.paneDivision,this.sheetViewWidth=e.sheetViewWidth,this.sheetViewHeight=e.sheetViewHeight,this.getZoomLevel=e.getZoomLevel,this.getFooterSize=e.getFooterSize,this.zoneToDisplay=e.zoneToDisplay}changeViewportArgs(e){for(let t in e)this[t]=e[t];for(let e of this.getters.getSheetIds())this.resetViewports(e)}getColIndex(e,t){return Math.max(...this.getPositionedViewports(e).map(({viewport:e,viewportX:n})=>t<n||t>n+e.viewportWidth?-1:e.getColIndex(t-n)))}getRowIndex(e,t){return Math.max(...this.getPositionedViewports(e).map(({viewport:e,viewportY:n})=>t<n||t>n+e.viewportHeight?-1:e.getRowIndex(t-n)))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getGridOffset(){return{x:this.gridOffsetX,y:this.gridOffsetY}}getSheetScrollInfo(e){let t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getSheetViewVisibleCols(e){let t=this.getSubViewports(e).map(e=>e);return[...new Set(t.map(e=>C(e.left,e.right+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`COL`,t))}getSheetViewVisibleRows(e){let t=this.getSubViewports(e).map(e=>e);return[...new Set(t.map(e=>C(e.top,e.bottom+1)).flat())].filter(t=>t>=0&&!this.getters.isHeaderHidden(e,`ROW`,t))}getVisibleCellPositions(e){let t=this.getSheetViewVisibleCols(e),n=this.getSheetViewVisibleRows(e),r=[];for(let i of t)for(let t of n){let n={sheetId:e,col:i,row:t},a=this.getters.getMainCellPosition(n);a.row!==t||a.col!==i||r.push(n)}return r}getMainViewportRect(e){let{width:t,height:n}=this.getMainInternalViewport(e).getMaxSize(),{paneWidth:r,paneHeight:i}=this.getPanesDimensions(e);return{x:r,y:i,width:t,height:n}}getMaximumSheetOffset(e){let{width:t,height:n}=this.getMainViewportRect(e),r=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-r.viewportWidth),maxOffsetY:Math.max(0,n-r.viewportHeight)}}getColRowOffsetInViewport(e,t,n,r){if(r<n)return-this.getColRowOffsetInViewport(e,t,r,n);let i=t===`COL`?this.getSheetViewVisibleCols(e):this.getSheetViewVisibleRows(e),a=i.findIndex(e=>n>=e),o=i.findIndex(e=>r<=e);o=o===-1?i.length:o;let s=i.slice(a,o),c=0;for(let n of s)c+=this.getters.getHeaderSize(e,t,n);return c*this.getZoomLevel()}isVisibleInViewport({sheetId:e,col:t,row:n}){return this.getSubViewports(e).some(e=>e.isVisible(t,n))}isZoneVisibleInViewport(e,t){return this.getSubViewports(e).some(e=>e.isZoneVisible(t))}getEdgeScrollCol(e,t,n,r){let i=!1,a=0,o=0,{xSplit:s}=this.getPaneDivisions(e),{width:c}=this.getSheetViewDimension(),{x:l}=this.getMainViewportCoordinates(e),u=this.getSheetScrollInfo(e).scrollX;return t>c?(i=!0,o=Wg(t-c),a=1):t<l&&r>=l&&u>0?(i=!0,o=Wg(l-t),a=-1):s&&n<l&&t>l&&(i=!0,o=Wg(t),a=`reset`),{canEdgeScroll:i,direction:a,delay:o}}getEdgeScrollRow(e,t,n,r){let i=!1,a=0,o=0,{ySplit:s}=this.getPaneDivisions(e),{height:c}=this.getSheetViewDimension(),{y:l}=this.getMainViewportCoordinates(e),u=this.getSheetScrollInfo(e).scrollY;return t>c?(i=!0,o=Wg(t-c),a=1):t<l&&r>=l&&u>0?(i=!0,o=Wg(l-t),a=-1):s&&n<l&&t>l&&(i=!0,o=Wg(t),a=`reset`),{canEdgeScroll:i,direction:a,delay:o}}getVisibleRect(e,t){let n=this.getVisibleRectWithoutHeaders(e,t);return{...n,x:n.x+this.gridOffsetX,y:n.y+this.gridOffsetY}}getVisibleRectWithZoom(e,t){let n=this.getZoomLevel(),r=this.getVisibleRectWithoutHeaders(e,t);return r.width*=n,r.height*=n,r.x=r.x*n+this.gridOffsetX*n,r.y=r.y*n+this.gridOffsetY*n,r}getVisibleRectWithoutHeaders(e,t){return this.mapViewportsToRect(e,e=>e.getVisibleRect(t))}getRect(e,t){let n=this.mapViewportsToRect(e,e=>e.getFullRect(t));return{...n,x:n.x+this.gridOffsetX,y:n.y+this.gridOffsetY}}getRectWithoutHeaders(e,t){return this.mapViewportsToRect(e,e=>e.getFullRect(t))}getMainViewportCoordinates(e){let{paneWidth:t,paneHeight:n}=this.getPanesDimensions(e);return{x:t,y:n}}getColDimensionsInViewport(e,t){let{top:n}=this.getMainInternalViewport(e),r={left:t,right:t,top:n,bottom:n},{x:i,width:a}=this.getVisibleRect(e,r),o=i-this.gridOffsetX;return{start:o,size:a,end:o+a}}getRowDimensionsInViewport(e,t){let{left:n}=this.getMainInternalViewport(e),r={left:0,right:n,top:t,bottom:t},{y:i,height:a}=this.getVisibleRect(e,r),o=i-this.gridOffsetY;return{start:o,size:a,end:o+a}}getAllSheetViewportsZonesAndRect(e){return this.getPositionedViewports(e).map(({viewport:e,viewportX:t,viewportY:n})=>({zone:e,rect:{x:t+this.gridOffsetX,y:n+this.gridOffsetY,...e.getMaxSize()}}))}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getPanesDimensions(e){let t=this.getViewportZones(e),n=0;if(t.bottomLeft){let r=this.getters.getColDimensions(e,t.bottomLeft.left).start;n=this.getters.getColDimensions(e,t.bottomLeft.right).end-r}let r=0;if(t.topRight){let n=this.getters.getRowDimensions(e,t.topRight.top).start;r=this.getters.getRowDimensions(e,t.topRight.bottom).end-n}return{paneWidth:n,paneHeight:r}}getPositionedViewports(e){this.ensureMainViewportExist(e);let t=this.viewports[e],{paneWidth:n,paneHeight:r}=this.getPanesDimensions(e),i=[];return t.topLeft&&i.push({viewport:t.topLeft,viewportX:0,viewportY:0}),t.topRight&&i.push({viewport:t.topRight,viewportX:n,viewportY:0}),t.bottomLeft&&i.push({viewport:t.bottomLeft,viewportX:0,viewportY:r}),i.push({viewport:t.bottomRight,viewportX:n,viewportY:r}),i}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(w)}checkPositiveDimension(e){return!(e.width<0||e.height<0)}checkValuesAreDifferent(e){let{height:t,width:n}=this.getSheetViewDimension();return!(e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===n&&e.height===t)}checkScrollingDirection(e,{offsetX:t,offsetY:n}){let r=this.getMainInternalViewport(e);return!(!r.canScrollHorizontally&&t>0||!r.canScrollVertically&&n>0)}checkIfViewportsWillChange(e,{offsetX:t,offsetY:n}){let{maxOffsetX:r,maxOffsetY:i}=this.getMaximumSheetOffset(e);return!!this.getSubViewports(e).some(e=>e.willNewOffsetScrollViewport(S(t,0,r),S(n,0,i)))}getMainViewport(e){let t=this.getMainInternalViewport(e);return{top:t.top,left:t.left,bottom:t.bottom,right:t.right}}getMainInternalViewport(e){return this.ensureMainViewportExist(e),this.viewports[e].bottomRight}cleanViewports(){let e={};for(let t of this.getters.getSheetIds())e[t]=this.viewports[t];this.viewports=e}resizeSheetView(e){this.sheetViewHeight=e.height,this.sheetViewWidth=e.width,this.gridOffsetX=e.gridOffsetX||0,this.gridOffsetY=e.gridOffsetY||0,this.recomputeViewports()}recomputeViewports(){for(let e of this.getters.getSheetIds())this.resetViewports(e)}setSheetViewOffset(e,t,n){let{maxOffsetX:r,maxOffsetY:i}=this.getMaximumSheetOffset(e);this.getSubViewports(e).forEach(e=>e.setViewportOffset(S(t,0,r),S(n,0,i)))}getViewportOffset(e){return{x:this.viewports[e]?.bottomRight.offsetX||0,y:this.viewports[e]?.bottomRight.offsetY||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;let{paneWidth:t,paneHeight:n}=this.getPanesDimensions(e),r=Math.min(t,this.sheetViewWidth),i=Math.min(n,this.sheetViewHeight),a=Math.max(this.sheetViewWidth-t,0),o=Math.max(this.sheetViewHeight-n,0),{xRatio:s,yRatio:c}=this.getFrozenSheetViewRatio(e),l=s<1,u=c<1,d=this.getViewportOffset(e),f={},p=this.getViewportZones(e),m=p.topLeft;m&&(f.topLeft=new Gg({getters:this.getters,sheetId:e,boundaries:m,sizeInGrid:{width:r,height:i},canScrollHorizontally:!1,canScrollVertically:!1,offsets:{x:0,y:0},getFooterSize:()=>0}));let h=p.topRight;h&&(f.topRight=new Gg({getters:this.getters,sheetId:e,boundaries:h,sizeInGrid:{width:a,height:i},canScrollHorizontally:l,canScrollVertically:!1,offsets:{x:l?d.x:0,y:0},getFooterSize:()=>0}));let g=p.bottomLeft;g&&(f.bottomLeft=new Gg({getters:this.getters,sheetId:e,boundaries:g,sizeInGrid:{width:r,height:o},canScrollHorizontally:!1,canScrollVertically:u,offsets:{x:0,y:u?d.y:0},getFooterSize:this.getFooterSize}));let _=p.bottomRight;f.bottomRight=new Gg({getters:this.getters,sheetId:e,boundaries:_,sizeInGrid:{width:a,height:o},canScrollHorizontally:l,canScrollVertically:u,offsets:{x:l?d.x:0,y:u?d.y:0},getFooterSize:this.getFooterSize}),this.viewports[e]=f}reorganizeViewportZones(e,t){let n=Object.values(t).filter(e=>e!==void 0);if(n.length===1)return{bottomRight:n[0]};if(n.length===4)return t;if(n.length===2){if(t.bottomRight&&(t.topRight||t.bottomLeft))return t;let{topLeft:e,topRight:n,bottomLeft:r}=t;if(e&&n)return{bottomLeft:e,bottomRight:n};if(e&&r)return{topRight:e,bottomRight:r}}throw Error(`ViewportCollection: Malformed viewports for ${e}`)}getViewportZones(e){let{xSplit:t,ySplit:n}=this.getPaneDivisions(e),r=this.getters.getNumberCols(e),i=this.getters.getNumberRows(e),a=this.zoneToDisplay?pr(this.zoneToDisplay,this.getters.getSheetZone(e)):void 0,o={};if(t&&n){let e={left:0,right:t-1,top:0,bottom:n-1};o.topLeft=a?pr(e,a):e}if(n){let e={left:t,right:r-1,top:0,bottom:n-1};o.topRight=a?pr(e,a):e}if(t){let e={left:0,right:t-1,top:n,bottom:i-1};o.bottomLeft=a?pr(e,a):e}let s={left:t,right:r-1,top:n,bottom:i-1};return o.bottomRight=a?pr(s,a):s,this.reorganizeViewportZones(e,o)}refreshViewport(e,t){this.getSubViewports(e).forEach(e=>{e.adjustViewportZone(),e.repositionViewport(t)})}getColIndexLeftOfMainViewport(e,t){if(t>=0)return-1;let n=this.getMainViewport(e).left,r=-this.getSheetScrollInfo(e).scrollX-this.getters.getColRowOffset(`COL`,n,0,e);for(;t<r;n--)r-=this.getters.getColSize(e,n-1);return Math.max(n,0)}getRowIndexTopOfMainViewport(e,t){if(t>=0)return-1;let n=this.getMainViewport(e).top,r=-this.getSheetScrollInfo(e).scrollY-this.getters.getColRowOffset(`ROW`,n,0,e);for(;t<r;n--)r-=this.getters.getRowSize(e,n-1);return Math.max(n,0)}getVisibleFigures(e){let t=[],n=this.getters.getFigures(e),{scrollX:r,scrollY:i}=this.getSheetScrollInfo(e),{x:a,y:o}=this.getMainViewportCoordinates(e),{width:s,height:c}=this.getSheetViewDimensionWithHeaders();for(let l of n){let n=this.getFigureUI(e,l),{x:u,y:d}=n;u>=a&&(u+l.width<r+a||u>s+r+a)||d>=o&&(d+l.height<i+o||d>c+i+o)||t.push(n)}return t}getFigureUI(e,t){let n=t.offset.x+this.getters.getColDimensions(e,t.col).start,r=t.offset.y+this.getters.getRowDimensions(e,t.row).start;return{...t,x:n,y:r}}getPositionAnchorOffset(e,t){let{scrollX:n,scrollY:r}=this.getSheetScrollInfo(e),i=t.x-n,a=t.y-r,o=i>=0?this.getColIndex(e,i):this.getColIndexLeftOfMainViewport(e,i);o<0&&(o=this.getMainInternalViewport(e).searchHeaderIndex(`COL`,i));let s=a>=0?this.getRowIndex(e,a):this.getRowIndexTopOfMainViewport(e,a);s<0&&(s=this.getMainInternalViewport(e).searchHeaderIndex(`ROW`,a));let{x:c,y:l}=this.getRect(e,D({col:o,row:s}));return{col:o,row:s,offset:{x:Math.max(i-c+this.gridOffsetX,0),y:Math.max(a-l+this.gridOffsetY,0)}}}isPixelPositionVisible(e,t){let{scrollX:n,scrollY:r}=this.getSheetScrollInfo(e),{x:i,y:a}=this.getMainViewportCoordinates(e),{width:o,height:s}=this.getSheetViewDimension();return!(t.x>=i&&(t.x<i+n||t.x>o+n+i)||t.y>=a&&(t.y<a+r||t.y>s+r+a))}getFrozenSheetViewRatio(e){let{paneWidth:t,paneHeight:n}=this.getPanesDimensions(e),r=this.sheetViewWidth+this.gridOffsetX,i=this.sheetViewHeight+this.gridOffsetY;return{xRatio:t/r,yRatio:n/i}}mapViewportsToRect(e,t){let n=1/0,r=1/0,i=0,a=0,o=!1;for(let s of this.getPositionedViewports(e)){let e=t(s.viewport);e&&(e.x+=s.viewportX,e.y+=s.viewportY,o=!0,n=Math.min(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x+e.width),a=Math.max(a,e.y+e.height))}return o?{x:n,y:r,width:i-n,height:a-r}:{x:0,y:0,width:0,height:0}}getGridOffsetX(){return this.gridOffsetX}getGridOffsetY(){return this.gridOffsetY}getPaneDivisions(e){return this.paneDivision[e]||{xSplit:0,ySplit:0}}setPaneDivision(e,t){this.paneDivision[e]=t}},W=class extends ei{mutators=[`setViewportOffset`,`resizeSheetView`,`shiftViewportDown`,`shiftViewportUp`,`scrollToCell`,`setDisplayedSheetId`,`setViewportArgs`,`rebuildViewports`];storeGetters=[`getCartesianCoordinates`];zoomStore=this.get(Rg);getHeaderDimensionsCallback=this.getters.getHeaderDimensions;getFooterSizeCallback=this.getFooterSize.bind(this);getZoomLevelCallback=()=>this.zoomStore.zoomLevel;zoneToDisplay=void 0;viewports=new Kg({getters:this.buildViewportGetters(this.getHeaderDimensionsCallback),paneDivision:this.getPaneDivisions(),sheetViewHeight:ft(),sheetViewWidth:ft(),getZoomLevel:this.getZoomLevelCallback,getFooterSize:this.getFooterSizeCallback});sheetsWithDirtyViewports=new Set;displayedSheetId=this.model.getters.getActiveSheetId();constructor(e){super(e),this.viewports.resetViewports(this.displayedSheetId)}handle(e){if(Nd.has(e.type))for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);switch(e.type){case`UNDO`:case`REDO`:this.viewports.cleanViewports();for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e),this.syncPaneDivision(e);break;case`UNFREEZE_ROWS`:case`UNFREEZE_COLUMNS`:case`FREEZE_COLUMNS`:case`FREEZE_ROWS`:case`UNFREEZE_COLUMNS_ROWS`:case`REMOVE_COLUMNS_ROWS`:case`ADD_COLUMNS_ROWS`:this.sheetsWithDirtyViewports.add(e.sheetId),this.syncPaneDivision(e.sheetId);break;case`DUPLICATE_SHEET`:this.sheetsWithDirtyViewports.add(e.sheetIdTo),this.syncPaneDivision(e.sheetIdTo);break;case`REMOVE_TABLE`:case`UPDATE_TABLE`:case`UPDATE_FILTER`:case`RESIZE_COLUMNS_ROWS`:case`HIDE_COLUMNS_ROWS`:case`UNHIDE_COLUMNS_ROWS`:case`UNGROUP_HEADERS`:case`GROUP_HEADERS`:case`FOLD_HEADER_GROUP`:case`UNFOLD_HEADER_GROUP`:case`FOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_HEADER_GROUPS_IN_ZONE`:case`UNFOLD_ALL_HEADER_GROUPS`:case`FOLD_ALL_HEADER_GROUPS`:this.sheetsWithDirtyViewports.add(e.sheetId);break;case`UPDATE_CELL`:case`SET_FORMATTING`:for(let e of this.getters.getSheetIds())this.sheetsWithDirtyViewports.add(e);break;case`DELETE_SHEET`:this.viewports.cleanViewports(),this.sheetsWithDirtyViewports.delete(e.sheetId);break}}finalize(){for(let e of this.sheetsWithDirtyViewports)this.viewports.resetViewports(e);this.sheetsWithDirtyViewports=new Set,this.setViewports()}setViewports(){let e=this.getters.getSheetIds();for(let t of e)this.viewports.viewports[t]?.bottomRight||this.viewports.resetViewports(t)}syncPaneDivision(e){this.viewports.setPaneDivision(e,this.getters.getPaneDivisions(e))}setDisplayedSheetId(e){this.displayedSheetId=e,this.viewports.resetViewports(e)}setViewportOffset(e){let t=this.displayedSheetId;if(!this.viewports.checkScrollingDirection(t,e)||!this.viewports.checkIfViewportsWillChange(t,e))return`noStateChange`;this.viewports.setSheetViewOffset(t,e.offsetX,e.offsetY)}resizeSheetView(e){if(!this.viewports.checkValuesAreDifferent(e)||!this.viewports.checkPositiveDimension(e))return`noStateChange`;this.viewports.resizeSheetView(e)}shiftViewportDown(){let e=this.displayedSheetId,{top:t,viewportHeight:n,boundaryTopY:r}=this.viewports.getMainInternalViewport(e),i=this.getters.getRowDimensions(e,t);this.shiftVertically(i.start+n-r)}shiftViewportUp(){let e=this.displayedSheetId,{top:t,viewportHeight:n,boundaryTopY:r}=this.viewports.getMainInternalViewport(e),i=this.getters.getRowDimensions(e,t);this.shiftVertically(i.end-r-n)}scrollToCell(e,t,n){this.sheetsWithDirtyViewports.has(e)||this.viewports.refreshViewport(e,{col:t,row:n})}get sheetViewDimensionWithHeaders(){return this.viewports.getSheetViewDimensionWithHeaders()}get sheetViewDimension(){return this.viewports.getSheetViewDimension()}get gridOffset(){return this.viewports.getGridOffset()}getCartesianCoordinates(e,t){return[this.viewports.getColIndex(this.displayedSheetId,e),this.viewports.getRowIndex(this.displayedSheetId,t)]}get activeMainViewport(){return this.viewports.getMainViewport(this.displayedSheetId)}get activeSheetScrollInfo(){return this.viewports.getSheetScrollInfo(this.displayedSheetId)}get visibleCols(){return this.viewports.getSheetViewVisibleCols(this.displayedSheetId)}get visibleRows(){return this.viewports.getSheetViewVisibleRows(this.displayedSheetId)}get visibleCellPositions(){return this.viewports.getVisibleCellPositions(this.displayedSheetId)}get mainViewportRect(){return this.viewports.getMainViewportRect(this.displayedSheetId)}get maximumSheetOffset(){return this.viewports.getMaximumSheetOffset(this.displayedSheetId)}get mainViewportCoordinates(){return this.viewports.getMainViewportCoordinates(this.displayedSheetId)}get visibleFigures(){return this.viewports.getVisibleFigures(this.displayedSheetId)}shiftVertically(e){let t=this.displayedSheetId,{top:n}=this.viewports.getMainInternalViewport(t),{scrollX:r}=this.activeSheetScrollInfo;this.viewports.setSheetViewOffset(t,r,e);let{anchor:i}=this.getters.getSelection();if(i.cell.row>=this.getters.getPaneDivisions(t).ySplit){let e=this.viewports.getMainInternalViewport(t).top-n;this.model.selection.selectCell(i.cell.col,i.cell.row+e)}}getPaneDivisions(){let e={};for(let t of this.getters.getSheetIds())e[t]=this.getters.getPaneDivisions(t);return e}getFooterSize(){return this.getters.isReadonly()?0:46}setViewportArgs(e){let t=!1;e.getHeaderDimensions&&(t=!0,this.getHeaderDimensionsCallback=e.getHeaderDimensions),e.getFooterSize&&(t=!0,this.getFooterSizeCallback=e.getFooterSize),e.zoneToDisplay&&!T(e.zoneToDisplay,this.zoneToDisplay)&&(t=!0,this.zoneToDisplay=e.zoneToDisplay),t&&this.rebuildViewports()}rebuildViewports(){this.viewports.changeViewportArgs({getters:this.buildViewportGetters(this.getHeaderDimensionsCallback),paneDivision:this.getPaneDivisions(),sheetViewHeight:this.viewports.getSheetViewDimension().height,sheetViewWidth:this.viewports.getSheetViewDimension().width,getZoomLevel:this.getZoomLevelCallback,getFooterSize:this.getFooterSizeCallback,zoneToDisplay:this.zoneToDisplay})}buildViewportGetters(e){return{findLastVisibleColRowIndex:this.getters.findLastVisibleColRowIndex,isReadonly:this.getters.isReadonly,getMainCellPosition:this.getters.getMainCellPosition,getNextVisibleCellPosition:this.getters.getNextVisibleCellPosition,isColHidden:this.getters.isColHidden,isRowHidden:this.getters.isRowHidden,isHeaderHidden:this.getters.isHeaderHidden,getNumberHeaders:this.getters.getNumberHeaders,getSheetIds:this.getters.getSheetIds,tryGetSheet:this.getters.tryGetSheet,getNumberCols:this.getters.getNumberCols,getNumberRows:this.getters.getNumberRows,getSheetZone:this.getters.getSheetZone,getFigures:this.getters.getFigures,getColDimensions:(t,n)=>e(t,`COL`,n),getRowDimensions:(t,n)=>e(t,`ROW`,n),getHeaderSize:(t,n,r)=>n===`COL`?e(t,`COL`,r).size:e(t,`ROW`,r).size,getColSize:(t,n)=>e(t,`COL`,n).size,getRowSize:(t,n)=>e(t,`ROW`,n).size,getColRowOffset:(t,n,r,i)=>e(i,t,r).start-e(i,t,n).start}}};function qg(e,t,n){let r=e.model.getters.getFigure(t,n);if(!r)throw Error(`Could not find figure with id ${n} in sheet ${t}`);let i=e.model.getters.getFigureUI(t,r);return e.getStore(W).viewports.getPositionAnchorOffset(t,{x:i.x+50,y:i.y+50})}function Jg(e,t){if(t.type===`carouselDataView`)return`o-spreadsheet-Icon.DATA`;let n=e.getChartDefinition(t.chartId);return(Ug.getAll().find(e=>e.matcher?.(n))||Ug.get(n.type)).preview}function Yg(e,t){if(t.title)return e.dynamicTranslate(t.title);if(t.type===`carouselDataView`)return N(`Data`);let n=e.getChartDefinition(t.chartId);return(Ug.getAll().find(e=>e.matcher?.(n))||Ug.get(n.type)).displayName}function Xg(e,t,n){let r=yt,i={...vt,...t.title},a=e.x+r.paddingX,o=Math.max(0,e.width-2*r.paddingX),s=i.text?i.fontSize*r.headerLineHeight:0,c={x:a,y:e.y+r.paddingY+r.headerPaddingTop,width:o,height:Math.max(r.minHeaderHeight,s)},l=c.y+c.height,u=i.text?{x:a,y:l+r.paddingY,width:o,height:r.separatorWidth}:void 0,d=n?.type===`carouselDataView`?r.paddingY:0,f=u||c,p=f.y+f.height+d,m=e.y+e.height-2*r.paddingY;return{headerRect:c,separatorRect:u,contentRect:{x:a,y:p,width:o,height:Math.max(0,m-p)},headerLineHeight:r.headerLineHeight}}let Zg=`#F8F8F8`;function Qg(e,t,n=1,r,i){let a=r??$g(e),o=typeof globalThis.devicePixelRatio==`number`?globalThis.devicePixelRatio:1;e.width=a.width*o,e.height=a.height*o;let s=e.getContext(`2d`);if(!s)throw Error(`Unable to retrieve 2D context from canvas`);s.scale(o*n,o*n);let c=a_({width:a.width/n,height:a.height/n,x:0,y:0},t,s,i);t_(s,c),e_(s,c),r_(s,c),n_(s,c),i_(s,c)}function $g(e){if(e instanceof HTMLCanvasElement){let t=e.getBoundingClientRect();return{width:t.width,height:t.height}}return{width:e.width,height:e.height}}function e_(e,t){e.save();let n=t.gauge,r=n.rect.x+n.rect.width/2,i=n.rect.y+n.rect.height,a=n.rect.height-n.arcWidth/2;if(a<0)return;let o=n.percentage===1?0:Math.PI*(1+n.percentage);e.strokeStyle=Zg,e.beginPath(),e.lineWidth=n.arcWidth,e.arc(r,i,a,o,0),e.stroke(),e.strokeStyle=n.color,e.beginPath(),e.arc(r,i,a,Math.PI,o),e.stroke(),e.restore()}function t_(e,t){e.save(),e.fillStyle=t.backgroundColor,e.fillRect(0,0,t.width,t.height),e.restore()}function n_(e,t){for(let n of[t.minLabel,t.maxLabel,t.gaugeValue])e.save(),e.textAlign=`center`,e.fillStyle=n.color,e.font=`${n.fontSize}px ${$e}`,e.fillText(n.label,n.textPosition.x,n.textPosition.y),e.restore()}function r_(e,t){let{x:n,y:r,width:i,height:a}=t.gauge.rect;for(let o of t.inflectionValues){e.save(),e.translate(n+i/2-.5,r+a-.5),e.rotate(Math.PI/2-o.rotation),e.lineWidth=2,e.strokeStyle=Tm(t.backgroundColor)+`aa`,e.beginPath(),e.moveTo(0,-(a-t.gauge.arcWidth)),e.lineTo(0,-a-3),e.stroke(),e.textAlign=`center`,e.font=`${o.fontSize}px ${$e}`,e.fillStyle=o.color;let s=-a-6-o.offset;e.fillText(o.label,0,s),e.restore()}}function i_(e,t){e.save();let n=t.title;e.font=Tp(n.fontSize,n.bold,n.italic),e.textBaseline=`middle`,e.fillStyle=n.color,e.fillText(n.label,n.textPosition.x,n.textPosition.y),e.restore()}function a_(e,t,n,r){let i=r?.labelFontSize??12,a=t.maxValue,o=t.minValue,s=p_(t,`animated`),c=o_(e,t.title.text),l=c.width/6,u=s?(s-o.value)/(a.value-o.value):0,d={x:e.width/2,y:c.y+c.height-c.height/12},f=80;c.height<300&&(f*=c.height/300);let p=c.width/2,m=t.gaugeValue?.label||`-`;Dp(n,m,{fontSize:f},`px`)>p&&(f=Lp(p,f,e=>Dp(n,m,{fontSize:e},`px`)));let h={x:c.x+l/2,y:c.y+c.height+i},g={x:c.x+c.width-l/2,y:c.y+c.height+i},_=Tm(t.background),v=s_(t,c,_,n,i),ee=0,y=0,b=0;switch(t.title.text&&({width:y,height:b}=Ap(n,t.title.text,{fontSize:16,...t.title},`px`)),t.title.align){case`right`:ee=e.width-y-20;break;case`center`:ee=(e.width-y)/2;break;default:ee=20;break}return{width:e.width,height:e.height,title:{label:t.title.text??``,fontSize:t.title.fontSize??16,textPosition:{x:ee,y:15+b/2},color:t.title.color??_,bold:t.title.bold,italic:t.title.italic},backgroundColor:t.background,gauge:{rect:c,arcWidth:l,percentage:S(u,0,1),color:c_(t)},inflectionValues:v,gaugeValue:{label:m,textPosition:d,fontSize:f,color:_},minLabel:{label:t.minValue.label,textPosition:h,fontSize:i,color:_},maxLabel:{label:t.maxValue.label,textPosition:g,fontSize:i,color:_}}}function o_(e,t){let n=t?25:0,r=e.height-20-n-10,i=e.width-60,a,o;return i>2*r?(a=2*r,o=r):(a=i,o=i/2),{x:30+(i-a)/2,y:n+10+(r-o)/2,width:a,height:o}}function s_(e,t,n,r,i=12){let a=e.maxValue,o=e.minValue,s={x:t.x+t.width/2,y:t.y+t.height},c={fontSize:i},l=[],u=[];for(let d of e.inflectionValues){let e=(d.value-o.value)/(a.value-o.value),f=Dp(r,d.label,c,`px`),p=Math.PI-Math.PI*e,m=f_(p,t.height+6,s.x,s.y,f+2,i),h=u.some(e=>d_(e,m))?i:0;u.push(m),l.push({rotation:p,label:d.label,fontSize:i,color:n,offset:h})}return l}function c_(e){let t=p_(e,`final`);if(t===void 0)return Zg;for(let n=0;n<e.inflectionValues.length;n++){let r=e.inflectionValues[n];if(r.operator===`<`&&t<r.value||r.operator===`<=`&&t<=r.value)return e.colors[n]}return e.colors.at(-1)}function l_(e){return[{start:e.topLeft,end:e.topRight},{start:e.topRight,end:e.bottomRight},{start:e.bottomRight,end:e.bottomLeft},{start:e.bottomLeft,end:e.topLeft}]}function u_(e,t){let n=e.start,r=e.end,i=t.start,a=t.end;function o(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}return o(n,i,a)!==o(r,i,a)&&o(n,r,i)!==o(n,r,a)}function d_(e,t){let n=l_(e),r=l_(t);for(let e of n)for(let t of r)if(u_(e,t))return!0;return!1}function f_(e,t,n,r,i,a){let o=Math.cos(e),s=Math.sin(e),c=o*t,l=s*t,u=i/2*s,d=i/2*o,f={x:c+u+n,y:r-(l-d)},p={x:c-u+n,y:r-(l+d)},m=o*(t+a),h=s*(t+a),g={x:m-u+n,y:r-(h+d)};return{bottomLeft:p,bottomRight:f,topRight:{x:m+u+n,y:r-(h-d)},topLeft:g}}function p_(e,t){return t===`animated`&&e.animationValue!==void 0?e.animationValue:e.gaugeValue?.value}let m_={responsive:!0,maintainAspectRatio:!1,elements:{line:{fill:!1},point:{hitRadius:15}},animation:!1,events:[`mousemove`,`mouseout`,`click`,`touchstart`,`touchmove`,`mouseup`]};function h_(e,t=20){let n=e.data;return n?{...e,data:{...n,labels:__(n.labels,t),datasets:n.datasets?.map(e=>g_(e,t))}}:e}function g_(e,t){let n=e.data;if(!Array.isArray(n)||n.length<=t)return e;let r=n.length,i=v_(r,t),a={...e};for(let e of Object.keys(a)){let t=a[e];Array.isArray(t)&&t.length===r&&(a[e]=i.map(e=>t[e]))}return a}function __(e,t){return!Array.isArray(e)||e.length<=t?e:v_(e.length,t).map(t=>e[t])}function v_(e,t){let n=e/t;return Array.from({length:t},(t,r)=>Math.min(e-1,Math.floor(r*n)))}async function y_(e,t,n,r=`light`){try{let i=S_(t.width,t.height),a=T_(i,e,t,n),o=await w_(r===`dark`?b_(i):i);return a(),o}catch(e){console.log(`Error exporting chart to image URL: `+e.message)}}function b_(e){let t=S_(e.width,e.height),n=t.getContext(`2d`);return!n||!(`filter`in n)?e:(n.filter=Zf,n.drawImage(e,0,0),t)}async function x_(e,t,n,r=`light`){try{let i=S_(t.width,t.height),a=T_(i,e,t,n),o=await C_(r===`dark`?b_(i):i);return a(),o}catch(e){console.log(`Error exporting chart to image file: `+e.message)}return null}function S_(e,t){if(!globalThis.OffscreenCanvas)throw Error(`converting a chart to an image using OffscreenCanvas is not supported in this environment`);return new OffscreenCanvas(e,t)}async function C_(e){return`convertToBlob`in e?e.convertToBlob({type:`image/png`}):new Promise(t=>e.toBlob(t,`image/png`))}async function w_(e){let t=await C_(e);if(t)return new Promise(e=>{let n=new FileReader;n.addEventListener(`load`,()=>{e(n.result)}),n.readAsDataURL(t)})}function T_(e,t,n,r,i=1){if(`chartJsConfig`in t){if(!globalThis.Chart)throw Error(`Chart.js library is not loaded`);let n=ii();n||ai();let r=x(t.chartJsConfig);if(!globalThis.Chart.registry.controllers.get(r.type))throw console.log(`Chart of type "${r.type}" is not registered in Chart.js library.`),n||oi(),Error(`Chart of type "${r.type}" is not registered in Chart.js library.`);let i=new globalThis.Chart(e,r);return()=>{i.destroy(),n||oi()}}else r===`scorecard`?Dg(Ag(n,t),e,i):r===`gauge`&&Qg(e,t,i,n);return()=>{}}let E_=1e3,D_=1e3;function O_(e,t){let n=e.getStore(W),{scrollX:r,scrollY:i}=n.activeSheetScrollInfo,a=n.sheetViewDimension,o=r+Math.max(0,(a.width-t.width)/2),s=i+Math.max(0,(a.height-t.height)/2),c=e.model.getters.getActiveSheetId();return n.viewports.getPositionAnchorOffset(c,{x:o,y:s})}function k_(e){let t=x(e);if(t.width>E_){let e=E_/t.width;t.width=E_,t.height*=e}if(t.height>D_){let e=D_/t.height;t.height=D_,t.width*=e}return t}function A_(e,t,n,r){let i=e.getMaxAnchorOffset(t,r.height,r.width),{col:a,row:o}=n,s={...r.offset};for(let n=e.getColSize(t,a);s.x>n;n=e.getColSize(t,a))a+=1,s.x-=n;a>i.col&&(a=i.col,s.x=i.offset.x);for(let n=e.getRowSize(t,o);s.y>n;n=e.getRowSize(t,o))o+=1,s.y-=n;return o>i.row&&(o=i.row,s.y=i.offset.y),{col:a,row:o,offset:s}}async function j_(e){return new Promise((t,n)=>{let r=new Image;r.addEventListener(`load`,()=>{let e=document.createElement(`canvas`);e.width=r.width,e.height=r.height,e.getContext(`2d`)?.drawImage(r,0,0),e.toBlob(t,`image/png`)}),r.addEventListener(`error`,n),r.src=e})}function M_({strikethrough:e,underline:t}){return!e&&!t?`none`:`${e?`line-through`:``} ${t?`underline`:``}`}function N_(e){let t=P_(e);return e&&e.fillColor&&(t.background=e.fillColor),t}function P_(e){let t={};if(!e)return t;if(e.bold&&(t[`font-weight`]=`bold`),e.italic&&(t[`font-style`]=`italic`),e.fontSize&&(t[`font-size`]=`${e.fontSize}px`),e.strikethrough||e.underline){let n=e.strikethrough?`line-through`:``;n=e.underline?n+` underline`:n,t[`text-decoration`]=n}return e.textColor&&(t.color=e.textColor),t}function G(e){let t=``;for(let n in e)e[n]&&(t+=`${n}:${e[n]}; `);return t}function F_(e){let t=window.getComputedStyle(e);return{top:parseInt(t.marginTop,10)||0,bottom:parseInt(t.marginBottom,10)||0,left:parseInt(t.marginLeft,10)||0,right:parseInt(t.marginRight,10)||0}}let I_=function(e){return e.PlainText=`text/plain`,e.Html=`text/html`,e.Image=`image`,e}({}),L_=[`image/avif`,`image/bmp`,`image/gif`,`image/vnd.microsoft.icon`,`image/jpeg`,`image/png`,`image/tiff`,`image/webp`];function R_(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?Dr(t):[t[t.length-1]],s=o.map(e=>Sr(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 z_(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 B_(e,t){if(!t.length||!t[0].length)return e;let n=t[0].length,r=t.length;return e.map(e=>z_(e,n,r)).flat()}function V_(e){let t;e[`text/html`]&&(t=U_(new DOMParser().parseFromString(e[`text/html`],`text/html`)));let n=e[`text/plain`]||``,r;if(!n.trim()){for(let t of L_)if(e[t]){r=e[t];break}}return{text:n,data:t,imageBlob:r}}function H_(e){return e?.match(/<div data-osheet-clipboard-id=(['"])([^'"]+)\1/)?.[2]}function U_(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 G_(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=dr(a,e)}}return{target:s,zone:a,selectedZones:o}}let K_=(e,t,n)=>{let r={col:t[0].left,row:t[0].top};e.getBackToDefault(),e.selectZone({cell:r,zone:dr(...n)},{scrollIntoView:!1})};var K=class{static getCrypto(){if(typeof globalThis<`u`&&globalThis.crypto)return globalThis.crypto}static smallUuid(){let e=this.getCrypto();return e?`10000000-1000`.replace(/[01]/g,t=>{let n=Number(t);return(n^e.getRandomValues(new Uint8Array(1))[0]&15>>n/4).toString(16)}):`xxxxxxxx-xxxx`.replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}static uuidv4(){let e=this.getCrypto();return e?`10000000-1000-4000-8000-100000000000`.replace(/[018]/g,t=>{let n=Number(t);return(n^e.getRandomValues(new Uint8Array(1))[0]&15>>n/4).toString(16)}):`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,function(e){let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}};function q_(e){if(!e||typeof e!=`object`||!(!e.thousandsSeparator||typeof e.thousandsSeparator==`string`))return!1;for(let t of[`code`,`name`,`decimalSeparator`,`dateFormat`,`timeFormat`,`formulaArgSeparator`])if(!e[t]||typeof e[t]!=`string`)return!1;if(e.formulaArgSeparator===e.decimalSeparator||e.thousandsSeparator===e.decimalSeparator)return!1;try{V(1,{locale:e,format:`#,##0.00`}),V(1,{locale:e,format:e.dateFormat}),V(1,{locale:e,format:e.timeFormat})}catch{return!1}return!0}function J_(e,t){return Dn(e)?Q_(e,t):tv(e,t)}function Y_(e,t){return Dn(e)?Q_(e,t):nv(e,t)}function X_(e,t){return e.startsWith(`=`)?$_(e,t):iv(e,t)}function Z_(e,t){return Dn(e)?Q_(e,t):tv(e,t)}function Q_(e,t){return ev(e.startsWith(`+`)?`=`+e.slice(1):e,t,B)}function $_(e,t){return ev(e,B,t)}function ev(e,t,n){if(t.formulaArgSeparator===n.formulaArgSeparator&&t.decimalSeparator===n.decimalSeparator)return e;let r=Il(e,t),i=``;for(let e of r)e.type===`NUMBER`?i+=e.value.replace(t.decimalSeparator,n.decimalSeparator):e.type===`ARG_SEPARATOR`?i+=n.formulaArgSeparator:e.type===`ARRAY_ROW_SEPARATOR`?i+=n.formulaArgSeparator===`;`?`\\`:`;`:i+=e.value;return i}function tv(e,t){return t.decimalSeparator===`.`||!mo(e,t)?e:(t.thousandsSeparator&&(e=e.replaceAll(t.thousandsSeparator,``)),e.replace(t.decimalSeparator,`.`))}function nv(e,t){if(Fa(e,t)){let n=I(e,t),r=B.dateFormat;return Number.isInteger(n)||(r+=` `+B.timeFormat),V(n,{locale:B,format:r})}return tv(e,t)}function rv(e,t){if(t.decimalSeparator===`.`||!mo(e,B))return e;let n=xc(B);return e.replace(n,e=>e.replace(`.`,t.decimalSeparator))}function iv(e,t){if(Fa(e,B)){let n=I(e,B),r=t.dateFormat;return Number.isInteger(n)||(r+=` `+t.timeFormat),V(n,{locale:t,format:r})}return rv(e,t)}function av(e){return e.dateFormat+` `+e.timeFormat}var ov=class{xmlString;constructor(e){this.xmlString=e}toString(){return this.xmlString}};let sv=[`areaChart`,`area3DChart`,`lineChart`,`line3DChart`,`stockChart`,`radarChart`,`scatterChart`,`pieChart`,`pie3DChart`,`doughnutChart`,`barChart`,`bar3DChart`,`ofPieChart`,`surfaceChart`,`surface3DChart`,`bubbleChart`,`comboChart`,`radarChart`];var cv=class{static getters=[];history;constructor(e){this.history=Object.assign(Object.create(e),{update:e.addChange.bind(e,this),selectCell:()=>{}})}exportForExcel(e){}allowDispatch(e){return`Success`}beforeHandle(e){}handle(e){}finalize(){}batchValidations(...e){return t=>e.map(e=>e.call(this,t)).flat()}chainValidations(...e){return t=>{for(let n of e){let e=n.call(this,t);Array.isArray(e)||(e=[e]);let r=e.filter(e=>e!==`Success`);if(r.length)return r}return`Success`}}checkValidations(e,...t){return this.batchValidations(...t)(e)}},lv=class extends cv{getters;dispatch;canDispatch;constructor({getters:e,stateObserver:t,range:n,dispatch:r,canDispatch:i,formulasPlugin:a}){super(t),n.addRangeProvider(this.adaptRanges.bind(this)),a.addFormulaProvider(this.getFormulas.bind(this)),this.getters=e,this.dispatch=r,this.canDispatch=i}import(e){}export(e,t){}adaptRanges(e){}getFormulas(){return[]}};let uv=/^[\p{L}\p{N}_.]+$/u;var dv=class extends lv{static getters=[`getNamedRange`,`getNamedRangeFromZone`,`getNamedRanges`];namedRanges=[];adaptRanges({applyChange:e}){let t=[],n=!1;for(let r of this.namedRanges){let i=e(r.range);switch(i.changeType){case`REMOVE`:n=!0;break;case`RESIZE`:case`MOVE`:case`CHANGE`:n=!0,t.push({...r,range:i.range});break;case`NONE`:t.push(r)}}n&&this.history.update(`namedRanges`,t)}allowDispatch(e){switch(e.type){case`CREATE_NAMED_RANGE`:return this.checkValidNewNamedRangeName(e.name);case`UPDATE_NAMED_RANGE`:return this.checkValidations(e,()=>this.checkNamedRangeExists(e.oldRangeName),()=>e.newRangeName===e.oldRangeName?`Success`:this.checkValidNewNamedRangeName(e.newRangeName));case`DELETE_NAMED_RANGE`:return this.checkNamedRangeExists(e.name)}return`Success`}handle(e){switch(e.type){case`CREATE_NAMED_RANGE`:{let t=this.getters.getRangeFromRangeData(e.ranges[0]),n=[...this.namedRanges,{name:e.name,range:t}];this.history.update(`namedRanges`,n);break}case`UPDATE_NAMED_RANGE`:{let t=this.getNamedRangeIndex(e.oldRangeName);if(t!==-1){let n=this.getters.getRangeFromRangeData(e.ranges[0]);this.history.update(`namedRanges`,t,{name:e.newRangeName,range:n})}break}case`DELETE_NAMED_RANGE`:{let t=this.getNamedRangeIndex(e.name);if(t!==-1){let e=[...this.namedRanges];e.splice(t,1),this.history.update(`namedRanges`,e)}break}}}getNamedRange(e){return this.namedRanges[this.getNamedRangeIndex(e)]}getNamedRangeFromZone(e,t){for(let n of this.namedRanges){let r=n.range;if(r.sheetId===e&&T(r.unboundedZone,t))return n}}getNamedRanges(){return this.namedRanges}getNamedRangeIndex(e){return this.namedRanges.findIndex(t=>t&&t.name.toLowerCase()===e.toLowerCase())}import(e){for(let t in e.namedRanges||{})this.namedRanges.push({name:t,range:this.getters.getRangeFromSheetXC(void 0,e.namedRanges[t])})}export(e){e.namedRanges={};for(let t of this.namedRanges){let n=this.getters.getRangeString(t.range);e.namedRanges[t.name]=n}}exportForExcel(e){this.export(e)}checkValidNewNamedRangeName(e){return this.getNamedRange(e)?`NamedRangeNameAlreadyExists`:!uv.test(e)||mo(e,B)||[`TRUE`,`FALSE`].includes(e.toUpperCase())?`NamedRangeInvalidName`:vl.test(e)?`NamedRangeNameLooksLikeCellReference`:`Success`}checkNamedRangeExists(e){return this.getNamedRange(e)?`Success`:`NamedRangeNotFound`}};function fv(e,t){let n={};for(let r of e.namedRanges){if(!r.value.split(`!`)[0]?.replace(/'/g,``)){t.addConversionWarning(`Named range "${r.name}" does not specify a sheet and will be ignored.`);continue}if(!uv.test(r.name)){t.addConversionWarning(`Named range "${r.name}" has an invalid name and will be ignored.`);continue}n[r.name]=r.value}return n}let pv=new WeakMap,mv=new WeakMap;function hv(e,t){pv.has(t)||(pv.set(t,new Map),mv.set(t,0));let n=pv.get(t),r=vv(e);if(n.has(r)){let i=n.get(r);return t[i]=e,i}let i=mv.get(t)+1;return n.set(r,i),mv.set(t,i),t[i]=e,i}function gv(e){let t={};for(let n in e){let r=Wn(e[n].map(D));for(let e of r)t[or(e)]=Number(n)}return t}function*_v(e,t){for(let n in t){let r=tr(n),i=t[n];for(let t=r.top;t<=r.bottom;t++)for(let n=r.left;n<=r.right;n++)yield[{sheetId:e,col:n,row:t},i]}}function vv(e){if(e===null)return`null`;if(e===void 0)return`undefined`;if(typeof e!=`object`)return String(e);if(Array.isArray(e)){let t=e.length,n=`[`;for(let r=0;r<t;r++)r>0&&(n+=`,`),n+=vv(e[r]);return n+`]`}let t=Object.keys(e).sort(),n=`{`;for(let r of t)e[r]!==void 0&&(n+=`"${r}":${vv(e[r])},`);return n+=`}`,n}let yv=[`thin`,`medium`,`thick`,`dashed`,`dotted`],bv=[`general`,`left`,`center`,`right`],xv=[`top`,`center`,`bottom`],Sv=[`Arial`],Cv=[`solid`,`none`],wv=[`expression`,`cellIs`,`colorScale`,`iconSet`,`containsText`,`notContainsText`,`beginsWith`,`endsWithText`,`containsBlanks`,`notContainsBlanks`],Tv={b:`boolean`,d:`date`,e:`error`,inlineStr:`inlineStr`,n:`number`,s:`sharedString`,str:`str`},Ev={dashDot:`thin`,dashDotDot:`thin`,dashed:`dashed`,dotted:`dotted`,double:`thin`,hair:`thin`,medium:`medium`,mediumDashDot:`thin`,mediumDashDotDot:`thin`,mediumDashed:`thin`,none:void 0,slantDashDot:`thin`,thick:`thick`,thin:`thin`},Dv={general:void 0,left:`left`,center:`center`,right:`right`,fill:`left`,justify:`left`,centerContinuous:`center`,distributed:`center`},Ov={top:`top`,center:`middle`,bottom:`bottom`,justify:`middle`,distributed:`middle`},kv={top:`top`,middle:`center`,bottom:`bottom`},Av={beginsWith:`beginsWithText`,endsWith:`endsWithText`,containsText:`containsText`,notContains:`notContainsText`,between:`isBetween`,notBetween:`isNotBetween`,equal:`isEqual`,notEqual:`isNotEqual`,greaterThan:`isGreaterThan`,greaterThanOrEqual:`isGreaterOrEqualTo`,lessThan:`isLessThan`,lessThanOrEqual:`isLessOrEqualTo`},jv={aboveAverage:void 0,expression:`customFormula`,cellIs:void 0,colorScale:void 0,dataBar:void 0,iconSet:void 0,top10:`top10`,uniqueValues:`uniqueValues`,duplicateValues:`duplicateValues`,containsText:`containsText`,notContainsText:`notContainsText`,beginsWith:`beginsWithText`,endsWith:`endsWithText`,containsBlanks:`isEmpty`,notContainsBlanks:`isNotEmpty`,containsErrors:void 0,notContainsErrors:void 0,timePeriod:void 0},Mv={num:`number`,percent:`percentage`,max:`value`,min:`value`,percentile:`percentile`,formula:`formula`},Nv={NoIcons:void 0,"3Arrows":`arrows`,"3ArrowsGray":`arrows`,"3Symbols":`smiley`,"3Symbols2":`smiley`,"3Signs":`dots`,"3Flags":`dots`,"3TrafficLights1":`dots`,"3TrafficLights2":`dots`,"4Arrows":`arrows`,"4ArrowsGray":`arrows`,"4RedToBlack":`dots`,"4Rating":`smiley`,"4TrafficLights":`dots`,"5Arrows":`arrows`,"5ArrowsGray":`arrows`,"5Rating":`smiley`,"5Quarters":`dots`,"3Stars":`smiley`,"3Triangles":`arrows`,"5Boxes":`dots`},Pv={none:`none`,b:`bottom`,t:`top`,l:`left`,r:`right`,tr:`right`},Fv={areaChart:void 0,area3DChart:void 0,lineChart:`line`,line3DChart:void 0,stockChart:void 0,radarChart:`radar`,scatterChart:`scatter`,pieChart:`pie`,pie3DChart:void 0,doughnutChart:`pie`,barChart:`bar`,bar3DChart:void 0,ofPieChart:void 0,surfaceChart:void 0,surface3DChart:void 0,bubbleChart:void 0,comboChart:`combo`},Iv={exp:`exponential`,log:`logarithmic`,poly:`polynomial`,movingAvg:`trailingMovingAverage`},Lv={1:`AVERAGE`,2:`COUNT`,3:`COUNTA`,4:`MAX`,5:`MIN`,6:`PRODUCT`,7:`STDEV`,8:`STDEVP`,9:`SUM`,10:`VAR`,11:`VARP`,101:`AVERAGE`,102:`COUNT`,103:`COUNTA`,104:`MAX`,105:`MIN`,106:`PRODUCT`,107:`STDEV`,108:`STDEVP`,109:`SUM`,110:`VAR`,111:`VARP`},Rv={0:`General`,1:`0`,2:`0.00`,3:`#,#00`,4:`#,##0.00`,9:`0%`,10:`0.00%`,11:void 0,12:void 0,13:void 0,14:`m/d/yyyy`,15:`m/d/yyyy`,16:`m/d/yyyy`,17:`m/d/yyyy`,18:`hh:mm:ss a`,19:`hh:mm:ss a`,20:`hhhh:mm:ss`,21:`hhhh:mm:ss`,22:`m/d/yy h:mm`,37:void 0,38:void 0,39:void 0,40:void 0,45:`hhhh:mm:ss`,46:`hhhh:mm:ss`,47:`hhhh:mm:ss`,48:void 0,49:`@`},zv={0:1,"0.00":2,"#,#00":3,"#,##0.00":4,"0%":9,"0.00%":10,"0.00E+00":11,"# ?/?":12,"# ??/??":13,"mm-dd-yy":14,"d-mm-yy":15,"mm-yy":16,"mmm-yy":17,"h:mm AM/PM":18,"h:mm:ss AM/PM":19,"h:mm":20,"h:mm:ss":21,"m/d/yy h:mm":22,"#,##0 ;(#,##0)":37,"#,##0 ;[Red](#,##0)":38,"#,##0.00;(#,##0.00)":39,"#,##0.00;[Red](#,##0.00)":40,"mm:ss":45,"[h]:mm:ss":46,"mmss.0":47,"##0.0E+0":48,"@":49,"hh:mm:ss a":19},Bv={0:`000000`,1:`FFFFFF`,2:`FF0000`,3:`00FF00`,4:`0000FF`,5:`FFFF00`,6:`FF00FF`,7:`00FFFF`,8:`000000`,9:`FFFFFF`,10:`FF0000`,11:`00FF00`,12:`0000FF`,13:`FFFF00`,14:`FF00FF`,15:`00FFFF`,16:`800000`,17:`008000`,18:`000080`,19:`808000`,20:`800080`,21:`008080`,22:`C0C0C0`,23:`808080`,24:`9999FF`,25:`993366`,26:`FFFFCC`,27:`CCFFFF`,28:`660066`,29:`FF8080`,30:`0066CC`,31:`CCCCFF`,32:`000080`,33:`FF00FF`,34:`FFFF00`,35:`00FFFF`,36:`800080`,37:`800000`,38:`008080`,39:`0000FF`,40:`00CCFF`,41:`CCFFFF`,42:`CCFFCC`,43:`FFFF99`,44:`99CCFF`,45:`FF99CC`,46:`CC99FF`,47:`FFCC99`,48:`3366FF`,49:`33CCCC`,50:`99CC00`,51:`FFCC00`,52:`FF9900`,53:`FF6600`,54:`666699`,55:`969696`,56:`003366`,57:`339966`,58:`003300`,59:`333300`,60:`993300`,61:`993366`,62:`333399`,63:`333333`,64:`000000`,65:`FFFFFF`},Vv={"image/avif":`avif`,"image/bmp":`bmp`,"image/gif":`gif`,"image/vnd.microsoft.icon":`ico`,"image/jpeg":`jpeg`,"image/png":`png`,"image/tiff":`tiff`,"image/webp":`webp`},Hv={avif:`image/avif`,bmp:`image/bmp`,gif:`image/gif`,ico:`image/vnd.microsoft.icon`,jpeg:`image/jpeg`,png:`image/png`,tiff:`image/tiff`,webp:`image/webp`,jpg:`image/jpeg`},Uv={between:`isBetween`,notBetween:`isNotBetween`,equal:`isEqual`,notEqual:`isNotEqual`,greaterThan:`isGreaterThan`,greaterThanOrEqual:`isGreaterOrEqualTo`,lessThan:`isLessThan`,lessThanOrEqual:`isLessOrEqualTo`},Wv={between:`dateIsBetween`,notBetween:`dateIsNotBetween`,equal:`dateIs`,greaterThan:`dateIsAfter`,greaterThanOrEqual:`dateIsOnOrAfter`,lessThan:`dateIsBefore`,lessThanOrEqual:`dateIsOnOrBefore`};function Gv(e){switch(e){case`isNotEmpty`:return`notContainsBlanks`;case`isEmpty`:return`containsBlanks`;case`notContainsText`:return`notContainsBlanks`;case`containsText`:return`containsText`;case`beginsWithText`:return`beginsWith`;case`endsWithText`:return`endsWith`;case`isGreaterThan`:return`greaterThan`;case`isGreaterOrEqualTo`:return`greaterThanOrEqual`;case`isLessThan`:return`lessThan`;case`isLessOrEqualTo`:return`lessThanOrEqual`;case`isBetween`:return`between`;case`isNotBetween`:return`notBetween`;case`isEqual`:return`equal`;case`isNotEqual`:return`notEqual`;case`customFormula`:return``;case`dateIs`:return``;case`dateIsBefore`:return`lessThan`;case`dateIsAfter`:return`greaterThan`;case`dateIsOnOrAfter`:return`greaterThanOrEqual`;case`dateIsOnOrBefore`:return`lessThanOrEqual`;case`top10`:return`top10`;case`uniqueValues`:return`uniqueValues`;case`duplicateValues`:return`duplicateValues`}}function Kv(e){switch(typeof e){case`boolean`:return`b`;case`string`:return`str`;case`number`:return`n`;default:return}}function qv(e){return Math.round(om*e*100)/100}function Jv(e){return Math.round(sm*e*100)/100}function Yv(e){return e&&Math.round(e/om*100)/100}function Xv(e){return e&&Math.round(e/sm*100)/100}function Zv(e,t,n,r,i){let a=n?e.styles[n]:{},o=r?e.formats[r]:void 0,s={font:{size:a?.fontSize||Qe,color:{rgb:a?.textColor?a.textColor:`000000`},family:2,name:`Arial`},fill:a?.fillColor?{fgColor:{rgb:a.fillColor}}:{reservedAttribute:`none`},numFmt:o?{format:o,id:0}:void 0,border:i||0,alignment:{horizontal:a.align==="default"?void 0:a.align,vertical:a.verticalAlign?kv[a.verticalAlign]:void 0,wrapText:a.wrapping===`wrap`||t?.includes(`
18
18
  `)?!0:void 0,textRotation:a.rotation?Qv(a.rotation):void 0,shrinkToFit:a.wrapping===`clip`?!0:void 0}};return s.font.strike=!!a?.strikethrough||void 0,s.font.underline=!!a?.underline||void 0,s.font.bold=!!a?.bold||void 0,s.font.italic=!!a?.italic||void 0,s}function Qv(e){let t=Math.round(-e/Math.PI*180)%180;return t>90?t-=180:t<-90&&(t+=180),t>=0?t:90-t}function $v(e){return e<=90?-(e/180)*Math.PI:-(90-e)/180*Math.PI}function ey(e,t){let n=ty(t.numFmt,e.numFmts);return iy({fontId:iy(t.font,e.fonts),fillId:iy(t.fill,e.fills),borderId:t.border,numFmtId:n,alignment:{vertical:t.alignment.vertical,horizontal:t.alignment.horizontal,wrapText:t.alignment.wrapText,textRotation:t.alignment.textRotation,shrinkToFit:t.alignment.shrinkToFit}},e.styles)}function ty(e,t){if(!e)return 0;let n=zv[e.format];return n||=iy(e,t)+164,n}function ny(e,t,n){let r=e.find(e=>e.path===t),i;return r?(i=`rId${(r.rels.length+1).toString()}`,r.rels.push({...n,id:i})):(i=`rId1`,e.push({path:t,rels:[{...n,id:i}]})),i}let ry=new WeakMap;function iy(e,t){let n=ry.get(t);if(!n){n=new Map;for(let e=0;e<t.length;e++){let r=vv(t[e]);n.set(r,e)}ry.set(t,n)}let r=vv(e);if(n.has(r))return n.get(r);let i=t.length;return t.push(e),n.set(r,i),i}function ay(e,t){let n=t.chartIds.findIndex(t=>t===e);return n===-1?(t.chartIds.push(e),t.chartIds.length):n+1}let oy=[];function sy(e){let t=oy.findIndex(t=>t===e);return t===-1?(oy.push(e),oy.length):t+1}function cy(e){return Math.round(e*914400/96)}function ly(e,t,n){let r=e,i;({xc:r,sheetName:i}=wl(e));let a;if(i){let e=n.sheets.findIndex(e=>Xu(e.name,i));if(e<0)throw Error(`Unable to find a sheet with the name `+i);a=e}else a=Number(t);let o=er(r);return o.right===void 0&&(o.right=n.sheets[a].colNumber),o.bottom===void 0&&(o.bottom=n.sheets[a].rowNumber),(o.right-o.left+1)*(o.bottom-o.top+1)}function uy(e){return Math.round(e*96/914400)}function dy(e,t){let n=0;for(let r=0;r<e;r++){let e=t.cols.find(e=>r>=e.min&&r<=e.max);e?.width?n+=e.width:t.sheetFormat?.defaultColWidth?n+=t.sheetFormat.defaultColWidth:n+=cm}return n/sm}function fy(e,t){let n=0;for(let r=0;r<e;r++){let e=t.rows.find(e=>e.index-1===r);e?.height?n+=e.height:t.sheetFormat?.defaultRowHeight?n+=t.sheetFormat.defaultRowHeight:n+=lm}return n/om}function py(e){return Object.keys(Uv).find(t=>Uv[t]===e)}function my(e){return Object.keys(Wv).find(t=>Wv[t]===e)}var hy=class{_parsingWarnings=new Set;_conversionWarnings=new Set;addParsingWarning(e){this._parsingWarnings.add(e)}addConversionWarning(e){this._conversionWarnings.add(e)}get warnings(){return[...this._parsingWarnings,...this._conversionWarnings]}generateNotSupportedWarning(e,t,n){let r=`${e} ${t?`"`+t+`" is`:`are`} not yet supported. `;n&&(r+=`Only ${n.join(`, `)} are currently supported.`),this._conversionWarnings.has(r)||this._conversionWarnings.add(r)}};let gy={name:`ARROW_DOWN`,width:448,height:512,paths:[{fillColor:`#E06666`,path:`M413.1 222.5l22.2 22.2c9.4 9.4 9.4 24.6 0 33.9L241 473c-9.4 9.4-24.6 9.4-33.9 0L12.7 278.6c-9.4-9.4-9.4-24.6 0-33.9l22.2-22.2c9.5-9.5 25-9.3 34.3.4L184 343.4V56c0-13.3 10.7-24 24-24h32c13.3 0 24 10.7 24 24v287.4l114.8-120.5c9.3-9.8 24.8-10 34.3-.4z`}]},_y={name:`ARROW_UP`,width:448,height:512,paths:[{fillColor:`#6AA84F`,path:`M34.9 289.5l-22.2-22.2c-9.4-9.4-9.4-24.6 0-33.9L207 39c9.4-9.4 24.6-9.4 33.9 0l194.3 194.3c9.4 9.4 9.4 24.6 0 33.9L413 289.4c-9.5 9.5-25 9.3-34.3-.4L264 168.6V456c0 13.3-10.7 24-24 24h-32c-13.3 0-24-10.7-24-24V168.6L69.2 289.1c-9.3 9.8-24.8 10-34.3.4z`}]},vy={name:`ARROW_RIGHT`,width:448,height:512,paths:[{fillColor:`#F0AD4E`,path:`M190.5 66.9l22.2-22.2c9.4-9.4 24.6-9.4 33.9 0L441 239c9.4 9.4 9.4 24.6 0 33.9L246.6 467.3c-9.4 9.4-24.6 9.4-33.9 0l-22.2-22.2c-9.5-9.5-9.3-25 .4-34.3L311.4 296H24c-13.3 0-24-10.7-24-24v-32c0-13.3 10.7-24 24-24h287.4L190.9 101.2c-9.8-9.3-10-24.8-.4-34.3z`}]},yy={name:`SMILE`,width:496,height:512,paths:[{fillColor:`#6AA84F`,path:`M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm4 72.6c-20.8 25-51.5 39.4-84 39.4s-63.2-14.3-84-39.4c-8.5-10.2-23.7-11.5-33.8-3.1-10.2 8.5-11.5 23.6-3.1 33.8 30 36 74.1 56.6 120.9 56.6s90.9-20.6 120.9-56.6c8.5-10.2 7.1-25.3-3.1-33.8-10.1-8.4-25.3-7.1-33.8 3.1z`}]},by={name:`MEH`,width:496,height:512,paths:[{fillColor:`#F0AD4E`,path:`M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm8 144H160c-13.2 0-24 10.8-24 24s10.8 24 24 24h176c13.2 0 24-10.8 24-24s-10.8-24-24-24z`}]},xy={name:`FROWN`,width:496,height:512,paths:[{fillColor:`#E06666`,path:`M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm-80 128c-40.2 0-78 17.7-103.8 48.6-8.5 10.2-7.1 25.3 3.1 33.8 10.2 8.4 25.3 7.1 33.8-3.1 16.6-19.9 41-31.4 66.9-31.4s50.3 11.4 66.9 31.4c8.1 9.7 23.1 11.9 33.8 3.1 10.2-8.5 11.5-23.6 3.1-33.8C326 321.7 288.2 304 248 304z`}]},Sy=`M256 9 a247 247 0 1 0.1 0 0`,Cy={name:`GREEN_DOT`,width:512,height:512,paths:[{fillColor:`#6AA84F`,path:Sy}]},wy={name:`YELLOW_DOT`,width:512,height:512,paths:[{fillColor:`#F0AD4E`,path:Sy}]},Ty={name:`RED_DOT`,width:512,height:512,paths:[{fillColor:`#E06666`,path:Sy}]},Ey=`M40 160 h320 l-160 160`;function Dy(e){return{name:`CARET_DOWN`,width:512,height:512,paths:[{fillColor:e.textColor||`#374151C2`,path:Ey}]}}function Oy(e){return{name:`CARET_UP`,width:512,height:512,paths:[{fillColor:e.textColor||`#374151C2`,path:`M40 320 h320 l-160 -160`}]}}function ky(e){return{name:`CARET_DOWN`,width:512,height:512,paths:[{fillColor:e.textColor||`#374151C2`,path:`M200 32a200 200 0 1 1 0 400 200 200 0 1 1 0-400`},{fillColor:e.fillColor||`#fff`,path:Ey}]}}let Ay=e=>({name:`CHECKBOX_UNCHECKED`,width:512,height:512,paths:[{fillColor:e?ze:`#91959d`,path:`M45,45 h422 v422 h-422 v-422 m30,30 v362 h362 v-362`}]}),jy=e=>({name:`CHECKBOX_UNCHECKED`,width:512,height:512,paths:[{fillColor:e?`#82d1d5`:Ve,path:`M45,45 h422 v422 h-422 v-422 m30,30 v362 h362 v-362`}]}),My=e=>({name:`CHECKBOX_CHECKED`,width:512,height:512,paths:[{fillColor:e?`#82d1d5`:Ve,path:`M45,45 h422 v422 h-422 v-422`},{fillColor:e?`#505050`:`#FFF`,path:`M165,240 l45,45 l135,-135 h60 l-195,195 l-105,-105`}]});function Ny(e,t){return{name:`PIVOT_ICON`,width:512,height:512,paths:[{path:`M21,21 h469 v469 h-469`,fillColor:t?Le:`#777`},{path:`M64,64 v384 h384 v-384`,fillColor:t?`#E7E9ED`:`#eee`},{path:e?`M149,235 h213 v43 h-213 M235,149 h43 v213 h-43`:`M149,235 h213 v43 h-213`,fillColor:t?Le:`#777`}]}}function Py(e,t,n){let r=e?`M 11 20 Q 10.575 20 10.2875 19.7125 T 10 19 L 10 13 L 4.2 5.6 Q 3.825 5.1 4.0875 4.55 T 5 4 L 19 4 Q 19.65 4 19.9125 4.55 T 19.8 5.6 L 14 13 L 14 19 Q 14 19.425 13.7125 19.7125 T 13 20 L 11 20 Z`:`M 339.667 681 L 510.333 681 L 510.333 595.667 L 339.667 595.667 L 339.667 681 Z M 41 169 L 41 254.333 L 809 254.333 L 809 169 L 41 169 Z M 169 467.667 L 681 467.667 L 681 382.333 L 169 382.333 L 169 467.667 Z`,i=e?`M0,0 h24 v24 h-24`:`M0,0 h850 v850 h-850`,a={iconColor:Pe,hoverBackgroundColor:Pe};return n&&!t?a.iconColor=`#fff`:!n&&t?a.iconColor=`#defade`:n&&t&&(a.iconColor=Pe,a.hoverBackgroundColor=`#fff`),{name:`DATA_FILTER_ICON`,width:e?24:850,height:e?24:850,paths:[n?{path:i,fillColor:a.hoverBackgroundColor}:void 0,{path:r,fillColor:a.iconColor}].filter(w)}}let Fy={arrowGood:{template:`ARROW_UP`,svg:_y},arrowNeutral:{template:`ARROW_RIGHT`,svg:vy},arrowBad:{template:`ARROW_DOWN`,svg:gy},smileyGood:{template:`SMILE`,svg:yy},smileyNeutral:{template:`MEH`,svg:by},smileyBad:{template:`FROWN`,svg:xy},dotGood:{template:`GREEN_DOT`,svg:Cy},dotNeutral:{template:`YELLOW_DOT`,svg:wy},dotBad:{template:`RED_DOT`,svg:Ty}},Iy={arrows:{good:`arrowGood`,neutral:`arrowNeutral`,bad:`arrowBad`},smiley:{good:`smileyGood`,neutral:`smileyNeutral`,bad:`smileyBad`},dots:{good:`dotGood`,neutral:`dotNeutral`,bad:`dotBad`}},Ly={};function Ry(e){if(Ly[e])return Ly[e];let t=new Path2D(e);return Ly[e]=t,t}function zy(e,t){let n=e.split(`/`),r=t.split(`/`),i=``,a=0;for(let e=0;e<n.length-1;e++)n[e]===r[e]?a++:i+=`../`;return i+=r.slice(a).join(`/`),i}function By(e,t=0){let n={};for(let r=0;r<e.length;r++)e[r]&&(n[r+t]=e[r]);return n}function Vy(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,(e,t)=>String.fromCharCode(parseInt(t,16)))}function Hy(e,t,n){return t===`COL`?(e.cols[n]||(e.cols[n]={}),e.cols[n]):(e.rows[n]||(e.rows[n]={}),e.rows[n])}function Uy(e){if(e[0]===`=`)return e;let t=Il(e);return t.length===1&&t[0].type!==`REFERENCE`?e:`=`+e}function Wy(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=Qp;else if(e.indexed)t=Bv[e.indexed];else return;return t=Gy(t),e.tint&&(t=qy(t,e.tint)),t=t.toUpperCase(),t.length===9&&t.endsWith(`FF`)&&(t=t.slice(0,7)),t}function Gy(e){return e.length===6?`#`+e+`FF`:`#`+e.slice(2)+e.slice(0,2)}function Ky(e,t,n){let r=Hf(Bf(e));return r.l=Math.min(100,Math.max(0,r.l*t+n*100)),zf(Vf(r))}function qy(e,t){let n=Hf(Bf(e));return t<0&&(n.l*=1+t),t>0&&(n.l=n.l*(1-t)+(100-100*(1-t))),zf(Vf(n))}function Jy(e){return e.length===9&&(e=e.slice(0,7)),parseInt(e.replace(`#`,``),16)}let Yy=/^(yy|yyyy|m{1,5}|d{1,4}|h{1,2}|s{1,2}|am\/pm|a\/m|\s|-|\/|\.|:)+$/i;function Xy(e,t,n){let r=Rv[e]||t.find(t=>t.id===e)?.format;if(r!==`General`){if(r)try{let e=r.replace(/\[(.*)-[A-Z0-9]{3}\]/g,`[$1]`);if(e=e.replace(/\[\$\]/g,``),e=e.replace(/_.{1}/g,``),e=e.replace(/\*.{1}/g,``),Qy(e)&&(e=$y(e)),Zy(e))return e}catch{}n.generateNotSupportedWarning(`Number format`,r||`nmFmtId ${e}`)}}function Zy(e){try{return V(0,{format:e,locale:B}),!0}catch{return!1}}function Qy(e){return Yy.test(e)}function $y(e){return e=e.toLowerCase(),e=e.replace(/mmmmm/g,`mmm`),e=e.replace(/am\/pm|a\/m/g,`a`),e=e.replace(/hhhh/g,`hh`),e=e.replace(/\bh\b/g,`hh`),e}function eb(e,t){return By(e.borders.map(e=>{sb(e,t);let n={top:tb(e.top,t),bottom:tb(e.bottom,t),left:tb(e.left,t),right:tb(e.right,t)};return Object.keys(n).forEach(e=>n[e]===void 0&&delete n[e]),n}),1)}function tb(e,t){if(!e)return;ob(e,t);let n=Ev[e.style];return n?{style:n,color:Wy(e.color)}:void 0}function nb(e,t){return By(e.styles.map(n=>rb({fontStyle:e.fonts[n.fontId],fillStyle:e.fills[n.fillId],alignment:n.alignment},t)),1)}function rb(e,t){return ab(e?.fontStyle,e?.fillStyle,t),cb(e?.alignment?.horizontal,t),lb(e?.alignment?.vertical,t),{bold:e.fontStyle?.bold,italic:e.fontStyle?.italic,strikethrough:e.fontStyle?.strike,underline:e.fontStyle?.underline,verticalAlign:e.alignment?.vertical?Ov[e.alignment.vertical]:void 0,align:e.alignment?.horizontal?Dv[e.alignment.horizontal]:void 0,rotation:e.alignment?.textRotation?$v(e.alignment.textRotation):void 0,fillColor:e.fillStyle?.patternType===`solid`?Wy(e.fillStyle?.fgColor):Wy(e.fillStyle?.bgColor),textColor:Wy(e.fontStyle?.color),fontSize:e.fontStyle?.size,wrapping:e.alignment?.wrapText?`wrap`:`overflow`}}function ib(e,t){let n=[];for(let r of e.styles){let i=Xy(r.numFmtId,e.numFmts,t);i&&(n[r.numFmtId]=i)}return By(n,1)}function ab(e,t,n){e&&e.name&&!Sv.includes(e.name)&&n.generateNotSupportedWarning(`Font`,e.name,Sv),t&&t.patternType&&!Cv.includes(t.patternType)&&n.generateNotSupportedWarning(`Fill Style`,t.patternType,Cv)}function ob(e,t){yv.includes(e.style)||t.generateNotSupportedWarning(`Border style`,e.style,yv)}function sb(e,t){e.diagonal&&t.generateNotSupportedWarning(`Diagonal Borders`)}function cb(e,t){e&&!bv.includes(e)&&t.generateNotSupportedWarning(`Horizontal Alignment`,e,bv)}function lb(e,t){e&&!xv.includes(e)&&t.generateNotSupportedWarning(`Vertical Alignments`,e,xv)}function ub(e,t,n){let r=[],i=1;for(let a of e){if(a.cfRules.length===0)continue;hb(a,t,n);let e=a.cfRules[0],o,s=[],c={};if(!(e.dxfId===void 0&&!(e.type===`colorScale`||e.type===`iconSet`||e.type===`dataBar`))){switch(e.type){case`aboveAverage`:case`containsErrors`:case`notContainsErrors`:case`timePeriod`:continue;case`dataBar`:let t=db(i++,a);t&&r.push(t);continue;case`colorScale`:let l=fb(i++,a);l&&r.push(l);continue;case`iconSet`:let u=pb(i++,a,n);u&&r.push(u);continue;case`containsText`:case`notContainsText`:case`beginsWith`:case`endsWith`:if(!e.text)continue;o=jv[e.type],s.push(e.text);break;case`expression`:if(!e.formula?.length)continue;o=jv[e.type],s.push(`=${e.formula[0]}`);break;case`duplicateValues`:case`uniqueValues`:case`containsBlanks`:case`notContainsBlanks`:o=jv[e.type];break;case`cellIs`:if(!e.operator||!e.formula||e.formula.length===0)continue;o=Av[e.operator],s.push(Uy(e.formula[0])),e.formula.length===2&&s.push(Uy(e.formula[1]));break;case`top10`:if(e.rank===void 0)continue;o=jv[e.type],s.push(e.rank.toString()),e.percent&&(c.isPercent=!0),e.bottom&&(c.isBottom=!0);break}o&&e.dxfId!==void 0&&r.push({id:(i++).toString(),ranges:a.sqref,stopIfTrue:e.stopIfTrue,rule:{type:`CellIsRule`,operator:o,values:s,...c,style:rb({fontStyle:t[e.dxfId].font,fillStyle:t[e.dxfId].fill},n)}})}}return r}function db(e,t){let n=t.cfRules[0].dataBar;if(!n)return;let r=Jy(Wy(n.color)||`#FFFFFF`);return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:`DataBarRule`,color:r}}}function fb(e,t){let n=t.cfRules[0].colorScale;if(!n||n.cfvos.length!==n.colors.length||n.cfvos.length<2||n.cfvos.length>3)return;let r=[];for(let e=0;e<n.cfvos.length;e++)r.push({color:Jy(Wy(n.colors[e])||`#FFFFFF`),type:Mv[n.cfvos[e].type],value:n.cfvos[e].value});let i=r[0],a=r.length===2?r[1]:r[2],o=r.length===3?r[1]:void 0;return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:`ColorScaleRule`,minimum:i,midpoint:o,maximum:a}}}function pb(e,t,n){let r=t.cfRules[0].iconSet;if(!r)return;let i=r.cfvos,a=r.cfIcons;if(i.length<3||a&&a.length<3)return;i.length>3&&(i=[i[0],i[Math.floor(i.length/2)],i[i.length-1]]),a&&a.length>3&&(a=[a[0],a[Math.floor(a.length/2)],a[a.length-1]]);let o=[];for(let e=1;e<=2;e++){let t=Mv[i[e].type];if(t===`value`)return;o.push({value:i[e].value||``,operator:i[e].gte?`ge`:`gt`,type:t})}let s={lower:a?mb(a[0].iconSet,a[0].iconId):mb(r.iconSet,0),middle:a?mb(a[1].iconSet,a[1].iconId):mb(r.iconSet,1),upper:a?mb(a[2].iconSet,a[2].iconId):mb(r.iconSet,2)};r.reverse&&(s={upper:s.lower,middle:s.middle,lower:s.upper});for(let e of Object.keys(s))if(!s[e])switch(n.generateNotSupportedWarning(`IconSets with empty icons`),e){case`upper`:s[e]=Iy.dots.good;break;case`middle`:s[e]=Iy.dots.neutral;break;case`lower`:s[e]=Iy.dots.bad;break}return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:`IconSetRule`,icons:s,upperInflectionPoint:o[1],lowerInflectionPoint:o[0]}}}function mb(e,t){let n=Nv[e];return n?t===0?Iy[n].bad:t===1?Iy[n].neutral:Iy[n].good:``}function hb(e,t,n){if(e.cfRules.length>1&&n.generateNotSupportedWarning(`Multiple rules conditional formats`),wv.includes(e.cfRules[0].type)||n.generateNotSupportedWarning(`Conditional format type`,e.cfRules[0].type),e.cfRules[0].dxfId){let r=t[e.cfRules[0].dxfId];r.border&&n.generateNotSupportedWarning(`Borders in conditional formats`),r.alignment&&n.generateNotSupportedWarning(`Alignment in conditional formats`),r.numFmt&&n.generateNotSupportedWarning(`Num formats in conditional formats`)}}function gb(e){let t=xa.now();switch(e){case`today`:return Math.floor(Ya(t));case`yesterday`:return t.setDate(t.getDate()-1),Math.floor(Ya(t));case`tomorrow`:return t.setDate(t.getDate()+1),Math.floor(Ya(t));case`lastWeek`:return t.setDate(t.getDate()-6),Math.floor(Ya(t));case`lastMonth`:{let e=t.getMonth()===0?11:t.getMonth()-1,n=new xa(t.getFullYear(),e,1);return t.getDate()>Xa(n)?t.setDate(1):(t.setDate(t.getDate()+1),t.setMonth(t.getMonth()-1)),Math.floor(Ya(t))}case`lastYear`:return t.getMonth()===1&&t.getDate()===29?(t.setDate(28),t.setFullYear(t.getFullYear()-1)):(t.setDate(t.getDate()+1),t.setFullYear(t.getFullYear()-1)),Math.floor(Ya(t))}}function _b(e,t){return`dateValue`in e&&e.dateValue!==`exactDate`?[gb(e.dateValue)]:e.values.map(e=>Pa(e,t))}function vb(e,t){return e.map(e=>{if(e.startsWith(`=`))return e;let n=df(e,B);return typeof n==`number`?V(n,{format:t.dateFormat,locale:t}):``})}function yb(e,t){let n=[],r=1;for(let i of e)if(i)switch(i.type){case`time`:t.generateNotSupportedWarning(`Time data validation rules`);break;case`textLength`:t.generateNotSupportedWarning(`Text length data validation rules`);break;case`whole`:t.generateNotSupportedWarning(`Whole number data validation rules`);break;case`decimal`:let e=bb(r++,i);n.push(e);break;case`list`:let a=xb(r++,i);n.push(a);break;case`date`:if(i.operator===`notEqual`){t.generateNotSupportedWarning(`Not equal date data validation rules`);break}let o=Sb(r++,i);n.push(o);break;case`custom`:let s=Cb(r++,i);n.push(s);break}return n}function bb(e,t){let n=[Uy(t.formula1.toString())];return t.formula2&&n.push(Uy(t.formula2.toString())),{id:e.toString(),ranges:t.sqref,isBlocking:t.errorStyle!==`warning`,criterion:{type:Uv[t.operator],values:n}}}function xb(e,t){let n=t.formula1.toString(),r=vl.test(n);return{id:e.toString(),ranges:t.sqref,isBlocking:t.errorStyle!==`warning`,criterion:{type:r?`isValueInRange`:`isValueInList`,values:r?[n]:n.replaceAll(`"`,``).split(`,`),displayStyle:`arrow`}}}function Sb(e,t){let n,r=[Uy(t.formula1.toString())];return t.formula2?(r.push(Uy(t.formula2.toString())),n={type:Wv[t.operator],values:vb(r,B)}):n={type:Wv[t.operator],values:vb(r,B),dateValue:`exactDate`},{id:e.toString(),ranges:t.sqref,isBlocking:t.errorStyle!==`warning`,criterion:n}}function Cb(e,t){return{id:e.toString(),ranges:t.sqref,isBlocking:t.errorStyle!==`warning`,criterion:{type:`customFormula`,values:[Uy(t.formula1.toString())]}}}let wb=new O,Tb=new O;function Eb(e){let t=1;return e.figures.map(n=>Db(n,(t++).toString(),e)).filter(w)}function Db(e,t,n){let r,i,a,o,s;if(e.anchors.length===1)({col:r,row:i,offset:a}=Nb(e.anchors[0])),s=uy(e.figureSize.cx),o=uy(e.figureSize.cy);else{({col:r,row:i,offset:a}=Nb(e.anchors[0]));let{x:t,y:c}=Pb(e.anchors[0],n),{x:l,y:u}=Pb(e.anchors[1],n);s=l-t,o=u-c}let c={id:t,col:r,row:i,offset:a};if(Ob(e.data))return{...c,width:s,height:o,tag:`chart`,data:Ab(e.data)};if(kb(e.data))return{...c,width:uy(e.data.size.cx),height:uy(e.data.size.cy),tag:`image`,data:{path:e.data.imageSrc,mimetype:e.data.mimetype}}}function Ob(e){return`dataSets`in e&&e.dataSets.length>0}function kb(e){return`imageSrc`in e}function Ab(e){let t=e.dataSets.some(e=>`reference`in(e.label??{})),n={},r=e.labelRange?jb(e.labelRange,t):void 0,i=e.dataSets.map((e,r)=>{let i;e.label&&`text`in e.label&&(i=e.label.text);let a=r.toString();return n[a]={label:i,backgroundColor:e.backgroundColor,trend:Mb(e.trend)},{dataSetId:a,dataRange:jb(e.range,t)}});e.type===`pie`&&i.reverse();let a={dataSource:{dataSets:i,dataSetsHaveTitle:t,labelRange:r,type:`range`},dataSetStyles:n,auxiliaryRange:r,title:e.title??{text:``},background:Wy({rgb:e.backgroundColor})||`#FFFFFF`,legendPosition:e.legendPosition,stacked:e.stacked||!1,aggregated:!1,cumulative:e.cumulative||!1,labelsAsText:!1,horizontal:e.horizontal,isDoughnut:e.isDoughnut,pieHolePercentage:e.pieHolePercentage,showValues:e.showValues,axesDesign:e.axesDesign,slicesColors:e.slicesColors};try{let t=Tb.get(e.type),n=wb.get(`range`);return t.getDefinitionFromContextCreation(a,n)}catch{return}}function jb(e,t){let{sheetName:n,xc:r}=wl(e),i=er(r);if(t&&i.bottom!==void 0&&i.right!==void 0){let e=i.bottom-i.top+1,t=i.right-i.left+1;e===1?i={...i,left:i.left-1}:t===1&&(i={...i,top:i.top-1})}return Tl(n,or(i))}function Mb(e){if(!(!e||!e.type))return{type:e.type===`linear`?`polynomial`:Iv[e.type],order:e.type===`linear`?1:e.order,color:e.color,window:e.window||2,display:!0}}function Nb(e){let t={x:uy(e.colOffset)-1,y:uy(e.rowOffset)-1};return{col:e.col,row:e.row,offset:t}}function Pb(e,t){return{x:dy(e.col,t)+uy(e.colOffset),y:fy(e.row,t)+uy(e.rowOffset)}}let Fb=new RegExp(/'?\[([0-9]*)\](.*)'?!(\$?[a-zA-Z]*\$?[0-9]*)/g),Ib=new RegExp(/SUBTOTAL\(([0-9]*),/g),Lb=new RegExp(fl.source,`ig`);function Rb(e,t){let n=zb(e);for(let r of e.rows.map(e=>e.cells).flat())r?.formula&&(r.formula.content=r.formula.sharedIndex!==void 0&&!r.formula.content?`=`+Vb(r.xc,n[r.formula.sharedIndex]):`=`+r.formula.content,r.formula.content=Bb(r.formula.content,t))}function zb(e){let t={};for(let n of e.rows)for(let e of n.cells)e.formula&&e.formula.sharedIndex!==void 0&&e.formula.content&&(t[e.formula.sharedIndex]={refCellXc:e.xc,formula:e.formula.content});return t}function Bb(e,t){return e=e.replace(`_xlfn.`,``),e=e.replace(/#REF!/g,`#REF`),e=e.replace(Ib,(e,t)=>{let n=Lv[t];return n?n+`(`:e}),e=e.replace(Fb,(e,n,r,i)=>{n=Number(n)-1,i=i.replace(/\$/g,``);let a=t.externalBooks[n]?.sheetNames.findIndex(e=>Xu(e,r))??-1;if(a===-1)return e;let o=t.externalBooks[n].datasets.find(e=>e.sheetId===a)?.data;if(!o)return e;let s=o&&o[i];return(Number(s)?s:`"${s}"`)||e}),e}function Vb(e,t){let n=Un(t.refCellXc),r=t.formula.slice(),i;do if(i=Lb.exec(r),i){let t=Un(i[0].replace(`$`,``)),a=Un(e),o={colFixed:i[0].startsWith(`$`),rowFixed:i[0].includes(`$`,1)},s={col:a.col-n.col,row:a.row-n.row},c={col:o.colFixed?t.col:t.col+s.col,row:o.rowFixed?t.row:t.row+s.row};r=r.slice(0,i.index)+E(c.col,c.row,o)+r.slice(i.index+i[0].length)}while(i);return r}function Hb(e,t){return e.sheets.map(n=>{Rb(n,e);let r=Xb(n),i=n.sheetViews[0],a=Zb(n,`ROW`,r[1]),o=Zb(n,`COL`,r[0]);return{id:n.sheetName,areGridLinesVisible:i?i.showGridLines:!0,name:n.sheetName,colNumber:r[0],rowNumber:r[1],...qb(n,e,r,t),merges:n.merges,cols:Ub(n,r[0],o),rows:Wb(n,r[1],a),...Gb(n,e,r),conditionalFormats:ub(n.cfs,e.dxfs,t),dataValidationRules:yb(n.dataValidations,t),figures:Eb(n),isVisible:n.isVisible,panes:i?{xSplit:i.pane.xSplit,ySplit:i.pane.ySplit}:{xSplit:0,ySplit:0},tables:[],headerGroups:{COL:o,ROW:a},color:Wy(n.sheetProperties?.tabColor),isLocked:n.isLocked}})}function Ub(e,t,n){let r={};for(let i=1;i<t+1;i++){let t=e.cols.find(e=>e.min<=i&&i<=e.max),a;a=t&&t.width?t.width:e.sheetFormat?.defaultColWidth?e.sheetFormat.defaultColWidth:cm;let o=i-1,s=n.some(e=>e.isFolded&&e.start<=o&&o<=e.end);r[o]={size:Xv(a),isHidden:!s&&t?.hidden}}return r}function Wb(e,t,n){let r={};for(let i=1;i<t+1;i++){let t=e.rows.find(e=>e.index===i),a;a=t&&t.height?t.height:e.sheetFormat?.defaultRowHeight?e.sheetFormat.defaultRowHeight:lm;let o=i-1,s=n.some(e=>e.isFolded&&e.start<=o&&o<=e.end);r[o]={size:Yv(a),isHidden:!s&&t?.hidden}}return r}function Gb(e,t,n){let r={rowDefault:[],colDefault:[]},i={rowDefault:[],colDefault:[]};for(let n of e.rows.filter(e=>e.styleIndex))r.rowDefault[n.index-1]=n.styleIndex+1,i.rowDefault[n.index-1]=t.styles[n.styleIndex].numFmtId+1;for(let a of e.cols.filter(e=>e.styleIndex))if(a.min===1&&a.max>=n[0])r.sheetDefault=a.styleIndex+1,i.sheetDefault=t.styles[a.styleIndex].numFmtId+1;else for(let e=a.min;e<=a.max;e++)r.colDefault[e-1]=a.styleIndex+1,i.colDefault[e-1]=t.styles[a.styleIndex].numFmtId+1;return{defaultFormat:i,defaultStyle:r}}function Kb(e){return e.map(fn)}function qb(e,t,n,r){let i={},a={},o={},s={},c=Kb(t.sharedStrings),l=e.hyperlinks.reduce((e,t)=>(e[t.xc]=t,e),{});for(let n of e.rows)for(let e of n.cells)i[e.xc]=Jb(e,l,c,r),e.styleIndex&&(a[e.xc]=e.styleIndex+1,o[e.xc]=t.styles[e.styleIndex].numFmtId+1,s[e.xc]=t.styles[e.styleIndex].borderId+1);for(let r of e.rows.filter(e=>e.styleIndex))for(let e=1;e<=n[0];e++){let n=E(e-1,r.index-1);s[n]??=t.styles[r.styleIndex].borderId+1}for(let r of e.cols.filter(e=>e.styleIndex))for(let e=r.min;e<=Math.min(r.max,n[0]);e++)for(let i=1;i<=n[1];i++){let n=E(e-1,i-1);s[n]??=t.styles[r.styleIndex].borderId+1}return{cells:i,styles:a,formats:o,borders:s}}function Jb(e,t,n,r){let i;switch(e.type){case`sharedString`:i=n[parseInt(e.value,10)];break;case`boolean`:i=Number(e.value)?`TRUE`:`FALSE`;break;case`date`:case`error`:case`inlineStr`:case`number`:case`str`:i=e.value;break}return i&&t[e.xc]&&(i=Yb(t[e.xc],i,r)),e.formula&&(i=e.formula.content),i}function Yb(e,t,n){let r=e.display||t;return!e.relTarget&&!e.location&&n.generateNotSupportedWarning(`Badly formatted hyperlink`),Ut(r,e.relTarget?e.relTarget:qt(wl(e.location).sheetName))}function Xb(e){let t=[0,0];for(let n of e.rows)t[0]=Math.max(t[0],xn(n.cells.map(e=>Un(e.xc).col))),t[1]=Math.max(t[1],n.index);for(let n of e.figures)t[0]=Math.max(t[0],n.anchors[n.anchors.length-1]?.col??0),t[1]=Math.max(t[1],n.anchors[n.anchors.length-1]?.row??0);return t[0]=Math.max(t[0]+5,30),t[1]=Math.max(t[1]+5,100),t}function Zb(e,t,n){let r=e?.sheetProperties?.outlinePr,i=[],a=0;for(let o=0;o<n;o++){let n=$b(e,t,o)?.outlineLevel||0;if(n>a){let n=(t===`ROW`?r?.summaryBelow:r?.summaryRight)??!0,a=Qb(e,t,o,n);a&&i.push(a)}a=n}return i}function Qb(e,t,n,r){let i=$b(e,t,n),a=i?.outlineLevel;if(!a||!a)return;let o=a,s=n,c=i;for(;c&&o>=a;)s++,c=$b(e,t,s),o=c?.outlineLevel||0;let l=n,u=s-1,d=(r?$b(e,t,u+1):$b(e,t,l-1))?.collapsed||!1;return{start:l-1,end:u-1,isFolded:d}}function $b(e,t,n){return t===`COL`?e.cols.find(e=>e.min<=n&&n<=e.max):e.rows.find(e=>e.index===n)}let ex={hasFilters:!1,totalRow:!1,firstColumn:!1,lastColumn:!1,numberOfHeaders:1,bandedRows:!0,bandedColumns:!1,automaticAutofill:!0,styleId:`TableStyleMedium2`},tx={light:N(`Light`),medium:N(`Medium`),dark:N(`Dark`)};function nx(e,t){return{coloredText:ep(t,.3),light:Yf(t,.8),medium:Yf(t,.6),dark:ep(t,.3),mediumBorder:Yf(t,.45),highlight:t,name:e}}let q={black:{name:N(`Black`),coloredText:`#000000`,light:`#D9D9D9`,medium:`#A6A6A6`,dark:`#404040`,mediumBorder:`#000000`,highlight:`#000000`},lightBlue:nx(N(`Blue`),`#346B90`),red:nx(N(`Red`),`#C53628`),lightGreen:nx(N(`Green`),`#748747`),purple:nx(N(`Purple`),`#6C4E65`),gray:{name:N(`Gray`),coloredText:`#666666`,light:`#EEEEEE`,medium:`#DDDDDD`,dark:`#767676`,mediumBorder:`#D0D0D0`,highlight:`#A9A9A9`},orange:nx(N(`Orange`),`#C37034`)},rx={black:q.black,orangeBlue:{...q.lightBlue,highlight:q.orange.highlight},purpleGreen:{...q.lightGreen,highlight:q.purple.highlight},redBlue:{...q.lightBlue,highlight:q.red.highlight}},ix=e=>({category:`light`,templateName:`lightColoredText`,primaryColor:e.highlight,wholeTable:{style:{textColor:e.coloredText},border:{top:{color:e.highlight,style:`thin`},bottom:{color:e.highlight,style:`thin`}}},headerRow:{border:{bottom:{color:e.highlight,style:`thin`}},style:{bold:!0}},totalRow:{border:{top:{color:e.highlight,style:`thin`}},style:{bold:!0}},firstRowStripe:{style:{fillColor:e.light}},firstColumn:{style:{bold:!0}},lastColumn:{style:{bold:!0}}}),ax=e=>({category:`light`,templateName:`lightWithHeader`,primaryColor:e.highlight,wholeTable:{border:{top:{color:e.highlight,style:`thin`},bottom:{color:e.highlight,style:`thin`},left:{color:e.highlight,style:`thin`},right:{color:e.highlight,style:`thin`}}},headerRow:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0},border:{bottom:{color:e.highlight,style:`thin`}}},totalRow:{border:{top:{color:e.highlight,style:`medium`}},style:{bold:!0}},firstRowStripe:{border:{bottom:{color:e.highlight,style:`thin`}}},secondRowStripe:{border:{bottom:{color:e.highlight,style:`thin`}}},firstColumn:{style:{bold:!0}},lastColumn:{style:{bold:!0}}}),ox=e=>({category:`light`,templateName:`lightAllBorders`,primaryColor:e.highlight,wholeTable:{border:{top:{color:e.highlight,style:`thin`},bottom:{color:e.highlight,style:`thin`},left:{color:e.highlight,style:`thin`},right:{color:e.highlight,style:`thin`},horizontal:{color:e.highlight,style:`thin`},vertical:{color:e.highlight,style:`thin`}}},headerRow:{border:{bottom:{color:e.highlight,style:`medium`}},style:{bold:!0}},totalRow:{border:{top:{color:e.highlight,style:`medium`}},style:{bold:!0}},firstRowStripe:{style:{fillColor:e.light}},firstColumnStripe:{style:{fillColor:e.light}},firstColumn:{style:{bold:!0}},lastColumn:{style:{bold:!0}}}),sx=e=>({category:`medium`,templateName:`mediumBandedBorders`,primaryColor:e.highlight,wholeTable:{border:{top:{color:e.mediumBorder,style:`thin`},bottom:{color:e.mediumBorder,style:`thin`},left:{color:e.mediumBorder,style:`thin`},right:{color:e.mediumBorder,style:`thin`},horizontal:{color:e.mediumBorder,style:`thin`}}},headerRow:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},totalRow:{border:{top:{color:e.highlight,style:`medium`}},style:{bold:!0}},firstRowStripe:{style:{fillColor:e.light}},firstColumnStripe:{style:{fillColor:e.light}},firstColumn:{style:{bold:!0}},lastColumn:{style:{bold:!0}}}),cx=e=>({category:`medium`,templateName:`mediumWhiteBorders`,primaryColor:e.highlight,wholeTable:{border:{horizontal:{color:`#FFFFFF`,style:`thin`},vertical:{color:`#FFFFFF`,style:`thin`}},style:{fillColor:e.light}},headerRow:{border:{bottom:{color:`#FFFFFF`,style:`thick`}},style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},totalRow:{border:{top:{color:`#FFFFFF`,style:`thick`}},style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},firstColumn:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},lastColumn:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},firstRowStripe:{style:{fillColor:e.medium}},firstColumnStripe:{style:{fillColor:e.medium}}}),lx=e=>({category:`medium`,templateName:`mediumMinimalBorders`,primaryColor:e.highlight,wholeTable:{border:{top:{color:`#000000`,style:`medium`},bottom:{color:`#000000`,style:`medium`}}},totalRow:{border:{top:{color:`#000000`,style:`medium`}},style:{bold:!0}},headerRow:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0},border:{bottom:{color:`#000000`,style:`medium`}}},firstColumn:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},lastColumn:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},firstRowStripe:{style:{fillColor:q.black.light}},firstColumnStripe:{style:{fillColor:q.black.light}}}),ux=e=>({category:`medium`,templateName:`mediumAllBorders`,primaryColor:e.highlight,wholeTable:{border:{top:{color:e.mediumBorder,style:`thin`},bottom:{color:e.mediumBorder,style:`thin`},left:{color:e.mediumBorder,style:`thin`},right:{color:e.mediumBorder,style:`thin`},horizontal:{color:e.mediumBorder,style:`thin`},vertical:{color:e.mediumBorder,style:`thin`}},style:{fillColor:e.light}},totalRow:{border:{top:{color:e.highlight,style:`medium`}},style:{bold:!0}},firstRowStripe:{style:{fillColor:e.medium}},firstColumnStripe:{style:{fillColor:e.medium}},firstColumn:{style:{bold:!0}},lastColumn:{style:{bold:!0}},headerRow:{style:{bold:!0}}}),dx=e=>({category:`dark`,templateName:`dark`,primaryColor:e.highlight,wholeTable:{style:{fillColor:e.highlight,textColor:`#FFFFFF`}},totalRow:{style:{fillColor:e.dark,textColor:`#FFFFFF`,bold:!0},border:{top:{color:`#FFFFFF`,style:`thick`}}},headerRow:{style:{fillColor:`#000000`,bold:!0},border:{bottom:{color:`#FFFFFF`,style:`thick`}}},firstColumn:{style:{fillColor:e.dark,bold:!0},border:{right:{color:`#FFFFFF`,style:`thick`}}},lastColumn:{style:{fillColor:e.dark,bold:!0},border:{left:{color:`#FFFFFF`,style:`thick`}}},firstRowStripe:{style:{fillColor:e.dark}},firstColumnStripe:{style:{fillColor:e.dark}}}),fx=e=>({category:`dark`,templateName:`darkNoBorders`,primaryColor:e.highlight,wholeTable:{style:{fillColor:e.light}},totalRow:{border:{top:{color:`#000000`,style:`medium`}},style:{bold:!0}},headerRow:{style:{fillColor:e.highlight,textColor:`#FFFFFF`,bold:!0}},firstRowStripe:{style:{fillColor:e.medium}},firstColumnStripe:{style:{fillColor:e.medium}},firstColumn:{style:{bold:!0}},lastColumn:{style:{bold:!0}}}),px=dx(q.black);px.wholeTable.style.fillColor=`#737373`;let mx=lx(q.black);mx.wholeTable.border={...mx.wholeTable.border,left:{color:`#000000`,style:`thin`},right:{color:`#000000`,style:`thin`},horizontal:{color:`#000000`,style:`thin`},vertical:{color:`#000000`,style:`thin`}};function J(e,t,n){return{...t(n),displayName:`${n.name}, ${e}`}}let hx={None:{category:`light`,templateName:`none`,primaryColor:``,displayName:N(`None`)},TableStyleLight1:J(`TableStyleLight1`,ix,q.black),TableStyleLight2:J(`TableStyleLight2`,ix,q.lightBlue),TableStyleLight3:J(`TableStyleLight3`,ix,q.red),TableStyleLight4:J(`TableStyleLight4`,ix,q.lightGreen),TableStyleLight5:J(`TableStyleLight5`,ix,q.purple),TableStyleLight6:J(`TableStyleLight6`,ix,q.gray),TableStyleLight7:J(`TableStyleLight7`,ix,q.orange),TableStyleLight8:J(`TableStyleLight8`,ax,q.black),TableStyleLight9:J(`TableStyleLight9`,ax,q.lightBlue),TableStyleLight10:J(`TableStyleLight10`,ax,q.red),TableStyleLight11:J(`TableStyleLight11`,ax,q.lightGreen),TableStyleLight12:J(`TableStyleLight12`,ax,q.purple),TableStyleLight13:J(`TableStyleLight13`,ax,q.gray),TableStyleLight14:J(`TableStyleLight14`,ax,q.orange),TableStyleLight15:J(`TableStyleLight15`,ox,q.black),TableStyleLight16:J(`TableStyleLight16`,ox,q.lightBlue),TableStyleLight17:J(`TableStyleLight17`,ox,q.red),TableStyleLight18:J(`TableStyleLight18`,ox,q.lightGreen),TableStyleLight19:J(`TableStyleLight19`,ox,q.purple),TableStyleLight20:J(`TableStyleLight20`,ox,q.gray),TableStyleLight21:J(`TableStyleLight21`,ox,q.orange),TableStyleMedium1:J(`TableStyleMedium1`,sx,q.black),TableStyleMedium2:J(`TableStyleMedium2`,sx,q.lightBlue),TableStyleMedium3:J(`TableStyleMedium3`,sx,q.red),TableStyleMedium4:J(`TableStyleMedium4`,sx,q.lightGreen),TableStyleMedium5:J(`TableStyleMedium5`,sx,q.purple),TableStyleMedium6:J(`TableStyleMedium6`,sx,q.gray),TableStyleMedium7:J(`TableStyleMedium7`,sx,q.orange),TableStyleMedium8:J(`TableStyleMedium8`,cx,q.black),TableStyleMedium9:J(`TableStyleMedium9`,cx,q.lightBlue),TableStyleMedium10:J(`TableStyleMedium10`,cx,q.red),TableStyleMedium11:J(`TableStyleMedium11`,cx,q.lightGreen),TableStyleMedium12:J(`TableStyleMedium12`,cx,q.purple),TableStyleMedium13:J(`TableStyleMedium13`,cx,q.gray),TableStyleMedium14:J(`TableStyleMedium14`,cx,q.orange),TableStyleMedium15:{...mx,displayName:`Black, TableStyleMedium15`},TableStyleMedium16:J(`TableStyleMedium16`,lx,q.lightBlue),TableStyleMedium17:J(`TableStyleMedium17`,lx,q.red),TableStyleMedium18:J(`TableStyleMedium18`,lx,q.lightGreen),TableStyleMedium19:J(`TableStyleMedium19`,lx,q.purple),TableStyleMedium20:J(`TableStyleMedium20`,lx,q.gray),TableStyleMedium21:J(`TableStyleMedium21`,lx,q.orange),TableStyleMedium22:J(`TableStyleMedium22`,ux,q.black),TableStyleMedium23:J(`TableStyleMedium23`,ux,q.lightBlue),TableStyleMedium24:J(`TableStyleMedium24`,ux,q.red),TableStyleMedium25:J(`TableStyleMedium25`,ux,q.lightGreen),TableStyleMedium26:J(`TableStyleMedium26`,ux,q.purple),TableStyleMedium27:J(`TableStyleMedium27`,ux,q.gray),TableStyleMedium28:J(`TableStyleMedium28`,ux,q.orange),TableStyleDark1:{...px,displayName:`Black, TableStyleDark1`},TableStyleDark2:J(`TableStyleDark2`,dx,q.lightBlue),TableStyleDark3:J(`TableStyleDark3`,dx,q.red),TableStyleDark4:J(`TableStyleDark4`,dx,q.lightGreen),TableStyleDark5:J(`TableStyleDark5`,dx,q.purple),TableStyleDark6:J(`TableStyleDark6`,dx,q.gray),TableStyleDark7:J(`TableStyleDark7`,dx,q.orange),TableStyleDark8:J(`TableStyleDark8`,fx,rx.black),TableStyleDark9:J(`TableStyleDark9`,fx,rx.redBlue),TableStyleDark10:J(`TableStyleDark10`,fx,rx.purpleGreen),TableStyleDark11:J(`TableStyleDark11`,fx,rx.orangeBlue)},gx={none:()=>({category:`none`,templateName:`none`,primaryColor:``,name:`none`}),lightColoredText:ix,lightAllBorders:ox,mediumAllBorders:ux,lightWithHeader:ax,mediumBandedBorders:sx,mediumMinimalBorders:lx,darkNoBorders:fx,mediumWhiteBorders:cx,dark:dx};function _x(e,t,n){let r=nx(``,n);return{...gx[t](r),category:`custom`,displayName:e}}function vx(e,t){for(let n of t.sheets){let t=e.sheets.find(e=>e.name===n.sheetName);if(t){t.tables||=[];for(let e of n.tables)t.tables.push({range:e.ref,config:yx(e)});for(let e of n.pivotTables)t.tables.push({range:e.location.ref,config:bx(e)})}}xx(e,t.sheets)}function yx(e){let t=e.style?.name||``;return{hasFilters:e.autoFilter!==void 0,numberOfHeaders:e.headerRowCount,totalRow:e.totalsRowCount>0,firstColumn:e.style?.showFirstColumn||!1,lastColumn:e.style?.showLastColumn||!1,bandedRows:e.style?.showRowStripes||!1,bandedColumns:e.style?.showColumnStripes||!1,styleId:hx[t]?t:ex.styleId}}function bx(e){return{hasFilters:!1,numberOfHeaders:e.location.firstDataRow,totalRow:e.rowGrandTotals,firstColumn:!0,lastColumn:e.style?.showLastColumn||!1,bandedRows:e.style?.showRowStripes||!1,bandedColumns:e.style?.showColStripes||!1,styleId:ex.styleId}}function xx(e,t){let n=null;Cx(e,t);let r=e.sheets;for(let e of r){let i=t.find(t=>Xu(t.sheetName,e.name)).tables;if(!(!i||i.length===0)){n||=Sx(r);for(let t of i)for(let i in n){let a=r.find(e=>e.id===i);for(let r in n[i]){let o=n[i][r];for(let s=o.length-3;s>=0;s-=2){let o=n[i][r][s];if(!o.endsWith(t.name))continue;let c=n[i][r][s+1],l=wx(e.id===a.id?``:e.name+`!`,c,t,r);n[i][r][s+2]=o.slice(0,o.indexOf(t.name))+l+n[i][r][s+2],n[i][r].splice(s,2)}}}}}if(n)for(let e in n){let t=r.find(t=>t.id===e);for(let r in n[e]){let i=n[e][r];if(i.length===1){t.cells[r]=i[0];continue}let a=``;for(let e=0;e<i.length;e+=2)a+=i[e]+`[`+i[e+1]+`]`;a+=i[i.length-1],t.cells[r]=a}}}function Sx(e){let t={};for(let n of e)for(let e in n.cells){let r=n.cells[e];if(!r||!r.startsWith(`=`))continue;let i=r.indexOf(`[`);if(i===-1)continue;let a=[],o=r.slice(0,i),s=``,c=1,l=0,u=i;for(let e=i+1;e<r.length;e++){if(r[e]===`[`){c===0&&(o=r.slice(l,e),u=e),c++;continue}r[e]===`]`&&(c--,c===0&&(s=r.slice(u+1,e),a.push(o),a.push(s),l=e+1))}a.length&&(t[n.id]||(t[n.id]={}),a.push(r.slice(l)),t[n.id][e]=[...a])}return t}function Cx(e,t){for(let n in e.namedRanges||{}){let r=e.namedRanges[n];if(r.endsWith(`]`))for(let i of e.sheets){let a=t.find(e=>Xu(e.sheetName,i.name))?.tables;for(let t of a||[]){if(!t.name||!r.startsWith(t.name+`[`))continue;let a=wx(i.name+`!`,r.slice(t.name.length+1,r.length-1),t,`invalidCellXc`);e.namedRanges[n]=a}}}}function wx(e,t,n,r){t===``&&(t=`#Data`);let i=t.split(`,`).map(e=>e.trim()),a=tr(n.ref),o=[],s=[],c=[];for(let e of i)if(Tx(e).startsWith(`#`)){let t=Tx(e);switch(c.push(t),t){case`#All`:s.push(a.top,a.bottom);break;case`#Data`:let e=n.headerRowCount?a.top+n.headerRowCount:a.top,t=n.totalsRowCount?a.bottom-n.totalsRowCount:a.bottom;s.push(e,t);break;case`#This Row`:s.push(Un(r).row);break;case`#Headers`:if(!n.headerRowCount)return P.InvalidReference;s.push(a.top);break;case`#Totals`:if(!n.totalsRowCount)return P.InvalidReference;s.push(a.bottom);break}}else{let t=e.split(`:`).map(e=>e.trim()).map(Tx);if(o.length)return P.InvalidReference;let r=n.cols.findIndex(e=>e.name===t[0]);if(r===-1)return P.InvalidReference;if(o.push(r+a.left),t[1]){let e=n.cols.findIndex(e=>e.name===t[1]);if(e===-1)return P.InvalidReference;o.push(e+a.left)}}if(!Ex(c))return P.InvalidReference;if(s.length===0){let e=n.headerRowCount?a.top+n.headerRowCount:a.top,t=n.totalsRowCount?a.bottom-n.totalsRowCount:a.bottom;s.push(e,t)}return o.length===0&&o.push(a.left,a.right),e+or({top:Math.min(...s),left:Math.min(...o),bottom:Math.max(...s),right:Math.max(...o)})}function Tx(e){return e.startsWith(`[`)&&e.endsWith(`]`)?e.slice(1,e.length-1):e}function Ex(e){return e.length<2?!0:e.length>2?!1:e.includes(`#Data`)&&e.includes(`#Totals`)?!0:!!(e.includes(`#Headers`)&&e.includes(`#Data`))}function Dx(e,t,n){return{content:new XMLSerializer().serializeToString(e),path:t,contentType:n}}function Ox(e){return String(e).replace(/\&/g,`&amp;`).replace(/\</g,`&lt;`).replace(/\>/g,`&gt;`).replace(/\"/g,`&quot;`).replace(/\'/g,`&apos;`).replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,``)}function Y(e){return new ov(e.map(([e,t])=>`${e}="${Ox(t)}"`).join(` `))}function kx(e,t=`text/xml`){let n=new DOMParser().parseFromString(e.toString(),t),r=n.querySelector(`parsererror`);if(r){let t=r.innerHTML,n=parseInt(t.split(`:`)[0],10),i=e.toString().trim().split(`
19
19
  `),a=i.slice(Math.max(n-3,0),Math.min(n+2,i.length)).join(`
20
20
  `);throw Error(`XML string could not be parsed: ${t}\n${a}`)}return n}function Ax(e){if(e)return{style:e.style,color:{rgb:e.color}}}function jx(e){let t=[{},...Object.values(e.borders).map(e=>({left:Ax(e.left),right:Ax(e.right),bottom:Ax(e.bottom),top:Ax(e.top)}))];return{relsFiles:[],sharedStrings:[],chartIds:[],imageIds:[],styles:[{fontId:0,fillId:0,numFmtId:0,borderId:0,alignment:{}}],fonts:[{size:Qe,family:2,color:{rgb:`000000`},name:`Arial`}],fills:[{reservedAttribute:`none`},{reservedAttribute:`gray125`}],borders:t,numFmts:[],dxfs:[],namedRanges:[]}}function Mx(e,t){return X`
@@ -64,7 +64,7 @@ You can download it directly instead.`,5),sticky:!1,type:`warning`});return}r=aw
64
64
  `),e+=i.value.textContent)}return e}};function oN(e,t){let n=(e.color?Mf(e.color):``)===(t.style?.color?Mf(t.style?.color):``),r=T(e.classes,[...t.classList]),i=t.textContent===e.value;return n&&r&&i}let sN=new DOMParser,cN=sN.parseFromString(`<br>`,`text/html`).body.firstChild,lN=sN.parseFromString(`<span><br></span>`,`text/html`).body.firstChild;function uN(e){if(e.childNodes.length>1)return!1;let t=e.firstChild?.cloneNode(!0);return t?t instanceof Element?(t.removeAttribute(`class`),t.removeAttribute(`style`),t.isEqualNode(cN)||t.isEqualNode(lN)||!1):!1:!0}var dN=class extends k{static template=`o-spreadsheet-Collapse`;props=(0,t.useProps)({isCollapsed:M.boolean()});contentRef=t.signal.ref();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`)}}},fN=class extends k{static template=`o-spreadsheet-FunctionDescriptionProvider`;static components={Collapse:dN};props=(0,t.useProps)({functionDescription:M.FunctionDescription(),argsToFocus:M.array(M.number()),repeatingArgGroupIndex:M.number().optional()});state=(0,t.proxy)({isCollapsed:!0});toggle(){this.state.isCollapsed=!this.state.isCollapsed}getContext(){return this.props}get formulaHeaderContent(){let{functionDescription:e,repeatingArgGroupIndex:t,argsToFocus:n}=this.props,r=this.env.model.getters.getLocale().formulaArgSeparator+` `,i=[{content:e.name+` ( `}];for(let a=0;a<e.args.length;a++){let o=e.args[a],s=o.repeating;if(a>0&&i.push({content:r}),s){let s=o.optional||(t??0)>0,c=e.args.slice(a,a+e.nbrArgRepeating).map(e=>e.name);t&&i.push({content:`... `+r}),s&&i.push({content:`[`});for(let e=0;e<c.length;e++){let o=c[e],s=a+e,l=n.includes(s);i.push({content:o+((t??0)+1),focused:l}),e<c.length-1&&i.push({content:r})}if(s&&i.push({content:`]`}),e.nbrArgRepeating<=1){i.push({content:r+`[`});for(let e=0;e<c.length;e++){let n=c[e];i.push({content:n+((t??0)+2)}),e<c.length-1&&i.push({content:r})}i.push({content:`]`})}i.push({content:r+`... `}),a+=e.nbrArgRepeating-1}else{let e=o.optional||o.default,t=n.includes(a);e&&i.push({content:`[`}),i.push({content:o.name,focused:t}),e&&i.push({content:`]`})}}return i.push({content:` )`}),i}},pN=class extends k{static template=`o-spreadsheet-SpeechBubble`;static components={};props=(0,t.useProps)({content:M.string(),anchorRect:M.Rect()});spreadsheetRect=Nw();bubbleRef=t.signal.ref();setup(){Vi(()=>{let e=this.bubbleRef();if(!e)return;let t=this.props.anchorRect,n=b(e),r=t.x+t.width/2-n.width/2-this.spreadsheetRect.x,i=t.y-n.height-7-this.spreadsheetRect.y;e.style.left=`${r}px`,e.style.top=`${i}px`})}};let mN=ul.content;var hN=class extends k{static template=`o-spreadsheet-Composer`;static components={TextValueProvider:iN,FunctionDescriptionProvider:fN,SpeechBubble:pN};props=(0,t.useProps)({focus:M.ComposerFocusType(),inputStyle:M.string().optional(``),rect:M.Rect().optional(),delimitation:M.DOMDimension().optional(),onComposerCellFocused:M.function().optional(),onComposerContentFocused:M.function(),isDefaultFocus:M.boolean().optional(!1),onInputContextMenu:M.function().optional(),composerStore:M.Store(),placeholder:M.string().optional(),inputMode:M.string().optional(`text`),showAssistant:M.boolean().optional(!0)});DOMFocusableElementStore;composerRef=t.signal.ref();containerRef=t.signal.ref();contentHelper=new aN(this.composerRef());composerState=(0,t.proxy)({positionStart:0,positionEnd:0,hoveredRect:void 0});functionDescriptionState=(0,t.proxy)({showDescription:!1,functionDescription:{},argsToFocus:[],repeatingArgGroupIndex:0});assistant=(0,t.proxy)({forcedClosed:!1});compositionActive=!1;spreadsheetRect=Nw();lastHoveredTokenIndex=void 0;debouncedHover=Xt((e,t,n)=>{let r=this.contentHelper.getCurrentSelection(),i=this.props.composerStore.currentContent;if(r.start!==r.end||i!==t)return;let a=this.props.composerStore.hoveredTokens;this.props.composerStore.hoverToken(e),T(a,this.props.composerStore.hoveredTokens)||(this.composerState.hoveredRect=n)},120);get assistantStyleProperties(){let e=this.composerRef().getBoundingClientRect(),t={};t[`min-width`]=`${Math.min(this.props.rect?.width||1/0,300)}px`;let n=this.props.composerStore.autoCompleteProposals?.some(e=>e.description);if((this.functionDescriptionState.showDescription||n)&&(t.width=`300px`),this.props.delimitation&&this.props.rect){let{x:e,y:n,height:r}=this.props.rect,i=this.props.delimitation.height-(n+r);t[`max-height`]=`${i}px`,n>i&&(t[`max-height`]=`${n-9}px`,t.top=`-3px`,t.transform=`translate(0, -100%)`),e+300>this.props.delimitation.width&&(t.right=`0px`)}else t[`max-height`]=`${this.spreadsheetRect.height-e.bottom-1}px`,e.left+300+15+9>this.spreadsheetRect.width&&(t.right=`9px`);return t}get assistantStyle(){let e=this.assistantStyleProperties;return G({"max-height":e[`max-height`],width:e.width,"min-width":e[`min-width`]})}get assistantContainerStyle(){let e=this.assistantStyleProperties;return G({top:e.top,right:e.right,transform:e.transform})}shouldProcessInputEvents=!1;tokens=[];keyMapping={Enter:e=>this.processEnterKey(e,`down`),"Shift+Enter":e=>this.processEnterKey(e,`up`),"Alt+Enter":this.processNewLineEvent,"Ctrl+Enter":this.processNewLineEvent,Escape:this.processEscapeKey,F2:e=>this.toggleEditionMode(e),F4:e=>this.processF4Key(e),Tab:e=>this.processTabKey(e,`right`),"Shift+Tab":e=>this.processTabKey(e,`left`)};keyCodeMapping={NumpadDecimal:this.processNumpadDecimal};setup(){this.DOMFocusableElementStore=A(Ow),(0,t.onMounted)(()=>{let e=this.composerRef();e&&(this.props.isDefaultFocus&&this.DOMFocusableElementStore.setFocusableElement(e),this.contentHelper.updateEl(e))}),(0,t.onWillUnmount)(()=>{this.debouncedHover.stopDebounce()}),Vi(()=>{this.processContent(),document.activeElement===this.contentHelper.el&&this.props.composerStore.editionMode===`inactive`&&!this.props.isDefaultFocus&&this.DOMFocusableElementStore.focus()}),Vi(()=>{this.processTokenAtCursor()},()=>[this.props.composerStore.editionMode!==`inactive`]),Vi(()=>{this.contentHelper.scrollSelectionIntoView()},()=>[this.props.composerStore.composerSelection.start,this.props.composerStore.composerSelection.end])}processArrowKeys(e){let t=this.props.composerStore.tokenAtCursor;if((this.props.composerStore.isSelectingRange||this.props.composerStore.editionMode===`inactive`)&&!([`ArrowUp`,`ArrowDown`].includes(e.key)&&this.props.composerStore.isAutoCompleteDisplayed&&t?.type!==`REFERENCE`)){this.functionDescriptionState.showDescription=!1,this.props.composerStore.hideHelp(),e.preventDefault(),e.stopPropagation(),IM(e,this.env.model.selection);return}let n=this.props.composerStore.currentContent;if(this.props.focus===`cellFocus`&&!this.props.composerStore.isAutoCompleteDisplayed&&!Dn(n)){this.props.composerStore.stopEdition();return}e.stopPropagation(),this.handleArrowKeysForAutocomplete(e)}handleArrowKeysForAutocomplete(e){[`ArrowUp`,`ArrowDown`].includes(e.key)&&this.props.composerStore.isAutoCompleteDisplayed&&(e.preventDefault(),this.props.composerStore.moveAutoCompleteSelection(e.key===`ArrowDown`?`next`:`previous`))}processTabKey(e,t){e.preventDefault(),e.stopPropagation(),this.props.composerStore.autoCompleteOrStop(t,this.assistant.forcedClosed)}processEnterKey(e,t){e.preventDefault(),e.stopPropagation(),this.props.composerStore.autoCompleteOrStop(t,this.assistant.forcedClosed)}processNewLineEvent(e){e.preventDefault(),e.stopPropagation();let t=this.contentHelper.getText(),n=this.contentHelper.getCurrentSelection(),r=Math.min(n.start,n.end),i=Math.max(n.start,n.end);this.props.composerStore.stopComposerRangeSelection(),this.props.composerStore.setCurrentContent(t.slice(0,r)+`
65
65
  `+t.slice(i),{start:r+1,end:r+1}),this.processContent()}processEscapeKey(e){this.props.composerStore.cancelEdition(),e.stopPropagation(),e.preventDefault()}processF4Key(e){e.stopPropagation(),this.props.composerStore.cycleReferences(),this.processContent()}toggleEditionMode(e){e.stopPropagation(),this.props.composerStore.toggleEditionMode(),this.processContent()}processNumpadDecimal(e){e.stopPropagation(),e.preventDefault();let t=this.env.model.getters.getLocale(),n=this.contentHelper.getCurrentSelection(),r=this.props.composerStore.currentContent,i=r.slice(0,n.start)+t.decimalSeparator+r.slice(n.end);this.props.composerStore.setCurrentContent(i,{start:n.start+1,end:n.start+1}),this.processContent()}onCompositionStart(){this.compositionActive=!0}onCompositionEnd(){this.compositionActive=!1}onKeydown(e){if(this.props.composerStore.editionMode===`inactive`)return;if(e.key.startsWith(`Arrow`)){this.processArrowKeys(e);return}let t=this.keyMapping[ce(e)]||this.keyCodeMapping[ce(e,`code`)];t?t.call(this,e):e.stopPropagation()}onPaste(e){this.props.composerStore.editionMode===`inactive`?e.preventDefault():e.stopPropagation()}onInput(e){if(!this.shouldProcessInputEvents)return;e.stopPropagation();let t;if(t=this.props.composerStore.editionMode===`inactive`?e.data||``:this.contentHelper.getText(),this.props.focus===`inactive`)return this.props.onComposerCellFocused?.(t);let n=this.contentHelper.getCurrentSelection();this.props.composerStore.stopComposerRangeSelection(),this.props.composerStore.setCurrentContent(t,n),this.processTokenAtCursor()}onKeyup(e){if(this.contentHelper.el===document.activeElement){if(this.props.composerStore.isAutoCompleteDisplayed&&[`ArrowUp`,`ArrowDown`].includes(e.key)||this.props.composerStore.isSelectingRange&&e.key?.startsWith(`Arrow`))return;let{start:t,end:n}=this.props.composerStore.composerSelection,{start:r,end:i}=this.contentHelper.getCurrentSelection();(r!==t||i!==n)&&this.props.composerStore.changeComposerCursorSelection(r,i),this.processTokenAtCursor()}}onBlur(e){if(this.props.composerStore.editionMode===`inactive`)return;let t=e.relatedTarget;if(!t||!(t instanceof HTMLElement)){this.props.composerStore.stopEdition();return}if(!this.containerRef()?.contains(e.relatedTarget)){if(t.attributes.getNamedItem(`composerFocusableElement`)){this.contentHelper.el.focus();return}t.classList.contains(`o-composer`)||this.props.composerStore.stopEdition()}}onMousedown(e){e.button>0||this.env.isMobile()&&!he()||(this.debouncedHover.stopDebounce(),this.contentHelper.removeSelection())}onMouseup(){if(this.env.model.getters.isReadonly())return;let e=this.contentHelper.getCurrentSelection();e.start!==e.end&&this.props.composerStore.hoverToken(void 0)}onClick(){if(this.env.model.getters.isReadonly())return;let e=this.contentHelper.getCurrentSelection(),t=this.props.composerStore.editionMode===`inactive`;this.props.onComposerContentFocused(e),t||this.props.composerStore.changeComposerCursorSelection(e.start,e.end),this.processTokenAtCursor()}onDblClick(){if(this.env.model.getters.isReadonly())return;let e=this.props.composerStore.currentContent;if(Dn(e)){let t=this.props.composerStore.currentTokens,n=this.contentHelper.getCurrentSelection();if(n.start===n.end)return;let r=e.substring(n.start,n.end),i=t.filter(e=>e.value.includes(r)&&e.start<=n.start&&e.end>=n.end)[0];if(!i)return;i.type===`REFERENCE`&&this.props.composerStore.changeComposerCursorSelection(i.start,i.end)}}onContextMenu(e){this.props.composerStore.editionMode===`inactive`&&this.props.onInputContextMenu?.(e)}closeAssistant(){this.props.composerStore.canBeToggled&&(this.assistant.forcedClosed=!0)}openAssistant(){this.props.composerStore.canBeToggled&&(this.assistant.forcedClosed=!1)}onWheel(e){let t=this.composerRef();t&&t.scrollHeight>t.clientHeight&&e.stopPropagation()}processContent(){if(this.compositionActive)return;this.shouldProcessInputEvents=!1,this.props.focus!==`inactive`&&document.activeElement!==this.contentHelper.el&&this.contentHelper.el.focus();let e=this.getContentLines();if(this.contentHelper.setText(e),e.length!==0&&e.length[0]!==0&&this.props.focus!==`inactive`){let{start:e,end:t}=this.props.composerStore.composerSelection;this.contentHelper.selectRange(e,t)}this.shouldProcessInputEvents=!0}getContentLines(){let e=this.props.composerStore.currentContent,t=Dn(e);return e===``?[]:t&&this.props.focus!==`inactive`?this.splitHtmlContentIntoLines(this.getHtmlContentFromTokens()):this.splitHtmlContentIntoLines([{value:e,classes:[]}])}getHtmlContentFromTokens(){let e=this.props.composerStore.currentTokens,t=[],{end:n,start:r}=this.props.composerStore.composerSelection;for(let i=0;i<e.length;i++){let a=e[i],o=a.color||`light-dark(#000000, #ffffff)`;a.isBlurred&&(o=Jf(o,.5));let s=[];a.type===`REFERENCE`&&this.props.composerStore.tokenAtCursor===a&&this.props.composerStore.editionMode===`selecting`&&s.push(`text-decoration-underline`),n===r&&a.isParenthesisLinkedToCursor&&s.push(`highlight-parenthesis-flag`),a.isInHoverContext&&s.push(`highlight-flag`),this.props.composerStore.showSelectionIndicator&&n===r&&n===a.end&&s.push(`selector-flag`),t.push({value:a.value,color:o,classes:s,onHover:e=>this.onTokenHover(i,e),onStopHover:()=>this.onTokenHover(void 0)})}return t}onTokenHover(e,t){if(this.lastHoveredTokenIndex!==e){this.lastHoveredTokenIndex=e;let n=this.props.composerStore.currentContent;this.debouncedHover(e,n,t)}}splitHtmlContentIntoLines(e){let t=[],n=[];for(let r of e)if(r.value.includes(`
66
66
  `)){let e=r.value.split(`
67
- `),i=e.pop();for(let i of e)n.push({color:r.color,value:i}),t.push(n),n=[];n.push({...r,value:i})}else n.push(r);n.length&&t.push(n);let r=[];for(let e of t)e.every(this.isContentEmpty)?r.push([e[0]]):r.push(e.filter(e=>!this.isContentEmpty(e)));return r}isContentEmpty(e){return!(e.value||e.classes?.length)}processTokenAtCursor(){let e=this.props.composerStore;this.functionDescriptionState.showDescription=!1;let t=this.props.composerStore.tokenAtCursor;if(Dn(e.currentContent)&&t&&t.type!==`SYMBOL`){let e=t.functionContext,n=e?.parent.toUpperCase();if(e&&n&&n in mN&&t.type!==`UNKNOWN`){let r=mN[n],i=e.argPosition,a=e.args.length;this.functionDescriptionState.functionDescription=r;let o=this.props.composerStore.currentTokens.some(e=>e.type===`RIGHT_PAREN`&&e.parenthesesCode===t.parenthesesCode);this.functionDescriptionState.argsToFocus=this.getArgsToFocus(o,r,a,i),this.functionDescriptionState.showDescription=!0,this.functionDescriptionState.repeatingArgGroupIndex=this.getRepeatingArgGroupIndex(r,a,i)}}}getRepeatingArgGroupIndex(e,t,n){let{minArgRequired:r,maxArgPossible:i,nbrArgRepeating:a}=e;if(!a)return;let o=(a?Math.ceil((t-r)/a):0)*a+r;return Xc(e,Math.max(Math.min(i,o),r))[n].repeatingGroupIndex??0}getArgsToFocus(e,t,n,r){let{nbrArgRepeating:i,minArgRequired:a,nbrOptionalNonRepeatingArgs:o,maxArgPossible:s}=t;if(e){let e=Xc(t,Math.max(Math.min(s,n),a))[r]?.index;return e===void 0?[]:[e]}let c=Math.max(n,a),l=i?a+Math.ceil((c-a)/i)*i+o:s,u=[];for(let e=c;e<=l;e++){let n=Xc(t,e)[r]?.index;n!==void 0&&u.push(n)}return[...new Set(u)]}autoComplete(e){!e?.text||this.assistant.forcedClosed&&this.props.composerStore.canBeToggled||(this.props.composerStore.insertAutoCompleteValue(e),this.processTokenAtCursor())}get displaySpeechBubble(){return!!(this.props.focus!==`inactive`&&this.composerState.hoveredRect&&this.props.composerStore.hoveredContentEvaluation)}};let gN=3*.4*globalThis.devicePixelRatio||1;var _N=class extends k{static template=`o-spreadsheet-GridComposer`;static components={Composer:hN};props=(0,t.useProps)({gridDims:M.DOMDimension(),onInputContextMenu:M.function()});rect=this.defaultRect;isEditing=!1;isCellReferenceVisible=!1;currentEditedCell={col:0,row:0,sheetId:this.env.model.getters.getActiveSheetId()};composerStore;composerFocusStore;viewStore;composerInterface;get defaultRect(){return{x:0,y:0,width:0,height:0}}setup(){let e=A(rN);this.composerStore=e,this.composerFocusStore=A(ni),this.viewStore=A(W),this.composerInterface={id:`gridComposer`,get editionMode(){return e.editionMode},startEdition:this.composerStore.startEdition,setCurrentContent:this.composerStore.setCurrentContent,stopEdition:this.composerStore.stopEdition},this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`inactive`}),(0,t.onWillUpdateProps)(()=>{this.updateComponentPosition(),this.updateCellReferenceVisibility()})}get shouldDisplayCellReference(){return!this.env.isMobile()&&this.isCellReferenceVisible}get cellReference(){let{col:e,row:t,sheetId:n}=this.composerStore.currentEditedCell;return Tl(n===this.env.model.getters.getActiveSheetId()?void 0:this.env.model.getters.getSheetName(n),E(e,t))}get cellReferenceStyle(){let{x:e,y:t}=this.rect;return G({left:`${e-gN}px`,top:`${t-28}px`})}get focus(){return this.composerFocusStore.activeComposer===this.composerInterface?this.composerFocusStore.focusMode:`inactive`}get composerProps(){let{width:e,height:t}=this.viewStore.sheetViewDimensionWithHeaders,n=this.props.gridDims.height-this.rect.y-2*gN;return{rect:{...this.rect},delimitation:{width:e,height:t},focus:this.focus,isDefaultFocus:!0,onComposerContentFocused:e=>this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`contentFocus`,selection:e}),onComposerCellFocused:e=>this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`cellFocus`,content:e}),onInputContextMenu:this.props.onInputContextMenu,composerStore:this.composerStore,inputStyle:`max-height: ${n}px;`,inputMode:this.composerStore.editionMode===`inactive`?`none`:void 0}}get containerStyle(){if(this.composerStore.editionMode===`inactive`||this.env.isMobile())return`z-index: -1000; opacity: 0;`;let e=Dn(this.composerStore.currentContent),t=this.env.model.getters.getActiveCell(),n=this.env.model.getters.getActivePosition(),r=this.env.model.getters.getCellComputedStyle(n),{x:i,y:a,width:o,height:s}=this.rect,c=!e&&r.fillColor||`#ffffff`,l=!e&&r.textColor||`#000000`,u=!e&&r.fontSize||10,d=!e&&r.bold?`bold`:void 0,f=!e&&r.italic?`italic`:`normal`,p=e?`none`:M_(r),m=`left`;e||(m=r.align==="default"||!r.align?t.defaultAlign:r.align);let h=this.props.gridDims.height-this.rect.y,g=this.props.gridDims.width-this.rect.x,_=Math.min(s+1,h),v=Math.min(o+1,g);return G({left:`${i-1}px`,top:`${a}px`,border:`${gN}px solid ${je}`,"min-width":`${v}px`,"min-height":`${_}px`,"max-width":`${g}px`,"max-height":`${h}px`,background:c,color:l,"font-size":`${Mp(u)}px`,"font-weight":d,"font-style":f,"text-decoration":p,"text-align":m})}updateComponentPosition(){let e=this.composerFocusStore.activeComposer.editionMode!==`inactive`;!e&&this.composerFocusStore.activeComposer!==this.composerInterface&&this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`inactive`});let t=!T(this.currentEditedCell,this.composerStore.currentEditedCell);if(this.isEditing!==e){if(this.isEditing=e,!e){this.rect=this.defaultRect;return}this.currentEditedCell=this.composerStore.currentEditedCell,t=!0}if(t){let e=this.env.model.getters.getActivePosition(),t=this.env.model.getters.expandZone(e.sheetId,D(e));this.rect=this.viewStore.viewports.getVisibleRect(e.sheetId,t)}}updateCellReferenceVisibility(){if(this.composerStore.editionMode===`inactive`){this.isCellReferenceVisible=!1;return}if(this.isCellReferenceVisible)return;let e=this.env.model.getters.getActiveSheetId(),t=D(this.env.model.getters.getSelection().anchor.cell);(!T(this.viewStore.viewports.getVisibleRect(e,t),this.rect)||e!==this.composerStore.currentEditedCell.sheetId)&&(this.isCellReferenceVisible=!0)}onFocus(){this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`contentFocus`})}};function vN(e,t=!1){e.__owl__.render(t)}var yN=class{mutators=[`setHighlightedFigure`];highlightedFigureId=void 0;setHighlightedFigure(e){this.highlightedFigureId=e}},bN=class e{getters;sheetId;definition;chartTypeBuilder;dataSourceBuilder;dataSource;constructor(e,t,n,r,i){this.getters=e,this.sheetId=t,this.definition=n,this.chartTypeBuilder=r,this.dataSourceBuilder=i,this.dataSource=n.dataSource}static fromStrDefinition(t,n,r){let i=wb.get(r.dataSource?.type??`none`),a=Tb.get(r.type),o=i.fromExternalDefinition(r.dataSource??{type:`none`},n,t),s={...a.fromStrDefinition(r,n,t),dataSource:o};return new e(t,n,e.deleteInvalidKeys(s),a,i)}static fromDefinition(t,n,r){let i=wb.get(r.dataSource?.type??`none`);return new e(t,n,r,Tb.get(r.type),i)}static validate(e,t){let n=Tb.get(t.type),r=wb.get(t.dataSource?.type??`none`);return e.batchValidations(()=>n.validateDefinition(e,t),()=>r.validate(t.dataSource??{type:`none`},e))(void 0)}static transformDefinition(e,t,n){let r=Tb.get(t.type);if(!t.dataSource)return r.transformDefinition(t,e,n);let i=wb.get(t.dataSource?.type??`none`).transform(t.dataSource,e,n);return{...r.transformDefinition(t,e,n),dataSource:i}}getRangeDefinition(){return{...this.definition,dataSource:this.dataSource}}getDefinition(){return{...this.chartTypeBuilder.toStrDefinition(this.definition,this.sheetId,this.getters),dataSource:this.dataSource&&this.dataSourceBuilder.getDefinition(this.dataSource,this.sheetId,this.getters)}}updateRanges(e){return{...this.chartTypeBuilder.updateRanges(this.definition,e,this.sheetId),dataSource:this.dataSource&&this.dataSourceBuilder.adaptRanges(this.dataSource,e)}}duplicateInDuplicatedSheet(t,n){let r=this.dataSource&&this.dataSourceBuilder.duplicateInDuplicatedSheet(this.dataSource,t,n,this.getters),i={...this.chartTypeBuilder.duplicateInDuplicatedSheet(this.definition,t,n,this.getters),dataSource:r};return e.fromDefinition(this.getters,n,i).getDefinition()}copyInSheetId(e){return{...this.chartTypeBuilder.copyInSheetId(this.definition,this.sheetId,e,this.getters),dataSource:this.dataSource}}getContextCreation(){let e=this.getDefinition();return{...this.dataSourceBuilder.getContextCreation(e.dataSource??{type:`none`}),...this.chartTypeBuilder.getContextCreation(e,this.dataSourceBuilder,e.dataSource)}}getDefinitionForExcel(e){let t=this.definition,n=this.dataSourceBuilder.toExcelDataSets(this.dataSource,`dataSetStyles`in t?t.dataSetStyles:{},e);if(n!==void 0)return this.chartTypeBuilder.getDefinitionForExcel(e,t,n)}getData(e,t){let n=this.dataSource;return n?this.dataSourceBuilder.extractData(n,t,e):{dataSetsValues:[],labelValues:[]}}getFormulas(e){return this.chartTypeBuilder.getFormulas(e,this.sheetId,this.definition)}getRuntime(e,t,n){let r=this.dataSource,i=r?{extractData:()=>this.dataSourceBuilder.extractData(r,t,e),extractHierarchicalData:()=>this.dataSourceBuilder.extractHierarchicalData(r,t,e)}:{extractData:()=>({dataSetsValues:[],labelValues:[]}),extractHierarchicalData:()=>({dataSetsValues:[],labelValues:[]})};return this.chartTypeBuilder.getRuntime(e,this.definition,i,this.sheetId,{onClick:(n,r,i)=>this.dataSourceBuilder.onDataSetClick?.(this.definition.type,t,n,r,i,e),onHover:(e,n,r)=>this.dataSourceBuilder.onDataSetHover?.(this.definition.type,t,e,n,r)},n)}static deleteInvalidKeys(e){e={...e};let t=new Set(Tb.get(e.type).allowedDefinitionKeys);for(let n of Object.keys(e))t.has(n)||delete e[n];return e}async loadDataForExport(e){return this.chartTypeBuilder.loadDataForExport?.(e)}};function xN(e){return e===`scorecard`?{width:213,height:101}:{width:536,height:335}}function SN(e,t,n){if(e.tag!==`chart`)return;let r=e.x+e.width/2,i=e.y+e.height/2,a,o=1/0;for(let s of t){if(!n.includes(s.tag))continue;let t=s.x+s.width/2,c=s.y+s.height/2,l=Math.abs(r-t),u=Math.abs(i-c),d=l**2+u**2;l<=e.width/2&&u<=e.height/2&&d<o&&(o=d,a=s)}return a}function CN(e,t,n){let r=e.getStore(Rg).zoomLevel,i=v(r),a=document.querySelector(`.o-spreadsheet`);if(!a)return;let o=n.clientX/r,s=n.clientY/r,{width:c,height:l}=xN(t.type),u=c*r,d=l*r,f=e.model.getters,p=f.getActiveSheetId(),m=null,h,g=e.getStore(yN),_=document.body.style.cursor;document.body.style.cursor=`grabbing`;let ee=(t,n)=>{if(t>i.x+i.width||n>i.y+i.height)return;let{scrollX:a,scrollY:o}=e.getStore(W).activeSheetScrollInfo;return{x:Math.max(0,(t-i.x)/r+a),y:Math.max(0,(n-i.y)/r+o)}},y=(t,n)=>{let r=ee(t,n);if(!r)return;let i={tag:`chart`,...r,width:c,height:l},a=e.getStore(W).visibleFigures;return SN(i,a,[`carousel`,`chart`])},b=u/2,te=d/2;IE(e=>{if(Math.abs(e.clientX-o)<=5&&Math.abs(e.clientY-s)<=5)return;if(m===null){m=document.createElement(`div`),m.className=`o-chart-drag-preview os-theme-dependant position-fixed border pe-none`,m.style.width=`${c}px`,m.style.height=`${l}px`,m.style.zoom=`${r}`;let e=document.createElement(`canvas`);e.className=`w-100 h-100`,m.appendChild(e),a.appendChild(m),h=T_(e,bN.fromStrDefinition(f,p,t).getRuntime(f,`newChart`,f.getSpreadsheetTheme().colorThemeName),{width:c,height:l},t.type,r)}m.style.left=`${Math.max(i.x,(e.clientX-b)/r)}px`,m.style.top=`${Math.max(i.y,(e.clientY-te)/r)}px`;let n=y(e.clientX-b,e.clientY-te);m.style.opacity=n?.id?`0.6`:`0.9`,g.setHighlightedFigure(n?.id)},n=>{g.setHighlightedFigure(void 0),m!==null&&(a.removeChild(m),m=null),h?.(),document.body.style.cursor=_;let u=ee(n.clientX-b,n.clientY-te);if(Math.abs(n.clientX/r-o)<=5&&Math.abs(n.clientY/r-s)<=5)u={x:0,y:0};else if(!u||u.x+b>i.width)return;let{col:d,row:f,offset:v}=e.getStore(W).viewports.getPositionAnchorOffset(p,u),ne={chartId:K.smallUuid(),figureId:K.smallUuid(),sheetId:p,size:{width:c,height:l},definition:t,col:d,row:f,offset:v},re=y(n.clientX-b,n.clientY-te);re?.tag===`carousel`?e.model.dispatch(`ADD_NEW_CHART_TO_CAROUSEL`,{sheetId:p,figureId:re.id,newChartId:K.smallUuid(),chartDefinition:t}):re?.tag===`chart`?e.model.dispatch(`CREATE_CHART_AND_MERGE_INTO_CAROUSEL`,{chartId:ne.chartId,figureId:ne.figureId,sheetId:ne.sheetId,definition:ne.definition,baseFigureId:re.id}):e.model.dispatch(`CREATE_CHART`,ne)})}function wN({x:e,y:t},{x:n,y:r},i,{maxX:a,maxY:o},{scrollX:s,scrollY:c},{scrollX:l,scrollY:u}){let d=e-n+l-s,f=t-r+u-c;for(let e of i)d=S(d,-e.x,a-e.x-e.width),f=S(f,-e.y,o-e.y-e.height);return i.map(e=>({...e,x:e.x+d,y:e.y+f}))}function TN(e,t,n,{x:r,y:i},{x:a,y:o},s,c,{scrollX:l,scrollY:u},{scrollX:d,scrollY:f},{maxX:p,maxY:m}){let{x:h,y:g,width:_,height:v}=e;if(s&&t!==0&&n!==0){let e=Math.min(t*(a-r+d-l),_-c.width),s=Math.min(n*(o-i+f-u),v-c.height),p=Math.min(e/_,s/v);t<0&&(h+=_*p),n<0&&(g+=v*p),_*=1-p,v*=1-p}else{let e=Math.max(t*(r-a+d-l),c.width-_),s=Math.max(n*(i-o+f-u),c.height-v);_+=e,v+=s,t<0&&(h-=e),n<0&&(g-=s)}return h+d<=0?(_=_+h+d,h=-d):h+_>p&&(_=p-h),g+f<=0?(v=v+g+f,g=-f):g+v>m&&(v=m-g),{x:h,y:g,width:_,height:v}}function EN(e,t,n){let r=Ng(...t),i=AN(e,r,[`hCenter`,`right`,`left`],n,[`hCenter`,`right`,`left`]),a=AN(e,r,[`vCenter`,`bottom`,`top`],n,[`vCenter`,`bottom`,`top`]),{y:o,x:s}=e.getStore(W).mainViewportCoordinates,{scrollY:c,scrollX:l}=e.getStore(W).activeSheetScrollInfo;for(let e of t){if(a){e.y-=a.snapOffset;let t=e.y<o,n=e.y<o;t&&!n?e.y+=c:!t&&n&&(e.y-=c)}if(i){e.x-=i.snapOffset;let t=e.x<s,n=e.x<s;t&&!n?e.x+=l:!t&&n&&(e.x-=l)}}return{snappedFigures:t,verticalSnapLine:i,horizontalSnapLine:a}}function DN(e,t,n,r,i){let a=AN(e,r,[t===-1?`left`:`right`],i,[`right`,`left`]),o=AN(e,r,[n===-1?`top`:`bottom`],i,[`bottom`,`top`]);return a&&(t===1?r.width-=a.snapOffset:t===-1&&(r.x-=a.snapOffset,r.width+=a.snapOffset)),o&&(n===1?r.height-=o.snapOffset:n===-1&&(r.y-=o.snapOffset,r.height+=o.snapOffset)),{snappedRect:{x:Math.round(r.x),y:Math.round(r.y),width:Math.round(r.width),height:Math.round(r.height)},verticalSnapLine:a,horizontalSnapLine:o}}function ON(e,t,n){return n.map(n=>MN(e,t,!1,n)).filter(n=>kN(e,t,n))}function kN(e,t,n){let{x:r,y:i}=e.getStore(W).mainViewportCoordinates,a=[];switch(n.axisType){case`top`:case`bottom`:case`vCenter`:if(t.y<i)return!0;a.push({x:t.x,y:n.position}),a.push({x:t.x+t.width,y:n.position});break;case`left`:case`right`:case`hCenter`:if(t.x<r)return!0;a.push({x:n.position,y:t.y}),a.push({x:n.position,y:t.y+t.height});break}return a.some(t=>e.getStore(W).viewports.isPixelPositionVisible(e.model.getters.getActiveSheetId(),t))}function AN(e,t,n,r,i){let a=n.map(n=>MN(e,t,!0,n)),o;for(let t of r){let n=ON(e,t,i);for(let e of a)for(let r of n){if(!jN(e.position,r.position))continue;let n=e.position-r.position;o&&n===o.snapOffset?o.matchedFigIds.push(t.id):(!o||Math.abs(n)<=Math.abs(o.snapOffset))&&(o={matchedFigIds:[t.id],snapOffset:n,snappedAxisType:e.axisType,position:r.position})}}return o}function jN(e,t){return Math.abs(e-t)<=5}function MN(e,t,n,r){let i=0,{scrollX:a,scrollY:o}=e.getStore(W).activeSheetScrollInfo,{x:s,y:c}=e.getStore(W).mainViewportCoordinates,l=!n&&t.y<c?t.y+o:t.y,u=!n&&t.x<s?t.x+a:t.x;switch(r){case`top`:i=l;break;case`bottom`:i=l+t.height-1;break;case`vCenter`:i=l+Math.floor(t.height/2)-1;break;case`left`:i=u;break;case`right`:i=u+t.width-1;break;case`hCenter`:i=u+Math.floor(t.width/2)-1;break}return{position:i,axisType:r}}var NN=class extends k{static template=`o-spreadsheet-FiguresContainer`;static components={FigureComponent:rD};dnd=(0,t.proxy)({draggedFigure:void 0,selectedFigures:void 0,selectedRect:void 0,horizontalSnap:void 0,verticalSnap:void 0,cancelDnd:void 0});viewStore;zoomStore;chartDragStore;setup(){this.viewStore=A(W),this.zoomStore=A(Rg),this.chartDragStore=A(yN),(0,t.onMounted)(()=>{vN(this)}),(0,t.onWillUpdateProps)(()=>{let e=this.env.model.getters.getActiveSheetId(),t=this.dnd.draggedFigure?.id;t&&!this.env.model.getters.getFigure(e,t)&&(this.dnd.cancelDnd?.(),this.dnd.draggedFigure=void 0,this.dnd.selectedFigures=void 0,this.dnd.selectedRect=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0,this.chartDragStore.setHighlightedFigure(void 0),this.dnd.cancelDnd=void 0)})}getVisibleFigures(){let e=this.viewStore.visibleFigures;for(let t of this.dnd.selectedFigures||[])e.some(e=>e.id===t.id)||e.push(t);return e}get containers(){let e=this.getVisibleFigures(),t=[];for(let n of[`topLeft`,`topRight`,`bottomLeft`,`bottomRight`]){let r=e.filter(e=>this.getFigureContainer(e)===n);r.length>0&&t.push({type:n,figures:r,style:this.getContainerStyle(n),inverseViewportStyle:this.getInverseViewportPositionStyle(n)})}return this.dnd.selectedFigures&&t.push({type:`dnd`,figures:this.dnd.selectedFigures,style:this.getContainerStyle(`dnd`),inverseViewportStyle:this.getInverseViewportPositionStyle(`dnd`)}),t}getContainerStyle(e){return this.rectToCss(this.getContainerRect(e))}rectToCss(e){return G({left:`${e.x}px`,top:`${e.y}px`,width:`${e.width}px`,height:`${e.height}px`})}getContainerRect(e){let{width:t,height:n}=this.viewStore.sheetViewDimension,{x:r,y:i}=this.viewStore.mainViewportCoordinates,a=[`bottomRight`,`topRight`].includes(e)?r:0,o=t-a,s=[`bottomRight`,`bottomLeft`].includes(e)?i:0;return{x:a,y:s,width:o,height:n-s}}get selectedRectStyle(){return this.dnd.selectedRect?this.rectToCss(this.dnd.selectedRect):``}get maxDimensions(){let e=this.env.model.getters.getActiveSheetId();return{maxX:this.env.model.getters.getColDimensions(e,this.env.model.getters.getNumberCols(e)-1).end,maxY:this.env.model.getters.getRowDimensions(e,this.env.model.getters.getNumberRows(e)-1).end}}getInverseViewportPositionStyle(e){let{scrollX:t,scrollY:n}=this.viewStore.activeSheetScrollInfo,{x:r,y:i}=this.viewStore.mainViewportCoordinates,a=0,o=0;return e===`dnd`&&(a=-t,o=-n),[`bottomRight`,`topRight`].includes(e)&&(a=-t-r),[`bottomRight`,`bottomLeft`].includes(e)&&(o=-n-i),G({left:`${a}px`,top:`${o}px`})}getFigureContainer(e){let{x:t,y:n}=this.viewStore.mainViewportCoordinates;return this.dnd.selectedFigures?.some(t=>t.id===e.id)?`dnd`:e.x<t&&e.y<n?`topLeft`:e.x<t?`bottomLeft`:e.y<n?`topRight`:`bottomRight`}getDndFigureRect(){if(this.dnd.selectedFigures&&this.dnd.selectedFigures.length>1)return Ng(...this.dnd.selectedFigures)}toBottomRightViewport(e){let t=this.getFigureContainer(e),n=this.viewStore.activeSheetScrollInfo,r={...e};return[`bottomLeft`,`topLeft`].includes(t)&&(r.x+=n.scrollX),[`topLeft`,`topRight`].includes(t)&&(r.y+=n.scrollY),r}isMenuClick(e){let t=e.target;return t&&t instanceof Element?!!t.closest(`.o-figure-menu`):!1}startDraggingFigure(e,t){if(t.button>0||this.env.model.getters.isReadonly()||this.isMenuClick(t))return;let n=this.env.model.getters.getSelectedFigureIds().includes(e.id);if(!n&&!this.env.model.dispatch(`SELECT_FIGURE`,{figureId:e.id,selectMultiple:t.shiftKey||ue(t)}).isSuccessful||this.env.isMobile()||this.env.model.getters.isCurrentSheetLocked())return;let r=this.env.model.getters.getActiveSheetId(),i=this.zoomStore.zoomLevel,a={x:t.clientX/i,y:t.clientY/i},o=this.viewStore.activeSheetScrollInfo,s=this.maxDimensions,c=this.env.model.getters.getSelectedFigureIds().map(e=>this.env.model.getters.getFigure(r,e)).filter(w).map(e=>this.env.model.getters.getFigureUI(r,e)).map(this.toBottomRightViewport.bind(this)),l=e.id,u=!1,d,f=e=>{let t={x:e.clientX/i,y:e.clientY/i},n=Math.abs(t.x-a.x),r=Math.abs(t.y-a.y);if(!u&&n<5&&r<5)return;u=!0;let f=wN(t,a,c,s,o,this.viewStore.activeSheetScrollInfo),p=f.find(e=>e.id===l);d=void 0;let m=this.getOtherFigures(f.map(e=>e.id));if(p&&!f.find(e=>e.tag!==`chart`)&&(d=SN(p,m,[`carousel`,`chart`])),this.chartDragStore.setHighlightedFigure(d?.id),d)this.dnd.draggedFigure=p,this.dnd.selectedFigures=f,this.dnd.selectedRect=this.getDndFigureRect(),this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0;else{let e=EN(this.env,f,m);this.dnd.selectedFigures=e.snappedFigures,this.dnd.selectedRect=this.getDndFigureRect(),this.dnd.draggedFigure=f.find(e=>e.id===l),this.dnd.horizontalSnap=this.getSnap(e.horizontalSnapLine),this.dnd.verticalSnap=this.getSnap(e.verticalSnapLine)}},p=t=>{if(!this.dnd.draggedFigure){n&&(t.shiftKey||ue(t)?this.env.model.dispatch(`UNSELECT_FIGURE`,{figureId:e.id}):this.env.model.dispatch(`SELECT_FIGURE`,{figureId:e.id}));return}if(d){let e=d.id,t=this.dnd.selectedFigures?.map(e=>e.id)||[];d.tag===`carousel`?this.env.model.dispatch(`ADD_FIGURES_CHART_TO_CAROUSEL`,{sheetId:r,carouselFigureId:e,chartFigureIds:t}):d.tag===`chart`&&this.env.model.dispatch(`MERGE_CHART_FIGURES_INTO_CAROUSEL`,{sheetId:r,baseFigureId:e,chartFigureIds:[e,...t]})}else{let e=this.dnd.selectedFigures?.map(e=>({sheetId:r,figureId:e.id,...this.viewStore.viewports.getPositionAnchorOffset(r,e)}))||[];this.env.model.dispatch(`UPDATE_FIGURES`,{figures:e})}this.dnd.draggedFigure=void 0,this.dnd.selectedFigures=void 0,this.dnd.selectedRect=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0,this.chartDragStore.setHighlightedFigure(void 0)};this.dnd.cancelDnd=IE(f,p)}resizeAllSelectedFigures(e,t,n){n.stopPropagation();let r=this.env.model.getters.getActiveSheetId(),i=this.zoomStore.zoomLevel,a={x:n.clientX/i,y:n.clientY/i},o=this.viewStore.activeSheetScrollInfo,s=this.maxDimensions,c=this.env.model.getters.getSelectedFigureIds(),l=c.map(e=>this.env.model.getters.getFigure(r,e)).filter(w).map(e=>this.env.model.getters.getFigureUI(r,e)).map(this.toBottomRightViewport.bind(this)),u=c.length>1,d=this.getOtherFigures(c);if(l.length===0)return;let f;if(u){let e=Math.max(...l.map(e=>nD.get(e.tag).minFigSize/e.width)),t=Math.max(...l.map(e=>nD.get(e.tag).minFigSize/e.height)),n=Ng(...l);f={width:Math.round(n.width*e),height:Math.round(n.height*t)}}else{let e=nD.get(l[0].tag).minFigSize;f={width:e,height:e}}let p=n=>{let r={x:n.clientX/i,y:n.clientY/i},c=u||n.shiftKey?!0:nD.get(l[0].tag).keepRatio||!1,p=Ng(...l),m=TN(p,e,t,r,a,c,f,o,this.viewStore.activeSheetScrollInfo,s),{snappedRect:h,verticalSnapLine:g,horizontalSnapLine:_}=DN(this.env,e,t,m,d),v=h.width/p.width,ee=h.height/p.height,y=l.map(e=>({...e,x:Math.round(h.x+(e.x-p.x)*v),y:Math.round(h.y+(e.y-p.y)*ee),width:Math.round(e.width*v),height:Math.round(e.height*ee)}));this.dnd.draggedFigure=y[0],this.dnd.selectedFigures=y,this.dnd.selectedRect=this.getDndFigureRect(),this.dnd.horizontalSnap=this.getSnap(_),this.dnd.verticalSnap=this.getSnap(g)},m=()=>{if(!this.dnd.selectedFigures)return;let n=this.dnd.selectedFigures.map(n=>{let i=this.viewStore.viewports.getPositionAnchorOffset(r,n);return e&&(i.width=n.width),t&&(i.height=n.height),{sheetId:r,figureId:n.id,...i}});this.env.model.dispatch(`UPDATE_FIGURES`,{figures:n}),this.dnd.draggedFigure=void 0,this.dnd.selectedFigures=void 0,this.dnd.selectedRect=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0};this.dnd.cancelDnd=IE(p,m)}getOtherFigures(e){return this.getVisibleFigures().filter(t=>!e.includes(t.id))}getFigureStyle(e){return e.id===this.dnd.draggedFigure?.id?G({opacity:this.chartDragStore.highlightedFigureId?`0.6`:`0.9`,cursor:`grabbing`}):``}getFigureClass(e){return e.id===this.chartDragStore.highlightedFigureId?`o-add-to-carousel`:``}getSnap(e){if(!e||!this.dnd.draggedFigure)return;let{scrollX:t,scrollY:n}=this.viewStore.activeSheetScrollInfo,r=e.matchedFigIds.map(e=>this.getVisibleFigures().find(t=>t.id===e)).filter(w).map(e=>({x:e.x-t,y:e.y-n,width:e.width,height:e.height})).filter(w),i=Ng({...this.dnd.draggedFigure,x:this.dnd.draggedFigure.x-t,y:this.dnd.draggedFigure.y-n},...r);return{line:e,containerStyle:this.rectToCss(i),lineStyle:this.getSnapLineStyle(e,i)}}getSnapLineStyle(e,t){if(!e)return``;let{scrollX:n,scrollY:r}=this.viewStore.activeSheetScrollInfo;return[`top`,`vCenter`,`bottom`].includes(e.snappedAxisType)?G({top:`${e.position-t.y-r}px`,left:`0px`,width:`100%`}):G({top:`0px`,left:`${e.position-t.x-n}px`,height:`100%`})}},PN=class extends k{static template=`o-spreadsheet-HeaderResizeEditor`;static components={Popover:Fw};props=(0,t.useProps)({target:M.signal(),gridRect:M.Rect()});errorMessage=(0,t.signal)(``);isInputEmpty=(0,t.signal)(!1);inputRef=t.signal.ref(HTMLInputElement);editorRef=t.signal.ref();viewStore;zoomStore;DOMFocusableElementStore;setup(){this.viewStore=A(W),this.zoomStore=A(Rg),this.DOMFocusableElementStore=A(Ow),(0,t.useListener)(window,`click`,this.onExternalClick.bind(this),{capture:!0}),(0,t.useListener)(window,`contextmenu`,this.onExternalClick.bind(this),{capture:!0}),(0,t.useEffect)(()=>{let e=this.inputRef();e&&this.props.target()&&(e.value=this.currentSize.toString(),e.focus(),e.select())})}get target(){let e=this.props.target();if(!e)throw Error(`Header resize editor target is not set`);return e}get popoverProps(){return{anchorRect:this.anchorRect,positioning:this.target.dimension===`COL`?`bottom-left`:`top-right`,onPopoverHidden:()=>this.close()}}get anchorRect(){let{dimension:e,index:t}=this.target,n=this.env.model.getters.getActiveSheetId(),r=this.viewStore.gridOffset,i;if(e===`COL`){let{start:e,size:a}=this.viewStore.viewports.getColDimensionsInViewport(n,t);i={x:r.x+e,y:0,width:a,height:r.y}}else{let{start:e,size:a}=this.viewStore.viewports.getRowDimensionsInViewport(n,t);i={x:0,y:r.y+e,width:r.x,height:a}}let a=this.zoomStore.getZoomedRect(i);return{...a,x:this.props.gridRect.x+a.x,y:this.props.gridRect.y+a.y}}get minSize(){return this.target.dimension===`COL`?5:10}get currentSize(){let e=this.env.model.getters.getActiveSheetId();return this.target.dimension===`COL`?this.env.model.getters.getColSize(e,this.target.index):this.env.model.getters.getRowSize(e,this.target.index)}onExternalClick(e){this.props.target()&&!_(this.editorRef(),e)&&this.close()}close(){this.editorRef()?.contains(document.activeElement)&&this.DOMFocusableElementStore.focus(),this.errorMessage.set(``),this.isInputEmpty.set(!1),this.props.target.set(null)}onInput(e){let t=e.target;this.errorMessage.set(``),this.isInputEmpty.set(!t.value&&!t.validity.badInput)}get emptyInputHint(){return this.target.dimension===`COL`?N(`Empty value resets width to %s px`,`96`):N(`Empty value fits height to content`)}onKeydown(e){e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),this.apply()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.close())}apply(){if(!this.props.target())return;let e=this.validateAndParseSize();e!==void 0&&this.env.model.dispatch(`RESIZE_COLUMNS_ROWS`,{sheetId:this.env.model.getters.getActiveSheetId(),dimension:this.target.dimension,elements:this.target.dimension===`COL`?[...this.env.model.getters.getActiveCols()]:[...this.env.model.getters.getActiveRows()],size:e}).isSuccessful&&this.close()}validateAndParseSize(){let e=this.inputRef();if(!e)return;if(!e.value&&!e.validity.badInput)return null;let t=e.valueAsNumber;if(!Number.isInteger(t)){this.errorMessage.set(N(`Size must be an integer`));return}if(t<this.minSize||t>2e3){this.errorMessage.set(N(`Size must be between %(min)s and %(max)s pixels`,{min:this.minSize,max:Ge}));return}return t}},FN=class extends k{static template=`o-spreadsheet-UnhideRowHeaders`;props=(0,t.useProps)({headersGroups:M.array(),headerRange:M.object({start:M.HeaderIndex(),end:M.HeaderIndex()}),offset:M.number().optional(0)});viewStore;setup(){this.viewStore=A(W)}get sheetId(){return this.env.model.getters.getActiveSheetId()}getUnhidePreviousButtonStyle(e){let t=this.viewStore.viewports.getRect(this.sheetId,D({col:0,row:e}));return G({top:t.y+t.height-26-this.props.offset+`px`,"margin-right":`1px`})}getUnhideNextButtonStyle(e){return G({top:this.viewStore.viewports.getRect(this.sheetId,D({col:0,row:e})).y-26-this.props.offset+`px`,"margin-right":`1px`})}unhide(e){this.env.model.dispatch(`UNHIDE_COLUMNS_ROWS`,{sheetId:this.sheetId,dimension:`ROW`,elements:e})}isVisible(e){return e>=this.props.headerRange.start&&e<=this.props.headerRange.end}},IN=class extends k{static template=`o-spreadsheet-UnhideColumnHeaders`;props=(0,t.useProps)({headersGroups:M.array(),headerRange:M.object({start:M.HeaderIndex(),end:M.HeaderIndex()}),offset:M.number().optional(0)});viewStore;setup(){this.viewStore=A(W)}get sheetId(){return this.env.model.getters.getActiveSheetId()}getUnhidePreviousButtonStyle(e){let t=this.viewStore.viewports.getRect(this.sheetId,D({col:e,row:0}));return G({left:t.x+t.width-48-this.props.offset+`px`})}getUnhideNextButtonStyle(e){return G({left:this.viewStore.viewports.getRect(this.sheetId,D({col:e,row:0})).x-48-this.props.offset+`px`})}unhide(e){this.env.model.dispatch(`UNHIDE_COLUMNS_ROWS`,{sheetId:this.sheetId,dimension:`COL`,elements:e})}isVisible(e){return e>=this.props.headerRange.start&&e<=this.props.headerRange.end}};let LN={onOpenContextMenu:M.function()};var RN=class extends k{props=(0,t.useProps)(LN);composerFocusStore;viewStore;zoomStore;PADDING=0;MAX_SIZE_MARGIN=0;MIN_ELEMENT_SIZE=0;lastSelectedElementIndex=null;state=(0,t.proxy)({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0,position:`before`});dragNDropGrid=Jj(this.env);setup(){this.composerFocusStore=A(ni),this.viewStore=A(W),this.zoomStore=A(Rg)}_computeHandleDisplay(e){let t=this._getEvOffset(e),n=this._getElementIndex(t);if(n<0)return;let r=this._getDimensionsInViewport(n);t-r.start<this.PADDING&&n!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=r.start,this.state.activeElement=this._getPreviousVisibleElement(n)):r.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=r.end,this.state.activeElement=n):this.state.resizerIsActive=!1}_computeGrabDisplay(e){if(ue(e.ev)){this.state.waitingForMove=!1;return}let t=this._getElementIndex(this._getEvOffset(e)),n=this._getActiveElements(),r=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();if(n.has(r)&&r<=t&&t<=i){this.state.waitingForMove=!0;return}this.state.waitingForMove=!1}onMouseMove(e){if(this.env.isMobile()||this.env.model.getters.isReadonly()||this.state.isResizing||this.state.isMoving||this.state.isSelecting)return;let t=this.zoomStore.getZoomedEvent(e);this._computeHandleDisplay(t),this._computeGrabDisplay(t)}onMouseLeave(){this.state.resizerIsActive=this.state.isResizing,this.state.waitingForMove=!1}onDblClick(e){let t=this.zoomStore.getZoomedEvent(e);this._fitElementSize(this.state.activeElement),this.state.isResizing=!1,this._computeHandleDisplay(t),this._computeGrabDisplay(t)}onMouseDown(e){if(e.button!==0)return;this.state.isResizing=!0,this.state.delta=0;let t=this.zoomStore.getZoomedEvent(e),n=this._getClientPosition(t),r=this.state.draggerLinePosition,i=this._getElementSize(this.state.activeElement),a=r-i+this.MIN_ELEMENT_SIZE,o=Math.min(this._getMaxSize(),r-i+Ge);IE(e=>{this.state.delta=this._getClientPosition(this.zoomStore.getZoomedEvent(e))-n,this.state.draggerLinePosition=r+this.state.delta,this.state.draggerLinePosition<a&&(this.state.draggerLinePosition=a,this.state.delta=this.MIN_ELEMENT_SIZE-i),this.state.draggerLinePosition>o&&(this.state.draggerLinePosition=o,this.state.delta=o-r)},e=>{this.state.isResizing=!1,this.state.delta!==0&&this._updateSize()})}onClick(e){if(!this.env.isMobile()||e.button>0)return;let t=this.zoomStore.getZoomedEvent(e),n=this._getElementIndex(this._getEvOffset(t));this._selectElement(n,!1)}select(e){if(this.env.isMobile()||e.button>0)return;let t=this.zoomStore.getZoomedEvent(e),n=this._getElementIndex(this._getEvOffset(t));if(!(n<0)){if(this.env.model.getters.isReadonly()){this._selectElement(n,!1);return}if(!ue(e)&&this.state.waitingForMove){this.env.model.getters.isGridSelectionActive()?this.startMovement(e):this._selectElement(n,!1);return}this.composerFocusStore.activeComposer.editionMode===`editing`&&this.env.model.selection.getBackToDefault(),this.startSelection(e,n)}}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;let t=this.zoomStore.getZoomedEvent(e),n=this._getDimensionsInViewport(this._getSelectedZoneStart()),r=this._getDimensionsInViewport(this._getSelectedZoneEnd()),i=n.start;this.state.draggerLinePosition=i,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=i,this.state.draggerShadowThickness=r.end-n.start,this.dragNDropGrid.start(t,(e,t)=>{let r=this._getType()===`COL`?e:t;if(r>=0){let e=this._getDimensionsInViewport(r);r<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=r,this.state.position=`before`):this._getSelectedZoneEnd()<r?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=r,this.state.position=`after`):(this.state.draggerLinePosition=n.start,this.state.draggerShadowPosition=n.start,this.state.base=this._getSelectedZoneStart())}},()=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements();let t=this.zoomStore.getZoomedEvent(e);this._computeGrabDisplay(t)})}startSelection(e,t){if(this.env.isMobile())return;this.state.isSelecting=!0,e.shiftKey?this._increaseSelection(t):this._selectElement(t,ue(e)),this.lastSelectedElementIndex=t;let n=this.zoomStore.getZoomedEvent(e);this.dragNDropGrid.start(n,(e,t)=>{let n=this._getType()===`COL`?e:t;n!==this.lastSelectedElementIndex&&n!==-1&&(this._increaseSelection(n),this.lastSelectedElementIndex=n)},()=>{this.env.model.selection.commitSelection(),this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this._computeGrabDisplay(n)})}onContextMenu(e){e.preventDefault();let t=this._getElementIndex(this._getEvOffset(this.zoomStore.getZoomedEvent(e)));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);let n=this._getType();this.props.onOpenContextMenu(n,e.clientX,e.clientY)}},zN=class extends RN{static template=`o-spreadsheet-ColResizer`;static components={UnhideColumnHeaders:IN};colResizerRef=t.signal.ref();setup(){super.setup(),this.PADDING=15,this.MAX_SIZE_MARGIN=90,this.MIN_ELEMENT_SIZE=5}get sheetId(){return this.env.model.getters.getActiveSheetId()}_getEvOffset(e){return e.offsetX}_getViewportOffset(){return this.viewStore.activeMainViewport.left}_getClientPosition(e){return e.clientX}_getElementIndex(e){return this.viewStore.viewports.getColIndex(this.sheetId,e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().left}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().right}_getEdgeScroll(e){return this.viewStore.viewports.getEdgeScrollCol(this.sheetId,e,e,e)}_getDimensionsInViewport(e){return this.viewStore.viewports.getColDimensionsInViewport(this.sheetId,e)}_getElementSize(e){return this.env.model.getters.getColSize(this.sheetId,e)}_getMaxSize(){return this.colResizerRef()?.clientWidth??0}_updateSize(){let e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),n=this.env.model.getters.getActiveCols();this.env.model.dispatch(`RESIZE_COLUMNS_ROWS`,{dimension:`COL`,sheetId:this.sheetId,elements:n.has(e)?[...n]:[e],size:t})}_moveElements(){let e=[],t=this._getSelectedZoneStart(),n=this._getSelectedZoneEnd();for(let r=t;r<=n;r++)e.push(r);let r=this.env.model.dispatch(`MOVE_COLUMNS_ROWS`,{sheetId:this.sheetId,sheetName:this.env.model.getters.getActiveSheetName(),dimension:`COL`,base:this.state.base,elements:e,position:this.state.position});!r.isSuccessful&&r.reasons.includes(`WillRemoveExistingMerge`)&&this.env.raiseError(hT)}_selectElement(e,t){this.env.model.selection.selectColumn(e,t?`newAnchor`:`overrideSelection`)}_increaseSelection(e){this.env.model.selection.selectColumn(e,`updateAnchor`)}_fitElementSize(e){let t=this.env.model.getters.getActiveCols();this.env.model.dispatch(`AUTORESIZE_COLUMNS`,{sheetId:this.sheetId,cols:t.has(e)?[...t]:[e]})}_getType(){return`COL`}_getActiveElements(){return this.env.model.getters.getActiveCols()}_getPreviousVisibleElement(e){let t=this.sheetId,n;for(n=e-1;n>=0&&this.env.model.getters.isColHidden(t,n);n--);return n}unhide(e){this.env.model.dispatch(`UNHIDE_COLUMNS_ROWS`,{sheetId:this.sheetId,elements:e,dimension:`COL`})}get mainUnhideHeadersProps(){let{left:e,right:t}=this.viewStore.activeMainViewport,{xSplit:n}=this.env.model.getters.getPaneDivisions(this.sheetId),r=this.env.model.getters.getHiddenColsGroups(this.sheetId),i=r.findIndex(e=>e[0]>=n-1);return{headersGroups:i===-1?[]:r.slice(i),offset:this.viewStore.mainViewportCoordinates.x,headerRange:{start:e,end:t}}}get frozenUnhideHeadersProps(){let{xSplit:e}=this.env.model.getters.getPaneDivisions(this.sheetId),t=this.env.model.getters.getHiddenColsGroups(this.sheetId),n=t.findIndex(t=>t[0]>=e-1);return{headersGroups:n===-1?t:t.slice(0,n+1),headerRange:{start:0,end:e-1}}}get frozenContainerStyle(){return G({width:this.viewStore.mainViewportCoordinates.x+`px`})}get hasFrozenPane(){return this.env.model.getters.getPaneDivisions(this.sheetId).xSplit>0}},BN=class extends RN{static template=`o-spreadsheet-RowResizer`;static components={UnhideRowHeaders:FN};rowResizerRef=t.signal.ref();setup(){super.setup(),this.PADDING=5,this.MAX_SIZE_MARGIN=60,this.MIN_ELEMENT_SIZE=10}get sheetId(){return this.env.model.getters.getActiveSheetId()}_getEvOffset(e){return e.offsetY}_getViewportOffset(){return this.viewStore.activeMainViewport.top}_getClientPosition(e){return e.clientY}_getElementIndex(e){return this.viewStore.viewports.getRowIndex(this.sheetId,e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().top}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().bottom}_getEdgeScroll(e){return this.viewStore.viewports.getEdgeScrollRow(this.sheetId,e,e,e)}_getDimensionsInViewport(e){return this.viewStore.viewports.getRowDimensionsInViewport(this.sheetId,e)}_getElementSize(e){return this.env.model.getters.getRowSize(this.sheetId,e)}_getMaxSize(){return this.rowResizerRef()?.clientHeight??0}_updateSize(){let e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),n=this.env.model.getters.getActiveRows();this.env.model.dispatch(`RESIZE_COLUMNS_ROWS`,{dimension:`ROW`,sheetId:this.sheetId,elements:n.has(e)?[...n]:[e],size:t})}_moveElements(){let e=[],t=this._getSelectedZoneStart(),n=this._getSelectedZoneEnd();for(let r=t;r<=n;r++)e.push(r);let r=this.env.model.dispatch(`MOVE_COLUMNS_ROWS`,{sheetId:this.sheetId,sheetName:this.env.model.getters.getActiveSheetName(),dimension:`ROW`,base:this.state.base,elements:e,position:this.state.position});r.isSuccessful||(r.reasons.includes(`WillRemoveExistingMerge`)?this.env.raiseError(hT):r.reasons.includes(`CannotMoveTableHeader`)&&this.env.raiseError(gT))}_selectElement(e,t){this.env.model.selection.selectRow(e,t?`newAnchor`:`overrideSelection`)}_increaseSelection(e){this.env.model.selection.selectRow(e,`updateAnchor`)}_fitElementSize(e){let t=this.env.model.getters.getActiveRows();this.env.model.dispatch(`AUTORESIZE_ROWS`,{sheetId:this.sheetId,rows:t.has(e)?[...t]:[e]})}_getType(){return`ROW`}_getActiveElements(){return this.env.model.getters.getActiveRows()}_getPreviousVisibleElement(e){let t=this.sheetId,n;for(n=e-1;n>=0&&this.env.model.getters.isRowHidden(t,n);n--);return n}get mainUnhideHeadersProps(){let{top:e,bottom:t}=this.viewStore.activeMainViewport,{ySplit:n}=this.env.model.getters.getPaneDivisions(this.sheetId),r=this.env.model.getters.getHiddenRowsGroups(this.sheetId),i=r.findIndex(e=>e[0]>=n-1);return{headersGroups:i===-1?[]:r.slice(i),offset:this.viewStore.mainViewportCoordinates.y,headerRange:{start:e,end:t}}}get frozenUnhideHeadersProps(){let{ySplit:e}=this.env.model.getters.getPaneDivisions(this.sheetId),t=this.env.model.getters.getHiddenRowsGroups(this.sheetId),n=t.findIndex(t=>t[0]>=e-1);return{headersGroups:n===-1?t:t.slice(0,n+1),headerRange:{start:0,end:e-1}}}get frozenContainerStyle(){return G({height:this.viewStore.mainViewportCoordinates.y+`px`})}get hasFrozenPane(){return this.env.model.getters.getPaneDivisions(this.sheetId).ySplit>0}},VN=class extends k{static template=`o-spreadsheet-HeadersOverlay`;props=(0,t.useProps)(LN);static components={ColResizer:zN,RowResizer:BN};selectAll(){this.env.model.selection.selectAll()}};let HN=.95;function UN(e,{updateScroll:n,canMoveUp:r,canMoveDown:i,getZoom:a,setZoom:o}){let s=0,c=0,l=0,u=0,d=!1,f=0,p=null,m=!1,h=[],g=-1;(0,t.useListener)(e,`touchstart`,_,{capture:!1}),(0,t.useListener)(e,`touchmove`,v,{capture:!1}),(0,t.useListener)(e,`touchend`,ee,{capture:!1}),(0,t.useListener)(e,`pointerdown`,b,{passive:!1,capture:!1}),(0,t.useListener)(e,`pointermove`,ne,{passive:!1,capture:!1}),(0,t.useListener)(window,`pointerup`,te,{passive:!1,capture:!0}),(0,t.useListener)(e,`pointercancel`,te,{passive:!1});function _(e){d=!0,{clientX:s,clientY:c}=e.touches[0],l=0,u=0}function v(e){if(!d||m){e.cancelable&&e.preventDefault(),e.stopPropagation();return}p&&=(clearTimeout(p),null);let t=Date.now(),{clientX:a,clientY:o}=e.touches[0],h=s-a,g=c-o,_=t-f;_&&(l=h/_,u=g/_,s=a,c=o,f=t,(g<0&&r()||g>0&&i())&&(e.cancelable&&e.preventDefault(),e.stopPropagation()),p=setTimeout(()=>{l=0,u=0},100),n(h*1,g*1))}function ee(e){d=!1,s=c=0,p&&clearTimeout(p),l*=1.2,u*=1.2,requestAnimationFrame(y)}function y(){if(Math.abs(l)<.05&&(l=0),Math.abs(u)<.05&&(u=0),!l&&!u)return;let e=Date.now(),t=Math.abs(e-f),r=l*t,i=u*t;n(r*1,i*1),f=e,l*=HN,u*=HN,requestAnimationFrame(y)}function b(e){e.button===0&&h.findIndex(t=>t.pointerId===e.pointerId)===-1&&(h.push(e),h.length<2?g=-1/0:h.length===2&&(g=WN(h[0],h[1])))}function te(e){let t=h.findIndex(t=>t.pointerId===e.pointerId);t!==-1&&(h.splice(t,1),h.length<2&&(g=-1/0,m=!1))}function ne(e){let t=h.findIndex(t=>t.pointerId===e.pointerId);if(t!==-1&&(h[t]=e,h.length===2)){let e=WN(h[0],h[1]);if(!m&&Math.abs(e-g)>=30&&(m=!0,g=e),m){let t=(e/g)**.5;o(Math.round(a()*t*1e3)/1e3),g=e}}}}function WN(e,t){let n=e.clientX-t.clientX,r=e.clientY-t.clientY;return Math.sqrt(n*n+r*r)}var GN=class extends k{static template=`o-spreadsheet-Border`;props=(0,t.useProps)({zone:M.Zone(),orientation:M.or([M.literal(`n`),M.literal(`s`),M.literal(`w`),M.literal(`e`)]),isMoving:M.boolean(),onMoveHighlight:M.function()});viewStore;setup(){this.viewStore=A(W)}get style(){let e=[`n`,`w`,`e`].includes(this.props.orientation),t=[`n`,`w`,`s`].includes(this.props.orientation),n=[`n`,`s`].includes(this.props.orientation),r=[`w`,`e`].includes(this.props.orientation),i=this.props.zone,a=this.viewStore.viewports.getVisibleRect(this.env.model.getters.getActiveSheetId(),i),o=a.x,s=a.x+a.width-4,c=a.y,l=a.y+a.height-4,u=t?o:s,d=e?c:l,f=n?s-o:4,p=r?l-c:4;return G({left:`${u}px`,top:`${d}px`,width:`${f}px`,height:`${p}px`})}onMouseDown(e){this.props.onMoveHighlight(e)}},KN=class extends k{static template=`o-spreadsheet-Corner`;props=(0,t.useProps)({zone:M.Zone(),color:M.Color(),orientation:M.or([M.literal(`nw`),M.literal(`ne`),M.literal(`sw`),M.literal(`se`),M.literal(`n`),M.literal(`s`),M.literal(`e`),M.literal(`w`)]),isResizing:M.boolean(),onResizeHighlight:M.function()});dirX;dirY;viewStore;setup(){this.viewStore=A(W);let{dirX:e,dirY:t}=qN(this.props.orientation);this.dirX=e,this.dirY=t}get handlerStyle(){let e=this.props.zone,t=this.viewStore.viewports.getVisibleRect(this.env.model.getters.getActiveSheetId(),{left:this.dirX===1?e.right:e.left,right:this.dirX===-1?e.left:e.right,top:this.dirY===1?e.bottom:e.top,bottom:this.dirY===-1?e.top:e.bottom});if(t.width*t.height===0)return`display: none !important;`;let n=t.x+t.width/2+this.dirX*t.width/2,r=t.y+t.height/2+this.dirY*t.height/2,i=this.getHandlerEdgeLength(),a={left:`${n-i/2}px`,top:`${r-i/2}px`,height:`${i}px`,width:`${i}px`};return this.env.isMobile()&&(a[`border-radius`]=`${i/2}px`),G(a)}getHandlerEdgeLength(){return this.env.isMobile()?40:8}get buttonLook(){let e={"background-color":this.props.color,cursor:`${this.props.orientation}-resize`};return this.env.isMobile()&&(e[`border-radius`]=`${8/2}px`),G(e)}onMouseDown(e){this.props.onResizeHighlight(e,this.dirX,this.dirY)}};function qN(e){return{dirX:e.includes(`w`)?-1:+!!e.includes(`e`),dirY:e.includes(`n`)?-1:+!!e.includes(`s`)}}var JN=class extends k{static template=`o-spreadsheet-Highlight`;static components={Corner:KN,Border:GN};props=(0,t.useProps)({range:M.Range(),color:M.Color()});highlightState=(0,t.proxy)({shiftingMode:`none`});dragNDropGrid=Jj(this.env);viewStore;zoomStore;setup(){this.viewStore=A(W),this.zoomStore=A(Rg)}get cornerOrientations(){if(!this.env.isMobile())return[`nw`,`ne`,`sw`,`se`];let e=this.props.range.unboundedZone;return e.bottom===void 0?[`w`,`e`]:e.right===void 0?[`n`,`s`]:[`nw`,`se`]}onResizeHighlight(e,t,n){let r=this.env.model.getters.getActiveSheetId(),i=this.zoomStore.getZoomedEvent(e);this.highlightState.shiftingMode=`isResizing`;let a=this.props.range.zone,o=t===1?a.left:a.right,s=n===1?a.top:a.bottom,c=t===1?a.right:a.left,l=n===1?a.bottom:a.top,u=a,d=`all`;this.env.isMobile()&&(d=t===0?`vertical`:n===0?`horizontal`:`all`),this.env.model.dispatch(`START_CHANGE_HIGHLIGHT`,{zone:u}),this.dragNDropGrid.start(i,(e,t)=>{if(c!==e||l!==t){let{left:n,right:i,top:a,bottom:f}=u;d!==`horizontal`&&(l=l=S(t===-1?l:t,0,this.env.model.getters.getNumberRows(r)-1),a=Math.min(s,l),f=Math.max(s,l)),d!==`vertical`&&(c=S(e===-1?c:e,0,this.env.model.getters.getNumberCols(r)-1),n=Math.min(o,c),i=Math.max(o,c));let p={left:n,right:i,top:a,bottom:f};mr(p,u)||(this.env.model.selection.selectZone({cell:{col:p.left,row:p.top},zone:p},{unbounded:!0}),u=p)}},()=>{this.highlightState.shiftingMode=`none`},d)}onMoveHighlight(e){this.highlightState.shiftingMode=`isMoving`;let t=this.props.range.zone,n=this.zoomStore.zoomLevel,r=v(n),i=this.zoomStore.getZoomedEvent(e,r),a=this.env.model.getters.getActiveSheetId(),o=this.viewStore.viewports.getColIndex(a,i.clientX-r.x),s=this.viewStore.viewports.getRowIndex(a,i.clientY-r.y),c=-t.left,l=this.env.model.getters.getNumberCols(a)-t.right-1,u=-t.top,d=this.env.model.getters.getNumberRows(a)-t.bottom-1,f=t;this.env.model.dispatch(`START_CHANGE_HIGHLIGHT`,{zone:f});let p=o,m=s;this.dragNDropGrid.start(i,(e,n)=>{if(p!==e||m!==n){p=e===-1?p:e,m=n===-1?m:n;let r=S(p-o,c,l),i=S(m-s,u,d),a={left:t.left+r,top:t.top+i,right:t.right+r,bottom:t.bottom+i};mr(a,f)||(this.env.model.selection.selectZone({cell:{col:a.left,row:a.top},zone:a},{unbounded:!0}),f=a)}},()=>{this.highlightState.shiftingMode=`none`})}},YN=class extends k{static components={ScrollBar:KE};viewStore;zoomStore;static template=t.xml`
67
+ `),i=e.pop();for(let i of e)n.push({color:r.color,value:i}),t.push(n),n=[];n.push({...r,value:i})}else n.push(r);n.length&&t.push(n);let r=[];for(let e of t)e.every(this.isContentEmpty)?r.push([e[0]]):r.push(e.filter(e=>!this.isContentEmpty(e)));return r}isContentEmpty(e){return!(e.value||e.classes?.length)}processTokenAtCursor(){let e=this.props.composerStore;this.functionDescriptionState.showDescription=!1;let t=this.props.composerStore.tokenAtCursor;if(Dn(e.currentContent)&&t&&t.type!==`SYMBOL`){let e=t.functionContext,n=e?.parent.toUpperCase();if(e&&n&&n in mN&&t.type!==`UNKNOWN`){let r=mN[n],i=e.argPosition,a=e.args.length;this.functionDescriptionState.functionDescription=r;let o=this.props.composerStore.currentTokens.some(e=>e.type===`RIGHT_PAREN`&&e.parenthesesCode===t.parenthesesCode);this.functionDescriptionState.argsToFocus=this.getArgsToFocus(o,r,a,i),this.functionDescriptionState.showDescription=!0,this.functionDescriptionState.repeatingArgGroupIndex=this.getRepeatingArgGroupIndex(r,a,i)}}}getRepeatingArgGroupIndex(e,t,n){let{minArgRequired:r,maxArgPossible:i,nbrArgRepeating:a}=e;if(!a)return;let o=(a?Math.ceil((t-r)/a):0)*a+r;return Xc(e,Math.max(Math.min(i,o),r))[n].repeatingGroupIndex??0}getArgsToFocus(e,t,n,r){let{nbrArgRepeating:i,minArgRequired:a,nbrOptionalNonRepeatingArgs:o,maxArgPossible:s}=t;if(e){let e=Xc(t,Math.max(Math.min(s,n),a))[r]?.index;return e===void 0?[]:[e]}let c=Math.max(n,a),l=i?a+Math.ceil((c-a)/i)*i+o:s,u=[];for(let e=c;e<=l;e++){let n=Xc(t,e)[r]?.index;n!==void 0&&u.push(n)}return[...new Set(u)]}autoComplete(e){!e?.text||this.assistant.forcedClosed&&this.props.composerStore.canBeToggled||(this.props.composerStore.insertAutoCompleteValue(e),this.processTokenAtCursor())}get displaySpeechBubble(){return!!(this.props.focus!==`inactive`&&this.composerState.hoveredRect&&this.props.composerStore.hoveredContentEvaluation)}};let gN=3*.4*globalThis.devicePixelRatio||1;var _N=class extends k{static template=`o-spreadsheet-GridComposer`;static components={Composer:hN};props=(0,t.useProps)({gridDims:M.DOMDimension(),onInputContextMenu:M.function()});rect=this.defaultRect;isEditing=!1;isCellReferenceVisible=!1;currentEditedCell={col:0,row:0,sheetId:this.env.model.getters.getActiveSheetId()};composerStore;composerFocusStore;viewStore;composerInterface;get defaultRect(){return{x:0,y:0,width:0,height:0}}setup(){let e=A(rN);this.composerStore=e,this.composerFocusStore=A(ni),this.viewStore=A(W),this.composerInterface={id:`gridComposer`,get editionMode(){return e.editionMode},startEdition:this.composerStore.startEdition,setCurrentContent:this.composerStore.setCurrentContent,stopEdition:this.composerStore.stopEdition},this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`inactive`}),(0,t.onWillUpdateProps)(()=>{this.updateComponentPosition(),this.updateCellReferenceVisibility()})}get shouldDisplayCellReference(){return!this.env.isMobile()&&this.isCellReferenceVisible}get cellReference(){let{col:e,row:t,sheetId:n}=this.composerStore.currentEditedCell;return Tl(n===this.env.model.getters.getActiveSheetId()?void 0:this.env.model.getters.getSheetName(n),E(e,t))}get cellReferenceStyle(){let{x:e,y:t}=this.rect;return G({left:`${e-gN}px`,top:`${t-28}px`})}get focus(){return this.composerFocusStore.activeComposer===this.composerInterface?this.composerFocusStore.focusMode:`inactive`}get composerProps(){let{width:e,height:t}=this.viewStore.sheetViewDimensionWithHeaders,n=this.props.gridDims.height-this.rect.y-2*gN;return{rect:{...this.rect},delimitation:{width:e,height:t},focus:this.focus,isDefaultFocus:!0,onComposerContentFocused:e=>this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`contentFocus`,selection:e}),onComposerCellFocused:e=>this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`cellFocus`,content:e}),onInputContextMenu:this.props.onInputContextMenu,composerStore:this.composerStore,inputStyle:`max-height: ${n}px;`,inputMode:this.composerStore.editionMode===`inactive`?`none`:void 0}}get containerStyle(){if(this.composerStore.editionMode===`inactive`||this.env.isMobile())return`z-index: -1000; opacity: 0;`;let e=Dn(this.composerStore.currentContent),t=this.env.model.getters.getActiveCell(),n=this.env.model.getters.getActivePosition(),r=this.env.model.getters.getCellComputedStyle(n),{x:i,y:a,width:o,height:s}=this.rect,c=!e&&r.fillColor||`#ffffff`,l=!e&&r.textColor||`#000000`,u=!e&&r.fontSize||10,d=!e&&r.bold?`bold`:void 0,f=!e&&r.italic?`italic`:`normal`,p=e?`none`:M_(r),m=`left`;e||(m=r.align==="default"||!r.align?t.defaultAlign:r.align);let h=this.props.gridDims.height-this.rect.y,g=this.props.gridDims.width-this.rect.x,_=Math.min(s+1,h),v=Math.min(o+1,g);return G({left:`${i-1}px`,top:`${a}px`,border:`${gN}px solid ${je}`,"min-width":`${v}px`,"min-height":`${_}px`,"max-width":`${g}px`,"max-height":`${h}px`,background:c,color:l,"font-size":`${Mp(u)}px`,"font-weight":d,"font-style":f,"text-decoration":p,"text-align":m})}updateComponentPosition(){let e=this.composerFocusStore.activeComposer.editionMode!==`inactive`;!e&&this.composerFocusStore.activeComposer!==this.composerInterface&&this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`inactive`});let t=!T(this.currentEditedCell,this.composerStore.currentEditedCell);if(this.isEditing!==e){if(this.isEditing=e,!e){this.rect=this.defaultRect;return}this.currentEditedCell=this.composerStore.currentEditedCell,t=!0}if(t){let e=this.env.model.getters.getActivePosition(),t=this.env.model.getters.expandZone(e.sheetId,D(e));this.rect=this.viewStore.viewports.getVisibleRect(e.sheetId,t)}}updateCellReferenceVisibility(){if(this.composerStore.editionMode===`inactive`){this.isCellReferenceVisible=!1;return}if(this.isCellReferenceVisible)return;let e=this.env.model.getters.getActiveSheetId(),t=D(this.env.model.getters.getSelection().anchor.cell);(!T(this.viewStore.viewports.getVisibleRect(e,t),this.rect)||e!==this.composerStore.currentEditedCell.sheetId)&&(this.isCellReferenceVisible=!0)}onFocus(){this.composerFocusStore.focusComposer(this.composerInterface,{focusMode:`contentFocus`})}};function vN(e,t=!1){e.__owl__.render(t)}var yN=class{mutators=[`setHighlightedFigure`];highlightedFigureId=void 0;setHighlightedFigure(e){this.highlightedFigureId=e}},bN=class e{getters;sheetId;definition;chartTypeBuilder;dataSourceBuilder;dataSource;constructor(e,t,n,r,i){this.getters=e,this.sheetId=t,this.definition=n,this.chartTypeBuilder=r,this.dataSourceBuilder=i,this.dataSource=n.dataSource}static fromStrDefinition(t,n,r){let i=wb.get(r.dataSource?.type??`none`),a=Tb.get(r.type),o=i.fromExternalDefinition(r.dataSource??{type:`none`},n,t),s={...a.fromStrDefinition(r,n,t),dataSource:o};return new e(t,n,e.deleteInvalidKeys(s),a,i)}static fromDefinition(t,n,r){let i=wb.get(r.dataSource?.type??`none`);return new e(t,n,r,Tb.get(r.type),i)}static validate(e,t){let n=Tb.get(t.type),r=wb.get(t.dataSource?.type??`none`);return e.batchValidations(()=>n.validateDefinition(e,t),()=>r.validate(t.dataSource??{type:`none`},e))(void 0)}static transformDefinition(e,t,n){let r=Tb.get(t.type);if(!t.dataSource)return r.transformDefinition(t,e,n);let i=wb.get(t.dataSource?.type??`none`).transform(t.dataSource,e,n);return{...r.transformDefinition(t,e,n),dataSource:i}}getRangeDefinition(){return{...this.definition,dataSource:this.dataSource}}getDefinition(){return{...this.chartTypeBuilder.toStrDefinition(this.definition,this.sheetId,this.getters),dataSource:this.dataSource&&this.dataSourceBuilder.getDefinition(this.dataSource,this.sheetId,this.getters)}}updateRanges(e){return{...this.chartTypeBuilder.updateRanges(this.definition,e,this.sheetId),dataSource:this.dataSource&&this.dataSourceBuilder.adaptRanges(this.dataSource,e)}}duplicateInDuplicatedSheet(t,n){let r=this.dataSource&&this.dataSourceBuilder.duplicateInDuplicatedSheet(this.dataSource,t,n,this.getters),i={...this.chartTypeBuilder.duplicateInDuplicatedSheet(this.definition,t,n,this.getters),dataSource:r};return e.fromDefinition(this.getters,n,i).getDefinition()}copyInSheetId(e){return{...this.chartTypeBuilder.copyInSheetId(this.definition,this.sheetId,e,this.getters),dataSource:this.dataSource}}getContextCreation(){let e=this.getDefinition();return{...this.dataSourceBuilder.getContextCreation(e.dataSource??{type:`none`}),...this.chartTypeBuilder.getContextCreation(e,this.dataSourceBuilder,e.dataSource)}}getDefinitionForExcel(e){let t=this.definition,n=this.dataSourceBuilder.toExcelDataSets(this.dataSource,`dataSetStyles`in t?t.dataSetStyles:{},e);if(n!==void 0)return this.chartTypeBuilder.getDefinitionForExcel(e,t,n)}getData(e,t){let n=this.dataSource;return n?this.dataSourceBuilder.extractData(n,t,e):{dataSetsValues:[],labelValues:[]}}getFormulas(e){return this.chartTypeBuilder.getFormulas(e,this.sheetId,this.definition)}getRuntime(e,t,n){let r=this.dataSource,i=r?{extractData:()=>this.dataSourceBuilder.extractData(r,t,e),extractHierarchicalData:()=>this.dataSourceBuilder.extractHierarchicalData(r,t,e)}:{extractData:()=>({dataSetsValues:[],labelValues:[]}),extractHierarchicalData:()=>({dataSetsValues:[],labelValues:[]})};return this.chartTypeBuilder.getRuntime(e,this.definition,i,this.sheetId,{onClick:(n,r,i)=>this.dataSourceBuilder.onDataSetClick?.(this.definition.type,t,n,r,i,e),onHover:(e,n,r)=>this.dataSourceBuilder.onDataSetHover?.(this.definition.type,t,e,n,r)},n)}static deleteInvalidKeys(e){e={...e};let t=new Set(Tb.get(e.type).allowedDefinitionKeys);for(let n of Object.keys(e))t.has(n)||delete e[n];return e}async loadDataForExport(e){return this.chartTypeBuilder.loadDataForExport?.(e)}};function xN(e){return e===`scorecard`?{width:213,height:101}:{width:536,height:335}}function SN(e,t,n){if(e.tag!==`chart`)return;let r=e.x+e.width/2,i=e.y+e.height/2,a,o=1/0;for(let s of t){if(!n.includes(s.tag))continue;let t=s.x+s.width/2,c=s.y+s.height/2,l=Math.abs(r-t),u=Math.abs(i-c),d=l**2+u**2;l<=e.width/2&&u<=e.height/2&&d<o&&(o=d,a=s)}return a}function CN(e,t,n){let r=e.getStore(Rg).zoomLevel,i=v(r),a=document.querySelector(`.o-spreadsheet`);if(!a)return;let o=n.clientX/r,s=n.clientY/r,{width:c,height:l}=xN(t.type),u=c*r,d=l*r,f=e.model.getters,p=f.getActiveSheetId(),m=null,h,g=e.getStore(yN),_=document.body.style.cursor;document.body.style.cursor=`grabbing`;let ee=(t,n)=>{if(t>i.x+i.width||n>i.y+i.height)return;let{scrollX:a,scrollY:o}=e.getStore(W).activeSheetScrollInfo;return{x:Math.max(0,(t-i.x)/r+a),y:Math.max(0,(n-i.y)/r+o)}},y=(t,n)=>{let r=ee(t,n);if(!r)return;let i={tag:`chart`,...r,width:c,height:l},a=e.getStore(W).visibleFigures;return SN(i,a,[`carousel`,`chart`])},b=u/2,te=d/2;IE(e=>{if(Math.abs(e.clientX-o)<=5&&Math.abs(e.clientY-s)<=5)return;if(m===null){m=document.createElement(`div`),m.className=`o-chart-drag-preview os-theme-dependant position-fixed border pe-none`,m.style.width=`${c}px`,m.style.height=`${l}px`,m.style.zoom=`${r}`;let e=document.createElement(`canvas`);e.className=`w-100 h-100`,m.appendChild(e),a.appendChild(m),h=T_(e,bN.fromStrDefinition(f,p,t).getRuntime(f,`newChart`,f.getSpreadsheetTheme().colorThemeName),{width:c,height:l},t.type,r)}m.style.left=`${Math.max(i.x,(e.clientX-b)/r)}px`,m.style.top=`${Math.max(i.y,(e.clientY-te)/r)}px`;let n=y(e.clientX-b,e.clientY-te);m.style.opacity=n?.id?`0.6`:`0.9`,g.setHighlightedFigure(n?.id)},n=>{g.setHighlightedFigure(void 0),m!==null&&(a.removeChild(m),m=null),h?.(),document.body.style.cursor=_;let u=ee(n.clientX-b,n.clientY-te);if(Math.abs(n.clientX/r-o)<=5&&Math.abs(n.clientY/r-s)<=5)u={x:0,y:0};else if(!u||u.x+b>i.width)return;let{col:d,row:f,offset:v}=e.getStore(W).viewports.getPositionAnchorOffset(p,u),ne={chartId:K.smallUuid(),figureId:K.smallUuid(),sheetId:p,size:{width:c,height:l},definition:t,col:d,row:f,offset:v},re=y(n.clientX-b,n.clientY-te);re?.tag===`carousel`?e.model.dispatch(`ADD_NEW_CHART_TO_CAROUSEL`,{sheetId:p,figureId:re.id,newChartId:K.smallUuid(),chartDefinition:t}):re?.tag===`chart`?e.model.dispatch(`CREATE_CHART_AND_MERGE_INTO_CAROUSEL`,{chartId:ne.chartId,figureId:ne.figureId,sheetId:ne.sheetId,definition:ne.definition,baseFigureId:re.id}):e.model.dispatch(`CREATE_CHART`,ne)})}function wN({x:e,y:t},{x:n,y:r},i,{maxX:a,maxY:o},{scrollX:s,scrollY:c},{scrollX:l,scrollY:u}){let d=e-n+l-s,f=t-r+u-c;for(let e of i)d=S(d,-e.x,a-e.x-e.width),f=S(f,-e.y,o-e.y-e.height);return i.map(e=>({...e,x:e.x+d,y:e.y+f}))}function TN(e,t,n,{x:r,y:i},{x:a,y:o},s,c,{scrollX:l,scrollY:u},{scrollX:d,scrollY:f},{maxX:p,maxY:m}){let{x:h,y:g,width:_,height:v}=e;if(s&&t!==0&&n!==0){let e=Math.min(t*(a-r+d-l),_-c.width),s=Math.min(n*(o-i+f-u),v-c.height),p=Math.min(e/_,s/v);t<0&&(h+=_*p),n<0&&(g+=v*p),_*=1-p,v*=1-p}else{let e=Math.max(t*(r-a+d-l),c.width-_),s=Math.max(n*(i-o+f-u),c.height-v);_+=e,v+=s,t<0&&(h-=e),n<0&&(g-=s)}return h+d<=0?(_=_+h+d,h=-d):h+_>p&&(_=p-h),g+f<=0?(v=v+g+f,g=-f):g+v>m&&(v=m-g),{x:h,y:g,width:_,height:v}}function EN(e,t,n){let r=Ng(...t),i=AN(e,r,[`hCenter`,`right`,`left`],n,[`hCenter`,`right`,`left`]),a=AN(e,r,[`vCenter`,`bottom`,`top`],n,[`vCenter`,`bottom`,`top`]),{y:o,x:s}=e.getStore(W).mainViewportCoordinates,{scrollY:c,scrollX:l}=e.getStore(W).activeSheetScrollInfo;for(let e of t){if(a){e.y-=a.snapOffset;let t=e.y<o,n=e.y<o;t&&!n?e.y+=c:!t&&n&&(e.y-=c)}if(i){e.x-=i.snapOffset;let t=e.x<s,n=e.x<s;t&&!n?e.x+=l:!t&&n&&(e.x-=l)}}return{snappedFigures:t,verticalSnapLine:i,horizontalSnapLine:a}}function DN(e,t,n,r,i){let a=AN(e,r,[t===-1?`left`:`right`],i,[`right`,`left`]),o=AN(e,r,[n===-1?`top`:`bottom`],i,[`bottom`,`top`]);return a&&(t===1?r.width-=a.snapOffset:t===-1&&(r.x-=a.snapOffset,r.width+=a.snapOffset)),o&&(n===1?r.height-=o.snapOffset:n===-1&&(r.y-=o.snapOffset,r.height+=o.snapOffset)),{snappedRect:{x:Math.round(r.x),y:Math.round(r.y),width:Math.round(r.width),height:Math.round(r.height)},verticalSnapLine:a,horizontalSnapLine:o}}function ON(e,t,n){return n.map(n=>MN(e,t,!1,n)).filter(n=>kN(e,t,n))}function kN(e,t,n){let{x:r,y:i}=e.getStore(W).mainViewportCoordinates,a=[];switch(n.axisType){case`top`:case`bottom`:case`vCenter`:if(t.y<i)return!0;a.push({x:t.x,y:n.position}),a.push({x:t.x+t.width,y:n.position});break;case`left`:case`right`:case`hCenter`:if(t.x<r)return!0;a.push({x:n.position,y:t.y}),a.push({x:n.position,y:t.y+t.height});break}return a.some(t=>e.getStore(W).viewports.isPixelPositionVisible(e.model.getters.getActiveSheetId(),t))}function AN(e,t,n,r,i){let a=n.map(n=>MN(e,t,!0,n)),o;for(let t of r){let n=ON(e,t,i);for(let e of a)for(let r of n){if(!jN(e.position,r.position))continue;let n=e.position-r.position;o&&n===o.snapOffset?o.matchedFigIds.push(t.id):(!o||Math.abs(n)<=Math.abs(o.snapOffset))&&(o={matchedFigIds:[t.id],snapOffset:n,snappedAxisType:e.axisType,position:r.position})}}return o}function jN(e,t){return Math.abs(e-t)<=5}function MN(e,t,n,r){let i=0,{scrollX:a,scrollY:o}=e.getStore(W).activeSheetScrollInfo,{x:s,y:c}=e.getStore(W).mainViewportCoordinates,l=!n&&t.y<c?t.y+o:t.y,u=!n&&t.x<s?t.x+a:t.x;switch(r){case`top`:i=l;break;case`bottom`:i=l+t.height-1;break;case`vCenter`:i=l+Math.floor(t.height/2)-1;break;case`left`:i=u;break;case`right`:i=u+t.width-1;break;case`hCenter`:i=u+Math.floor(t.width/2)-1;break}return{position:i,axisType:r}}var NN=class extends k{static template=`o-spreadsheet-FiguresContainer`;static components={FigureComponent:rD};dnd=(0,t.proxy)({draggedFigure:void 0,selectedFigures:void 0,selectedRect:void 0,horizontalSnap:void 0,verticalSnap:void 0,cancelDnd:void 0});viewStore;zoomStore;chartDragStore;setup(){this.viewStore=A(W),this.zoomStore=A(Rg),this.chartDragStore=A(yN),(0,t.onMounted)(()=>{vN(this)}),(0,t.onWillUpdateProps)(()=>{let e=this.env.model.getters.getActiveSheetId(),t=this.dnd.draggedFigure?.id;t&&!this.env.model.getters.getFigure(e,t)&&(this.dnd.cancelDnd?.(),this.dnd.draggedFigure=void 0,this.dnd.selectedFigures=void 0,this.dnd.selectedRect=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0,this.chartDragStore.setHighlightedFigure(void 0),this.dnd.cancelDnd=void 0)})}getVisibleFigures(){let e=this.viewStore.visibleFigures;for(let t of this.dnd.selectedFigures||[])e.some(e=>e.id===t.id)||e.push(t);return e}get containers(){let e=this.getVisibleFigures(),t=[];for(let n of[`topLeft`,`topRight`,`bottomLeft`,`bottomRight`]){let r=e.filter(e=>this.getFigureContainer(e)===n);r.length>0&&t.push({type:n,figures:r,style:this.getContainerStyle(n),inverseViewportStyle:this.getInverseViewportPositionStyle(n)})}return this.dnd.selectedFigures&&t.push({type:`dnd`,figures:this.dnd.selectedFigures,style:this.getContainerStyle(`dnd`),inverseViewportStyle:this.getInverseViewportPositionStyle(`dnd`)}),t}getContainerStyle(e){return this.rectToCss(this.getContainerRect(e))}rectToCss(e){return G({left:`${e.x}px`,top:`${e.y}px`,width:`${e.width}px`,height:`${e.height}px`})}getContainerRect(e){let{width:t,height:n}=this.viewStore.sheetViewDimension,{x:r,y:i}=this.viewStore.mainViewportCoordinates,a=[`bottomRight`,`topRight`].includes(e)?r:0,o=t-a,s=[`bottomRight`,`bottomLeft`].includes(e)?i:0;return{x:a,y:s,width:o,height:n-s}}get selectedRectStyle(){return this.dnd.selectedRect?this.rectToCss(this.dnd.selectedRect):``}get maxDimensions(){let e=this.env.model.getters.getActiveSheetId();return{maxX:this.env.model.getters.getColDimensions(e,this.env.model.getters.getNumberCols(e)-1).end,maxY:this.env.model.getters.getRowDimensions(e,this.env.model.getters.getNumberRows(e)-1).end}}getInverseViewportPositionStyle(e){let{scrollX:t,scrollY:n}=this.viewStore.activeSheetScrollInfo,{x:r,y:i}=this.viewStore.mainViewportCoordinates,a=0,o=0;return e===`dnd`&&(a=-t,o=-n),[`bottomRight`,`topRight`].includes(e)&&(a=-t-r),[`bottomRight`,`bottomLeft`].includes(e)&&(o=-n-i),G({left:`${a}px`,top:`${o}px`})}getFigureContainer(e){let{x:t,y:n}=this.viewStore.mainViewportCoordinates;return this.dnd.selectedFigures?.some(t=>t.id===e.id)?`dnd`:e.x<t&&e.y<n?`topLeft`:e.x<t?`bottomLeft`:e.y<n?`topRight`:`bottomRight`}getDndFigureRect(){if(this.dnd.selectedFigures&&this.dnd.selectedFigures.length>1)return Ng(...this.dnd.selectedFigures)}toBottomRightViewport(e){let t=this.getFigureContainer(e),n=this.viewStore.activeSheetScrollInfo,r={...e};return[`bottomLeft`,`topLeft`].includes(t)&&(r.x+=n.scrollX),[`topLeft`,`topRight`].includes(t)&&(r.y+=n.scrollY),r}isMenuClick(e){let t=e.target;return t&&t instanceof Element?!!t.closest(`.o-figure-menu`):!1}startDraggingFigure(e,t){if(t.button>0||this.env.model.getters.isReadonly()||this.isMenuClick(t))return;let n=this.env.model.getters.getSelectedFigureIds().includes(e.id);if(!n&&!this.env.model.dispatch(`SELECT_FIGURE`,{figureId:e.id,selectMultiple:t.shiftKey||ue(t)}).isSuccessful||this.env.isMobile()||this.env.model.getters.isCurrentSheetLocked())return;let r=this.env.model.getters.getActiveSheetId(),i=this.zoomStore.zoomLevel,a={x:t.clientX/i,y:t.clientY/i},o=this.viewStore.activeSheetScrollInfo,s=this.maxDimensions,c=this.env.model.getters.getSelectedFigureIds().map(e=>this.env.model.getters.getFigure(r,e)).filter(w).map(e=>this.env.model.getters.getFigureUI(r,e)).map(this.toBottomRightViewport.bind(this)),l=e.id,u=!1,d,f=e=>{let t={x:e.clientX/i,y:e.clientY/i},n=Math.abs(t.x-a.x),r=Math.abs(t.y-a.y);if(!u&&n<5&&r<5)return;u=!0;let f=wN(t,a,c,s,o,this.viewStore.activeSheetScrollInfo),p=f.find(e=>e.id===l);d=void 0;let m=this.getOtherFigures(f.map(e=>e.id));if(p&&!f.find(e=>e.tag!==`chart`)&&(d=SN(p,m,[`carousel`,`chart`])),this.chartDragStore.setHighlightedFigure(d?.id),d)this.dnd.draggedFigure=p,this.dnd.selectedFigures=f,this.dnd.selectedRect=this.getDndFigureRect(),this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0;else{let e=EN(this.env,f,m);this.dnd.selectedFigures=e.snappedFigures,this.dnd.selectedRect=this.getDndFigureRect(),this.dnd.draggedFigure=f.find(e=>e.id===l),this.dnd.horizontalSnap=this.getSnap(e.horizontalSnapLine),this.dnd.verticalSnap=this.getSnap(e.verticalSnapLine)}},p=t=>{if(!this.dnd.draggedFigure){n&&(t.shiftKey||ue(t)?this.env.model.dispatch(`UNSELECT_FIGURE`,{figureId:e.id}):this.env.model.dispatch(`SELECT_FIGURE`,{figureId:e.id}));return}if(d){let e=d.id,t=this.dnd.selectedFigures?.map(e=>e.id)||[];d.tag===`carousel`?this.env.model.dispatch(`ADD_FIGURES_CHART_TO_CAROUSEL`,{sheetId:r,carouselFigureId:e,chartFigureIds:t}):d.tag===`chart`&&this.env.model.dispatch(`MERGE_CHART_FIGURES_INTO_CAROUSEL`,{sheetId:r,baseFigureId:e,chartFigureIds:[e,...t]})}else{let e=this.dnd.selectedFigures?.map(e=>({sheetId:r,figureId:e.id,...this.viewStore.viewports.getPositionAnchorOffset(r,e)}))||[];this.env.model.dispatch(`UPDATE_FIGURES`,{figures:e})}this.dnd.draggedFigure=void 0,this.dnd.selectedFigures=void 0,this.dnd.selectedRect=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0,this.chartDragStore.setHighlightedFigure(void 0)};this.dnd.cancelDnd=IE(f,p)}resizeAllSelectedFigures(e,t,n){n.stopPropagation();let r=this.env.model.getters.getActiveSheetId(),i=this.zoomStore.zoomLevel,a={x:n.clientX/i,y:n.clientY/i},o=this.viewStore.activeSheetScrollInfo,s=this.maxDimensions,c=this.env.model.getters.getSelectedFigureIds(),l=c.map(e=>this.env.model.getters.getFigure(r,e)).filter(w).map(e=>this.env.model.getters.getFigureUI(r,e)).map(this.toBottomRightViewport.bind(this)),u=c.length>1,d=this.getOtherFigures(c);if(l.length===0)return;let f;if(u){let e=Math.max(...l.map(e=>nD.get(e.tag).minFigSize/e.width)),t=Math.max(...l.map(e=>nD.get(e.tag).minFigSize/e.height)),n=Ng(...l);f={width:Math.round(n.width*e),height:Math.round(n.height*t)}}else{let e=nD.get(l[0].tag).minFigSize;f={width:e,height:e}}let p=n=>{let r={x:n.clientX/i,y:n.clientY/i},c=u||n.shiftKey?!0:nD.get(l[0].tag).keepRatio||!1,p=Ng(...l),m=TN(p,e,t,r,a,c,f,o,this.viewStore.activeSheetScrollInfo,s),{snappedRect:h,verticalSnapLine:g,horizontalSnapLine:_}=DN(this.env,e,t,m,d),v=h.width/p.width,ee=h.height/p.height,y=l.map(e=>({...e,x:Math.round(h.x+(e.x-p.x)*v),y:Math.round(h.y+(e.y-p.y)*ee),width:Math.round(e.width*v),height:Math.round(e.height*ee)}));this.dnd.draggedFigure=y[0],this.dnd.selectedFigures=y,this.dnd.selectedRect=this.getDndFigureRect(),this.dnd.horizontalSnap=this.getSnap(_),this.dnd.verticalSnap=this.getSnap(g)},m=()=>{if(!this.dnd.selectedFigures)return;let n=this.dnd.selectedFigures.map(n=>{let i=this.viewStore.viewports.getPositionAnchorOffset(r,n);return e&&(i.width=n.width),t&&(i.height=n.height),{sheetId:r,figureId:n.id,...i}});this.env.model.dispatch(`UPDATE_FIGURES`,{figures:n}),this.dnd.draggedFigure=void 0,this.dnd.selectedFigures=void 0,this.dnd.selectedRect=void 0,this.dnd.horizontalSnap=void 0,this.dnd.verticalSnap=void 0};this.dnd.cancelDnd=IE(p,m)}getOtherFigures(e){return this.getVisibleFigures().filter(t=>!e.includes(t.id))}getFigureStyle(e){return e.id===this.dnd.draggedFigure?.id?G({opacity:this.chartDragStore.highlightedFigureId?`0.6`:`0.9`,cursor:`grabbing`}):``}getFigureClass(e){return e.id===this.chartDragStore.highlightedFigureId?`o-add-to-carousel`:``}getSnap(e){if(!e||!this.dnd.draggedFigure)return;let{scrollX:t,scrollY:n}=this.viewStore.activeSheetScrollInfo,r=e.matchedFigIds.map(e=>this.getVisibleFigures().find(t=>t.id===e)).filter(w).map(e=>({x:e.x-t,y:e.y-n,width:e.width,height:e.height})).filter(w),i=Ng({...this.dnd.draggedFigure,x:this.dnd.draggedFigure.x-t,y:this.dnd.draggedFigure.y-n},...r);return{line:e,containerStyle:this.rectToCss(i),lineStyle:this.getSnapLineStyle(e,i)}}getSnapLineStyle(e,t){if(!e)return``;let{scrollX:n,scrollY:r}=this.viewStore.activeSheetScrollInfo;return[`top`,`vCenter`,`bottom`].includes(e.snappedAxisType)?G({top:`${e.position-t.y-r}px`,left:`0px`,width:`100%`}):G({top:`0px`,left:`${e.position-t.x-n}px`,height:`100%`})}},PN=class extends k{static template=`o-spreadsheet-HeaderResizeEditor`;static components={Popover:Fw};props=(0,t.useProps)({target:M.signal(),gridRect:M.Rect()});errorMessage=(0,t.signal)(``);isInputEmpty=(0,t.signal)(!1);inputRef=t.signal.ref(HTMLInputElement);editorRef=t.signal.ref();viewStore;zoomStore;DOMFocusableElementStore;setup(){this.viewStore=A(W),this.zoomStore=A(Rg),this.DOMFocusableElementStore=A(Ow),(0,t.useListener)(window,`click`,this.onExternalClick.bind(this),{capture:!0}),(0,t.useListener)(window,`contextmenu`,this.onExternalClick.bind(this),{capture:!0}),(0,t.useEffect)(()=>{let e=this.inputRef();e&&this.props.target()&&(e.value=this.currentSize.toString(),e.focus(),e.select())})}get target(){let e=this.props.target();if(!e)throw Error(`Header resize editor target is not set`);return e}get popoverProps(){return{anchorRect:this.anchorRect,positioning:this.target.dimension===`COL`?`bottom-left`:`top-right`,onPopoverHidden:()=>this.close()}}get anchorRect(){let{dimension:e,index:t}=this.target,n=this.env.model.getters.getActiveSheetId(),r=this.viewStore.gridOffset,i;if(e===`COL`){let{start:e,size:a}=this.viewStore.viewports.getColDimensionsInViewport(n,t);i={x:r.x+e,y:0,width:a,height:r.y}}else{let{start:e,size:a}=this.viewStore.viewports.getRowDimensionsInViewport(n,t);i={x:0,y:r.y+e,width:r.x,height:a}}let a=this.zoomStore.getZoomedRect(i);return{...a,x:this.props.gridRect.x+a.x,y:this.props.gridRect.y+a.y}}get minSize(){return this.target.dimension===`COL`?5:10}get currentSize(){let e=this.env.model.getters.getActiveSheetId();return this.target.dimension===`COL`?this.env.model.getters.getColSize(e,this.target.index):this.env.model.getters.getRowSize(e,this.target.index)}onExternalClick(e){this.props.target()&&!_(this.editorRef(),e)&&this.close()}close(){this.editorRef()?.contains(document.activeElement)&&this.DOMFocusableElementStore.focus(),this.errorMessage.set(``),this.isInputEmpty.set(!1),this.props.target.set(null)}onInput(e){let t=e.target;this.errorMessage.set(``),this.isInputEmpty.set(!t.value&&!t.validity.badInput)}get emptyInputHint(){return this.target.dimension===`COL`?N(`Empty value resets width to %s px`,96):N(`Empty value fits height to content`)}onKeydown(e){e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),this.apply()):e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),this.close())}apply(){if(!this.props.target())return;let e=this.validateAndParseSize();e!==void 0&&this.env.model.dispatch(`RESIZE_COLUMNS_ROWS`,{sheetId:this.env.model.getters.getActiveSheetId(),dimension:this.target.dimension,elements:this.target.dimension===`COL`?[...this.env.model.getters.getActiveCols()]:[...this.env.model.getters.getActiveRows()],size:e}).isSuccessful&&this.close()}validateAndParseSize(){let e=this.inputRef();if(!e)return;if(!e.value&&!e.validity.badInput)return null;let t=e.valueAsNumber;if(!Number.isInteger(t)){this.errorMessage.set(N(`Size must be an integer`));return}if(t<this.minSize||t>2e3){this.errorMessage.set(N(`Size must be between %(min)s and %(max)s pixels`,{min:this.minSize,max:Ge}));return}return t}},FN=class extends k{static template=`o-spreadsheet-UnhideRowHeaders`;props=(0,t.useProps)({headersGroups:M.array(),headerRange:M.object({start:M.HeaderIndex(),end:M.HeaderIndex()}),offset:M.number().optional(0)});viewStore;setup(){this.viewStore=A(W)}get sheetId(){return this.env.model.getters.getActiveSheetId()}getUnhidePreviousButtonStyle(e){let t=this.viewStore.viewports.getRect(this.sheetId,D({col:0,row:e}));return G({top:t.y+t.height-26-this.props.offset+`px`,"margin-right":`1px`})}getUnhideNextButtonStyle(e){return G({top:this.viewStore.viewports.getRect(this.sheetId,D({col:0,row:e})).y-26-this.props.offset+`px`,"margin-right":`1px`})}unhide(e){this.env.model.dispatch(`UNHIDE_COLUMNS_ROWS`,{sheetId:this.sheetId,dimension:`ROW`,elements:e})}isVisible(e){return e>=this.props.headerRange.start&&e<=this.props.headerRange.end}},IN=class extends k{static template=`o-spreadsheet-UnhideColumnHeaders`;props=(0,t.useProps)({headersGroups:M.array(),headerRange:M.object({start:M.HeaderIndex(),end:M.HeaderIndex()}),offset:M.number().optional(0)});viewStore;setup(){this.viewStore=A(W)}get sheetId(){return this.env.model.getters.getActiveSheetId()}getUnhidePreviousButtonStyle(e){let t=this.viewStore.viewports.getRect(this.sheetId,D({col:e,row:0}));return G({left:t.x+t.width-48-this.props.offset+`px`})}getUnhideNextButtonStyle(e){return G({left:this.viewStore.viewports.getRect(this.sheetId,D({col:e,row:0})).x-48-this.props.offset+`px`})}unhide(e){this.env.model.dispatch(`UNHIDE_COLUMNS_ROWS`,{sheetId:this.sheetId,dimension:`COL`,elements:e})}isVisible(e){return e>=this.props.headerRange.start&&e<=this.props.headerRange.end}};let LN={onOpenContextMenu:M.function()};var RN=class extends k{props=(0,t.useProps)(LN);composerFocusStore;viewStore;zoomStore;PADDING=0;MAX_SIZE_MARGIN=0;MIN_ELEMENT_SIZE=0;lastSelectedElementIndex=null;state=(0,t.proxy)({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0,position:`before`});dragNDropGrid=Jj(this.env);setup(){this.composerFocusStore=A(ni),this.viewStore=A(W),this.zoomStore=A(Rg)}_computeHandleDisplay(e){let t=this._getEvOffset(e),n=this._getElementIndex(t);if(n<0)return;let r=this._getDimensionsInViewport(n);t-r.start<this.PADDING&&n!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=r.start,this.state.activeElement=this._getPreviousVisibleElement(n)):r.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=r.end,this.state.activeElement=n):this.state.resizerIsActive=!1}_computeGrabDisplay(e){if(ue(e.ev)){this.state.waitingForMove=!1;return}let t=this._getElementIndex(this._getEvOffset(e)),n=this._getActiveElements(),r=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();if(n.has(r)&&r<=t&&t<=i){this.state.waitingForMove=!0;return}this.state.waitingForMove=!1}onMouseMove(e){if(this.env.isMobile()||this.env.model.getters.isReadonly()||this.state.isResizing||this.state.isMoving||this.state.isSelecting)return;let t=this.zoomStore.getZoomedEvent(e);this._computeHandleDisplay(t),this._computeGrabDisplay(t)}onMouseLeave(){this.state.resizerIsActive=this.state.isResizing,this.state.waitingForMove=!1}onDblClick(e){let t=this.zoomStore.getZoomedEvent(e);this._fitElementSize(this.state.activeElement),this.state.isResizing=!1,this._computeHandleDisplay(t),this._computeGrabDisplay(t)}onMouseDown(e){if(e.button!==0)return;this.state.isResizing=!0,this.state.delta=0;let t=this.zoomStore.getZoomedEvent(e),n=this._getClientPosition(t),r=this.state.draggerLinePosition,i=this._getElementSize(this.state.activeElement),a=r-i+this.MIN_ELEMENT_SIZE,o=Math.min(this._getMaxSize(),r-i+Ge);IE(e=>{this.state.delta=this._getClientPosition(this.zoomStore.getZoomedEvent(e))-n,this.state.draggerLinePosition=r+this.state.delta,this.state.draggerLinePosition<a&&(this.state.draggerLinePosition=a,this.state.delta=this.MIN_ELEMENT_SIZE-i),this.state.draggerLinePosition>o&&(this.state.draggerLinePosition=o,this.state.delta=o-r)},e=>{this.state.isResizing=!1,this.state.delta!==0&&this._updateSize()})}onClick(e){if(!this.env.isMobile()||e.button>0)return;let t=this.zoomStore.getZoomedEvent(e),n=this._getElementIndex(this._getEvOffset(t));this._selectElement(n,!1)}select(e){if(this.env.isMobile()||e.button>0)return;let t=this.zoomStore.getZoomedEvent(e),n=this._getElementIndex(this._getEvOffset(t));if(!(n<0)){if(this.env.model.getters.isReadonly()){this._selectElement(n,!1);return}if(!ue(e)&&this.state.waitingForMove){this.env.model.getters.isGridSelectionActive()?this.startMovement(e):this._selectElement(n,!1);return}this.composerFocusStore.activeComposer.editionMode===`editing`&&this.env.model.selection.getBackToDefault(),this.startSelection(e,n)}}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;let t=this.zoomStore.getZoomedEvent(e),n=this._getDimensionsInViewport(this._getSelectedZoneStart()),r=this._getDimensionsInViewport(this._getSelectedZoneEnd()),i=n.start;this.state.draggerLinePosition=i,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=i,this.state.draggerShadowThickness=r.end-n.start,this.dragNDropGrid.start(t,(e,t)=>{let r=this._getType()===`COL`?e:t;if(r>=0){let e=this._getDimensionsInViewport(r);r<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=r,this.state.position=`before`):this._getSelectedZoneEnd()<r?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=r,this.state.position=`after`):(this.state.draggerLinePosition=n.start,this.state.draggerShadowPosition=n.start,this.state.base=this._getSelectedZoneStart())}},()=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements();let t=this.zoomStore.getZoomedEvent(e);this._computeGrabDisplay(t)})}startSelection(e,t){if(this.env.isMobile())return;this.state.isSelecting=!0,e.shiftKey?this._increaseSelection(t):this._selectElement(t,ue(e)),this.lastSelectedElementIndex=t;let n=this.zoomStore.getZoomedEvent(e);this.dragNDropGrid.start(n,(e,t)=>{let n=this._getType()===`COL`?e:t;n!==this.lastSelectedElementIndex&&n!==-1&&(this._increaseSelection(n),this.lastSelectedElementIndex=n)},()=>{this.env.model.selection.commitSelection(),this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this._computeGrabDisplay(n)})}onContextMenu(e){e.preventDefault();let t=this._getElementIndex(this._getEvOffset(this.zoomStore.getZoomedEvent(e)));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);let n=this._getType();this.props.onOpenContextMenu(n,e.clientX,e.clientY)}},zN=class extends RN{static template=`o-spreadsheet-ColResizer`;static components={UnhideColumnHeaders:IN};colResizerRef=t.signal.ref();setup(){super.setup(),this.PADDING=15,this.MAX_SIZE_MARGIN=90,this.MIN_ELEMENT_SIZE=5}get sheetId(){return this.env.model.getters.getActiveSheetId()}_getEvOffset(e){return e.offsetX}_getViewportOffset(){return this.viewStore.activeMainViewport.left}_getClientPosition(e){return e.clientX}_getElementIndex(e){return this.viewStore.viewports.getColIndex(this.sheetId,e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().left}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().right}_getEdgeScroll(e){return this.viewStore.viewports.getEdgeScrollCol(this.sheetId,e,e,e)}_getDimensionsInViewport(e){return this.viewStore.viewports.getColDimensionsInViewport(this.sheetId,e)}_getElementSize(e){return this.env.model.getters.getColSize(this.sheetId,e)}_getMaxSize(){return this.colResizerRef()?.clientWidth??0}_updateSize(){let e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),n=this.env.model.getters.getActiveCols();this.env.model.dispatch(`RESIZE_COLUMNS_ROWS`,{dimension:`COL`,sheetId:this.sheetId,elements:n.has(e)?[...n]:[e],size:t})}_moveElements(){let e=[],t=this._getSelectedZoneStart(),n=this._getSelectedZoneEnd();for(let r=t;r<=n;r++)e.push(r);let r=this.env.model.dispatch(`MOVE_COLUMNS_ROWS`,{sheetId:this.sheetId,sheetName:this.env.model.getters.getActiveSheetName(),dimension:`COL`,base:this.state.base,elements:e,position:this.state.position});!r.isSuccessful&&r.reasons.includes(`WillRemoveExistingMerge`)&&this.env.raiseError(hT)}_selectElement(e,t){this.env.model.selection.selectColumn(e,t?`newAnchor`:`overrideSelection`)}_increaseSelection(e){this.env.model.selection.selectColumn(e,`updateAnchor`)}_fitElementSize(e){let t=this.env.model.getters.getActiveCols();this.env.model.dispatch(`AUTORESIZE_COLUMNS`,{sheetId:this.sheetId,cols:t.has(e)?[...t]:[e]})}_getType(){return`COL`}_getActiveElements(){return this.env.model.getters.getActiveCols()}_getPreviousVisibleElement(e){let t=this.sheetId,n;for(n=e-1;n>=0&&this.env.model.getters.isColHidden(t,n);n--);return n}unhide(e){this.env.model.dispatch(`UNHIDE_COLUMNS_ROWS`,{sheetId:this.sheetId,elements:e,dimension:`COL`})}get mainUnhideHeadersProps(){let{left:e,right:t}=this.viewStore.activeMainViewport,{xSplit:n}=this.env.model.getters.getPaneDivisions(this.sheetId),r=this.env.model.getters.getHiddenColsGroups(this.sheetId),i=r.findIndex(e=>e[0]>=n-1);return{headersGroups:i===-1?[]:r.slice(i),offset:this.viewStore.mainViewportCoordinates.x,headerRange:{start:e,end:t}}}get frozenUnhideHeadersProps(){let{xSplit:e}=this.env.model.getters.getPaneDivisions(this.sheetId),t=this.env.model.getters.getHiddenColsGroups(this.sheetId),n=t.findIndex(t=>t[0]>=e-1);return{headersGroups:n===-1?t:t.slice(0,n+1),headerRange:{start:0,end:e-1}}}get frozenContainerStyle(){return G({width:this.viewStore.mainViewportCoordinates.x+`px`})}get hasFrozenPane(){return this.env.model.getters.getPaneDivisions(this.sheetId).xSplit>0}},BN=class extends RN{static template=`o-spreadsheet-RowResizer`;static components={UnhideRowHeaders:FN};rowResizerRef=t.signal.ref();setup(){super.setup(),this.PADDING=5,this.MAX_SIZE_MARGIN=60,this.MIN_ELEMENT_SIZE=10}get sheetId(){return this.env.model.getters.getActiveSheetId()}_getEvOffset(e){return e.offsetY}_getViewportOffset(){return this.viewStore.activeMainViewport.top}_getClientPosition(e){return e.clientY}_getElementIndex(e){return this.viewStore.viewports.getRowIndex(this.sheetId,e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().top}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().bottom}_getEdgeScroll(e){return this.viewStore.viewports.getEdgeScrollRow(this.sheetId,e,e,e)}_getDimensionsInViewport(e){return this.viewStore.viewports.getRowDimensionsInViewport(this.sheetId,e)}_getElementSize(e){return this.env.model.getters.getRowSize(this.sheetId,e)}_getMaxSize(){return this.rowResizerRef()?.clientHeight??0}_updateSize(){let e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),n=this.env.model.getters.getActiveRows();this.env.model.dispatch(`RESIZE_COLUMNS_ROWS`,{dimension:`ROW`,sheetId:this.sheetId,elements:n.has(e)?[...n]:[e],size:t})}_moveElements(){let e=[],t=this._getSelectedZoneStart(),n=this._getSelectedZoneEnd();for(let r=t;r<=n;r++)e.push(r);let r=this.env.model.dispatch(`MOVE_COLUMNS_ROWS`,{sheetId:this.sheetId,sheetName:this.env.model.getters.getActiveSheetName(),dimension:`ROW`,base:this.state.base,elements:e,position:this.state.position});r.isSuccessful||(r.reasons.includes(`WillRemoveExistingMerge`)?this.env.raiseError(hT):r.reasons.includes(`CannotMoveTableHeader`)&&this.env.raiseError(gT))}_selectElement(e,t){this.env.model.selection.selectRow(e,t?`newAnchor`:`overrideSelection`)}_increaseSelection(e){this.env.model.selection.selectRow(e,`updateAnchor`)}_fitElementSize(e){let t=this.env.model.getters.getActiveRows();this.env.model.dispatch(`AUTORESIZE_ROWS`,{sheetId:this.sheetId,rows:t.has(e)?[...t]:[e]})}_getType(){return`ROW`}_getActiveElements(){return this.env.model.getters.getActiveRows()}_getPreviousVisibleElement(e){let t=this.sheetId,n;for(n=e-1;n>=0&&this.env.model.getters.isRowHidden(t,n);n--);return n}get mainUnhideHeadersProps(){let{top:e,bottom:t}=this.viewStore.activeMainViewport,{ySplit:n}=this.env.model.getters.getPaneDivisions(this.sheetId),r=this.env.model.getters.getHiddenRowsGroups(this.sheetId),i=r.findIndex(e=>e[0]>=n-1);return{headersGroups:i===-1?[]:r.slice(i),offset:this.viewStore.mainViewportCoordinates.y,headerRange:{start:e,end:t}}}get frozenUnhideHeadersProps(){let{ySplit:e}=this.env.model.getters.getPaneDivisions(this.sheetId),t=this.env.model.getters.getHiddenRowsGroups(this.sheetId),n=t.findIndex(t=>t[0]>=e-1);return{headersGroups:n===-1?t:t.slice(0,n+1),headerRange:{start:0,end:e-1}}}get frozenContainerStyle(){return G({height:this.viewStore.mainViewportCoordinates.y+`px`})}get hasFrozenPane(){return this.env.model.getters.getPaneDivisions(this.sheetId).ySplit>0}},VN=class extends k{static template=`o-spreadsheet-HeadersOverlay`;props=(0,t.useProps)(LN);static components={ColResizer:zN,RowResizer:BN};selectAll(){this.env.model.selection.selectAll()}};let HN=.95;function UN(e,{updateScroll:n,canMoveUp:r,canMoveDown:i,getZoom:a,setZoom:o}){let s=0,c=0,l=0,u=0,d=!1,f=0,p=null,m=!1,h=[],g=-1;(0,t.useListener)(e,`touchstart`,_,{capture:!1}),(0,t.useListener)(e,`touchmove`,v,{capture:!1}),(0,t.useListener)(e,`touchend`,ee,{capture:!1}),(0,t.useListener)(e,`pointerdown`,b,{passive:!1,capture:!1}),(0,t.useListener)(e,`pointermove`,ne,{passive:!1,capture:!1}),(0,t.useListener)(window,`pointerup`,te,{passive:!1,capture:!0}),(0,t.useListener)(e,`pointercancel`,te,{passive:!1});function _(e){d=!0,{clientX:s,clientY:c}=e.touches[0],l=0,u=0}function v(e){if(!d||m){e.cancelable&&e.preventDefault(),e.stopPropagation();return}p&&=(clearTimeout(p),null);let t=Date.now(),{clientX:a,clientY:o}=e.touches[0],h=s-a,g=c-o,_=t-f;_&&(l=h/_,u=g/_,s=a,c=o,f=t,(g<0&&r()||g>0&&i())&&(e.cancelable&&e.preventDefault(),e.stopPropagation()),p=setTimeout(()=>{l=0,u=0},100),n(h*1,g*1))}function ee(e){d=!1,s=c=0,p&&clearTimeout(p),l*=1.2,u*=1.2,requestAnimationFrame(y)}function y(){if(Math.abs(l)<.05&&(l=0),Math.abs(u)<.05&&(u=0),!l&&!u)return;let e=Date.now(),t=Math.abs(e-f),r=l*t,i=u*t;n(r*1,i*1),f=e,l*=HN,u*=HN,requestAnimationFrame(y)}function b(e){e.button===0&&h.findIndex(t=>t.pointerId===e.pointerId)===-1&&(h.push(e),h.length<2?g=-1/0:h.length===2&&(g=WN(h[0],h[1])))}function te(e){let t=h.findIndex(t=>t.pointerId===e.pointerId);t!==-1&&(h.splice(t,1),h.length<2&&(g=-1/0,m=!1))}function ne(e){let t=h.findIndex(t=>t.pointerId===e.pointerId);if(t!==-1&&(h[t]=e,h.length===2)){let e=WN(h[0],h[1]);if(!m&&Math.abs(e-g)>=30&&(m=!0,g=e),m){let t=(e/g)**.5;o(Math.round(a()*t*1e3)/1e3),g=e}}}}function WN(e,t){let n=e.clientX-t.clientX,r=e.clientY-t.clientY;return Math.sqrt(n*n+r*r)}var GN=class extends k{static template=`o-spreadsheet-Border`;props=(0,t.useProps)({zone:M.Zone(),orientation:M.or([M.literal(`n`),M.literal(`s`),M.literal(`w`),M.literal(`e`)]),isMoving:M.boolean(),onMoveHighlight:M.function()});viewStore;setup(){this.viewStore=A(W)}get style(){let e=[`n`,`w`,`e`].includes(this.props.orientation),t=[`n`,`w`,`s`].includes(this.props.orientation),n=[`n`,`s`].includes(this.props.orientation),r=[`w`,`e`].includes(this.props.orientation),i=this.props.zone,a=this.viewStore.viewports.getVisibleRect(this.env.model.getters.getActiveSheetId(),i),o=a.x,s=a.x+a.width-4,c=a.y,l=a.y+a.height-4,u=t?o:s,d=e?c:l,f=n?s-o:4,p=r?l-c:4;return G({left:`${u}px`,top:`${d}px`,width:`${f}px`,height:`${p}px`})}onMouseDown(e){this.props.onMoveHighlight(e)}},KN=class extends k{static template=`o-spreadsheet-Corner`;props=(0,t.useProps)({zone:M.Zone(),color:M.Color(),orientation:M.or([M.literal(`nw`),M.literal(`ne`),M.literal(`sw`),M.literal(`se`),M.literal(`n`),M.literal(`s`),M.literal(`e`),M.literal(`w`)]),isResizing:M.boolean(),onResizeHighlight:M.function()});dirX;dirY;viewStore;setup(){this.viewStore=A(W);let{dirX:e,dirY:t}=qN(this.props.orientation);this.dirX=e,this.dirY=t}get handlerStyle(){let e=this.props.zone,t=this.viewStore.viewports.getVisibleRect(this.env.model.getters.getActiveSheetId(),{left:this.dirX===1?e.right:e.left,right:this.dirX===-1?e.left:e.right,top:this.dirY===1?e.bottom:e.top,bottom:this.dirY===-1?e.top:e.bottom});if(t.width*t.height===0)return`display: none !important;`;let n=t.x+t.width/2+this.dirX*t.width/2,r=t.y+t.height/2+this.dirY*t.height/2,i=this.getHandlerEdgeLength(),a={left:`${n-i/2}px`,top:`${r-i/2}px`,height:`${i}px`,width:`${i}px`};return this.env.isMobile()&&(a[`border-radius`]=`${i/2}px`),G(a)}getHandlerEdgeLength(){return this.env.isMobile()?40:8}get buttonLook(){let e={"background-color":this.props.color,cursor:`${this.props.orientation}-resize`};return this.env.isMobile()&&(e[`border-radius`]=`${8/2}px`),G(e)}onMouseDown(e){this.props.onResizeHighlight(e,this.dirX,this.dirY)}};function qN(e){return{dirX:e.includes(`w`)?-1:+!!e.includes(`e`),dirY:e.includes(`n`)?-1:+!!e.includes(`s`)}}var JN=class extends k{static template=`o-spreadsheet-Highlight`;static components={Corner:KN,Border:GN};props=(0,t.useProps)({range:M.Range(),color:M.Color()});highlightState=(0,t.proxy)({shiftingMode:`none`});dragNDropGrid=Jj(this.env);viewStore;zoomStore;setup(){this.viewStore=A(W),this.zoomStore=A(Rg)}get cornerOrientations(){if(!this.env.isMobile())return[`nw`,`ne`,`sw`,`se`];let e=this.props.range.unboundedZone;return e.bottom===void 0?[`w`,`e`]:e.right===void 0?[`n`,`s`]:[`nw`,`se`]}onResizeHighlight(e,t,n){let r=this.env.model.getters.getActiveSheetId(),i=this.zoomStore.getZoomedEvent(e);this.highlightState.shiftingMode=`isResizing`;let a=this.props.range.zone,o=t===1?a.left:a.right,s=n===1?a.top:a.bottom,c=t===1?a.right:a.left,l=n===1?a.bottom:a.top,u=a,d=`all`;this.env.isMobile()&&(d=t===0?`vertical`:n===0?`horizontal`:`all`),this.env.model.dispatch(`START_CHANGE_HIGHLIGHT`,{zone:u}),this.dragNDropGrid.start(i,(e,t)=>{if(c!==e||l!==t){let{left:n,right:i,top:a,bottom:f}=u;d!==`horizontal`&&(l=l=S(t===-1?l:t,0,this.env.model.getters.getNumberRows(r)-1),a=Math.min(s,l),f=Math.max(s,l)),d!==`vertical`&&(c=S(e===-1?c:e,0,this.env.model.getters.getNumberCols(r)-1),n=Math.min(o,c),i=Math.max(o,c));let p={left:n,right:i,top:a,bottom:f};mr(p,u)||(this.env.model.selection.selectZone({cell:{col:p.left,row:p.top},zone:p},{unbounded:!0}),u=p)}},()=>{this.highlightState.shiftingMode=`none`},d)}onMoveHighlight(e){this.highlightState.shiftingMode=`isMoving`;let t=this.props.range.zone,n=this.zoomStore.zoomLevel,r=v(n),i=this.zoomStore.getZoomedEvent(e,r),a=this.env.model.getters.getActiveSheetId(),o=this.viewStore.viewports.getColIndex(a,i.clientX-r.x),s=this.viewStore.viewports.getRowIndex(a,i.clientY-r.y),c=-t.left,l=this.env.model.getters.getNumberCols(a)-t.right-1,u=-t.top,d=this.env.model.getters.getNumberRows(a)-t.bottom-1,f=t;this.env.model.dispatch(`START_CHANGE_HIGHLIGHT`,{zone:f});let p=o,m=s;this.dragNDropGrid.start(i,(e,n)=>{if(p!==e||m!==n){p=e===-1?p:e,m=n===-1?m:n;let r=S(p-o,c,l),i=S(m-s,u,d),a={left:t.left+r,top:t.top+i,right:t.right+r,bottom:t.bottom+i};mr(a,f)||(this.env.model.selection.selectZone({cell:{col:a.left,row:a.top},zone:a},{unbounded:!0}),f=a)}},()=>{this.highlightState.shiftingMode=`none`})}},YN=class extends k{static components={ScrollBar:KE};viewStore;zoomStore;static template=t.xml`
68
68
  <ScrollBar
69
69
  t-if="this.isDisplayed"
70
70
  width="this.width"
@@ -72,7 +72,7 @@ You can download it directly instead.`,5),sticky:!1,type:`warning`});return}r=aw
72
72
  offset="this.offset"
73
73
  direction="'horizontal'"
74
74
  onScroll.bind="this.onScroll"
75
- />`;setup(){this.viewStore=A(W),this.zoomStore=A(Rg)}props=(0,t.useProps)({leftOffset:M.number().optional(0)});get offset(){return this.viewStore.viewports.getSheetScrollInfo(this.viewStore.displayedSheetId).scrollX}get width(){return this.viewStore.viewports.getMainViewportRect(this.viewStore.displayedSheetId).width}get isDisplayed(){let{xRatio:e}=this.viewStore.viewports.getFrozenSheetViewRatio(this.viewStore.displayedSheetId);return e<1}get position(){let{x:e}=this.viewStore.viewports.getMainViewportRect(this.viewStore.displayedSheetId),t=this.zoomStore.scrollBarWidth;return{left:`${this.props.leftOffset+e}px`,bottom:`0px`,height:`${t}px`,right:`${t}px`}}onScroll(e){let{scrollY:t}=this.viewStore.viewports.getSheetScrollInfo(this.viewStore.displayedSheetId);this.viewStore.setViewportOffset({offsetX:e,offsetY:t})}},XN=class extends k{static template=`o-spreadsheet-Selection`;static components={Highlight:JN};get highlightProps(){let e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getUnboundedZone(e,this.env.model.getters.getSelectedZone());return{range:this.env.model.getters.getRangeFromZone(e,t),color:je}}},ZN=class extends ei{canResizeTable(e){let t=this.getters.getCoreTableMatchingTopLeft(e.sheetId,e.zone);if(!t)return new Jd([`TableNotFound`]);let n=t.range.zone,r=this.getters.getRangeFromRangeData(e.newTableRange).zone;return r.top!==n.top||r.left!==n.left?new Jd([`InvalidTableResize`]):this.model.canDispatch(`UPDATE_TABLE`,{...e})}handle(e){switch(e.type){case`RESIZE_TABLE`:{if(!this.canResizeTable(e).isSuccessful)return;let t=this.getters.getCoreTableMatchingTopLeft(e.sheetId,e.zone);if(this.model.dispatch(`UPDATE_TABLE`,{...e}),!t)return;let n=this.getters.getRangeFromRangeData(e.newTableRange).zone;if(this.model.selection.selectCell(n.right,n.bottom),!t.config.automaticAutofill)return;let r=t.range.zone;if(n.bottom>=r.bottom){for(let t=n.left;t<=n.right;t++){let i={col:t,row:r.bottom,sheetId:e.sheetId};this.getters.getCell(i)?.isFormula&&this.model.dispatch(`AUTOFILL_TABLE_COLUMN`,{...i,autofillRowStart:r.bottom,autofillRowEnd:n.bottom})}break}}}}};function QN(e){let n=(0,t.proxy)({hovered:!1});(0,t.useListener)(e,`mouseenter`,()=>n.hovered=!0),(0,t.useListener)(e,`mouseleave`,()=>n.hovered=!1);let r=new ResizeObserver(()=>{n.hovered=!1});return(0,t.useEffect)(()=>{let t=e();return t&&r.observe(t),()=>{r.disconnect()}}),n}function $N(e,t){let n=QN(e);eP({get highlights(){return n.hovered?t.highlights:[]}})}function eP(e){let n=Yi(),r=Zi(DE);(0,t.onMounted)(()=>{r.register(e)});let i=e.highlights;Vi(e=>{T(e,i)||(i=e,n.trigger(`store-updated`))},()=>[e.highlights])}var tP=class extends k{static template=`o-spreadsheet-TableResizer`;props=(0,t.useProps)({table:M.Table()});state=(0,t.proxy)({highlightZone:void 0});dragNDropGrid=Jj(this.env);viewStore;zoomStore;setup(){eP(this),this.viewStore=A(W),A(ZN),this.zoomStore=A(Rg)}get containerStyle(){let e=this.props.table.range.sheetId,t=this.props.table.range.zone,n={...t,left:t.right,top:t.bottom},r=this.viewStore.viewports.getVisibleRect(e,n);return r.height===0||r.width===0?G({display:`none`}):G({top:`${r.y+r.height-6}px`,left:`${r.x+r.width-6}px`})}onMouseDown(e){let t=this.props.table.range.zone,n={col:t.left,row:t.top};document.body.style.cursor=`nwse-resize`;let r=this.zoomStore.getZoomedEvent(e);this.dragNDropGrid.start(r,(e,t,r)=>{this.state.highlightZone={left:n.col,top:n.row,right:Math.max(e,n.col),bottom:Math.max(t,n.row)}},()=>{document.body.style.cursor=``;let e=this.state.highlightZone;if(!e)return;let t=this.props.table.range.sheetId;this.env.model.dispatch(`RESIZE_TABLE`,{sheetId:t,zone:this.props.table.range.zone,newTableRange:this.env.model.getters.getRangeDataFromZone(t,e)}),this.state.highlightZone=void 0})}get highlights(){return this.state.highlightZone?[{range:this.env.model.getters.getRangeFromZone(this.props.table.range.sheetId,this.state.highlightZone),color:`#777`,noFill:!0}]:[]}};let nP={ROW:Uj,COL:Ij,CELL:AA,GROUP_HEADERS:Vj,UNGROUP_HEADERS:Hj};var rP=class extends k{static template=`o-spreadsheet-Grid`;static components={GridComposer:_N,GridOverlay:PE,GridPopover:FE,HeaderResizeEditor:PN,HeadersOverlay:VN,MenuPopover:zw,Autofill:dM,ClientTag:pM,Highlight:JN,Popover:Fw,VerticalScrollBar:qE,HorizontalScrollBar:YN,TableResizer:tP,Selection:XN,FiguresContainer:NN};props=(0,t.useProps)({exposeFocus:M.function(),getGridSize:M.function()});HEADER_HEIGHT=26;HEADER_WIDTH=48;menuState;headerResizeEditorTarget=(0,t.signal)(null);gridRef=t.signal.ref();canvasRef=t.signal.ref(HTMLCanvasElement);highlightStore;viewStore;zoomStore;cellPopovers;composerFocusStore;DOMFocusableElementStore;paintFormatStore;clientFocusStore;checkboxToggleStore;clipboardStore;dragNDropGrid=Jj(this.env);onMouseWheel;hoveredCell;sidePanel;automaticSumStore;setup(){this.highlightStore=A(DE),this.viewStore=A(W),this.zoomStore=A(Rg),this.menuState=(0,t.proxy)({isOpen:!1,anchorRect:null,menuItems:[]}),this.hoveredCell=A(CE),this.composerFocusStore=A(ni),this.DOMFocusableElementStore=A(Ow),this.sidePanel=A(U),this.paintFormatStore=A(kE),this.clientFocusStore=A(qj),this.checkboxToggleStore=A(Kj),A(Wj),this.automaticSumStore=Zi(Gj),this.clipboardStore=A(aw),(0,t.providePlugins)([Mw],{getPopoverContainerRect:()=>this.getGridRect()}),(0,t.useListener)(document.body,`cut`,this.copy.bind(this,!0)),(0,t.useListener)(document.body,`copy`,this.copy.bind(this,!1)),(0,t.useListener)(document.body,`paste`,this.paste.bind(this)),(0,t.onMounted)(()=>this.focusDefaultElement()),this.props.exposeFocus(()=>this.focusDefaultElement()),UE({canvasRef:this.canvasRef,renderingCtx:()=>({dpr:window.devicePixelRatio||1,viewports:this.viewStore.viewports,...this.env.model.getters.getSelectionState()})}),this.onMouseWheel=WE((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.clear()}),this.cellPopovers=A(jE),Vi((e,t)=>{!e&&!t&&this.DOMFocusableElementStore.focus()},()=>[this.sidePanel.isMainPanelOpen,this.sidePanel.isSecondaryPanelOpen]),UN(this.gridRef,{updateScroll:this.moveCanvas.bind(this),canMoveUp:()=>{let{scrollY:e}=this.viewStore.activeSheetScrollInfo;return e>0},canMoveDown:()=>{let{maxOffsetY:e}=this.viewStore.maximumSheetOffset,{scrollY:t}=this.viewStore.activeSheetScrollInfo;return t<e},getZoom:()=>this.zoomStore.zoomLevel,setZoom:e=>this.zoomStore.setZoom(e)})}get highlights(){return this.highlightStore.highlights}get gridOverlayDimensions(){let e=this.zoomStore.scrollBarWidth;return G({top:`26px`,left:`48px`,height:`calc(100% - ${26+e}px)`,width:`calc(100% - ${48+e}px)`})}onClosePopover(){this.cellPopovers.isOpen&&this.cellPopovers.close(),this.focusDefaultElement()}keyDownMapping={Enter:()=>this.editOrMoveInSelection(`down`),"Shift+Enter":()=>this.editOrMoveInSelection(`up`),Tab:()=>this.moveInSelection(`right`),"Shift+Tab":()=>this.moveInSelection(`left`),F2:()=>{this.focusComposerFromActiveCell()},Delete:()=>{this.env.model.dispatch(`DELETE_UNFILTERED_CONTENT`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},Backspace:()=>{this.env.model.dispatch(`DELETE_UNFILTERED_CONTENT`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},Escape:()=>{this.cellPopovers.isOpen?this.cellPopovers.close():this.menuState.isOpen?this.closeMenu():this.paintFormatStore.isActive?this.paintFormatStore.cancel():this.env.model.dispatch(`CLEAN_CLIPBOARD_HIGHLIGHT`)},"Ctrl+A":()=>this.env.model.selection.loopSelection(),"Ctrl+Z":()=>this.env.model.dispatch(`REQUEST_UNDO`),"Ctrl+Y":()=>this.env.model.dispatch(`REQUEST_REDO`),F4:()=>this.env.model.dispatch(`REQUEST_REDO`),F9:()=>this.env.model.dispatch(`EVALUATE_CELLS`),"Ctrl+B":()=>this.env.model.dispatch(`SET_FORMATTING`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{bold:!this.env.model.getters.getCurrentStyle().bold}}),"Ctrl+I":()=>this.env.model.dispatch(`SET_FORMATTING`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{italic:!this.env.model.getters.getCurrentStyle().italic}}),"Ctrl+U":()=>this.env.model.dispatch(`SET_FORMATTING`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{underline:!this.env.model.getters.getCurrentStyle().underline}}),"Ctrl+O":()=>QD(this.env),"Alt+=":()=>{let e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZone(),n=this.automaticSumStore.automaticSumsOnMainSelectedZone;if(this.env.model.getters.isSingleCellOrMerge(e,t)||this.env.model.getters.isEmpty(e,t)&&n.length<=1){let t=n[0]?.zone?this.env.model.getters.zoneToXC(e,n[0].zone):``,r=`=SUM(${t})`;this.onComposerCellFocused(r,{start:5,end:5+t.length})}else this.env.model.dispatch(`SUM_SELECTION`)},"Alt+Enter":()=>{let e=this.env.model.getters.getActiveCell();e.link&&rf(e.link,this.env)},"Ctrl+Home":()=>{let e=this.env.model.getters.getActiveSheetId(),{col:t,row:n}=this.env.model.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0});this.env.model.selection.selectCell(t,n)},"Ctrl+End":()=>{let e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.findVisibleHeader(e,`COL`,this.env.model.getters.getNumberCols(e)-1,0),n=this.env.model.getters.findVisibleHeader(e,`ROW`,this.env.model.getters.getNumberRows(e)-1,0);this.env.model.selection.selectCell(t,n)},"Shift+ ":()=>{let e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),left:0,right:this.env.model.getters.getNumberCols(e)-1},n=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:n,zone:t})},"Ctrl+ ":()=>{let e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),top:0,bottom:this.env.model.getters.getNumberRows(e)-1},n=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:n,zone:t})},"Ctrl+D":()=>{iD(this.env,{type:`COPY_PASTE_CELLS_ABOVE`})},"Ctrl+R":()=>{iD(this.env,{type:`COPY_PASTE_CELLS_ON_LEFT`})},"Ctrl+Enter":()=>{iD(this.env,{type:`COPY_PASTE_CELLS_ON_ZONE`})},"Ctrl+H":()=>this.sidePanel.open(`FindAndReplace`,{}),"Ctrl+F":()=>this.sidePanel.open(`FindAndReplace`,{}),"Ctrl+Shift+E":()=>this.setHorizontalAlign(`center`),"Ctrl+Shift+L":()=>this.setHorizontalAlign(`left`),"Ctrl+Shift+R":()=>this.setHorizontalAlign(`right`),"Ctrl+Shift+V":()=>DD(this.env),"Ctrl+Shift+<":()=>this.clearFormatting(),"Ctrl+<":()=>this.clearFormatting(),"Ctrl+Shift+ ":()=>{this.env.model.selection.selectAll()},"Ctrl+Alt+=":()=>{let e=this.env.model.getters.getActiveCols(),t=this.env.model.getters.getActiveRows(),n=this.env.model.getters.getSelectedZones().length===1,r=e.size>0&&n,i=t.size>0&&n;r&&!i?UD(this.env):i&&!r&&VD(this.env)},"Ctrl+Alt+-":()=>{let e=[...this.env.model.getters.getActiveCols()],t=[...this.env.model.getters.getActiveRows()];e.length>0&&t.length===0?this.env.model.dispatch(`REMOVE_COLUMNS_ROWS`,{sheetId:this.env.model.getters.getActiveSheetId(),sheetName:this.env.model.getters.getActiveSheetName(),dimension:`COL`,elements:e}):t.length>0&&e.length===0&&this.env.model.dispatch(`REMOVE_COLUMNS_ROWS`,{sheetId:this.env.model.getters.getActiveSheetId(),sheetName:this.env.model.getters.getActiveSheetName(),dimension:`ROW`,elements:t})},"Shift+PageDown":()=>{this.env.model.dispatch(`ACTIVATE_NEXT_SHEET`)},"Shift+PageUp":()=>{this.env.model.dispatch(`ACTIVATE_PREVIOUS_SHEET`)},"Shift+F11":()=>{KO.execute?.(this.env)},"Alt+T":()=>{NO.execute?.(this.env)},PageDown:()=>this.viewStore.shiftViewportDown(),PageUp:()=>this.viewStore.shiftViewportUp(),"Ctrl+Shift+K":()=>{this.closeMenu(),tO(this.env)},"Alt+Shift+ArrowRight":()=>this.processHeaderGroupingKey(`right`),"Alt+Shift+ArrowLeft":()=>this.processHeaderGroupingKey(`left`),"Alt+Shift+ArrowUp":()=>this.processHeaderGroupingKey(`up`),"Alt+Shift+ArrowDown":()=>this.processHeaderGroupingKey(`down`)};focusComposerFromActiveCell(){this.env.model.getters.getActiveCell().type===`empty`?this.onComposerCellFocused():this.onComposerContentFocused()}editOrMoveInSelection(e){if(this.isSingleCellOrMergeSelection()){this.focusComposerFromActiveCell();return}LM(this.env.model.getters,this.env.model.selection,e)}moveInSelection(e){if(this.isSingleCellOrMergeSelection()){this.env.model.selection.moveAnchorCell(e,1);return}LM(this.env.model.getters,this.env.model.selection,e)}isSingleCellOrMergeSelection(){let e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZone();return this.env.model.getters.isSingleCellOrMerge(e,t)}focusDefaultElement(){!this.env.model.getters.getSelectedFigureIds().length&&this.composerFocusStore.activeComposer.editionMode===`inactive`&&this.DOMFocusableElementStore.focus()}get gridEl(){let e=this.gridRef();if(!e)throw Error(`Grid el is not defined.`);return e}getAutofillPosition(){let e=this.env.model.getters.getSelectedZone(),t=this.viewStore.viewports.getVisibleRect(this.env.model.getters.getActiveSheetId(),e);return{x:t.x+t.width-8/2,y:t.y+t.height-8/2}}get isAutofillVisible(){if(this.env.model.getters.isCurrentSheetLocked())return!1;let e=this.env.model.getters.getSelectedZone(),t=this.viewStore.viewports.getVisibleRect(this.env.model.getters.getActiveSheetId(),{left:e.right,right:e.right,top:e.bottom,bottom:e.bottom});return!(t.width===0||t.height===0)}onGridResized(){let{height:e,width:t}=this.props.getGridSize();this.viewStore.resizeSheetView({height:e-26,width:t-48,gridOffsetX:48,gridOffsetY:26})}moveCanvas(e,t){let{scrollX:n,scrollY:r}=this.viewStore.activeSheetScrollInfo;this.viewStore.setViewportOffset({offsetX:n+e,offsetY:r+t})}processSpaceKey(e){this.checkboxToggleStore.hasBooleanValidationInZones(this.env.model.getters.getSelectedZones())&&(e.preventDefault(),e.stopPropagation(),this.env.model.dispatch(`TOGGLE_CHECKBOX`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()}))}getClientPositionKey(e){return`${e.id}-${e.position?.sheetId}-${e.position?.col}-${e.position?.row}`}isCellHovered(e,t){return this.hoveredCell.col===e&&this.hoveredCell.row===t}get focusedClients(){return this.clientFocusStore.focusedClients}getGridRect(){let e=this.zoomStore.zoomLevel,{width:t,height:n}=this.viewStore.sheetViewDimensionWithHeaders;return{...y(this.gridRef()),width:t*e,height:n*e}}onCellClicked(e,t,n,r){if(r.ev.preventDefault(),this.composerFocusStore.activeComposer.editionMode===`editing`&&this.composerFocusStore.activeComposer.stopEdition(),n.expandZone?this.env.model.selection.setAnchorCorner(e,t):n.addZone?this.env.model.selection.addCellToSelection(e,t):this.env.model.selection.selectCell(e,t),this.env.isMobile())return;let i=e,a=t;this.dragNDropGrid.start(r,(e,t,n)=>{n.preventDefault(),(e!==i&&e!==-1||t!==a&&t!==-1)&&(i=e===-1?i:e,a=t===-1?a:t,this.env.model.selection.setAnchorCorner(i,a))},()=>{this.env.model.selection.commitSelection(),this.paintFormatStore.isActive&&this.paintFormatStore.pasteFormat(this.env.model.getters.getSelectedZones())})}onCellDoubleClicked(e,t){let n=this.env.model.getters.getActiveSheetId();({col:e,row:t}=this.env.model.getters.getMainCellPosition({sheetId:n,col:e,row:t})),this.env.model.getters.getEvaluatedCell({sheetId:n,col:e,row:t}).type===`empty`?this.onComposerCellFocused():this.onComposerContentFocused()}processArrows(e){e.preventDefault(),e.stopPropagation(),this.cellPopovers.isOpen&&this.cellPopovers.close(),IM(e,this.env.model.selection),this.paintFormatStore.isActive&&this.paintFormatStore.pasteFormat(this.env.model.getters.getSelectedZones())}onKeydown(e){let t=ce(e),n=this.keyDownMapping[t];if(n){e.preventDefault(),e.stopPropagation(),n();return}if(t===` `){this.processSpaceKey(e);return}if(e.key.startsWith(`Arrow`)){this.processArrows(e);return}}onInputContextMenu(e){e.preventDefault();let t=this.env.model.getters.getActivePosition(),{col:n,row:r,sheetId:i}=t,a=`CELL`;this.composerFocusStore.activeComposer.stopEdition(),this.env.model.getters.getActiveCols().has(n)?a=`COL`:this.env.model.getters.getActiveRows().has(r)&&(a=`ROW`);let o=D(t),s=this.env.model.getters.getSheetZone(i);a===`COL`?o={...s,left:n,right:n}:a===`ROW`&&(o={...s,top:r,bottom:r});let{x:c,y:l}=this.viewStore.viewports.getVisibleRectWithZoom(i,o),u=this.getGridRect();this.toggleContextMenu(a,u.x+c,u.y+l)}onCellRightClicked(e,t,{x:n,y:r}){let i=this.env.model.getters.getSelectedZones(),a=i[i.length-1],o=`CELL`;_r(e,t,a)?this.env.model.getters.getActiveCols().has(e)?o=`COL`:this.env.model.getters.getActiveRows().has(t)&&(o=`ROW`):(this.env.model.selection.getBackToDefault(),this.env.model.selection.selectCell(e,t)),this.toggleContextMenu(o,n,r)}getMenuItems(e,t,n){let r=nP[e].getMenuItems(),i=e===`COL`?t:e===`ROW`?n:-1;if(i===-1)return r;let a=e===`COL`,o=r.find(({id:e})=>e===(a?`unhide_columns`:`unhide_rows`));if(!o)throw Error(`Missing unhide action in the header menu`);return r.push(we({id:a?`resize_columns`:`resize_rows`,name:N(a?`Resize column`:`Resize row`),sequence:o.sequence+1,separator:!0,icon:a?`o-spreadsheet-Icon.RESIZE_HORIZONTAL`:`o-spreadsheet-Icon.RESIZE_VERTICAL`,children:[{name:N(`Fit to data`),execute:e=>{let t=e.model.getters.getActiveSheetId();return a?e.model.dispatch(`AUTORESIZE_COLUMNS`,{sheetId:t,cols:[...e.model.getters.getActiveCols()]}):e.model.dispatch(`AUTORESIZE_ROWS`,{sheetId:t,rows:[...e.model.getters.getActiveRows()]})}},{name:N(`Custom size`),execute:()=>this.headerResizeEditorTarget.set({dimension:a?`COL`:`ROW`,index:i})}]})),r.sort((e,t)=>e.sequence-t.sequence)}toggleContextMenu(e,t,n){this.cellPopovers.isOpen&&this.cellPopovers.close();let r=this.getGridRect(),i=this.zoomStore.zoomLevel,a=this.viewStore.gridOffset,[o,s]=this.viewStore.getCartesianCoordinates((t-r.x)/i-a.x,(n-r.y)/i-a.y);this.menuState.isOpen=!0,this.menuState.anchorRect={x:t,y:n,width:0,height:0},this.menuState.menuItems=this.getMenuItems(e,o,s)}async copy(e,t){if(!this.gridEl.contains(document.activeElement)||this.composerFocusStore.activeComposer.editionMode!==`inactive`)return;e?Fk(this.env):this.env.model.dispatch(`COPY`);let n=await this.clipboardStore.getClipboardTextAndImageContent();await this.env.clipboard.write(n),t.preventDefault()}async paste(e){if(!this.gridEl.contains(document.activeElement))return;e.preventDefault();let t=e.clipboardData;if(!t)return;let n=[...t.files].find(e=>L_.includes(e.type)),r={content:{"text/plain":t?.getData(`text/plain`),"text/html":t?.getData(`text/html`)}};n&&(r.content[n.type]=n);let i=this.env.model.getters.getSelectedZones(),a=this.clipboardStore.isCutOperation();if(this.clipboardStore.getClipboardId()===H_(r.content[`text/html`]))sD(this.env,i);else{let e=V_(r.content);await cD(this.env,i,e)}a&&await this.env.clipboard.write({"text/plain":``})}clearFormatting(){this.env.model.dispatch(`CLEAR_FORMATTING`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}setHorizontalAlign(e){this.env.model.dispatch(`SET_FORMATTING`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{align:e}})}closeMenu(){this.menuState.isOpen=!1,this.focusDefaultElement()}processHeaderGroupingKey(e){if(this.env.model.getters.getSelectedZones().length!==1)return;let t=this.env.model.getters.getActiveRows().size>0,n=this.env.model.getters.getActiveCols().size>0;n&&t?this.processHeaderGroupingEventOnWholeSheet(e):n?this.processHeaderGroupingEventOnHeaders(e,`COL`):t?this.processHeaderGroupingEventOnHeaders(e,`ROW`):this.processHeaderGroupingEventOnGrid(e)}processHeaderGroupingEventOnHeaders(e,t){let n=this.env.model.getters.getActiveSheetId(),r=this.env.model.getters.getSelectedZone(),i=t===`COL`?r.left:r.top,a=t===`COL`?r.right:r.bottom;switch(e){case`right`:this.env.model.dispatch(`GROUP_HEADERS`,{sheetId:n,dimension:t,start:i,end:a});break;case`left`:this.env.model.dispatch(`UNGROUP_HEADERS`,{sheetId:n,dimension:t,start:i,end:a});break;case`down`:this.env.model.dispatch(`UNFOLD_HEADER_GROUPS_IN_ZONE`,{sheetId:n,dimension:t,zone:r});break;case`up`:this.env.model.dispatch(`FOLD_HEADER_GROUPS_IN_ZONE`,{sheetId:n,dimension:t,zone:r});break}}processHeaderGroupingEventOnWholeSheet(e){let t=this.env.model.getters.getActiveSheetId();e===`up`?(this.env.model.dispatch(`FOLD_ALL_HEADER_GROUPS`,{sheetId:t,dimension:`ROW`}),this.env.model.dispatch(`FOLD_ALL_HEADER_GROUPS`,{sheetId:t,dimension:`COL`})):e===`down`&&(this.env.model.dispatch(`UNFOLD_ALL_HEADER_GROUPS`,{sheetId:t,dimension:`ROW`}),this.env.model.dispatch(`UNFOLD_ALL_HEADER_GROUPS`,{sheetId:t,dimension:`COL`}))}processHeaderGroupingEventOnGrid(e){let t=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getSelectedZone();switch(e){case`down`:this.env.model.dispatch(`UNFOLD_HEADER_GROUPS_IN_ZONE`,{sheetId:t,dimension:`ROW`,zone:n}),this.env.model.dispatch(`UNFOLD_HEADER_GROUPS_IN_ZONE`,{sheetId:t,dimension:`COL`,zone:n});break;case`up`:this.env.model.dispatch(`FOLD_HEADER_GROUPS_IN_ZONE`,{sheetId:t,dimension:`ROW`,zone:n}),this.env.model.dispatch(`FOLD_HEADER_GROUPS_IN_ZONE`,{sheetId:t,dimension:`COL`,zone:n});break;case`right`:{let{x:e,y:r,width:i}=this.viewStore.viewports.getVisibleRectWithZoom(t,n),a=this.getGridRect();this.toggleContextMenu(`GROUP_HEADERS`,e+i+a.x,r+a.y);break}case`left`:{if(!Ck(this.env,`COL`)&&!Ck(this.env,`ROW`))return;let{x:e,y:r,width:i}=this.viewStore.viewports.getVisibleRectWithZoom(t,n),a=this.getGridRect();this.toggleContextMenu(`UNGROUP_HEADERS`,e+i+a.x,r+a.y);break}}}onComposerCellFocused(e,t){this.composerFocusStore.focusActiveComposer({content:e,selection:t,focusMode:`cellFocus`})}onComposerContentFocused(){this.composerFocusStore.focusActiveComposer({focusMode:`contentFocus`})}get staticTables(){let e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getCoreTables(e).filter(kk)}get displaySelectionHandler(){return this.env.isMobile()&&this.composerFocusStore.activeComposer.editionMode===`inactive`}get clientsToDisplay(){let e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getClientsToDisplay(e)}get displayTableResizer(){return this.env.model.getters.isGridSelectionActive()&&!this.env.model.getters.isReadonly()&&!this.env.model.getters.isSheetLocked(this.env.model.getters.getActiveSheetId())}};function iP(){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 cP(a.scrollableContainerEl):new sP(a.scrollableContainerEl);e=new aP({...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 aP=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`),G(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()}},oP=class{el;constructor(e){this.el=e}get containerRect(){return this.el.getBoundingClientRect()}},sP=class extends oP{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}},cP=class extends oP{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}},lP=class{mutators=[`focus`,`unfocus`];focusedElement=null;focus(e){this.focusedElement=e}unfocus(e){this.focusedElement&&this.focusedElement===e&&(this.focusedElement=null)}},uP=class extends ei{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(lP);highlightStore=this.get(DE);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,D({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}=wl(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 mr(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 pp(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 pp(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}=wl(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}=wl(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`}},dP=class extends k{static template=`o-spreadsheet-SelectionInput`;props=(0,t.useProps)({ranges:M.array(M.string()),hasSingleRange:M.boolean().optional(),required:M.boolean().optional(),autofocus:M.boolean().optional(),isInvalid:M.boolean().optional(),class:M.string().optional(),onSelectionChanged:M.function().optional(),onSelectionConfirmed:M.function().optional(),onSelectionReordered:M.function().optional(),onSelectionRemoved:M.function().optional(),onInputFocused:M.function().optional(),colors:M.ArrayOf().optional([]),disabledRanges:M.array(M.boolean()).optional([]),disabledRangeTitle:M.string().optional()});state=(0,t.proxy)({isMissing:!1});dragAndDrop=iP();focusedInputRef=t.signal.ref(HTMLInputElement);unfocusedInputRef=t.signal.ref(HTMLInputElement);selectionRef=t.signal.ref();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=A(Ow),this.store=Zi(uP,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()}),Vi(()=>{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`),G(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(),IM(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?.()}},fP=class extends k{static template=`o-spreadsheet.Checkbox`;props=(0,t.useProps)({label:M.string().optional(),value:M.boolean().optional(!1),className:M.string().optional(),name:M.string().optional(),title:M.string().optional(),disabled:M.boolean().optional(),onChange:M.function()});onChange(e){let t=e.target.checked;this.props.onChange(t)}},Q=class extends k{static template=`o_spreadsheet.Section`;props=(0,t.useProps)({class:M.string().optional(),title:M.string().optional(),slots:M.object()})};let pP={chartId:M.UID(),definition:M.object({}),canUpdateChart:M.function(),updateChart:M.function()},mP=new O;var hP=class extends k{static template=`o-spreadsheet.ChartDataSeries`;static components={SelectionInput:dP,Section:Q};props=(0,t.useProps)({ranges:M.ArrayOf(),dataSetStyles:M.DataSetStyle().optional(),hasSingleRange:M.boolean().optional(),onSelectionChanged:M.function(),onSelectionReordered:M.function().optional(),onSelectionRemoved:M.function().optional(),onSelectionConfirmed:M.function(),maxNumberOfUsedRanges:M.number().optional(),title:M.string().optional(),datasetOrientation:M.or([M.literal(`rows`),M.literal(`columns`)]).optional(),canChangeDatasetOrientation:M.boolean().optional(),onFlipAxis:M.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?N(`Data range`):N(`Data series`)}},gP=class extends k{static template=`o-spreadsheet.ChartLabelRange`;static components={SelectionInput:dP,Checkbox:fP,Section:Q};props=(0,t.useProps)({title:M.string().optional(N(`Categories / Labels`)),range:M.string(),class:M.string().optional(),isInvalid:M.boolean(),onSelectionChanged:M.function(),onSelectionConfirmed:M.function(),options:M.ArrayOf().optional([])});get sectionClass(){return`o-data-labels`+(this.props.class?` ${this.props.class}`:``)}},_P=class extends k{static template=`o-spreadsheet-ChartDataSourceComponent`;static components={ChartDataSeries:hP,ChartLabelRange:gP};props=(0,t.useProps)({chartId:M.UID(),definition:M.ChartDefinitionWithDataSource(),updateChart:M.function(),canUpdateChart:M.function(),dataSeriesTitle:M.string().optional(),labelRangeTitle:M.string().optional(),getLabelRangeOptions:M.function().optional()});get DataSourceComponent(){let e=this.props.definition.dataSource.type;return mP.get(e)}},vP=class extends k{static template=`o-spreadsheet.ChartErrorSection`;static components={Section:Q,ValidationMessages:wE};props=(0,t.useProps)({messages:M.array(M.string())})},yP=class extends k{static template=`o-spreadsheet-GenericChartConfigPanel`;static components={ChartDataSourceComponent:_P,Section:Q,Checkbox:fP,ChartErrorSection:vP};props=(0,t.useProps)(pP);chartTerms=pT;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})}}}},bP=class extends yP{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()]}};function xP(e){(0,t.useEffect)(()=>e()?.focus())}let SP={value:M.or([M.number(),M.string()]),onChange:M.function(),onFocused:M.function().optional(),onBlur:M.function().optional(),onInput:M.function().optional(),class:M.string().optional(),id:M.string().optional(),placeholder:M.string().optional(),autofocus:M.boolean().optional(),alwaysShowBorder:M.boolean().optional(),selectContentOnFocus:M.boolean().optional(),resetOnBlur:M.boolean().optional()};var CP=class extends k{props=(0,t.useProps)(SP);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&&xP(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)}},wP=class extends CP{static template=`o-spreadsheet-TextInput`;static components={};props=(0,t.useProps)({...SP,value:M.string(),errorMessage:M.string().optional(),maxLength:M.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(` `)}},TP=class extends k{static template=`o-spreadsheet-ActionButton`;props=(0,t.useProps)({action:M.ActionSpec(),hasTriangleDownIcon:M.boolean().optional(),selectedColor:M.string().optional(),class:M.string().optional(),onClick:M.function().optional()});actionButton=we(this.props.action);setup(){(0,t.onWillUpdateProps)(e=>{e.action!==this.props.action&&(this.actionButton=we(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)||xe(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?G({"border-bottom":`4px solid ${this.props.selectedColor}`,height:`16px`,"margin-top":`2px`}):``}},EP=class extends k{static template=`o-spreadsheet-ColorPicker`;static components={Popover:Fw};props=(0,t.useProps)({onColorPicked:M.function(),currentColor:M.string().optional(``),maxHeight:M.Pixel().optional(),anchorRect:M.Rect(),disableNoColor:M.boolean().optional()});COLORS=We;state=(0,t.proxy)({showGradient:!1,currentHslaColor:Nf(this.props.currentColor)?{...Wf(this.props.currentColor),a:1}:{h:0,s:100,l:100,a:1},customHexColor:Nf(this.props.currentColor)?Mf(this.props.currentColor):``});get colorPickerStyle(){return this.props.maxHeight!==void 0&&this.props.maxHeight<=0?G({display:`none`}):``}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:`bottom-left`,verticalOffset:0}}get gradientHueStyle(){return G({background:`hsl(${this.state.currentHslaColor?.h||0} 100% 50%)`})}get sliderStyle(){let e=this.state.currentHslaColor?.h||0;return G({"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 G({left:`${-16/2+n}px`,top:`${-16/2+r}px`,background:Uf(this.state.currentHslaColor)})}get colorPreviewStyle(){return G({"background-color":Uf(this.state.currentHslaColor)})}get checkmarkColor(){return wm(this.props.currentColor)}get isHexColorInputValid(){return!this.state.customHexColor||Nf(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=Uf(this.state.currentHslaColor)}onColorClick(e){e&&this.props.onColorPicked(Mf(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,Nf(t)&&(this.state.currentHslaColor={...Wf(t),a:1})}addCustomColor(e){!Pf(this.state.currentHslaColor)||!Nf(this.state.customHexColor)||this.props.onColorPicked(Mf(this.state.customHexColor))}isSameColor(e,t){return qf(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(Mf(e.sRGBHex))}catch(e){if(e.name!==`AbortError`)throw e}}},DP=class extends k{static template=`o-spreadsheet-ColorPickerWidget`;static components={ColorPicker:EP};props=(0,t.useProps)({currentColor:M.string().optional(),toggleColorPicker:M.function(),showColorPicker:M.boolean(),onColorPicked:M.function(),icon:M.string(),title:M.string().optional(),disabled:M.boolean().optional(),dropdownMaxHeight:M.Pixel().optional(),class:M.string().optional()});colorPickerButtonRef=t.signal.ref();get iconStyle(){return this.props.currentColor?`border-color: ${this.props.currentColor}`:`border-bottom-style: hidden`}get colorPickerAnchorRect(){return y(this.colorPickerButtonRef())}},OP=class extends k{static template=`o-spreadsheet-NumberEditor`;static components={Popover:Fw};props=(0,t.useProps)({currentValue:M.number(),onValueChange:M.function(),onToggle:M.function().optional(),onFocusInput:M.function().optional(()=>()=>{}),class:M.string(),valueIcon:M.string().optional(),min:M.number(),max:M.number(),title:M.string(),valueList:M.array(M.number())});dropdown=(0,t.proxy)({isOpen:!1});inputRef=t.signal.ref(HTMLInputElement);rootEditorRef=t.signal.ref();valueListRef=t.signal.ref();DOMFocusableElementStore;setup(){this.DOMFocusableElementStore=A(Ow),(0,t.useListener)(window,`click`,this.onExternalClick.bind(this),{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}}},kP=class extends k{static template=`o-spreadsheet-FontSizeEditor`;static components={NumberEditor:OP};props=(0,t.useProps)({currentFontSize:M.number(),onFontSizeChanged:M.function(),onToggle:M.function().optional(),onFocusInput:M.function().optional(()=>()=>{}),class:M.string()});fontSizes=mt},AP=class extends k{static template=`o-spreadsheet.TextStyler`;static components={ColorPickerWidget:DP,ActionButton:TP,FontSizeEditor:kP};props=(0,t.useProps)({style:M.ChartStyle(),updateStyle:M.function(),defaultStyle:M.object().optional(),hasVerticalAlign:M.boolean().optional(),hasHorizontalAlign:M.boolean().optional(),hasBackgroundColor:M.boolean().optional(),class:M.string().optional()});openedEl=null;setup(){(0,t.useListener)(window,`click`,this.onExternalClick.bind(this))}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??qe.fontSize}get boldButtonAction(){return{name:N(`Bold`),execute:()=>this.toggleBold(),isActive:()=>this.bold||!1,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.BOLD`}}get italicButtonAction(){return{name:N(`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:N(`Horizontal alignment`),icon:e,isEnabledOnLockedSheet:!0}}get horizontalAlignActions(){return[{name:N(`Left`),execute:()=>this.updateAlignment(`left`),isActive:()=>this.align===`left`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_LEFT`},{name:N(`Center`),execute:()=>this.updateAlignment(`center`),isActive:()=>this.align===`center`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_CENTER`},{name:N(`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:N(`Vertical alignment`),icon:e,isEnabledOnLockedSheet:!0}}get verticalAlignActions(){return[{name:N(`Top`),execute:()=>this.updateVerticalAlignment(`top`),isActive:()=>this.verticalAlign===`top`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_TOP`},{name:N(`Middle`),execute:()=>this.updateVerticalAlignment(`middle`),isActive:()=>this.verticalAlign===`middle`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_MIDDLE`},{name:N(`Bottom`),execute:()=>this.updateVerticalAlignment(`bottom`),isActive:()=>this.verticalAlign===`bottom`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_BOTTOM`}]}},jP=class extends k{static template=`o-spreadsheet.ChartTitle`;static components={Section:Q,TextStyler:AP,TextInput:wP};props=(0,t.useProps)({class:M.string().optional(),title:M.string().optional(``),placeholder:M.string().optional(``),updateTitle:M.function(),name:M.string().optional(),style:M.TitleDesign(),defaultStyle:M.object().optional(),updateStyle:M.function()});updateTitle(e){this.props.updateTitle(e)}},MP=class extends k{static template=`o-spreadsheet-SidePanelCollapsible`;static components={Collapse:dN};props=(0,t.useProps)({title:M.string().optional(),isInitiallyCollapsed:M.boolean().optional(),class:M.string().optional()});state=(0,t.proxy)({isCollapsed:!!this.props.isInitiallyCollapsed});toggle(){this.state.isCollapsed=!this.state.isCollapsed}},NP=class extends k{static template=`o-spreadsheet.ChartAnnotation`;static components={SidePanelCollapsible:MP,Section:Q,TextInput:wP};props=(0,t.useProps)(pP);editorRef=t.signal.ref();state=(0,t.proxy)({annotationTextInput:this.props.definition.annotationText||``,isOverflowing:!1});setup(){Vi((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]),Vi(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 N(`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})}},PP=class extends CP{static template=`o-spreadsheet-NumberInput`;static components={};props=(0,t.useProps)({...SP,min:M.number().optional(),max:M.number().optional()});debouncedOnChange=Xt(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(` `)}},FP=class extends PP{static template=`o-spreadsheet-DateInput`},IP=class extends k{static template=`o-spreadsheet.BadgeSelection`;props=(0,t.useProps)({choices:M.ArrayOf(),onChange:M.function(),selectedValue:M.string()})},LP=class extends k{static template=`o-spreadsheet-AxisDesignEditor`;static components={Section:Q,ChartTitle:jP,BadgeSelection:IP,Checkbox:fP,NumberInput:PP,DateInput:FP};props=(0,t.useProps)({chartId:M.UID(),definition:M.ChartWithAxisDefinition(),updateChart:M.function(),axesList:M.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`?N(`Major vertical gridlines`):N(`Major horizontal gridlines`)}get minorGridLabel(){return this.state.currentAxis===`x`?N(`Minor vertical gridlines`):N(`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}=km(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=I(e,this.env.model.getters.getLocale());return Number.isNaN(t)?null:t}formatAxisBoundary(e){if(e!==void 0)return V(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}},RP=class extends k{static template=`o-spreadsheet.RadioSelection`;props=(0,t.useProps)({choices:M.ArrayOf(),onChange:M.function(),selectedValue:M.string(),name:M.string(),direction:M.or([M.literal(`horizontal`),M.literal(`vertical`)]).optional(`horizontal`)})},zP=class extends k{static template=`o-spreadsheet.RoundColorPicker`;static components={Section:Q,ColorPicker:EP};props=(0,t.useProps)({currentColor:M.string().optional(),title:M.string().optional(),onColorPicked:M.function(),disableNoColor:M.boolean().optional()});colorPickerButtonRef=t.signal.ref();state;setup(){this.state=(0,t.proxy)({pickerOpened:!1}),(0,t.useListener)(window,`click`,this.closePicker.bind(this))}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 G({background:this.props.currentColor})}},BP=class extends k{static template=`o-spreadsheet-GeneralDesignEditor`;static components={RoundColorPicker:zP,ChartTitle:jP,Section:Q,SidePanelCollapsible:MP,RadioSelection:RP};props=(0,t.useProps)({chartId:M.UID(),definition:M.ChartDefinition(),canUpdateChart:M.function(),updateChart:M.function(),defaultChartTitleFontSize:M.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=``}},VP=class extends k{static template=`o-spreadsheet-ChartHumanizeNumbers`;static components={Checkbox:fP};props=(0,t.useProps)(pP);get title(){let e=this.env.model.getters.getLocale();return N(`E.g. 1234567 -> %(value)s`,{value:V(1234567,{format:Mc({value:1234567},void 0,e),locale:e})})}},HP=class extends k{static template=`o-spreadsheet-ChartLegend`;static components={Section:Q,Select:XE};props=(0,t.useProps)({chartId:M.string(),definition:M.ChartDefinitionWithDataSource(),canUpdateChart:M.function(),updateChart:M.function(),isDisabled:M.boolean().optional(!1)});updateLegendPosition(e){this.props.updateChart(this.props.chartId,{legendPosition:e})}get legendValues(){return[{value:`none`,label:N(`None`)},{value:`top`,label:N(`Top`)},{value:`bottom`,label:N(`Bottom`)},{value:`left`,label:N(`Left`)},{value:`right`,label:N(`Right`)}]}},UP=class extends k{static template=`o-spreadsheet-SeriesDesignEditor`;static components={SidePanelCollapsible:MP,Section:Q,RoundColorPicker:zP,Select:XE};props=(0,t.useProps)({chartId:M.UID(),definition:M.ChartDefinitionWithDataSource(),updateChart:M.function(),canUpdateChart:M.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?Mf(e):up(n,dp(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}))}},WP=class extends k{static template=`o-spreadsheet-SeriesWithAxisDesignEditor`;static components={SeriesDesignEditor:UP,Checkbox:fP,RadioSelection:RP,Section:Q,RoundColorPicker:zP,NumberInput:PP,Select:XE};props=(0,t.useProps)({chartId:M.UID(),definition:M.ChartDefinitionWithDataSource(),updateChart:M.function(),canUpdateChart:M.function()});axisChoices=Mm;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:N(`Linear`)},{value:`polynomial`,label:N(`Polynomial`)},{value:`exponential`,label:N(`Exponential`)},{value:`logarithmic`,label:N(`Logarithmic`)},{value:`trailingMovingAverage`,label:N(`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?Mf(n):up(i,dp(r.customizableSeries.length))}getTrendLineColor(e){return this.getTrendLineConfiguration(e)?.color??Jf(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})}},GP=class extends k{static template=`o-spreadsheet-ChartShowValues`;static components={Checkbox:fP};props=(0,t.useProps)({chartId:M.UID(),definition:M.ChartDefinitionWithDataSource(),canUpdateChart:M.function(),updateChart:M.function(),defaultValue:M.boolean().optional()})},KP=class extends k{static template=`o-spreadsheet-ChartWithAxisDesignPanel`;static components={GeneralDesignEditor:BP,ChartAnnotation:NP,SidePanelCollapsible:MP,Section:Q,AxisDesignEditor:LP,SeriesWithAxisDesignEditor:WP,ChartLegend:HP,ChartShowValues:GP,ChartHumanizeNumbers:VP};props=(0,t.useProps)(pP);get axesList(){let{useLeftAxis:e,useRightAxis:t}=km(this.props.definition),n=[{id:`x`,name:N(`Horizontal axis`)}];return e&&n.push({id:`y`,name:N(t?`Left axis`:`Vertical axis`)}),t&&n.push({id:`y1`,name:N(e?`Right axis`:`Vertical axis`)}),n}},qP=class extends KP{static template=`o-spreadsheet-GenericZoomableChartDesignPanel`;static components={...KP.components,Checkbox:fP};onToggleZoom(e){this.props.updateChart(this.props.chartId,{zoomable:e})}},JP=class extends qP{static template=`o-spreadsheet-BarChartDesignPanel`;get isZoomable(){return!this.props.definition.horizontal}},YP=class extends k{static template=`o-spreadsheet-BubbleChartConfigPanel`;static components={ChartDataSeries:hP,ChartLabelRange:gP,ChartErrorSection:vP};props=(0,t.useProps)(pP);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=>pT.Errors[e]||pT.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`?N(`Use col %(column_name)s as headers`,{column_name:Pn(this.calculateHeaderPosition()||0)}):N(`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=ju(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=ju(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`}},XP=class extends k{static template=`o-spreadsheet-BubbleChartDesignPanel`;static components={GeneralDesignEditor:BP,SidePanelCollapsible:MP,Section:Q,AxisDesignEditor:LP,ChartLegend:HP,ChartShowValues:GP,ChartHumanizeNumbers:VP,RadioSelection:RP,RoundColorPicker:zP,Checkbox:fP,ChartAnnotation:NP};props=(0,t.useProps)(pP);get axesList(){return[{id:`x`,name:N(`Horizontal axis`)},{id:this.verticalAxisPosition===`right`?`y1`:`y`,name:N(`Vertical axis`)}]}colorModeChoices=[{value:`single`,label:N(`Single color`)},{value:`multiple`,label:N(`Multiple colors`)}];axisChoices=Mm;get colorMode(){return this.props.definition.bubbleColor.color===`multiple`?`multiple`:`single`}onColorModeChange(e){this.updateBubbleColor(e===`multiple`?`multiple`:np)}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`?np: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 ZP(e){return e=Mf(e).replace(`#`,``),e.length===8?e.slice(6)+e.slice(0,6):e}let QP=Object.freeze({value:null}),$P=Object.freeze({value:0});function eF(e,{labelValues:t,dataSetsValues:n},r,i){let a=r.getLocale(),o=t.map(({value:e,format:t})=>V(e,{format:t,locale:a}));({labels:o,dataSetsValues:n}=DF(o,n)),e.aggregated&&({labels:o,dataSetsValues:n}=jF(o,n));let s=NF(e.dataSetStyles,n,`left`),c=NF(e.dataSetStyles,n,`right`),l=e.horizontal?{x:s||c}:{y:s,y1:c},u=[];for(let t in n){let{data:r,dataSetId:i}=n[t],a=e.dataSetStyles?.[i]?.trend;if(!a?.display||e.horizontal){u.push(void 0);continue}let o=pF(a,r);u.push(o)}return{dataSetsValues:n,trendDataSetsValues:u,axisFormats:l,labels:o,locale:r.getLocale(),topPadding:FF(e,r),background:Im(e,i)}}function tF(e,t){switch(t){case`day_of_week`:return nc[e-1].toString();case`hour_number`:{let t=String(e%12).padStart(2,`0`);return N(e<12?`%(hour)s AM`:`%(hour)s PM`,{hour:t})}case`month_number`:return tc[e-1].toString();case`iso_week_number`:return N(`W%(weekNumber)s`,{weekNumber:String(e).padStart(2,`0`)});case`quarter_number`:return N(`Q%(value)s`,{value:e});default:return e.toString()}}function nF(e,t,n,r,i,a){let o={},s=[],c=[],l=[];for(let u=0;u<e?.length;u++){let d=I(UT({granularity:n,type:`date`,displayName:`date`},e[u].value,B),i);d in o||(s.push(d),o[d]={});let f=I(UT({granularity:r,type:`date`,displayName:`date`},e[u].value,B),i);if(l.includes(f)||(c.push(f),l.push(f)),f in o[d]||(o[d][f]={value:0}),a)o[d][f].value+=1;else{let e=t[u];mf(e)&&(o[d][f].value+=e.value)}}return s.sort((e,t)=>e-t),c.sort((e,t)=>t-e),{dataSetsValues:c.map(e=>({data:s.map(t=>o?.[t]?.[e]),label:tF(e,r),hidden:!1,dataSetId:`0`})),labels:s.map(e=>({value:tF(e,n)}))}}function rF(e,{labelValues:t,dataSetsValues:n},r,i){let a=t,o=r.getLocale(),s=n.length===0;({labels:a,dataSetsValues:n}=OF(a,n,s));let c={y:NF(e.dataSetStyles,n,`left`)};return{labels:a,dataSetsValues:n}=nF(a,n[0]?.data??[],e.horizontalGroupBy??`day_of_week`,e.verticalGroupBy??`hour_number`,o,s),{dataSetsValues:n,axisFormats:c,labels:a.map(({value:e})=>String(e??``)),locale:r.getLocale(),topPadding:FF(e,r),background:Im(e,i)}}function iF(e,{labelValues:t,dataSetsValues:n},r,i){let a=eF(e,{labelValues:t,dataSetsValues:n.slice(0,2)},r,i),o=a.dataSetsValues.filter(e=>!e.hidden),s=[];if(o[0]){let e=o[0].data.map(e=>mf(e)&&e.value>0?e:$P);s.push({...o[0],data:e})}if(o[1]){let e=o[1].data.map(e=>mf(e)&&e.value>0?{value:-e.value}:$P);s.push({...o[1],data:e})}return{...a,dataSetsValues:s}}function aF(e,{labelValues:t,dataSetsValues:n},r,i){let a=_F(e,{labelValues:t,dataSetsValues:n}),o=a===`linear`?t.map(({value:e})=>String(e??``)):t.map(({value:e,format:t})=>V(e,{format:t,locale:r.getLocale()})),s=e.fillArea?$P:QP;({labels:o,dataSetsValues:n}=DF(o,n,s)),a===`time`&&({labels:o,dataSetsValues:n}=EF(o,n)),e.aggregated&&({labels:o,dataSetsValues:n}=jF(o,n)),e.cumulative&&(n=PF(n,`asc`));let c={y:NF(e.dataSetStyles,n,`left`),y1:NF(e.dataSetStyles,n,`right`),x:MF(t)},l=[];for(let t in n){let{data:i,dataSetId:s}=n[t],c=e.dataSetStyles?.[s]?.trend;if(!c?.display){l.push(void 0);continue}l.push(mF(c,i,o,a,r.getLocale()))}return{dataSetsValues:n,axisFormats:c,labels:o,locale:r.getLocale(),trendDataSetsValues:l,axisType:a,topPadding:FF(e,r),background:Im(e,i)}}function oF(e,{labelValues:t,dataSetsValues:n},r,i){let a=t.map(({value:e,format:t})=>V(e,{format:t,locale:r.getLocale()}));({labels:a,dataSetsValues:n}=DF(a,n)),e.aggregated&&({labels:a,dataSetsValues:n}=jF(a,n)),{dataSetsValues:n,labels:a}=TF(a,n);let o=NF(e.dataSetStyles,n,`left`);return{dataSetsValues:n,axisFormats:{y:o},labels:a,locale:r.getLocale(),topPadding:FF(e,r),background:Im(e,i)}}function sF(e,{labelValues:t,dataSetsValues:n},r,i){let a=t.map(({value:e,format:t})=>V(e,{format:t,locale:r.getLocale()}));({labels:a,dataSetsValues:n}=DF(a,n)),e.aggregated&&({labels:a,dataSetsValues:n}=jF(a,n));let o={r:NF(e.dataSetStyles,n,`left`)||NF(e.dataSetStyles,n,`right`)};return{dataSetsValues:n,axisFormats:o,labels:a,locale:r.getLocale(),background:Im(e,i)}}function cF(e,{labelValues:t,dataSetsValues:n},r,i){n=n.slice(0,1);let a=t.map(({value:e,format:t})=>V(e,{format:t,locale:r.getLocale()}));({labels:a,dataSetsValues:n}=jF(a,n));let o=NF(e.dataSetStyles,n,`left`)||NF(e.dataSetStyles,n,`right`);return{dataSetsValues:n,axisFormats:{y:o},labels:a,locale:r.getLocale(),availableRegions:r.getGeoChartAvailableRegions(),geoFeatureNameToId:r.geoFeatureNameToId,getGeoJsonFeatures:r.getGeoJsonFeatures,background:Im(e,i)}}function lF(e,{labelValues:t,dataSetsValues:n},r,i){let a=t.map(({value:e,format:t})=>V(e,{format:t,locale:r.getLocale()}));({labels:a,dataSetsValues:n}=DF(a,n)),e.aggregated&&({labels:a,dataSetsValues:n}=jF(a,n)),e.cumulative&&(n=PF(n,`desc`));let o=NF(e.dataSetStyles,n,`left`)||NF(e.dataSetStyles,n,`right`);return{dataSetsValues:n,axisFormats:{x:o},labels:a,locale:r.getLocale(),background:Im(e,i)}}function uF(e,{labelValues:t,dataSetsValues:n},r,i){let a=t;return{labels:a,dataSetsValues:n}=AF(a,n),{labels:a,dataSetsValues:n}=kF(a,n),{dataSetsValues:n,axisFormats:{y:MF(a)},labels:a.map(({value:e})=>String(e??``)),locale:r.getLocale(),background:Im(e,i)}}function dF(e,t,n){let r=fF(e,t),i=aF(e,r,t,n),a=e.labelRange?t.getVisibleRangeValues(e.labelRange):[],o=e.sizeRange?t.getVisibleRangeValues(e.sizeRange):[];r.shouldRemoveFirstLabel&&(a=a.slice(1),o=o.slice(1));let s=[],c=[],l=MF(o);for(let e=0;e<i.dataSetsValues[0].data.length;e++){let t=o[e]?.value,n=a[e],r=n?V(n.value,{format:n.format,locale:i.locale}):``,l=t===null?void 0:Uo(t,i.locale);l!==void 0&&l<0&&(l=void 0),s.push(r?String(r):``),c.push(l)}let u=C(0,c.length).sort((e,t)=>{let n=c[e],r=c[t];return n===void 0&&r===void 0?0:n===void 0?1:r===void 0?-1:r-n});return i.dataSetsValues[0]={...i.dataSetsValues[0],data:u.map(e=>i.dataSetsValues[0].data[e])},{...i,axisFormats:{...i.axisFormats||{},size:l},labels:u.map(e=>i.labels[e]),bubbleLabels:u.map(e=>s[e]),bubbleSizes:u.map(e=>c[e])}}function fF(e,t){let n=e.yRanges[0],r=e.xRange?t.getVisibleRangeValues(e.xRange):n?Array.from({length:t.getVisibleRangeValues(n).length},()=>QP):[],i=n?t.getVisibleRangeValues(n):[],a=Om(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 pF(e,t){let n=[],r=[],i=[];for(let e=0;e<t.length;e++){let a=t[e];mf(a)&&(n.push(a.value),r.push(e+1)),i.push(e+1)}let a=hF(e,n,r,C(.5,i.length+.55,.2));return a.length?a:void 0}function mF(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];mf(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];mf(i)&&(a.push(i.value),o.push(r)),s.push(r)}break;case`time`:for(let e=0;e<t.length;e++){let r=I({value:n[e]},i),c=t[e];mf(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=hF(e,a,o,C(l,u+f/2,f));if(p.length)return p}function hF(e,t,n,r){if(t.length<2||n.length<2||r.length===0)return[];let{normalizedLabels:i,normalizedNewLabels:a}=gF(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 OS([t],[i],[a],!0)[0].map((e,t)=>({x:r[t],y:e}));let o=CS(t,i,n,!0).flat();return a.map((e,t)=>({x:r[t],y:TS(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?ES(OS([e],[n],[a],!0))[0].map((e,t)=>({x:r[t],y:e})):r.map(e=>({x:e,y:NaN}))}case`logarithmic`:return OS([t],DS([i]),DS([a]),!0)[0].map((e,t)=>({x:r[t],y:e}));case`trailingMovingAverage`:return kS(t,n,e.window);default:return r.map(e=>({x:e,y:NaN}))}}catch{return r.map(e=>({x:e,y:NaN}))}}function gF(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 _F(e,t){return vF(e,t)&&wF()?`time`:yF(e,t)?`linear`:`category`}function vF(e,t){return!e.labelsAsText&&xF(t)}function yF(e,t){return!e.labelsAsText&&SF(t)}function bF(e){return xF(e)||SF(e)}function xF(e){if(!SF(e))return!1;let t=MF(e.labelValues);return!!(t&&nh.test(t))}function SF(e){let t=e.labelValues;return!(t.some(e=>!mf(e)&&e.value)||t.every(e=>!e.value))}let CF=!1;function wF(){if(!window.Chart)return!1;let e=new window.Chart._adapters._date({})._id===`luxon`;return!e&&!CF&&(CF=!0,console.warn(`'chartjs-adapter-luxon' time adapter is not installed. Time scale axes are disabled.`)),e}function TF(e,t){let n=C(0,Math.max(e.length,...t.map(e=>e.data?.length||0))).filter(e=>t.some(t=>mf(t.data[e])&&t.data[e].value>0));return{labels:n.map(t=>e[t]||``),dataSetsValues:t.map(e=>({...e,data:n.map(t=>mf(e.data[t])&&e.data[t].value>0?e.data[t]:QP)}))}}function EF(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]=tn(n,e);for(let t of r)t.data[e]=QP}return{labels:n,dataSetsValues:r}}function DF(e,t,n=QP){let r=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(mf)});return{labels:r.map(t=>e[t]||``),dataSetsValues:t.map(e=>({...e,data:r.map(t=>mf(e.data[t])?e.data[t]:n)}))}}function OF(e,t,n){let r=C(0,Math.max(e.length,...t.map(e=>e.data?.length||0))).filter(r=>{let i=e[r];return mf(i)?n?!0:mf(t.map(e=>e.data?.[r])[0]):!1});return{labels:r.map(t=>e[t]||``),dataSetsValues:t.map(e=>({...e,data:r.map(t=>mf(e.data[t])?e.data[t]:QP)}))}}function kF(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]&&mf(e[n])});return{labels:i.map(t=>e[t]),dataSetsValues:t.map(e=>({...e,data:i.map(t=>e.data[t])}))}}function AF(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 jF(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 MF(e){return e.find(({format:e})=>e!==void 0)?.format}function NF(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&&!vc(e));if(t)return t.format}}function PF(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];mf(i)?(r+=i.value,n[t]={...i,value:r}):n[t]=QP}return{...e,data:n}})}function FF(e,t){let{title:n,legendPosition:r}=e,i=n&&n.text||r===`top`;return t.isDashboard()&&!i?30:0}function IF(e,t){return{padding:{left:20,right:20,top:Math.max(15,t.topPadding||0),bottom:10}}}function LF(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 RF=.2;function zF(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]=Jf(r[t],e===n?1:RF))}}function BF(e){for(let t of e)for(let e of[`borderColor`,`backgroundColor`])e in t&&(t[e]=Jf(t[e],1))}function VF(e,t){let n=e.datasetIndex;for(let e=0;e<t.length;e++){let r=t[e],i=Jf(r.borderColor,e===n?1:RF);r.borderColor=i,r.pointBackgroundColor=i,r.backgroundColor=Jf(r.backgroundColor,ct*(e===n?1:RF))}}function HF(e){for(let t of e){let e=Jf(t.borderColor,1);t.borderColor=e,t.pointBackgroundColor=e,t.backgroundColor=Jf(t.backgroundColor,ct)}}function UF(e,t){let n=t[0],r=n.hoverBackgroundColor,i=n.hoverBorderColor;!Array.isArray(r)||!Array.isArray(i)||(n.backgroundColor=r.map((t,n)=>Jf(t,n===e.datasetIndex?1:RF)),n.borderColor=i.map((t,n)=>Jf(t,n===e.datasetIndex?1:RF)))}function WF(e){let t=e[0],n=t.hoverBackgroundColor,r=t.hoverBorderColor;!Array.isArray(n)||!Array.isArray(r)||(t.backgroundColor=[...n],t.borderColor=[...r])}function GF(e,t){let n=t.datasetIndex;n!==void 0&&(e.isDatasetVisible(n)?e.hide(n):e.show(n))}function KF(e,t){for(let n of t){let t=n.backgroundColor;if(!t)return;t.forEach((t,n,r)=>{r[n]=Jf(t,n===e.index?1:RF)})}}function qF(e){for(let t of e){let e=t.backgroundColor;if(!e)return;e.forEach((e,t,n)=>{n[t]=Jf(e,1)})}}function JF(e,t){let n=t.index;n!==void 0&&e.toggleDataVisibility(n)}function YF({legendPosition:e}){return{display:e!==`none`,position:e===`none`?void 0:e}}function XF(e,t){return{...oI({highlightItem:zF,unHighlightItems:BF,toggleDataVisibility:GF}),...YF(e),...cI(wm(e.background),{lineWidth:3})}}function ZF(e,t){return{...YF(e),...cI(wm(e.background),{pointStyle:`rect`,lineWidth:3})}}function QF(e,t){let n=e.fillArea,r=n?`rect`:`line`,i=n?2:3;return{...oI({highlightItem:VF,unHighlightItems:HF,toggleDataVisibility:GF}),...YF(e),...cI(wm(e.background),{pointStyle:r,lineWidth:i})}}function $F(e,t){let{dataSetsValues:n}=t,r=Nm(new pp(Math.max(0,...n.map(e=>e?.data?.length??0)),e.slicesColors),n),i=wm(e.background);return{...oI({highlightItem:KF,unHighlightItems:qF,toggleDataVisibility:JF}),...YF(e),labels:{usePointStyle:!0,generateLabels:e=>(e.data.labels?.map((t,n)=>({text:Pm(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 eI(e,t){return{...oI({highlightItem:VF,unHighlightItems:HF,toggleDataVisibility:GF}),...YF(e),...uI(wm(e.background),{pointStyle:`circle`,strokeStyle:e.background||`#ffffff`,lineWidth:8})}}function tI(e,t){return e.bubbleColor.color===`multiple`?{...sI,...YF(e),...lI(wm(e.background),{pointStyle:`circle`,strokeStyle:e.background||`#ffffff`,lineWidth:8},t.bubbleLabels)}:{display:!1}}function nI(e,t){return{...oI({highlightItem:zF,unHighlightItems:BF,toggleDataVisibility:GF}),...YF(e),...cI(wm(e.background),{lineWidth:3})}}function rI(e,t){let n=wm(e.background),r=e.negativeValuesColor||`#EA6175`,i=e.positiveValuesColor||`#4EA7F2`,a=e.subTotalValuesColor||`#AAAAAA`;return{...YF(e),labels:{usePointStyle:!0,generateLabels:()=>{let t=[{text:N(`Positive values`),fontColor:n,fillStyle:i,strokeStyle:i,pointStyle:`rect`},{text:N(`Negative values`),fontColor:n,fillStyle:r,strokeStyle:r,pointStyle:`rect`}];return(e.showSubTotals||e.firstValueAsSubtotal)&&t.push({text:N(`Subtotals`),fontColor:n,fillStyle:a,strokeStyle:a,pointStyle:`rect`}),t},filter:(e,t)=>`datasetIndex`in e?!t.datasets[e.datasetIndex].hidden:!0},onClick:()=>{}}}function iI(e,t){let n=e.fillArea??!1,r=n?`rect`:`line`,i=n?2:3;return{...oI({highlightItem:VF,unHighlightItems:HF,toggleDataVisibility:GF}),...YF(e),...cI(wm(e.background),{pointStyle:r,lineWidth:i})}}function aI(e,t){let n=wm(e.background);return{...YF(e),labels:{usePointStyle:!0,generateLabels:e=>{let t=e.data.datasets.at(-1);return t?t.groupColors.map(({color:e,label:t})=>({text:Pm(t),fontColor:n,fillStyle:e,strokeStyle:e,pointStyle:`rect`})):[]}}}}function oI({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 sI={...oI({highlightItem:UF,unHighlightItems:WF,toggleDataVisibility:GF}),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 cI(e,t){return{labels:{color:e,usePointStyle:!0,generateLabels:n=>n.data.datasets.map((r,i)=>Fm(r.xAxisID)?{text:Pm(r.label),fontColor:e,strokeStyle:r.borderColor,hidden:!n.isDatasetVisible(i),pointStyle:`line`,datasetIndex:i,lineWidth:3}:{text:Pm(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 lI(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 uI(e,t){return{labels:{color:e,usePointStyle:!0,generateLabels:n=>n.data.datasets.map((r,i)=>Fm(r.xAxisID)?{text:Pm(r.label),fontColor:e,strokeStyle:r.borderColor,hidden:!n.isDatasetVisible(i),pointStyle:`line`,datasetIndex:i,lineWidth:3}:{text:Pm(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 dI={showValues:!1,showLabels:!0,valuesDesign:{align:`center`,fontSize:13}};function fI(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=_I(e,i);return Am(n,r,e.humanize)(t,a)}}}function pI(e,t){let{locale:n,axisFormats:r}=t;return{type:`calendar`,horizontal:!1,showValues:`showValues`in e?!!e.showValues:!1,background:()=>e.background,callback:(e,t,i)=>{let a=t._dataset.values[i];return a===void 0?``:jc({value:a,format:r?.y},n)}}}function mI(e,t){let{axisFormats:n,locale:r}=t;return{callback:Am(n,r,e.humanize),showLabels:e.showLabels??dI.showLabels,showValues:e.showValues??dI.showValues,style:{fontSize:e.valuesDesign?.fontSize??dI.valuesDesign.fontSize,align:e.valuesDesign?.align??dI.valuesDesign.align,bold:e.valuesDesign?.bold??dI.valuesDesign.bold,italic:e.valuesDesign?.italic??dI.valuesDesign.italic,textColor:e.valuesDesign?.color??dI.valuesDesign.color}}}function hI(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?``:Am(n,r)(e,t.xAxisID||`x`))}}function gI(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}${Am(n,r,e.humanize)(c,i.yAxisID)}`}}}function _I(e,t){return t.rAxisID?t.rAxisID:(`horizontal`in e&&e.horizontal?t.xAxisID:t.yAxisID)||`y`}function vI({title:e,legendPosition:t,background:n},r){let i=Tm(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 yI;function bI(e,t={}){return xI(e,t).innerHTML}function xI(e,n={}){yI||=new t.App({templates:`
75
+ />`;setup(){this.viewStore=A(W),this.zoomStore=A(Rg)}props=(0,t.useProps)({leftOffset:M.number().optional(0)});get offset(){return this.viewStore.viewports.getSheetScrollInfo(this.viewStore.displayedSheetId).scrollX}get width(){return this.viewStore.viewports.getMainViewportRect(this.viewStore.displayedSheetId).width}get isDisplayed(){let{xRatio:e}=this.viewStore.viewports.getFrozenSheetViewRatio(this.viewStore.displayedSheetId);return e<1}get position(){let{x:e}=this.viewStore.viewports.getMainViewportRect(this.viewStore.displayedSheetId),t=this.zoomStore.scrollBarWidth;return{left:`${this.props.leftOffset+e}px`,bottom:`0px`,height:`${t}px`,right:`${t}px`}}onScroll(e){let{scrollY:t}=this.viewStore.viewports.getSheetScrollInfo(this.viewStore.displayedSheetId);this.viewStore.setViewportOffset({offsetX:e,offsetY:t})}},XN=class extends k{static template=`o-spreadsheet-Selection`;static components={Highlight:JN};get highlightProps(){let e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getUnboundedZone(e,this.env.model.getters.getSelectedZone());return{range:this.env.model.getters.getRangeFromZone(e,t),color:je}}},ZN=class extends ei{canResizeTable(e){let t=this.getters.getCoreTableMatchingTopLeft(e.sheetId,e.zone);if(!t)return new Jd([`TableNotFound`]);let n=t.range.zone,r=this.getters.getRangeFromRangeData(e.newTableRange).zone;return r.top!==n.top||r.left!==n.left?new Jd([`InvalidTableResize`]):this.model.canDispatch(`UPDATE_TABLE`,{...e})}handle(e){switch(e.type){case`RESIZE_TABLE`:{if(!this.canResizeTable(e).isSuccessful)return;let t=this.getters.getCoreTableMatchingTopLeft(e.sheetId,e.zone);if(this.model.dispatch(`UPDATE_TABLE`,{...e}),!t)return;let n=this.getters.getRangeFromRangeData(e.newTableRange).zone;if(this.model.selection.selectCell(n.right,n.bottom),!t.config.automaticAutofill)return;let r=t.range.zone;if(n.bottom>=r.bottom){for(let t=n.left;t<=n.right;t++){let i={col:t,row:r.bottom,sheetId:e.sheetId};this.getters.getCell(i)?.isFormula&&this.model.dispatch(`AUTOFILL_TABLE_COLUMN`,{...i,autofillRowStart:r.bottom,autofillRowEnd:n.bottom})}break}}}}};function QN(e){let n=(0,t.proxy)({hovered:!1});(0,t.useListener)(e,`mouseenter`,()=>n.hovered=!0),(0,t.useListener)(e,`mouseleave`,()=>n.hovered=!1);let r=new ResizeObserver(()=>{n.hovered=!1});return(0,t.useEffect)(()=>{let t=e();return t&&r.observe(t),()=>{r.disconnect()}}),n}function $N(e,t){let n=QN(e);eP({get highlights(){return n.hovered?t.highlights:[]}})}function eP(e){let n=Yi(),r=Zi(DE);(0,t.onMounted)(()=>{r.register(e)});let i=e.highlights;Vi(e=>{T(e,i)||(i=e,n.trigger(`store-updated`))},()=>[e.highlights])}var tP=class extends k{static template=`o-spreadsheet-TableResizer`;props=(0,t.useProps)({table:M.Table()});state=(0,t.proxy)({highlightZone:void 0});dragNDropGrid=Jj(this.env);viewStore;zoomStore;setup(){eP(this),this.viewStore=A(W),A(ZN),this.zoomStore=A(Rg)}get containerStyle(){let e=this.props.table.range.sheetId,t=this.props.table.range.zone,n={...t,left:t.right,top:t.bottom},r=this.viewStore.viewports.getVisibleRect(e,n);return r.height===0||r.width===0?G({display:`none`}):G({top:`${r.y+r.height-6}px`,left:`${r.x+r.width-6}px`})}onMouseDown(e){let t=this.props.table.range.zone,n={col:t.left,row:t.top};document.body.style.cursor=`nwse-resize`;let r=this.zoomStore.getZoomedEvent(e);this.dragNDropGrid.start(r,(e,t,r)=>{this.state.highlightZone={left:n.col,top:n.row,right:Math.max(e,n.col),bottom:Math.max(t,n.row)}},()=>{document.body.style.cursor=``;let e=this.state.highlightZone;if(!e)return;let t=this.props.table.range.sheetId;this.env.model.dispatch(`RESIZE_TABLE`,{sheetId:t,zone:this.props.table.range.zone,newTableRange:this.env.model.getters.getRangeDataFromZone(t,e)}),this.state.highlightZone=void 0})}get highlights(){return this.state.highlightZone?[{range:this.env.model.getters.getRangeFromZone(this.props.table.range.sheetId,this.state.highlightZone),color:`#777`,noFill:!0}]:[]}};let nP={ROW:Uj,COL:Ij,CELL:AA,GROUP_HEADERS:Vj,UNGROUP_HEADERS:Hj};var rP=class extends k{static template=`o-spreadsheet-Grid`;static components={GridComposer:_N,GridOverlay:PE,GridPopover:FE,HeaderResizeEditor:PN,HeadersOverlay:VN,MenuPopover:zw,Autofill:dM,ClientTag:pM,Highlight:JN,Popover:Fw,VerticalScrollBar:qE,HorizontalScrollBar:YN,TableResizer:tP,Selection:XN,FiguresContainer:NN};props=(0,t.useProps)({exposeFocus:M.function(),getGridSize:M.function()});HEADER_HEIGHT=26;HEADER_WIDTH=48;menuState;headerResizeEditorTarget=(0,t.signal)(null);gridRef=t.signal.ref();canvasRef=t.signal.ref(HTMLCanvasElement);highlightStore;viewStore;zoomStore;cellPopovers;composerFocusStore;DOMFocusableElementStore;paintFormatStore;clientFocusStore;checkboxToggleStore;clipboardStore;dragNDropGrid=Jj(this.env);onMouseWheel;hoveredCell;sidePanel;automaticSumStore;setup(){this.highlightStore=A(DE),this.viewStore=A(W),this.zoomStore=A(Rg),this.menuState=(0,t.proxy)({isOpen:!1,anchorRect:null,menuItems:[]}),this.hoveredCell=A(CE),this.composerFocusStore=A(ni),this.DOMFocusableElementStore=A(Ow),this.sidePanel=A(U),this.paintFormatStore=A(kE),this.clientFocusStore=A(qj),this.checkboxToggleStore=A(Kj),A(Wj),this.automaticSumStore=Zi(Gj),this.clipboardStore=A(aw),(0,t.providePlugins)([Mw],{getPopoverContainerRect:()=>this.getGridRect()}),(0,t.useListener)(document.body,`cut`,this.copy.bind(this,!0)),(0,t.useListener)(document.body,`copy`,this.copy.bind(this,!1)),(0,t.useListener)(document.body,`paste`,this.paste.bind(this)),(0,t.onMounted)(()=>this.focusDefaultElement()),this.props.exposeFocus(()=>this.focusDefaultElement()),UE({canvasRef:this.canvasRef,renderingCtx:()=>({dpr:window.devicePixelRatio||1,viewports:this.viewStore.viewports,...this.env.model.getters.getSelectionState()})}),this.onMouseWheel=WE((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.clear()}),this.cellPopovers=A(jE),Vi((e,t)=>{!e&&!t&&this.DOMFocusableElementStore.focus()},()=>[this.sidePanel.isMainPanelOpen,this.sidePanel.isSecondaryPanelOpen]),UN(this.gridRef,{updateScroll:this.moveCanvas.bind(this),canMoveUp:()=>{let{scrollY:e}=this.viewStore.activeSheetScrollInfo;return e>0},canMoveDown:()=>{let{maxOffsetY:e}=this.viewStore.maximumSheetOffset,{scrollY:t}=this.viewStore.activeSheetScrollInfo;return t<e},getZoom:()=>this.zoomStore.zoomLevel,setZoom:e=>this.zoomStore.setZoom(e)})}get highlights(){return this.highlightStore.highlights}get gridOverlayDimensions(){let e=this.zoomStore.scrollBarWidth;return G({top:`26px`,left:`48px`,height:`calc(100% - ${26+e}px)`,width:`calc(100% - ${48+e}px)`})}onClosePopover(){this.cellPopovers.isOpen&&this.cellPopovers.close(),this.focusDefaultElement()}keyDownMapping={Enter:()=>this.editOrMoveInSelection(`down`),"Shift+Enter":()=>this.editOrMoveInSelection(`up`),Tab:()=>this.moveInSelection(`right`),"Shift+Tab":()=>this.moveInSelection(`left`),F2:()=>{this.focusComposerFromActiveCell()},Delete:()=>{this.env.model.dispatch(`DELETE_UNFILTERED_CONTENT`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},Backspace:()=>{this.env.model.dispatch(`DELETE_UNFILTERED_CONTENT`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},Escape:()=>{this.cellPopovers.isOpen?this.cellPopovers.close():this.menuState.isOpen?this.closeMenu():this.paintFormatStore.isActive?this.paintFormatStore.cancel():this.env.model.dispatch(`CLEAN_CLIPBOARD_HIGHLIGHT`)},"Ctrl+A":()=>this.env.model.selection.loopSelection(),"Ctrl+Z":()=>this.env.model.dispatch(`REQUEST_UNDO`),"Ctrl+Y":()=>this.env.model.dispatch(`REQUEST_REDO`),F4:()=>this.env.model.dispatch(`REQUEST_REDO`),F9:()=>this.env.model.dispatch(`EVALUATE_CELLS`),"Ctrl+B":()=>this.env.model.dispatch(`SET_FORMATTING`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{bold:!this.env.model.getters.getCurrentStyle().bold}}),"Ctrl+I":()=>this.env.model.dispatch(`SET_FORMATTING`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{italic:!this.env.model.getters.getCurrentStyle().italic}}),"Ctrl+U":()=>this.env.model.dispatch(`SET_FORMATTING`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{underline:!this.env.model.getters.getCurrentStyle().underline}}),"Ctrl+O":()=>QD(this.env),"Alt+=":()=>{let e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZone(),n=this.automaticSumStore.automaticSumsOnMainSelectedZone;if(this.env.model.getters.isSingleCellOrMerge(e,t)||this.env.model.getters.isEmpty(e,t)&&n.length<=1){let t=n[0]?.zone?this.env.model.getters.zoneToXC(e,n[0].zone):``,r=`=SUM(${t})`;this.onComposerCellFocused(r,{start:5,end:5+t.length})}else this.env.model.dispatch(`SUM_SELECTION`)},"Alt+Enter":()=>{let e=this.env.model.getters.getActiveCell();e.link&&rf(e.link,this.env)},"Ctrl+Home":()=>{let e=this.env.model.getters.getActiveSheetId(),{col:t,row:n}=this.env.model.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0});this.env.model.selection.selectCell(t,n)},"Ctrl+End":()=>{let e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.findVisibleHeader(e,`COL`,this.env.model.getters.getNumberCols(e)-1,0),n=this.env.model.getters.findVisibleHeader(e,`ROW`,this.env.model.getters.getNumberRows(e)-1,0);this.env.model.selection.selectCell(t,n)},"Shift+ ":()=>{let e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),left:0,right:this.env.model.getters.getNumberCols(e)-1},n=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:n,zone:t})},"Ctrl+ ":()=>{let e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),top:0,bottom:this.env.model.getters.getNumberRows(e)-1},n=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:n,zone:t})},"Ctrl+D":()=>{iD(this.env,{type:`COPY_PASTE_CELLS_ABOVE`})},"Ctrl+R":()=>{iD(this.env,{type:`COPY_PASTE_CELLS_ON_LEFT`})},"Ctrl+Enter":()=>{iD(this.env,{type:`COPY_PASTE_CELLS_ON_ZONE`})},"Ctrl+H":()=>this.sidePanel.open(`FindAndReplace`,{}),"Ctrl+F":()=>this.sidePanel.open(`FindAndReplace`,{}),"Ctrl+Shift+E":()=>this.setHorizontalAlign(`center`),"Ctrl+Shift+L":()=>this.setHorizontalAlign(`left`),"Ctrl+Shift+R":()=>this.setHorizontalAlign(`right`),"Ctrl+Shift+V":()=>DD(this.env),"Ctrl+Shift+<":()=>this.clearFormatting(),"Ctrl+<":()=>this.clearFormatting(),"Ctrl+Shift+ ":()=>{this.env.model.selection.selectAll()},"Ctrl+Alt+=":()=>{let e=this.env.model.getters.getActiveCols(),t=this.env.model.getters.getActiveRows(),n=this.env.model.getters.getSelectedZones().length===1,r=e.size>0&&n,i=t.size>0&&n;r&&!i?UD(this.env):i&&!r&&VD(this.env)},"Ctrl+Alt+-":()=>{let e=[...this.env.model.getters.getActiveCols()],t=[...this.env.model.getters.getActiveRows()];e.length>0&&t.length===0?this.env.model.dispatch(`REMOVE_COLUMNS_ROWS`,{sheetId:this.env.model.getters.getActiveSheetId(),sheetName:this.env.model.getters.getActiveSheetName(),dimension:`COL`,elements:e}):t.length>0&&e.length===0&&this.env.model.dispatch(`REMOVE_COLUMNS_ROWS`,{sheetId:this.env.model.getters.getActiveSheetId(),sheetName:this.env.model.getters.getActiveSheetName(),dimension:`ROW`,elements:t})},"Shift+PageDown":()=>{this.env.model.dispatch(`ACTIVATE_NEXT_SHEET`)},"Shift+PageUp":()=>{this.env.model.dispatch(`ACTIVATE_PREVIOUS_SHEET`)},"Shift+F11":()=>{KO.execute?.(this.env)},"Alt+T":()=>{NO.execute?.(this.env)},PageDown:()=>this.viewStore.shiftViewportDown(),PageUp:()=>this.viewStore.shiftViewportUp(),"Ctrl+Shift+K":()=>{this.closeMenu(),tO(this.env)},"Alt+Shift+ArrowRight":()=>this.processHeaderGroupingKey(`right`),"Alt+Shift+ArrowLeft":()=>this.processHeaderGroupingKey(`left`),"Alt+Shift+ArrowUp":()=>this.processHeaderGroupingKey(`up`),"Alt+Shift+ArrowDown":()=>this.processHeaderGroupingKey(`down`)};focusComposerFromActiveCell(){this.env.model.getters.getActiveCell().type===`empty`?this.onComposerCellFocused():this.onComposerContentFocused()}editOrMoveInSelection(e){if(this.isSingleCellOrMergeSelection()){this.focusComposerFromActiveCell();return}LM(this.env.model.getters,this.env.model.selection,e)}moveInSelection(e){if(this.isSingleCellOrMergeSelection()){this.env.model.selection.moveAnchorCell(e,1);return}LM(this.env.model.getters,this.env.model.selection,e)}isSingleCellOrMergeSelection(){let e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZone();return this.env.model.getters.isSingleCellOrMerge(e,t)}focusDefaultElement(){!this.env.model.getters.getSelectedFigureIds().length&&this.composerFocusStore.activeComposer.editionMode===`inactive`&&this.DOMFocusableElementStore.focus()}get gridEl(){let e=this.gridRef();if(!e)throw Error(`Grid el is not defined.`);return e}getAutofillPosition(){let e=this.env.model.getters.getSelectedZone(),t=this.viewStore.viewports.getVisibleRect(this.env.model.getters.getActiveSheetId(),e);return{x:t.x+t.width-8/2,y:t.y+t.height-8/2}}get isAutofillVisible(){if(this.env.model.getters.isCurrentSheetLocked())return!1;let e=this.env.model.getters.getSelectedZone(),t=this.viewStore.viewports.getVisibleRect(this.env.model.getters.getActiveSheetId(),{left:e.right,right:e.right,top:e.bottom,bottom:e.bottom});return!(t.width===0||t.height===0)}onGridResized(){let{height:e,width:t}=this.props.getGridSize();this.viewStore.resizeSheetView({height:e-26,width:t-48,gridOffsetX:48,gridOffsetY:26})}moveCanvas(e,t){let{scrollX:n,scrollY:r}=this.viewStore.activeSheetScrollInfo;this.viewStore.setViewportOffset({offsetX:n+e,offsetY:r+t})}processSpaceKey(e){this.checkboxToggleStore.hasBooleanValidationInZones(this.env.model.getters.getSelectedZones())&&(e.preventDefault(),e.stopPropagation(),this.env.model.dispatch(`TOGGLE_CHECKBOX`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()}))}getClientPositionKey(e){return`${e.id}-${e.position?.sheetId}-${e.position?.col}-${e.position?.row}`}isCellHovered(e,t){return this.hoveredCell.col===e&&this.hoveredCell.row===t}get focusedClients(){return this.clientFocusStore.focusedClients}getGridRect(){let e=this.zoomStore.zoomLevel,{width:t,height:n}=this.viewStore.sheetViewDimensionWithHeaders;return{...y(this.gridRef()),width:t*e,height:n*e}}onCellClicked(e,t,n,r){if(r.ev.preventDefault(),this.composerFocusStore.activeComposer.editionMode===`editing`&&this.composerFocusStore.activeComposer.stopEdition(),n.expandZone?this.env.model.selection.setAnchorCorner(e,t):n.addZone?this.env.model.selection.addCellToSelection(e,t):this.env.model.selection.selectCell(e,t),this.env.isMobile())return;let i=e,a=t;this.dragNDropGrid.start(r,(e,t,n)=>{n.preventDefault(),(e!==i&&e!==-1||t!==a&&t!==-1)&&(i=e===-1?i:e,a=t===-1?a:t,this.env.model.selection.setAnchorCorner(i,a))},()=>{this.env.model.selection.commitSelection(),this.paintFormatStore.isActive&&this.paintFormatStore.pasteFormat(this.env.model.getters.getSelectedZones())})}onCellDoubleClicked(e,t){let n=this.env.model.getters.getActiveSheetId();({col:e,row:t}=this.env.model.getters.getMainCellPosition({sheetId:n,col:e,row:t})),this.env.model.getters.getEvaluatedCell({sheetId:n,col:e,row:t}).type===`empty`?this.onComposerCellFocused():this.onComposerContentFocused()}processArrows(e){e.preventDefault(),e.stopPropagation(),this.cellPopovers.isOpen&&this.cellPopovers.close(),IM(e,this.env.model.selection),this.paintFormatStore.isActive&&this.paintFormatStore.pasteFormat(this.env.model.getters.getSelectedZones())}onKeydown(e){let t=ce(e),n=this.keyDownMapping[t];if(n){e.preventDefault(),e.stopPropagation(),n();return}if(t===` `){this.processSpaceKey(e);return}if(e.key.startsWith(`Arrow`)){this.processArrows(e);return}}onInputContextMenu(e){e.preventDefault();let t=this.env.model.getters.getActivePosition(),{col:n,row:r,sheetId:i}=t,a=`CELL`;this.composerFocusStore.activeComposer.stopEdition(),this.env.model.getters.getActiveCols().has(n)?a=`COL`:this.env.model.getters.getActiveRows().has(r)&&(a=`ROW`);let o=D(t),s=this.env.model.getters.getSheetZone(i);a===`COL`?o={...s,left:n,right:n}:a===`ROW`&&(o={...s,top:r,bottom:r});let{x:c,y:l}=this.viewStore.viewports.getVisibleRectWithZoom(i,o),u=this.getGridRect();this.toggleContextMenu(a,u.x+c,u.y+l)}onCellRightClicked(e,t,{x:n,y:r}){let i=this.env.model.getters.getSelectedZones(),a=i[i.length-1],o=`CELL`;_r(e,t,a)?this.env.model.getters.getActiveCols().has(e)?o=`COL`:this.env.model.getters.getActiveRows().has(t)&&(o=`ROW`):(this.env.model.selection.getBackToDefault(),this.env.model.selection.selectCell(e,t)),this.toggleContextMenu(o,n,r)}getMenuItems(e,t,n){let r=nP[e].getMenuItems(),i=e===`COL`?t:e===`ROW`?n:-1;if(i===-1)return r;let a=e===`COL`,o=r.find(({id:e})=>e===(a?`unhide_columns`:`unhide_rows`));if(!o)throw Error(`Missing unhide action in the header menu`);return r.push(we({id:a?`resize_columns`:`resize_rows`,name:N(a?`Resize column`:`Resize row`),sequence:o.sequence+1,separator:!0,icon:a?`o-spreadsheet-Icon.RESIZE_HORIZONTAL`:`o-spreadsheet-Icon.RESIZE_VERTICAL`,children:[{name:N(`Fit to data`),execute:e=>{let t=e.model.getters.getActiveSheetId();return a?e.model.dispatch(`AUTORESIZE_COLUMNS`,{sheetId:t,cols:[...e.model.getters.getActiveCols()]}):e.model.dispatch(`AUTORESIZE_ROWS`,{sheetId:t,rows:[...e.model.getters.getActiveRows()]})}},{name:N(`Custom size`),execute:()=>this.headerResizeEditorTarget.set({dimension:a?`COL`:`ROW`,index:i})}]})),r.sort((e,t)=>e.sequence-t.sequence)}toggleContextMenu(e,t,n){this.cellPopovers.isOpen&&this.cellPopovers.close();let r=this.getGridRect(),i=this.zoomStore.zoomLevel,a=this.viewStore.gridOffset,[o,s]=this.viewStore.getCartesianCoordinates((t-r.x)/i-a.x,(n-r.y)/i-a.y);this.menuState.isOpen=!0,this.menuState.anchorRect={x:t,y:n,width:0,height:0},this.menuState.menuItems=this.getMenuItems(e,o,s)}async copy(e,t){if(!this.gridEl.contains(document.activeElement)||this.composerFocusStore.activeComposer.editionMode!==`inactive`)return;e?Fk(this.env):this.env.model.dispatch(`COPY`);let n=await this.clipboardStore.getClipboardTextAndImageContent();await this.env.clipboard.write(n),t.preventDefault()}async paste(e){if(!this.gridEl.contains(document.activeElement))return;e.preventDefault();let t=e.clipboardData;if(!t)return;let n=[...t.files].find(e=>L_.includes(e.type)),r={content:{"text/plain":t?.getData(`text/plain`),"text/html":t?.getData(`text/html`)}};n&&(r.content[n.type]=n);let i=this.env.model.getters.getSelectedZones(),a=this.clipboardStore.isCutOperation();if(this.clipboardStore.getClipboardId()===H_(r.content[`text/html`]))sD(this.env,i);else{let e=V_(r.content);await cD(this.env,i,e)}a&&await this.env.clipboard.write({"text/plain":``})}clearFormatting(){this.env.model.dispatch(`CLEAR_FORMATTING`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}setHorizontalAlign(e){this.env.model.dispatch(`SET_FORMATTING`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),style:{align:e}})}closeMenu(){this.menuState.isOpen=!1,this.focusDefaultElement()}processHeaderGroupingKey(e){if(this.env.model.getters.getSelectedZones().length!==1)return;let t=this.env.model.getters.getActiveRows().size>0,n=this.env.model.getters.getActiveCols().size>0;n&&t?this.processHeaderGroupingEventOnWholeSheet(e):n?this.processHeaderGroupingEventOnHeaders(e,`COL`):t?this.processHeaderGroupingEventOnHeaders(e,`ROW`):this.processHeaderGroupingEventOnGrid(e)}processHeaderGroupingEventOnHeaders(e,t){let n=this.env.model.getters.getActiveSheetId(),r=this.env.model.getters.getSelectedZone(),i=t===`COL`?r.left:r.top,a=t===`COL`?r.right:r.bottom;switch(e){case`right`:this.env.model.dispatch(`GROUP_HEADERS`,{sheetId:n,dimension:t,start:i,end:a});break;case`left`:this.env.model.dispatch(`UNGROUP_HEADERS`,{sheetId:n,dimension:t,start:i,end:a});break;case`down`:this.env.model.dispatch(`UNFOLD_HEADER_GROUPS_IN_ZONE`,{sheetId:n,dimension:t,zone:r});break;case`up`:this.env.model.dispatch(`FOLD_HEADER_GROUPS_IN_ZONE`,{sheetId:n,dimension:t,zone:r});break}}processHeaderGroupingEventOnWholeSheet(e){let t=this.env.model.getters.getActiveSheetId();e===`up`?(this.env.model.dispatch(`FOLD_ALL_HEADER_GROUPS`,{sheetId:t,dimension:`ROW`}),this.env.model.dispatch(`FOLD_ALL_HEADER_GROUPS`,{sheetId:t,dimension:`COL`})):e===`down`&&(this.env.model.dispatch(`UNFOLD_ALL_HEADER_GROUPS`,{sheetId:t,dimension:`ROW`}),this.env.model.dispatch(`UNFOLD_ALL_HEADER_GROUPS`,{sheetId:t,dimension:`COL`}))}processHeaderGroupingEventOnGrid(e){let t=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getSelectedZone();switch(e){case`down`:this.env.model.dispatch(`UNFOLD_HEADER_GROUPS_IN_ZONE`,{sheetId:t,dimension:`ROW`,zone:n}),this.env.model.dispatch(`UNFOLD_HEADER_GROUPS_IN_ZONE`,{sheetId:t,dimension:`COL`,zone:n});break;case`up`:this.env.model.dispatch(`FOLD_HEADER_GROUPS_IN_ZONE`,{sheetId:t,dimension:`ROW`,zone:n}),this.env.model.dispatch(`FOLD_HEADER_GROUPS_IN_ZONE`,{sheetId:t,dimension:`COL`,zone:n});break;case`right`:{let{x:e,y:r,width:i}=this.viewStore.viewports.getVisibleRectWithZoom(t,n),a=this.getGridRect();this.toggleContextMenu(`GROUP_HEADERS`,e+i+a.x,r+a.y);break}case`left`:{if(!Ck(this.env,`COL`)&&!Ck(this.env,`ROW`))return;let{x:e,y:r,width:i}=this.viewStore.viewports.getVisibleRectWithZoom(t,n),a=this.getGridRect();this.toggleContextMenu(`UNGROUP_HEADERS`,e+i+a.x,r+a.y);break}}}onComposerCellFocused(e,t){this.composerFocusStore.focusActiveComposer({content:e,selection:t,focusMode:`cellFocus`})}onComposerContentFocused(){this.composerFocusStore.focusActiveComposer({focusMode:`contentFocus`})}get staticTables(){let e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getCoreTables(e).filter(kk)}get displaySelectionHandler(){return this.env.isMobile()&&this.composerFocusStore.activeComposer.editionMode===`inactive`}get clientsToDisplay(){let e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getClientsToDisplay(e)}get displayTableResizer(){return this.env.model.getters.isGridSelectionActive()&&!this.env.model.getters.isReadonly()&&!this.env.model.getters.isSheetLocked(this.env.model.getters.getActiveSheetId())}};function iP(){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 cP(a.scrollableContainerEl):new sP(a.scrollableContainerEl);e=new aP({...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 aP=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`),G(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()}},oP=class{el;constructor(e){this.el=e}get containerRect(){return this.el.getBoundingClientRect()}},sP=class extends oP{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}},cP=class extends oP{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}},lP=class{mutators=[`focus`,`unfocus`];focusedElement=null;focus(e){this.focusedElement=e}unfocus(e){this.focusedElement&&this.focusedElement===e&&(this.focusedElement=null)}},uP=class extends ei{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(lP);highlightStore=this.get(DE);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,D({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}=wl(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 mr(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 pp(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 pp(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}=wl(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}=wl(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`}},dP=class extends k{static template=`o-spreadsheet-SelectionInput`;props=(0,t.useProps)({ranges:M.array(M.string()),hasSingleRange:M.boolean().optional(),required:M.boolean().optional(),autofocus:M.boolean().optional(),isInvalid:M.boolean().optional(),class:M.string().optional(),onSelectionChanged:M.function().optional(),onSelectionConfirmed:M.function().optional(),onSelectionReordered:M.function().optional(),onSelectionRemoved:M.function().optional(),onInputFocused:M.function().optional(),colors:M.ArrayOf().optional([]),disabledRanges:M.array(M.boolean()).optional([]),disabledRangeTitle:M.string().optional()});state=(0,t.proxy)({isMissing:!1});dragAndDrop=iP();focusedInputRef=t.signal.ref(HTMLInputElement);unfocusedInputRef=t.signal.ref(HTMLInputElement);selectionRef=t.signal.ref();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=A(Ow),this.store=Zi(uP,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()}),Vi(()=>{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`),G(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(),IM(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?.()}},fP=class extends k{static template=`o-spreadsheet.Checkbox`;props=(0,t.useProps)({label:M.string().optional(),value:M.boolean().optional(!1),className:M.string().optional(),name:M.string().optional(),title:M.string().optional(),disabled:M.boolean().optional(),onChange:M.function()});onChange(e){let t=e.target.checked;this.props.onChange(t)}},Q=class extends k{static template=`o_spreadsheet.Section`;props=(0,t.useProps)({class:M.string().optional(),title:M.string().optional(),slots:M.object()})};let pP={chartId:M.UID(),definition:M.object({}),canUpdateChart:M.function(),updateChart:M.function()},mP=new O;var hP=class extends k{static template=`o-spreadsheet.ChartDataSeries`;static components={SelectionInput:dP,Section:Q};props=(0,t.useProps)({ranges:M.ArrayOf(),dataSetStyles:M.DataSetStyle().optional(),hasSingleRange:M.boolean().optional(),onSelectionChanged:M.function(),onSelectionReordered:M.function().optional(),onSelectionRemoved:M.function().optional(),onSelectionConfirmed:M.function(),maxNumberOfUsedRanges:M.number().optional(),title:M.string().optional(),datasetOrientation:M.or([M.literal(`rows`),M.literal(`columns`)]).optional(),canChangeDatasetOrientation:M.boolean().optional(),onFlipAxis:M.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?N(`Data range`):N(`Data series`)}},gP=class extends k{static template=`o-spreadsheet.ChartLabelRange`;static components={SelectionInput:dP,Checkbox:fP,Section:Q};props=(0,t.useProps)({title:M.string().optional(N(`Categories / Labels`)),range:M.string(),class:M.string().optional(),isInvalid:M.boolean(),onSelectionChanged:M.function(),onSelectionConfirmed:M.function(),options:M.ArrayOf().optional([])});get sectionClass(){return`o-data-labels`+(this.props.class?` ${this.props.class}`:``)}},_P=class extends k{static template=`o-spreadsheet-ChartDataSourceComponent`;static components={ChartDataSeries:hP,ChartLabelRange:gP};props=(0,t.useProps)({chartId:M.UID(),definition:M.ChartDefinitionWithDataSource(),updateChart:M.function(),canUpdateChart:M.function(),dataSeriesTitle:M.string().optional(),labelRangeTitle:M.string().optional(),getLabelRangeOptions:M.function().optional()});get DataSourceComponent(){let e=this.props.definition.dataSource.type;return mP.get(e)}},vP=class extends k{static template=`o-spreadsheet.ChartErrorSection`;static components={Section:Q,ValidationMessages:wE};props=(0,t.useProps)({messages:M.array(M.string())})},yP=class extends k{static template=`o-spreadsheet-GenericChartConfigPanel`;static components={ChartDataSourceComponent:_P,Section:Q,Checkbox:fP,ChartErrorSection:vP};props=(0,t.useProps)(pP);chartTerms=pT;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})}}}},bP=class extends yP{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()]}};function xP(e){(0,t.useEffect)(()=>e()?.focus())}let SP={value:M.or([M.number(),M.string()]),onChange:M.function(),onFocused:M.function().optional(),onBlur:M.function().optional(),onInput:M.function().optional(),class:M.string().optional(),id:M.string().optional(),placeholder:M.string().optional(),autofocus:M.boolean().optional(),alwaysShowBorder:M.boolean().optional(),selectContentOnFocus:M.boolean().optional(),resetOnBlur:M.boolean().optional()};var CP=class extends k{props=(0,t.useProps)(SP);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&&xP(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)}},wP=class extends CP{static template=`o-spreadsheet-TextInput`;static components={};props=(0,t.useProps)({...SP,value:M.string(),errorMessage:M.string().optional(),maxLength:M.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(` `)}},TP=class extends k{static template=`o-spreadsheet-ActionButton`;props=(0,t.useProps)({action:M.ActionSpec(),hasTriangleDownIcon:M.boolean().optional(),selectedColor:M.string().optional(),class:M.string().optional(),onClick:M.function().optional()});actionButton=we(this.props.action);setup(){(0,t.onWillUpdateProps)(e=>{e.action!==this.props.action&&(this.actionButton=we(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)||xe(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?G({"border-bottom":`4px solid ${this.props.selectedColor}`,height:`16px`,"margin-top":`2px`}):``}},EP=class extends k{static template=`o-spreadsheet-ColorPicker`;static components={Popover:Fw};props=(0,t.useProps)({onColorPicked:M.function(),currentColor:M.string().optional(``),maxHeight:M.Pixel().optional(),anchorRect:M.Rect(),disableNoColor:M.boolean().optional()});COLORS=We;state=(0,t.proxy)({showGradient:!1,currentHslaColor:Nf(this.props.currentColor)?{...Wf(this.props.currentColor),a:1}:{h:0,s:100,l:100,a:1},customHexColor:Nf(this.props.currentColor)?Mf(this.props.currentColor):``});get colorPickerStyle(){return this.props.maxHeight!==void 0&&this.props.maxHeight<=0?G({display:`none`}):``}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:`bottom-left`,verticalOffset:0}}get gradientHueStyle(){return G({background:`hsl(${this.state.currentHslaColor?.h||0} 100% 50%)`})}get sliderStyle(){let e=this.state.currentHslaColor?.h||0;return G({"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 G({left:`${-16/2+n}px`,top:`${-16/2+r}px`,background:Uf(this.state.currentHslaColor)})}get colorPreviewStyle(){return G({"background-color":Uf(this.state.currentHslaColor)})}get checkmarkColor(){return wm(this.props.currentColor)}get isHexColorInputValid(){return!this.state.customHexColor||Nf(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=Uf(this.state.currentHslaColor)}onColorClick(e){e&&this.props.onColorPicked(Mf(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,Nf(t)&&(this.state.currentHslaColor={...Wf(t),a:1})}addCustomColor(e){!Pf(this.state.currentHslaColor)||!Nf(this.state.customHexColor)||this.props.onColorPicked(Mf(this.state.customHexColor))}isSameColor(e,t){return qf(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(Mf(e.sRGBHex))}catch(e){if(e.name!==`AbortError`)throw e}}},DP=class extends k{static template=`o-spreadsheet-ColorPickerWidget`;static components={ColorPicker:EP};props=(0,t.useProps)({currentColor:M.string().optional(),toggleColorPicker:M.function(),showColorPicker:M.boolean(),onColorPicked:M.function(),icon:M.string(),title:M.string().optional(),disabled:M.boolean().optional(),dropdownMaxHeight:M.Pixel().optional(),class:M.string().optional()});colorPickerButtonRef=t.signal.ref();get iconStyle(){return this.props.currentColor?`border-color: ${this.props.currentColor}`:`border-bottom-style: hidden`}get colorPickerAnchorRect(){return y(this.colorPickerButtonRef())}},OP=class extends k{static template=`o-spreadsheet-NumberEditor`;static components={Popover:Fw};props=(0,t.useProps)({currentValue:M.number(),onValueChange:M.function(),onToggle:M.function().optional(),onFocusInput:M.function().optional(()=>()=>{}),class:M.string(),valueIcon:M.string().optional(),min:M.number(),max:M.number(),title:M.string(),valueList:M.array(M.number())});dropdown=(0,t.proxy)({isOpen:!1});inputRef=t.signal.ref(HTMLInputElement);rootEditorRef=t.signal.ref();valueListRef=t.signal.ref();skipNextInputChange=!1;DOMFocusableElementStore;setup(){this.DOMFocusableElementStore=A(Ow),(0,t.useListener)(window,`click`,this.onExternalClick.bind(this),{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.round(parseFloat(e)),this.props.min,this.props.max);if(!isNaN(t))return this.props.onValueChange(t),this.closeList(),t}setValueFromInput(e){this.skipNextInputChange||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){let t=e.target;switch(e.key){case`Enter`:case`Tab`:{e.preventDefault(),e.stopPropagation();let n=this.setValue(t.value);if(n===void 0)return;t.value=`${n}`;break}case`Escape`:t.value=`${this.props.currentValue}`,this.closeList();break;default:return}this.skipNextInputChange=!0,this.DOMFocusableElementStore.focus(),this.skipNextInputChange=!1}},kP=class extends k{static template=`o-spreadsheet-FontSizeEditor`;static components={NumberEditor:OP};props=(0,t.useProps)({currentFontSize:M.number(),onFontSizeChanged:M.function(),onToggle:M.function().optional(),onFocusInput:M.function().optional(()=>()=>{}),class:M.string()});fontSizes=mt},AP=class extends k{static template=`o-spreadsheet.TextStyler`;static components={ColorPickerWidget:DP,ActionButton:TP,FontSizeEditor:kP};props=(0,t.useProps)({style:M.ChartStyle(),updateStyle:M.function(),defaultStyle:M.object().optional(),hasVerticalAlign:M.boolean().optional(),hasHorizontalAlign:M.boolean().optional(),hasBackgroundColor:M.boolean().optional(),class:M.string().optional()});openedEl=null;setup(){(0,t.useListener)(window,`click`,this.onExternalClick.bind(this))}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??qe.fontSize}get boldButtonAction(){return{name:N(`Bold`),execute:()=>this.toggleBold(),isActive:()=>this.bold||!1,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.BOLD`}}get italicButtonAction(){return{name:N(`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:N(`Horizontal alignment`),icon:e,isEnabledOnLockedSheet:!0}}get horizontalAlignActions(){return[{name:N(`Left`),execute:()=>this.updateAlignment(`left`),isActive:()=>this.align===`left`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_LEFT`},{name:N(`Center`),execute:()=>this.updateAlignment(`center`),isActive:()=>this.align===`center`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_CENTER`},{name:N(`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:N(`Vertical alignment`),icon:e,isEnabledOnLockedSheet:!0}}get verticalAlignActions(){return[{name:N(`Top`),execute:()=>this.updateVerticalAlignment(`top`),isActive:()=>this.verticalAlign===`top`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_TOP`},{name:N(`Middle`),execute:()=>this.updateVerticalAlignment(`middle`),isActive:()=>this.verticalAlign===`middle`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_MIDDLE`},{name:N(`Bottom`),execute:()=>this.updateVerticalAlignment(`bottom`),isActive:()=>this.verticalAlign===`bottom`,isEnabledOnLockedSheet:!0,icon:`o-spreadsheet-Icon.ALIGN_BOTTOM`}]}},jP=class extends k{static template=`o-spreadsheet.ChartTitle`;static components={Section:Q,TextStyler:AP,TextInput:wP};props=(0,t.useProps)({class:M.string().optional(),title:M.string().optional(``),placeholder:M.string().optional(``),updateTitle:M.function(),name:M.string().optional(),style:M.TitleDesign(),defaultStyle:M.object().optional(),updateStyle:M.function()});updateTitle(e){this.props.updateTitle(e)}},MP=class extends k{static template=`o-spreadsheet-SidePanelCollapsible`;static components={Collapse:dN};props=(0,t.useProps)({title:M.string().optional(),isInitiallyCollapsed:M.boolean().optional(),class:M.string().optional()});state=(0,t.proxy)({isCollapsed:!!this.props.isInitiallyCollapsed});toggle(){this.state.isCollapsed=!this.state.isCollapsed}},NP=class extends k{static template=`o-spreadsheet.ChartAnnotation`;static components={SidePanelCollapsible:MP,Section:Q,TextInput:wP};props=(0,t.useProps)(pP);editorRef=t.signal.ref();state=(0,t.proxy)({annotationTextInput:this.props.definition.annotationText||``,isOverflowing:!1});setup(){Vi((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]),Vi(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 N(`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})}},PP=class extends CP{static template=`o-spreadsheet-NumberInput`;static components={};props=(0,t.useProps)({...SP,min:M.number().optional(),max:M.number().optional()});debouncedOnChange=Xt(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(` `)}},FP=class extends PP{static template=`o-spreadsheet-DateInput`},IP=class extends k{static template=`o-spreadsheet.BadgeSelection`;props=(0,t.useProps)({choices:M.ArrayOf(),onChange:M.function(),selectedValue:M.string()})},LP=class extends k{static template=`o-spreadsheet-AxisDesignEditor`;static components={Section:Q,ChartTitle:jP,BadgeSelection:IP,Checkbox:fP,NumberInput:PP,DateInput:FP};props=(0,t.useProps)({chartId:M.UID(),definition:M.ChartWithAxisDefinition(),updateChart:M.function(),axesList:M.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`?N(`Major vertical gridlines`):N(`Major horizontal gridlines`)}get minorGridLabel(){return this.state.currentAxis===`x`?N(`Minor vertical gridlines`):N(`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}=km(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=I(e,this.env.model.getters.getLocale());return Number.isNaN(t)?null:t}formatAxisBoundary(e){if(e!==void 0)return V(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}},RP=class extends k{static template=`o-spreadsheet.RadioSelection`;props=(0,t.useProps)({choices:M.ArrayOf(),onChange:M.function(),selectedValue:M.string(),name:M.string(),direction:M.or([M.literal(`horizontal`),M.literal(`vertical`)]).optional(`horizontal`)})},zP=class extends k{static template=`o-spreadsheet.RoundColorPicker`;static components={Section:Q,ColorPicker:EP};props=(0,t.useProps)({currentColor:M.string().optional(),title:M.string().optional(),onColorPicked:M.function(),disableNoColor:M.boolean().optional()});colorPickerButtonRef=t.signal.ref();state;setup(){this.state=(0,t.proxy)({pickerOpened:!1}),(0,t.useListener)(window,`click`,this.closePicker.bind(this))}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 G({background:this.props.currentColor})}},BP=class extends k{static template=`o-spreadsheet-GeneralDesignEditor`;static components={RoundColorPicker:zP,ChartTitle:jP,Section:Q,SidePanelCollapsible:MP,RadioSelection:RP};props=(0,t.useProps)({chartId:M.UID(),definition:M.ChartDefinition(),canUpdateChart:M.function(),updateChart:M.function(),defaultChartTitleFontSize:M.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=``}},VP=class extends k{static template=`o-spreadsheet-ChartHumanizeNumbers`;static components={Checkbox:fP};props=(0,t.useProps)(pP);get title(){let e=this.env.model.getters.getLocale();return N(`E.g. 1234567 -> %(value)s`,{value:V(1234567,{format:Mc({value:1234567},void 0,e),locale:e})})}},HP=class extends k{static template=`o-spreadsheet-ChartLegend`;static components={Section:Q,Select:XE};props=(0,t.useProps)({chartId:M.string(),definition:M.ChartDefinitionWithDataSource(),canUpdateChart:M.function(),updateChart:M.function(),isDisabled:M.boolean().optional(!1)});updateLegendPosition(e){this.props.updateChart(this.props.chartId,{legendPosition:e})}get legendValues(){return[{value:`none`,label:N(`None`)},{value:`top`,label:N(`Top`)},{value:`bottom`,label:N(`Bottom`)},{value:`left`,label:N(`Left`)},{value:`right`,label:N(`Right`)}]}},UP=class extends k{static template=`o-spreadsheet-SeriesDesignEditor`;static components={SidePanelCollapsible:MP,Section:Q,RoundColorPicker:zP,Select:XE};props=(0,t.useProps)({chartId:M.UID(),definition:M.ChartDefinitionWithDataSource(),updateChart:M.function(),canUpdateChart:M.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?Mf(e):up(n,dp(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}))}},WP=class extends k{static template=`o-spreadsheet-SeriesWithAxisDesignEditor`;static components={SeriesDesignEditor:UP,Checkbox:fP,RadioSelection:RP,Section:Q,RoundColorPicker:zP,NumberInput:PP,Select:XE};props=(0,t.useProps)({chartId:M.UID(),definition:M.ChartDefinitionWithDataSource(),updateChart:M.function(),canUpdateChart:M.function()});axisChoices=Mm;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:N(`Linear`)},{value:`polynomial`,label:N(`Polynomial`)},{value:`exponential`,label:N(`Exponential`)},{value:`logarithmic`,label:N(`Logarithmic`)},{value:`trailingMovingAverage`,label:N(`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?Mf(n):up(i,dp(r.customizableSeries.length))}getTrendLineColor(e){return this.getTrendLineConfiguration(e)?.color??Jf(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})}},GP=class extends k{static template=`o-spreadsheet-ChartShowValues`;static components={Checkbox:fP};props=(0,t.useProps)({chartId:M.UID(),definition:M.ChartDefinitionWithDataSource(),canUpdateChart:M.function(),updateChart:M.function(),defaultValue:M.boolean().optional()})},KP=class extends k{static template=`o-spreadsheet-ChartWithAxisDesignPanel`;static components={GeneralDesignEditor:BP,ChartAnnotation:NP,SidePanelCollapsible:MP,Section:Q,AxisDesignEditor:LP,SeriesWithAxisDesignEditor:WP,ChartLegend:HP,ChartShowValues:GP,ChartHumanizeNumbers:VP};props=(0,t.useProps)(pP);get axesList(){let{useLeftAxis:e,useRightAxis:t}=km(this.props.definition),n=[{id:`x`,name:N(`Horizontal axis`)}];return e&&n.push({id:`y`,name:N(t?`Left axis`:`Vertical axis`)}),t&&n.push({id:`y1`,name:N(e?`Right axis`:`Vertical axis`)}),n}},qP=class extends KP{static template=`o-spreadsheet-GenericZoomableChartDesignPanel`;static components={...KP.components,Checkbox:fP};onToggleZoom(e){this.props.updateChart(this.props.chartId,{zoomable:e})}},JP=class extends qP{static template=`o-spreadsheet-BarChartDesignPanel`;get isZoomable(){return!this.props.definition.horizontal}},YP=class extends k{static template=`o-spreadsheet-BubbleChartConfigPanel`;static components={ChartDataSeries:hP,ChartLabelRange:gP,ChartErrorSection:vP};props=(0,t.useProps)(pP);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=>pT.Errors[e]||pT.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`?N(`Use col %(column_name)s as headers`,{column_name:Pn(this.calculateHeaderPosition()||0)}):N(`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=ju(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=ju(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`}},XP=class extends k{static template=`o-spreadsheet-BubbleChartDesignPanel`;static components={GeneralDesignEditor:BP,SidePanelCollapsible:MP,Section:Q,AxisDesignEditor:LP,ChartLegend:HP,ChartShowValues:GP,ChartHumanizeNumbers:VP,RadioSelection:RP,RoundColorPicker:zP,Checkbox:fP,ChartAnnotation:NP};props=(0,t.useProps)(pP);get axesList(){return[{id:`x`,name:N(`Horizontal axis`)},{id:this.verticalAxisPosition===`right`?`y1`:`y`,name:N(`Vertical axis`)}]}colorModeChoices=[{value:`single`,label:N(`Single color`)},{value:`multiple`,label:N(`Multiple colors`)}];axisChoices=Mm;get colorMode(){return this.props.definition.bubbleColor.color===`multiple`?`multiple`:`single`}onColorModeChange(e){this.updateBubbleColor(e===`multiple`?`multiple`:np)}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`?np: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 ZP(e){return e=Mf(e).replace(`#`,``),e.length===8?e.slice(6)+e.slice(0,6):e}let QP=Object.freeze({value:null}),$P=Object.freeze({value:0});function eF(e,{labelValues:t,dataSetsValues:n},r,i){let a=r.getLocale(),o=t.map(({value:e,format:t})=>V(e,{format:t,locale:a}));({labels:o,dataSetsValues:n}=DF(o,n)),e.aggregated&&({labels:o,dataSetsValues:n}=jF(o,n));let s=NF(e.dataSetStyles,n,`left`),c=NF(e.dataSetStyles,n,`right`),l=e.horizontal?{x:s||c}:{y:s,y1:c},u=[];for(let t in n){let{data:r,dataSetId:i}=n[t],a=e.dataSetStyles?.[i]?.trend;if(!a?.display||e.horizontal){u.push(void 0);continue}let o=pF(a,r);u.push(o)}return{dataSetsValues:n,trendDataSetsValues:u,axisFormats:l,labels:o,locale:r.getLocale(),topPadding:FF(e,r),background:Im(e,i)}}function tF(e,t){switch(t){case`day_of_week`:return nc[e-1].toString();case`hour_number`:{let t=String(e%12).padStart(2,`0`);return N(e<12?`%(hour)s AM`:`%(hour)s PM`,{hour:t})}case`month_number`:return tc[e-1].toString();case`iso_week_number`:return N(`W%(weekNumber)s`,{weekNumber:String(e).padStart(2,`0`)});case`quarter_number`:return N(`Q%(value)s`,{value:e});default:return e.toString()}}function nF(e,t,n,r,i,a){let o={},s=[],c=[],l=[];for(let u=0;u<e?.length;u++){let d=I(UT({granularity:n,type:`date`,displayName:`date`},e[u].value,B),i);d in o||(s.push(d),o[d]={});let f=I(UT({granularity:r,type:`date`,displayName:`date`},e[u].value,B),i);if(l.includes(f)||(c.push(f),l.push(f)),f in o[d]||(o[d][f]={value:0}),a)o[d][f].value+=1;else{let e=t[u];mf(e)&&(o[d][f].value+=e.value)}}return s.sort((e,t)=>e-t),c.sort((e,t)=>t-e),{dataSetsValues:c.map(e=>({data:s.map(t=>o?.[t]?.[e]),label:tF(e,r),hidden:!1,dataSetId:`0`})),labels:s.map(e=>({value:tF(e,n)}))}}function rF(e,{labelValues:t,dataSetsValues:n},r,i){let a=t,o=r.getLocale(),s=n.length===0;({labels:a,dataSetsValues:n}=OF(a,n,s));let c={y:NF(e.dataSetStyles,n,`left`)};return{labels:a,dataSetsValues:n}=nF(a,n[0]?.data??[],e.horizontalGroupBy??`day_of_week`,e.verticalGroupBy??`hour_number`,o,s),{dataSetsValues:n,axisFormats:c,labels:a.map(({value:e})=>String(e??``)),locale:r.getLocale(),topPadding:FF(e,r),background:Im(e,i)}}function iF(e,{labelValues:t,dataSetsValues:n},r,i){let a=eF(e,{labelValues:t,dataSetsValues:n.slice(0,2)},r,i),o=a.dataSetsValues.filter(e=>!e.hidden),s=[];if(o[0]){let e=o[0].data.map(e=>mf(e)&&e.value>0?e:$P);s.push({...o[0],data:e})}if(o[1]){let e=o[1].data.map(e=>mf(e)&&e.value>0?{value:-e.value}:$P);s.push({...o[1],data:e})}return{...a,dataSetsValues:s}}function aF(e,{labelValues:t,dataSetsValues:n},r,i){let a=_F(e,{labelValues:t,dataSetsValues:n}),o=a===`linear`?t.map(({value:e})=>String(e??``)):t.map(({value:e,format:t})=>V(e,{format:t,locale:r.getLocale()})),s=e.fillArea?$P:QP;({labels:o,dataSetsValues:n}=DF(o,n,s)),a===`time`&&({labels:o,dataSetsValues:n}=EF(o,n)),e.aggregated&&({labels:o,dataSetsValues:n}=jF(o,n)),e.cumulative&&(n=PF(n,`asc`));let c={y:NF(e.dataSetStyles,n,`left`),y1:NF(e.dataSetStyles,n,`right`),x:MF(t)},l=[];for(let t in n){let{data:i,dataSetId:s}=n[t],c=e.dataSetStyles?.[s]?.trend;if(!c?.display){l.push(void 0);continue}l.push(mF(c,i,o,a,r.getLocale()))}return{dataSetsValues:n,axisFormats:c,labels:o,locale:r.getLocale(),trendDataSetsValues:l,axisType:a,topPadding:FF(e,r),background:Im(e,i)}}function oF(e,{labelValues:t,dataSetsValues:n},r,i){let a=t.map(({value:e,format:t})=>V(e,{format:t,locale:r.getLocale()}));({labels:a,dataSetsValues:n}=DF(a,n)),e.aggregated&&({labels:a,dataSetsValues:n}=jF(a,n)),{dataSetsValues:n,labels:a}=TF(a,n);let o=NF(e.dataSetStyles,n,`left`);return{dataSetsValues:n,axisFormats:{y:o},labels:a,locale:r.getLocale(),topPadding:FF(e,r),background:Im(e,i)}}function sF(e,{labelValues:t,dataSetsValues:n},r,i){let a=t.map(({value:e,format:t})=>V(e,{format:t,locale:r.getLocale()}));({labels:a,dataSetsValues:n}=DF(a,n)),e.aggregated&&({labels:a,dataSetsValues:n}=jF(a,n));let o={r:NF(e.dataSetStyles,n,`left`)||NF(e.dataSetStyles,n,`right`)};return{dataSetsValues:n,axisFormats:o,labels:a,locale:r.getLocale(),background:Im(e,i)}}function cF(e,{labelValues:t,dataSetsValues:n},r,i){n=n.slice(0,1);let a=t.map(({value:e,format:t})=>V(e,{format:t,locale:r.getLocale()}));({labels:a,dataSetsValues:n}=jF(a,n));let o=NF(e.dataSetStyles,n,`left`)||NF(e.dataSetStyles,n,`right`);return{dataSetsValues:n,axisFormats:{y:o},labels:a,locale:r.getLocale(),availableRegions:r.getGeoChartAvailableRegions(),geoFeatureNameToId:r.geoFeatureNameToId,getGeoJsonFeatures:r.getGeoJsonFeatures,background:Im(e,i)}}function lF(e,{labelValues:t,dataSetsValues:n},r,i){let a=t.map(({value:e,format:t})=>V(e,{format:t,locale:r.getLocale()}));({labels:a,dataSetsValues:n}=DF(a,n)),e.aggregated&&({labels:a,dataSetsValues:n}=jF(a,n)),e.cumulative&&(n=PF(n,`desc`));let o=NF(e.dataSetStyles,n,`left`)||NF(e.dataSetStyles,n,`right`);return{dataSetsValues:n,axisFormats:{x:o},labels:a,locale:r.getLocale(),background:Im(e,i)}}function uF(e,{labelValues:t,dataSetsValues:n},r,i){let a=t;return{labels:a,dataSetsValues:n}=AF(a,n),{labels:a,dataSetsValues:n}=kF(a,n),{dataSetsValues:n,axisFormats:{y:MF(a)},labels:a.map(({value:e})=>String(e??``)),locale:r.getLocale(),background:Im(e,i)}}function dF(e,t,n){let r=fF(e,t),i=aF(e,r,t,n),a=e.labelRange?t.getVisibleRangeValues(e.labelRange):[],o=e.sizeRange?t.getVisibleRangeValues(e.sizeRange):[];r.shouldRemoveFirstLabel&&(a=a.slice(1),o=o.slice(1));let s=[],c=[],l=MF(o);for(let e=0;e<i.dataSetsValues[0].data.length;e++){let t=o[e]?.value,n=a[e],r=n?V(n.value,{format:n.format,locale:i.locale}):``,l=t===null?void 0:Uo(t,i.locale);l!==void 0&&l<0&&(l=void 0),s.push(r?String(r):``),c.push(l)}let u=C(0,c.length).sort((e,t)=>{let n=c[e],r=c[t];return n===void 0&&r===void 0?0:n===void 0?1:r===void 0?-1:r-n});return i.dataSetsValues[0]={...i.dataSetsValues[0],data:u.map(e=>i.dataSetsValues[0].data[e])},{...i,axisFormats:{...i.axisFormats||{},size:l},labels:u.map(e=>i.labels[e]),bubbleLabels:u.map(e=>s[e]),bubbleSizes:u.map(e=>c[e])}}function fF(e,t){let n=e.yRanges[0],r=e.xRange?t.getVisibleRangeValues(e.xRange):n?Array.from({length:t.getVisibleRangeValues(n).length},()=>QP):[],i=n?t.getVisibleRangeValues(n):[],a=Om(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 pF(e,t){let n=[],r=[],i=[];for(let e=0;e<t.length;e++){let a=t[e];mf(a)&&(n.push(a.value),r.push(e+1)),i.push(e+1)}let a=hF(e,n,r,C(.5,i.length+.55,.2));return a.length?a:void 0}function mF(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];mf(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];mf(i)&&(a.push(i.value),o.push(r)),s.push(r)}break;case`time`:for(let e=0;e<t.length;e++){let r=I({value:n[e]},i),c=t[e];mf(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=hF(e,a,o,C(l,u+f/2,f));if(p.length)return p}function hF(e,t,n,r){if(t.length<2||n.length<2||r.length===0)return[];let{normalizedLabels:i,normalizedNewLabels:a}=gF(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 OS([t],[i],[a],!0)[0].map((e,t)=>({x:r[t],y:e}));let o=CS(t,i,n,!0).flat();return a.map((e,t)=>({x:r[t],y:TS(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?ES(OS([e],[n],[a],!0))[0].map((e,t)=>({x:r[t],y:e})):r.map(e=>({x:e,y:NaN}))}case`logarithmic`:return OS([t],DS([i]),DS([a]),!0)[0].map((e,t)=>({x:r[t],y:e}));case`trailingMovingAverage`:return kS(t,n,e.window);default:return r.map(e=>({x:e,y:NaN}))}}catch{return r.map(e=>({x:e,y:NaN}))}}function gF(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 _F(e,t){return vF(e,t)&&wF()?`time`:yF(e,t)?`linear`:`category`}function vF(e,t){return!e.labelsAsText&&xF(t)}function yF(e,t){return!e.labelsAsText&&SF(t)}function bF(e){return xF(e)||SF(e)}function xF(e){if(!SF(e))return!1;let t=MF(e.labelValues);return!!(t&&nh.test(t))}function SF(e){let t=e.labelValues;return!(t.some(e=>!mf(e)&&e.value)||t.every(e=>!e.value))}let CF=!1;function wF(){if(!window.Chart)return!1;let e=new window.Chart._adapters._date({})._id===`luxon`;return!e&&!CF&&(CF=!0,console.warn(`'chartjs-adapter-luxon' time adapter is not installed. Time scale axes are disabled.`)),e}function TF(e,t){let n=C(0,Math.max(e.length,...t.map(e=>e.data?.length||0))).filter(e=>t.some(t=>mf(t.data[e])&&t.data[e].value>0));return{labels:n.map(t=>e[t]||``),dataSetsValues:t.map(e=>({...e,data:n.map(t=>mf(e.data[t])&&e.data[t].value>0?e.data[t]:QP)}))}}function EF(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]=tn(n,e);for(let t of r)t.data[e]=QP}return{labels:n,dataSetsValues:r}}function DF(e,t,n=QP){let r=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(mf)});return{labels:r.map(t=>e[t]||``),dataSetsValues:t.map(e=>({...e,data:r.map(t=>mf(e.data[t])?e.data[t]:n)}))}}function OF(e,t,n){let r=C(0,Math.max(e.length,...t.map(e=>e.data?.length||0))).filter(r=>{let i=e[r];return mf(i)?n?!0:mf(t.map(e=>e.data?.[r])[0]):!1});return{labels:r.map(t=>e[t]||``),dataSetsValues:t.map(e=>({...e,data:r.map(t=>mf(e.data[t])?e.data[t]:QP)}))}}function kF(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]&&mf(e[n])});return{labels:i.map(t=>e[t]),dataSetsValues:t.map(e=>({...e,data:i.map(t=>e.data[t])}))}}function AF(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 jF(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 MF(e){return e.find(({format:e})=>e!==void 0)?.format}function NF(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&&!vc(e));if(t)return t.format}}function PF(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];mf(i)?(r+=i.value,n[t]={...i,value:r}):n[t]=QP}return{...e,data:n}})}function FF(e,t){let{title:n,legendPosition:r}=e,i=n&&n.text||r===`top`;return t.isDashboard()&&!i?30:0}function IF(e,t){return{padding:{left:20,right:20,top:Math.max(15,t.topPadding||0),bottom:10}}}function LF(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 RF=.2;function zF(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]=Jf(r[t],e===n?1:RF))}}function BF(e){for(let t of e)for(let e of[`borderColor`,`backgroundColor`])e in t&&(t[e]=Jf(t[e],1))}function VF(e,t){let n=e.datasetIndex;for(let e=0;e<t.length;e++){let r=t[e],i=Jf(r.borderColor,e===n?1:RF);r.borderColor=i,r.pointBackgroundColor=i,r.backgroundColor=Jf(r.backgroundColor,ct*(e===n?1:RF))}}function HF(e){for(let t of e){let e=Jf(t.borderColor,1);t.borderColor=e,t.pointBackgroundColor=e,t.backgroundColor=Jf(t.backgroundColor,ct)}}function UF(e,t){let n=t[0],r=n.hoverBackgroundColor,i=n.hoverBorderColor;!Array.isArray(r)||!Array.isArray(i)||(n.backgroundColor=r.map((t,n)=>Jf(t,n===e.datasetIndex?1:RF)),n.borderColor=i.map((t,n)=>Jf(t,n===e.datasetIndex?1:RF)))}function WF(e){let t=e[0],n=t.hoverBackgroundColor,r=t.hoverBorderColor;!Array.isArray(n)||!Array.isArray(r)||(t.backgroundColor=[...n],t.borderColor=[...r])}function GF(e,t){let n=t.datasetIndex;n!==void 0&&(e.isDatasetVisible(n)?e.hide(n):e.show(n))}function KF(e,t){for(let n of t){let t=n.backgroundColor;if(!t)return;t.forEach((t,n,r)=>{r[n]=Jf(t,n===e.index?1:RF)})}}function qF(e){for(let t of e){let e=t.backgroundColor;if(!e)return;e.forEach((e,t,n)=>{n[t]=Jf(e,1)})}}function JF(e,t){let n=t.index;n!==void 0&&e.toggleDataVisibility(n)}function YF({legendPosition:e}){return{display:e!==`none`,position:e===`none`?void 0:e}}function XF(e,t){return{...oI({highlightItem:zF,unHighlightItems:BF,toggleDataVisibility:GF}),...YF(e),...cI(wm(e.background),{lineWidth:3})}}function ZF(e,t){return{...YF(e),...cI(wm(e.background),{pointStyle:`rect`,lineWidth:3})}}function QF(e,t){let n=e.fillArea,r=n?`rect`:`line`,i=n?2:3;return{...oI({highlightItem:VF,unHighlightItems:HF,toggleDataVisibility:GF}),...YF(e),...cI(wm(e.background),{pointStyle:r,lineWidth:i})}}function $F(e,t){let{dataSetsValues:n}=t,r=Nm(new pp(Math.max(0,...n.map(e=>e?.data?.length??0)),e.slicesColors),n),i=wm(e.background);return{...oI({highlightItem:KF,unHighlightItems:qF,toggleDataVisibility:JF}),...YF(e),labels:{usePointStyle:!0,generateLabels:e=>(e.data.labels?.map((t,n)=>({text:Pm(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 eI(e,t){return{...oI({highlightItem:VF,unHighlightItems:HF,toggleDataVisibility:GF}),...YF(e),...uI(wm(e.background),{pointStyle:`circle`,strokeStyle:e.background||`#ffffff`,lineWidth:8})}}function tI(e,t){return e.bubbleColor.color===`multiple`?{...sI,...YF(e),...lI(wm(e.background),{pointStyle:`circle`,strokeStyle:e.background||`#ffffff`,lineWidth:8},t.bubbleLabels)}:{display:!1}}function nI(e,t){return{...oI({highlightItem:zF,unHighlightItems:BF,toggleDataVisibility:GF}),...YF(e),...cI(wm(e.background),{lineWidth:3})}}function rI(e,t){let n=wm(e.background),r=e.negativeValuesColor||`#EA6175`,i=e.positiveValuesColor||`#4EA7F2`,a=e.subTotalValuesColor||`#AAAAAA`;return{...YF(e),labels:{usePointStyle:!0,generateLabels:()=>{let t=[{text:N(`Positive values`),fontColor:n,fillStyle:i,strokeStyle:i,pointStyle:`rect`},{text:N(`Negative values`),fontColor:n,fillStyle:r,strokeStyle:r,pointStyle:`rect`}];return(e.showSubTotals||e.firstValueAsSubtotal)&&t.push({text:N(`Subtotals`),fontColor:n,fillStyle:a,strokeStyle:a,pointStyle:`rect`}),t},filter:(e,t)=>`datasetIndex`in e?!t.datasets[e.datasetIndex].hidden:!0},onClick:()=>{}}}function iI(e,t){let n=e.fillArea??!1,r=n?`rect`:`line`,i=n?2:3;return{...oI({highlightItem:VF,unHighlightItems:HF,toggleDataVisibility:GF}),...YF(e),...cI(wm(e.background),{pointStyle:r,lineWidth:i})}}function aI(e,t){let n=wm(e.background);return{...YF(e),labels:{usePointStyle:!0,generateLabels:e=>{let t=e.data.datasets.at(-1);return t?t.groupColors.map(({color:e,label:t})=>({text:Pm(t),fontColor:n,fillStyle:e,strokeStyle:e,pointStyle:`rect`})):[]}}}}function oI({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 sI={...oI({highlightItem:UF,unHighlightItems:WF,toggleDataVisibility:GF}),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 cI(e,t){return{labels:{color:e,usePointStyle:!0,generateLabels:n=>n.data.datasets.map((r,i)=>Fm(r.xAxisID)?{text:Pm(r.label),fontColor:e,strokeStyle:r.borderColor,hidden:!n.isDatasetVisible(i),pointStyle:`line`,datasetIndex:i,lineWidth:3}:{text:Pm(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 lI(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 uI(e,t){return{labels:{color:e,usePointStyle:!0,generateLabels:n=>n.data.datasets.map((r,i)=>Fm(r.xAxisID)?{text:Pm(r.label),fontColor:e,strokeStyle:r.borderColor,hidden:!n.isDatasetVisible(i),pointStyle:`line`,datasetIndex:i,lineWidth:3}:{text:Pm(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 dI={showValues:!1,showLabels:!0,valuesDesign:{align:`center`,fontSize:13}};function fI(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=_I(e,i);return Am(n,r,e.humanize)(t,a)}}}function pI(e,t){let{locale:n,axisFormats:r}=t;return{type:`calendar`,horizontal:!1,showValues:`showValues`in e?!!e.showValues:!1,background:()=>e.background,callback:(e,t,i)=>{let a=t._dataset.values[i];return a===void 0?``:jc({value:a,format:r?.y},n)}}}function mI(e,t){let{axisFormats:n,locale:r}=t;return{callback:Am(n,r,e.humanize),showLabels:e.showLabels??dI.showLabels,showValues:e.showValues??dI.showValues,style:{fontSize:e.valuesDesign?.fontSize??dI.valuesDesign.fontSize,align:e.valuesDesign?.align??dI.valuesDesign.align,bold:e.valuesDesign?.bold??dI.valuesDesign.bold,italic:e.valuesDesign?.italic??dI.valuesDesign.italic,textColor:e.valuesDesign?.color??dI.valuesDesign.color}}}function hI(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?``:Am(n,r)(e,t.xAxisID||`x`))}}function gI(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}${Am(n,r,e.humanize)(c,i.yAxisID)}`}}}function _I(e,t){return t.rAxisID?t.rAxisID:(`horizontal`in e&&e.horizontal?t.xAxisID:t.yAxisID)||`y`}function vI({title:e,legendPosition:t,background:n},r){let i=Tm(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 yI;function bI(e,t={}){return xI(e,t).innerHTML}function xI(e,n={}){yI||=new t.App({templates:`
76
76
  <templates>
77
77
  <t t-name="o-spreadsheet-CustomTooltip">
78
78
  <div
@@ -174,7 +174,7 @@ You can download it directly instead.`,5),sticky:!1,type:`warning`});return}r=aw
174
174
  }
175
175
  `+i),c(n)}function c(t){let r=e.pageCount(),i=!!t.body.querySelector(`.o-empty-print-page`);if(r===0)i||t.body.replaceChildren(UG());else{for(i&&t.body.replaceChildren();t.body.children.length>r;)t.body.lastElementChild?.remove();for(;t.body.children.length<r;)t.body.appendChild(HG())}for(let n of t.body.children)n.setAttribute(`style`,e.pageStyle());let a=[...t.querySelectorAll(`canvas`)];WG(n(),a)||n.set(a)}function l(){e.iframeRef()?.contentWindow?.focus(),e.iframeRef()?.contentWindow?.print()}return{canvases:n,print:l}}function HG(){let e=document.createElement(`div`);e.classList.add(`o-print-page`);let t=document.createElement(`canvas`);return e.appendChild(t),e}function UG(){let e=document.createElement(`div`);e.classList.add(`o-print-page`,`o-empty-print-page`);let t=document.createElement(`h4`);return t.textContent=N(`No content to print`),e.appendChild(t),e}function WG(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}let GG={A3:{width:297,height:420,name:N(`A3 (297 x 420 mm)`)},A4:{width:210,height:297,name:N(`A4 (210 x 297 mm)`)},A5:{width:148,height:210,name:N(`A5 (148 x 210 mm)`)},B4:{width:250,height:353,name:N(`B4 (250 x 353 mm)`)},B5:{width:176,height:250,name:N(`B5 (176 x 250 mm)`)},Letter:{width:216,height:279,name:N(`Letter (216 x 279 mm)`)},Legal:{width:216,height:356,name:N(`Legal (216 x 356 mm)`)}},KG=3.78;var qG=class extends ei{mutators=[`changePrintLayout`,`changePrintSelection`,`changePrintScale`,`changePrintOrientation`,`setGridLinesVisibility`];pageLayout=`A4`;printSelection=`currentSheet`;printScale=`fitToWidth`;orientation=`portrait`;hideGridLines=this.getters.isDashboard()||!this.getters.getGridLinesVisibility(this.getters.getActiveSheetId());get printPages(){if(this.printSelection===`selection`){let e=this.getters.getActiveSheetId();return this.splitZoneToPrintPages(e,this.getters.getSelectedZone())}return(this.printSelection===`entireWorkbook`?this.getters.getSheetIds():[this.getters.getActiveSheetId()]).flatMap(e=>{let{lastUsedCol:t,lastUsedRow:n}=this.getLastUsedHeaders(e),r={left:0,top:0,right:t,bottom:n};return this.splitZoneToPrintPages(e,r)})}changePrintLayout(e){this.pageLayout=e}changePrintSelection(e){this.printSelection=e}changePrintScale(e){this.printScale=e}setGridLinesVisibility(e){this.hideGridLines=e}changePrintOrientation(e){this.orientation=e}splitZoneToPrintPages(e,t){let n=this.getPrintZoom(e,t),r=this.printScale===`fitToWidth`?[t.left,t.right+1]:this.getPageBreaks(e,t,`COL`,n),i=this.printScale===`fitToHeight`?[t.top,t.bottom+1]:this.getPageBreaks(e,t,`ROW`,n),a=[];for(let t=0;t<r.length-1;t++)for(let o=0;o<i.length-1;o++){let s={left:r[t],top:i[o],right:r[t+1]-1,bottom:i[o+1]-1};a.push({sheetId:e,zone:s,renderingCtx:this.getZoneRenderingContext(e,s,n)})}return a.filter(e=>this.pageHasContent(e))}getPageBreaks(e,t,n,r){let{width:i,height:a}=this.pageDimensionWithMargins,o=n===`COL`?t.left:t.top,s=n===`COL`?t.right:t.bottom,c=n===`COL`?i:a,l=[],u=0;for(let t=o;t<=s;t++){let i=this.getters.isHeaderHidden(e,n,t)?0:this.getters.getHeaderSize(e,n,t)*r;u+=i,u>=c&&(l.push(t),u=i)}return[o,...l,s+1]}getPrintZoom(e,t){if(this.printScale===`fitToWidth`){let n=this.getters.getColDimensions(e,t.left).start,r=this.getters.getColDimensions(e,t.right).end-n;return Math.min(this.pageDimensionWithMargins.width/r,1)}else if(this.printScale===`fitToHeight`){let n=this.getters.getRowDimensions(e,t.top).start,r=this.getters.getRowDimensions(e,t.bottom).end-n;return Math.min(this.pageDimensionWithMargins.height/r,1)}return 1}getZoneRenderingContext(e,t,n){let r=this.getters.getRowDimensions(e,t.top).start,i=this.getters.getRowDimensions(e,t.bottom).end,a=this.getters.getColDimensions(e,t.left).start,o=this.getters.getColDimensions(e,t.right).end-a,s=i-r,c=new Kg({getters:this.getters,paneDivision:{[e]:{xSplit:0,ySplit:0}},sheetViewWidth:o,sheetViewHeight:s,getZoomLevel:()=>n,getFooterSize:()=>0});return c.setSheetViewOffset(e,a,r),{sheetId:e,viewports:c,hideGridLines:this.hideGridLines,dpr:3,selectedZones:[],activeCols:new Set,activeRows:new Set,activePosition:void 0}}get pageDimensionWithMargins(){let{width:e,height:t}=this.pageDimensionsInPixels;return{width:e-this.printMargin*2,height:t-this.printMargin*2}}get printMargin(){return 50}getLastUsedHeaders(e){let t=0,n=0,r=this.getters.getCells(e);for(let e of r){let r=this.getters.getCellPosition(e.id),i=this.getters.getSpreadZone(r);t=Math.max(t,i?.right??r.col),n=Math.max(n,i?.bottom??r.row)}let i=this.getters.getTables(e);for(let e of i)t=Math.max(t,e.range.zone.right),n=Math.max(n,e.range.zone.bottom);for(let r of this.getters.getFigures(e)){let i=this.getters.getFigureUI(e,r),a=this.getZoneContainingFigure(e,i);t=Math.max(t,a.right),n=Math.max(n,a.bottom)}return{lastUsedCol:t,lastUsedRow:n}}pageHasContent({sheetId:e,zone:t}){if(this.getters.getTablesOverlappingZones(e,[t]).length>0||this.areThereFiguresInZone(e,t))return!0;for(let n of Cr(e,t)){let e=this.getters.getCell(n);if(e&&(e.style||e.isFormula||e.content))return!0;let t=this.getters.getEvaluatedCell(n);if(t&&t.type!==`empty`)return!0}return!1}get pageDimensionsInPixels(){let e=GG[this.pageLayout],t=Math.floor(e.width*KG),n=Math.floor(e.height*KG);return this.orientation===`portrait`?{width:t,height:n}:{width:n,height:t}}areThereFiguresInZone(e,t){return this.getters.getFigures(e).map(t=>this.getters.getFigureUI(e,t)).some(n=>!!pr(t,this.getZoneContainingFigure(e,n)))}getZoneContainingFigure(e,t){let n=t.col,r=t.x+t.width,i=n;for(;i<this.getters.getNumberCols(e)-1&&this.getters.getColDimensions(e,i).end<r;)i++;let a=t.row,o=t.y+t.height,s=a;for(;s<this.getters.getNumberRows(e)-1&&this.getters.getRowDimensions(e,s).end<o;)s++;return{left:n,right:i,top:a,bottom:s}}get layoutOptions(){return Object.keys(GG).map(e=>({value:e,label:GG[e].name}))}get printSelectionOptions(){let e=[{value:`currentSheet`,label:N(`Current sheet`)},{value:`entireWorkbook`,label:N(`Entire workbook`)}],t=this.getters.getSelectedZones();if(t.length===1){let n=this.getters.getActiveSheetId(),r=this.getters.getRangeFromZone(n,t[0]),i=this.getters.getRangeString(r,n);e.push({value:`selection`,label:N(`Selected cells (%s)`,i)})}return e}get printScaleOptions(){return[{value:`fitToWidth`,label:N(`Fit to width`)},{value:`fitToHeight`,label:N(`Fit to height`)},{value:`actualSize`,label:N(`Actual size`)}]}get orientationChoices(){return[{value:`portrait`,label:N(`Portrait`)},{value:`landscape`,label:N(`Landscape`)}]}},JG=class extends k{static template=`o-spreadsheet-SpreadsheetPrint`;props=(0,t.useProps)({onExitPrintMode:M.function()});static components={StandaloneGridCanvas:BG,Section:Q,Select:XE,BadgeSelection:IP,Checkbox:fP};printStore;printIframe;iframeRef=(0,t.signal)(null);setup(){this.printStore=Zi(qG),this.printIframe=VG({iframeRef:this.iframeRef,pageCount:()=>this.printStore.printPages.length,pageStyle:()=>this.pageStyle,pageRule:()=>this.pageRule})}get pageRule(){return`@page { size: ${`${this.printStore.pageLayout} ${this.printStore.orientation}`}; margin: ${this.printStore.printMargin}px; }`}get pageStyle(){let{width:e,height:t}=this.printStore.pageDimensionsInPixels;return G({width:`${e}px`,height:`${t}px`,padding:`${this.printStore.printMargin}px`})}onLayoutChange(e){this.printStore.changePrintLayout(e)}onPrintSelectionChange(e){this.printStore.changePrintSelection(e)}onPrintScaleChange(e){this.printStore.changePrintScale(e)}setGridLinesVisibility(e){this.printStore.setGridLinesVisibility(!e)}changeOrientation(e){this.printStore.changePrintOrientation(e)}onPrint(){this.printIframe.print(),this.props.onExitPrintMode()}},YG=class extends k{static template=`o-spreadsheet-TopBarComposer`;static components={Composer:hN};composerFocusStore;composerStore;composerInterface;setup(){this.composerFocusStore=A(ni);let e=A(rN);this.composerStore=e,this.composerInterface={id:`topbarComposer`,get editionMode(){return e.editionMode},startEdition:this.composerStore.startEdition,setCurrentContent:this.composerStore.setCurrentContent,stopEdition:this.composerStore.stopEdition}}get focus(){return this.composerFocusStore.activeComposer===this.composerInterface?this.composerFocusStore.focusMode:`inactive`}get showFxIcon(){return this.focus===`inactive`&&!this.composerStore.currentContent&&!this.composerStore.placeholder}get composerStyle(){let e={padding:`5px 0px 5px 8px`,"max-height":`300px`,"line-height":`24px`};return this.env.model.getters.isCurrentSheetLocked()&&(e[`pointer-events`]=`none`),e.height=this.focus===`inactive`?`34px`:`fit-content`,G(e)}onFocus(e){this.composerFocusStore.focusComposer(this.composerInterface,{selection:e})}},XG=class{mutators=[`closeDropdowns`,`openDropdown`];_currentDropdown=null;closeDropdowns(){this._currentDropdown=null}openDropdown(e){this._currentDropdown=e}get currentDropdown(){return this._currentDropdown}};function ZG(){let e=Bi(),n=A(XG);return(0,t.onWillUnmount)(()=>{e===n.currentDropdown&&n.closeDropdowns()}),{closeDropdowns:()=>n.closeDropdowns(),openDropdown:()=>{n.openDropdown(e)},get isActive(){return n.currentDropdown===e}}}var QG=class extends k{static template=`o-spreadsheet-NamedRangeSelector`;static components={TextInput:wP,MenuPopover:zw};DOMFocusableElementStore;sidePanelStore;topBarToolStore;menuState=(0,t.proxy)({anchorRect:null,menuItems:[]});namedRangeSelectorRef=t.signal.ref();setup(){this.topBarToolStore=ZG(),this.DOMFocusableElementStore=A(Ow),this.sidePanelStore=A(U)}onInput(e){this.menuState.searchedText=e||void 0,this.menuState.menuItems=this.getNamedRangeMenuItems()}changeInputValue(e){if(this.stopEditingNamedRange(),!e)return;e=e.replace(/ /g,`_`);let t=this.env.model.getters.getActiveSheetId(),n=this.selectedZone;if(vl.test(e)){let n=this.env.model.getters.getRangeFromSheetXC(t,e);this.navigateToRange(n);return}let r=this.env.model.getters.getNamedRange(e);if(r){this.navigateToRange(r.range);return}let i=this.env.model.getters.getNamedRangeFromZone(t,n);i?EW(this.env,{newRangeName:e,oldRangeName:i.name,ranges:[this.env.model.getters.getRangeData(i.range)]}):TW(this.env,{name:e,ranges:[this.env.model.getters.getRangeDataFromZone(t,n)]})}get inputValue(){let e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getNamedRangeFromZone(e,this.selectedZone)?.name||or(this.selectedZone)}get selectedZone(){return this.env.model.getters.getSelectedZone()}openDropdown(){this.topBarToolStore.openDropdown(),this.menuState.anchorRect=y(this.namedRangeSelectorRef()),this.menuState.menuItems=this.getNamedRangeMenuItems()}getNamedRangeMenuItems(){let e=[];for(let{name:t,range:n}of this.env.model.getters.getNamedRanges()){let r={get highlights(){return[{range:n,color:Ae,noFill:!0}]}};e.push({name:t,execute:()=>{this.navigateToRange(n),this.stopEditingNamedRange()},description:e=>e.model.getters.getRangeString(n),icon:`o-spreadsheet-Icon.NAMED_RANGE`,onStartHover:e=>e.getStore(DE).register(r),onStopHover:e=>e.getStore(DE).unRegister(r)})}return this.menuState.searchedText&&(e=QM(this.menuState.searchedText,e,e=>e.name)),e.length>0&&(e.at(-1).separator=!0),this.env.isSmall||e.push({name:N(`Manage named ranges`),execute:()=>{this.sidePanelStore.open(`NamedRangesPanel`,{}),this.stopEditingNamedRange()},icon:`o-spreadsheet-Icon.COG`}),be(e)}stopEditingNamedRange(){this.menuState.searchedText=void 0,this.topBarToolStore.closeDropdowns(),this.DOMFocusableElementStore.focus()}navigateToRange(e){let{sheetId:t,zone:n}=e;if(this.env.model.getters.checkZonesExistInSheet(t,[n])!==`Success`){this.env.raiseError(N(`The range you specified is outside of the sheet.
176
176
 
177
- If you meant to create a named range, named range cannot have the same name as a cell reference. Please choose another name.`));return}let r=this.env.model.getters.getActiveSheetId();if(r!==t){if(!this.env.model.getters.getSheet(t).isVisible){this.env.notifyUser({text:N(`The sheet on which the range is defined is hidden.`),type:`info`,sticky:!1});return}this.env.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:r,sheetIdTo:t})}this.env.model.selection.selectCell(n.right,n.bottom,{allowsHiddenSelection:!0}),this.env.model.selection.selectZone({cell:{col:n.left,row:n.top},zone:n},{allowsHiddenSelection:!0})}get selectionKey(){return`${this.env.model.getters.getActiveSheetId()}-${or(this.selectedZone)}`}onInputFocused(){this.menuState.searchedText=void 0,this.openDropdown()}onInputBlur(){this.stopEditingNamedRange()}},$G=class extends O{add(e){return super.add(e,[])}addChild(e,t){if(!(e in this.content))throw Error(`${e} is not present in this registry!`);return this.content[e].push(t),this}replaceChild(e,t){if(!(e in this.content))throw Error(`${e} is not present in this registry!`);let n=this.content[e].findIndex(e=>e.name===t.name);return n!==-1&&(this.content[e][n]=t),this}removeChild(e,t){if(!(e in this.content))throw Error(`${e} is not present in this registry!`);let n=this.content[e].findIndex(e=>e.name===t);return n!==-1&&this.content[e].splice(n,1),this}getEntries(e){return this.content[e].sort((e,t)=>e.sequence-t.sequence)}getCategories(){return Object.keys(this.content)}};let eK=[[[`all`,`o-spreadsheet-Icon.BORDERS`],[`hv`,`o-spreadsheet-Icon.BORDER_HV`],[`h`,`o-spreadsheet-Icon.BORDER_H`],[`v`,`o-spreadsheet-Icon.BORDER_V`],[`external`,`o-spreadsheet-Icon.BORDER_EXTERNAL`]],[[`left`,`o-spreadsheet-Icon.BORDER_LEFT`],[`top`,`o-spreadsheet-Icon.BORDER_TOP`],[`right`,`o-spreadsheet-Icon.BORDER_RIGHT`],[`bottom`,`o-spreadsheet-Icon.BORDER_BOTTOM`],[`clear`,`o-spreadsheet-Icon.BORDER_CLEAR`]]];var tK=class extends k{static template=`o-spreadsheet-BorderEditor`;static components={ColorPickerWidget:DP,Popover:Fw};props=(0,t.useProps)({class:M.string().optional(),currentBorderColor:M.Color(),currentBorderStyle:M.BorderStyle(),currentBorderPosition:M.BorderPosition().optional(),onBorderColorPicked:M.function(),onBorderStylePicked:M.function(),onBorderPositionPicked:M.function(),maxHeight:M.Pixel().optional(),anchorRect:M.Rect()});BORDER_POSITIONS=eK;lineStyleButtonRef=t.signal.ref();borderStyles=Ct;state=(0,t.proxy)({activeTool:void 0});toggleDropdownTool(e){let t=this.state.activeTool===e;this.state.activeTool=t?void 0:e}closeDropdown(){this.state.activeTool=void 0}setBorderPosition(e){this.props.onBorderPositionPicked(e),this.closeDropdown()}setBorderColor(e){this.props.onBorderColorPicked(e),this.closeDropdown()}setBorderStyle(e){this.props.onBorderStylePicked(e),this.closeDropdown()}get lineStylePickerPopoverProps(){return{anchorRect:this.lineStylePickerAnchorRect,positioning:`bottom-left`,verticalOffset:0}}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:`bottom-left`,verticalOffset:0}}get lineStylePickerAnchorRect(){let e=this.lineStyleButtonRef();if(e===null)return{x:0,y:0,width:0,height:0};let t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}},nK=class extends k{static template=`o-spreadsheet-BorderEditorWidget`;static components={BorderEditor:tK};props=(0,t.useProps)({disabled:M.boolean().optional(),dropdownMaxHeight:M.Pixel().optional(),class:M.string().optional()});topBarToolStore;viewStore;borderEditorButtonRef=t.signal.ref();state=(0,t.proxy)({currentColor:et.color,currentStyle:et.style,currentPosition:void 0});setup(){this.topBarToolStore=ZG(),this.viewStore=A(W),(0,t.onWillUpdateProps)(()=>{this.isActive||(this.state.currentPosition=void 0)})}get dropdownMaxHeight(){return this.viewStore.sheetViewDimension.height}get borderEditorAnchorRect(){return y(this.borderEditorButtonRef())}onBorderPositionPicked(e){this.state.currentPosition=e,this.updateBorder()}onBorderColorPicked(e){this.state.currentColor=e,this.updateBorder()}onBorderStylePicked(e){this.state.currentStyle=e,this.updateBorder()}get isActive(){return this.topBarToolStore.isActive}toggleBorderEditor(){this.isActive?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}updateBorder(){this.state.currentPosition!==void 0&&this.env.model.dispatch(`SET_ZONE_BORDERS`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),border:{position:this.state.currentPosition,color:this.state.currentColor,style:this.state.currentStyle}})}},rK=class extends k{static template=`o-spreadsheet-PaintFormatButton`;props=(0,t.useProps)({class:M.string().optional()});paintFormatStore;setup(){this.paintFormatStore=A(kE)}get isActive(){return this.paintFormatStore.isActive}onDblClick(){this.paintFormatStore.activate({persistent:!0})}togglePaintFormat(){this.isActive?this.paintFormatStore.cancel():this.paintFormatStore.activate({persistent:!1})}},iK=class extends k{static template=`o-spreadsheet-TableDropdownButton`;static components={TableStylesPopover:RW,ActionButton:TP};props=(0,t.useProps)({class:M.string().optional()});topBarToolStore;sidePanelStore;state=(0,t.proxy)({popoverProps:void 0});setup(){this.topBarToolStore=ZG(),this.sidePanelStore=A(U)}onStylePicked(e){let t=this.env.model.getters.getActiveSheetId(),n={...this.tableConfig,styleId:e};if(CD(this.env,t,n).isSuccessful){let e=oO(this.env);e&&this.sidePanelStore.open(`TableSidePanel`,{table:e})}this.closePopover()}onClick(e){if(e.hasClosedTableStylesPopover||this.state.popoverProps){this.closePopover();return}let t=this.dynamicPivotIdInSelection;if(t){this.sidePanelStore.open(`PivotSidePanel`,{pivotId:t,openTab:`design`});return}let n=oO(this.env);if(n){this.topBarToolStore.closeDropdowns(),this.sidePanelStore.toggle(`TableSidePanel`,{table:n});return}let{left:r,bottom:i}=e.currentTarget.getBoundingClientRect();this.topBarToolStore.openDropdown(),this.state.popoverProps={anchorRect:{x:r,y:i,width:0,height:0},positioning:`bottom-left`,verticalOffset:0}}closePopover(){this.state.popoverProps=void 0}get action(){return this.dynamicPivotIdInSelection?{name:N(`Edit pivot style`),icon:`o-spreadsheet-Icon.EDIT_TABLE`}:{name:e=>oO(e)?N(`Edit table`):N(`Insert table`),icon:e=>oO(e)?`o-spreadsheet-Icon.EDIT_TABLE`:`o-spreadsheet-Icon.PAINT_TABLE`}}get tableConfig(){return{...ex,numberOfHeaders:1,bandedRows:!0}}get tableStyles(){return this.env.model.getters.getTableStyles()}get dynamicPivotIdInSelection(){let e=this.env.model.getters.getSelectedZones(),t=new Set(this.env.model.getters.getCellsWithTrackedFormula(`PIVOT`));if(t.size===0)return;let n=this.env.model.getters.getActiveSheetId();for(let r of e)for(let e of Cr(n,r)){let n=this.env.model.getters.getArrayFormulaSpreadingOn(e);if(!n)continue;let r=this.env.model.getters.getCell(n)?.id;if(r&&t.has(r)){let e=this.env.model.getters.getPivotIdFromPosition(n);if(e)return e}}}get class(){return`${this.props.class?this.props.class:``} ${this.env.model.getters.isCurrentSheetLocked()?`o-disabled`:``}`}},aK=class extends k{static components={ColorPickerWidget:DP};static template=`o-spreadsheet-ColorEditor`;props=(0,t.useProps)({class:M.string(),style:M.or([M.literal(`textColor`),M.literal(`fillColor`)]),icon:M.string(),title:M.string()});topBarToolStore;state=(0,t.proxy)({isOpen:!1});setup(){this.topBarToolStore=ZG()}get currentColor(){return this.env.model.getters.getCurrentStyle()[this.props.style]||(this.props.style===`textColor`?`#000000`:`#ffffff`)}setColor(e){if(this.props.style===`fillColor`&&this.isWholeSheetSelected()){let t=this.env.model.getters.getActiveSheetId();this.env.model.dispatch(`SET_BACKGROUND_FOR_ALL_CELLS`,{sheetId:t,color:e});return}TD(this.env.model,{[this.props.style]:e}),this.state.isOpen=!1}get isMenuOpen(){return this.topBarToolStore.isActive}onClick(){this.isMenuOpen?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}isWholeSheetSelected(){let e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSheetZone(e);return T(this.env.model.getters.getSelectedZone(),t)}},oK=class extends k{static template=`o-spreadsheet-DropdownAction`;static components={ActionButton:TP,Popover:Fw};props=(0,t.useProps)({parentAction:M.ActionSpec(),childActions:M.array(M.ActionSpec()),class:M.string(),childClass:M.string()});topBarToolStore;actionRef=t.signal.ref();setup(){this.topBarToolStore=ZG()}toggleDropdown(){this.isActive?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}get isActive(){return this.topBarToolStore.isActive}get popoverProps(){return{anchorRect:y(this.actionRef()),positioning:`bottom-left`,verticalOffset:0,class:`rounded`}}},sK=class extends k{static components={FontSizeEditor:kP};static template=`o-spreadsheet-TopBarFontSizeEditor`;props=(0,t.useProps)({class:M.string()});topBarToolStore;setup(){this.topBarToolStore=ZG()}get currentFontSize(){return this.env.model.getters.getCurrentStyle().fontSize||Qe}setFontSize(e){TD(this.env.model,{fontSize:e})}onToggle(){this.isActive?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}onFocusInput(){this.topBarToolStore.openDropdown()}get isActive(){return this.topBarToolStore.isActive}get class(){return`${this.props.class} ${this.env.model.getters.isCurrentSheetLocked()?`o-disabled`:``}`}},cK=class extends k{static template=`o-spreadsheet-NumberFormatsTool`;static components={MenuPopover:zw,ActionButton:TP};props=(0,t.useProps)({class:M.string()});formatNumberMenuItemSpec=yH;topBarToolStore;buttonRef=t.signal.ref();state=(0,t.proxy)({anchorRect:{x:0,y:0,width:0,height:0},menuItems:[]});setup(){this.topBarToolStore=ZG()}toggleMenu(){if(this.isActive)this.topBarToolStore.closeDropdowns();else{let e=we(this.formatNumberMenuItemSpec);this.state.menuItems=e.children(this.env).sort((e,t)=>e.sequence-t.sequence),this.state.anchorRect=b(this.buttonRef()),this.topBarToolStore.openDropdown()}}get isActive(){return this.topBarToolStore.isActive}},lK=class extends k{static template=`o-spreadsheet-TopBarZoom`;static components={NumberEditor:OP};props=(0,t.useProps)({class:M.string()});topBarToolStore;zoomStore;valueList=Ke;setup(){this.topBarToolStore=ZG(),this.zoomStore=A(Rg)}get currentFontSize(){return(this.zoomStore.zoomLevel||1)*100}setZoom(e){this.zoomStore.setZoom(e/100)}toggle(){this.topBarToolStore.isActive?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}onFocusInput(){this.topBarToolStore.openDropdown()}};let uK=new $G;uK.add(`edit`).addChild(`edit`,{name:`undo`,component:TP,props:{action:aA,class:`o-hoverable-button o-toolbar-button`},sequence:1}).addChild(`edit`,{name:`redo`,component:TP,props:{action:oA,class:`o-hoverable-button o-toolbar-button`},sequence:2}).addChild(`edit`,{name:`paintFormat`,component:rK,props:{class:`o-hoverable-button o-toolbar-button o-mobile-disabled`},sequence:3}).addChild(`edit`,{name:`clearFormat`,component:TP,props:{action:wj,class:`o-hoverable-button o-toolbar-button`},sequence:4}).addChild(`edit`,{name:`zoom`,component:lK,props:{class:`o-menu-item-button o-hoverable-button o-toolbar-button`},sequence:5}).add(`numberFormat`).addChild(`numberFormat`,{name:`formatPercent`,component:TP,props:{action:FA,class:`o-hoverable-button o-toolbar-button`},sequence:1}).addChild(`numberFormat`,{name:`decreaseDecimalPlaces`,component:TP,props:{action:YA,class:`o-hoverable-button o-toolbar-button`},sequence:2}).addChild(`numberFormat`,{name:`increaseDecimalPlaces`,component:TP,props:{action:JA,class:`o-hoverable-button o-toolbar-button`},sequence:3}).addChild(`numberFormat`,{name:`numberFormatsTool`,component:cK,props:{class:`o-menu-item-button o-hoverable-button o-toolbar-button`},sequence:4}).add(`fontSize`).addChild(`fontSize`,{name:`fontSizeEditor`,component:sK,props:{class:`o-hoverable-button o-toolbar-button`},sequence:3}).add(`textStyle`).addChild(`textStyle`,{name:`bold`,component:TP,props:{action:XA,class:`o-hoverable-button o-toolbar-button`},sequence:1}).addChild(`textStyle`,{name:`italic`,component:TP,props:{action:ZA,class:`o-hoverable-button o-toolbar-button`},sequence:2}).addChild(`textStyle`,{name:`strikethrough`,component:TP,props:{action:sj,class:`o-hoverable-button o-toolbar-button`},sequence:3}).addChild(`textStyle`,{name:`textColor`,component:aK,props:{class:`o-hoverable-button o-menu-item-button o-toolbar-button`,style:`textColor`,icon:`o-spreadsheet-Icon.TEXT_COLOR`,title:N(`Text Color`)},sequence:4}).add(`cellStyle`).addChild(`cellStyle`,{name:`fillColor`,component:aK,props:{class:`o-hoverable-button o-menu-item-button o-toolbar-button`,style:`fillColor`,icon:`o-spreadsheet-Icon.FILL_COLOR`,title:N(`Fill Color`)},sequence:1}).addChild(`cellStyle`,{name:`borderEditor`,component:nK,props:{class:`o-hoverable-button o-menu-item-button o-toolbar-button`},sequence:2}).addChild(`cellStyle`,{name:`mergeCells`,component:TP,props:{action:wA,class:`o-hoverable-button o-menu-item-button o-toolbar-button`},sequence:3}).add(`alignment`).addChild(`alignment`,{name:`alignmentHorizontal`,component:oK,props:{parentAction:uj,childActions:[dj,fj,pj],class:`o-hoverable-button o-toolbar-button`,childClass:`o-hoverable-button`},sequence:1}).addChild(`alignment`,{name:`alignmentVertical`,component:oK,props:{parentAction:mj,childActions:[hj,gj,_j],class:`o-hoverable-button o-menu-item-button o-toolbar-button`,childClass:`o-hoverable-button`},sequence:2}).addChild(`alignment`,{name:`formatWrapping`,component:oK,props:{parentAction:yj,childActions:[bj,xj,Sj],class:`o-hoverable-button o-menu-item-button o-toolbar-button`,childClass:`o-hoverable-button`},sequence:3}).addChild(`alignment`,{name:`formatRotation`,component:oK,props:{parentAction:$A,childActions:[nj,rj,ij,aj,oj],class:`o-hoverable-button o-menu-item-button o-toolbar-button`,childClass:`o-hoverable-button`},sequence:4}).add(`misc`).addChild(`misc`,{name:`tableDropdown`,component:iK,props:{class:`o-toolbar-button o-hoverable-button o-menu-item-button o-mobile-disabled`},sequence:1}).addChild(`misc`,{name:`createRemoveFilterTool`,component:TP,props:{action:Jk,class:`o-hoverable-button o-menu-item-button o-toolbar-button`},sequence:2});var dK=class extends k{static template=`o-spreadsheet-TopBar`;props=(0,t.useProps)({onClick:M.function(),dropdownMaxHeight:M.Pixel()});static components={MenuPopover:zw,TopBarComposer:YG,Popover:Fw,NamedRangeSelector:QG};toolsCategories=uK.getCategories();state=(0,t.proxy)({menuState:{isOpen:!1,anchorRect:null,menuItems:[]},invisibleToolsCategories:[],toolsPopoverState:{isOpen:!1}});isSelectingMenu=!1;openedEl=null;menus=[];toolbarMenuRegistry=uK;formatNumberMenuItemSpec=yH;isntToolbarMenu=!1;composerFocusStore;fingerprints;topBarToolStore;toolBarContainerRef=t.signal.ref();toolbarRef=t.signal.ref();namedRangesRef=t.signal.ref();topBarTopRef=t.signal.ref();moreToolsContainerRef=t.signal.ref();moreToolsButtonRef=t.signal.ref();spreadsheetRect=Nw();setup(){this.composerFocusStore=A(ni),this.fingerprints=A(VE),this.topBarToolStore=A(XG),(0,t.useListener)(window,`click`,this.onExternalClick.bind(this)),(0,t.useListener)(window,`keydown`,this.onKeydown.bind(this)),this.menus=bH.getMenuItems();let e,n=()=>{let t=this.spreadsheetRect.width;e!==t&&(e=t,this.state.toolsPopoverState.isOpen=!1,this.setVisibilityToolsGroups())};(0,t.onMounted)(n),(0,t.onPatched)(n)}setVisibilityToolsGroups(){if(this.env.model.getters.isReadonly())return;let e=[],t=this.toolbarRef(),n=this.toolBarContainerRef();if(!t||!n)return;let{x:r}=t.getBoundingClientRect(),{x:i}=n.getBoundingClientRect();this.moreToolsContainerRef()?.classList.remove(`d-none`);let a=this.moreToolsButtonRef()?.getBoundingClientRect().width||0,o=y(this.namedRangesRef()).width,s=Math.round(this.spreadsheetRect.width)-a-(r-i)-16-o,c=document.querySelectorAll(`.tool-container`),l=0;for(let t=0;t<c.length;t++){let n=c[t];n.classList.remove(`d-none`);let{width:r}=n.getBoundingClientRect();l+=r,l>s&&(n.classList.add(`d-none`),e.push(this.toolsCategories[t]))}this.state.invisibleToolsCategories=e,e.length||this.moreToolsContainerRef()?.classList.add(`d-none`)}get topbarComponents(){return nG.getAllOrdered().filter(e=>!e.isVisible||e.isVisible(this.env))}get currentFontSize(){return this.env.model.getters.getCurrentStyle().fontSize||Qe}onExternalClick(e){this.openedEl!==e.target&&this.closeMenus()}onKeydown(e){let t=ce(e,`code`),n=this.menus.find(e=>e.id===this.shortcutToMenuId[t]);if(n){e.preventDefault(),e.stopPropagation(),this.openMenu(n,this.getMenuItemEl(n.id));return}}shortcutToMenuId={"Alt+Shift+KeyF":`file`,"Alt+Shift+KeyE":`edit`,"Alt+Shift+KeyV":`view`,"Alt+Shift+KeyI":`insert`,"Alt+Shift+KeyO":`format`,"Alt+Shift+KeyD":`data`};onClick(){this.props.onClick(),this.closeMenus()}onMenuMouseOver(e,t){this.isSelectingMenu&&this.isntToolbarMenu&&this.openMenu(e,t.currentTarget)}toggleContextMenu(e,t){this.state.menuState.isOpen&&this.isntToolbarMenu?this.closeMenus():(this.openMenu(e,t.currentTarget),this.isntToolbarMenu=!0)}openMenu(e,t,n=!1){t&&(this.topBarToolStore.currentDropdown&&this.topBarToolStore.closeDropdowns(),this.state.toolsPopoverState.isOpen=!1,this.state.menuState.isOpen=!0,this.state.menuState.anchorRect=b(t),this.state.menuState.menuItems=e.children(this.env).sort((e,t)=>e.sequence-t.sequence),this.state.menuState.parentMenu=e,this.state.menuState.autoSelectFirstItem=n,this.isSelectingMenu=!0,this.openedEl=t,this.composerFocusStore.activeComposer.stopEdition())}closeMenus(){this.topBarToolStore.currentDropdown&&this.topBarToolStore.closeDropdowns(),this.state.toolsPopoverState.isOpen=!1,this.state.menuState.isOpen=!1,this.state.menuState.parentMenu=void 0,this.isSelectingMenu=!1,this.openedEl=null}getMenuName(e){return e.name(this.env)}setColor(e,t){TD(this.env.model,{[e]:t}),this.onClick()}setFontSize(e){TD(this.env.model,{fontSize:e})}toggleMoreTools(){this.topBarToolStore.currentDropdown&&this.topBarToolStore.closeDropdowns(),this.state.toolsPopoverState.isOpen=!this.state.toolsPopoverState.isOpen}get toolsPopoverProps(){let e=this.moreToolsButtonRef();return{anchorRect:e?b(e):{x:0,y:0,width:0,height:0},positioning:`bottom-left`,verticalOffset:0,class:`rounded`,maxWidth:300}}showDivider(e){return e<this.toolsCategories.length-1||this.state.invisibleToolsCategories.length>0}onKeyboardNavigation(e){let t=this.menus.findIndex(e=>e.id===this.state.menuState.parentMenu?.id||``);if(t!==-1)switch(e.key){case`ArrowLeft`:{let e=(t-1+this.menus.length)%this.menus.length,n=this.menus[e];this.openMenu(n,this.getMenuItemEl(n.id),!0);break}case`ArrowRight`:{let e=(t+1)%this.menus.length,n=this.menus[e];this.openMenu(n,this.getMenuItemEl(n.id),!0);break}case`Escape`:this.closeMenus();break}}getMenuItemEl(e){return this.topBarTopRef()?.querySelector(`[data-id="${e}"]`)||void 0}};function fK(){return new pK(navigator.clipboard)}var pK=class{clipboard;constructor(e){this.clipboard=e}async write(e){if(this.clipboard?.write)try{await this.clipboard?.write(this.getClipboardItems(e))}catch(t){console.log(`Failed to write on the clipboard, falling back to plain/html text. Error %s`,t);try{await this.clipboard?.write([new ClipboardItem({"text/plain":this.getBlob(e,`text/plain`),"text/html":this.getBlob(e,`text/html`)})])}catch{}}else await this.writeText(e[`text/plain`]??``)}async writeText(e){try{await this.clipboard?.writeText(e)}catch{}}async read(){let e;try{e=await navigator.permissions.query({name:`clipboard-read`})}catch{}if(this.clipboard?.read)try{let e=await this.clipboard.read(),t={};for(let n of e)for(let e of n.types){let r=await n.getType(e);L_.includes(e)?t[e]=r:t[e]=await r.text()}return{status:`ok`,content:t}}catch{return{status:e?.state===`denied`?`permissionDenied`:`notImplemented`}}else return{status:`ok`,content:{"text/plain":await this.clipboard?.readText()}}}getClipboardItems(e){let t={};for(let n of Object.keys(e))t[n]=this.getBlob(e,n);return[new ClipboardItem(t)]}getBlob(e,t){let n=e[t];return n instanceof Blob||n instanceof File?n:new Blob([e[t]||``],{type:t})}},mK=class extends k{static template=`o-spreadsheet-Spreadsheet`;props=(0,t.useProps)({model:M.Model(),notifyUser:M.function().optional(),raiseError:M.function().optional(),askConfirmation:M.function().optional()});static components={TopBar:dK,Grid:rP,BottomBar:DG,SmallBottomBar:LG,SidePanels:FG,SpreadsheetDashboard:OG,HeaderGroupContainer:MG,FullScreenFigure:cR,SpreadsheetPrint:JG};sidePanel;spreadsheetRef=t.signal.ref();spreadsheetRect=Nw();state=(0,t.proxy)({printModeEnabled:!1,colorThemeBeforePrint:`light`});_focusGrid;isViewportTooSmall=!1;notificationStore;composerFocusStore;viewStore;zoomStore;get model(){return this.props.model}getStyle(){let e={};return e[`--os-scrollbar-width`]=`${this.zoomStore.scrollBarWidth}px`,e[`--os-dark-mode-filter`]=Zf,e[`color-scheme`]=this.colorScheme,this.state.printModeEnabled?e.display=`block`:(this.env.model.getters.isDashboard()?e[`grid-template-rows`]=`auto`:e[`grid-template-rows`]=`min-content auto min-content`,e[`grid-template-columns`]=`auto ${this.sidePanel.mainPanel?`${this.sidePanel.totalPanelSize||350}px`:`auto`}`),G(e)}setup(){if(!(`isSmall`in this.env)){let e=NG();Wi({get isSmall(){return e.isSmall}})}let e=Yi();e.inject(Yr,this.model),this.viewStore=A(W),this.zoomStore=A(Rg),(0,t.providePlugins)([Mw],{getPopoverContainerRect:()=>y(this.spreadsheetRef())});let n=this.env;e.get(Hg).setSmallThreshhold(()=>n.isSmall),this.notificationStore=A(Vg),this.composerFocusStore=A(ni),this.sidePanel=A(U);for(let e of oG.getAll())A(e);let r=this.model.config.external.fileStore;Wi({model:this.model,imageProvider:r?new iG(r):void 0,loadCurrencies:this.model.config.external.loadCurrencies,loadLocales:this.model.config.external.loadLocales,clipboard:this.env.clipboard||fK(),startCellEdition:e=>this.composerFocusStore.focusActiveComposer({content:e}),notifyUser:e=>this.notificationStore.notifyUser(e),askConfirmation:(e,t,n)=>this.notificationStore.askConfirmation(e,t,n),raiseError:(e,t)=>this.notificationStore.raiseError(e,t),isMobile:_e,printSpreadsheet:this.enterPrintMode.bind(this)}),this.notificationStore.updateNotificationCallbacks({...this.props}),Vi(()=>{let e=this.spreadsheetRef();e&&!e.contains(document.activeElement)&&document.activeElement?.contains(e)&&this.focusGrid()}),(0,t.useListener)(window,`resize`,()=>vN(this,!0)),(0,t.useListener)(document.body,`wheel`,()=>{}),(0,t.useListener)(window,`keydown`,async e=>{ce(e)===`Ctrl+P`&&(this.enterPrintMode(),e.stopPropagation(),e.preventDefault())},{capture:!0}),(0,t.onWillUpdateProps)(e=>{if(e.model!==this.props.model)throw Error(`Changing the props model is not supported at the moment.`);(e.notifyUser!==this.props.notifyUser||e.askConfirmation!==this.props.askConfirmation||e.raiseError!==this.props.raiseError)&&this.notificationStore.updateNotificationCallbacks({...e})});let i=new ResizeObserver(()=>{this.sidePanel.changeSpreadsheetWidth(this.spreadsheetRect.width)});(0,t.useEffect)(()=>{let e=this.spreadsheetRef();if(e)return i.observe(e),()=>i.disconnect()});let a=Zt(()=>vN(this,!0));(0,t.onMounted)(()=>{this.bindModelEvents(),this.checkViewportSize(),e.on(`store-updated`,this,a)}),(0,t.onWillUnmount)(()=>{this.unbindModelEvents(),e.off(`store-updated`,this),oi()}),(0,t.onPatched)(()=>{this.checkViewportSize()})}bindModelEvents(){this.model.on(`update`,this,()=>vN(this,!0)),this.model.on(`command-rejected`,this,({result:e})=>{e.isCancelledBecause(`SheetLocked`)&&this.notificationStore.notifyUser({type:`info`,text:N(`This sheet is locked and cannot be modified. Please unlock it first.`),sticky:!1})})}unbindModelEvents(){this.model.off(`update`,this),this.model.off(`command-rejected`,this)}checkViewportSize(){let{xRatio:e,yRatio:t}=this.viewStore.viewports.getFrozenSheetViewRatio(this.viewStore.displayedSheetId);if(!(!isFinite(e)||!isFinite(t)))if(t>.85||e>.85){if(this.isViewportTooSmall)return;this.notificationStore.notifyUser({text:N(`The current window is too small to display this sheet properly. Consider resizing your browser window or adjusting frozen rows and columns.`),type:`warning`,sticky:!1}),this.isViewportTooSmall=!0}else this.isViewportTooSmall=!1}focusGrid(){this._focusGrid&&this._focusGrid()}get gridHeight(){return this.viewStore.sheetViewDimension.height}get gridContainerStyle(){let e=21*this.rowLayers.length,t=21*this.colLayers.length;return G({"grid-template-columns":`${e?e+2:0}px auto`,"grid-template-rows":`${t?t+2:0}px auto`,zoom:this.zoomStore.cssZoom})}get rowLayers(){let e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getVisibleGroupLayers(e,`ROW`)}get colLayers(){let e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getVisibleGroupLayers(e,`COL`)}getGridSize(){let e=this.spreadsheetRef();if(!e)return{width:0,height:0};let t=this.zoomStore.zoomLevel,n=this.zoomStore.scrollBarWidth,r=n=>e.querySelector(n)&&ee(e.querySelector(n),t).height||0,i=n=>e.querySelector(n)&&ee(e.querySelector(n),t).width||0,a=e.getBoundingClientRect(),o=r(`.o-spreadsheet-topbar-wrapper`),s=r(`.o-spreadsheet-bottombar-wrapper`),c=r(`.o-column-groups`),l=i(`.o-grid`),u=a.height-c-o-s;return{width:Math.max(l/t-n,0),height:Math.max(u/t-n,0)}}getSpreadSheetClasses(){return[this.env.isSmall?`o-spreadsheet-mobile`:``,this.props.model.getters.isDarkMode()?`dark`:``].join(` `)}enterPrintMode(){this.state.printModeEnabled||(this.state.colorThemeBeforePrint=this.props.model.getters.isDarkMode()?`dark`:`light`,this.env.model.dispatch(`UPDATE_COLOR_SCHEME`,{colorScheme:`light`}),this.state.printModeEnabled=!0)}exitPrintMode(){this.state.printModeEnabled&&(this.env.model.dispatch(`UPDATE_COLOR_SCHEME`,{colorScheme:this.state.colorThemeBeforePrint}),this.state.printModeEnabled=!1)}get colorScheme(){return this.state.printModeEnabled?this.state.colorThemeBeforePrint:this.props.model.getters.isDarkMode()?`dark`:`light`}},hK=class{getters;constructor(e){this.getters=e}squish(e){let t=[];for(let n of this.collectConsecutiveUpdateCellCommands(e))if(n[0].type===`UPDATE_CELL`&&n.length>1){let e=Object.groupBy(n,e=>e.sheetId),r=Object.values(e).reduce(this.sortAndSquishUpdateCellsBySheet.bind(this),[]);t.push(...r)}else t.push(...n);return t}unsquish(e){return[...new YR().unsquishCommands(e,this.getters)]}*collectConsecutiveUpdateCellCommands(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.type===`UPDATE_CELL`){let r=[n];for(let n=t+1;n<e.length;n++){let t=e[n];if(t.type===`UPDATE_CELL`)r.push(t);else break}yield r,t+=r.length-1}else yield[n]}}sortAndSquishUpdateCellsBySheet(e,t){if(t.sort((e,t)=>e.col===t.col?e.row-t.row:e.col-t.col),t.some((e,n)=>n>0&&t[n-1].col===e.col&&t[n-1].row===e.row))return e.push(...t),e;let n=new KR(this.getters),r=t.map(e=>({...e,content:n.squishCommand(e)}));for(let n=0;n<r.length;n++){let i=r[n],a={row:i.row,col:i.col},o=0;for(o=0;o+n+1<r.length;o++){let e=r[o+n+1],t={row:e.row,col:e.col};if(t.col!==a.col||t.row!==a.row+o+1||!this.compareUpdateCell(i,e))break}if(o>0){let t=`${E(a.col,a.row)}:${E(a.col,a.row+o)}`,r={type:`SQUISHED_UPDATE_CELL`,sheetId:i.sheetId,targetRange:t};`content`in i&&(r.content=i.content),`format`in i&&(r.format=i.format),`style`in i&&(r.style=i.style),e.push(r),n+=o}else e.push(t[n])}return e}compareUpdateCell(e,t){return T(e.content,t.content)&&T(e.format,t.format)&&T(e.style,t.style)}},gK=class{transportService;constructor(e){this.transportService=e}async sendMessage(e){(e.type===`CLIENT_JOINED`||e.type===`CLIENT_LEFT`||e.type===`CLIENT_MOVED`)&&await this.transportService.sendMessage(e)}onNewMessage(e,t){this.transportService.onNewMessage(e,t)}leave(e){this.transportService.leave(e)}};function _K(e){return QV.get(e.type)(e)}var vK=class e{buildTransformation;operations;constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){let t=this.operations.find(t=>t.id===e);if(!t)throw Error(`Operation ${e} not found`);return t}getLastOperationId(){return this.operations[this.operations.length-1]?.id}getFirstOperationAmong(e,t){for(let n of this.operations){if(n.id===e)return e;if(n.id===t)return t}throw Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find(t=>t.id===e)}prepend(e){let t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map(e=>e.transformed(t))]}insert(e,t){let n=this.buildTransformation.with(e.data),{before:r,operation:i,after:a}=this.locateOperation(t);this.operations=[...r,i,e,...a.map(e=>e.transformed(n))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(t){let{after:n}=this.locateOperation(t);return new e(this.buildTransformation,n)}transform(e){this.operations=this.operations.map(t=>t.transformed(e))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){let{before:t,operation:n}=this.locateOperation(e);this.operations=t.concat([n])}locateOperation(e){let t=this.operations.findIndex(t=>t.id===e);if(t===-1)throw Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}},yK=class{id;data;constructor(e,t){this.id=e,this.data=t}transformed(e){return new bK(this.id,en(()=>e(this.data)))}},bK=class e{id;lazyData;constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(t){return new e(this.id,this.lazyData.map(t))}},xK=class e{operations;constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(t){function*n(e,t){for(let n of e)if(yield n,n.operation.id===t)return}return new e(n(this.operations,t))}stopBefore(t){function*n(e,t){for(let n of e){if(n.operation.id===t)return;yield n}}return new e(n(this.operations,t))}startAfter(t){function*n(e,t){let n=!0;for(let r of e)n||(yield r),r.operation.id===t&&(n=!1)}return new e(n(this.operations,t))}},SK=class{buildTransformation;branches;branchingOperationIds=new Map;constructor(e,t){this.buildTransformation=e,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new xK(Lt(this._execution(e),this._execution(e)))}revertedExecution(e){return new xK(Lt(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){let n=e.getLastOperationId()||this.previousBranch(e)?.getLastOperationId();e.append(t),n&&this.insertPrevious(e,t,n)}insertOperationAfter(e,t,n){e.insert(t,n),this.updateNextWith(e,t,n),this.insertPrevious(e,t,n)}undo(e,t){let n=this.buildTransformation.without(t.data),r=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);let i=e.fork(t.id);r&&this.branchingOperationIds.set(i,r),this.insertBranchAfter(e,i),this.transform(i,n)}redo(e){let t=this.nextBranch(e);if(!t)return;let n=this.nextBranch(t);this.removeBranchFromTree(t);let r=this.branchingOperationIds.get(t);r?this.branchingOperationIds.set(e,r):this.branchingOperationIds.delete(e),n&&this.rebaseUp(n)}drop(e){for(let t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(let n of this.revertedExecution(e))if(n.operation.id===t)return n;throw Error(`Operation ${t} not found`)}rebaseUp(e){let{previousBranch:t,branchingOperation:n}=this.findPreviousBranchingOperation(e);if(!t||!n)return;let r=this.buildTransformation.without(n.data),i=t.fork(n.id);this.branchingOperationIds.set(i,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,i),i.transform(r);let a=this.nextBranch(i);a&&this.rebaseUp(a)}removeBranchFromTree(e){let t=this.branches.findIndex(t=>t===e);this.branches.splice(t,1)}insertBranchAfter(e,t){let n=this.branches.findIndex(t=>t===e);this.branches.splice(n+1,0,t)}updateNextWith(e,t,n){let r=this.branchingOperationIds.get(e),i=this.nextBranch(e);if(!(!r||!i))if(e.getFirstOperationAmong(n,r)===r){let a=this.addToNextBranch(e,i,r,t,n);this.updateNextWith(i,a,n)}else{let e=this.buildTransformation.with(t.data);this.transform(i,e)}}addToNextBranch(e,t,n,r,i){let a=r;return i===n?(a=this.getTransformedOperation(e,n,r),t.prepend(a)):t.contains(i)?(a=this.getTransformedOperation(e,n,r),t.insert(a,i)):t.append(r),a}getTransformedOperation(e,t,n){let r=e.getOperation(t),i=this.buildTransformation.without(r.data);return n.transformed(i)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);let n=this.nextBranch(e);n&&this.transform(n,t)}insertPrevious(e,t,n){let{previousBranch:r,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!r||!i)return;let a=this.buildTransformation.with(i.data),o=e.fork(n);o.transform(a),r.cutAfter(n),r.appendBranch(o);let s=t.transformed(a);this.insertPrevious(r,s,n)}findPreviousBranchingOperation(e){let t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};let n=this.branchingOperationIds.get(t);return n?{previousBranch:t,branchingOperation:t.getOperation(n)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){let t=this.branches.findIndex(t=>t===e);if(t!==-1)return this.branches[t+1]}previousBranch(e){let t=this.branches.findIndex(t=>t===e);if(t!==-1)return this.branches[t-1]}*_revertedExecution(e){let t=this.branchingOperationIds.get(e),n=!!t,r=e.getOperations();for(let i=r.length-1;i>=0;i--){let a=r[i];a.id===t&&(n=!1),n||(yield{operation:a,branch:e,isCancelled:!this.shouldExecute(e,a)})}let i=this.previousBranch(e);yield*i?this._revertedExecution(i):[]}*_execution(e){for(let t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){let t=this.nextBranch(e);yield*t?this._execution(t):[];return}if(!this.branchingOperationIds.get(e)){let t=this.nextBranch(e);yield*t?this._execution(t):[]}}},CK=class{HEAD_BRANCH;HEAD_OPERATION;tree;applyOperation;revertOperation;buildEmpty;buildTransformation;constructor(e){this.applyOperation=e.applyOperation,this.revertOperation=e.revertOperation,this.buildEmpty=e.buildEmpty,this.buildTransformation=e.buildTransformation,this.HEAD_BRANCH=new vK(this.buildTransformation),this.tree=new SK(this.buildTransformation,this.HEAD_BRANCH);let t=e.initialOperationId,n=new yK(t,this.buildEmpty(t));this.tree.insertOperationLast(this.HEAD_BRANCH,n),this.HEAD_OPERATION=n}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){let n=new yK(e,t),r=this.tree.getLastBranch();this.tree.insertOperationLast(r,n),this.HEAD_BRANCH=r,this.HEAD_OPERATION=n}insert(e,t,n){let r=new yK(e,t);this.revertTo(n),this.tree.insertOperationAfter(this.HEAD_BRANCH,r,n),this.fastForward()}undo(e,t,n){let{branch:r,operation:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(r,i),this.fastForward(),this.insert(t,this.buildEmpty(t),n)}redo(e,t,n){let{branch:r}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(r),this.fastForward(),this.insert(t,this.buildEmpty(t),n)}rebase(e){let t=this.get(e),n=[...this.tree.execution(this.HEAD_BRANCH).startAfter(e)];this.revertBefore(e);let r=this.HEAD_OPERATION.id;this.tree.drop(e),this.insert(e,t,r);for(let{operation:e}of n)this.insert(e.id,e.data,this.HEAD_OPERATION.id)}revertBefore(e){let t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){let t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(let{next:t,operation:n,isCancelled:r}of e)r||this.revertOperation(n.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){let e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(let{operation:t,branch:n,isCancelled:r}of e)r||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=n}};function wK(e){return new CK({initialOperationId:e.initialRevisionId,applyOperation:t=>{let n=t.commands.slice(),{changes:r}=e.recordChanges(()=>{for(let t of n)e.dispatch(t)});t.setChanges(r)},revertOperation:e=>TK([e]),buildEmpty:e=>new vV(e,`empty`,[]),buildTransformation:{with:e=>t=>new vV(t.id,t.clientId,lV(t.commands,e.commands),t.rootCommand,void 0,t.timestamp),without:e=>t=>new vV(t.id,t.clientId,lV(t.commands,e.commands.map(_K).flat()),t.rootCommand,void 0,t.timestamp)}})}function TK(e){for(let t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){let n=t.changes[e];EK(n)}}function EK(e){let t=e.target,n=e.key,r=e.before;r===void 0?delete t[n]:t[n]=r}var DK=class{providers=[];static getters=[`getAllFormulas`];addFormulaProvider(e){this.providers.push(e)}getAllFormulas(){return this.providers.flatMap(e=>e())}},OK=class{getters;providers=[];isAdaptingRanges=!1;constructor(e){this.getters=e}static getters=[`copyFormulaStringForSheet`,`extendRange`,`getRangeString`,`getRangeFromSheetXC`,`clipRangesToSheet`,`clipRangeToSheet`,`createAdaptedRanges`,`getRangeData`,`getRangeDataFromXc`,`getRangeDataFromZone`,`getRangeFromRangeData`,`getRangeFromZone`,`getRangesUnion`,`recomputeRanges`,`isRangeValid`,`removeRangesSheetPrefix`];allowDispatch(e){return e.type===`MOVE_RANGES`?e.target.length===1?`Success`:`InvalidZones`:`Success`}beforeHandle(e){}handle(e){if(this.isAdaptingRanges)throw Error(`Plugins cannot dispatch commands during adaptRanges phase`);let t=NB(e);t&&this.executeOnAllRanges(t)}finalize(){}executeOnAllRanges(e){this.isAdaptingRanges=!0;for(let t of this.providers)t(e);this.isAdaptingRanges=!1}addRangeProvider(e){this.providers.push(e)}clipRangeToSheet(e){if(e.invalidXc)return e;let t=this.getters.getSheetZone(e.sheetId);if(vr(e.zone,t))return e;let n=pr(e.zone,t);if(n)return this.getters.getRangeFromZone(e.sheetId,n)}clipRangesToSheet(e){let t=[];for(let n of e){let e=this.clipRangeToSheet(n);e&&t.push(e)}return t}createAdaptedRanges(e,t,n,r){return e.map(e=>{if(!ir(e.zone))return e;let i=e.prefixSheet?e.sheetId:r,a=Ou(e),o=Du(e),s={...e.unboundedZone,left:a&&!e.unboundedZone.hasHeader?e.unboundedZone.left:e.unboundedZone.left+(e.parts[0].colFixed?0:t),right:a?e.unboundedZone.right:e.unboundedZone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:o&&!e.unboundedZone.hasHeader?e.unboundedZone.top:e.unboundedZone.top+(e.parts[0].rowFixed?0:n),bottom:o?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:n)};return Fu(wu({...e,sheetId:i,zone:s},this.getters.getSheetSize))})}removeRangesSheetPrefix(e,t){return t.map(t=>t.prefixSheet&&t.sheetId===e?{...t,prefixSheet:!1}:t)}extendRange(e,t,n){let r=t===`COL`?e.zone.right+n:e.zone.right,i=t===`ROW`?e.zone.bottom+n:e.zone.bottom,a={left:e.zone.left,top:e.zone.top,right:Ou(e)?void 0:r,bottom:Du(e)?void 0:i};return wu({...e,zone:a},this.getters.getSheetSize)}getRangeFromSheetXC(e,t){if(!vl.test(t))return Eu(t);let{sheetName:n}=wl(t),r=this.getters.getSheetIdByName(n)||e;return!r||!this.getters.tryGetSheet(r)?Eu(t):Tu({xc:t,sheetId:r,invalidSheetName:n&&!this.getters.getSheetIdByName(n)?n:void 0},this.getters.getSheetSize)}getRangeString(e,t,n={useBoundedReference:!1,useFixedReference:!1}){return e?e.invalidXc?e.invalidXc:this.getters.tryGetSheet(e.sheetId)?ku(e,t,this.getters.getSheetName,n):P.InvalidReference:P.InvalidReference}getRangeDataFromXc(e,t){let n=this.getters.getRangeFromSheetXC(e,t);return this.getRangeDataFromZone(n.sheetId,n.unboundedZone)}getRangeDataFromZone(e,t){return t=this.getters.getUnboundedZone(e,t),{_sheetId:e,_zone:t}}getRangeData(e){return this.getRangeDataFromZone(e.sheetId,e.unboundedZone)}getRangeFromZone(e,t){return wu({sheetId:e,zone:t,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}],prefixSheet:!1},this.getters.getSheetSize)}recomputeRanges(e,t){return Wn(e.map(e=>e.unboundedZone),t.map(e=>e.unboundedZone)).map(t=>this.getRangeFromZone(e[0].sheetId,t))}getRangeFromRangeData(e){return this.getters.tryGetSheet(e._sheetId)?wu({prefixSheet:!1,zone:e._zone,sheetId:e._sheetId,invalidSheetName:void 0,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}]},this.getters.getSheetSize):Eu(P.InvalidReference)}isRangeValid(e){if(!e)return!1;let{xc:t,sheetName:n}=wl(e);return t.match(vl)!==null&&(!n||this.getters.getSheetIdByName(n)!==void 0)}getRangesUnion(e){let t=fr(...e.map(e=>e.unboundedZone));return this.getRangeFromZone(e[0].sheetId,t)}copyFormulaStringForSheet(e,t,n,r){if(!n.startsWith(`=`))return n;let i=yd.Compile(n,e,this.getters),a=i.rangeDependencies.map(n=>r===`keepSameReference`?n:Au(e,t,n));return yd.CopyWithDependencies(i,t,a).toFormulaString(this.getters)}},kK=class{observers=new Map;defaultSubscription;mainSubscription;registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||=this.defaultSubscription}observe(e,t){this.observers.set(e,{owner:e,callbacks:t})}unobserve(e){this.observers.delete(e)}capture(e,t){if(this.observers.get(e))throw Error(`You are already subscribed forever`);this.mainSubscription?.owner&&this.mainSubscription.owner!==e&&this.mainSubscription.callbacks.release?.(),this.mainSubscription={owner:e,callbacks:t}}release(e){this.mainSubscription?.owner!==e||this.observers.get(e)||(this.mainSubscription=this.defaultSubscription)}getBackToDefault(){this.mainSubscription!==this.defaultSubscription&&(this.mainSubscription?.callbacks.release?.(),this.mainSubscription=this.defaultSubscription)}isListening(e){return this.mainSubscription?.owner===e}send(e){this.mainSubscription?.callbacks.handleEvent(e),this.observers.forEach(t=>t.callbacks.handleEvent(e))}},AK=class{getters;stream;anchor;defaultAnchor;constructor(e){this.getters=e,this.stream=new kK,this.anchor={cell:{col:0,row:0},zone:D({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,n){this.stream.capture(e,n),this.anchor=t}registerAsDefault(e,t,n){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,n),this.defaultAnchor=t,this.capture(e,t,n)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}unobserve(e){this.stream.unobserve(e)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}modifyAnchor(e,t,n){let r=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(r,e.zone)},this.processEvent({options:n,anchor:e,mode:t})}selectZone(e,t={scrollIntoView:!0}){return this.modifyAnchor(e,`overrideSelection`,t)}selectCell(e,t,n){let r=D({col:e,row:t});return this.selectZone({zone:r,cell:{col:e,row:t}},{scrollIntoView:!0,...n})}moveAnchorCell(e,t=1){if(t!==`end`&&t<=0)return new Jd(`InvalidSelectionStep`);let{col:n,row:r}=this.getNextAvailablePosition(e,t);return this.selectCell(n,r)}updateAnchorCell(e,t,n={scrollIntoView:!0}){return this.processEvent({mode:`updateAnchor`,anchor:{zone:this.anchor.zone,cell:{col:e,row:t}},options:n})}setAnchorCorner(e,t){let n=this.getters.getActiveSheetId(),{col:r,row:i}=this.anchor.cell,a={left:Math.min(r,e),top:Math.min(i,t),right:Math.max(r,e),bottom:Math.max(i,t)},o=this.getters.expandZone(n,a);if(mr(this.anchor.zone,o))return new Jd(`NoChanges`);let s={zone:o,cell:{col:r,row:i}};return this.processEvent({mode:`updateAnchor`,anchor:s,options:{scrollIntoView:!1}})}addCellToSelection(e,t){let n=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:n,col:e,row:t}));let r=this.getters.expandZone(n,D({col:e,row:t}));return this.processEvent({options:{scrollIntoView:!0},anchor:{zone:r,cell:{col:e,row:t}},mode:`newAnchor`})}commitSelection(){return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:this.anchor,mode:`commitSelection`})}resizeAnchorZone(e,t=1){if(t!==`end`&&t<=0)return new Jd(`InvalidSelectionStep`);let n=this.getters.getActiveSheetId(),r=this.anchor,{col:i,row:a}=r.cell,{left:o,right:s,top:c,bottom:l}=r.zone,u=this.getStartingPosition(e),[d,f]=this.deltaToTarget(u,e,t);if(d===0&&f===0)return Jd.Success;let p=r.zone,m=e=>{e=wr(e);let{left:t,right:r,top:i,bottom:a}=this.getters.expandZone(n,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(n)-1,r),top:Math.max(0,i),bottom:Math.min(this.getters.getNumberRows(n)-1,a)}},{cell:h,zone:g}=this.getReferenceAnchor(),{col:_,row:v}=h,ee=0;for(;p!==null;){if(ee++,d<0){let e=this.getNextAvailableCol(d,s-(ee-1),v);p=g.right<=s-ee?m({top:c,left:o,bottom:l,right:e}):null}if(d>0){let e=this.getNextAvailableCol(d,o+(ee-1),v);p=o+ee<=g.left?m({top:c,left:e,bottom:l,right:s}):null}if(f<0){let e=this.getNextAvailableRow(f,_,l-(ee-1));p=g.bottom<=l-ee?m({top:c,left:o,bottom:e,right:s}):null}if(f>0){let e=this.getNextAvailableRow(f,_,c+(ee-1));p=c+ee<=g.top?m({top:e,left:o,bottom:l,right:s}):null}if(p&&=wr(p),p&&!mr(p,r.zone))return this.processEvent({options:{scrollIntoView:!0},mode:`updateAnchor`,anchor:{zone:p,cell:{col:i,row:a}}})}p=m(dr({top:a,bottom:a,left:i,right:i},wr({top:this.getNextAvailableRow(f,_,c),left:this.getNextAvailableCol(d,o,v),bottom:this.getNextAvailableRow(f,_,l),right:this.getNextAvailableCol(d,s,v)})));let y={zone:p,cell:{col:i,row:a}};return this.processEvent({anchor:y,mode:`updateAnchor`,options:{scrollIntoView:!0}})}selectColumn(e,t){let n=this.getters.getActiveSheetId(),r=this.getters.getNumberRows(n)-1,i={left:e,right:e,top:0,bottom:r},a=this.getters.findFirstVisibleColRowIndex(n,`ROW`),o,s;switch(t){case`overrideSelection`:case`newAnchor`:o=e,s=a;break;case`updateAnchor`:({col:o,row:s}=this.anchor.cell),i=dr(i,{left:o,right:o,top:a,bottom:r});break}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:i,cell:{col:o,row:s}},mode:t})}selectRow(e,t){let n=this.getters.getActiveSheetId(),r=this.getters.getNumberCols(n)-1,i={top:e,bottom:e,left:0,right:r},a=this.getters.findFirstVisibleColRowIndex(n,`COL`),o,s;switch(t){case`overrideSelection`:case`newAnchor`:o=a,s=e;break;case`updateAnchor`:({col:o,row:s}=this.anchor.cell),i=dr(i,{left:a,right:r,top:s,bottom:s});break}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:i,cell:{col:o,row:s}},mode:t})}loopSelection(){let e=this.getters.getActiveSheetId(),t=this.anchor;if(mr(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:D(t.cell)},`updateAnchor`,{scrollIntoView:!1});let n=this.getters.getContiguousZone(e,t.zone);return T(n,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:n},`updateAnchor`,{scrollIntoView:!1})}selectTableAroundSelection(){let e=this.getters.getActiveSheetId(),t=this.getters.getContiguousZone(e,this.anchor.zone);return this.modifyAnchor({...this.anchor,zone:t},`updateAnchor`,{scrollIntoView:!1})}selectAll(){let e=this.getters.getActiveSheetId(),t={left:0,top:0,bottom:this.getters.getNumberRows(e)-1,right:this.getters.getNumberCols(e)-1};return this.processEvent({mode:`overrideSelection`,anchor:{zone:t,cell:this.anchor.cell},options:{scrollIntoView:!1}})}isListening(e){return this.stream.isListening(e)}processEvent(e){let t={...e,previousAnchor:x(this.anchor)},n=this.checkEventAnchorZone(t);return n===`Success`?(this.anchor=t.anchor,this.stream.send(t),Jd.Success):new Jd(n)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor,e.options)}checkAnchorZone(e,t){let{cell:n,zone:r}=e;if(!_r(n.col,n.row,r))return`InvalidAnchorZone`;let{left:i,right:a,top:o,bottom:s}=r,c=this.getters.getActiveSheetId();if(t?.allowsHiddenSelection){let e=this.getters.getNumberCols(c),t=this.getters.getNumberRows(c);if(i<0||a>e-1||o<0||s>t-1)return`SelectionOutOfBound`}else{let e=this.getters.findVisibleHeader(c,`COL`,i,a);if(this.getters.findVisibleHeader(c,`ROW`,o,s)===void 0||e===void 0)return`SelectionOutOfBound`}return`Success`}checkAnchorZoneOrThrow(e){if(this.checkAnchorZone(e)===`InvalidAnchorZone`)throw Error(`The provided anchor is invalid. The cell must be part of the zone.`)}getNextAvailablePosition(e,t=1){let{col:n,row:r}=this.anchor.cell,i=this.deltaToTarget({col:n,row:r},e,t);return{col:this.getNextAvailableCol(i[0],n,r),row:this.getNextAvailableRow(i[1],n,r)}}getNextAvailableCol(e,t,n){let r=this.getters.getActiveSheetId(),i={col:t,row:n};return this.getNextAvailableHeader(e,`COL`,t,i,e=>this.getters.isInSameMerge(r,t,n,e,n))}getNextAvailableRow(e,t,n){let r=this.getters.getActiveSheetId(),i={col:t,row:n};return this.getNextAvailableHeader(e,`ROW`,n,i,e=>this.getters.isInSameMerge(r,t,n,t,e))}getNextAvailableHeader(e,t,n,r,i){let a=this.getters.getActiveSheetId();if(e===0)return n;let o=Math.sign(e),s=n+e;for(;i(s);)s+=o;for(;this.getters.isHeaderHidden(a,t,s);)s+=o;return s<0||s>this.getters.getNumberHeaders(a,t)-1?this.getters.isHeaderHidden(a,t,n)?this.getNextAvailableHeader(-o,t,n,r,i):n:s}getReferenceAnchor(){let e=this.getters.getActiveSheetId(),t=this.anchor,{left:n,right:r,top:i,bottom:a}=t.zone,{col:o,row:s}=t.cell,c=this.getters.isColHidden(e,o)&&this.getters.findVisibleHeader(e,`COL`,n,r)||o,l=this.getters.isRowHidden(e,s)&&this.getters.findVisibleHeader(e,`ROW`,i,a)||s,u=this.getters.expandZone(e,{left:c,right:c,top:l,bottom:l});return{cell:{col:c,row:l},zone:u}}deltaToTarget(e,t,n){switch(t){case`up`:return n===`end`?[0,this.getEndOfCluster(e,`rows`,-1)-e.row]:[0,-n];case`down`:return n===`end`?[0,this.getEndOfCluster(e,`rows`,1)-e.row]:[0,n];case`left`:return n===`end`?[this.getEndOfCluster(e,`cols`,-1)-e.col,0]:[-n,0];case`right`:return n===`end`?[this.getEndOfCluster(e,`cols`,1)-e.col,0]:[n,0]}}getStartingPosition(e){let{col:t,row:n}=this.getPosition(),r=this.anchor.zone;switch(e){case`down`:case`up`:n=n===r.top?r.bottom:r.top;break;case`left`:case`right`:t=t===r.right?r.left:r.right;break}return{col:t,row:n}}getEndOfCluster(e,t,n){let r=this.getters.getActiveSheetId(),i=e,a=this.getNextCellPosition(e,t,n),o=!this.isCellSkippableInCluster({...i,sheetId:r})&&!this.isCellSkippableInCluster({...a,sheetId:r})?`endOfCluster`:`nextCluster`;for(;;){let e=this.getNextCellPosition(i,t,n);if(i.col===e.col&&i.row===e.row)break;let a=this.isCellSkippableInCluster({...e,sheetId:r});if(o===`endOfCluster`&&a)break;if(o===`nextCluster`&&!a){i=e;break}i=e}return t===`cols`?i.col:i.row}getNextCellPosition(e,t,n){let r=t===`cols`?`col`:`row`,i={...e};return i[r]=t===`cols`?this.getNextAvailableCol(n,i.col,i.row):this.getNextAvailableRow(n,i.col,i.row),{col:i.col,row:i.row}}getPosition(){return{...this.anchor.cell}}isCellSkippableInCluster(e){let t=this.getters.getMainCellPosition(e),n=this.getters.getEvaluatedCell(t);return n.type===`empty`||n.type===`text`&&n.value===``}};function jK(e){if(typeof e==`string`)return{};if(typeof e==`number`)return[];throw Error(`Cannot create new node`)}var MK=class{changes;commands=[];recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){let t=e.pop(),n=e[0],r=e.at(-1),i=e.length-2;for(let t=1;t<=i;t++){let r=e[t];if(n[r]===void 0){let i=e[t+1];n[r]=jK(i)}n=n[r]}n[r]!==t&&(this.changes?.push({key:r,target:n,before:n[r]}),t===void 0?delete n[r]:n[r]=t)}};let NK=17781237,PK=17781238,FK=88853993,IK=88853994;function LK(e,t,n){let r=[[`xmlns:r`,am],[`xmlns:a`,tm],[`xmlns:c`,nm]],i=RK({backgroundColor:e.data.backgroundColor,line:{color:`000000`}}),a=X``;if(e.data.title?.text){let t=e.data.title.color?ZP(e.data.title.color):ZP(Tm(e.data.backgroundColor)),n=e.data.title.fontSize??16;a=X`
177
+ If you meant to create a named range, named range cannot have the same name as a cell reference. Please choose another name.`));return}let r=this.env.model.getters.getActiveSheetId();if(r!==t){if(!this.env.model.getters.getSheet(t).isVisible){this.env.notifyUser({text:N(`The sheet on which the range is defined is hidden.`),type:`info`,sticky:!1});return}this.env.model.dispatch(`ACTIVATE_SHEET`,{sheetIdFrom:r,sheetIdTo:t})}this.env.model.selection.selectCell(n.right,n.bottom,{allowsHiddenSelection:!0}),this.env.model.selection.selectZone({cell:{col:n.left,row:n.top},zone:n},{allowsHiddenSelection:!0})}get selectionKey(){return`${this.env.model.getters.getActiveSheetId()}-${or(this.selectedZone)}`}onInputFocused(){this.menuState.searchedText=void 0,this.openDropdown()}onInputBlur(){this.stopEditingNamedRange()}},$G=class extends O{add(e){return super.add(e,[])}addChild(e,t){if(!(e in this.content))throw Error(`${e} is not present in this registry!`);return this.content[e].push(t),this}replaceChild(e,t){if(!(e in this.content))throw Error(`${e} is not present in this registry!`);let n=this.content[e].findIndex(e=>e.name===t.name);return n!==-1&&(this.content[e][n]=t),this}removeChild(e,t){if(!(e in this.content))throw Error(`${e} is not present in this registry!`);let n=this.content[e].findIndex(e=>e.name===t);return n!==-1&&this.content[e].splice(n,1),this}getEntries(e){return this.content[e].sort((e,t)=>e.sequence-t.sequence)}getCategories(){return Object.keys(this.content)}};let eK=[[[`all`,`o-spreadsheet-Icon.BORDERS`],[`hv`,`o-spreadsheet-Icon.BORDER_HV`],[`h`,`o-spreadsheet-Icon.BORDER_H`],[`v`,`o-spreadsheet-Icon.BORDER_V`],[`external`,`o-spreadsheet-Icon.BORDER_EXTERNAL`]],[[`left`,`o-spreadsheet-Icon.BORDER_LEFT`],[`top`,`o-spreadsheet-Icon.BORDER_TOP`],[`right`,`o-spreadsheet-Icon.BORDER_RIGHT`],[`bottom`,`o-spreadsheet-Icon.BORDER_BOTTOM`],[`clear`,`o-spreadsheet-Icon.BORDER_CLEAR`]]];var tK=class extends k{static template=`o-spreadsheet-BorderEditor`;static components={ColorPickerWidget:DP,Popover:Fw};props=(0,t.useProps)({class:M.string().optional(),currentBorderColor:M.Color(),currentBorderStyle:M.BorderStyle(),currentBorderPosition:M.BorderPosition().optional(),onBorderColorPicked:M.function(),onBorderStylePicked:M.function(),onBorderPositionPicked:M.function(),maxHeight:M.Pixel().optional(),anchorRect:M.Rect()});BORDER_POSITIONS=eK;lineStyleButtonRef=t.signal.ref();borderStyles=Ct;state=(0,t.proxy)({activeTool:void 0});toggleDropdownTool(e){let t=this.state.activeTool===e;this.state.activeTool=t?void 0:e}closeDropdown(){this.state.activeTool=void 0}setBorderPosition(e){this.props.onBorderPositionPicked(e),this.closeDropdown()}setBorderColor(e){this.props.onBorderColorPicked(e),this.closeDropdown()}setBorderStyle(e){this.props.onBorderStylePicked(e),this.closeDropdown()}get lineStylePickerPopoverProps(){return{anchorRect:this.lineStylePickerAnchorRect,positioning:`bottom-left`,verticalOffset:0}}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:`bottom-left`,verticalOffset:0}}get lineStylePickerAnchorRect(){let e=this.lineStyleButtonRef();if(e===null)return{x:0,y:0,width:0,height:0};let t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}},nK=class extends k{static template=`o-spreadsheet-BorderEditorWidget`;static components={BorderEditor:tK};props=(0,t.useProps)({disabled:M.boolean().optional(),dropdownMaxHeight:M.Pixel().optional(),class:M.string().optional()});topBarToolStore;viewStore;borderEditorButtonRef=t.signal.ref();state=(0,t.proxy)({currentColor:et.color,currentStyle:et.style,currentPosition:void 0});setup(){this.topBarToolStore=ZG(),this.viewStore=A(W),(0,t.onWillUpdateProps)(()=>{this.isActive||(this.state.currentPosition=void 0)})}get dropdownMaxHeight(){return this.viewStore.sheetViewDimension.height}get borderEditorAnchorRect(){return y(this.borderEditorButtonRef())}onBorderPositionPicked(e){this.state.currentPosition=e,this.updateBorder()}onBorderColorPicked(e){this.state.currentColor=e,this.updateBorder()}onBorderStylePicked(e){this.state.currentStyle=e,this.updateBorder()}get isActive(){return this.topBarToolStore.isActive}toggleBorderEditor(){this.isActive?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}updateBorder(){this.state.currentPosition!==void 0&&this.env.model.dispatch(`SET_ZONE_BORDERS`,{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),border:{position:this.state.currentPosition,color:this.state.currentColor,style:this.state.currentStyle}})}},rK=class extends k{static template=`o-spreadsheet-PaintFormatButton`;props=(0,t.useProps)({class:M.string().optional()});paintFormatStore;setup(){this.paintFormatStore=A(kE)}get isActive(){return this.paintFormatStore.isActive}onDblClick(){this.paintFormatStore.activate({persistent:!0})}togglePaintFormat(){this.isActive?this.paintFormatStore.cancel():this.paintFormatStore.activate({persistent:!1})}},iK=class extends k{static template=`o-spreadsheet-TableDropdownButton`;static components={TableStylesPopover:RW,ActionButton:TP};props=(0,t.useProps)({class:M.string().optional()});topBarToolStore;sidePanelStore;state=(0,t.proxy)({popoverProps:void 0});setup(){this.topBarToolStore=ZG(),this.sidePanelStore=A(U)}onStylePicked(e){let t=this.env.model.getters.getActiveSheetId(),n={...this.tableConfig,styleId:e};if(CD(this.env,t,n).isSuccessful){let e=oO(this.env);e&&this.sidePanelStore.open(`TableSidePanel`,{table:e})}this.closePopover()}onClick(e){if(e.hasClosedTableStylesPopover||this.state.popoverProps){this.closePopover();return}let t=this.dynamicPivotIdInSelection;if(t){this.sidePanelStore.open(`PivotSidePanel`,{pivotId:t,openTab:`design`});return}let n=oO(this.env);if(n){this.topBarToolStore.closeDropdowns(),this.sidePanelStore.toggle(`TableSidePanel`,{table:n});return}let{left:r,bottom:i}=e.currentTarget.getBoundingClientRect();this.topBarToolStore.openDropdown(),this.state.popoverProps={anchorRect:{x:r,y:i,width:0,height:0},positioning:`bottom-left`,verticalOffset:0}}closePopover(){this.state.popoverProps=void 0}get action(){return this.dynamicPivotIdInSelection?{name:N(`Edit pivot style`),icon:`o-spreadsheet-Icon.EDIT_TABLE`}:{name:e=>oO(e)?N(`Edit table`):N(`Insert table`),icon:e=>oO(e)?`o-spreadsheet-Icon.EDIT_TABLE`:`o-spreadsheet-Icon.PAINT_TABLE`}}get tableConfig(){return{...ex,numberOfHeaders:1,bandedRows:!0}}get tableStyles(){return this.env.model.getters.getTableStyles()}get dynamicPivotIdInSelection(){let e=this.env.model.getters.getSelectedZones(),t=new Set(this.env.model.getters.getCellsWithTrackedFormula(`PIVOT`));if(t.size===0)return;let n=this.env.model.getters.getActiveSheetId();for(let r of e)for(let e of Cr(n,r)){let n=this.env.model.getters.getArrayFormulaSpreadingOn(e);if(!n)continue;let r=this.env.model.getters.getCell(n)?.id;if(r&&t.has(r)){let e=this.env.model.getters.getPivotIdFromPosition(n);if(e)return e}}}get class(){return`${this.props.class?this.props.class:``} ${this.env.model.getters.isCurrentSheetLocked()?`o-disabled`:``}`}},aK=class extends k{static components={ColorPickerWidget:DP};static template=`o-spreadsheet-ColorEditor`;props=(0,t.useProps)({class:M.string(),style:M.or([M.literal(`textColor`),M.literal(`fillColor`)]),icon:M.string(),title:M.string()});topBarToolStore;state=(0,t.proxy)({isOpen:!1});setup(){this.topBarToolStore=ZG()}get currentColor(){return this.env.model.getters.getCurrentStyle()[this.props.style]||(this.props.style===`textColor`?`#000000`:`#ffffff`)}setColor(e){if(this.props.style===`fillColor`&&this.isWholeSheetSelected()){let t=this.env.model.getters.getActiveSheetId();this.env.model.dispatch(`SET_BACKGROUND_FOR_ALL_CELLS`,{sheetId:t,color:e});return}TD(this.env.model,{[this.props.style]:e}),this.state.isOpen=!1}get isMenuOpen(){return this.topBarToolStore.isActive}onClick(){this.isMenuOpen?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}isWholeSheetSelected(){let e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSheetZone(e);return T(this.env.model.getters.getSelectedZone(),t)}},oK=class extends k{static template=`o-spreadsheet-DropdownAction`;static components={ActionButton:TP,Popover:Fw};props=(0,t.useProps)({parentAction:M.ActionSpec(),childActions:M.array(M.ActionSpec()),class:M.string(),childClass:M.string()});topBarToolStore;actionRef=t.signal.ref();setup(){this.topBarToolStore=ZG()}toggleDropdown(){this.isActive?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}get isActive(){return this.topBarToolStore.isActive}get popoverProps(){return{anchorRect:y(this.actionRef()),positioning:`bottom-left`,verticalOffset:0,class:`rounded`}}},sK=class extends k{static components={FontSizeEditor:kP};static template=`o-spreadsheet-TopBarFontSizeEditor`;props=(0,t.useProps)({class:M.string()});topBarToolStore;setup(){this.topBarToolStore=ZG()}get currentFontSize(){return this.env.model.getters.getCurrentStyle().fontSize||Qe}setFontSize(e){TD(this.env.model,{fontSize:e})}onToggle(){this.isActive?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}onFocusInput(){this.topBarToolStore.openDropdown()}get isActive(){return this.topBarToolStore.isActive}get class(){return`${this.props.class} ${this.env.model.getters.isCurrentSheetLocked()?`o-disabled`:``}`}},cK=class extends k{static template=`o-spreadsheet-NumberFormatsTool`;static components={MenuPopover:zw,ActionButton:TP};props=(0,t.useProps)({class:M.string()});formatNumberMenuItemSpec=yH;topBarToolStore;buttonRef=t.signal.ref();state=(0,t.proxy)({anchorRect:{x:0,y:0,width:0,height:0},menuItems:[]});setup(){this.topBarToolStore=ZG()}toggleMenu(){if(this.isActive)this.topBarToolStore.closeDropdowns();else{let e=we(this.formatNumberMenuItemSpec);this.state.menuItems=e.children(this.env).sort((e,t)=>e.sequence-t.sequence),this.state.anchorRect=b(this.buttonRef()),this.topBarToolStore.openDropdown()}}get isActive(){return this.topBarToolStore.isActive}},lK=class extends k{static template=`o-spreadsheet-TopBarZoom`;static components={NumberEditor:OP};props=(0,t.useProps)({class:M.string()});topBarToolStore;zoomStore;valueList=Ke;minZoom=.5*100;maxZoom=200;setup(){this.topBarToolStore=ZG(),this.zoomStore=A(Rg)}getZoomLevel(){let e=this.zoomStore.zoomLevel||1;return Math.round(e*100)}setZoom(e){this.zoomStore.setZoom(e/100)}toggle(){this.topBarToolStore.isActive?this.topBarToolStore.closeDropdowns():this.topBarToolStore.openDropdown()}onFocusInput(){this.topBarToolStore.openDropdown()}};let uK=new $G;uK.add(`edit`).addChild(`edit`,{name:`undo`,component:TP,props:{action:aA,class:`o-hoverable-button o-toolbar-button`},sequence:1}).addChild(`edit`,{name:`redo`,component:TP,props:{action:oA,class:`o-hoverable-button o-toolbar-button`},sequence:2}).addChild(`edit`,{name:`paintFormat`,component:rK,props:{class:`o-hoverable-button o-toolbar-button o-mobile-disabled`},sequence:3}).addChild(`edit`,{name:`clearFormat`,component:TP,props:{action:wj,class:`o-hoverable-button o-toolbar-button`},sequence:4}).addChild(`edit`,{name:`zoom`,component:lK,props:{class:`o-menu-item-button o-hoverable-button o-toolbar-button`},sequence:5}).add(`numberFormat`).addChild(`numberFormat`,{name:`formatPercent`,component:TP,props:{action:FA,class:`o-hoverable-button o-toolbar-button`},sequence:1}).addChild(`numberFormat`,{name:`decreaseDecimalPlaces`,component:TP,props:{action:YA,class:`o-hoverable-button o-toolbar-button`},sequence:2}).addChild(`numberFormat`,{name:`increaseDecimalPlaces`,component:TP,props:{action:JA,class:`o-hoverable-button o-toolbar-button`},sequence:3}).addChild(`numberFormat`,{name:`numberFormatsTool`,component:cK,props:{class:`o-menu-item-button o-hoverable-button o-toolbar-button`},sequence:4}).add(`fontSize`).addChild(`fontSize`,{name:`fontSizeEditor`,component:sK,props:{class:`o-hoverable-button o-toolbar-button`},sequence:3}).add(`textStyle`).addChild(`textStyle`,{name:`bold`,component:TP,props:{action:XA,class:`o-hoverable-button o-toolbar-button`},sequence:1}).addChild(`textStyle`,{name:`italic`,component:TP,props:{action:ZA,class:`o-hoverable-button o-toolbar-button`},sequence:2}).addChild(`textStyle`,{name:`strikethrough`,component:TP,props:{action:sj,class:`o-hoverable-button o-toolbar-button`},sequence:3}).addChild(`textStyle`,{name:`textColor`,component:aK,props:{class:`o-hoverable-button o-menu-item-button o-toolbar-button`,style:`textColor`,icon:`o-spreadsheet-Icon.TEXT_COLOR`,title:N(`Text Color`)},sequence:4}).add(`cellStyle`).addChild(`cellStyle`,{name:`fillColor`,component:aK,props:{class:`o-hoverable-button o-menu-item-button o-toolbar-button`,style:`fillColor`,icon:`o-spreadsheet-Icon.FILL_COLOR`,title:N(`Fill Color`)},sequence:1}).addChild(`cellStyle`,{name:`borderEditor`,component:nK,props:{class:`o-hoverable-button o-menu-item-button o-toolbar-button`},sequence:2}).addChild(`cellStyle`,{name:`mergeCells`,component:TP,props:{action:wA,class:`o-hoverable-button o-menu-item-button o-toolbar-button`},sequence:3}).add(`alignment`).addChild(`alignment`,{name:`alignmentHorizontal`,component:oK,props:{parentAction:uj,childActions:[dj,fj,pj],class:`o-hoverable-button o-toolbar-button`,childClass:`o-hoverable-button`},sequence:1}).addChild(`alignment`,{name:`alignmentVertical`,component:oK,props:{parentAction:mj,childActions:[hj,gj,_j],class:`o-hoverable-button o-menu-item-button o-toolbar-button`,childClass:`o-hoverable-button`},sequence:2}).addChild(`alignment`,{name:`formatWrapping`,component:oK,props:{parentAction:yj,childActions:[bj,xj,Sj],class:`o-hoverable-button o-menu-item-button o-toolbar-button`,childClass:`o-hoverable-button`},sequence:3}).addChild(`alignment`,{name:`formatRotation`,component:oK,props:{parentAction:$A,childActions:[nj,rj,ij,aj,oj],class:`o-hoverable-button o-menu-item-button o-toolbar-button`,childClass:`o-hoverable-button`},sequence:4}).add(`misc`).addChild(`misc`,{name:`tableDropdown`,component:iK,props:{class:`o-toolbar-button o-hoverable-button o-menu-item-button o-mobile-disabled`},sequence:1}).addChild(`misc`,{name:`createRemoveFilterTool`,component:TP,props:{action:Jk,class:`o-hoverable-button o-menu-item-button o-toolbar-button`},sequence:2});var dK=class extends k{static template=`o-spreadsheet-TopBar`;props=(0,t.useProps)({onClick:M.function(),dropdownMaxHeight:M.Pixel()});static components={MenuPopover:zw,TopBarComposer:YG,Popover:Fw,NamedRangeSelector:QG};toolsCategories=uK.getCategories();state=(0,t.proxy)({menuState:{isOpen:!1,anchorRect:null,menuItems:[]},invisibleToolsCategories:[],toolsPopoverState:{isOpen:!1}});isSelectingMenu=!1;openedEl=null;menus=[];toolbarMenuRegistry=uK;formatNumberMenuItemSpec=yH;isntToolbarMenu=!1;composerFocusStore;fingerprints;topBarToolStore;toolBarContainerRef=t.signal.ref();toolbarRef=t.signal.ref();namedRangesRef=t.signal.ref();topBarTopRef=t.signal.ref();moreToolsContainerRef=t.signal.ref();moreToolsButtonRef=t.signal.ref();spreadsheetRect=Nw();setup(){this.composerFocusStore=A(ni),this.fingerprints=A(VE),this.topBarToolStore=A(XG),(0,t.useListener)(window,`click`,this.onExternalClick.bind(this)),(0,t.useListener)(window,`keydown`,this.onKeydown.bind(this)),this.menus=bH.getMenuItems();let e,n=()=>{let t=this.spreadsheetRect.width;e!==t&&(e=t,this.state.toolsPopoverState.isOpen=!1,this.setVisibilityToolsGroups())};(0,t.onMounted)(n),(0,t.onPatched)(n)}setVisibilityToolsGroups(){if(this.env.model.getters.isReadonly())return;let e=[],t=this.toolbarRef(),n=this.toolBarContainerRef();if(!t||!n)return;let{x:r}=t.getBoundingClientRect(),{x:i}=n.getBoundingClientRect();this.moreToolsContainerRef()?.classList.remove(`d-none`);let a=this.moreToolsButtonRef()?.getBoundingClientRect().width||0,o=y(this.namedRangesRef()).width,s=Math.round(this.spreadsheetRect.width)-a-(r-i)-16-o,c=document.querySelectorAll(`.tool-container`),l=0;for(let t=0;t<c.length;t++){let n=c[t];n.classList.remove(`d-none`);let{width:r}=n.getBoundingClientRect();l+=r,l>s&&(n.classList.add(`d-none`),e.push(this.toolsCategories[t]))}this.state.invisibleToolsCategories=e,e.length||this.moreToolsContainerRef()?.classList.add(`d-none`)}get topbarComponents(){return nG.getAllOrdered().filter(e=>!e.isVisible||e.isVisible(this.env))}get currentFontSize(){return this.env.model.getters.getCurrentStyle().fontSize||Qe}onExternalClick(e){this.openedEl!==e.target&&this.closeMenus()}onKeydown(e){let t=ce(e,`code`),n=this.menus.find(e=>e.id===this.shortcutToMenuId[t]);if(n){e.preventDefault(),e.stopPropagation(),this.openMenu(n,this.getMenuItemEl(n.id));return}}shortcutToMenuId={"Alt+Shift+KeyF":`file`,"Alt+Shift+KeyE":`edit`,"Alt+Shift+KeyV":`view`,"Alt+Shift+KeyI":`insert`,"Alt+Shift+KeyO":`format`,"Alt+Shift+KeyD":`data`};onClick(){this.props.onClick(),this.closeMenus()}onMenuMouseOver(e,t){this.isSelectingMenu&&this.isntToolbarMenu&&this.openMenu(e,t.currentTarget)}toggleContextMenu(e,t){this.state.menuState.isOpen&&this.isntToolbarMenu?this.closeMenus():(this.openMenu(e,t.currentTarget),this.isntToolbarMenu=!0)}openMenu(e,t,n=!1){t&&(this.topBarToolStore.currentDropdown&&this.topBarToolStore.closeDropdowns(),this.state.toolsPopoverState.isOpen=!1,this.state.menuState.isOpen=!0,this.state.menuState.anchorRect=b(t),this.state.menuState.menuItems=e.children(this.env).sort((e,t)=>e.sequence-t.sequence),this.state.menuState.parentMenu=e,this.state.menuState.autoSelectFirstItem=n,this.isSelectingMenu=!0,this.openedEl=t,this.composerFocusStore.activeComposer.stopEdition())}closeMenus(){this.topBarToolStore.currentDropdown&&this.topBarToolStore.closeDropdowns(),this.state.toolsPopoverState.isOpen=!1,this.state.menuState.isOpen=!1,this.state.menuState.parentMenu=void 0,this.isSelectingMenu=!1,this.openedEl=null}getMenuName(e){return e.name(this.env)}setColor(e,t){TD(this.env.model,{[e]:t}),this.onClick()}setFontSize(e){TD(this.env.model,{fontSize:e})}toggleMoreTools(){this.topBarToolStore.currentDropdown&&this.topBarToolStore.closeDropdowns(),this.state.toolsPopoverState.isOpen=!this.state.toolsPopoverState.isOpen}get toolsPopoverProps(){let e=this.moreToolsButtonRef();return{anchorRect:e?b(e):{x:0,y:0,width:0,height:0},positioning:`bottom-left`,verticalOffset:0,class:`rounded`,maxWidth:300}}showDivider(e){return e<this.toolsCategories.length-1||this.state.invisibleToolsCategories.length>0}onKeyboardNavigation(e){let t=this.menus.findIndex(e=>e.id===this.state.menuState.parentMenu?.id||``);if(t!==-1)switch(e.key){case`ArrowLeft`:{let e=(t-1+this.menus.length)%this.menus.length,n=this.menus[e];this.openMenu(n,this.getMenuItemEl(n.id),!0);break}case`ArrowRight`:{let e=(t+1)%this.menus.length,n=this.menus[e];this.openMenu(n,this.getMenuItemEl(n.id),!0);break}case`Escape`:this.closeMenus();break}}getMenuItemEl(e){return this.topBarTopRef()?.querySelector(`[data-id="${e}"]`)||void 0}};function fK(){return new pK(navigator.clipboard)}var pK=class{clipboard;constructor(e){this.clipboard=e}async write(e){if(this.clipboard?.write)try{await this.clipboard?.write(this.getClipboardItems(e))}catch(t){console.log(`Failed to write on the clipboard, falling back to plain/html text. Error %s`,t);try{await this.clipboard?.write([new ClipboardItem({"text/plain":this.getBlob(e,`text/plain`),"text/html":this.getBlob(e,`text/html`)})])}catch{}}else await this.writeText(e[`text/plain`]??``)}async writeText(e){try{await this.clipboard?.writeText(e)}catch{}}async read(){let e;try{e=await navigator.permissions.query({name:`clipboard-read`})}catch{}if(this.clipboard?.read)try{let e=await this.clipboard.read(),t={};for(let n of e)for(let e of n.types){let r=await n.getType(e);L_.includes(e)?t[e]=r:t[e]=await r.text()}return{status:`ok`,content:t}}catch{return{status:e?.state===`denied`?`permissionDenied`:`notImplemented`}}else return{status:`ok`,content:{"text/plain":await this.clipboard?.readText()}}}getClipboardItems(e){let t={};for(let n of Object.keys(e))t[n]=this.getBlob(e,n);return[new ClipboardItem(t)]}getBlob(e,t){let n=e[t];return n instanceof Blob||n instanceof File?n:new Blob([e[t]||``],{type:t})}},mK=class extends k{static template=`o-spreadsheet-Spreadsheet`;props=(0,t.useProps)({model:M.Model(),notifyUser:M.function().optional(),raiseError:M.function().optional(),askConfirmation:M.function().optional()});static components={TopBar:dK,Grid:rP,BottomBar:DG,SmallBottomBar:LG,SidePanels:FG,SpreadsheetDashboard:OG,HeaderGroupContainer:MG,FullScreenFigure:cR,SpreadsheetPrint:JG};sidePanel;spreadsheetRef=t.signal.ref();spreadsheetRect=Nw();state=(0,t.proxy)({printModeEnabled:!1,colorThemeBeforePrint:`light`});_focusGrid;isViewportTooSmall=!1;notificationStore;composerFocusStore;viewStore;zoomStore;get model(){return this.props.model}getStyle(){let e={};return e[`--os-scrollbar-width`]=`${this.zoomStore.scrollBarWidth}px`,e[`--os-dark-mode-filter`]=Zf,e[`color-scheme`]=this.colorScheme,this.state.printModeEnabled?e.display=`block`:(this.env.model.getters.isDashboard()?e[`grid-template-rows`]=`auto`:e[`grid-template-rows`]=`min-content auto min-content`,e[`grid-template-columns`]=`auto ${this.sidePanel.mainPanel?`${this.sidePanel.totalPanelSize||350}px`:`auto`}`),G(e)}setup(){if(!(`isSmall`in this.env)){let e=NG();Wi({get isSmall(){return e.isSmall}})}let e=Yi();e.inject(Yr,this.model),this.viewStore=A(W),this.zoomStore=A(Rg),(0,t.providePlugins)([Mw],{getPopoverContainerRect:()=>y(this.spreadsheetRef())});let n=this.env;e.get(Hg).setSmallThreshhold(()=>n.isSmall),this.notificationStore=A(Vg),this.composerFocusStore=A(ni),this.sidePanel=A(U);for(let e of oG.getAll())A(e);let r=this.model.config.external.fileStore;Wi({model:this.model,imageProvider:r?new iG(r):void 0,loadCurrencies:this.model.config.external.loadCurrencies,loadLocales:this.model.config.external.loadLocales,clipboard:this.env.clipboard||fK(),startCellEdition:e=>this.composerFocusStore.focusActiveComposer({content:e}),notifyUser:e=>this.notificationStore.notifyUser(e),askConfirmation:(e,t,n)=>this.notificationStore.askConfirmation(e,t,n),raiseError:(e,t)=>this.notificationStore.raiseError(e,t),isMobile:_e,printSpreadsheet:this.enterPrintMode.bind(this)}),this.notificationStore.updateNotificationCallbacks({...this.props}),Vi(()=>{let e=this.spreadsheetRef();e&&!e.contains(document.activeElement)&&document.activeElement?.contains(e)&&this.focusGrid()}),(0,t.useListener)(window,`resize`,()=>vN(this,!0)),(0,t.useListener)(document.body,`wheel`,()=>{}),(0,t.useListener)(window,`keydown`,async e=>{ce(e)===`Ctrl+P`&&(this.enterPrintMode(),e.stopPropagation(),e.preventDefault())},{capture:!0}),(0,t.onWillUpdateProps)(e=>{if(e.model!==this.props.model)throw Error(`Changing the props model is not supported at the moment.`);(e.notifyUser!==this.props.notifyUser||e.askConfirmation!==this.props.askConfirmation||e.raiseError!==this.props.raiseError)&&this.notificationStore.updateNotificationCallbacks({...e})});let i=new ResizeObserver(()=>{this.sidePanel.changeSpreadsheetWidth(this.spreadsheetRect.width)});(0,t.useEffect)(()=>{let e=this.spreadsheetRef();if(e)return i.observe(e),()=>i.disconnect()});let a=Zt(()=>vN(this,!0));(0,t.onMounted)(()=>{this.bindModelEvents(),this.checkViewportSize(),e.on(`store-updated`,this,a)}),(0,t.onWillUnmount)(()=>{this.unbindModelEvents(),e.off(`store-updated`,this),oi()}),(0,t.onPatched)(()=>{this.checkViewportSize()})}bindModelEvents(){this.model.on(`update`,this,()=>vN(this,!0)),this.model.on(`command-rejected`,this,({result:e})=>{e.isCancelledBecause(`SheetLocked`)&&this.notificationStore.notifyUser({type:`info`,text:N(`This sheet is locked and cannot be modified. Please unlock it first.`),sticky:!1})})}unbindModelEvents(){this.model.off(`update`,this),this.model.off(`command-rejected`,this)}checkViewportSize(){let{xRatio:e,yRatio:t}=this.viewStore.viewports.getFrozenSheetViewRatio(this.viewStore.displayedSheetId);if(!(!isFinite(e)||!isFinite(t)))if(t>.85||e>.85){if(this.isViewportTooSmall)return;this.notificationStore.notifyUser({text:N(`The current window is too small to display this sheet properly. Consider resizing your browser window or adjusting frozen rows and columns.`),type:`warning`,sticky:!1}),this.isViewportTooSmall=!0}else this.isViewportTooSmall=!1}focusGrid(){this._focusGrid&&this._focusGrid()}get gridHeight(){return this.viewStore.sheetViewDimension.height}get gridContainerStyle(){let e=21*this.rowLayers.length,t=21*this.colLayers.length;return G({"grid-template-columns":`${e?e+2:0}px auto`,"grid-template-rows":`${t?t+2:0}px auto`,zoom:this.zoomStore.cssZoom})}get rowLayers(){let e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getVisibleGroupLayers(e,`ROW`)}get colLayers(){let e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getVisibleGroupLayers(e,`COL`)}getGridSize(){let e=this.spreadsheetRef();if(!e)return{width:0,height:0};let t=this.zoomStore.zoomLevel,n=this.zoomStore.scrollBarWidth,r=n=>e.querySelector(n)&&ee(e.querySelector(n),t).height||0,i=n=>e.querySelector(n)&&ee(e.querySelector(n),t).width||0,a=e.getBoundingClientRect(),o=r(`.o-spreadsheet-topbar-wrapper`),s=r(`.o-spreadsheet-bottombar-wrapper`),c=r(`.o-column-groups`),l=i(`.o-grid`),u=a.height-c-o-s;return{width:Math.max(l/t-n,0),height:Math.max(u/t-n,0)}}getSpreadSheetClasses(){return[this.env.isSmall?`o-spreadsheet-mobile`:``,this.props.model.getters.isDarkMode()?`dark`:``].join(` `)}enterPrintMode(){this.state.printModeEnabled||(this.state.colorThemeBeforePrint=this.props.model.getters.isDarkMode()?`dark`:`light`,this.env.model.dispatch(`UPDATE_COLOR_SCHEME`,{colorScheme:`light`}),this.state.printModeEnabled=!0)}exitPrintMode(){this.state.printModeEnabled&&(this.env.model.dispatch(`UPDATE_COLOR_SCHEME`,{colorScheme:this.state.colorThemeBeforePrint}),this.state.printModeEnabled=!1)}get colorScheme(){return this.state.printModeEnabled?this.state.colorThemeBeforePrint:this.props.model.getters.isDarkMode()?`dark`:`light`}},hK=class{getters;constructor(e){this.getters=e}squish(e){let t=[];for(let n of this.collectConsecutiveUpdateCellCommands(e))if(n[0].type===`UPDATE_CELL`&&n.length>1){let e=Object.groupBy(n,e=>e.sheetId),r=Object.values(e).reduce(this.sortAndSquishUpdateCellsBySheet.bind(this),[]);t.push(...r)}else t.push(...n);return t}unsquish(e){return[...new YR().unsquishCommands(e,this.getters)]}*collectConsecutiveUpdateCellCommands(e){for(let t=0;t<e.length;t++){let n=e[t];if(n.type===`UPDATE_CELL`){let r=[n];for(let n=t+1;n<e.length;n++){let t=e[n];if(t.type===`UPDATE_CELL`)r.push(t);else break}yield r,t+=r.length-1}else yield[n]}}sortAndSquishUpdateCellsBySheet(e,t){if(t.sort((e,t)=>e.col===t.col?e.row-t.row:e.col-t.col),t.some((e,n)=>n>0&&t[n-1].col===e.col&&t[n-1].row===e.row))return e.push(...t),e;let n=new KR(this.getters),r=t.map(e=>({...e,content:n.squishCommand(e)}));for(let n=0;n<r.length;n++){let i=r[n],a={row:i.row,col:i.col},o=0;for(o=0;o+n+1<r.length;o++){let e=r[o+n+1],t={row:e.row,col:e.col};if(t.col!==a.col||t.row!==a.row+o+1||!this.compareUpdateCell(i,e))break}if(o>0){let t=`${E(a.col,a.row)}:${E(a.col,a.row+o)}`,r={type:`SQUISHED_UPDATE_CELL`,sheetId:i.sheetId,targetRange:t};`content`in i&&(r.content=i.content),`format`in i&&(r.format=i.format),`style`in i&&(r.style=i.style),e.push(r),n+=o}else e.push(t[n])}return e}compareUpdateCell(e,t){return T(e.content,t.content)&&T(e.format,t.format)&&T(e.style,t.style)}},gK=class{transportService;constructor(e){this.transportService=e}async sendMessage(e){(e.type===`CLIENT_JOINED`||e.type===`CLIENT_LEFT`||e.type===`CLIENT_MOVED`)&&await this.transportService.sendMessage(e)}onNewMessage(e,t){this.transportService.onNewMessage(e,t)}leave(e){this.transportService.leave(e)}};function _K(e){return QV.get(e.type)(e)}var vK=class e{buildTransformation;operations;constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){let t=this.operations.find(t=>t.id===e);if(!t)throw Error(`Operation ${e} not found`);return t}getLastOperationId(){return this.operations[this.operations.length-1]?.id}getFirstOperationAmong(e,t){for(let n of this.operations){if(n.id===e)return e;if(n.id===t)return t}throw Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find(t=>t.id===e)}prepend(e){let t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map(e=>e.transformed(t))]}insert(e,t){let n=this.buildTransformation.with(e.data),{before:r,operation:i,after:a}=this.locateOperation(t);this.operations=[...r,i,e,...a.map(e=>e.transformed(n))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(t){let{after:n}=this.locateOperation(t);return new e(this.buildTransformation,n)}transform(e){this.operations=this.operations.map(t=>t.transformed(e))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){let{before:t,operation:n}=this.locateOperation(e);this.operations=t.concat([n])}locateOperation(e){let t=this.operations.findIndex(t=>t.id===e);if(t===-1)throw Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}},yK=class{id;data;constructor(e,t){this.id=e,this.data=t}transformed(e){return new bK(this.id,en(()=>e(this.data)))}},bK=class e{id;lazyData;constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(t){return new e(this.id,this.lazyData.map(t))}},xK=class e{operations;constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(t){function*n(e,t){for(let n of e)if(yield n,n.operation.id===t)return}return new e(n(this.operations,t))}stopBefore(t){function*n(e,t){for(let n of e){if(n.operation.id===t)return;yield n}}return new e(n(this.operations,t))}startAfter(t){function*n(e,t){let n=!0;for(let r of e)n||(yield r),r.operation.id===t&&(n=!1)}return new e(n(this.operations,t))}},SK=class{buildTransformation;branches;branchingOperationIds=new Map;constructor(e,t){this.buildTransformation=e,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new xK(Lt(this._execution(e),this._execution(e)))}revertedExecution(e){return new xK(Lt(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){let n=e.getLastOperationId()||this.previousBranch(e)?.getLastOperationId();e.append(t),n&&this.insertPrevious(e,t,n)}insertOperationAfter(e,t,n){e.insert(t,n),this.updateNextWith(e,t,n),this.insertPrevious(e,t,n)}undo(e,t){let n=this.buildTransformation.without(t.data),r=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);let i=e.fork(t.id);r&&this.branchingOperationIds.set(i,r),this.insertBranchAfter(e,i),this.transform(i,n)}redo(e){let t=this.nextBranch(e);if(!t)return;let n=this.nextBranch(t);this.removeBranchFromTree(t);let r=this.branchingOperationIds.get(t);r?this.branchingOperationIds.set(e,r):this.branchingOperationIds.delete(e),n&&this.rebaseUp(n)}drop(e){for(let t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(let n of this.revertedExecution(e))if(n.operation.id===t)return n;throw Error(`Operation ${t} not found`)}rebaseUp(e){let{previousBranch:t,branchingOperation:n}=this.findPreviousBranchingOperation(e);if(!t||!n)return;let r=this.buildTransformation.without(n.data),i=t.fork(n.id);this.branchingOperationIds.set(i,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,i),i.transform(r);let a=this.nextBranch(i);a&&this.rebaseUp(a)}removeBranchFromTree(e){let t=this.branches.findIndex(t=>t===e);this.branches.splice(t,1)}insertBranchAfter(e,t){let n=this.branches.findIndex(t=>t===e);this.branches.splice(n+1,0,t)}updateNextWith(e,t,n){let r=this.branchingOperationIds.get(e),i=this.nextBranch(e);if(!(!r||!i))if(e.getFirstOperationAmong(n,r)===r){let a=this.addToNextBranch(e,i,r,t,n);this.updateNextWith(i,a,n)}else{let e=this.buildTransformation.with(t.data);this.transform(i,e)}}addToNextBranch(e,t,n,r,i){let a=r;return i===n?(a=this.getTransformedOperation(e,n,r),t.prepend(a)):t.contains(i)?(a=this.getTransformedOperation(e,n,r),t.insert(a,i)):t.append(r),a}getTransformedOperation(e,t,n){let r=e.getOperation(t),i=this.buildTransformation.without(r.data);return n.transformed(i)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);let n=this.nextBranch(e);n&&this.transform(n,t)}insertPrevious(e,t,n){let{previousBranch:r,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!r||!i)return;let a=this.buildTransformation.with(i.data),o=e.fork(n);o.transform(a),r.cutAfter(n),r.appendBranch(o);let s=t.transformed(a);this.insertPrevious(r,s,n)}findPreviousBranchingOperation(e){let t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};let n=this.branchingOperationIds.get(t);return n?{previousBranch:t,branchingOperation:t.getOperation(n)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){let t=this.branches.findIndex(t=>t===e);if(t!==-1)return this.branches[t+1]}previousBranch(e){let t=this.branches.findIndex(t=>t===e);if(t!==-1)return this.branches[t-1]}*_revertedExecution(e){let t=this.branchingOperationIds.get(e),n=!!t,r=e.getOperations();for(let i=r.length-1;i>=0;i--){let a=r[i];a.id===t&&(n=!1),n||(yield{operation:a,branch:e,isCancelled:!this.shouldExecute(e,a)})}let i=this.previousBranch(e);yield*i?this._revertedExecution(i):[]}*_execution(e){for(let t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){let t=this.nextBranch(e);yield*t?this._execution(t):[];return}if(!this.branchingOperationIds.get(e)){let t=this.nextBranch(e);yield*t?this._execution(t):[]}}},CK=class{HEAD_BRANCH;HEAD_OPERATION;tree;applyOperation;revertOperation;buildEmpty;buildTransformation;constructor(e){this.applyOperation=e.applyOperation,this.revertOperation=e.revertOperation,this.buildEmpty=e.buildEmpty,this.buildTransformation=e.buildTransformation,this.HEAD_BRANCH=new vK(this.buildTransformation),this.tree=new SK(this.buildTransformation,this.HEAD_BRANCH);let t=e.initialOperationId,n=new yK(t,this.buildEmpty(t));this.tree.insertOperationLast(this.HEAD_BRANCH,n),this.HEAD_OPERATION=n}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){let n=new yK(e,t),r=this.tree.getLastBranch();this.tree.insertOperationLast(r,n),this.HEAD_BRANCH=r,this.HEAD_OPERATION=n}insert(e,t,n){let r=new yK(e,t);this.revertTo(n),this.tree.insertOperationAfter(this.HEAD_BRANCH,r,n),this.fastForward()}undo(e,t,n){let{branch:r,operation:i}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(r,i),this.fastForward(),this.insert(t,this.buildEmpty(t),n)}redo(e,t,n){let{branch:r}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(r),this.fastForward(),this.insert(t,this.buildEmpty(t),n)}rebase(e){let t=this.get(e),n=[...this.tree.execution(this.HEAD_BRANCH).startAfter(e)];this.revertBefore(e);let r=this.HEAD_OPERATION.id;this.tree.drop(e),this.insert(e,t,r);for(let{operation:e}of n)this.insert(e.id,e.data,this.HEAD_OPERATION.id)}revertBefore(e){let t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){let t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(let{next:t,operation:n,isCancelled:r}of e)r||this.revertOperation(n.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){let e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(let{operation:t,branch:n,isCancelled:r}of e)r||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=n}};function wK(e){return new CK({initialOperationId:e.initialRevisionId,applyOperation:t=>{let n=t.commands.slice(),{changes:r}=e.recordChanges(()=>{for(let t of n)e.dispatch(t)});t.setChanges(r)},revertOperation:e=>TK([e]),buildEmpty:e=>new vV(e,`empty`,[]),buildTransformation:{with:e=>t=>new vV(t.id,t.clientId,lV(t.commands,e.commands),t.rootCommand,void 0,t.timestamp),without:e=>t=>new vV(t.id,t.clientId,lV(t.commands,e.commands.map(_K).flat()),t.rootCommand,void 0,t.timestamp)}})}function TK(e){for(let t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){let n=t.changes[e];EK(n)}}function EK(e){let t=e.target,n=e.key,r=e.before;r===void 0?delete t[n]:t[n]=r}var DK=class{providers=[];static getters=[`getAllFormulas`];addFormulaProvider(e){this.providers.push(e)}getAllFormulas(){return this.providers.flatMap(e=>e())}},OK=class{getters;providers=[];isAdaptingRanges=!1;constructor(e){this.getters=e}static getters=[`copyFormulaStringForSheet`,`extendRange`,`getRangeString`,`getRangeFromSheetXC`,`clipRangesToSheet`,`clipRangeToSheet`,`createAdaptedRanges`,`getRangeData`,`getRangeDataFromXc`,`getRangeDataFromZone`,`getRangeFromRangeData`,`getRangeFromZone`,`getRangesUnion`,`recomputeRanges`,`isRangeValid`,`removeRangesSheetPrefix`];allowDispatch(e){return e.type===`MOVE_RANGES`?e.target.length===1?`Success`:`InvalidZones`:`Success`}beforeHandle(e){}handle(e){if(this.isAdaptingRanges)throw Error(`Plugins cannot dispatch commands during adaptRanges phase`);let t=NB(e);t&&this.executeOnAllRanges(t)}finalize(){}executeOnAllRanges(e){this.isAdaptingRanges=!0;for(let t of this.providers)t(e);this.isAdaptingRanges=!1}addRangeProvider(e){this.providers.push(e)}clipRangeToSheet(e){if(e.invalidXc)return e;let t=this.getters.getSheetZone(e.sheetId);if(vr(e.zone,t))return e;let n=pr(e.zone,t);if(n)return this.getters.getRangeFromZone(e.sheetId,n)}clipRangesToSheet(e){let t=[];for(let n of e){let e=this.clipRangeToSheet(n);e&&t.push(e)}return t}createAdaptedRanges(e,t,n,r){return e.map(e=>{if(!ir(e.zone))return e;let i=e.prefixSheet?e.sheetId:r,a=Ou(e),o=Du(e),s={...e.unboundedZone,left:a&&!e.unboundedZone.hasHeader?e.unboundedZone.left:e.unboundedZone.left+(e.parts[0].colFixed?0:t),right:a?e.unboundedZone.right:e.unboundedZone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:o&&!e.unboundedZone.hasHeader?e.unboundedZone.top:e.unboundedZone.top+(e.parts[0].rowFixed?0:n),bottom:o?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:n)};return Fu(wu({...e,sheetId:i,zone:s},this.getters.getSheetSize))})}removeRangesSheetPrefix(e,t){return t.map(t=>t.prefixSheet&&t.sheetId===e?{...t,prefixSheet:!1}:t)}extendRange(e,t,n){let r=t===`COL`?e.zone.right+n:e.zone.right,i=t===`ROW`?e.zone.bottom+n:e.zone.bottom,a={left:e.zone.left,top:e.zone.top,right:Ou(e)?void 0:r,bottom:Du(e)?void 0:i};return wu({...e,zone:a},this.getters.getSheetSize)}getRangeFromSheetXC(e,t){if(!vl.test(t))return Eu(t);let{sheetName:n}=wl(t),r=this.getters.getSheetIdByName(n)||e;return!r||!this.getters.tryGetSheet(r)?Eu(t):Tu({xc:t,sheetId:r,invalidSheetName:n&&!this.getters.getSheetIdByName(n)?n:void 0},this.getters.getSheetSize)}getRangeString(e,t,n={useBoundedReference:!1,useFixedReference:!1}){return e?e.invalidXc?e.invalidXc:this.getters.tryGetSheet(e.sheetId)?ku(e,t,this.getters.getSheetName,n):P.InvalidReference:P.InvalidReference}getRangeDataFromXc(e,t){let n=this.getters.getRangeFromSheetXC(e,t);return this.getRangeDataFromZone(n.sheetId,n.unboundedZone)}getRangeDataFromZone(e,t){return t=this.getters.getUnboundedZone(e,t),{_sheetId:e,_zone:t}}getRangeData(e){return this.getRangeDataFromZone(e.sheetId,e.unboundedZone)}getRangeFromZone(e,t){return wu({sheetId:e,zone:t,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}],prefixSheet:!1},this.getters.getSheetSize)}recomputeRanges(e,t){return Wn(e.map(e=>e.unboundedZone),t.map(e=>e.unboundedZone)).map(t=>this.getRangeFromZone(e[0].sheetId,t))}getRangeFromRangeData(e){return this.getters.tryGetSheet(e._sheetId)?wu({prefixSheet:!1,zone:e._zone,sheetId:e._sheetId,invalidSheetName:void 0,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}]},this.getters.getSheetSize):Eu(P.InvalidReference)}isRangeValid(e){if(!e)return!1;let{xc:t,sheetName:n}=wl(e);return t.match(vl)!==null&&(!n||this.getters.getSheetIdByName(n)!==void 0)}getRangesUnion(e){let t=fr(...e.map(e=>e.unboundedZone));return this.getRangeFromZone(e[0].sheetId,t)}copyFormulaStringForSheet(e,t,n,r){if(!n.startsWith(`=`))return n;let i=yd.Compile(n,e,this.getters),a=i.rangeDependencies.map(n=>r===`keepSameReference`?n:Au(e,t,n));return yd.CopyWithDependencies(i,t,a).toFormulaString(this.getters)}},kK=class{observers=new Map;defaultSubscription;mainSubscription;registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||=this.defaultSubscription}observe(e,t){this.observers.set(e,{owner:e,callbacks:t})}unobserve(e){this.observers.delete(e)}capture(e,t){if(this.observers.get(e))throw Error(`You are already subscribed forever`);this.mainSubscription?.owner&&this.mainSubscription.owner!==e&&this.mainSubscription.callbacks.release?.(),this.mainSubscription={owner:e,callbacks:t}}release(e){this.mainSubscription?.owner!==e||this.observers.get(e)||(this.mainSubscription=this.defaultSubscription)}getBackToDefault(){this.mainSubscription!==this.defaultSubscription&&(this.mainSubscription?.callbacks.release?.(),this.mainSubscription=this.defaultSubscription)}isListening(e){return this.mainSubscription?.owner===e}send(e){this.mainSubscription?.callbacks.handleEvent(e),this.observers.forEach(t=>t.callbacks.handleEvent(e))}},AK=class{getters;stream;anchor;defaultAnchor;constructor(e){this.getters=e,this.stream=new kK,this.anchor={cell:{col:0,row:0},zone:D({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,n){this.stream.capture(e,n),this.anchor=t}registerAsDefault(e,t,n){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,n),this.defaultAnchor=t,this.capture(e,t,n)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}unobserve(e){this.stream.unobserve(e)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}modifyAnchor(e,t,n){let r=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(r,e.zone)},this.processEvent({options:n,anchor:e,mode:t})}selectZone(e,t={scrollIntoView:!0}){return this.modifyAnchor(e,`overrideSelection`,t)}selectCell(e,t,n){let r=D({col:e,row:t});return this.selectZone({zone:r,cell:{col:e,row:t}},{scrollIntoView:!0,...n})}moveAnchorCell(e,t=1){if(t!==`end`&&t<=0)return new Jd(`InvalidSelectionStep`);let{col:n,row:r}=this.getNextAvailablePosition(e,t);return this.selectCell(n,r)}updateAnchorCell(e,t,n={scrollIntoView:!0}){return this.processEvent({mode:`updateAnchor`,anchor:{zone:this.anchor.zone,cell:{col:e,row:t}},options:n})}setAnchorCorner(e,t){let n=this.getters.getActiveSheetId(),{col:r,row:i}=this.anchor.cell,a={left:Math.min(r,e),top:Math.min(i,t),right:Math.max(r,e),bottom:Math.max(i,t)},o=this.getters.expandZone(n,a);if(mr(this.anchor.zone,o))return new Jd(`NoChanges`);let s={zone:o,cell:{col:r,row:i}};return this.processEvent({mode:`updateAnchor`,anchor:s,options:{scrollIntoView:!1}})}addCellToSelection(e,t){let n=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:n,col:e,row:t}));let r=this.getters.expandZone(n,D({col:e,row:t}));return this.processEvent({options:{scrollIntoView:!0},anchor:{zone:r,cell:{col:e,row:t}},mode:`newAnchor`})}commitSelection(){return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:this.anchor,mode:`commitSelection`})}resizeAnchorZone(e,t=1){if(t!==`end`&&t<=0)return new Jd(`InvalidSelectionStep`);let n=this.getters.getActiveSheetId(),r=this.anchor,{col:i,row:a}=r.cell,{left:o,right:s,top:c,bottom:l}=r.zone,u=this.getStartingPosition(e),[d,f]=this.deltaToTarget(u,e,t);if(d===0&&f===0)return Jd.Success;let p=r.zone,m=e=>{e=wr(e);let{left:t,right:r,top:i,bottom:a}=this.getters.expandZone(n,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(n)-1,r),top:Math.max(0,i),bottom:Math.min(this.getters.getNumberRows(n)-1,a)}},{cell:h,zone:g}=this.getReferenceAnchor(),{col:_,row:v}=h,ee=0;for(;p!==null;){if(ee++,d<0){let e=this.getNextAvailableCol(d,s-(ee-1),v);p=g.right<=s-ee?m({top:c,left:o,bottom:l,right:e}):null}if(d>0){let e=this.getNextAvailableCol(d,o+(ee-1),v);p=o+ee<=g.left?m({top:c,left:e,bottom:l,right:s}):null}if(f<0){let e=this.getNextAvailableRow(f,_,l-(ee-1));p=g.bottom<=l-ee?m({top:c,left:o,bottom:e,right:s}):null}if(f>0){let e=this.getNextAvailableRow(f,_,c+(ee-1));p=c+ee<=g.top?m({top:e,left:o,bottom:l,right:s}):null}if(p&&=wr(p),p&&!mr(p,r.zone))return this.processEvent({options:{scrollIntoView:!0},mode:`updateAnchor`,anchor:{zone:p,cell:{col:i,row:a}}})}p=m(dr({top:a,bottom:a,left:i,right:i},wr({top:this.getNextAvailableRow(f,_,c),left:this.getNextAvailableCol(d,o,v),bottom:this.getNextAvailableRow(f,_,l),right:this.getNextAvailableCol(d,s,v)})));let y={zone:p,cell:{col:i,row:a}};return this.processEvent({anchor:y,mode:`updateAnchor`,options:{scrollIntoView:!0}})}selectColumn(e,t){let n=this.getters.getActiveSheetId(),r=this.getters.getNumberRows(n)-1,i={left:e,right:e,top:0,bottom:r},a=this.getters.findFirstVisibleColRowIndex(n,`ROW`),o,s;switch(t){case`overrideSelection`:case`newAnchor`:o=e,s=a;break;case`updateAnchor`:({col:o,row:s}=this.anchor.cell),i=dr(i,{left:o,right:o,top:a,bottom:r});break}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:i,cell:{col:o,row:s}},mode:t})}selectRow(e,t){let n=this.getters.getActiveSheetId(),r=this.getters.getNumberCols(n)-1,i={top:e,bottom:e,left:0,right:r},a=this.getters.findFirstVisibleColRowIndex(n,`COL`),o,s;switch(t){case`overrideSelection`:case`newAnchor`:o=a,s=e;break;case`updateAnchor`:({col:o,row:s}=this.anchor.cell),i=dr(i,{left:a,right:r,top:s,bottom:s});break}return this.processEvent({options:{scrollIntoView:!1,unbounded:!0},anchor:{zone:i,cell:{col:o,row:s}},mode:t})}loopSelection(){let e=this.getters.getActiveSheetId(),t=this.anchor;if(mr(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:D(t.cell)},`updateAnchor`,{scrollIntoView:!1});let n=this.getters.getContiguousZone(e,t.zone);return T(n,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:n},`updateAnchor`,{scrollIntoView:!1})}selectTableAroundSelection(){let e=this.getters.getActiveSheetId(),t=this.getters.getContiguousZone(e,this.anchor.zone);return this.modifyAnchor({...this.anchor,zone:t},`updateAnchor`,{scrollIntoView:!1})}selectAll(){let e=this.getters.getActiveSheetId(),t={left:0,top:0,bottom:this.getters.getNumberRows(e)-1,right:this.getters.getNumberCols(e)-1};return this.processEvent({mode:`overrideSelection`,anchor:{zone:t,cell:this.anchor.cell},options:{scrollIntoView:!1}})}isListening(e){return this.stream.isListening(e)}processEvent(e){let t={...e,previousAnchor:x(this.anchor)},n=this.checkEventAnchorZone(t);return n===`Success`?(this.anchor=t.anchor,this.stream.send(t),Jd.Success):new Jd(n)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor,e.options)}checkAnchorZone(e,t){let{cell:n,zone:r}=e;if(!_r(n.col,n.row,r))return`InvalidAnchorZone`;let{left:i,right:a,top:o,bottom:s}=r,c=this.getters.getActiveSheetId();if(t?.allowsHiddenSelection){let e=this.getters.getNumberCols(c),t=this.getters.getNumberRows(c);if(i<0||a>e-1||o<0||s>t-1)return`SelectionOutOfBound`}else{let e=this.getters.findVisibleHeader(c,`COL`,i,a);if(this.getters.findVisibleHeader(c,`ROW`,o,s)===void 0||e===void 0)return`SelectionOutOfBound`}return`Success`}checkAnchorZoneOrThrow(e){if(this.checkAnchorZone(e)===`InvalidAnchorZone`)throw Error(`The provided anchor is invalid. The cell must be part of the zone.`)}getNextAvailablePosition(e,t=1){let{col:n,row:r}=this.anchor.cell,i=this.deltaToTarget({col:n,row:r},e,t);return{col:this.getNextAvailableCol(i[0],n,r),row:this.getNextAvailableRow(i[1],n,r)}}getNextAvailableCol(e,t,n){let r=this.getters.getActiveSheetId(),i={col:t,row:n};return this.getNextAvailableHeader(e,`COL`,t,i,e=>this.getters.isInSameMerge(r,t,n,e,n))}getNextAvailableRow(e,t,n){let r=this.getters.getActiveSheetId(),i={col:t,row:n};return this.getNextAvailableHeader(e,`ROW`,n,i,e=>this.getters.isInSameMerge(r,t,n,t,e))}getNextAvailableHeader(e,t,n,r,i){let a=this.getters.getActiveSheetId();if(e===0)return n;let o=Math.sign(e),s=n+e;for(;i(s);)s+=o;for(;this.getters.isHeaderHidden(a,t,s);)s+=o;return s<0||s>this.getters.getNumberHeaders(a,t)-1?this.getters.isHeaderHidden(a,t,n)?this.getNextAvailableHeader(-o,t,n,r,i):n:s}getReferenceAnchor(){let e=this.getters.getActiveSheetId(),t=this.anchor,{left:n,right:r,top:i,bottom:a}=t.zone,{col:o,row:s}=t.cell,c=this.getters.isColHidden(e,o)&&this.getters.findVisibleHeader(e,`COL`,n,r)||o,l=this.getters.isRowHidden(e,s)&&this.getters.findVisibleHeader(e,`ROW`,i,a)||s,u=this.getters.expandZone(e,{left:c,right:c,top:l,bottom:l});return{cell:{col:c,row:l},zone:u}}deltaToTarget(e,t,n){switch(t){case`up`:return n===`end`?[0,this.getEndOfCluster(e,`rows`,-1)-e.row]:[0,-n];case`down`:return n===`end`?[0,this.getEndOfCluster(e,`rows`,1)-e.row]:[0,n];case`left`:return n===`end`?[this.getEndOfCluster(e,`cols`,-1)-e.col,0]:[-n,0];case`right`:return n===`end`?[this.getEndOfCluster(e,`cols`,1)-e.col,0]:[n,0]}}getStartingPosition(e){let{col:t,row:n}=this.getPosition(),r=this.anchor.zone;switch(e){case`down`:case`up`:n=n===r.top?r.bottom:r.top;break;case`left`:case`right`:t=t===r.right?r.left:r.right;break}return{col:t,row:n}}getEndOfCluster(e,t,n){let r=this.getters.getActiveSheetId(),i=e,a=this.getNextCellPosition(e,t,n),o=!this.isCellSkippableInCluster({...i,sheetId:r})&&!this.isCellSkippableInCluster({...a,sheetId:r})?`endOfCluster`:`nextCluster`;for(;;){let e=this.getNextCellPosition(i,t,n);if(i.col===e.col&&i.row===e.row)break;let a=this.isCellSkippableInCluster({...e,sheetId:r});if(o===`endOfCluster`&&a)break;if(o===`nextCluster`&&!a){i=e;break}i=e}return t===`cols`?i.col:i.row}getNextCellPosition(e,t,n){let r=t===`cols`?`col`:`row`,i={...e};return i[r]=t===`cols`?this.getNextAvailableCol(n,i.col,i.row):this.getNextAvailableRow(n,i.col,i.row),{col:i.col,row:i.row}}getPosition(){return{...this.anchor.cell}}isCellSkippableInCluster(e){let t=this.getters.getMainCellPosition(e),n=this.getters.getEvaluatedCell(t);return n.type===`empty`||n.type===`text`&&n.value===``}};function jK(e){if(typeof e==`string`)return{};if(typeof e==`number`)return[];throw Error(`Cannot create new node`)}var MK=class{changes;commands=[];recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){let t=e.pop(),n=e[0],r=e.at(-1),i=e.length-2;for(let t=1;t<=i;t++){let r=e[t];if(n[r]===void 0){let i=e[t+1];n[r]=jK(i)}n=n[r]}n[r]!==t&&(this.changes?.push({key:r,target:n,before:n[r]}),t===void 0?delete n[r]:n[r]=t)}};let NK=17781237,PK=17781238,FK=88853993,IK=88853994;function LK(e,t,n){let r=[[`xmlns:r`,am],[`xmlns:a`,tm],[`xmlns:c`,nm]],i=RK({backgroundColor:e.data.backgroundColor,line:{color:`000000`}}),a=X``;if(e.data.title?.text){let t=e.data.title.color?ZP(e.data.title.color):ZP(Tm(e.data.backgroundColor)),n=e.data.title.fontSize??16;a=X`
178
178
  <c:title>
179
179
  ${VK(e.data.title.text,t,n,e.data.title)}
180
180
  <c:overlay val="0" />
@@ -1008,4 +1008,4 @@ If you meant to create a named range, named range cannot have the same name as a
1008
1008
  <Relationships xmlns="${em.Relationships}">
1009
1009
  <Relationship ${Y(e)} />
1010
1010
  </Relationships>
1011
- `),`_rels/.rels`)}function vJ(e){let t={},n=[];for(let r of e.sheets){let e=r.name.slice(0,31);e=En(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(`'?${At(e)}'?!`,`g`);i=i.replaceAll(n,n=>{let r=t[e];return n.replace(e,r)})}return JSON.parse(i)}function yJ(e){for(let t of e.sheets)t.tables=t.tables.filter(e=>yr(tr(e.range)).numberOfRows>1);return e}var bJ=class e extends Ki{statefulUIPlugins=[];range;formulasPlugin;session;isReplayingCommand=!1;renderers={};status=0;config;corePluginConfig;evaluationPluginConfig;uiPluginConfig;state;selection;getters;coreGetters;evaluationGetters;handlers=[];uiHandlers=[];coreHandlers=[];evaluationHandlers=[];constructor(e={},t={},n=[],r=!1){let i=performance.now();console.debug(`##### Model creation #####`),super(),wo(),n=JC(e,n);let a=BC(e,r);this.state=new MK,this.config=this.setupConfig(t),this.getters={isReadonly:()=>this.config.mode===`readonly`||this.config.mode===`dashboard`,isDashboard:()=>this.config.mode===`dashboard`},this.evaluationGetters={isReadonly:()=>this.config.mode===`readonly`||this.config.mode===`dashboard`,isDashboard:()=>this.config.mode===`dashboard`},this.coreGetters={},this.session=this.setupSession(a.revisionId),this.range=new OK(this.coreGetters);for(let e of OK.getters)this.registerCoreGetter(this.range,e);this.formulasPlugin=new DK;for(let e of DK.getters)this.registerCoreGetter(this.formulasPlugin,e);this.selection=new AK(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.getCorePluginConfig(),this.evaluationPluginConfig=this.getEvaluationPluginConfig(),this.uiPluginConfig=this.getUiPluginConfig();for(let e of JV.getAll())this.setupCorePlugin(e,a);this.session.loadInitialMessages(n);for(let e of ZV.getAll()){let t=this.setupEvaluationPlugin(e);this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t),this.evaluationHandlers.push(t)}for(let e of XV.getAll()){let t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t),this.evaluationHandlers.push(t)}for(let e of YV.getAll()){let t=this.setupUiPlugin(e);this.handlers.push(t),this.uiHandlers.push(t),this.evaluationHandlers.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()?en(()=>this.exportData()):void 0;await this.session.leave(t)}registerCoreGetter(e,t){if(!(t in e))throw Error(`Invalid getter name: ${t} for plugin ${e.constructor}`);if(t in this.coreGetters)throw Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=e[t].bind(e),this.evaluationGetters[t]=e[t].bind(e),this.getters[t]=e[t].bind(e)}registerEvaluationGetter(e,t){if(!(t in e))throw Error(`Invalid getter name: ${t} for plugin ${e.constructor}`);if(t in this.evaluationGetters)throw Error(`Getter "${t}" is already defined.`);this.evaluationGetters[t]=e[t].bind(e),this.getters[t]=e[t].bind(e)}registerUiGetter(e,t){if(!(t in e))throw Error(`Invalid getter name: ${t} for plugin ${e.constructor}`);if(t in this.getters)throw Error(`Getter "${t}" is already defined.`);this.getters[t]=e[t].bind(e)}setupUiPlugin(e){let t=new e(this.uiPluginConfig);for(let n of e.getters)this.registerUiGetter(t,n);for(let n of e.layers)this.renderers[n]||(this.renderers[n]=[]),this.renderers[n].push(t);return t}setupEvaluationPlugin(e){let t=new e(this.evaluationPluginConfig);for(let n of e.getters)this.registerEvaluationGetter(t,n);return t}setupCorePlugin(e,t){let n=new e(this.corePluginConfig);for(let t of e.getters)this.registerCoreGetter(n,t);n.import(t),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 bV(wK({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 hK(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:K.smallUuid(),name:N(`Anonymous`).toString()},n=e.transportService||new rG,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 gK(n):n,client:t,moveClient:()=>{},snapshotRequested:!1,customColors:e.customColors||[]}}setupExternalConfig(e){let t=e.loadLocales||(()=>Promise.resolve(Es));return{...e,loadLocales:t}}getCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,formulasPlugin:this.formulasPlugin,dispatch:this.dispatchFromCorePlugin,canDispatch:this.canDispatch,custom:this.config.custom,external:this.config.external}}getEvaluationPluginConfig(){return{getters:this.evaluationGetters,stateObserver:this.state,custom:this.config.custom,session:this.session,dispatch:this.dispatchFromEvaluationPlugin,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external}}getUiPluginConfig(){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,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external,colorScheme:this.config.colorScheme}}checkDispatchAllowed(e){let t=Wd(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return this.processCommandResults(t)}processCommandResults(e){return e.some(e=>e!==`Success`)?new Jd(e.flat()):Jd.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.filter(t=>this.canHandle(t,e)).map(t=>t.allowDispatch(e))}canHandle(e,t){return e instanceof lv?Wd(t):e instanceof LE?Kd(t):!0}finalize(){this.status=4;for(let e of this.handlers)e.finalize();this.status=0,this.trigger(`command-finalized`)}canDispatch=(e,t)=>this.checkDispatchAllowed(xJ(e,t));dispatch=(e,t)=>{let n=xJ(e,t),r=this.status;if(this.getters.isReadonly()&&!qd(n))return new Jd(`Readonly`);if(!this.session.canApplyOptimisticUpdate())return new Jd(`WaitingSessionConfirmation`);switch(r){case 0:if(Gd(n)){this.status=3;let t=performance.now();this.dispatchToHandlers(this.handlers,n),this.finalize();let r=performance.now()-t;r>5&&console.debug(e,r,`ms`),this.status=0,this.trigger(`update`);break}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();Wd(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(Wd(n)){let e=this.checkDispatchAllowed(n);if(!e.isSuccessful)return e;this.state.addCommand(n)}this.dispatchToHandlers(this.handlers,n);break;case 4:throw Error(`Cannot dispatch commands in the finalize state`);case 2:if(Wd(n))throw Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,n);break;case 3:if(!Gd(n))throw Error(`A top level evaluation command cannot dispatch non-evaluation commands (${e})`);break}return Jd.Success};dispatchFromCorePlugin=(e,t)=>{let n=xJ(e,t),r=this.status;this.status=2;let i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,n),this.status=r,Jd.Success};dispatchFromEvaluationPlugin=(e,t)=>{let n=xJ(e,t);if(!Gd(n))throw Error(`An evaluation plugin cannot dispatch non-evaluation commands (${e})`);return this.status===0?(this.status=3,this.dispatchToHandlers(this.evaluationHandlers,n),this.finalize(),this.status=0,this.trigger(`update`),Jd.Success):(this.dispatchToHandlers(this.evaluationHandlers,n),Jd.Success)};dispatchToHandlers(e,t){let n=e.filter(e=>this.canHandle(e,t));for(let e of n)e.beforeHandle(t);for(let e of n)e.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 rG};return T(n,new e(x(t),r)._exportData(!1))?t:(n.isNotSquishable=!0,n)}_exportData(e){let t=tw();for(let n of this.handlers)n instanceof lv&&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=rw();for(let t of this.handlers)t instanceof cv&&await t.exportForExcel(e);return e=x(e),lJ(e)}};function xJ(e,t={}){let n=x(t);return n.type=e,n}var SJ=class extends UW{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(D(t))}executeQueuedChanges(e){for(let t in this.queuedBordersToAdd){let n=this.queuedBordersToAdd[t],r=JSON.parse(t),i=Wn(n,[]);this.dispatch(`SET_BORDERS_ON_TARGET`,{sheetId:e,target:i,border:r})}this.queuedBordersToAdd={}}},CJ=class extends HW{copy(e){}getCopyRect(e){return Ng(...e.figureIds.map(t=>this.getters.getFigure(e.sheetId,t)).filter(w).map(t=>this.getters.getFigureUI(e.sheetId,t)))}},wJ=class extends CJ{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]=K.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}=A_(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=K.smallUuid(),r=bN.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:this.getters.carouselToCarouselData({...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`}},TJ=class extends CJ{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]=K.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=bN.fromDefinition(this.getters,i,l.copyInSheetId(i)).getDefinition();u=bN.fromStrDefinition(this.getters,i,u).getDefinition();let{col:d,row:f,offset:p}=A_(this.getters,i,{col:r[0].left,row:r[0].top},{...a.copiedFigure,offset:a.offset});this.dispatch(`CREATE_CHART`,{figureId:o,chartId:K.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`}},EJ=class extends UW{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=D(e.position),i=D(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:K.smallUuid(),ranges:[]}}},DJ=class extends UW{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=D(t),i=D(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?K.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=Wn([...Wn(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})}}},OJ=class extends UW{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 qe){t.style[n]={sheetDefault:this.getters.getDefaultStyle(e.sheetId,n,`SHEET`,void 0)??qe[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}adaptContentToZone(e,t){let n=Math.max(Math.floor((e.right-e.left+1)/t.width),1),r=Math.max(Math.floor((e.bottom-e.top+1)/t.height),1);if(n===1&&r===1)return t;let i=x(t);i.height*=r,i.width*=n,r>1&&i.format.rowDefault&&(i.format.rowDefault.length=t.height,i.format.rowDefault=Nn(i.format.rowDefault,r)),n>1&&i.format.colDefault&&(i.format.colDefault.length=t.width,i.format.colDefault=Nn(i.format.colDefault,n));for(let e in t.style)r>1&&i.style[e].rowDefault&&(i.style[e].rowDefault.length=t.height,i.style[e].rowDefault=Nn(i.style[e].rowDefault,r)),n>1&&i.style[e].colDefault&&(i.style[e].colDefault.length=t.width,i.style[e].colDefault=Nn(i.style[e].colDefault,n));return i}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){let n=this.adaptContentToZone(e,t);this.pasteStyle(r,e.left,e.top,n.width,n.height,n.style),this.pasteFormat(r,e.left,e.top,n.width,n.height,n.format)}}clearClippedZones(e){this.dispatch(`CLEAR_FORMATTING`,{sheetId:e.sheetId,target:e.zones})}pasteStyle(e,t,n,r,i,a){let o=jn({}),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},qe);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);Yt(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];r!==void 0&&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})}},kJ=class extends CJ{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]=K.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}=A_(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`}},AJ=class extends UW{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}]})}},jJ=class extends UW{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})}}},MJ=class extends UW{isPasteAllowed(e,t,n,r){if(!(`cells`in n))return`Success`;let{xSplit:i,ySplit:a}=this.getters.getPaneDivisions(e);return Pr(B_(t,n.cells),i,a)?`FrozenPaneOverlap`:`Success`}},NJ=class extends UW{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=>vr(f,e))){s.add(u.id);let{numberOfRows:e}=yr(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=>vr(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=sn({...this.getters.getCellTableStyle(e),hideGridLines:!1}),n=this.getters.getCellStyle(e),r=this.getters.getCellTableBorder(e),i=this.getters.getCellBorder(e);return{style:{...t,...sn(n)},border:{...r,...sn(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=yr(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}))}};iw.figureHandlers.add(`chart`,TJ).add(`image`,kJ).add(`carousel`,wJ),iw.cellHandlers.add(`dataValidation`,DJ).add(`default`,OJ).add(`cell`,WW).add(`sheet`,MJ).add(`merge`,AJ).add(`border`,SJ).add(`table`,NJ).add(`conditionalFormat`,EJ).add(`references`,jJ);var PJ=class extends k{static maxSize={maxHeight:80};static template=`o-spreadsheet-ErrorToolTip`;props=(0,t.useProps)({cellPosition:M.CellPosition(),onClosed:M.function().optional()});viewStore;setup(){this.viewStore=A(W)}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,D(e)),this.viewStore.displayedSheetId)}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===P.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 An(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?N(`Add missing columns and rows`):e.missingCols>0?N(`Add missing columns`):N(`Add missing rows`)}};let FJ={onHover:(e,t)=>{let n=t.getEvaluatedCell(e);return n.type===`error`&&n.message||t.getInvalidDataValidationMessage(e)?{isOpen:!0,props:{cellPosition:e},Component:PJ,cellCorner:`top-right`}:{isOpen:!1}}};var IJ=class extends k{static template=`o-spreadsheet-FilterMenu`;static components={FilterMenuValueList:PR,SidePanelCollapsible:MP,FilterMenuCriterion:MR};props=(0,t.useProps)({filterPosition:M.Position(),onClosed:M.function().optional()});state;criterionCategory=`text`;updatedCriterionValue;viewStore;setup(){this.viewStore=A(W),(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.viewStore.displayedSheetId,t=this.props.filterPosition;return this.env.model.getters.getTable({sheetId:e,...t})}get filterValueType(){let e=this.viewStore.displayedSheetId,t=this.props.filterPosition;return this.env.model.getters.getFilterValue({sheetId:e,...t})?.filterType}getCriterionCategory(e){let t=this.viewStore.displayedSheetId,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&&vc(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.viewStore.displayedSheetId,value:this.updatedCriterionValue}),this.props.onClosed?.()}get criterionOperators(){return this.criterionCategory===`date`?vR:this.criterionCategory===`number`?_R:gR}cancel(){this.props.onClosed?.()}sortFilterZone(e){let t=this.props.filterPosition,n=this.table,r=n?.range.zone;if(!t||!r||r.top===r.bottom)return;let i=this.viewStore.displayedSheetId,a={...r,top:r.top+n.config.numberOfHeaders},o={col:t.col,row:a.top};Rk(this.env,i,o,a,e,{emptyCellAsZero:!0,sortHeaders:!0}),this.props.onClosed?.()}getFilterHiddenValues(e){let t=this.viewStore.displayedSheetId,n=this.env.model.getters.getFilter({sheetId:t,...e});if(!n?.filteredRange)return[];let r=this.env.model.getters.getFilterValue({sheetId:t,...e}),i=Sr(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(Rp)),c=new Set,l=[],u=e=>{let t=Rp(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.viewStore.displayedSheetId,n=this.env.model.getters.getFilterCriterionValue({sheetId:t,...e});return n?.filterType===`criterion`?x(n):{filterType:`criterion`,type:`none`,values:[]}}};let LJ={onOpen:(e,t)=>({isOpen:!0,props:{filterPosition:e},Component:IJ,cellCorner:`bottom-left`})};var RJ=class extends k{static template=`o-spreadsheet-LinkDisplay`;props=(0,t.useProps)({cellPosition:M.CellPosition(),onClosed:M.function().optional()});cellPopovers;viewStore;setup(){this.cellPopovers=A(jE),this.viewStore=A(W)}get cell(){let{col:e,row:t}=this.props.cellPosition,n=this.viewStore.displayedSheetId;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 nf(e,this.env.model.getters)}openLink(e){rf(this.link,this.env,de(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.viewStore.displayedSheetId,{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 zJ={onHover:(e,t)=>{let n=t.getEvaluatedCell(e);return!t.isDashboard()&&n.link?{isOpen:!0,Component:RJ,props:{cellPosition:e},cellCorner:`bottom-left`}:{isOpen:!1}}};var BJ=class extends k{static template=`o-spreadsheet-LinkEditor`;static components={MenuPopover:zw};props=(0,t.useProps)({cellPosition:M.CellPosition(),onClosed:M.function().optional()});static size={maxHeight:500};urlInput=t.signal.ref(HTMLInputElement);suggestionListRef=t.signal.ref();urlInputContainer=t.signal.ref();state;viewStore;setup(){this.viewStore=A(W),this.state=(0,t.proxy)(this.defaultState),this.computeLinks(),(0,t.onMounted)(()=>this.urlInput()?.focus())}onLinkUrlInput(e){this.state.url=e.target.value,this.computeLinks()}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 Qd.getKeys()){let i=Qd.get(r),a=i.getLinkProposals?.(this.env)||[],o=n&&this.state.isUrlEditable?QM(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.viewStore.displayedSheetId,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 nf(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?J_(this.state.label,n):this.state.url;this.env.model.dispatch(`UPDATE_CELL`,{col:e,row:t,sheetId:this.viewStore.displayedSheetId,content:Ut(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`})}};AE.add(`ErrorToolTip`,FJ).add(`LinkCell`,zJ).add(`LinkEditor`,{onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:BJ,cellCorner:`bottom-left`})}).add(`FilterMenu`,LJ);let VJ=Object.freeze({value:null}),HJ=Object.freeze({value:1}),UJ={supportedChartTypes:jC,fromExternalDefinition(e,t,n){let r=bm(n,t,e),i=ju(n,t,e.labelRange);return{...e,dataSets:r,labelRange:i}},fromContextCreation(e){return{type:`range`,dataSets:[],dataSetsHaveTitle:!1,labelRange:e.auxiliaryRange,...e.dataSource}},fromHierarchicalContextCreation(e){if(e.dataSource?.type!==`range`||e.hierarchicalDataSource!==void 0&&e.hierarchicalDataSource.type!==`range`)return{type:`range`,dataSets:[],dataSetsHaveTitle:!1};let t={type:`range`,dataSets:[],dataSetsHaveTitle:e.dataSource?.dataSetsHaveTitle??!1,labelRange:e.dataSource?.dataSets?.[0]?.dataRange};return e.hierarchicalDataSource?.dataSets.length?t=e.hierarchicalDataSource:e.auxiliaryRange&&(t={...t,dataSets:[{dataRange:e.auxiliaryRange,dataSetId:`0`}]}),t},validate:(e,t)=>t.checkValidations(e,Em,Dm),transform(e,t,{adaptRangeString:n}){let r;if(e.labelRange){let{changeType:i,range:a}=n(t,e.labelRange);i!==`REMOVE`&&(r=a)}let i=[];for(let r of e.dataSets){let e={...r},{changeType:a,range:o}=n(t,r.dataRange);a!==`REMOVE`&&(e.dataRange=o,i.push(e))}return{...e,dataSets:i,labelRange:r}},extractData:(e,t,n)=>WJ(n,e),extractHierarchicalData(e,t,n){let r=e.dataSets,i=e.labelRange,a=KJ(n,r,i),o=qJ(n,r),s={labelValues:a,dataSetsValues:o};return Om(a.length,o[0]?.data.length+(o[0]?.label===void 0?0:1),e.dataSetsHaveTitle||!1)&&a.shift(),s},adaptRanges(e,{applyChange:t}){let n=e.dataSets.map(e=>{let{range:n,changeType:r}=t(e.dataRange);if(r===`REMOVE`)return;let i;if(e.labelCell){let{range:n,changeType:r}=t(e.labelCell);r!==`REMOVE`&&(i=n)}return{...e,dataRange:n,labelCell:i}}).filter(w),r=e.labelRange;if(r){let{range:e,changeType:n}=t(r);r=n===`REMOVE`?void 0:e}let i=n;return{...e,dataSets:i,labelRange:r?.invalidSheetName||r?.invalidXc?void 0:r}},getDefinition(e,t,n){return{labelRange:e.labelRange?n.getRangeString(e.labelRange,t):void 0,type:`range`,dataSets:e.dataSets.map(e=>({dataSetId:e.dataSetId,dataRange:n.getRangeString(e.dataRange,t)})),dataSetsHaveTitle:e.dataSetsHaveTitle}},duplicateInDuplicatedSheet(e,t,n,r){return{...e,labelRange:vm(t,n,e.labelRange),dataSets:e.dataSets.map(e=>({...e,dataRange:Au(t,n,e.dataRange)}))}},getContextCreation:e=>({auxiliaryRange:e.labelRange,dataSource:e}),getHierarchicalContextCreation(e){let t=e.dataSets.at(-1)?.dataRange,n=e.dataSetsHaveTitle;return{auxiliaryRange:t,hierarchicalDataSource:e,dataSource:e.labelRange?{type:`range`,dataSets:[{dataRange:e.labelRange,dataSetId:`0`}],dataSetsHaveTitle:n}:{type:`range`,dataSets:[],dataSetsHaveTitle:n}}},toExcelDataSets(e,t,n){let r=e.dataSets,i=e.labelRange,a=r.map(e=>Sm(n,t,e)).filter(e=>e.range!==``&&e.range!==P.InvalidReference),o=r[0]?Mr(r[0].dataRange.zone):void 0;return{dataSets:a,labelRange:Cm(n,i,Om(i?Mr(i.zone):0,o,e.dataSetsHaveTitle))}}};function WJ(e,t){let n=t.dataSets,r=t.labelRange,i=KJ(e,n,r),a=GJ(e,n,r),o={labelValues:i,dataSetsValues:a},s=a.length?a[0]?.data.length+(a[0]?.label===void 0?0:1):0;return Om(i.length,s,t.dataSetsHaveTitle||!1)&&i.shift(),o}function GJ(e,t,n){let r=[];for(let[i,a]of Object.entries(t)){let t=`${pT.Series} ${parseInt(i)+1}`,o=e.isColHidden(a.dataRange.sheetId,a.dataRange.zone.left);if(a.labelCell){let{sheetId:n,zone:r}=a.labelCell,i=e.getEvaluatedCell({sheetId:n,col:r.left,row:r.top});i&&(t=i.formattedValue)}let s=a.dataRange?JJ(e,a):[];if(!s.some(e=>mf(e))&&s.some(e=>gf(e))){let e=!n||n.sheetId===a.dataRange.sheetId&&mr(n.zone,a.dataRange.zone);s=s.map(t=>gf(t)?e?HJ:{value:+!!t.value}:VJ)}else s.every(e=>!e.value||hf(e))&&s.filter(hf).length>1?s=s.map(e=>e.value&&!_f(e)?HJ:VJ):s.every(e=>!mf(e))&&(o=!0);r.push({data:s,label:t,hidden:o,dataSetId:a.dataSetId})}return r}function KJ(e,t,n){if(n){let{left:t}=n.zone;if(!n.invalidXc&&!n.invalidSheetName&&!e.isColHidden(n.sheetId,t))return e.getVisibleRangeValues(n)}if(t[0]){let n=JJ(e,t[0]).length;return Array.from({length:n},()=>({value:``}))}return[]}function qJ(e,t){t=t.filter(t=>!e.isColHidden(t.dataRange.sheetId,t.dataRange.zone.left));let n=t.map(e=>({data:[],label:``,dataSetId:e.dataSetId})),r=e.getLocale(),i=t.map(t=>JJ(e,t)).map(e=>e.map(({value:e,format:t})=>e===null?VJ:{value:V(e,{format:t,locale:r})}));if(!i.length)return n;let a=Math.min(...i.map(e=>e.length)),o=[],s=t.length-1;for(let e=0;e<a;e++)for(let t=0;t<i.length;t++){let r=i[t][e];(r===void 0||r.value===null)&&t!==s&&(r=o[t]),r?.value!==o[t]?.value&&(o=o.slice(0,t),o[t]=r),n[t].data.push(r??VJ)}return n.filter(e=>e.data.some(e=>e.value!==null))}function JJ(e,t){if(t.dataRange){let n=t.labelCell?[t.labelCell.zone]:[],r=Wn([t.dataRange.zone],n)[0];if(r===void 0)return[];let i=e.getRangeFromZone(t.dataRange.sheetId,r);return e.getVisibleRangeValues(i).map(e=>e.value===``?VJ:e)}return[]}wb.add(`range`,UJ),wb.add(`none`,{supportedChartTypes:[],fromExternalDefinition:()=>({type:`none`}),fromContextCreation:()=>({type:`none`}),fromHierarchicalContextCreation:()=>({type:`none`}),validate:()=>`Success`,transform:()=>({type:`none`}),extractData:()=>({dataSetsValues:[],labelValues:[]}),extractHierarchicalData:()=>({dataSetsValues:[],labelValues:[]}),adaptRanges:e=>e,getDefinition:e=>e,duplicateInDuplicatedSheet:e=>e,getContextCreation:()=>({}),getHierarchicalContextCreation:()=>({}),toExcelDataSets:()=>({dataSets:[],labelRange:void 0})}),$M.add(`dataValidation`,{displayAllOnInitialContent:!0,canBeToggled:!1,getProposals(e,t){if(Dn(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:tp(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()}}),$M.add(`functions_and_named_ranges`,{sequence:100,autoSelectFirstProposal:!0,maxDisplayedProposals:10,getProposals(e){if(e.type!==`SYMBOL`)return[];let t=e.value;if(!Dn(this.composer.currentContent))return[];let n=Object.entries(ul.content).filter(([e,{hidden:t}])=>!t).map(([e,{description:n}])=>({type:`function`,text:e,icon:`o-spreadsheet-Icon.FX_SVG`,description:n,htmlContent:BL(t,e,Fe,`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:BL(t,e.name,Fe,`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 YJ(e,t){for(let n=0;n<t.length;n++){let r=t[n].proposalValues;r===void 0||r.length===0||$M.add(`${e}_function_${t[n].name}_argument_proposals`,{sequence:50,autoSelectFirstProposal:!0,selectProposal:XJ,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`?St.STRING:St.NUMBER}],fuzzySearchKey:o,alwaysExpanded:!0})}return a}})}}function XJ(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)}ul.getAll().forEach(e=>YJ(e.name,e.args)),$M.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:St.NUMBER}],fuzzySearchKey:n+t.name,alwaysExpanded:!0}}).filter(w)},selectProposal:XJ}),$M.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=iR(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:N(`Count`),htmlContent:[{value:e,color:St.STRING}],fuzzySearchKey:N(`Count`)+e}}return tR(e)}).filter(w):[]},selectProposal:XJ}),$M.add(`pivot_group_fields`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!ZJ(e)&&!QJ(e))return;let n=iR(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=sR.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?eR(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:N(`%s (positional)`,t.string)+(t.help?` (${t.help})`:``),htmlContent:[{value:n,color:St.STRING}],fuzzySearchKey:t.string+n}})).filter(w)},selectProposal:XJ});function ZJ(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==0}function QJ(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==1}$M.add(`pivot_group_values`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!e||!$J(e)&&!eY(e))return;let n=iR(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(tc).map((e,t)=>({text:`${t+1}`,fuzzySearchKey:e.toString(),description:e.toString(),htmlContent:[{value:`${t+1}`,color:St.NUMBER}]})):s.granularity===`quarter_number`?[1,2,3,4].map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:N(`Quarter %s`,e),htmlContent:[{value:`${e}`,color:St.NUMBER}]})):s.granularity===`day_of_month`?C(1,32).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:St.NUMBER}]})):s.granularity===`iso_week_number`?C(0,54).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:St.NUMBER}]})):s.granularity===`day_of_week`?C(1,8).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:St.NUMBER}]})):s.granularity===`hour_number`?C(0,24).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:St.NUMBER}]})):s.granularity===`minute_number`?C(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:St.NUMBER}]})):s.granularity===`second_number`?C(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:St.NUMBER}]})):i.getPossibleFieldValues(s).map(({value:e,label:t})=>{let n=typeof e==`string`,r=n?`"${e}"`:e.toString(),i=n?St.STRING:St.NUMBER,a=t===e?``:t;return{text:r,description:a,htmlContent:[{value:r,color:i}],fuzzySearchKey:r+a}})},selectProposal:XJ});function $J(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==1}function eY(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==0}$M.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=Pt(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 tY(e){return e.yRanges.length&&!vl.test(e.yRanges[0])?`InvalidYRange`:e.xRange&&!vl.test(e.xRange)?`InvalidXRange`:e.labelRange&&!vl.test(e.labelRange)?`InvalidLabelRange`:e.sizeRange&&!vl.test(e.sizeRange)?`InvalidBubbleSizeRange`:`Success`}let nY={sequence:40,allowedDefinitionKeys:[...gg.commonKeys,`yRanges`,`xRange`,`labelRange`,`sizeRange`,`dataSetsHaveTitle`,`verticalAxisPosition`,`labelsAsText`,`bubbleColor`,`legendPosition`,`axesDesign`,`showValues`],fromStrDefinition(e,t,n){let r=e.yRanges.map(e=>ju(n,t,e)).filter(w),i=ju(n,t,e.xRange),a=ju(n,t,e.labelRange),o=ju(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,tY)},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)}},getFormulas:()=>[],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=>ym(e,t)).filter(w),r=ym(e.xRange,t),i=ym(e.labelRange,t),a=ym(e.sizeRange,t);return{...e,yRanges:n,xRange:r,labelRange:i,sizeRange:a}},duplicateInDuplicatedSheet(e,t,n){let r=e=>vm(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,n,r,i,a){let o=dF(t,e,a);return{chartJsConfig:{type:`line`,data:{datasets:Mh(t,o),labels:o.labels},options:{...m_,layout:IF(t,o),scales:mh(t,o),plugins:{title:vI(t,e),legend:tI(t,o),tooltip:TI(t,o),chartShowValuesPlugin:fI(t,o),background:{color:o.background}}}}}}};function rY(e){return!$I.includes(e.horizontalGroupBy)||!$I.includes(e.verticalGroupBy)?`InvalidChartDefinition`:`Success`}let iY={sequence:110,dataSeriesLimit:1,allowedDefinitionKeys:[...gg.commonKeys,`dataSource`,`dataSetStyles`,`showValues`,`colorScale`,`missingValueColor`,`axesDesign`,`horizontalGroupBy`,`verticalGroupBy`,`legendPosition`],validateDefinition(e,t){return e.checkValidations(t,rY)},fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,updateRanges:e=>e,getContextCreation:e=>e,getFormulas:()=>[],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},r,i,a){let o=rF(t,n(),e,a),{labels:s,datasets:c}=Oh(t,o);return{chartJsConfig:{type:`calendar`,data:{labels:s,datasets:c},options:{...m_,indexAxis:`x`,layout:LF(t,o),scales:ch(t,c),plugins:{title:vI(t,e),legend:{display:!1},tooltip:CI(t,o),chartShowValuesPlugin:pI(t,o),chartColorScalePlugin:lh(t,o),background:{color:o.background}}}}}}},aY={sequence:15,allowedDefinitionKeys:[...gg.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,getFormulas:()=>[],getDefinitionForExcel(e,t,{dataSets:n,labelRange:r}){return{...t,backgroundColor:ZP(t.background||`#FFFFFF`),fontColor:ZP(wm(t.background)),dataSets:n,labelRange:r,verticalAxis:km(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,a){let o=eF(t,n(),e,a);return{chartJsConfig:{type:`bar`,data:{labels:o.labels,datasets:Fh(t,o)},options:{...m_,layout:IF(t,o),scales:sh(t,o),plugins:{title:vI(t,e),legend:nI(t,o),tooltip:SI(t,o),chartShowValuesPlugin:fI(t,o),background:{color:o.background}},...i}},customizableSeries:o.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},oY={sequence:100,dataSeriesLimit:1,allowedDefinitionKeys:[...gg.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,getFormulas:()=>[],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,a){let o=lF(t,n(),e,a);return{chartJsConfig:{type:`funnel`,data:{labels:o.labels,datasets:Rh(t,o)},options:{...m_,indexAxis:`y`,layout:IF(t,o),scales:yh(t,o),plugins:{title:vI(t,e),legend:{display:!1},tooltip:jI(t,o),chartShowValuesPlugin:fI(t,o),background:{color:o.background}},...i}}}}},sY={sequence:90,dataSeriesLimit:1,allowedDefinitionKeys:[...gg.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,getFormulas:()=>[],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,a){let o=cF(t,n(),e,a);return{chartJsConfig:{type:`choropleth`,data:{datasets:Lh(t,o)},options:{...m_,layout:IF(t,o),scales:vh(t,o),plugins:{title:vI(t,e),tooltip:AI(t,o),legend:{display:!1},background:{color:o.background}},...i}}}},loadDataForExport:async e=>e.loadUsedGeoJsonFeatures()},cY={sequence:80,dataSeriesLimit:2,allowedDefinitionKeys:[...gg.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,getFormulas:()=>[],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{dataSetsValues:i}=iF(t,WJ(e,t.dataSource),e,`light`),a=Math.max(...i.map(e=>Math.max(...e.data.map(e=>mf(e)?Math.abs(e.value):-1/0))));return{...t,horizontal:!0,backgroundColor:ZP(t.background||`#FFFFFF`),fontColor:ZP(wm(t.background)),dataSets:n,labelRange:r,verticalAxis:km(t),maxValue:a}},getRuntime(e,t,{extractData:n},r,i,a){let o=iF(t,n(),e,a);return{chartJsConfig:{type:`bar`,data:{labels:o.labels,datasets:Eh(t,o)},options:{...m_,indexAxis:`y`,layout:IF(t,o),scales:gh(t,o),plugins:{title:vI(t,e),legend:ZF(t,o),tooltip:OI(t,o),chartShowValuesPlugin:hI(t,o),background:{color:o.background}},...i}},customizableSeries:o.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},lY={sequence:80,allowedDefinitionKeys:[...gg.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,getFormulas:()=>[],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:ZP(t.background||`#FFFFFF`),fontColor:ZP(wm(t.background)),dataSets:n,labelRange:r}},getRuntime(e,t,{extractData:n},r,i,a){let o=sF(t,n(),e,a);return{chartJsConfig:{type:`radar`,data:{labels:o.labels,datasets:Ih(t,o)},options:{...m_,layout:IF(t,o),scales:_h(t,o),plugins:{title:vI(t,e),legend:iI(t,o),tooltip:kI(t,o),chartShowValuesPlugin:fI(t,o),background:{color:o.background}},...i}},customizableSeries:o.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},uY={sequence:60,allowedDefinitionKeys:[...gg.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,getFormulas:()=>[],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:ZP(t.background||`#FFFFFF`),fontColor:ZP(wm(t.background)),dataSets:n,labelRange:r,verticalAxis:km(t)}},getRuntime(e,t,{extractData:n},r,i,a){let o=aF(t,n(),e,a);return{chartJsConfig:{type:`line`,data:{labels:o.labels,datasets:jh(t,o)},options:{...m_,layout:IF(t,o),scales:ph(t,o),plugins:{title:vI(t,e),legend:eI(t,o),tooltip:wI(t,o),chartShowValuesPlugin:fI(t,o),background:{color:o.background}},...i}},customizableSeries:o.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},dY={sequence:30,allowedDefinitionKeys:[...gg.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,getFormulas:()=>[],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,a){let o=uF(t,n(),e,a);return{chartJsConfig:{type:`doughnut`,data:{datasets:Bh(t,o)},options:{cutout:t.pieHolePercentage===void 0?`25%`:`${t.pieHolePercentage}%`,...m_,layout:IF(t,o),plugins:{title:vI(t,e),legend:aI(t,o),tooltip:MI(t,o),sunburstLabelsPlugin:mI(t,o),sunburstHoverPlugin:{enabled:!0},background:{color:o.background}},...i}}}}},fY={sequence:100,allowedDefinitionKeys:[...gg.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,getFormulas:()=>[],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,a){let o=uF(t,n(),e,a);return{chartJsConfig:{type:`treemap`,data:{labels:o.labels,datasets:Gh(t,o)},options:{...m_,layout:IF(t,o),plugins:{title:vI(t,e),legend:{display:!1},tooltip:NI(t,o),background:{color:o.background}},...i}}}}};Tb.add(`bar`,LI),Tb.add(`combo`,aY),Tb.add(`line`,JI),Tb.add(`pie`,YI),Tb.add(`scorecard`,Eg),Tb.add(`gauge`,UI),Tb.add(`scatter`,uY),Tb.add(`waterfall`,XI),Tb.add(`pyramid`,cY),Tb.add(`radar`,lY),Tb.add(`geo`,sY),Tb.add(`funnel`,oY),Tb.add(`sunburst`,dY),Tb.add(`treemap`,fY),Tb.add(`calendar`,iY),Tb.add(`bubble`,nY),Ug.add(`line`,{matcher:e=>e.type===`line`&&!e.stacked&&!e.fillArea,displayName:N(`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:N(`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:N(`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:N(`Stacked Area`),chartType:`line`,chartSubtype:`stacked_area`,subtypeDefinition:{stacked:!0,fillArea:!0},category:`area`,preview:`o-spreadsheet-ChartPreview.STACKED_AREA_CHART`}).add(`scatter`,{displayName:N(`Scatter`),chartType:`scatter`,chartSubtype:`scatter`,category:`misc`,preview:`o-spreadsheet-ChartPreview.SCATTER_CHART`}).add(`bubble`,{displayName:N(`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:N(`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:N(`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:N(`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:N(`Stacked Bar`),chartType:`bar`,chartSubtype:`stacked_bar`,subtypeDefinition:{horizontal:!0,stacked:!0},category:`bar`,preview:`o-spreadsheet-ChartPreview.STACKED_BAR_CHART`}).add(`combo`,{displayName:N(`Combo`),chartSubtype:`combo`,chartType:`combo`,category:`line`,preview:`o-spreadsheet-ChartPreview.COMBO_CHART`}).add(`pie`,{matcher:e=>e.type===`pie`&&!e.isDoughnut,displayName:N(`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:N(`Doughnut`),chartSubtype:`doughnut`,chartType:`pie`,subtypeDefinition:{isDoughnut:!0},category:`pie`,preview:`o-spreadsheet-ChartPreview.DOUGHNUT_CHART`}).add(`gauge`,{displayName:N(`Gauge`),chartSubtype:`gauge`,chartType:`gauge`,category:`misc`,preview:`o-spreadsheet-ChartPreview.GAUGE_CHART`}).add(`scorecard`,{displayName:N(`Scorecard`),chartSubtype:`scorecard`,chartType:`scorecard`,category:`misc`,preview:`o-spreadsheet-ChartPreview.SCORECARD_CHART`}).add(`waterfall`,{displayName:N(`Waterfall`),chartSubtype:`waterfall`,chartType:`waterfall`,category:`misc`,preview:`o-spreadsheet-ChartPreview.WATERFALL_CHART`}).add(`pyramid`,{displayName:N(`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:N(`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:N(`Filled Radar`),chartType:`radar`,chartSubtype:`filled_radar`,subtypeDefinition:{fillArea:!0},category:`misc`,preview:`o-spreadsheet-ChartPreview.FILLED_RADAR_CHART`}).add(`geo`,{displayName:N(`Geo Chart`),chartSubtype:`geo`,chartType:`geo`,category:`misc`,preview:`o-spreadsheet-ChartPreview.GEO_CHART`}).add(`funnel`,{displayName:N(`Funnel`),chartSubtype:`funnel`,chartType:`funnel`,category:`misc`,preview:`o-spreadsheet-ChartPreview.FUNNEL_CHART`}).add(`sunburst`,{matcher:e=>e.type===`sunburst`,displayName:N(`Sunburst`),chartSubtype:`sunburst`,chartType:`sunburst`,category:`hierarchical`,preview:`o-spreadsheet-ChartPreview.SUNBURST_CHART`}).add(`treemap`,{matcher:e=>e.type===`treemap`,displayName:N(`Tree Map`),chartType:`treemap`,chartSubtype:`treemap`,category:`hierarchical`,preview:`o-spreadsheet-ChartPreview.TREE_MAP_CHART`}).add(`calendar`,{displayName:N(`Calendar`),chartSubtype:`calendar`,chartType:`calendar`,category:`misc`,preview:`o-spreadsheet-ChartPreview.CALENDAR_CHART`}),HV.add(`filter_icon`,(e,t)=>{if(e.isFilterHeader(t)){let n=e.isFilterActive(t),r=Lf(e.getCellComputedStyle(t).fillColor||`#fff`)<.45;return{type:`filter_icon`,svg:Py(n,r,!1),hoverSvg:Py(n,r,!0),priority:3,horizontalAlign:`right`,size:17,margin:2,position:t,onClick:(e,t)=>{let n=t.getStore(jE),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 pY=l({ARRAYTOTEXT:()=>HY,ARRAY_CONSTRAIN:()=>gY,ARRAY_LITERAL:()=>_Y,ARRAY_ROW:()=>vY,CHOOSECOLS:()=>yY,CHOOSEROWS:()=>bY,EXPAND:()=>xY,FLATTEN:()=>SY,FREQUENCY:()=>CY,HSTACK:()=>wY,MDETERM:()=>TY,MINVERSE:()=>EY,MMULT:()=>DY,SUMPRODUCT:()=>OY,SUMX2MY2:()=>AY,SUMX2PY2:()=>jY,SUMXMY2:()=>MY,TOCOL:()=>FY,TOROW:()=>IY,TRANSPOSE:()=>LY,VSTACK:()=>RY,WRAPCOLS:()=>zY,WRAPROWS:()=>BY});function mY(e,t){let n=e.map(z),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 F(N(`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 hY(e,t){let n=e.map(z),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 F(N(`All ranges in [[FUNCTION_NAME]] must have the same number of columns (got %s).`,r.join(`, `)))}let a=ss(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 gY={description:N(`Returns a result array constrained to a specific width and height.`),args:[H(`input_range (any, range<any>)`,N(`The range to constrain.`)),H(`rows (number)`,N(`The number of rows in the constrained array.`)),H(`columns (number)`,N(`The number of columns in the constrained array.`))],computeArray:function(e,t,n){let r=z(e),i=Ko(t?.value,this.locale),a=Ko(n?.value,this.locale);if(i<=0)return new F(N(`The rows argument (%s) must be strictly positive.`,i.toString()));if(a<=0)return new F(N(`The columns argument (%s) must be strictly positive.`,a.toString()));let o=Math.min(i,r[0].length);return ss(Math.min(a,r.length),o,(e,t)=>r[e][t])},isExported:!1},_Y={description:N(`Appends ranges vertically and in sequence to return a larger array. All ranges must have the same number of columns.`),args:[H(`range (any, range<any>, repeating)`,N(`The range to be appended.`))],computeArray:function(...e){return hY(e,{requireSameColCount:!0})},isExported:!1,hidden:!0},vY={description:N(`Appends ranges horizontally and in sequence to return a larger array. All ranges must have the same number of rows.`),args:[H(`range (any, range<any>, repeating)`,N(`The range to be appended.`))],computeArray:function(...e){return mY(e,{requireSameRowCount:!0})},isExported:!1,hidden:!0},yY={description:N(`Creates a new array from the selected columns in the existing range.`),args:[H(`array (any, range<any>)`,N(`The array that contains the columns to be returned.`)),H(`col_num (number, range<number>, repeating)`,N(`The column index of the column to be returned.`))],computeArray:function(e,...t){let n=z(e),r=Ss(t,e=>Ko(e?.value,this.locale)),i=r.filter(e=>e===0||n.length<Math.abs(e));if(i.length!==0)return new F(N(`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},bY={description:N(`Creates a new array from the selected rows in the existing range.`),args:[H(`array (any, range<any>)`,N(`The array that contains the rows to be returned.`)),H(`row_num (number, range<number>, repeating)`,N(`The row index of the row to be returned.`))],computeArray:function(e,...t){let n=z(e),r=Ss(t,e=>Ko(e?.value,this.locale)),i=n.length,a=r.filter(e=>e===0||n[0].length<Math.abs(e));return a.length===0?ss(i,r.length,(e,t)=>r[t]>0?n[e][r[t]-1]:n[e][n[e].length+r[t]]):new F(N(`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},xY={description:N(`Expands or pads an array to specified row and column dimensions.`),args:[H(`array (any, range<any>)`,N(`The array to expand.`)),H(`rows (number)`,N(`The number of rows in the expanded array. If missing, rows will not be expanded.`)),H(`columns (number, optional)`,N(`The number of columns in the expanded array. If missing, columns will not be expanded.`)),H(`pad_with (any, default=0)`,N(`The value with which to pad.`))],computeArray:function(e,t,n,r={value:0}){let i=z(e),a=Ko(t?.value,this.locale),o=n===void 0?i.length:Ko(n.value,this.locale);return a<i[0].length?new F(N(`The rows arguments (%s) must be greater or equal than the number of rows of the array.`,a.toString())):o<i.length?new F(N(`The columns arguments (%s) must be greater or equal than the number of columns of the array.`,o.toString())):ss(o,a,(e,t)=>e>=i.length||t>=i[e].length?r:i[e][t])},isExported:!0},SY={description:N(`Flattens all the values from one or more ranges into a single column.`),args:[H(`range (any, range<any>, repeating)`,N(`The range to flatten.`))],computeArray:function(...e){return[Ss(e,e=>e===void 0?{value:``}:e)]},isExported:!1},CY={description:N(`Calculates the frequency distribution of a range.`),args:[H(`data (range<number>)`,N(`The array of ranges containing the values to be counted.`)),H(`classes (number, range<number>)`,N(`The range containing the set of classes.`))],computeArray:function(e,t){let n=Ss([e],e=>e.value).filter(e=>typeof e==`number`),r=Ss([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=>({value:e.count}))]},isExported:!0},wY={description:N(`Appends ranges horizontally and in sequence to return a larger array.`),args:[H(`range (any, range<any>, repeating)`,N(`The range to be appended.`))],computeArray:function(...e){return mY(e)},isExported:!0},TY={description:N(`Returns the matrix determinant of a square matrix.`),args:[H(`square_matrix (number, range<number>)`,N(`An range with an equal number of rows and columns representing a matrix whose determinant will be calculated.`))],compute:function(e){let t=Wo(e,`square_matrix`);return fS(t)?{value:lg(t).determinant}:new F(N(`The argument square_matrix must have the same number of columns and rows.`))},isExported:!0},EY={description:N(`Returns the multiplicative inverse of a square matrix.`),args:[H(`square_matrix (number, range<number>)`,N(`An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated.`))],computeArray:function(e){let t=Wo(e,`square_matrix`);if(!fS(t))return new F(N(`The argument square_matrix must have the same number of columns and rows.`));let{inverted:n}=lg(t);return n?cs(n,e=>({value:e})):new F(N(`The matrix is not invertible.`))},isExported:!0},DY={description:N(`Calculates the matrix product of two matrices.`),args:[H(`matrix1 (number, range<number>)`,N(`The first matrix in the matrix multiplication operation.`)),H(`matrix2 (number, range<number>)`,N(`The second matrix in the matrix multiplication operation.`))],computeArray:function(e,t){let n=Wo(e,`matrix1`),r=Wo(t,`matrix2`);return n.length===0||r.length===0?new F(N(`The first and second arguments of [[FUNCTION_NAME]] must be non-empty matrices.`)):n.length===r[0].length?cs(dg(n,r),e=>({value:e})):new F(N(`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},OY={description:N(`Calculates the sum of the products of corresponding entries in equal-sized ranges.`),args:[H(`range (number, range<number>, repeating)`,N(`The range whose entries will be multiplied with corresponding entries in the other range.`))],compute:function(...e){if(!dS(...e))return new F(N(`All the ranges must have the same dimensions.`));let t=e.map(z),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*=I(n[e][r],this.locale);n+=i}return{value:n}},isExported:!0};function kY(e,t,n){if(!dS(e,t))return new F(N(`The arguments array_x and array_y must have the same dimensions.`));let r=z(e),i=z(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 F(N(`The arguments array_x and array_y must contain at least one pair of numbers.`))}let AY={description:N(`Calculates the sum of the difference of the squares of the values in two array.`),args:[H(`array_x (number, range<number>)`,N(`The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.`)),H(`array_y (number, range<number>)`,N(`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){let n=kY(e,t,(e,t)=>e**2-t**2);return n instanceof F?n:{value:n}},isExported:!0},jY={description:N(`Calculates the sum of the sum of the squares of the values in two array.`),args:[H(`array_x (number, range<number>)`,N(`The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.`)),H(`array_y (number, range<number>)`,N(`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){let n=kY(e,t,(e,t)=>e**2+t**2);return n instanceof F?n:{value:n}},isExported:!0},MY={description:N(`Calculates the sum of squares of the differences of values in two array.`),args:[H(`array_x (number, range<number>)`,N(`The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.`)),H(`array_y (number, range<number>)`,N(`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){let n=kY(e,t,(e,t)=>(e-t)**2);return n instanceof F?n:{value:n}},isExported:!0},NY=[H(`array (any, range<any>)`,N(`The array which will be transformed.`)),H(`ignore (number, default=0)`,N(`Whether to ignore certain types of values. By default, no values are ignored.`),[{value:0,label:N(`Keep all values (default)`)},{value:1,label:N(`Ignore blanks`)},{value:2,label:N(`Ignore errors`)},{value:3,label:N(`Ignore blanks and errors`)}]),H(`scan_by_column (number, default=false)`,N(`Scan the array by column. By default, the array is scanned by row.`),[{value:!1,label:N(`Scan by row (default)`)},{value:!0,label:N(`Scan by column`)}])];function PY(e){let t=Math.trunc(e);if(t===0)return()=>!0;if(t===1)return e=>e.value!==null;if(t===2)return e=>!Lo(e.value);if(t===3)return e=>e.value!==null&&!Lo(e.value);throw new F(N(`Argument ignore must be between 0 and 3`))}let FY={description:N(`Transforms a range of cells into a single column.`),args:NY,computeArray:function(e,t={value:0},n={value:!1}){let r=z(e),i=I(t.value,this.locale),a=(R(n.value)?r:us(r)).flat().filter(PY(i));return a.length===0?new Ao(N(`No results for the given arguments of TOCOL.`)):[a]},isExported:!0},IY={description:N(`Transforms a range of cells into a single row.`),args:NY,computeArray:function(e,t={value:0},n={value:!1}){let r=z(e),i=I(t.value,this.locale),a=(R(n.value)?r:us(r)).flat().filter(PY(i)).map(e=>[e]);return a.length===0||a[0].length===0?new Ao(N(`No results for the given arguments of TOROW.`)):a},isExported:!0},LY={description:N(`Transposes the rows and columns of a range.`),args:[H(`range (any, range<any>)`,N(`The range to be transposed.`))],computeArray:function(e){let t=z(e),n=t[0].length,r=t.length;return ss(n,r,(e,n)=>t[n][e])},isExported:!0},RY={description:N(`Appends ranges vertically and in sequence to return a larger array.`),args:[H(`range (any, range<any>, repeating)`,N(`The range to be appended.`))],computeArray:function(...e){return hY(e)},isExported:!0},zY={description:N(`Wraps the provided row or column of cells by columns after a specified number of elements to form a new array.`),args:[H(`range (any, range<any>)`,N(`The range to wrap.`)),H(`wrap_count (number)`,N(`The maximum number of cells for each column, rounded down to the nearest whole number.`)),H(`pad_with (any, default=0)`,N(`The value with which to fill the extra cells in the range.`))],computeArray:function(e,t,n={value:0}){let r=z(e),i=Ko(t?.value,this.locale);if(!uS(r))return new F(N(`Argument range must be a single row or column.`));if(i<1)return new F(N(`The wrap_count (%s) must be strictly positive.`,i),P.InvalidNumber);let a=r.flat();return ss(Math.ceil(a.length/i),i,(e,t)=>{let r=e*i+t;return r<a.length?a[r]:n})},isExported:!0},BY={description:N(`Wraps the provided row or column of cells by rows after a specified number of elements to form a new array.`),args:[H(`range (any, range<any>)`,N(`The range to wrap.`)),H(`wrap_count (number)`,N(`The maximum number of cells for each row, rounded down to the nearest whole number.`)),H(`pad_with (any, default=0)`,N(`The value with which to fill the extra cells in the range.`))],computeArray:function(e,t,n={value:0}){let r=z(e),i=Ko(t?.value,this.locale);if(!uS(r))return new F(N(`Argument range must be a single row or column.`));if(i<1)return new F(N(`The wrap_count (%s) must be strictly positive.`,i),P.InvalidNumber);let a=r.flat();return ss(i,Math.ceil(a.length/i),(e,t)=>{let r=t*i+e;return r<a.length?a[r]:n})},isExported:!0},VY=[{value:0,label:N(`Concise format\xA0(default)`)},{value:1,label:N(`Strict format`)}],HY={description:N(`returns an array of text values from any specified range. It passes text values unchanged, and converts non-text values to text.`),args:[H(`array (range)`,N(`The array to convert into text`)),H(`format (number, default=0)`,N(`The format of the returned data.`),VY)],compute:function(e,t={value:0}){let n=I(t,this.locale),r=z(e);if(n===1)return{value:JM(r,``,this.locale)};if(n===0){let e=this.locale.decimalSeparator===`,`?`/`:`,`;return{value:us(r).flatMap(e=>e.map(e=>Lo(e.value)?e.value:Jo(e,this.locale))).join(e)}}else return new F(N(`Format must be 0 or 1`))},isExported:!0};var UY=l({ABS:()=>GY,ACOS:()=>KY,ACOSH:()=>qY,ACOT:()=>JY,ACOTH:()=>YY,ASIN:()=>XY,ASINH:()=>ZY,ATAN:()=>QY,ATAN2:()=>$Y,ATANH:()=>eX,CEILING:()=>tX,CEILING_MATH:()=>rX,CEILING_PRECISE:()=>iX,COS:()=>aX,COSH:()=>oX,COT:()=>sX,COTH:()=>cX,COUNTBLANK:()=>lX,COUNTIF:()=>uX,COUNTIFS:()=>dX,COUNTUNIQUE:()=>fX,COUNTUNIQUEIFS:()=>pX,CSC:()=>mX,CSCH:()=>hX,DECIMAL:()=>gX,DEGREES:()=>_X,EXP:()=>vX,FLOOR:()=>yX,FLOOR_MATH:()=>xX,FLOOR_PRECISE:()=>SX,INT:()=>iZ,ISEVEN:()=>CX,ISODD:()=>TX,ISO_CEILING:()=>wX,LN:()=>EX,LOG:()=>DX,MOD:()=>kX,MUNIT:()=>AX,ODD:()=>jX,PI:()=>MX,POWER:()=>NX,PRODUCT:()=>PX,RAND:()=>FX,RANDARRAY:()=>IX,RANDBETWEEN:()=>LX,ROUND:()=>RX,ROUNDDOWN:()=>zX,ROUNDUP:()=>BX,SEC:()=>VX,SECH:()=>HX,SEQUENCE:()=>UX,SIN:()=>WX,SINH:()=>GX,SQRT:()=>KX,SUBTOTAL:()=>XX,SUM:()=>ZX,SUMIF:()=>QX,SUMIFS:()=>$X,TAN:()=>eZ,TANH:()=>tZ,TRUNC:()=>rZ});let WY=/^-?[a-z0-9]+$/i,GY={description:N(`Absolute value of a number.`),args:[H(`value (number)`,N(`The number of which to return the absolute value.`))],compute:function(e){return{value:Math.abs(I(e,this.locale))}},isExported:!0},KY={description:N(`Inverse cosine of a value, in radians.`),args:[H(`value (number)`,N(`The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.`))],compute:function(e){let t=I(e,this.locale);return Math.abs(t)>1?new F(N(`The value (%s) must be between -1 and 1 inclusive.`,t)):{value:Math.acos(t)}},isExported:!0},qY={description:N(`Inverse hyperbolic cosine of a number.`),args:[H(`value (number)`,N(`The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.`))],compute:function(e){let t=I(e,this.locale);return t<1?new F(N(`The value (%s) must be greater than or equal to 1.`,t)):{value:Math.acosh(t)}},isExported:!0},JY={description:N(`Inverse cotangent of a value.`),args:[H(`value (number)`,N(`The value for which to calculate the inverse cotangent.`))],compute:function(e){let t=I(e,this.locale);return{value:(Math.sign(t)||1)*Math.PI/2-Math.atan(t)}},isExported:!0},YY={description:N(`Inverse hyperbolic cotangent of a value.`),args:[H(`value (number)`,N(`The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.`))],compute:function(e){let t=I(e,this.locale);return Math.abs(t)<=1?new F(N(`The value (%s) cannot be between -1 and 1 inclusive.`,t)):{value:Math.log((t+1)/(t-1))/2}},isExported:!0},XY={description:N(`Inverse sine of a value, in radians.`),args:[H(`value (number)`,N(`The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.`))],compute:function(e){let t=I(e,this.locale);return Math.abs(t)>1?new F(N(`The value (%s) must be between -1 and 1 inclusive.`,t)):{value:Math.asin(t)}},isExported:!0},ZY={description:N(`Inverse hyperbolic sine of a number.`),args:[H(`value (number)`,N(`The value for which to calculate the inverse hyperbolic sine.`))],compute:function(e){return{value:Math.asinh(I(e,this.locale))}},isExported:!0},QY={description:N(`Inverse tangent of a value, in radians.`),args:[H(`value (number)`,N(`The value for which to calculate the inverse tangent.`))],compute:function(e){return{value:Math.atan(I(e,this.locale))}},isExported:!0},$Y={description:N(`Angle from the X axis to a point (x,y), in radians.`),args:[H(`x (number)`,N(`The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.`)),H(`y (number)`,N(`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=I(e,this.locale),r=I(t,this.locale);return n===0&&r===0?new No(N(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:Math.atan2(r,n)}},isExported:!0},eX={description:N(`Inverse hyperbolic tangent of a number.`),args:[H(`value (number)`,N(`The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.`))],compute:function(e){let t=I(e,this.locale);return Math.abs(t)>=1?new F(N(`The value (%s) must be between -1 and 1 exclusive.`,t)):{value:Math.atanh(t)}},isExported:!0},tX={description:N(`Rounds number up to nearest multiple of factor.`),args:[H(`value (number)`,N(`The value to round up to the nearest integer multiple of factor.`)),H(`factor (number, default=1)`,N(`The number to whose multiples value will be rounded.`))],compute:function(e,t={value:1}){let n=I(e,this.locale),r=I(t,this.locale);return r<0&&n>0?new F(N(`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 nX(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 rX={description:N(`Rounds number up to nearest multiple of factor.`),args:[H(`number (number)`,N(`The value to round up to the nearest integer multiple of significance.`)),H(`significance (number, default=1)`,N(`The number to whose multiples number will be rounded. The sign of significance will be ignored.`)),H(`mode (number, default=0)`,N(`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=I(t,this.locale);return{value:nX(I(e,this.locale),r,I(n,this.locale)),format:e?.format}},isExported:!0},iX={description:N(`Rounds number up to nearest multiple of factor.`),args:[H(`number (number)`,N(`The value to round up to the nearest integer multiple of significance.`)),H(`significance (number, default=1)`,N(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){let n=I(t,this.locale);return{value:nX(I(e,this.locale),n),format:e?.format}},isExported:!0},aX={description:N(`Cosine of an angle provided in radians.`),args:[H(`angle (number)`,N(`The angle to find the cosine of, in radians.`))],compute:function(e){return{value:Math.cos(I(e,this.locale))}},isExported:!0},oX={description:N(`Hyperbolic cosine of any real number.`),args:[H(`value (number)`,N(`Any real value to calculate the hyperbolic cosine of.`))],compute:function(e){return{value:Math.cosh(I(e,this.locale))}},isExported:!0},sX={description:N(`Cotangent of an angle provided in radians.`),args:[H(`angle (number)`,N(`The angle to find the cotangent of, in radians.`))],compute:function(e){let t=I(e,this.locale);return t===0?new No(N(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:1/Math.tan(t)}},isExported:!0},cX={description:N(`Hyperbolic cotangent of any real number.`),args:[H(`value (number)`,N(`Any real value to calculate the hyperbolic cotangent of.`))],compute:function(e){let t=I(e,this.locale);return t===0?new No(N(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:1/Math.tanh(t)}},isExported:!0},lX={description:N(`Number of empty values.`),args:[H(`value (any, range, repeating)`,N(`Value or range in which to count the number of blanks.`))],compute:function(...e){return{value:is(e,(e,t)=>t===void 0||t.value===null||t.value===``?e+1:e,0)}},isExported:!0},uX={description:N(`A conditional count across a range.`),args:[H(`range (range)`,N(`The range that is tested against criterion.`)),H(`criterion (string)`,N(`The pattern or test to apply to range.`))],compute:function(...e){let t=0;return gs(e,(e,n)=>{t+=1},this.locale),{value:t}},isExported:!0},dX={description:N(`Count values depending on multiple criteria.`),args:[H(`criteria_range (any, range, repeating)`,N(`Range over which to evaluate criteria.`)),H(`criterion (string, repeating)`,N(`Criteria to check.`))],compute:function(...e){let t=0;return gs(e,(e,n)=>{t+=1},this.locale),{value:t}},isExported:!0},fX={description:N(`Counts number of unique values in a range.`),args:[H(`value (any, range, repeating)`,N(`Value or range to consider for uniqueness.`))],compute:function(...e){return{value:sS(e)}}},pX={description:N(`Counts number of unique values in a range, filtered by a set of criteria.`),args:[H(`range (range)`,N(`The range of cells from which the number of unique values will be counted.`)),H(`criteria_range (any, range, repeating)`,N(`Range over which to evaluate criteria.`)),H(`criterion (string, repeating)`,N(`Criteria to check.`))],compute:function(e,...t){let n=new Set;return gs(t,(t,r)=>{let i=e[t]?.[r];Cs(i)&&n.add(i.value)},this.locale),{value:n.size}}},mX={description:N(`Cosecant of an angle provided in radians.`),args:[H(`angle (number)`,N(`The angle to find the cosecant of, in radians.`))],compute:function(e){let t=I(e,this.locale);return t===0?new No(N(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:1/Math.sin(t)}},isExported:!0},hX={description:N(`Hyperbolic cosecant of any real number.`),args:[H(`value (number)`,N(`Any real value to calculate the hyperbolic cosecant of.`))],compute:function(e){let t=I(e,this.locale);return t===0?new No(N(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:1/Math.sinh(t)}},isExported:!0},gX={description:N(`Converts from another base to decimal.`),args:[H(`value (string)`,N(`The number to convert.`)),H(`base (number)`,N(`The base to convert the value from.`))],compute:function(e,t){let n=I(t,this.locale);if(n=Math.floor(n),2>n||n>36)return new F(N(`The base (%s) must be between 2 and 36 inclusive.`,n));let r=L(e);if(r===``)return{value:0};if(!WY.test(r))return new F(N(`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 F(N(`The value (%s) must be a valid base %s representation.`,r,n));let a=parseInt(r,n);return isNaN(a)?new F(N(`The value (%s) must be a valid base %s representation.`,r,n)):{value:a}},isExported:!0},_X={description:N(`Converts an angle value in radians to degrees.`),args:[H(`angle (number)`,N(`The angle to convert from radians to degrees.`))],compute:function(e){return{value:I(e,this.locale)*180/Math.PI}},isExported:!0},vX={description:N(`Euler's number, e (~2.718) raised to a power.`),args:[H(`value (number)`,N(`The exponent to raise e.`))],compute:function(e){return{value:Math.exp(I(e,this.locale))}},isExported:!0},yX={description:N(`Rounds number down to nearest multiple of factor.`),args:[H(`value (number)`,N(`The value to round down to the nearest integer multiple of factor.`)),H(`factor (number, default=1)`,N(`The number to whose multiples value will be rounded.`))],compute:function(e,t={value:1}){let n=I(e,this.locale),r=I(t,this.locale);return r<0&&n>0?new F(N(`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 bX(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 xX={description:N(`Rounds number down to nearest multiple of factor.`),args:[H(`number (number)`,N(`The value to round down to the nearest integer multiple of significance.`)),H(`significance (number, default=1)`,N(`The number to whose multiples number will be rounded. The sign of significance will be ignored.`)),H(`mode (number, default=0)`,N(`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=I(t,this.locale);return{value:bX(I(e,this.locale),r,I(n,this.locale)),format:e?.format}},isExported:!0},SX={description:N(`Rounds number down to nearest multiple of factor.`),args:[H(`number (number)`,N(`The value to round down to the nearest integer multiple of significance.`)),H(`significance (number, default=1)`,N(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){let n=I(t,this.locale);return{value:bX(I(e,this.locale),n),format:e?.format}},isExported:!0},CX={description:N(`Whether the provided value is even.`),args:[H(`value (number)`,N(`The value to be verified as even.`))],compute:function(e){let t=Go(e,this.locale);return{value:!(Math.floor(Math.abs(t))&1)}},isExported:!0},wX={description:N(`Rounds number up to nearest multiple of factor.`),args:[H(`number (number)`,N(`The value to round up to the nearest integer multiple of significance.`)),H(`significance (number, default=1)`,N(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){return{value:nX(I(e,this.locale),I(t,this.locale)),format:e?.format}},isExported:!0},TX={description:N(`Whether the provided value is even.`),args:[H(`value (number)`,N(`The value to be verified as even.`))],compute:function(e){let t=Go(e,this.locale);return{value:!!(Math.floor(Math.abs(t))&1)}},isExported:!0},EX={description:N(`The logarithm of a number, base e (euler's number).`),args:[H(`value (number)`,N(`The value for which to calculate the logarithm, base e.`))],compute:function(e){let t=I(e,this.locale);return t<=0?new F(N(`The value (%s) must be strictly positive.`,t)):{value:Math.log(t)}},isExported:!0},DX={description:N(`The logarithm of a number, for a given base.`),args:[H(`value (number)`,N(`The value for which to calculate the logarithm.`)),H(`base (number, default=10)`,N(`The base of the logarithm.`))],compute:function(e,t={value:10}){let n=I(e,this.locale),r=I(t,this.locale);return n<=0?new F(N(`The value (%s) must be strictly positive.`,n)):r<=0?new F(N(`The base (%s) must be strictly positive.`,r)):r===1?new F(N(`The base must be different from 1.`)):{value:Math.log10(n)/Math.log10(r)}},isExported:!0};function OX(e,t){lS(t,N(`The divisor must be different from 0.`));let n=e%t;return n>0&&t<0||n<0&&t>0?n+t:n}let kX={description:N(`Modulo (remainder) operator.`),args:[H(`dividend (number)`,N(`The number to be divided to find the remainder.`)),H(`divisor (number)`,N(`The number to divide by.`))],compute:function(e,t){let n=I(t,this.locale);return{value:OX(I(e,this.locale),n),format:e?.format}},isExported:!0},AX={description:N(`Returns a n x n unit matrix, where n is the input dimension.`),args:[H(`dimension (number)`,N(`An integer specifying the dimension size of the unit matrix. It must be positive.`))],computeArray:function(e){let t=Ko(e,this.locale);return t<1?new F(N(`The argument dimension must be positive`)):cs(cg(t),e=>({value:e}))},isExported:!0},jX={description:N(`Rounds a number up to the nearest odd integer.`),args:[H(`value (number)`,N(`The value to round to the next greatest odd number.`))],compute:function(e){let t=I(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},MX={description:N(`The number pi.`),args:[],compute:function(){return{value:Math.PI}},isExported:!0},NX={description:N(`A number raised to a power.`),args:[H(`base (number)`,N(`The number to raise to the exponent power.`)),H(`exponent (number)`,N(`The exponent to raise base to.`))],compute:function(e,t){let n=I(e,this.locale),r=I(t,this.locale);return n<0&&!Number.isInteger(r)?new F(N(`The exponent (%s) must be an integer when the base is negative.`,r)):{value:n**+r,format:e?.format}},isExported:!0},PX={description:N(`Result of multiplying a series of numbers together.`),args:[H(`factor (number, range<number>, repeating)`,N(`Number or range to calculate for the product.`))],compute:function(...e){let t=0,n=1;for(let r of e)if(wt(r))for(let e of r)for(let r of e){let e=r.value;if(typeof e==`number`&&(n*=e,t+=1),Lo(e))return r}else r!==void 0&&r.value!==null&&(n*=Go(r,this.locale),t+=1);return{value:t===0?0:n,format:Io(e[0])}},isExported:!0},FX={description:N(`A random number between 0 inclusive and 1 exclusive.`),args:[],compute:function(){return{value:Math.random()}},isExported:!0},IX={description:N(`Returns a grid of random numbers between 0 inclusive and 1 exclusive.`),args:[H(`rows (number, default=1)`,N(`The number of rows to be returned.`)),H(`columns (number, default=1)`,N(`The number of columns to be returned.`)),H(`min (number, default=0)`,N(`The minimum number you would like returned.`)),H(`max (number, default=1)`,N(`The maximum number you would like returned.`)),H(`whole_number (boolean, default=FALSE)`,N(`Return a whole number or a decimal value.`),[{value:!1,label:N(`Decimal (default)`)},{value:!0,label:N(`Integer`)}])],computeArray:function(e={value:1},t={value:1},n={value:0},r={value:1},i={value:!1}){let a=Ko(t,this.locale),o=Ko(e,this.locale),s=I(n,this.locale),c=I(r,this.locale),l=R(i);if(a<1)return new F(N(`The number of columns (%s) must be positive.`,a));if(o<1)return new F(N(`The number of rows (%s) must be positive.`,o));if(s>c)return new F(N(`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 F(N(`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 cs(u,e=>({value:e}))},isExported:!0},LX={description:N(`Random integer between two values, inclusive.`),args:[H(`low (number)`,N(`The low end of the random range.`)),H(`high (number)`,N(`The high end of the random range.`))],compute:function(e,t){let n=I(e,this.locale);Number.isInteger(n)||(n=Math.ceil(n));let r=I(t,this.locale);return Number.isInteger(r)||(r=Math.floor(r)),n>r?new F(N(`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},RX={description:N(`Rounds a number according to standard rules.`),args:[H(`value (number)`,N(`The value to round to places number of places.`)),H(`places (number, default=0)`,N(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=I(e,this.locale),r=I(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},zX={description:N(`Rounds down a number.`),args:[H(`value (number)`,N(`The value to round to places number of places, always rounding down.`)),H(`places (number, default=0)`,N(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=I(e,this.locale),r=I(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},BX={description:N(`Rounds up a number.`),args:[H(`value (number)`,N(`The value to round to places number of places, always rounding up.`)),H(`places (number, default=0)`,N(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=I(e,this.locale),r=I(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},VX={description:N(`Secant of an angle provided in radians.`),args:[H(`angle (number)`,N(`The angle to find the secant of, in radians.`))],compute:function(e){return{value:1/Math.cos(I(e,this.locale))}},isExported:!0},HX={description:N(`Hyperbolic secant of any real number.`),args:[H(`value (number)`,N(`Any real value to calculate the hyperbolic secant of.`))],compute:function(e){return{value:1/Math.cosh(I(e,this.locale))}},isExported:!0},UX={description:N(`Returns a sequence of numbers.`),args:[H(`rows (number)`,N(`The number of rows to return`)),H(`columns (number, optional, default=1)`,N(`The number of columns to return`)),H(`start (number, optional, default=1)`,N(`The first number in the sequence`)),H(`step (number, optional, default=1)`,N(`The amount to increment each value in the sequence`))],computeArray:function(e,t={value:1},n={value:1},r={value:1}){let i=I(n,this.locale),a=I(r,this.locale),o=Ko(e,this.locale),s=Ko(t,this.locale);return s<1?new F(N(`The number of columns (%s) must be positive.`,s)):o<1?new F(N(`The number of rows (%s) must be positive.`,o)):ss(s,o,(e,t)=>({value:i+t*s*a+e*a}))},isExported:!0},WX={description:N(`Sine of an angle provided in radians.`),args:[H(`angle (number)`,N(`The angle to find the sine of, in radians.`))],compute:function(e){return{value:Math.sin(I(e,this.locale))}},isExported:!0},GX={description:N(`Hyperbolic sine of any real number.`),args:[H(`value (number)`,N(`Any real value to calculate the hyperbolic sine of.`))],compute:function(e){return{value:Math.sinh(I(e,this.locale))}},isExported:!0},KX={description:N(`Positive square root of a positive number.`),args:[H(`value (number)`,N(`The number for which to calculate the positive square root.`))],compute:function(e){let t=I(e,this.locale);return t<0?new F(N(`The value (%s) must be positive or null.`,t)):{value:Math.sqrt(t),format:e?.format}},isExported:!0},qX={1:`AVERAGE`,2:`COUNT`,3:`COUNTA`,4:`MAX`,5:`MIN`,6:`PRODUCT`,7:`STDEV`,8:`STDEVP`,9:`SUM`,10:`VAR`,11:`VARP`},JX=Object.entries(qX).map(([e,t])=>({value:parseInt(e),label:N(`%s (include manually-hidden rows)`,t)})),YX=Object.entries(qX).map(([e,t])=>({value:parseInt(e)+100,label:N(`%s (exclude manually-hidden rows)`,t)})),XX={description:N(`Returns a subtotal for a vertical range of cells using a specified aggregation function.`),args:[H(`function_code (number)`,N(`The function to use in subtotal aggregation.`),[...JX,...YX]),H(`ref (any, range<any>, repeating)`,N(`Range or reference for which you want the subtotal.`))],compute:function(e,...t){let n=Ko(e,this.locale),r=!0;if(n>100&&(n-=100,r=!1),n<1||n>11)return new F(N(`The function code (%s) must be between 1 to 11 or 101 to 111.`,n));let i=[];for(let e of t){let t=z(e),n=t[0][0]?.position;if(n===void 0)return new ko(Bo);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||!kn(n,`SUBTOTAL`))&&i.push(this.getFormulaResult({sheetId:s,col:t,row:e}))}}let a=qX[n],o=[i];return fg(nl(ul.get(a),o.length)(this,o))},isExported:!0},ZX={description:N(`Sum of a series of numbers and/or cells.`),args:[H(`value (number, range<number>, repeating)`,N(`Number or range to add together.`))],compute:function(...e){let t=e[0];return{value:oS(e,this.locale),format:Io(t)}},isExported:!0},QX={description:N(`A conditional sum across a range.`),args:[H(`criteria_range (range)`,N(`The range which is tested against criterion.`)),H(`criterion (string)`,N(`The pattern or test to apply to range.`)),H(`sum_range (range, default=criteria_range)`,N(`The range to be summed, if different from range.`))],compute:function(e,t,n){n===void 0&&(n=e);let r=0;return gs([e,t],(e,t)=>{let i=n[e]?.[t]?.value;typeof i==`number`&&(r+=i)},this.locale),{value:r}},isExported:!0},$X={description:N(`Sums a range depending on multiple criteria.`),args:[H(`sum_range (range)`,N(`The range to sum.`)),H(`criteria_range (any, range, repeating)`,N(`Range to check.`)),H(`criterion (string, repeating)`,N(`Criteria to check.`))],compute:function(e,...t){let n=0;return gs(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n+=i)},this.locale),{value:n}},isExported:!0},eZ={description:N(`Tangent of an angle provided in radians.`),args:[H(`angle (number)`,N(`The angle to find the tangent of, in radians.`))],compute:function(e){return{value:Math.tan(I(e,this.locale))}},isExported:!0},tZ={description:N(`Hyperbolic tangent of any real number.`),args:[H(`value (number)`,N(`Any real value to calculate the hyperbolic tangent of.`))],compute:function(e){return{value:Math.tanh(I(e,this.locale))}},isExported:!0};function nZ(e,t){return t===0?Math.trunc(e):(Number.isInteger(t)||(t=Math.trunc(t)),Math.trunc(e*10**t)/10**t)}let rZ={description:N(`Truncates a number.`),args:[H(`value (number)`,N(`The value to be truncated.`)),H(`places (number, default=0)`,N(`The number of significant digits to the right of the decimal point to retain.`))],compute:function(e,t={value:0}){return{value:nZ(I(e,this.locale),I(t,this.locale)),format:e?.format}},isExported:!0},iZ={description:N(`Rounds a number down to the nearest integer that is less than or equal to it.`),args:[H(`value (number)`,N(`The number to round down to the nearest integer.`))],compute:function(e){return{value:Math.floor(I(e,this.locale))}},isExported:!0};var aZ=l({AVEDEV:()=>hZ,AVERAGE:()=>gZ,AVERAGEA:()=>bZ,AVERAGEIF:()=>xZ,AVERAGEIFS:()=>SZ,AVERAGE_WEIGHTED:()=>yZ,CHISQ_DIST_RT:()=>OZ,CHISQ_TEST:()=>kZ,CONFIDENCE_NORM:()=>AZ,CONFIDENCE_T:()=>jZ,CORREL:()=>QZ,COUNT:()=>CZ,COUNTA:()=>wZ,COVAR:()=>TZ,COVARIANCE_P:()=>EZ,COVARIANCE_S:()=>DZ,FORECAST:()=>NZ,F_TEST:()=>MZ,GEOMEAN:()=>PZ,GROWTH:()=>FZ,HARMEAN:()=>IZ,INTERCEPT:()=>LZ,KURT:()=>RZ,LARGE:()=>zZ,LINEST:()=>BZ,LOGEST:()=>VZ,MATTHEWS:()=>HZ,MAX:()=>UZ,MAXA:()=>WZ,MAXIFS:()=>GZ,MEDIAN:()=>KZ,MIN:()=>qZ,MINA:()=>JZ,MINIFS:()=>YZ,PEARSON:()=>ZZ,PERCENTILE:()=>$Z,PERCENTILE_EXC:()=>eQ,PERCENTILE_INC:()=>tQ,POLYFIT_COEFFS:()=>nQ,POLYFIT_FORECAST:()=>rQ,QUARTILE:()=>iQ,QUARTILE_EXC:()=>aQ,QUARTILE_INC:()=>oQ,RANK:()=>sQ,RSQ:()=>cQ,SKEW:()=>uQ,SKEW_P:()=>dQ,SLOPE:()=>lQ,SMALL:()=>fQ,SPEARMAN:()=>pQ,STDEV:()=>mQ,STDEVA:()=>_Q,STDEVP:()=>vQ,STDEVPA:()=>yQ,STDEV_P:()=>hQ,STDEV_S:()=>gQ,STEYX:()=>xQ,TREND:()=>SQ,TRIMMEAN:()=>CQ,T_TEST:()=>bQ,VAR:()=>wQ,VARA:()=>DQ,VARP:()=>OQ,VARPA:()=>kQ,VAR_P:()=>TQ,VAR_S:()=>EQ});let oZ=[{value:!0,label:N(`b is calculated normally`)},{value:!1,label:N(`b is forced to 1`)}],sZ=[{value:!1,label:N(`do not return additional regression statistics`)},{value:!0,label:N(`return additional regression statistics`)}],cZ=[{value:1,label:N(`order 1 (Linear)`)},{value:2,label:N(`order 2 (Quadratic)`)},{value:3,label:N(`order 3 (Cubic)`)},{value:4,label:N(`order 4 (Quartic)`)},{value:5,label:N(`order 5 (Quintic)`)},{value:6,label:N(`order 6 (Sextic)`)}],lZ=[{value:!0,label:N(`Compute intercept`)},{value:!1,label:N(`Force intercept to 0`)}],uZ=[{value:0,label:N(`Minimum value`)},{value:1,label:N(`First quartile (25th percentile)`)},{value:2,label:N(`Median value (50th percentile)`)},{value:3,label:N(`Third quartile (75th percentile)`)},{value:4,label:N(`Maximum value`)}];function dZ(e,t){let n=[],r=[],i=0,a=0;ts([e],e=>{n.push(e),i+=1}),ts([t],e=>{r.push(e),a+=1}),cS(i===a,N(`[[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 fZ(e,t,n){let{flatDataX:r,flatDataY:i}=dZ(e,t),a=i.length;lS(a),n&&lS(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 pZ(e,t,n,r){let i=0,a=n?os:as,o=a(e,(e,t)=>(i+=1,e+t),0,r);lS(i),t&&lS(i-1);let s=o/i;return a(e,(e,t)=>e+(t-s)**2,0,r)/(i-+!!t)}function mZ(e,t,n,r){let i=I(t,r);cS(n?0<=i&&i<=1:0<i&&i<1,N(`Function [[FUNCTION_NAME]] parameter 2 value is out of range.`));let a=[],o,s=0;return ts(e,e=>{let t=e?.value;typeof t==`number`&&(o=_s(a,e,`nextSmaller`,`asc`,a.length,(e,t)=>e[t]),a.splice(o+1,0,t),s++)}),cS(s!==0,ws),n||cS(1/(s+1)<=i&&i<=s/(s+1),N(`Function [[FUNCTION_NAME]] parameter 2 value is out of range.`)),_o(a,i,n)}let hZ={description:N(`Average magnitude of deviations from mean.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the sample.`))],compute:function(...e){let t=0,n=as(e,(e,n)=>(t+=1,e+n),0,this.locale);if(t===0)return new No(N(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`));let r=n/t;return{value:as(e,(e,t)=>e+Math.abs(r-t),0,this.locale)/t}},isExported:!0},gZ={description:N(`Numerical average value in a dataset, ignoring text.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to consider when calculating the average value.`))],compute:function(...e){return{value:hS(e,this.locale),format:Io(e[0])}},isExported:!0},_Z=N(`[[FUNCTION_NAME]] has mismatched range sizes.`),vZ=N(`[[FUNCTION_NAME]] expects the weight to be positive or equal to 0.`),yZ={description:N(`Weighted average.`),args:[H(`values (number, range<number>, repeating)`,N(`Value to average.`)),H(`weights (number, range<number>, repeating)`,N(`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(!dS(i,a))return new F(_Z);if(wt(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=wt(a)?a?.[e][r].value:I(a,this.locale),c=typeof o==`number`,l=typeof s==`number`;if(c&&l){if(s<0)return new F(vZ);t+=o*s,n+=s;continue}if(c!==l)return new F(N(`[[FUNCTION_NAME]] expects number values.`))}else{let e=I(i,this.locale),r=wt(a)?a?.[0][0].value:I(a,this.locale);if(typeof r==`number`){if(r<0)return new F(vZ);t+=e*r,n+=r}}}return n===0?new No(N(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:t/n,format:Io(e[0])}}},bZ={description:N(`Numerical average value in a dataset.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to consider when calculating the average value.`))],compute:function(...e){let t=0,n=os(e,(e,n)=>(t+=1,e+n),0,this.locale);return t===0?new No(N(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:n/t,format:Io(e[0])}},isExported:!0},xZ={description:N(`Average of values depending on criteria.`),args:[H(`criteria_range (number, range<number>)`,N(`The range to check against criterion.`)),H(`criterion (string)`,N(`The pattern or test to apply to criteria_range.`)),H(`average_range (number, range<number>, default=criteria_range)`,N(`The range to average. If not included, criteria_range is used for the average instead.`))],compute:function(e,t,n){let r=z(n===void 0?e:n),i=0,a=0;return gs([e,t],(e,t)=>{let n=r[e]?.[t]?.value;typeof n==`number`&&(i+=1,a+=n)},this.locale),i===0?new No(N(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:a/i}},isExported:!0},SZ={description:N(`Average of values depending on multiple criteria.`),args:[H(`average_range (range)`,N(`The range to average.`)),H(`criteria_range (any, range, repeating)`,N(`Range to check.`)),H(`criterion (string, repeating)`,N(`Criterion to check.`))],compute:function(e,...t){let n=z(e),r=0,i=0;return gs(t,(e,t)=>{let a=n[e]?.[t]?.value;typeof a==`number`&&(r+=1,i+=a)},this.locale),r===0?new No(N(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:i/r}},isExported:!0},CZ={description:N(`The number of numeric values in dataset.`),args:[H(`value (number, any, range<number>, repeating)`,N(`Value or range to consider when counting.`))],compute:function(...e){return{value:_S(e,this.locale)}},isExported:!0},wZ={description:N(`The number of values in a dataset.`),args:[H(`value (any, range, repeating)`,N(`Value or range to consider when counting.`))],compute:function(...e){return{value:vS(e)}},isExported:!0},TZ={description:N(`The covariance of a dataset.`),args:[H(`data_y (any, range)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (any, range)`,N(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return{value:fZ(e,t,!1)}},isExported:!0},EZ={description:N(`The covariance of a dataset.`),args:[H(`data_y (any, range)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (any, range)`,N(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return{value:fZ(e,t,!1)}},isExported:!0},DZ={description:N(`The sample covariance of a dataset.`),args:[H(`data_y (any, range)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (any, range)`,N(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return{value:fZ(e,t,!0)}},isExported:!0},OZ={description:N(`Upper tail of the chi-square distribution.`),args:[H(`x (number)`,N(`The value to evaluate.`)),H(`degrees_of_freedom (number)`,N(`The degrees of freedom.`))],compute:function(e,t){let n=I(e,this.locale),r=Math.round(I(t,this.locale));return cS(n>=0,N(`x must be non-negative.`)),cS(r>=1,N(`Degrees of freedom must be >= 1.`)),{value:jS(r/2,n/2)}},isExported:!0},kZ={description:N(`Returns the p-value of a chi-square test for independence, comparing actual to expected values.`),args:[H(`actual_range (range<number>)`,N(`The range containing the observed values.`)),H(`expected_range (range<number>)`,N(`The range containing the expected values.`))],compute:function(e,t){cS(dS(e,t),N(`The two ranges must have the same dimensions.`));let n=Wo(e,`actual_range`),r=Wo(t,`expected_range`),i=n.length,a=n[0]?.length??0;cS(i*a>0,ws);let o=0;for(let e=0;e<i;e++)for(let t=0;t<a;t++){let i=r[e][t];lS(i);let a=n[e][t]-i;o+=a*a/i}let s;return s=a>1&&i>1?(a-1)*(i-1):a===1?i-1:a-1,cS(s>=1,N(`The ranges must contain at least 2 values.`)),{value:jS(s/2,o/2)}},isExported:!0},AZ={description:N(`Half-width of the confidence interval for a population mean (normal distribution).`),args:[H(`alpha (number)`,N(`The significance level (e.g. 0.05 for 95% CI).`)),H(`standard_deviation (number)`,N(`The population standard deviation.`)),H(`size (number)`,N(`The sample size.`))],compute:function(e,t,n){let r=I(e,this.locale),i=I(t,this.locale),a=Math.round(I(n,this.locale));return cS(r>0&&r<1,N(`Alpha must be between 0 and 1.`)),cS(i>0,N(`Standard deviation must be positive.`)),cS(a>=1,N(`Size must be >= 1.`)),{value:-PS(r/2)*i/Math.sqrt(a)}},isExported:!0},jZ={description:N(`Half-width of the confidence interval for a population mean (t-distribution).`),args:[H(`alpha (number)`,N(`The significance level (e.g. 0.05 for 95% CI).`)),H(`standard_deviation (number)`,N(`The sample standard deviation.`)),H(`size (number)`,N(`The sample size.`))],compute:function(e,t,n){let r=I(e,this.locale),i=I(t,this.locale),a=Math.round(I(n,this.locale));return cS(r>0&&r<1,N(`Alpha must be between 0 and 1.`)),cS(i>0,N(`Standard deviation must be positive.`)),cS(a>=2,N(`Size must be >= 2.`)),{value:IS(r,a-1)*i/Math.sqrt(a)}},isExported:!0},MZ={description:N(`Returns the two-tailed p-value of an F-test comparing the variances of two datasets.`),args:[H(`range1 (range<number>)`,N(`The first sample.`)),H(`range2 (range<number>)`,N(`The second sample.`))],compute:function(e,t){let n=[],r=[];ns([e],e=>n.push(e.value),this.locale),ns([t],e=>r.push(e.value),this.locale);let i=n.length,a=r.length;cS(i>=2&&a>=2,N(`Each range must contain at least 2 numeric values.`));let o=n.reduce((e,t)=>e+t,0)/i,s=r.reduce((e,t)=>e+t,0)/a,c=n.reduce((e,t)=>e+(t-o)**2,0)/(i-1),l=r.reduce((e,t)=>e+(t-s)**2,0)/(a-1);lS(c),lS(l);let u=c/l,d=i-1,f=a-1,p=MS(d*u/(d*u+f),d/2,f/2);return{value:2*Math.min(p,1-p)}},isExported:!0},NZ={description:N(`Calculates the expected y-value for a specified x based on a linear regression of a dataset.`),args:[H(`x (number, range<number>)`,N(`The value(s) on the x-axis to forecast.`)),H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>)`,N(`The range representing the array or matrix of independent data.`))],computeArray:function(e,t,n){let{flatDataX:r,flatDataY:i}=dZ(t,n);return r.length===0||i.length===0?new Ao(ws):cs(OS([i],[r],cs(z(e),e=>I(e,this.locale)),!0),e=>({value:e}))},isExported:!0},PZ={description:N(`Geometric mean of a dataset.`),args:[H(`value (number, range<number>, repeating)`,N(`Values to include.`))],compute:function(...e){let t=0,n=0;return ns(e,e=>{cS(e.value>0,N(`GEOMEAN requires strictly positive values.`)),t+=Math.log(e.value),n++},this.locale),cS(n>0,ws),{value:Math.exp(t/n)}},isExported:!0},FZ={description:N(`Fits points to exponential growth trend.`),args:[H(`known_data_y (range<number>)`,N(`The array or range containing dependent (y) values that are already known, used to curve fit an ideal exponential growth curve.`)),H(`known_data_x (range<number>, default={1;2;3;...})`,N(`The values of the independent variable(s) corresponding with known_data_y.`)),H(`new_data_x (any, range, default=known_data_x)`,N(`The data points to return the y values for on the ideal curve fit.`)),H(`b (boolean, default=TRUE)`,N(`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.`),oZ)],computeArray:function(e,t=[[]],n=[[]],r={value:!0}){return e.length===0||e[0].length===0?new F(Ts(`known_data_y`)):cs(ES(OS(DS(Wo(e,`known_data_y`)),Wo(t,`known_data_x`),Wo(n,`new_data_y`),R(r))),e=>({value:e}))}},IZ={description:N(`Harmonic mean of a dataset.`),args:[H(`value (number, range<number>, repeating)`,N(`Values to include.`))],compute:function(...e){let t=0,n=0;return ns(e,e=>{cS(e.value>0,N(`HARMEAN requires strictly positive values.`)),t+=1/e.value,n++},this.locale),cS(n>0,ws),{value:n/t}},isExported:!0},LZ={description:N(`Compute the intercept of the linear regression.`),args:[H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>)`,N(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=dZ(e,t);if(n.length===0||r.length===0)return new Ao(ws);let[[],[i]]=SS([n],[r]);return{value:i}},isExported:!0},RZ={description:N(`Excess kurtosis of a dataset.`),args:[H(`value (number, range<number>, repeating)`,N(`Values to include.`))],compute:function(...e){let t=[];ns(e,e=>t.push(e.value),this.locale);let n=t.length;cS(n>=4,N(`KURT requires at least 4 values.`));let r=t.reduce((e,t)=>e+t,0)/n,i=t.reduce((e,t)=>e+(t-r)**2,0)/(n-1);cS(i>0,N(`KURT requires non-constant data.`));let a=Math.sqrt(i),o=t.reduce((e,t)=>e+((t-r)/a)**4,0);return{value:n*(n+1)/((n-1)*(n-2)*(n-3))*o-3*(n-1)**2/((n-2)*(n-3))}},isExported:!0},zZ={description:N(`Nth largest element from a data set.`),args:[H(`data (any, range)`,N(`Array or range containing the dataset to consider.`)),H(`n (number)`,N(`The rank from largest to smallest of the element to return.`))],compute:function(e,t){let n=Math.trunc(I(t?.value,this.locale)),r=[],i,a=0;ts([e],e=>{typeof e?.value==`number`&&(i=_s(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 F(ws):a<n?new F(N(`Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.`,n)):o},isExported:!0},BZ={description:N(`Given partial data about a linear trend, calculates various parameters about the ideal linear trend using the least-squares method.`),args:[H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>, default={1;2;3;...})`,N(`The range representing the array or matrix of independent data.`)),H(`calculate_b (boolean, default=TRUE)`,N(`A flag specifying whether to compute the slope or not`),oZ),H(`verbose (boolean, default=FALSE)`,N(`A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept`),sZ)],computeArray:function(e,t=[[]],n={value:!0},r={value:!1}){return e.length===0||e[0].length===0?new F(Ts(`data_y`)):cs(SS(Wo(t,`data_x`),Wo(e,`data_y`),R(n),R(r)),e=>({value:e}))},isExported:!0},VZ={description:N(`Given partial data about an exponential growth curve, calculates various parameters about the best fit ideal exponential growth curve.`),args:[H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>, optional, default={1;2;3;...})`,N(`The range representing the array or matrix of independent data.`)),H(`calculate_b (boolean, default=TRUE)`,N(`A flag specifying whether to compute the slope or not`),oZ),H(`verbose (boolean, default=FALSE)`,N(`A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept`),sZ)],computeArray:function(e,t=[[]],n={value:!0},r={value:!1}){if(e.length===0||e[0].length===0)return new F(Ts(`data_y`));let i=SS(Wo(t,`data_x`),DS(Wo(e,`data_y`)),R(n),R(r));for(let e=0;e<i.length;e++)i[e][0]=Math.exp(i[e][0]);return cs(i,e=>({value:e}))},isExported:!0},HZ={description:N(`Compute the Matthews correlation coefficient of a dataset.`),args:[H(`data_x (range)`,N(`The range representing the array or matrix of observed data.`)),H(`data_y (range)`,N(`The range representing the array or matrix of predicted data.`))],compute:function(e,t){let n=e.flat(),r=t.flat();if(mS(n,r),n.length===0||r.length===0)return new Ao(ws);let i=n.length,a=0,o=0,s=0,c=0;for(let e=0;e<i;++e){let t=R(n[e]);t===R(r[e])?t?o++:a++:t?c++:s++}return{value:(o*a-s*c)/Math.sqrt((o+s)*(o+c)*(a+s)*(a+c))}},isExported:!1},UZ={description:N(`Maximum value in a numeric dataset.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to consider when calculating the maximum value.`))],compute:function(...e){return yS(e,this.locale)},isExported:!0},WZ={description:N(`Maximum numeric value in a dataset.`),args:[H(`value (any, range, repeating)`,N(`Value or range to consider when calculating the maximum value.`))],compute:function(...e){let t=os(e,(e,t)=>Math.max(t,e),-1/0,this.locale);return{value:t===-1/0?0:t,format:Io(e[0])}},isExported:!0},GZ={description:N(`Returns the maximum value in a range of cells, filtered by a set of criteria.`),args:[H(`range (range)`,N(`The range of cells from which the maximum will be determined.`)),H(`criteria_range (any, range, repeating)`,N(`Range to evaluate criteria.`)),H(`criterion (string, repeating)`,N(`Criteria to check.`))],compute:function(e,...t){let n=-1/0;return gs(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n=n<i?i:n)},this.locale),{value:n===-1/0?0:n}},isExported:!0},KZ={description:N(`Median value in a numeric dataset.`),args:[H(`value (any, range, repeating)`,N(`Value or range to consider when calculating the median value.`))],compute:function(...e){let t=[];return ns(e,e=>{t.push(e)},this.locale),{value:mZ(t,{value:.5},!0,this.locale),format:Io(t[0])}},isExported:!0},qZ={description:N(`Minimum value in a numeric dataset.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to consider when calculating the minimum value.`))],compute:function(...e){return bS(e,this.locale)},isExported:!0},JZ={description:N(`Minimum numeric value in a dataset.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to consider when calculating the minimum value.`))],compute:function(...e){let t=os(e,(e,t)=>Math.min(t,e),1/0,this.locale);return{value:t===1/0?0:t,format:Io(e[0])}},isExported:!0},YZ={description:N(`Returns the minimum value in a range of cells, filtered by a set of criteria.`),args:[H(`range (range)`,N(`The range of cells from which the minimum will be determined.`)),H(`criteria_range (any, range, repeating)`,N(`Range to evaluate criteria.`)),H(`criterion (string, repeating)`,N(`Criterion to check.`))],compute:function(e,...t){let n=1/0;return gs(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n=n>i?i:n)},this.locale),{value:n===1/0?0:n}},isExported:!0};function XZ(e,t){let{flatDataX:n,flatDataY:r}=dZ(e,t);if(n.length===0||r.length===0)return new Ao(ws);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 No:(i*s-a*o)/u}let ZZ={description:N(`Compute the Pearson product-moment correlation coefficient of a dataset.`),args:[H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>)`,N(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let n=XZ(e,t);return n instanceof No||n instanceof Ao?n:{value:n}},isExported:!0},QZ=ZZ,$Z={description:N(`Value at a given percentile of a dataset.`),args:[H(`data (any, range)`,N(`The array or range containing the dataset to consider.`)),H(`percentile (number)`,N(`The percentile whose value within data will be calculated and returned.`))],compute:function(e,t){return tQ.compute.bind(this)(e,t)},isExported:!0},eQ={description:N(`Value at a given percentile of a dataset exclusive of 0 and 1.`),args:[H(`data (any, range)`,N(`The array or range containing the dataset to consider.`)),H(`percentile (number)`,N(`The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.`))],compute:function(e,t){return{value:mZ([e],t,!1,this.locale),format:Io(e)}},isExported:!0},tQ={description:N(`Value at a given percentile of a dataset.`),args:[H(`data (any, range)`,N(`The array or range containing the dataset to consider.`)),H(`percentile (number)`,N(`The percentile whose value within data will be calculated and returned.`))],compute:function(e,t){return{value:mZ([e],t,!0,this.locale),format:Io(e)}},isExported:!0},nQ={description:N(`Compute the coefficients of polynomial regression of the dataset.`),args:[H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>)`,N(`The range representing the array or matrix of independent data.`)),H(`order (number)`,N(`The order of the polynomial to fit the data, between 1 and 6.`),cZ),H(`intercept (boolean, default=TRUE)`,N(`A flag specifying whether to compute the intercept or not.`),lZ)],computeArray:function(e,t,n,r={value:!0}){let{flatDataX:i,flatDataY:a}=dZ(e,t);return i.length===0||a.length===0?new Ao(ws):cs(CS(a,i,I(n,this.locale),R(r)),e=>({value:e}))},isExported:!1},rQ={description:N(`Predict value by computing a polynomial regression of the dataset.`),args:[H(`x (number, range<number>)`,N(`The value(s) on the x-axis to forecast.`)),H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>)`,N(`The range representing the array or matrix of independent data.`)),H(`order (number)`,N(`The order of the polynomial to fit the data, between 1 and 6.`),cZ),H(`intercept (boolean, default=TRUE)`,N(`A flag specifying whether to compute the intercept or not.`),lZ)],computeArray:function(e,t,n,r,i={value:!0}){let a=I(r,this.locale),{flatDataX:o,flatDataY:s}=dZ(t,n);if(o.length===0||s.length===0)return new Ao(ws);let c=CS(s,o,a,R(i)).flat();return cs(z(e),e=>({value:TS(c,I(e,this.locale),a)}))},isExported:!1},iQ={description:N(`Value nearest to a specific quartile of a dataset.`),args:[H(`data (any, range)`,N(`The array or range containing the dataset to consider.`)),H(`quartile_number (number)`,N(`Which quartile value to return.`),uZ)],compute:function(e,t){return oQ.compute.bind(this)(e,t)},isExported:!0},aQ={description:N(`Value nearest to a specific quartile of a dataset exclusive of 0 and 4.`),args:[H(`data (any, range)`,N(`The array or range containing the dataset to consider.`)),H(`quartile_number (number)`,N(`Which quartile value, exclusive of 0 and 4, to return.`),[{value:1,label:N(`First quartile (25th percentile)`)},{value:2,label:N(`Median value (50th percentile)`)},{value:3,label:N(`Third quartile (75th percentile)`)}])],compute:function(e,t){let n={value:.25*Math.trunc(I(t,this.locale))};return{value:mZ([e],n,!1,this.locale),format:Io(e)}},isExported:!0},oQ={description:N(`Value nearest to a specific quartile of a dataset.`),args:[H(`data (any, range)`,N(`The array or range containing the dataset to consider.`)),H(`quartile_number (number)`,N(`Which quartile value to return.`),uZ)],compute:function(e,t){let n={value:.25*Math.trunc(I(t,this.locale))};return{value:mZ([e],n,!0,this.locale),format:Io(e)}},isExported:!0},sQ={description:N(`Returns the rank of a specified value in a dataset.`),args:[H(`value (number)`,N(`The value whose rank will be determined.`)),H(`data (range)`,N(`The range containing the dataset to consider.`)),H(`is_ascending (boolean, default=FALSE)`,N(`Whether to consider the values in data in descending or ascending order.`),[{value:!1,label:N(`Descending`)},{value:!0,label:N(`Ascending`)}])],compute:function(e,t,n={value:!1}){let r=R(n),i=I(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=I(t,this.locale);e===i?o=!0:e>i!==r&&a++}return o?{value:a}:new Ao(N(`Value not found in the given data.`))},isExported:!0},cQ={description:N(`Compute the square of r, the Pearson product-moment correlation coefficient of a dataset.`),args:[H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>)`,N(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let n=XZ(e,t);return n instanceof No||n instanceof Ao?n:{value:n**2}},isExported:!0},lQ={description:N(`Compute the slope of the linear regression.`),args:[H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>)`,N(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=dZ(e,t);if(n.length===0||r.length===0)return new Ao(ws);let[[i]]=SS([n],[r]);return{value:i}},isExported:!0},uQ={description:N(`Skewness of a dataset.`),args:[H(`value (number, range<number>, repeating)`,N(`Values to include.`))],compute:function(...e){let t=[];ns(e,e=>t.push(e.value),this.locale);let n=t.length;cS(n>=3,N(`SKEW requires at least 3 values.`));let r=t.reduce((e,t)=>e+t,0)/n,i=t.reduce((e,t)=>e+(t-r)**2,0)/(n-1);cS(i>0,N(`SKEW requires non-constant data.`));let a=Math.sqrt(i),o=t.reduce((e,t)=>e+((t-r)/a)**3,0);return{value:n/((n-1)*(n-2))*o}},isExported:!0},dQ={description:N(`Population skewness of a dataset.`),args:[H(`value (number, range<number>, repeating)`,N(`Values to include.`))],compute:function(...e){let t=[];ns(e,e=>t.push(e.value),this.locale);let n=t.length;cS(n>=3,N(`SKEW.P requires at least 3 values.`));let r=t.reduce((e,t)=>e+t,0)/n,i=t.reduce((e,t)=>e+(t-r)**2,0)/n;cS(i>0,N(`SKEW.P requires non-constant data.`));let a=Math.sqrt(i);return{value:t.reduce((e,t)=>e+((t-r)/a)**3,0)/n}},isExported:!0},fQ={description:N(`Nth smallest element in a data set.`),args:[H(`data (any, range)`,N(`The array or range containing the dataset to consider.`)),H(`n (number)`,N(`The rank from smallest to largest of the element to return.`))],compute:function(e,t){let n=Math.trunc(I(t?.value,this.locale)),r=[],i,a=0;ts([e],e=>{typeof e?.value==`number`&&(i=_s(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 F(ws):a<n?new F(N(`Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.`,n)):o},isExported:!0},pQ={description:N(`Compute the Spearman rank correlation coefficient of a dataset.`),args:[H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>)`,N(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=dZ(t,e);if(n.length===0||r.length===0)return new Ao(ws);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{value:1-6*o/(i**3-i)}},isExported:!1},mQ={description:N(`Standard deviation.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the sample.`))],compute:function(...e){return{value:Math.sqrt(wQ.compute.bind(this)(...e).value)}},isExported:!0},hQ={description:N(`Standard deviation of entire population.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the population.`))],compute:function(...e){return{value:Math.sqrt(TQ.compute.bind(this)(...e).value)}},isExported:!0},gQ={description:N(`Standard deviation.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the sample.`))],compute:function(...e){return{value:Math.sqrt(EQ.compute.bind(this)(...e).value)}},isExported:!0},_Q={description:N(`Standard deviation of sample (text as 0).`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the sample.`))],compute:function(...e){return{value:Math.sqrt(DQ.compute.bind(this)(...e).value)}},isExported:!0},vQ={description:N(`Standard deviation of entire population.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the population.`))],compute:function(...e){return{value:Math.sqrt(OQ.compute.bind(this)(...e).value)}},isExported:!0},yQ={description:N(`Standard deviation of entire population (text as 0).`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the population.`))],compute:function(...e){return{value:Math.sqrt(kQ.compute.bind(this)(...e).value)}},isExported:!0},bQ={description:N(`Returns the p-value of a Student's t-test.`),args:[H(`range1 (range<number>)`,N(`The first sample.`)),H(`range2 (range<number>)`,N(`The second sample.`)),H(`tails (number)`,N(`1 for one-tailed, 2 for two-tailed.`)),H(`type (number)`,N(`1 = paired, 2 = two-sample equal variance, 3 = two-sample unequal variance (Welch).`))],compute:function(e,t,n,r){let i=Math.round(I(n,this.locale)),a=Math.round(I(r,this.locale));cS(i===1||i===2,N(`Tails must be 1 or 2.`)),cS(a>=1&&a<=3,N(`Type must be 1, 2, or 3.`));let o=[],s=[];ns([e],e=>o.push(e.value),this.locale),ns([t],e=>s.push(e.value),this.locale);let c,l;if(a===1){cS(o.length===s.length,N(`Paired t-test requires equal-length ranges.`));let e=o.map((e,t)=>e-s[t]),t=e.length;cS(t>=2,N(`Paired t-test requires at least 2 pairs.`));let n=e.reduce((e,t)=>e+t,0)/t,r=e.reduce((e,t)=>e+(t-n)**2,0)/(t-1);if(r===0){let e=+(n===0);return{value:i===1?e/2:e}}c=Math.abs(n)/Math.sqrt(r/t),l=t-1}else{let e=o.length,t=s.length;cS(e>=2&&t>=2,N(`Each range must contain at least 2 numeric values.`));let n=o.reduce((e,t)=>e+t,0)/e,r=s.reduce((e,t)=>e+t,0)/t,i=o.reduce((e,t)=>e+(t-n)**2,0)/(e-1),u=s.reduce((e,t)=>e+(t-r)**2,0)/(t-1);if(a===2){let a=((e-1)*i+(t-1)*u)/(e+t-2);cS(a>0,N(`T.TEST requires non-constant data.`)),c=Math.abs(n-r)/Math.sqrt(a*(1/e+1/t)),l=e+t-2}else{let a=i/e,o=u/t;cS(a+o>0,N(`T.TEST requires non-constant data.`)),c=Math.abs(n-r)/Math.sqrt(a+o),l=(a+o)**2/(a**2/(e-1)+o**2/(t-1))}}let u=FS(c,l);return{value:i===1?u/2:u}},isExported:!0},xQ={description:N(`Calculates the standard error of the predicted y-value for each x in the regression of a dataset.`),args:[H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>)`,N(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=dZ(e,t);return n.length===0||r.length===0?new Ao(ws):{value:SS([n],[r],!0,!0)[1][2]}},isExported:!0},SQ={description:N(`Fits points to linear trend derived via least-squares.`),args:[H(`known_data_y (number, range<number>)`,N(`The array or range containing dependent (y) values that are already known, used to curve fit an ideal linear trend.`)),H(`known_data_x (number, range<number>, optional, default={1;2;3;...})`,N(`The values of the independent variable(s) corresponding with known_data_y.`)),H(`new_data_x (number, range<number>, optional, default=known_data_x)`,N(`The data points to return the y values for on the ideal curve fit.`)),H(`b (boolean, optional, default=TRUE)`,N(`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.`),oZ)],computeArray:function(e,t=[[]],n=[[]],r={value:!0}){return e.length===0||e[0].length===0?new F(Ts(`known_data_y`)):cs(OS(Wo(e,`known_data_y`),Wo(t,`known_data_x`),Wo(n,`new_data_y`),R(r)),e=>({value:e}))}},CQ={description:N(`Average of a dataset after discarding a fraction of data from the ends.`),args:[H(`range (number, range<number>)`,N(`The data to average.`)),H(`percent (number)`,N(`Fraction of data to trim from each end (0 to 0.5).`))],compute:function(e,t){let n=I(t,this.locale);cS(n>=0&&n<.5,N(`Percent must be between 0 (inclusive) and 0.5 (exclusive).`));let r=[];ns([e],e=>r.push(e.value),this.locale),cS(r.length>0,ws),r.sort((e,t)=>e-t);let i=Math.floor(r.length*n/2),a=r.slice(i,r.length-i);return{value:a.reduce((e,t)=>e+t,0)/a.length}},isExported:!0},wQ={description:N(`Variance.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the sample.`))],compute:function(...e){return{value:pZ(e,!0,!1,this.locale)}},isExported:!0},TQ={description:N(`Variance of entire population.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the population.`))],compute:function(...e){return{value:pZ(e,!1,!1,this.locale)}},isExported:!0},EQ={description:N(`Variance.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the sample.`))],compute:function(...e){return{value:pZ(e,!0,!1,this.locale)}},isExported:!0},DQ={description:N(`Variance of sample (text as 0).`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the sample.`))],compute:function(...e){return{value:pZ(e,!0,!0,this.locale)}},isExported:!0},OQ={description:N(`Variance of entire population.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the population.`))],compute:function(...e){return{value:pZ(e,!1,!1,this.locale)}},isExported:!0},kQ={description:N(`Variance of entire population (text as 0).`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the population.`))],compute:function(...e){return{value:pZ(e,!1,!0,this.locale)}},isExported:!0};var AQ=l({DAVERAGE:()=>NQ,DCOUNT:()=>PQ,DCOUNTA:()=>FQ,DGET:()=>IQ,DMAX:()=>LQ,DMIN:()=>RQ,DPRODUCT:()=>zQ,DSTDEV:()=>BQ,DSTDEVP:()=>VQ,DSUM:()=>HQ,DVAR:()=>UQ,DVARP:()=>WQ});function jQ(e,t,n,r){let i=new Map,a=e.length;for(let t=a-1;t>=0;t--)i.set(L(e[t][0]).toUpperCase(),t);let o=t?.value;if(typeof o!=`number`&&typeof o!=`string`)throw new F(N(`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 F(N(`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=L(t).toUpperCase();if(s=i.get(e)??-1,s===-1)throw new F(N(`The field (%s) must be one of %s.`,L(t),[...i.keys()].toString()))}let c=n[0].length;if(c<2)throw new F(N(`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=L(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)gs(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 MQ=[H(`database (range)`,N(`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.`)),H(`field (number, string)`,N(`Indicates which column in database contains the values to be extracted and operated on.`)),H(`criteria (range)`,N(`An array or range containing zero or more criteria to filter the database values by before operating.`))],NQ={description:N(`Average of a set of values from a table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return gZ.compute.bind(this)([r])},isExported:!0},PQ={description:N(`Counts values from a table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return CZ.compute.bind(this)([r])},isExported:!0},FQ={description:N(`Counts values and text from a table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return wZ.compute.bind(this)([r])},isExported:!0},IQ={description:N(`Single value from a table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return r.length===0?new F(N(`No match found in DGET evaluation.`)):r.length>1?new F(N(`More than one match found in DGET evaluation.`)):r[0]},isExported:!0},LQ={description:N(`Maximum of values from a table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return UZ.compute.bind(this)([r])},isExported:!0},RQ={description:N(`Minimum of values from a table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return qZ.compute.bind(this)([r])},isExported:!0},zQ={description:N(`Product of values from a table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return PX.compute.bind(this)([r])},isExported:!0},BQ={description:N(`Standard deviation of population sample from table.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return mQ.compute.bind(this)([r])},isExported:!0},VQ={description:N(`Standard deviation of entire population from table.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return vQ.compute.bind(this)([r])},isExported:!0},HQ={description:N(`Sum of values from a table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return ZX.compute.bind(this)([r])},isExported:!0},UQ={description:N(`Variance of population sample from table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return wQ.compute.bind(this)([r])},isExported:!0},WQ={description:N(`Variance of a population from a table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return OQ.compute.bind(this)([r])},isExported:!0},GQ=N(`The cashflow_amounts and cashflow_dates ranges must have the same dimensions.`),KQ=N(`There must be both positive and negative values in cashflow_amounts.`),qQ=e=>N(`The cost (%s) must be positive or null.`,e),JQ=e=>N(`The cost (%s) must be strictly positive.`,e),YQ=e=>N(`The frequency (%s) must be one of %s`,e,[1,2,4].toString()),XQ=e=>N(`The day_count_convention (%s) must be between 0 and 4 inclusive.`,e),ZQ=e=>N(`The depreciation factor (%s) must be strictly positive.`,e),QQ=e=>N(`The discount (%s) must be different from -1.`,e),$Q=e=>N(`The discount (%s) must be strictly positive.`,e),e$=e=>N(`The discount (%s) must be smaller than 1.`,e),t$=e=>N(`The effective_rate (%s) must be strictly positive.`,e),n$=e=>N(`The end_period (%s) must be positive or null.`,e),r$=(e,t)=>N(`The end_period (%(end)s) must be smaller or equal to the life (%(life)s).`,{end:e,life:t}),i$=e=>N(`All the dates should be greater or equal to the first date in cashflow_dates (%s).`,e),a$=(e,t)=>N(`The first_period (%(first)s) must be smaller or equal to the last_period (%(last)s).`,{first:e,last:t}),o$=e=>N(`The first_period (%s) must be strictly positive.`,e),s$=e=>N(`The future_value (%s) must be strictly positive.`,e),c$=e=>N(`The investment (%s) must be strictly positive.`,e),l$=e=>N(`The issue (%s) must be positive or null.`,e),u$=(e,t)=>N(`The last_period (%(last)s) must be smaller or equal to the number_of_periods (%(nPeriods)s).`,{last:e,nPeriods:t}),d$=e=>N(`The last_period (%s) must be strictly positive.`,e),f$=e=>N(`The life (%s) must be strictly positive.`,e),p$=(e,t)=>N(`The maturity (%(maturity)s) must be strictly greater than the settlement (%(settlement)s).`,{maturity:t,settlement:e}),m$=e=>N(`The month (%s) must be between 1 and 12 inclusive.`,e),h$=e=>N(`The nominal_rate (%s) must be strictly positive.`,e),g$=e=>N(`The number_of_periods (%s) must be different from zero.`,e),_$=e=>N(`The number_of_periods (%s) must be strictly positive.`,e),v$=e=>N(`The period must be between 1 and number_of_periods (%s)`,e),y$=(e,t)=>N(`The period (%(period)s) must be less than or equal to %(lifeLimit)s.`,{period:e,lifeLimit:t}),b$=e=>N(`The period (%s) must be positive or null.`,e),x$=e=>N(`The periods_by_year (%s) must be strictly positive.`,e),S$=(e,t)=>N(`The period (%(period)s) must be less than or equal life (%(life)s).`,{period:e,life:t}),C$=e=>N(`The period (%s) must be strictly positive.`,e),w$=e=>N(`The present_value (%s) must be strictly positive.`,e),T$=e=>N(`The price (%s) must be strictly positive.`,e),E$=(e,t)=>N(`The purchase_date (%(purchaseDate)s) must be before the first_period_end (%(firstPeriodEnd)s).`,{purchaseDate:e,firstPeriodEnd:t}),D$=e=>N(`The purchase_date (%s) must be positive or null.`,e),O$=e=>N(`The rate_guess (%s) must be strictly greater than -1.`,e),k$=e=>N(`The rate (%s) must be positive or null.`,e),A$=e=>N(`The rate (%s) must be strictly positive.`,e),j$=e=>N(`The redemption (%s) must be strictly positive.`,e),M$=e=>N(`The salvage (%s) must be positive or null.`,e),N$=(e,t)=>N(`The salvage (%(salvage)s) must be smaller or equal than the cost (%(cost)s).`,{salvage:e,cost:t}),P$=(e,t)=>N(`The settlement date (%(settlement)s) must be greater or equal to the issue date (%(issue)s).`,{settlement:e,issue:t}),F$=(e,t)=>N(`The settlement date (%(settlement)s) must at most one year after the maturity date (%(maturity)s).`,{settlement:e,maturity:t}),I$=(e,t)=>N(`The settlement date (%(settlement)s) must be strictly greater than the issue date (%(issue)s).`,{settlement:e,issue:t}),L$=e=>N(`The start_period (%s) must be positive or null.`,e),R$=(e,t)=>N(`The start_period (%(start)s) must be smaller or equal to the end_period (%(end)s).`,{start:e,end:t}),z$=e=>N(`The unit (%s) must be strictly positive.`,e),B$=e=>N(`The yield (%s) must be positive or null.`,e);function V$(e){return e.some(e=>e>0)&&e.some(e=>e<0)}function H$(e){return![0,1,2,3,4].includes(e)}function U$(e){return![1,2,4].includes(e)}function W$(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 G$=[{value:0,label:N(`US (NASD) 30/360`)},{value:1,label:N(`Actual/Actual`)},{value:2,label:N(`Actual/360`)},{value:3,label:N(`Actual/365`)},{value:4,label:N(`European 30/360`)}];var K$=l({DATE:()=>J$,DATEDIF:()=>Y$,DATEVALUE:()=>X$,DAY:()=>Z$,DAYS:()=>Q$,DAYS360:()=>$$,EDATE:()=>e1,EOMONTH:()=>t1,HOUR:()=>n1,ISOWEEKNUM:()=>r1,MINUTE:()=>i1,MONTH:()=>a1,MONTH_END:()=>S1,MONTH_START:()=>x1,NETWORKDAYS:()=>o1,NETWORKDAYS_INTL:()=>l1,NOW:()=>u1,QUARTER:()=>C1,QUARTER_END:()=>T1,QUARTER_START:()=>w1,SECOND:()=>d1,TIME:()=>f1,TIMEVALUE:()=>p1,TODAY:()=>m1,WEEKDAY:()=>h1,WEEKNUM:()=>g1,WORKDAY:()=>_1,WORKDAY_INTL:()=>v1,YEAR:()=>y1,YEARFRAC:()=>b1,YEAR_END:()=>D1,YEAR_START:()=>E1}),q$=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}(q$||{});let J$={description:N(`Converts year/month/day into a date.`),args:[H(`year (number)`,N(`The year component of the date.`)),H(`month (number)`,N(`The month component of the date.`)),H(`day (number)`,N(`The day component of the date.`))],compute:function(e,t,n){let r=Math.trunc(I(e,this.locale)),i=Math.trunc(I(t,this.locale)),a=Math.trunc(I(n,this.locale));if(r<0||r>9999)return new F(N(`The year (%s) must be between 0 and 9999 inclusive.`,r.toString()));r<1900&&(r+=1900);let o=Ja(new xa(r,i-1,a));return o<0?new F(N(`The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.`)):{value:o,format:this.locale.dateFormat}},isExported:!0},Y$={description:N(`Calculates the number of days, months, or years between two dates.`),args:[H(`start_date (date)`,N(`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.`)),H(`end_date (date)`,N(`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.`)),H(`unit (string)`,N(`A text abbreviation for unit of time.`),[{value:`Y`,label:N(`The number of whole years between start_date and end_date`)},{value:`M`,label:N(`The number of whole months between start_date and end_date`)},{value:`D`,label:N(`The number of days between start_date and end_date`)},{value:`MD`,label:N(`The number of days between start_date and end_date after subtracting whole months`)},{value:`YM`,label:N(`The number of whole months between start_date and end_date after subtracting whole years`)},{value:`YD`,label:N(`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=L(n).toUpperCase();if(!Object.values(q$).includes(r))return new F(Ho(Object.values(q$),L(n)));let i=Math.trunc(I(e,this.locale)),a=Math.trunc(I(t,this.locale)),o=qa(i),s=qa(a);if(a<i)return new F(N(`start_date (%s) should be on or before end_date (%s).`,o.toLocaleDateString(),s.toLocaleDateString()));switch(r){case`Y`:return{value:ro(o,s)};case`M`:return{value:to(o,s)};case`D`:return{value:no(o,s)};case`YM`:return{value:to(o,s)-ro(o,s)*12};case`MD`:let e=s.getDate()-o.getDate();return e<0&&(e=Xa(new xa(s.getFullYear(),s.getMonth()-1,1))-Math.abs(e)),{value:e};case`YD`:{if(io(i,a))return{value:no(o,s)};let e=new xa(o.getFullYear(),s.getMonth(),s.getDate()),t=no(o,e);return t<0&&(e.setFullYear(o.getFullYear()+1),t=no(o,e)),{value:t}}}},isExported:!0},X$={description:N(`Converts a date string to a date value.`),args:[H(`date_string (string)`,N(`The string representing the date.`))],compute:function(e){let t=L(e),n=La(t,this.locale);return n===null?new F(N(`The date_string (%s) cannot be parsed to date/time.`,t.toString())):{value:Math.trunc(n.value)}},isExported:!0},Z$={description:N(`Day of the month that a specific date falls on.`),args:[H(`date (string)`,N(`The date from which to extract the day.`))],compute:function(e){return{value:Qo(e,this.locale).getDate()}},isExported:!0},Q$={description:N(`Number of days between two dates.`),args:[H(`end_date (date)`,N(`The end of the date range.`)),H(`start_date (date)`,N(`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{value:Math.round(i/Ca)}},isExported:!0},$$={description:N(`Number of days between two dates on a 360-day year (months of 30 days).`),args:[H(`start_date (date)`,N(`The start date to consider in the calculation.`)),H(`end_date (date)`,N(`The end date to consider in the calculation.`)),H(`method (boolean, default=false)`,N(`An indicator of what day count method to use.`),[{value:!1,label:N(`U.S. NASD method (default)`)},{value:!0,label:N(`European method`)}])],compute:function(e,t,n={value:!1}){let r=Math.trunc(I(e,this.locale)),i=Math.trunc(I(t,this.locale)),a=eo(r,i,R(n)?4:0);return{value:Math.sign(i-r)*Math.round(a*360)}},isExported:!0},e1={description:N(`Date a number of months before/after another date.`),args:[H(`start_date (date)`,N(`The date from which to calculate the result.`)),H(`months (number)`,N(`The number of months before (negative) or after (positive) 'start_date' to calculate.`))],compute:function(e,t){return{value:Ja(Qa(Qo(e,this.locale),Math.trunc(I(t,this.locale)),!1)),format:this.locale.dateFormat}},isExported:!0},t1={description:N(`Last day of a month before or after a date.`),args:[H(`start_date (date)`,N(`The date from which to calculate the result.`)),H(`months (number)`,N(`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(I(t,this.locale));return{value:Ja(new xa(n.getFullYear(),n.getMonth()+r+1,0)),format:this.locale.dateFormat}},isExported:!0},n1={description:N(`Hour component of a specific time.`),args:[H(`time (date)`,N(`The time from which to calculate the hour component.`))],compute:function(e){return{value:Qo(e,this.locale).getHours()}},isExported:!0},r1={description:N(`ISO week number of the year.`),args:[H(`date (date)`,N(`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 xa(n,0,r).getDay()!==4;)r+=1;let i=new xa(n,0,r-3),a=31;for(;new xa(n,11,a).getDay()!==4;)--a;let o=new xa(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 xa(n,11,a+3+1);break;case-1:let e=1;for(;new xa(n-1,0,e).getDay()!==4;)e+=1;c=new xa(n-1,0,e-3);break}let l=(t.getTime()-c.getTime())/Ca;return{value:Math.floor(l/7)+1}},isExported:!0},i1={description:N(`Minute component of a specific time.`),args:[H(`time (date)`,N(`The time from which to calculate the minute component.`))],compute:function(e){return{value:Qo(e,this.locale).getMinutes()}},isExported:!0},a1={description:N(`Month of the year a specific date falls in`),args:[H(`date (date)`,N(`The date from which to extract the month.`))],compute:function(e){return{value:Qo(e,this.locale).getMonth()+1}},isExported:!0},o1={description:N(`Net working days between two provided days.`),args:[H(`start_date (date)`,N(`The start date of the period from which to calculate the number of net working days.`)),H(`end_date (date)`,N(`The end date of the period from which to calculate the number of net working days.`)),H(`holidays (date, range<date>, optional)`,N(`A range or array constant containing the date serial numbers to consider holidays.`))],compute:function(e,t,n){return l1.compute.bind(this)(e,t,{value:1},n)},isExported:!0};function s1(e){let t=e?.value;if(typeof t==`string`){cS(t.length===7&&[...t].every(e=>e===`0`||e===`1`),N(`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 cS(1<=t&&t<=7||11<=t&&t<=17,N(`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 F(N(`The weekend must be a number or a string.`))}let c1=[{value:1,label:N(`Saturday/Sunday are weekends`)},{value:2,label:N(`Sunday/Monday are weekends`)},{value:3,label:N(`Monday/Tuesday are weekends`)},{value:4,label:N(`Tuesday/Wednesday are weekends`)},{value:5,label:N(`Wednesday/Thursday are weekends`)},{value:6,label:N(`Thursday/Friday are weekends`)},{value:7,label:N(`Friday/Saturday are weekends`)},{value:11,label:N(`Sunday is the only weekend`)},{value:12,label:N(`Monday is the only weekend`)},{value:13,label:N(`Tuesday is the only weekend`)},{value:14,label:N(`Wednesday is the only weekend`)},{value:15,label:N(`Thursday is the only weekend`)},{value:16,label:N(`Friday is the only weekend`)},{value:17,label:N(`Saturday is the only weekend`)}],l1={description:N(`Net working days between two dates (specifying weekends).`),args:[H(`start_date (date)`,N(`The start date of the period from which to calculate the number of net working days.`)),H(`end_date (date)`,N(`The end date of the period from which to calculate the number of net working days.`)),H(`weekend (any, default=1)`,N(`A number or string representing which days of the week are considered weekends.`),c1),H(`holidays (date, range<date>, optional)`,N(`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=s1(n),s=new Set;r!==void 0&&ts([r],e=>{let t=Qo(e,this.locale);s.add(t.getTime())});let c=i.getTime()>a.getTime(),l=xa.fromTimestamp((c?i:a).getTime()),u=xa.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{value:c?-p:p}},isExported:!0},u1={description:N(`Current date and time as a date value.`),args:[],compute:function(){let e=xa.now(),t=e.getTime()-Sa.getTime(),n=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return{value:Math.floor(t/Ca)+n,format:av(this.locale)}},isExported:!0},d1={description:N(`Minute component of a specific time.`),args:[H(`time (date)`,N(`The time from which to calculate the second component.`))],compute:function(e){return{value:Qo(e,this.locale).getSeconds()}},isExported:!0},f1={description:N(`Converts hour/minute/second into a time.`),args:[H(`hour (number)`,N(`The hour component of the time.`)),H(`minute (number)`,N(`The minute component of the time.`)),H(`second (number)`,N(`The second component of the time.`))],compute:function(e,t,n){let r=Math.trunc(I(e,this.locale)),i=Math.trunc(I(t,this.locale)),a=Math.trunc(I(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 F(N(`The function [[FUNCTION_NAME]] result cannot be negative`)):{value:r/24+i/1440+a/(1440*60),format:this.locale.timeFormat}},isExported:!0},p1={description:N(`Converts a time string into its serial number representation.`),args:[H(`time_string (string)`,N(`The string that holds the time representation.`))],compute:function(e){let t=L(e),n=La(t,this.locale);if(n===null)return new F(N(`The time_string (%s) cannot be parsed to date/time.`,t));let r=n.value-Math.trunc(n.value);return{value:r<0?1+r:r}},isExported:!0},m1={description:N(`Current date as a date value.`),args:[],compute:function(){let e=xa.now();return{value:Ja(new xa(e.getFullYear(),e.getMonth(),e.getDate())),format:this.locale.dateFormat}},isExported:!0},h1={description:N(`Day of the week of the date provided (as number).`),args:[H(`date (date)`,N(`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.`)),H(`type (number, default=1)`,N(`A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.`),[{value:1,label:N(`Numbers 1 (Sunday) trough 7 (Saturday)`)},{value:2,label:N(`Numbers 1 (Monday) trough 7 (Sunday)`)},{value:3,label:N(`Numbers 0 (Monday) trough 6 (Sunday)`)},{value:11,label:N(`Numbers 1 (Monday) trough 7 (Sunday)`)},{value:12,label:N(`Numbers 1 (Tuesday) trough 7 (Monday)`)},{value:13,label:N(`Numbers 1 (Wednesday) trough 7 (Tuesday)`)},{value:14,label:N(`Numbers 1 (Thursday) trough 7 (Wednesday)`)},{value:15,label:N(`Numbers 1 (Friday) trough 7 (Thursday)`)},{value:16,label:N(`Numbers 1 (Saturday) trough 7 (Friday)`)},{value:17,label:N(`Numbers 1 (Sunday) trough 7 (Saturday)`)}])],compute:function(e,t={value:1}){let n=Qo(e,this.locale),r=Math.round(I(t,this.locale)),i=n.getDay();if(!(1<=r&&r<=3)&&!(11<=r&&r<=17))return new F(N(`The type (%s) must be between 1 and 3 or between 11 and 17.`,r));switch(r){case 1:return{value:i+1};case 2:return{value:i===0?7:i};case 3:return{value:i===0?6:i-1}}let a=r-10,o=(i+1-a+7)%7;return{value:o===0?7:o}},isExported:!0},g1={description:N(`Week number of the year.`),args:[H(`date (date)`,N(`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.`)),H(`type (number, default=1)`,N(`A number representing the day that a week starts on. Sunday = 1.`),[{value:1,label:N(`Sunday`)},{value:2,label:N(`Monday`)},{value:11,label:N(`Monday`)},{value:12,label:N(`Tuesday`)},{value:13,label:N(`Wednesday`)},{value:14,label:N(`Thursday`)},{value:15,label:N(`Friday`)},{value:16,label:N(`Saturday`)},{value:17,label:N(`Sunday`)},{value:21,label:N(`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(I(t,this.locale));if(![1,2,11,12,13,14,15,16,17,21].includes(r))return new F(N(`The type (%s) is out of range.`,r.toString()));if(r===21)return r1.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 xa(a,0,o);for(;s.getDay()!==i;)o+=1,s=new xa(a,0,o);let c=(n.getTime()-s.getTime())/Ca;return c<0?{value:1}:{value:Math.floor(c/7)+(o===1?1:2)}},isExported:!0},_1={description:N(`Date after a number of workdays.`),args:[H(`start_date (date)`,N(`The date from which to begin counting.`)),H(`num_days (number)`,N(`The number of working days to advance from start_date. If negative, counts backwards.`)),H(`holidays (date, range<date>, optional)`,N(`A range or array constant containing the dates to consider holidays.`))],compute:function(e,t,n={value:null}){return v1.compute.bind(this)(e,t,{value:1},n)},isExported:!0},v1={description:N(`Date after a number of workdays (specifying weekends).`),args:[H(`start_date (date)`,N(`The date from which to begin counting.`)),H(`num_days (number)`,N(`The number of working days to advance from start_date. If negative, counts backwards.`)),H(`weekend (any, default=1)`,N(`A number or string representing which days of the week are considered weekends.`),c1),H(`holidays (date, range<date>, optional)`,N(`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(I(t,this.locale));if(n.value===`1111111`)return new F(N(`The weekend must be different from '1111111'.`));let o=s1(n),s=new Set;r!==void 0&&ts([r],e=>{let t=Qo(e,this.locale);s.add(t.getTime())});let c=xa.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-Sa.getTime();return{value:Math.round(f/Ca),format:this.locale.dateFormat}},isExported:!0},y1={description:N(`Year specified by a given date.`),args:[H(`date (date)`,N(`The date from which to extract the year.`))],compute:function(e){return{value:Qo(e,this.locale).getFullYear()}},isExported:!0},b1={description:N(`Exact number of years between two dates.`),args:[H(`start_date (date)`,N(`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.`)),H(`end_date (date)`,N(`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.`)),H(`day_count_convention (number, default=0)`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n={value:0}){let r=Math.trunc(I(e,this.locale)),i=Math.trunc(I(t,this.locale)),a=Math.trunc(I(n,this.locale));return r<0?new F(N(`The start_date (%s) must be positive or null.`,r)):i<0?new F(N(`The end_date (%s) must be positive or null.`,i)):0>a||a>4?new F(N(`The day_count_convention (%s) must be between 0 and 4 inclusive.`,a)):{value:eo(r,i,a)}}},x1={description:N(`First day of the month a date falls in.`),args:[H(`date (date)`,N(`The date from which to calculate the result.`))],compute:function(e){let t=Qo(e,this.locale);return{value:Ja(new xa(t.getFullYear(),t.getMonth(),1)),format:this.locale.dateFormat}}},S1={description:N(`Last day of the month a date falls in.`),args:[H(`date (date)`,N(`The date from which to calculate the result.`))],compute:function(e){return t1.compute.bind(this)(e,{value:0})}},C1={description:N(`Quarter of the year a specific date falls in`),args:[H(`date (date)`,N(`The date from which to extract the quarter.`))],compute:function(e){return{value:Math.ceil((Qo(e,this.locale).getMonth()+1)/3)}}},w1={description:N(`First day of the quarter of the year a specific date falls in.`),args:[H(`date (date)`,N(`The date from which to calculate the start of quarter.`))],compute:function(e){let t=C1.compute.bind(this)(e).value,n=y1.compute.bind(this)(e).value;return{value:Ja(new xa(n,(t-1)*3,1)),format:this.locale.dateFormat}}},T1={description:N(`Last day of the quarter of the year a specific date falls in.`),args:[H(`date (date)`,N(`The date from which to calculate the end of quarter.`))],compute:function(e){let t=C1.compute.bind(this)(e).value,n=y1.compute.bind(this)(e).value;return{value:Ja(new xa(n,t*3,0)),format:this.locale.dateFormat}}},E1={description:N(`First day of the year a specific date falls in.`),args:[H(`date (date)`,N(`The date from which to calculate the start of the year.`))],compute:function(e){let t=y1.compute.bind(this)(e).value;return{value:Ja(new xa(t,0,1)),format:this.locale.dateFormat}}},D1={description:N(`Last day of the year a specific date falls in.`),args:[H(`date (date)`,N(`The date from which to calculate the end of the year.`))],compute:function(e){let t=y1.compute.bind(this)(e).value;return{value:Ja(new xa(t+1,0,0)),format:this.locale.dateFormat}}};var O1=l({DELTA:()=>k1});let k1={description:N(`Compare two numeric values, returning 1 if they're equal.`),args:[H(`number1 (number)`,N(`The first number to compare.`)),H(`number2 (number, default=0)`,N(`The second number to compare.`))],compute:function(e,t={value:0}){return{value:+(I(e,this.locale)===I(t,this.locale))}},isExported:!0};var A1=l({FILTER:()=>M1,SORT:()=>N1,SORTN:()=>P1,UNIQUE:()=>F1});function j1(e,t,...n){for(let e=0;e<n.length;e++){let t=e%2==0?`sort_column`:`is_ascending`;cS(n[e]!==void 0,N(`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(R(fg(n[o+1])?.value)?`asc`:`desc`);let s=n[o];if(wt(s)&&(s.length>1||s[0].length>1))cS(s.length===1&&s[0].length===a,N(`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=I(fg(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:IV(`desc`),asc:IV(`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 M1={description:N(`Returns a filtered version of the source range, returning only rows or columns that meet the specified conditions.`),args:[H(`range (any, range<any>)`,N(`The data to be filtered.`)),H(`condition (boolean, range<boolean>, repeating)`,N(`Column or row containing true or false values corresponding to the range.`))],computeArray:function(e,...t){let n=z(e),r=t.map(e=>cs(z(e),e=>e.value));for(let e of r)if(!uS(e))return new F(N(`The arguments condition must be a single column or row.`));if(!dS(...t))return new F(N(`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`?us(n):n,i.some(e=>e.length!==n.length))return new F(N(`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`?us(o):o:new Ao(N(`No match found in FILTER evaluation`))},isExported:!1},N1={description:N(`Sorts the rows of a given array or range by the values in one or more columns.`),args:[H(`range (range)`,N(`The data to be sorted.`)),H(`sort_column (any, range<number>, repeating, optional)`,N(`The index of the column in range or a range outside of range containing the value by which to sort.`)),H(`is_ascending (boolean, repeating, optional)`,N(`TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.`),[{value:!0,label:N(`Ascending`)},{value:!1,label:N(`Descending`)}])],computeArray:function(e,...t){return us(j1(us(e),this.locale,...t))},isExported:!0},P1={description:N(`Returns the first n items in a data set after performing a sort.`),args:[H(`range (range)`,N(`The data to be sorted.`)),H(`n (number)`,N(`The number of items to return.`)),H(`display_ties_mode (number, default=0)`,N(`A number representing the way to display ties.`)),H(`sort_column (number, range<number>, repeating, optional)`,N(`The index of the column in range or a range outside of range containing the value by which to sort.`)),H(`is_ascending (boolean, repeating, optional)`,N(`TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.`),[{value:!0,label:N(`Ascending`)},{value:!1,label:N(`Descending`)}])],compute:function(e,t,...n){let r=I(t?.value??1,this.locale),i=n.length%2==0?0:I(n[0]?.value,this.locale),a=n.length%2==0?n:n.slice(1);if(r<0)return new F(N(`Wrong value of 'n'. Expected a positive number. Got %s.`,r));if(i<0||i>3)return new F(N(`Wrong value of 'display_ties_mode'. Expected a positive number between 0 and 3. Got %s.`,i));let o=j1(us(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 us(o.slice(0,r));case 1:for(let e=r;e<o.length;e++)if(!s(e,r-1))return us(o.slice(0,e));return us(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 us(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 us(e)}}},isExported:!1},F1={description:N(`Unique rows in the provided source range.`),args:[H(`range (any, range<any>)`,N(`The data to filter by unique entries.`)),H(`by_column (boolean, default=FALSE)`,N(`Whether to filter the data by columns or by rows.`),[{value:!0,label:N(`Return unique columns`)},{value:!1,label:N(`Return unique rows`)}]),H(`exactly_once (boolean, default=FALSE)`,N(`Whether to return only entries with no duplicates.`),[{value:!0,label:N(`Return items that appear exactly once`)},{value:!1,label:N(`Return every distinct item`)}])],computeArray:function(e={value:``},t,n){if(!wt(e))return[[e]];let r=R(t?.value)||!1,i=R(n?.value)||!1;r||(e=us(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:us(o):new F(N(`No unique values found`))},isExported:!0};var I1=l({ACCRINTM:()=>V1,AMORLINC:()=>H1,COUPDAYBS:()=>W1,COUPDAYS:()=>U1,COUPDAYSNC:()=>G1,COUPNCD:()=>K1,COUPNUM:()=>q1,COUPPCD:()=>J1,CUMIPMT:()=>Y1,CUMPRINC:()=>X1,DB:()=>Z1,DDB:()=>$1,DISC:()=>e0,DOLLARDE:()=>t0,DOLLARFR:()=>n0,DURATION:()=>r0,EFFECT:()=>i0,FV:()=>o0,FVSCHEDULE:()=>s0,INTRATE:()=>c0,IPMT:()=>u0,IRR:()=>f0,ISPMT:()=>p0,MDURATION:()=>m0,MIRR:()=>h0,NOMINAL:()=>g0,NPER:()=>_0,NPV:()=>y0,PDURATION:()=>b0,PMT:()=>S0,PPMT:()=>w0,PRICE:()=>E0,PRICEDISC:()=>D0,PRICEMAT:()=>O0,PV:()=>T0,RATE:()=>A0,RECEIVED:()=>j0,RRI:()=>M0,SLN:()=>N0,SYD:()=>P0,TBILLEQ:()=>L0,TBILLPRICE:()=>I0,TBILLYIELD:()=>R0,VDB:()=>z0,XIRR:()=>B0,XNPV:()=>V0,YIELD:()=>H0,YIELDDISC:()=>U0,YIELDMAT:()=>W0});let L1=[{value:1,label:N(`Annual`)},{value:2,label:N(`Semi-annual`)},{value:4,label:N(`Quarterly`)}],R1=[{value:0,label:N(`End of period (default)`)},{value:1,label:N(`Beginning of period`)}],z1=[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`frequency (number)`,N(`The number of interest or coupon payments per year (1, 2, or 4).`),L1),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)];function B1(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)){cS(d<r&&a!==void 0,N(`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,cS(d<r,N(`Function [[FUNCTION_NAME]] didn't find any result.`)),d++}while(!u);return o}let V1={description:N(`Accrued interest of security paying at maturity.`),args:[H(`issue (date)`,N(`The date the security was initially issued.`)),H(`maturity (date)`,N(`The maturity date of the security.`)),H(`rate (number)`,N(`The annualized rate of interest.`)),H(`redemption (number)`,N(`The redemption amount per 100 face value, or par.`)),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i={value:0}){let a=Math.trunc(I(e,this.locale)),o=Math.trunc(I(t,this.locale)),s=I(r,this.locale),c=I(n,this.locale),l=Math.trunc(I(i,this.locale));if(a<0)return new F(l$(a));if(a>=o)return new F(p$(a,o));if(H$(l))return new F(XQ(l));if(s<=0)return new F(j$(s));if(c<=0)return new F(A$(c));let u=eo(a,o,l);return{value:s*c*u}},isExported:!0},H1={description:N(`Depreciation for an accounting period.`),args:[H(`cost (number)`,N(`The initial cost of the asset.`)),H(`purchase_date (date)`,N(`The date the asset was purchased.`)),H(`first_period_end (date)`,N(`The date the first period ended.`)),H(`salvage (number)`,N(`The value of the asset at the end of depreciation.`)),H(`period (number)`,N(`The single period within life for which to calculate depreciation.`)),H(`rate (number)`,N(`The deprecation rate.`)),H(`day_count_convention (number, optional)`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=I(e,this.locale),c=Math.trunc(I(t,this.locale)),l=Math.trunc(I(n,this.locale)),u=I(r,this.locale),d=I(i,this.locale),f=I(a,this.locale),p=Math.trunc(I(o,this.locale));if(s<=0)return new F(JQ(s));if(c<0)return new F(D$(c));if(u<0)return new F(M$(u));if(u>s)return new F(N$(u,s));if(d<0)return new F(b$(d));if(f<=0)return new F(A$(f));if(H$(p))return new F(XQ(p));if(c>l)return new F(E$(c,l));let m=d<1&&d>0?1:Math.trunc(d),h=s*f,g=eo(c,l,p),_=c===l?h:h*g,v=s-_-h*m;return v>=u?{value:m===0?_:h}:{value:u-v<h?h-(u-v):0}},isExported:!0},U1={description:N(`Days in coupon period containing settlement date.`),args:z1,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(I(e,this.locale)),a=Math.trunc(I(t,this.locale)),o=Math.trunc(I(n,this.locale)),s=Math.trunc(I(r,this.locale));if(i>=a)return new F(p$(i,a));if(U$(o))return new F(YQ(o));if(H$(s))return new F(XQ(s));if(s===1){let i=J1.compute.bind(this)(e,t,n,r).value,a=K1.compute.bind(this)(e,t,n,r).value;return{value:I(a,this.locale)-I(i,this.locale)}}return{value:(s===3?365:360)/o}},isExported:!0},W1={description:N(`Days from settlement until next coupon.`),args:z1,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(I(e,this.locale)),a=Math.trunc(I(t,this.locale)),o=Math.trunc(I(n,this.locale)),s=Math.trunc(I(r,this.locale));if(i>=a)return new F(p$(i,a));if(U$(o))return new F(YQ(o));if(H$(s))return new F(XQ(s));let c=J1.compute.bind(this)(e,t,n,r).value,l=I(c,this.locale);if([1,2,3].includes(s))return{value:i-l};if(s===4){let e=eo(l,i,s);return{value: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&&Za(d)&&Za(u)&&(_=30),_===31&&(g===30||g===31)&&(_=30),m===2&&Za(d)&&(g=30),g===31&&(g=30),{value:(p-f)*360+(h-m)*30+(_-g)}},isExported:!0},G1={description:N(`Days from settlement until next coupon.`),args:z1,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(I(e,this.locale)),a=Math.trunc(I(t,this.locale)),o=Math.trunc(I(n,this.locale)),s=Math.trunc(I(r,this.locale));if(i>=a)return new F(p$(i,a));if(U$(o))return new F(YQ(o));if(H$(s))return new F(XQ(s));let c=K1.compute.bind(this)(e,t,n,r).value,l=I(c,this.locale);if([1,2,3].includes(s))return{value:l-i};if(s===4){let e=eo(i,l,s);return{value:Math.round(e*360)}}let u=W1.compute.bind(this)(e,t,n,r);return{value:I(U1.compute.bind(this)(e,t,n,r),this.locale)-I(u,this.locale)}},isExported:!0},K1={description:N(`Next coupon date after the settlement date.`),args:z1,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(I(e,this.locale)),a=Math.trunc(I(t,this.locale)),o=Math.trunc(I(n,this.locale)),s=Math.trunc(I(r,this.locale));if(i>=a)return new F(p$(i,a));if(U$(o))return new F(YQ(o));if(H$(s))return new F(XQ(s));let c=12/o,l=q1.compute.bind(this)(e,t,n,r);return{value:Ja(Qa(Qo(a,this.locale),-(I(l,this.locale)-1)*c,!0)),format:this.locale.dateFormat}},isExported:!0},q1={description:N(`Number of coupons between settlement and maturity.`),args:z1,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(I(e,this.locale)),a=Math.trunc(I(t,this.locale)),o=Math.trunc(I(n,this.locale)),s=Math.trunc(I(r,this.locale));if(i>=a)return new F(p$(i,a));if(U$(o))return new F(YQ(o));if(H$(s))return new F(XQ(s));let c=1,l=a,u=12/o;for(;l>i;)l=Ja(Qa(Qo(l,this.locale),-u,!1)),c++;return{value:c-1}},isExported:!0},J1={description:N(`Last coupon date prior to or on the settlement date.`),args:z1,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(I(e,this.locale)),a=Math.trunc(I(t,this.locale)),o=Math.trunc(I(n,this.locale)),s=Math.trunc(I(r,this.locale));if(i>=a)return new F(p$(i,a));if(U$(o))return new F(YQ(o));if(H$(s))return new F(XQ(s));let c=12/o,l=q1.compute.bind(this)(e,t,n,r).value;return{value:Ja(Qa(Qo(a,this.locale),-l*c,!0)),format:this.locale.dateFormat}},isExported:!0},Y1={description:N(`Cumulative interest paid over a set of periods.`),args:[H(`rate (number)`,N(`The interest rate.`)),H(`number_of_periods (number)`,N(`The number of payments to be made.`)),H(`present_value (number)`,N(`The current value of the annuity.`)),H(`first_period (number)`,N(`The number of the payment period to begin the cumulative calculation.`)),H(`last_period (number)`,N(`The number of the payment period to end the cumulative calculation.`)),H(`end_or_beginning (number, default=0)`,N(`The timing of the payment payments are due for each period.`),R1)],compute:function(e,t,n,r,i,a={value:0}){let o=I(r,this.locale),s=I(i,this.locale),c=I(e,this.locale),l=I(n,this.locale),u=I(t,this.locale),d=+!!R(a);if(u<=0)return new F(_$(u));if(o<=0)return new F(o$(o));if(s<=0)return new F(d$(s));if(o>s)return new F(a$(o,s));if(s>u)return new F(u$(s,u));if(c<=0)return new F(A$(c));if(l<=0)return new F(w$(l));let f=0;for(let e=o;e<=s;e++)f+=l0(c,e,u,l,0,d);return{value:f}},isExported:!0},X1={description:N(`Cumulative principal paid over a set of periods.`),args:[H(`rate (number)`,N(`The interest rate.`)),H(`number_of_periods (number)`,N(`The number of payments to be made.`)),H(`present_value (number)`,N(`The current value of the annuity.`)),H(`first_period (number)`,N(`The number of the payment period to begin the cumulative calculation.`)),H(`last_period (number)`,N(`The number of the payment period to end the cumulative calculation.`)),H(`end_or_beginning (number, default=0)`,N(`The timing of the payment payments are due for each period.`),R1)],compute:function(e,t,n,r,i,a={value:0}){let o=I(r,this.locale),s=I(i,this.locale),c=I(e,this.locale),l=I(n,this.locale),u=I(t,this.locale),d=+!!R(a);if(u<=0)return new F(_$(u));if(o<=0)return new F(o$(o));if(s<=0)return new F(d$(s));if(o>s)return new F(a$(o,s));if(s>u)return new F(u$(s,u));if(c<=0)return new F(A$(c));if(l<=0)return new F(w$(l));let f=0;for(let e=o;e<=s;e++)f+=C0(c,e,u,l,0,d);return{value:f}},isExported:!0},Z1={description:N(`Depreciation via declining balance method.`),args:[H(`cost (number)`,N(`The initial cost of the asset.`)),H(`salvage (number)`,N(`The value of the asset at the end of depreciation.`)),H(`life (number)`,N(`The number of periods over which the asset is depreciated.`)),H(`period (number)`,N(`The single period within life for which to calculate depreciation.`)),H(`month (number, optional)`,N(`The number of months in the first year of depreciation.`))],compute:function(e,t,n,r,...i){let a=I(e,this.locale),o=I(t,this.locale),s=I(n,this.locale),c=Math.trunc(I(r,this.locale)),l=i.length?Math.trunc(I(i[0],this.locale)):12,u=s+(l===12?0:1);if(a<0)return new F(qQ(a));if(o<0)return new F(M$(o));if(c<=0)return new F(C$(c));if(s<=0)return new F(f$(s));if(1>l||l>12)return new F(m$(l));if(c>u)return new F(y$(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},Q1=`#,##0.00`,$1={description:N(`Depreciation via double-declining balance method.`),args:[H(`cost (number)`,N(`The initial cost of the asset.`)),H(`salvage (number)`,N(`The value of the asset at the end of depreciation.`)),H(`life (number)`,N(`The number of periods over which the asset is depreciated.`)),H(`period (number)`,N(`The single period within life for which to calculate depreciation.`)),H(`factor (number, default=2)`,N(`The factor by which depreciation decreases.`))],compute:function(e,t,n,r,i={value:2}){let a=I(e,this.locale),o=I(t,this.locale),s=I(n,this.locale),c=I(r,this.locale),l=I(i,this.locale);if(a<0)return new F(qQ(a));if(o<0)return new F(M$(o));if(c<=0)return new F(C$(c));if(s<=0)return new F(f$(s));if(c>s)return new F(S$(c,s));if(l<=0)return new F(ZQ(l));if(a===0||o>=a)return{value:0,format:Q1};let u=l/s;if(u>1)return{value:c===1?a-o:0,format:Q1};if(c<=1)return{value:a*u,format:Q1};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:Q1}},isExported:!0},e0={description:N(`Discount rate of a security based on price.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`price (number)`,N(`The price at which the security is bought per 100 face value.`)),H(`redemption (number)`,N(`The redemption amount per 100 face value, or par.`)),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(I(e,this.locale)),o=Math.trunc(I(t,this.locale)),s=I(n,this.locale),c=I(r,this.locale),l=Math.trunc(I(i,this.locale));if(a>=o)return new F(p$(a,o));if(H$(l))return new F(XQ(l));if(s<=0)return new F(T$(s));if(c<=0)return new F(j$(c));let u=eo(a,o,l);return{value:(c-s)/c/u}},isExported:!0},t0={description:N(`Convert a decimal fraction to decimal value.`),args:[H(`fractional_price (number)`,N(`The price quotation given using fractional decimal conventions.`)),H(`unit (number)`,N(`The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.`))],compute:function(e,t){let n=I(e,this.locale),r=Math.trunc(I(t,this.locale));if(r<=0)return new F(z$(r));let i=Math.trunc(n);return{value:i+(n-i)*(10**Math.ceil(Math.log10(r))/r)}},isExported:!0},n0={description:N(`Convert a decimal value to decimal fraction.`),args:[H(`decimal_price (number)`,N(`The price quotation given as a decimal value.`)),H(`unit (number)`,N(`The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.`))],compute:function(e,t){let n=I(e,this.locale),r=Math.trunc(I(t,this.locale));if(r<=0)return new F(z$(r));let i=Math.trunc(n);return{value:i+(n-i)*(r/10**Math.ceil(Math.log10(r)))}},isExported:!0},r0={description:N(`Number of periods for an investment to reach a value.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`rate (number)`,N(`The annualized rate of interest.`)),H(`yield (number)`,N(`The expected annual yield of the security.`)),H(`frequency (number)`,N(`The number of interest or coupon payments per year (1, 2, or 4).`),L1),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i,a={value:0}){let o=Math.trunc(I(e,this.locale)),s=Math.trunc(I(t,this.locale)),c=I(n,this.locale),l=I(r,this.locale),u=Math.trunc(I(i,this.locale)),d=Math.trunc(I(a,this.locale));if(o>=s)return new F(p$(o,s));if(U$(u))return new F(YQ(u));if(H$(d))return new F(XQ(d));if(c<0)return new F(k$(c));if(l<0)return new F(B$(l));let f=eo(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{value:_===0?0:v/_}},isExported:!0},i0={description:N(`Annual effective interest rate.`),args:[H(`nominal_rate (number)`,N(`The nominal interest rate per year.`)),H(`periods_per_year (number)`,N(`The number of compounding periods per year.`))],compute:function(e,t){let n=I(e,this.locale),r=Math.trunc(I(t,this.locale));return n<=0?new F(h$(n)):r<=0?new F(x$(r)):{value:(1+n/r)**+r-1}},isExported:!0};function a0(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 o0={description:N(`Future value of an annuity investment.`),args:[H(`rate (number)`,N(`The interest rate.`)),H(`number_of_periods (number)`,N(`The number of payments to be made.`)),H(`payment_amount (number)`,N(`The amount per period to be paid.`)),H(`present_value (number, default=0)`,N(`The current value of the annuity.`)),H(`end_or_beginning (number, default=0)`,N(`The timing of the payment payments are due for each period.`),R1)],compute:function(e,t,n,r={value:0},i={value:0}){return r||=0,i||=0,{value:a0(I(e,this.locale),I(t,this.locale),I(n,this.locale),I(r,this.locale),+!!R(i)),format:`#,##0.00`}},isExported:!0},s0={description:N(`Future value of principal from series of rates.`),args:[H(`principal (number)`,N(`The amount of initial capital or value to compound against.`)),H(`rate_schedule (number, range<number>)`,N(`A series of interest rates to compound against the principal.`))],compute:function(e,t){let n=I(e,this.locale);return{value:is([t],(e,t)=>e*(1+I(t,this.locale)),n)}},isExported:!0},c0={description:N(`Calculates effective interest rate.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`investment (number)`,N(`The amount invested in the security.`)),H(`redemption (number)`,N(`The amount to be received at maturity.`)),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i={value:0}){let a=Math.trunc(I(e,this.locale)),o=Math.trunc(I(t,this.locale)),s=I(r,this.locale),c=I(n,this.locale),l=Math.trunc(I(i,this.locale));if(a>=o)return new F(p$(a,o));if(c<=0)return new F(c$(c));if(s<=0)return new F(j$(s));if(H$(l))return new F(XQ(l));let u=eo(a,o,l);return{value:(s-c)/c/u}},isExported:!0};function l0(e,t,n,r,i,a){return x0(e,n,r,i,a)-C0(e,t,n,r,i,a)}let u0={description:N(`Payment on the principal of an investment.`),args:[H(`rate (number)`,N(`The annualized rate of interest.`)),H(`period (number)`,N(`The amortization period, in terms of number of periods.`)),H(`number_of_periods (number)`,N(`The number of payments to be made.`)),H(`present_value (number)`,N(`The current value of the annuity.`)),H(`future_value (number, default=0)`,N(`The future value remaining after the final payment has been made.`)),H(`end_or_beginning (number, default=0)`,N(`The timing of the payment payments are due for each period.`),R1)],compute:function(e,t,n,r,i={value:0},a={value:0}){return{value:l0(I(e,this.locale),I(t,this.locale),I(n,this.locale),I(r,this.locale),I(i,this.locale),+!!R(a)),format:`#,##0.00`}},isExported:!0},d0=.1,f0={description:N(`Internal rate of return given periodic cashflows.`),args:[H(`cashflow_amounts (number, range<number>)`,N(`An array or range containing the income or payments associated with the investment.`)),H(`rate_guess (number, default=${d0})`,N(`An estimate for what the internal rate of return will be.`))],compute:function(e,t={value:d0}){let n=I(t,this.locale);if(n<=-1)return new F(O$(n));let r=!1,i=!1,a=[];if(ns([e],({value:e})=>{e>0&&(r=!0),e<0&&(i=!0),a.push(e)},this.locale),!r||!i)return new F(KQ);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:B1(l,u,n+1,20,1e-5)-1,format:`0%`}},isExported:!0},p0={description:N(`Returns the interest paid at a particular period of an investment.`),args:[H(`rate (number)`,N(`The interest rate.`)),H(`period (number)`,N(`The period for which you want to view the interest payment.`)),H(`number_of_periods (number)`,N(`The number of payments to be made.`)),H(`present_value (number)`,N(`The current value of the annuity.`))],compute:function(e,t,n,r){let i=I(e,this.locale),a=I(t,this.locale),o=I(n,this.locale),s=I(r,this.locale);return o===0?new F(g$(o)):{value:-1*(s-a/o*s)*i}},isExported:!0},m0={description:N(`Modified Macaulay duration.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`rate (number)`,N(`The annualized rate of interest.`)),H(`yield (number)`,N(`The expected annual yield of the security.`)),H(`frequency (number)`,N(`The number of interest or coupon payments per year (1, 2, or 4).`),L1),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`))],compute:function(e,t,n,r,i,a={value:0}){let o=r0.compute.bind(this)(e,t,n,r,i,a),s=I(r,this.locale),c=Math.trunc(I(i,this.locale));return{value:I(o,this.locale)/(1+s/c)}},isExported:!0},h0={description:N(`Modified internal rate of return.`),args:[H(`cashflow_amounts (range<number>)`,N(`A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.`)),H(`financing_rate (number)`,N(`The interest rate paid on funds invested.`)),H(`reinvestment_return_rate (number)`,N(`The return (as a percentage) earned on reinvestment of income received from the investment.`))],compute:function(e,t,n){let r=I(t,this.locale),i=I(n,this.locale),a=us(e).flat().filter(e=>e.value!==null).map(e=>I(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 F(KQ);let l=1/(o-1);return{value:(-s/c)**l-1}},isExported:!0},g0={description:N(`Annual nominal interest rate.`),args:[H(`effective_rate (number)`,N(`The effective interest rate per year.`)),H(`periods_per_year (number)`,N(`The number of compounding periods per year.`))],compute:function(e,t){let n=I(e,this.locale),r=Math.trunc(I(t,this.locale));return n<=0?new F(t$(n)):r<=0?new F(x$(r)):{value:((n+1)**(1/r)-1)*r}},isExported:!0},_0={description:N(`Number of payment periods for an investment.`),args:[H(`rate (number)`,N(`The interest rate.`)),H(`payment_amount (number)`,N(`The amount of each payment made.`)),H(`present_value (number)`,N(`The current value of the annuity.`)),H(`future_value (number, default=0)`,N(`The future value remaining after the final payment has been made.`)),H(`end_or_beginning (number, default=0)`,N(`The timing of the payment payments are due for each period.`),R1)],compute:function(e,t,n,r={value:0},i={value:0}){r||=0,i||=0;let a=I(e,this.locale),o=I(t,this.locale),s=I(n,this.locale),c=I(r,this.locale),l=+!!R(i);if(a===0)return{value:-(c+s)/o};let u=o*(1+a*l)/a;return{value:Math.log((u-c)/(s+u))/Math.log(1+a)}},isExported:!0};function v0(e,t,n,r){let i=0;return as(n,(t,n)=>(i++,t+n/(1+e)**i),t,r)}let y0={description:N(`The net present value of an investment based on a series of periodic cash flows and a discount rate.`),args:[H(`discount (number)`,N(`The discount rate of the investment over one period.`)),H(`cashflow (number, range<number>, repeating)`,N(`The future cash flows.`))],compute:function(e,...t){let n=I(e,this.locale);return n===-1?new F(QQ(n)):{value:v0(n,0,t,this.locale),format:`#,##0.00`}},isExported:!0},b0={description:N(`Computes the number of periods needed for an investment to reach a value.`),args:[H(`rate (number)`,N(`The rate at which the investment grows each period.`)),H(`present_value (number)`,N(`The investment's current value.`)),H(`future_value (number)`,N(`The investment's desired future value.`))],compute:function(e,t,n){let r=I(e,this.locale),i=I(t,this.locale),a=I(n,this.locale);return r<=0?new F(A$(r)):i<=0?new F(w$(i)):a<=0?new F(s$(a)):{value:(Math.log(a)-Math.log(i))/Math.log(1+r)}},isExported:!0};function x0(e,t,n,r,i){if(t<=0)throw new F(_$(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 S0={description:N(`Periodic payment for an annuity investment.`),args:[H(`rate (number)`,N(`The annualized rate of interest.`)),H(`number_of_periods (number)`,N(`The number of payments to be made.`)),H(`present_value (number)`,N(`The current value of the annuity.`)),H(`future_value (number, default=0)`,N(`The future value remaining after the final payment has been made.`)),H(`end_or_beginning (number, default=0)`,N(`The timing of the payment payments are due for each period.`),R1)],compute:function(e,t,n,r={value:0},i={value:0}){let a=I(t,this.locale),o=I(e,this.locale),s=+!!R(i),c=I(r,this.locale);return{value:x0(o,a,I(n,this.locale),c,s),format:`#,##0.00`}},isExported:!0};function C0(e,t,n,r,i,a){if(n<=0)throw new F(_$(n));if(t<=0||t>n)throw new F(v$(n));let o=x0(e,n,r,i,a);return a===1&&t===1?o:o+-a0(e,a===0?t-1:t-2,o,r+o*a,0)*e}let w0={description:N(`Payment on the principal of an investment.`),args:[H(`rate (number)`,N(`The annualized rate of interest.`)),H(`period (number)`,N(`The amortization period, in terms of number of periods.`)),H(`number_of_periods (number)`,N(`The number of payments to be made.`)),H(`present_value (number)`,N(`The current value of the annuity.`)),H(`future_value (number, default=0)`,N(`The future value remaining after the final payment has been made.`)),H(`end_or_beginning (number, default=0)`,N(`The timing of the payment payments are due for each period.`),R1)],compute:function(e,t,n,r,i={value:0},a={value:0}){let o=I(n,this.locale),s=I(e,this.locale),c=I(t,this.locale),l=+!!R(a),u=I(i,this.locale);return{value:C0(s,c,o,I(r,this.locale),u,l),format:`#,##0.00`}},isExported:!0},T0={description:N(`Present value of an annuity investment.`),args:[H(`rate (number)`,N(`The interest rate.`)),H(`number_of_periods (number)`,N(`The number of payments to be made.`)),H(`payment_amount (number)`,N(`The amount per period to be paid.`)),H(`future_value (number, default=0)`,N(`The future value remaining after the final payment has been made.`)),H(`end_or_beginning (number, default=0)`,N(`The timing of the payment payments are due for each period.`),R1)],compute:function(e,t,n,r={value:0},i={value:0}){r||=0,i||=0;let a=I(e,this.locale),o=I(t,this.locale),s=I(n,this.locale),c=I(r,this.locale),l=+!!R(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},E0={description:N(`Price of a security paying periodic interest.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`rate (number)`,N(`The annualized rate of interest.`)),H(`yield (number)`,N(`The expected annual yield of the security.`)),H(`redemption (number)`,N(`The redemption amount per 100 face value, or par.`)),H(`frequency (number)`,N(`The number of interest or coupon payments per year (1, 2, or 4).`),L1),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=Math.trunc(I(e,this.locale)),c=Math.trunc(I(t,this.locale)),l=I(n,this.locale),u=I(r,this.locale),d=I(i,this.locale),f=Math.trunc(I(a,this.locale)),p=Math.trunc(I(o,this.locale));if(s>=c)return new F(p$(s,c));if(U$(f))return new F(YQ(f));if(H$(p))return new F(XQ(p));if(l<0)return new F(k$(l));if(u<0)return new F(B$(u));if(d<=0)return new F(j$(d));let m=eo(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{value:(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{value:d/_**(h-1+g)+ee-v*(1-g)}},isExported:!0},D0={description:N(`Price of a discount security.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`discount (number)`,N(`The discount rate of the security at time of purchase.`)),H(`redemption (number)`,N(`The redemption amount per 100 face value, or par.`)),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(I(e,this.locale)),o=Math.trunc(I(t,this.locale)),s=I(n,this.locale),c=I(r,this.locale),l=Math.trunc(I(i,this.locale));if(a>=o)return new F(p$(a,o));if(H$(l))return new F(XQ(l));if(s<=0)return new F($Q(s));if(c<=0)return new F(j$(c));let u=eo(a,o,l);return{value:c-s*c*u}},isExported:!0},O0={description:N(`Calculates the price of a security paying interest at maturity, based on expected yield.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`issue (date)`,N(`The date the security was initially issued.`)),H(`rate (number)`,N(`The annualized rate of interest.`)),H(`yield (number)`,N(`The expected annual yield of the security.`)),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i,a={value:0}){a||=0;let o=Math.trunc(I(e,this.locale)),s=Math.trunc(I(t,this.locale)),c=Math.trunc(I(n,this.locale)),l=I(r,this.locale),u=I(i,this.locale),d=Math.trunc(I(a,this.locale));if(o<=c)return new F(I$(o,c));if(o>=s)return new F(p$(o,s));if(H$(d))return new F(XQ(d));if(l<0)return new F(k$(l));if(u<0)return new F(B$(u));let f=eo(o,s,d),p=eo(o,c,d),m=100+eo(c,s,d)*l*100,h=1+f*u,g=p*l*100;return{value:m/h-g}},isExported:!0},k0=.1,A0={description:N(`Interest rate of an annuity investment.`),args:[H(`number_of_periods (number)`,N(`The number of payments to be made.`)),H(`payment_per_period (number)`,N(`The amount per period to be paid.`)),H(`present_value (number)`,N(`The current value of the annuity.`)),H(`future_value (number, default=0)`,N(`The future value remaining after the final payment has been made.`)),H(`end_or_beginning (number, default=0)`,N(`The timing of the payment payments are due for each period.`),R1),H(`rate_guess (number, default=${k0})`,N(`An estimate for what the interest rate will be.`))],compute:function(e,t,n,r={value:0},i={value:0},a={value:k0}){let o=I(e,this.locale),s=I(t,this.locale),c=+!!R(i),l=I(a,this.locale)||k0,u=I(r,this.locale),d=I(n,this.locale);return o<=0?new F(_$(o)):V$([s,d,u])?l<=-1?new F(O$(l)):(u-=s*c,d+=s*c,{value:B1(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 F(N(`There must be both positive and negative values in [payment_amount, present_value, future_value].`))},isExported:!0},j0={description:N(`Amount received at maturity for a security.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`investment (number)`,N(`The amount invested (irrespective of face value of each security).`)),H(`discount (number)`,N(`The discount rate of the security invested in.`)),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(I(e,this.locale)),o=Math.trunc(I(t,this.locale)),s=I(n,this.locale),c=I(r,this.locale),l=Math.trunc(I(i,this.locale));return a>=o?new F(p$(a,o)):H$(l)?new F(XQ(l)):s<=0?new F(c$(s)):c<=0?new F($Q(c)):{value:s/(1-c*eo(a,o,l))}},isExported:!0},M0={description:N(`Computes the rate needed for an investment to reach a specific value within a specific number of periods.`),args:[H(`number_of_periods (number)`,N(`The number of periods.`)),H(`present_value (number)`,N(`The present value of the investment.`)),H(`future_value (number)`,N(`The future value of the investment.`))],compute:function(e,t,n){let r=I(e,this.locale),i=I(t,this.locale),a=I(n,this.locale);return r<=0?new F(_$(r)):{value:(a/i)**(1/r)-1}},isExported:!0},N0={description:N(`Depreciation of an asset using the straight-line method.`),args:[H(`cost (number)`,N(`The initial cost of the asset.`)),H(`salvage (number)`,N(`The value of the asset at the end of depreciation.`)),H(`life (number)`,N(`The number of periods over which the asset is depreciated.`))],compute:function(e,t,n){let r=I(e,this.locale),i=I(t,this.locale),a=I(n,this.locale);return{value:(r-i)/a,format:`#,##0.00`}},isExported:!0},P0={description:N(`Depreciation via sum of years digit method.`),args:[H(`cost (number)`,N(`The initial cost of the asset.`)),H(`salvage (number)`,N(`The value of the asset at the end of depreciation.`)),H(`life (number)`,N(`The number of periods over which the asset is depreciated.`)),H(`period (number)`,N(`The single period within life for which to calculate depreciation.`))],compute:function(e,t,n,r){let i=I(e,this.locale),a=I(t,this.locale),o=I(n,this.locale),s=I(r,this.locale);if(s<=0)return new F(C$(s));if(o<=0)return new F(f$(o));if(s>o)return new F(S$(s,o));let c=o*(o+1)/2,l=o-s+1;return{value:(i-a)*(l/c),format:`#,##0.00`}},isExported:!0};function F0(e,t,n){return 100*(1-n*eo(e,t,2))}let I0={description:N(`Price of a US Treasury bill.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`discount (number)`,N(`The discount rate of the bill at time of purchase.`))],compute:function(e,t,n){let r=Math.trunc(I(e,this.locale)),i=Math.trunc(I(t,this.locale)),a=I(n,this.locale);return r>=i?new F(p$(r,i)):W$(r,i,this.locale)?a<=0?new F($Q(a)):a>=1?new F(e$(a)):{value:F0(r,i,a)}:new F(F$(r,i))},isExported:!0},L0={description:N(`Equivalent rate of return for a US Treasury bill.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`discount (number)`,N(`The discount rate of the bill at time of purchase.`))],compute:function(e,t,n){let r=Math.trunc(I(e,this.locale)),i=Math.trunc(I(t,this.locale)),a=I(n,this.locale);if(r>=i)return new F(p$(r,i));if(!W$(r,i,this.locale))return new F(F$(r,i));if(a<=0)return new F($Q(a));if(a>=1)return new F(e$(a));let o=Q$.compute.bind(this)({value:i},{value:r}).value;if(o<=182)return{value:365*a/(360-a*o)};let s=F0(r,i,a)/100,c=o/(o===366?366:365);return{value:(-2*c+2*Math.sqrt(c**2-(2*c-1)*(1-1/s)))/(2*c-1)}},isExported:!0},R0={description:N(`The yield of a US Treasury bill based on price.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`price (number)`,N(`The price at which the security is bought per 100 face value.`))],compute:function(e,t,n){let r=Math.trunc(I(e,this.locale)),i=Math.trunc(I(t,this.locale)),a=I(n,this.locale);if(r>=i)return new F(p$(r,i));if(!W$(r,i,this.locale))return new F(F$(r,i));if(a<=0)return new F(T$(a));let o=eo(r,i,2);return{value:(100-a)/a*(1/o)}},isExported:!0},z0={description:N(`Variable declining balance. WARNING : does not handle decimal periods.`),args:[H(`cost (number)`,N(`The initial cost of the asset.`)),H(`salvage (number)`,N(`The value of the asset at the end of depreciation.`)),H(`life (number)`,N(`The number of periods over which the asset is depreciated.`)),H(`start (number)`,N(`Starting period to calculate depreciation.`)),H(`end (number)`,N(`Ending period to calculate depreciation.`)),H(`factor (number, default=2)`,N(`The number of months in the first year of depreciation.`)),H(`no_switch (number, default=false)`,N(`Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation.`),[{value:!1,label:N(`Switch to straight-line depreciation`)},{value:!0,label:N(`Do not switch to straight-line depreciation`)}])],compute:function(e,t,n,r,i,a={value:2},o={value:!1}){a||=0;let s=I(e,this.locale),c=I(t,this.locale),l=I(n,this.locale),u=Math.trunc(I(r,this.locale)),d=Math.trunc(I(i,this.locale)),f=I(a,this.locale),p=R(o);if(s<0)return new F(qQ(s));if(c<0)return new F(M$(c));if(l<=0)return new F(f$(l));if(u<0)return new F(L$(u));if(d<0)return new F(n$(d));if(u>d)return new F(R$(u,d));if(d>l)return new F(r$(d,l));if(f<=0)return new F(ZQ(f));if(s===0)return{value:0};if(c>=s)return{value:u<1?s-c:0};let m=f/l;if(m>=1)return{value: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{value:_}},isExported:!0},B0={description:N(`Internal rate of return given non-periodic cash flows.`),args:[H(`cashflow_amounts (range<number>)`,N(`An range containing the income or payments associated with the investment.`)),H(`cashflow_dates (range<number>)`,N(`An range with dates corresponding to the cash flows in cashflow_amounts.`)),H(`rate_guess (number, default=${k0})`,N(`An estimate for what the internal rate of return will be.`))],compute:function(e,t,n={value:k0}){let r=I(n,this.locale);if(!dS(e,t))return new F(GQ);let i=e.flat().map(e=>I(e,this.locale)),a=t.flat().map(e=>I(e,this.locale));if(!V$(i))return new F(KQ);if(a.some(e=>e<a[0]))return new F(i$(a[0]));if(r<=-1)return new F(O$(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{value:B1(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},V0={description:N(`Net present value given to non-periodic cash flows..`),args:[H(`discount (number)`,N(`The discount rate of the investment over one period.`)),H(`cashflow_amounts (number, range<number>)`,N(`An range containing the income or payments associated with the investment.`)),H(`cashflow_dates (number, range<number>)`,N(`An range with dates corresponding to the cash flows in cashflow_amounts.`))],compute:function(e,t,n){let r=I(e,this.locale);if(!dS(t,n))return new F(GQ);let i=z(t).flat().map(e=>Go(e,this.locale)),a=z(n).flat().map(e=>Go(e,this.locale));if(a.some(e=>e<a[0]))return new F(i$(a[0]));if(r<=0)return new F(A$(r));if(i.length===1)return{value: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{value:l}},isExported:!0},H0={description:N(`Annual yield of a security paying periodic interest.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`rate (number)`,N(`The annualized rate of interest.`)),H(`price (number)`,N(`The price at which the security is bought per 100 face value.`)),H(`redemption (number)`,N(`The redemption amount per 100 face value, or par.`)),H(`frequency (number)`,N(`The number of interest or coupon payments per year (1, 2, or 4).`),L1),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=Math.trunc(I(e,this.locale)),c=Math.trunc(I(t,this.locale)),l=I(n,this.locale),u=I(r,this.locale),d=I(i,this.locale),f=Math.trunc(I(a,this.locale)),p=Math.trunc(I(o,this.locale));if(s>=c)return new F(p$(s,c));if(U$(f))return new F(YQ(f));if(H$(p))return new F(XQ(p));if(l<0)return new F(k$(l));if(u<=0)return new F(T$(u));if(d<=0)return new F(j$(d));let m=eo(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{value:(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{value:(B1(y,b,1+(l+1)/f,100,1e-5)-1)*f}},isExported:!0},U0={description:N(`Annual yield of a discount security.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`price (number)`,N(`The price at which the security is bought per 100 face value.`)),H(`redemption (number)`,N(`The redemption amount per 100 face value, or par.`)),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(I(e,this.locale)),o=Math.trunc(I(t,this.locale)),s=I(n,this.locale),c=I(r,this.locale),l=Math.trunc(I(i,this.locale));if(a>=o)return new F(p$(a,o));if(H$(l))return new F(XQ(l));if(s<=0)return new F(T$(s));if(c<=0)return new F(j$(c));let u=eo(a,o,l);return{value:(c/s-1)/u}},isExported:!0},W0={description:N(`Annual yield of a security paying interest at maturity.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`issue (date)`,N(`The date the security was initially issued.`)),H(`rate (number)`,N(`The annualized rate of interest.`)),H(`price (number)`,N(`The price at which the security is bought.`)),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i,a={value:0}){a||=0;let o=Math.trunc(I(e,this.locale)),s=Math.trunc(I(t,this.locale)),c=Math.trunc(I(n,this.locale)),l=I(r,this.locale),u=I(i,this.locale),d=Math.trunc(I(a,this.locale));if(o>=s)return new F(p$(o,s));if(H$(d))return new F(XQ(d));if(o<c)return new F(P$(o,c));if(l<0)return new F(k$(l));if(u<=0)return new F(T$(u));let f=eo(c,s,d),p=eo(c,o,d),m=eo(o,s,d);return{value:(100*(1+l*f)/(u+100*l*p)-1)/m}},isExported:!0};var G0=l({CELL:()=>q0,ISBLANK:()=>t2,ISERR:()=>J0,ISERROR:()=>Y0,ISFORMULA:()=>r2,ISLOGICAL:()=>X0,ISNA:()=>Z0,ISNONTEXT:()=>Q0,ISNUMBER:()=>$0,ISTEXT:()=>e2,NA:()=>n2});let K0=[{value:`address`,label:N(`Returns an absolute reference as plain text of the top left cell in reference.`)},{value:`col`,label:N(`Returns the column number of the cell in reference.`)},{value:`contents`,label:N(`Returns the value contained in the top left cell in reference.`)},{value:`format`,label:N(`Returns the format of the top left cell in reference.`)},{value:`row`,label:N(`Returns the row number of the top left cell in reference.`)},{value:`type`,label:N(`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.`)}],q0={description:N(`Gets information about a cell.`),args:[H(`info_type (string)`,N(`The type of information requested.`),K0),H(`reference (any, range<any>)`,N(`The reference to the cell.`))],compute:function(e,t){let n=L(e).toLowerCase();if(!K0.map(e=>e.value).includes(n))return new F(N(`The info_type should be one of %s.`,K0.join(`, `)));let r=z(t)[0][0],i=r.position;if(i===void 0)return new F(N(`The reference is invalid.`));switch(n){case`address`:return{value:(this.__originSheetId===i.sheetId?``:this.getters.getSheetName(i.sheetId)+`!`)+E(i.col,i.row,{colFixed:!0,rowFixed:!0})};case`col`:return{value:i.col+1};case`contents`:return{value:r.value};case`format`:return{value:r.format||``};case`row`:return{value:i.row+1};case`type`:return r.value===null?{value:`b`}:Bc(r.format)?{value:`l`}:typeof r.value==`number`||typeof r.value==`boolean`?{value:`v`}:{value:`l`}}return{value:``}},isExported:!0},J0={description:N(`Whether a value is an error other than #N/A.`),args:[H(`value (any)`,N(`The value to be verified as an error type.`))],compute:function(e){let t=e?.value;return{value:Lo(t)&&t!==P.NotAvailable}},isExported:!0},Y0={description:N(`Whether a value is an error.`),args:[H(`value (any)`,N(`The value to be verified as an error type.`))],compute:function(e){let t=e?.value;return{value:Lo(t)}},isExported:!0},X0={description:N("Whether a value is `true` or `false`."),args:[H(`value (any)`,N(`The value to be verified as a logical TRUE or FALSE.`))],compute:function(e){return{value:typeof e?.value==`boolean`}},isExported:!0},Z0={description:N(`Whether a value is the error #N/A.`),args:[H(`value (any)`,N(`The value to be verified as an error type.`))],compute:function(e){return{value:e?.value===P.NotAvailable}},isExported:!0},Q0={description:N(`Whether a value is non-textual.`),args:[H(`value (any)`,N(`The value to be checked.`))],compute:function(e){return{value:!e2.compute.bind(this)(e).value}},isExported:!0},$0={description:N(`Whether a value is a number.`),args:[H(`value (any)`,N(`The value to be verified as a number.`))],compute:function(e){return{value:typeof e?.value==`number`}},isExported:!0},e2={description:N(`Whether a value is text.`),args:[H(`value (any)`,N(`The value to be verified as text.`))],compute:function(e){return{value:typeof e?.value==`string`&&Lo(e?.value)===!1}},isExported:!0},t2={description:N(`Whether the referenced cell is empty`),args:[H(`value (any)`,N(`Reference to the cell that will be checked for emptiness.`))],compute:function(e){return{value:e?.value===null}},isExported:!0},n2={description:N(`Returns the error value #N/A.`),args:[],compute:function(){return{value:P.NotAvailable}},isExported:!0},r2={description:N(`Checks whether there is a reference to a cell that contains a formula, and returns TRUE or FALSE.`),args:[H(`cell_reference (any)`,N(`A reference to a cell.`))],compute:function(e){return e?.position===void 0?new ko(Bo):{value:this.getters.getCell(e.position)?.isFormula??!1}},isExported:!0};var i2=l({AND:()=>a2,FALSE:()=>o2,IF:()=>s2,IFERROR:()=>c2,IFNA:()=>l2,IFS:()=>u2,NOT:()=>d2,OR:()=>f2,SWITCH:()=>p2,TRUE:()=>m2,XOR:()=>h2});let a2={description:N("Logical `and` operator."),args:[H(`logical_expression (boolean, range<boolean>, repeating)`,N(`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}=iS(e);return n?{value:t}:new F(ws)},isExported:!0},o2={description:N("Logical value `false`."),args:[],compute:function(){return{value:!1}},isExported:!0},s2={description:N(`Returns value depending on logical expression.`),args:[H(`logical_expression (boolean, range<boolean>)`,N(`An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.`)),H(`value_if_true (any, range)`,N(`The value the function returns if logical_expression is TRUE.`)),H(`value_if_false (any, range, default=FALSE)`,N(`The value the function returns if logical_expression is FALSE.`))],computeArray:function(e,t,n){if(mg(e)){let r=ul.get(`IF`);return $c(this,r,[e,t,n],tl(r,3),hg([e,t,n]))}return(R(fg(e))?t:n)??{value:0}},isExported:!0},c2={description:N(`Value if it is not an error, otherwise 2nd argument.`),args:[H(`value (any, range)`,N(`The value to return if value itself is not an error.`)),H(`value_if_error (any, range, default="empty")`,N(`The value the function returns if value is an error.`))],computeArray:function(e,t){if(mg(e)){let n=ul.get(`IFERROR`);return $c(this,n,[e,t],tl(n,2),hg([e,t]))}return(Lo(fg(e)?.value)?t:e)??{value:0}},isExported:!0},l2={description:N(`Value if it is not an #N/A error, otherwise 2nd argument.`),args:[H(`value (any, range)`,N(`The value to return if value itself is not #N/A an error.`)),H(`value_if_error (any, range, default="empty")`,N(`The value the function returns if value is an #N/A error.`))],computeArray:function(e,t){if(mg(e)){let n=ul.get(`IFNA`);return $c(this,n,[e,t],tl(n,2),hg([e,t]))}return(fg(e)?.value===P.NotAvailable?t:e)??{value:0}},isExported:!0},u2={description:N(`Returns a value depending on multiple logical expressions.`),args:[H(`condition (any, range, repeating)`,N(`The condition to be evaluated. It can be a boolean, a number, an array, or a reference to any of those.`)),H(`value (any, range, repeating)`,N(`The value to be returned if its corresponding condition is TRUE.`))],computeArray:function(...e){if(e.length%2!=0)return new F(N(`Wrong number of arguments. Expected an even number of arguments.`));for(;e.length>0;){if(mg(e[0])){let t=ul.get(`IFS`);return $c(this,t,e,tl(t,e.length),hg(e))}let t=R(fg(e.shift())),n=e.shift();if(t)return n??{value:0}}return new F(N(`No match.`))},isExported:!0},d2={description:N(`Returns opposite of provided logical value.`),args:[H(`logical_expression (boolean)`,N(`An expression or reference to a cell holding an expression that represents some logical value.`))],compute:function(e){return{value:!R(e)}},isExported:!0},f2={description:N("Logical `or` operator."),args:[H(`logical_expression (boolean, range<boolean>, repeating)`,N(`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}=aS(e);return n?{value:t}:new F(ws)},isExported:!0},p2={description:N(`Returns a value by comparing cases to an expression.`),args:[H(`expression (number, boolean, string)`,N(`The value to be checked.`)),H(`case (any, repeating)`,N(`Case to be checked against expression.`)),H(`value (any, repeating)`,N(`Value to be returned if its corresponding case matches expression.`)),H(`default (any, default="empty")`,N(`An optional default value to be returned if none of the cases match expression.`))],compute:function(e,...t){let n=t.length%2==0?Ro(e):t.pop();for(let n=0;n<t.length;n+=2){let r=t[n];if(r&&Lo(r.value))return r;if(e?.value===r?.value)return t[n+1]||{value:0}}return n||{value:0}},isExported:!0},m2={description:N("Logical value `true`."),args:[],compute:function(){return{value:!0}},isExported:!0},h2={description:N("Logical `xor` operator."),args:[H(`logical_expression (boolean, range<boolean>, repeating)`,N(`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 fs(e,e=>(t=!0,n=n?!e:e,!0)),t?{value:n}:new F(ws)},isExported:!0};function g2(e,t){let n=t.getPivotId(e);if(!n)throw new F(N(`There is no pivot with id "%s"`,e));return n}function _2(e,t,n){let{measures:r}=n.getPivotCoreDefinition(e);if(!r.find(e=>e.id===t))throw new F(N(`The argument %s is not a valid measure. Here are the measures: %s`,t,`(${r.map(e=>e.id).join(`, `)})`))}function v2(e){if(e.length%2!=0)throw new F(N(`Function PIVOT takes an even number of arguments.`))}function y2(e,t,n){let r=[],i=e.getters.getPivotCoreDefinition(t);if(i.type===`SPREADSHEET`&&i.dataSet){let{sheetId:t,zone:n}=i.dataSet,a=or(n),o=e.getters.getRangeFromSheetXC(t,a);if(o===void 0||o.invalidXc||o.invalidSheetName)throw new ko;if(e.__originCellPosition&&o.sheetId===e.__originSheetId&&vr(D(e.__originCellPosition),n))throw new Oo;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 b2=l({ADDRESS:()=>C2,CHOOSE:()=>B2,COLUMN:()=>w2,COLUMNS:()=>T2,DROP:()=>V2,FORMULATEXT:()=>U2,HLOOKUP:()=>E2,INDEX:()=>D2,INDIRECT:()=>O2,LOOKUP:()=>k2,MATCH:()=>A2,OFFSET:()=>z2,PIVOT:()=>R2,PIVOT_HEADER:()=>L2,PIVOT_VALUE:()=>I2,ROW:()=>j2,ROWS:()=>M2,TAKE:()=>H2,VLOOKUP:()=>N2,XLOOKUP:()=>F2});let x2=[{value:!0,label:N(`A1 style (default)`)},{value:!1,label:N(`R1C1 style`)}],S2=[{value:!0,label:N(`Approximate match (default)`)},{value:!1,label:N(`Exact match`)}],C2={description:N(`Returns a cell reference as a string. `),args:[H(`row (number)`,N(`The row number of the cell reference. `)),H(`column (number)`,N(`The column number (not name) of the cell reference. A is column number 1. `)),H(`absolute_relative_mode (number, default=1)`,N(`An indicator of whether the reference is row/column absolute.`),[{value:1,label:N(`Absolute row and column (e.g. $A$1)`)},{value:2,label:N(`Absolute row, relative column (e.g. A$1)`)},{value:3,label:N(`Relative row, absolute column (e.g. $A1)`)},{value:4,label:N(`Relative row and column (e.g. A1)`)}]),H(`use_a1_notation (boolean, default=TRUE)`,N(`A boolean indicating whether to use A1 style notation or R1C1 style notation.`),x2),H(`sheet (string, optional)`,N(`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=qo(e,this.locale),o=qo(t,this.locale);if(a<1)return new F(pS(a));if(o<1)return new F(pS(o));let s=qo(n,this.locale);if(![1,2,3,4].includes(s))return new F(Vo(1,4,s));let c=R(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?{value:l}:{value:Tl(L(i),l)}},isExported:!0},w2={description:N(`Column number of a specified cell.`),args:[H(`cell_reference (any, range<any>, default='this cell')`,N(`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.`))],computeArray:function(e){if(e===void 0)return this.__originCellPosition===void 0?new F(N(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):{value:this.__originCellPosition.col+1};let t=z(e),n=t[0][0];if(n===void 0)return new F(N(`The range is out of bounds.`));if(n.position===void 0)return new ko(Bo);let r=n.position.col;return t.length===1?{value:r+1}:ss(t.length,1,e=>({value:r+e+1}))},isExported:!0},T2={description:N(`Number of columns in a specified array or range.`),args:[H(`range (any, range<any>)`,N(`The range whose column count will be returned.`))],compute:function(e){let t=z(e);return t[0][0]===void 0?new F(N(`The range is out of bounds.`)):t[0][0].value===P.InvalidReference?t[0][0]:{value:t.length}},isExported:!0},E2={description:N(`Horizontal lookup`),args:[H(`search_key (string, number, boolean)`,N(`The value to search for. For example, 42, 'Cats', or I24.`)),H(`range (any, range)`,N(`The range to consider for the search. The first row in the range is searched for the key specified in search_key.`)),H(`index (number)`,N(`The row index of the value to be returned, where the first row in range is numbered 1.`)),H(`is_sorted (boolean, default=true)`,N(`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.`),S2)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(I(n?.value,this.locale)),a=z(t);if(1>i||i>a[0].length)return new F(N(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[t][0].value,s=a[R(r.value)?_s(a,e,`nextSmaller`,`asc`,a.length,o):vs(a,e,`wildcard`,a.length,o,this.lookupCaches)];return s===void 0?Ro(e):s[i-1]},isExported:!0},D2={description:N(`Returns the content of a cell, specified by row and column offset.`),args:[H(`reference (any, range)`,N(`The range of cells from which the values are returned.`)),H(`row (number, default=0)`,N(`The index of the row to be returned from within the reference range of cells.`)),H(`column (number, default=0)`,N(`The index of the column to be returned from within the reference range of cells.`))],computeArray:function(e,t={value:0},n={value:0}){let r=z(e),i=I(t.value,this.locale),a=I(n.value,this.locale);return a<0||a-1>=r.length||i<0||i-1>=r[0].length?new F(N(`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},O2={description:N(`Returns the content of a cell, specified by a string.`),args:[H(`reference (string)`,N(`The range of cells from which the values are returned.`)),H(`use_a1_notation (boolean, default=TRUE)`,N(`A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).`),x2)],computeArray:function(e,t={value:!0}){let n=e?.value?.toString();if(!n)return new ko(N(`Reference should be defined.`));if(!R(t))return new F(N(`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 ko;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},k2={description:N(`Look up a value.`),args:[H(`search_key (string, number, boolean)`,N(`The value to search for. For example, 42, 'Cats', or I24.`)),H(`search_array (any, range)`,N(`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.`)),H(`result_range (any, range, optional)`,N(`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=z(t),i=z(n),a=r.length,o=r[0].length,s=o>=a,c=_s(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?Ro(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 F(N(`The result_range must be a single row or a single column.`)):a>1?c>a-1?new F(N(`[[FUNCTION_NAME]] evaluates to an out of range row value %s.`,c+1)):i[c][0]:c>o-1?new F(N(`[[FUNCTION_NAME]] evaluates to an out of range column value %s.`,c+1)):i[0][c])},isExported:!0},A2={description:N(`Position of item in range that matches value.`),args:[H(`search_key (string, number, boolean)`,N(`The value to search for. For example, 42, 'Cats', or I24.`)),H(`range (any, range)`,N(`The one-dimensional array to be searched.`)),H(`search_type (number, default=1)`,N(`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:N(`Ascending order (default)`)},{value:0,label:N(`Exact match`)},{value:-1,label:N(`Descending order`)}])],compute:function(e,t,n={value:1}){let r=I(n,this.locale),i=z(t),a=i.length,o=i[0].length;if(a!==1&&o!==1)return new F(N(`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=_s(i,e,`nextSmaller`,`asc`,l,c);break;case 0:s=vs(i,e,`wildcard`,l,c,this.lookupCaches);break;case-1:s=_s(i,e,`nextGreater`,`desc`,l,c);break}return a===1&&i[0][s]===void 0||a!==1&&i[s]===void 0?Ro(e):{value:s+1}},isExported:!0},j2={description:N(`Row number of a specified cell.`),args:[H(`cell_reference (any, range<any>, default='this cell')`,N(`The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered.`))],computeArray:function(e){if(e===void 0)return this.__originCellPosition?.row===void 0?new F(N(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):{value:this.__originCellPosition.row+1};let t=z(e),n=t[0][0];if(n===void 0)return new F(N(`The range is out of bounds.`));if(n.position===void 0)return new ko(Bo);let r=n.position.row;return t[0].length===1?{value:r+1}:ss(1,t[0].length,(e,t)=>({value:r+t+1}))},isExported:!0},M2={description:N(`Number of rows in a specified array or range.`),args:[H(`range (any, range<any>)`,N(`The range whose row count will be returned.`))],compute:function(e){let t=z(e);return t[0][0]===void 0?new F(N(`The range is out of bounds.`)):t[0][0].value===P.InvalidReference?t[0][0]:{value:t[0].length}},isExported:!0},N2={description:N(`Vertical lookup.`),args:[H(`search_key (string, number, boolean)`,N(`The value to search for. For example, 42, 'Cats', or I24.`)),H(`range (any, range)`,N(`The range to consider for the search. The first column in the range is searched for the key specified in search_key.`)),H(`index (number)`,N(`The column index of the value to be returned, where the first column in range is numbered 1.`)),H(`is_sorted (boolean, default=true)`,N(`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.`),S2)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(I(n?.value,this.locale)),a=z(t);if(1>i||i>a.length)return new F(N(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[0][t].value,s=R(r.value)?_s(a,e,`nextSmaller`,`asc`,a[0].length,o):vs(a,e,`wildcard`,a[0].length,o,this.lookupCaches),c=a[i-1][s];return c===void 0?Ro(e):c},isExported:!0},P2={0:`strict`,1:`nextGreater`,"-1":`nextSmaller`,2:`wildcard`},F2={description:N(`Search a range for a match and return the corresponding item from a second range.`),args:[H(`search_key (string,number,boolean)`,N(`The value to search for.`)),H(`lookup_range (any, range)`,N(`The range to consider for the search. Should be a single column or a single row.`)),H(`return_range (any, range)`,N(`The range containing the return value. Should have the same dimensions as lookup_range.`)),H(`if_not_found (any, optional)`,N(`If a valid match is not found, return this value.`)),H(`match_mode (any, default=0)`,N(`Specifies how to match search_key with the items in lookup_range. `),[{value:0,label:N(`Exact match (default)`)},{value:-1,label:N(`Exact match or next smaller item`)},{value:1,label:N(`Exact match or next larger item`)},{value:2,label:N(`Wildcard character match`)}]),H(`search_mode (any, default=1)`,N(`Specifies the search mode to use. By default, a first to last search will be used.`),[{value:1,label:N(`Search first to last (default)`)},{value:-1,label:N(`Search last to first`)},{value:2,label:N(`Binary search (sorted ascending order)`)},{value:-2,label:N(`Binary search (sorted descending order)`)}])],computeArray:function(e,t,n,r,i={value:0},a={value:1}){let o=Math.trunc(I(i.value,this.locale)),s=Math.trunc(I(a.value,this.locale)),c=z(t),l=z(n);if(c.length!==1&&c[0].length!==1)return new F(N(`lookup_range should be either a single row or single column.`));if(![1,-1,2,-2].includes(s))return new F(N(`search_mode should be a value in [-1, 1, -2, 2].`));if(![-1,0,1,2].includes(o))return new F(N(`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 F(N(`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 F(N(`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=P2[o],m=s===-1,h=s===2||s===-2?_s(c,e,p,s===2?`asc`:`desc`,f,d):vs(c,e,p,f,d,this.lookupCaches,m);return h===-1?r===void 0?Ro(e):[[r]]:u===`col`?l.map(e=>[e[h]]):[l[h]]},isExported:!0},I2={description:N(`Get the value from a pivot.`),args:[H(`pivot_id (number,string)`,N(`ID of the pivot.`)),H(`measure_name (string)`,N(`Name of the measure.`)),H(`domain_field_name (string,repeating,optional)`,N(`Field name.`)),H(`domain_value (number,string,boolean,repeating,optional)`,N(`Value.`))],compute:function(e,t,...n){let r=L(e),i=L(t),a=g2(r,this.getters);_2(a,i,this.getters),v2(n);let o=this.getters.getPivot(a),s=this.getters.getPivotCoreDefinition(a);y2(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=N(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${r})`);return{value:P.GenericError,message:N(`Dimensions don't match the pivot definition`)+`. `+e}}let l=o.parseArgsToPivotDomain(n);return this.getters.getPivotPresenceTracker(a,this.__originSheetId)?.trackValue(i,l),o.getPivotCellValueAndFormat(i,l)}},L2={description:N(`Get the header of a pivot.`),args:[H(`pivot_id (number,string)`,N(`ID of the pivot.`)),H(`domain_field_name (string,repeating,optional)`,N(`Field name.`)),H(`domain_value (number,string,value,repeating,optional)`,N(`Value.`))],compute:function(e,...t){let n=L(e),r=g2(n,this.getters);v2(t);let i=this.getters.getPivot(r);y2(this,r,[]),i.init({reload:i.needsReevaluation});let a=i.assertIsValid({throwOnError:!1});if(a)return a;if(!i.areDomainArgsFieldsValid(t)){let e=N(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${n})`);return{value:P.GenericError,message:N(`Dimensions don't match the pivot definition`)+`. `+e}}let o=i.parseArgsToPivotDomain(t);this.getters.getPivotPresenceTracker(r,this.__originSheetId)?.trackHeader(o);let s=o.at(-1);if(s?.field===`measure`)return i.getPivotMeasureValue(L(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}}},R2={description:N(`Get a pivot table.`),args:[H(`pivot_id (string)`,N(`ID of the pivot.`)),H(`row_count (number, optional)`,N(`number of rows`)),H(`include_total (boolean, default=TRUE)`,N(`Whether to include total/sub-totals or not.`)),H(`include_column_titles (boolean, default=TRUE)`,N(`Whether to include the column titles or not.`)),H(`column_count (number, optional)`,N(`number of columns`)),H(`include_measure_titles (boolean, default=TRUE)`,N(`Whether to include the measure titles row or not.`))],computeArray:function(e,t,n,r,i,a){let o=g2(L(e),this.getters),s=this.getters.getPivot(o),c=this.getters.getPivotCoreDefinition(o),l=OC(c,t,n,r,i,a,this.locale);if(l.numberOfRows<0)return new F(N(`The number of rows must be positive.`));if(l.numberOfColumns<0)return new F(N(`The number of columns must be positive.`));y2(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 F(ST(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(yC(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}},z2={description:N(`Returns a range reference shifted by a specified number of rows and columns from a starting cell reference.`),args:[H(`cell_reference (any, range<any>)`,N(`The starting point from which to count the offset rows and columns.`)),H(`offset_rows (number)`,N(`The number of rows to offset by.`)),H(`offset_columns (number)`,N(`The number of columns to offset by.`)),H(`height (number, default='height of cell_reference')`,N(`The number of rows of the range to return starting at the offset target.`)),H(`width (number, default='width of cell_reference')`,N(`The number of columns of the range to return starting at the offset target.`))],computeArray:function(e,t,n,r,i){if(e===void 0)return new ko(Bo);let a=z(e),o=a[0][0];if(o===void 0)return new F(N(`The range is out of bounds.`));if(o.position===void 0)return new ko(Bo);let s=a[0].length,c=a.length;if(r){let e=I(r,this.locale);if(e<1)return new F(N(`Height value is %(_height)s. It should be greater than or equal to 1.`,{_height:e}));s=e}if(i){let e=I(i,this.locale);if(e<1)return new F(N(`Width value is %(_width)s. It should be greater than or equal to 1.`,{_width:e}));c=e}let l=I(t,this.locale),u=I(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 ko(N(`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 ko:(d&&this.addDependencies?.(d,[g]),ss(c,s,(e,t)=>this.getFormulaResult({sheetId:h,col:f+e,row:p+t})))}},B2={description:N(`Returns an element from a list of choices based on index.`),args:[H(`index (number)`,N(`Which choice to return.`)),H(`choice (any, range<any>, repeating)`,N(`A potential value to return. May be a reference to a cell or an individual value.`))],computeArray:function(e,...t){let n=Math.floor(I(e,this.locale))-1;return n<0||n>=t.length?new F(N(`Index for CHOOSE is invalid. Valid values are between 1 and %(choices)s inclusive.`,{choices:t.length})):t[n]??new F(N(`Choice is undefined.`))},isExported:!0},V2={description:N(`Excludes a specified number of rows or columns from the start or end of an array.`),args:[H(`array (range)`,N(`The array from which to drop rows or columns`)),H(`rows (number)`,N(`The number of rows to drop. A negative value drops from the end of the array.`)),H(`columns (number, optional)`,N(`The number of columns to exclude. A negative value drops from the end of the array.`))],computeArray:function(e,t,n){let r=I(t,this.locale),i=I(n,this.locale),a=e;if(Math.abs(i)>=e.length||Math.abs(r)>=e[0].length)return new F(N(`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},H2={description:N(`Returns a specified number of contiguous rows or columns from the start or end of an array.`),args:[H(`array (range)`,N(`The array from which to take rows or columns.`)),H(`rows (number)`,N(`The number of rows to take. A negative value takes from the end of the array.`)),H(`columns (number, optional)`,N(`The number of columns to take. A negative value takes from the end of the array.`))],computeArray:function(e,t,n){let r=t?I(t,this.locale):e[0].length,i=I(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 F(N(`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},U2={description:N(`Returns a formula as a string.`),args:[H(`cell_reference (any)`,N(`A reference to a cell.`))],compute:function(e){if(e?.position===void 0)return new ko(Bo);let t=this.getters.getCell(e.position);return t?.isFormula?{value:t.compiledFormula.toFormulaString(this.getters)}:new Ao(N(`The cell does not contain a formula.`))},isExported:!0};var W2=l({ADD:()=>G2,CONCAT:()=>K2,DIVIDE:()=>q2,EQ:()=>Z2,GT:()=>e4,GTE:()=>t4,LT:()=>n4,LTE:()=>r4,MINUS:()=>i4,MULTIPLY:()=>a4,NE:()=>o4,POW:()=>s4,SPILLED_RANGE:()=>c4,UMINUS:()=>l4,UNARY_PERCENT:()=>u4,UPLUS:()=>d4});let G2={description:N(`Sum of two numbers.`),args:[H(`value1 (number)`,N(`The first addend.`)),H(`value2 (number)`,N(`The second addend.`))],compute:function(e,t){return{value:I(e,this.locale)+I(t,this.locale),format:e?.format||t?.format}}},K2={description:N(`Concatenation of two values.`),args:[H(`value1 (string)`,N(`The value to which value2 will be appended.`)),H(`value2 (string)`,N(`The value to append to value1.`))],compute:function(e,t){return{value:Jo(e,this.locale)+Jo(t,this.locale)}},isExported:!0},q2={description:N(`One number divided by another.`),args:[H(`dividend (number)`,N(`The number to be divided.`)),H(`divisor (number)`,N(`The number to divide by.`))],compute:function(e,t){let n=I(t,this.locale);return n===0?new No(N(`The divisor must be different from zero.`)):{value:I(e,this.locale)/n,format:e?.format||t?.format}}};function J2(e){return e===void 0||e.value===null}let Y2={number:0,string:``,boolean:!1};function X2(e,t,n=2e-16){return Math.abs(e-t)<n}let Z2={description:N(`Equal.`),args:[H(`value1 (string, number, boolean)`,N(`The first value.`)),H(`value2 (string, number, boolean)`,N(`The value to test against value1 for equality.`))],compute:function(e,t){if(Lo(e?.value))return e;if(Lo(t?.value))return t;let n=J2(e)?Y2[typeof t?.value]:e?.value,r=J2(t)?Y2[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:X2(n,r)}:{value:n===r}}};function Q2(e,t,n){if(Lo(e?.value))return e;if(Lo(t?.value))return t;let r=J2(e)?Y2[typeof t?.value]??``:e?.value,i=J2(t)?Y2[typeof e?.value]??``:t?.value,a=$2[typeof r],o=$2[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 $2={number:0,string:1,boolean:2},e4={description:N(`Strictly greater than.`),args:[H(`value1 (number, string, boolean)`,N(`The value to test as being greater than value2.`)),H(`value2 (number, string, boolean)`,N(`The second value.`))],compute:function(e,t){return Q2(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?!X2(e,t)&&e>t:e>t)}},t4={description:N(`Greater than or equal to.`),args:[H(`value1 (number, string, boolean)`,N(`The value to test as being greater than or equal to value2.`)),H(`value2 (number, string, boolean)`,N(`The second value.`))],compute:function(e,t){return Q2(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?X2(e,t)||e>t:e>=t)}},n4={description:N(`Less than.`),args:[H(`value1 (number, string, boolean)`,N(`The value to test as being less than value2.`)),H(`value2 (number, string, boolean)`,N(`The second value.`))],compute:function(e,t){let n=t4.compute.bind(this)(e,t);return Lo(n.value)?n:{value:!n.value}}},r4={description:N(`Less than or equal to.`),args:[H(`value1 (number, string, boolean)`,N(`The value to test as being less than or equal to value2.`)),H(`value2 (number, string, boolean)`,N(`The second value.`))],compute:function(e,t){let n=e4.compute.bind(this)(e,t);return Lo(n.value)?n:{value:!n.value}}},i4={description:N(`Difference of two numbers.`),args:[H(`value1 (number)`,N(`The minuend, or number to be subtracted from.`)),H(`value2 (number)`,N(`The subtrahend, or number to subtract from value1.`))],compute:function(e,t){return{value:I(e,this.locale)-I(t,this.locale),format:e?.format||t?.format}}},a4={description:N(`Product of two numbers`),args:[H(`factor1 (number)`,N(`The first multiplicand.`)),H(`factor2 (number)`,N(`The second multiplicand.`))],compute:function(e,t){return{value:I(e,this.locale)*I(t,this.locale),format:e?.format||t?.format}}},o4={description:N(`Not equal.`),args:[H(`value1 (string, number, boolean)`,N(`The first value.`)),H(`value2 (string, number, boolean)`,N(`The value to test against value1 for inequality.`))],compute:function(e,t){let n=Z2.compute.bind(this)(e,t);return Lo(n.value)?n:{value:!n.value}}},s4={description:N(`A number raised to a power.`),args:[H(`base (number)`,N(`The number to raise to the exponent power.`)),H(`exponent (number)`,N(`The exponent to raise base to.`))],compute:function(e,t){return NX.compute.bind(this)(e,t)}},c4={description:N(`Gets the spilled range of an array formula.`),args:[H(`ref (any, range<any>)`,N(`The reference to get the spilled range from.`))],computeArray:function(e){if(e===void 0)return new ko(Bo);let t=z(e);if(t.length!==1||t[0].length!==1)return new F(N(`Only single-cell references are allowed to get the spilled range.`));let n=t[0][0];if(Lo(n.value))return n;if(n.position===void 0)return new ko(Bo);let r=this.__originCellPosition;r&&this.updateDependencies?.(r);let i=this.getters.getSpreadZone(n.position);if(i===void 0)return new ko;let a=this.getters.getRangeFromZone(this.__originSheetId,i);return r&&this.addDependencies?.(r,[a]),ss(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},l4={description:N(`A number with the sign reversed.`),args:[H(`value (number)`,N(`The number to have its sign reversed. Equivalently, the number to multiply by -1.`))],compute:function(e){return{value:-I(e,this.locale),format:e?.format}}},u4={description:N(`Value interpreted as a percentage.`),args:[H(`percentage (number)`,N(`The value to interpret as a percentage.`))],compute:function(e){return{value:I(e,this.locale)/100}}},d4={description:N(`A specified number, unchanged.`),args:[H(`value (any)`,N(`The number to return.`))],compute:function(e={value:null}){return e}},$=e=>({transform:t=>t*e,inverseTransform:t=>t/e}),f4={transform:e=>e,inverseTransform:e=>e},p4=1e-10,m4=.0254,h4=m4/72,g4=.3048,_4=.9144,v4=1609.34,y4=1852,b4=946073047258e4,x4={g:{...f4,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:{...f4,category:`distance`},km:{...$(1e3),category:`distance`},ang:{...$(p4),category:`distance`},Picapt:{...$(h4),category:`distance`},pica:{...$(m4/6),category:`distance`},in:{...$(m4),category:`distance`},ft:{...$(g4),category:`distance`},yd:{...$(_4),category:`distance`},ell:{...$(1.143),category:`distance`},mi:{...$(v4),category:`distance`},survey_mi:{...$(1609.34),category:`distance`},Nmi:{...$(y4),category:`distance`},ly:{...$(b4),category:`distance`},parsec:{...$(0x6da012f95c9fd0),category:`distance`},sec:{...f4,category:`time`},min:{...$(60),category:`time`},hr:{...$(3600),category:`time`},day:{...$(86400),category:`time`},yr:{...$(31556952),category:`time`},Pa:{...f4,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:{...f4,category:`force`},dyn:{...$(1e-5),category:`force`},pond:{...$(.00980665),category:`force`},lbf:{...$(4.44822),category:`force`},J:{...f4,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:{...f4,category:`power`},PS:{...$(735.499),category:`power`},HP:{...$(745.7),category:`power`},T:{...f4,category:`magnetism`},ga:{...$(1e-4),category:`magnetism`},K:{...f4,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":{...f4,category:`volume`,order:3},"ang^3":{...$(p4**3),category:`volume`,order:3},"Picapt^3":{...$(h4**3),category:`volume`,order:3},tsp:{...$(492892e-11),category:`volume`},tspm:{...$(5e-6),category:`volume`},tbs:{...$(14786764825785619e-21),category:`volume`},"in^3":{...$(m4**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":{...$(g4**3),category:`volume`,order:3},bushel:{...$(.0352390704),category:`volume`},barrel:{...$(.158987295),category:`volume`},"yd^3":{...$(_4**3),category:`volume`,order:3},MTON:{...$(1.13267386368),category:`volume`},GRT:{...$(2.83168),category:`volume`},"mi^3":{...$(v4**3),category:`volume`,order:3},"Nmi^3":{...$(y4**3),category:`volume`,order:3},"ly^3":{...$(b4**3),category:`volume`,order:3},"m^2":{...f4,category:`area`,order:2},"ang^2":{...$(p4**2),category:`area`,order:2},"Picapt^2":{...$(h4**2),category:`area`,order:2},"in^2":{...$(m4**2),category:`area`,order:2},"ft^2":{...$(g4**2),category:`area`,order:2},"yd^2":{...$(_4**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":{...$(v4**2),category:`area`,order:2},"Nmi^2":{...$(y4**2),category:`area`,order:2},"ly^2":{...$(b4**2),category:`area`,order:2},bit:{...f4,category:`information`},byte:{...$(8),category:`information`},"m/s":{...f4,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`}},S4={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`},C4={"":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},w4={weight:N(`Weight`),distance:N(`Distance`),time:N(`Time`),pressure:N(`Pressure`),force:N(`Force`),energy:N(`Energy`),power:N(`Power`),magnetism:N(`Magnetism`),temperature:N(`Temperature`),volume:N(`Volume`),area:N(`Area`),information:N(`Information`),speed:N(`Speed`)},T4=Object.entries(x4).map(([e,t])=>({value:e,label:E4(t.category)}));function E4(e){return w4[e]??``}function D4(e){for(let[t,n]of Object.entries(C4)){if(t&&!e.startsWith(t))continue;let r=e.slice(t.length),i=x4[r];if(!i&&S4[r]&&(i=x4[S4[r]]),i)return{...i,factor:i.order?n**+i.order:n}}}var O4=l({CONVERT:()=>k4});let k4={description:N(`Converts a numeric value to a different unit of measure.`),args:[H(`value (number)`,N(`the numeric value in start_unit to convert to end_unit`)),H(`start_unit (string)`,N(`The starting unit, the unit currently assigned to value`),T4),H(`end_unit (string)`,N(`The unit of measure into which to convert value`),T4)],compute:function(e,t,n){let r=I(e,this.locale),i=L(t),a=L(n),o=D4(i),s=D4(a);return o?s?o.category===s.category?{value:s.inverseTransform(o.factor*o.transform(r))/s.factor,format:e?.format}:{value:P.GenericError,message:N(`Incompatible units of measure ('%s' vs '%s')`,E4(o.category),E4(s.category))}:{value:P.GenericError,message:N(`Invalid units of measure ('%s')`,a)}:{value:P.GenericError,message:N(`Invalid units of measure ('%s')`,i)}},isExported:!0};var A4=l({CHAR:()=>P4,CLEAN:()=>F4,CONCATENATE:()=>I4,EXACT:()=>L4,FIND:()=>R4,FORMAT_LARGE_NUMBER:()=>z4,JOIN:()=>B4,LEFT:()=>V4,LEN:()=>H4,LOWER:()=>U4,MID:()=>W4,PROPER:()=>G4,REGEXEXTRACT:()=>q4,REGEXREPLACE:()=>J4,REGEXTEST:()=>K4,REPLACE:()=>Y4,RIGHT:()=>X4,SEARCH:()=>Z4,SPLIT:()=>Q4,SUBSTITUTE:()=>$4,TEXT:()=>i3,TEXTAFTER:()=>o3,TEXTBEFORE:()=>s3,TEXTJOIN:()=>e3,TEXTSPLIT:()=>t3,TRIM:()=>n3,UPPER:()=>r3,VALUE:()=>a3});let j4=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,M4=[{value:0,label:N(`Case-sensitive (default)`)},{value:1,label:N(`Case-insensitive`)}],N4=[{value:0,label:N(`Don't match to end (default)`)},{value:1,label:N(`Match to end`)}],P4={description:N(`Gets character associated with number.`),args:[H(`table_number (number)`,N(`The number of the character to look up from the current Unicode table in decimal format.`))],compute:function(e){let t=Math.trunc(I(e,this.locale));return t<1?new F(N(`The table_number (%s) is out of range.`,t)):{value:String.fromCharCode(t)}},isExported:!0},F4={description:N(`Remove non-printable characters from a piece of text.`),args:[H(`text (string)`,N(`The text whose non-printable characters are to be removed.`))],compute:function(e){let t=Jo(e,this.locale),n=``;for(let e of t)e&&e.charCodeAt(0)>31&&(n+=e);return{value:n}},isExported:!0},I4={description:N(`Appends strings to one another.`),args:[H(`string (string, range<string>, repeating)`,N(`String to append in sequence.`))],compute:function(...e){return{value:is(e,(e,t)=>e+Jo(t,this.locale),``)}},isExported:!0},L4={description:N(`Tests whether two strings are identical.`),args:[H(`string1 (string)`,N(`The first string to compare.`)),H(`string2 (string)`,N(`The second string to compare.`))],compute:function(e,t){return{value:Jo(e,this.locale)===Jo(t,this.locale)}},isExported:!0},R4={description:N(`First position of string found in text, case-sensitive.`),args:[H(`search_for (string)`,N(`The string to look for within text_to_search.`)),H(`text_to_search (string)`,N(`The text to search for the first occurrence of search_for.`)),H(`starting_at (number, default=1)`,N(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=Jo(e,this.locale),i=Jo(t,this.locale),a=I(n,this.locale);if(i===``)return new F(N(`The text_to_search must be non-empty.`));if(a<1)return new F(N(`The starting_at (%s) must be greater than or equal to 1.`,a));let o=i.indexOf(r,a-1);return o===-1?new F(N(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)):{value:o+1}},isExported:!0},z4={description:N(`Apply a large number format`),args:[H(`value (number)`,N(`The number.`)),H(`unit (string, optional)`,N(`The formatting unit. Use 'k', 'm', or 'b' to force the unit`),[{value:`k`,label:N(`Thousand`)},{value:`m`,label:N(`Million`)},{value:`b`,label:N(`Billion`)}])],compute:function(e,t){let n=t?.value;return n!==void 0&&(typeof n!=`string`||![`k`,`m`,`b`].includes(n))?new F(N(`The formatting unit should be 'k', 'm' or 'b'.`)):{value:I(e,this.locale),format:Mc(e,t,this.locale)}}},B4={description:N(`Concatenates elements of arrays with delimiter.`),args:[H(`delimiter (string)`,N(`The character or string to place between each concatenated value.`)),H(`value_or_array (string, range<string>, repeating)`,N(`Value to be appended using delimiter.`))],compute:function(e,...t){let n=Jo(e,this.locale);return{value:is(t,(e,t)=>(e?e+n:``)+Jo(t,this.locale),``)}}},V4={description:N(`Substring from beginning of specified string.`),args:[H(`text (string)`,N(`The string from which the left portion will be returned.`)),H(`number_of_characters (number, optional)`,N(`The number of characters to return from the left side of string.`))],compute:function(e,...t){let n=t.length?I(t[0],this.locale):1;return n<0?new F(N(`The number_of_characters (%s) must be positive or null.`,n)):{value:Jo(e,this.locale).substring(0,n)}},isExported:!0},H4={description:N(`Length of a string.`),args:[H(`text (string)`,N(`The string whose length will be returned.`))],compute:function(e){return{value:Jo(e,this.locale).length}},isExported:!0},U4={description:N(`Converts a specified string to lowercase.`),args:[H(`text (string)`,N(`The string to convert to lowercase.`))],compute:function(e){return{value:Jo(e,this.locale).toLowerCase()}},isExported:!0},W4={description:N(`A segment of a string.`),args:[H(`text (string)`,N(`The string to extract a segment from.`)),H(`starting_at (number)`,N(`The index from the left of string from which to begin extracting. The first character in string has the index 1.`)),H(`extract_length (number)`,N(`The length of the segment to extract.`))],compute:function(e,t,n){let r=Jo(e,this.locale),i=I(t,this.locale),a=I(n,this.locale);return i<1?new F(N(`The starting_at argument (%s) must be positive greater than one.`,i.toString())):a<0?new F(N(`The extract_length argument (%s) must be positive or null.`,a)):{value:r.slice(i-1,i+a-1)}},isExported:!0},G4={description:N(`Capitalizes each word in a specified string.`),args:[H(`text_to_capitalize (string)`,N(`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{value:Jo(e,this.locale).replace(j4,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())}},isExported:!0},K4={description:N(`Checks whether a string matches the supplied regular expression.`),args:[H(`text (string)`,N(`The string to test.`)),H(`pattern (string)`,N(`The regular expression pattern to match against the text.`)),H(`case_sensitivity (number, default=0)`,N(`Whether the match is case-sensitive.`),[{value:0,label:N(`Case-sensitive`)},{value:1,label:N(`Case-insensitive`)}])],compute:function(e,t,n={value:0}){let r=L(e),i=L(t),a=I(n,this.locale);if(i===``)return{value:!0};if(r===``)return{value:!1};if(a!==0&&a!==1)return new F(N(`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 F(N(`Invalid regular expression`))}return{value:s.test(r)}},isExported:!0},q4={description:N(`Extract text from a string based on the supplied regular expression.`),args:[H(`text (string)`,N(`The string on which you want to extract text.`)),H(`pattern (string)`,N(`The regular expression pattern to match against the text.`)),H(`return_mode (number, default=0)`,N(`0 = first match, 1 = all matches as an array, 2 = capturing groups from the first match as an array.`),[{value:0,label:N(`First match`)},{value:1,label:N(`All matches`)},{value:2,label:N(`Capture groups of first match`)}]),H(`case_sensitivity (number, default=0)`,N(`Whether the match is case-sensitive.`),[{value:0,label:N(`Case-sensitive`)},{value:1,label:N(`Case-insensitive`)}])],computeArray:function(e,t,n={value:0},r={value:0}){let i=L(e),a=L(t),o=I(n,this.locale),s=I(r,this.locale);if(i===``||a===``)return{value:``};if(o<0||o>2)return new F(N(`The return_mode (%s) must be 0, 1 or 2.`,o));if(s!==0&&s!==1)return new F(N(`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 F(N(`Invalid regular expression`))}let u=[...i.matchAll(l)];return u.length===0?{value:P.NotAvailable,message:N(`No matches found.`)}:o===0?{value:u[0][0]}:o===1?u.map(e=>[{value:e[0]}]):u[0].length<2?new F(N(`No capturing groups found.`)):u[0].slice(1).map(e=>[{value:e}])},isExported:!0},J4={description:N(`Replace text in a string based on the supplied regular expression.`),args:[H(`text (string)`,N(`The string in which you want to replace text.`)),H(`pattern (string)`,N(`The regular expression pattern to match against the text.`)),H(`replacement (string)`,N(`The text to use as the replacement.`)),H(`occurrence (number, default=0)`,N(`0 = replace all matches. A negative number counts from the end.`)),H(`case_sensitivity (number, default=0)`,N(`Whether the match is case-sensitive.`),[{value:0,label:N(`Case-sensitive`)},{value:1,label:N(`Case-insensitive`)}])],compute:function(e,t,n,r={value:0},i={value:0}){let a=L(e),o=L(t),s=L(n),c=I(r,this.locale),l=I(i,this.locale);if(l!==0&&l!==1)return new F(N(`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 F(N(`Invalid regular expression`))}if(c!==0){let e=[...a.matchAll(d)];if(e.length===0||Math.abs(c)>e.length)return{value:a};let t=c>0?c-1:e.length+c,n=e[t][0].length,r=e[t].index;return{value:a.substring(0,r)+s+a.substring(r+n)}}return{value:a.replace(d,s)}},isExported:!0},Y4={description:N(`Replaces part of a text string with different text.`),args:[H(`text (string)`,N(`The text, a part of which will be replaced.`)),H(`position (number)`,N(`The position where the replacement will begin (starting from 1).`)),H(`length (number)`,N(`The number of characters in the text to be replaced.`)),H(`new_text (string)`,N(`The text which will be inserted into the original text.`))],compute:function(e,t,n,r){let i=I(t,this.locale);if(i<1)return new F(N(`The position (%s) must be greater than or equal to 1.`,i));let a=I(n,this.locale);if(a<0)return new F(N(`The length (%s) must be positive or zero.`,a));let o=Jo(e,this.locale),s=Jo(r,this.locale);return{value:o.substring(0,i-1)+s+o.substring(i-1+a)}},isExported:!0},X4={description:N(`A substring from the end of a specified string.`),args:[H(`text (string)`,N(`The string from which the right portion will be returned.`)),H(`number_of_characters (number, optional)`,N(`The number of characters to return from the right side of string.`))],compute:function(e,...t){let n=t.length?I(t[0],this.locale):1;if(n<0)return new F(N(`The number_of_characters (%s) must be positive or zero.`,n));let r=Jo(e,this.locale),i=r.length;return{value:r.substring(i-n,i)}},isExported:!0},Z4={description:N(`First position of string found in text, ignoring case.`),args:[H(`search_for (string)`,N(`The string to look for within text_to_search.`)),H(`text_to_search (string)`,N(`The text to search for the first occurrence of search_for.`)),H(`starting_at (number, default=1)`,N(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=Jo(e,this.locale).toLowerCase(),i=Jo(t,this.locale).toLowerCase(),a=I(n,this.locale);if(i===``)return{value:P.GenericError,message:N(`The text_to_search must be non-empty.`)};if(a<1)return{value:P.GenericError,message:N(`The starting_at (%s) must be greater than or equal to 1.`,a)};let o=i.indexOf(r,a-1);return o===-1?{value:P.GenericError,message:N(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)}:{value:o+1}},isExported:!0},Q4={description:N(`Split text by specific character delimiter(s).`),args:[H(`text (string)`,N(`The text to divide.`)),H(`delimiter (string)`,N(`The character or characters to use to split text.`)),H(`split_by_each (boolean, default=true})`,N(`Whether or not to divide text around each character contained in delimiter.`)),H(`remove_empty_text (boolean, default=true)`,N(`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.`))],computeArray:function(e,t,n={value:!0},r={value:!0}){let i=Jo(e,this.locale),a=At(Jo(t,this.locale)),o=R(n),s=R(r);if(a.length<=0)return new F(N(`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!==``)),cs(us([l]),e=>({value:e}))},isExported:!1},$4={description:N(`Replaces existing text with new text in a string.`),args:[H(`text_to_search (string)`,N(`The text within which to search and replace.`)),H(`search_for (string)`,N(`The string to search for within text_to_search.`)),H(`replace_with (string)`,N(`The string that will replace search_for.`)),H(`occurrence_number (number, optional)`,N(`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=I(r,this.locale);if(i<0)return new F(N(`The occurrenceNumber (%s) must be positive or null.`,i));let a=Jo(e,this.locale),o=Jo(t,this.locale);if(o===``)return{value:a};let s=Jo(n,this.locale),c=new RegExp(At(o),`g`);if(i===0)return{value:a.replace(c,s)};let l=0;return{value:a.replace(c,e=>++l===i?s:e)}},isExported:!0},e3={description:N(`Combines text from multiple strings and/or arrays.`),args:[H(`delimiter (string)`,N(`A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.`)),H(`ignore_empty (boolean)`,N(`A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.`),[{value:!0,label:N(`Ignore empty cells`)},{value:!1,label:N(`Include empty cells (default)`)}]),H(`texts (string, range<string>, repeating)`,N(`Text item to join.`))],compute:function(e,t={value:!0},...n){let r=Jo(e,this.locale),i=R(t),a=0;return{value:is(n,(e,t)=>i&&Jo(t,this.locale)===``?e:(a++?e+r:``)+Jo(t,this.locale),``)}},isExported:!0},t3={description:N(`Splits text into rows or columns using specified column and row delimiters.`),args:[H(`text (string)`,N(`The text to split.`)),H(`col_delimiter (string, range<string>)`,N(`Character or string to split columns by.`)),H(`row_delimiter (string, range<string>, optional)`,N(`Character or string to split rows by.`)),H(`ignore_empty (boolean, default=false)`,N(`Whether to ignore empty cells.`),[{value:!1,label:N(`Include empty cells (default)`)},{value:!0,label:N(`Ignore empty cells`)}]),H(`match_mode (number, default=0)`,N(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),M4),H(`pad_with (string, default="${P.NotAvailable}")`,N(`The value to use for padding empty cells.`))],computeArray:function(e,t,n,r={value:!1},i={value:0},a=new Ao){let o=L(e);if(o.length<=0)return new F(N(`No text to split.`));if(t===void 0&&n===void 0)return new F(N(`At least one delimiter must be provided.`));let s=z(t).flat().map(e=>At(L(e))),c=z(n).flat().map(e=>At(L(e)));if(s.some(e=>e===``)||c.some(e=>e===``))return new F(N(`The delimiters cannot be empty values.`));let l=R(r),u=I(i,this.locale);if(![0,1].includes(u))return new F(N(`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 us(d)},isExported:!0},n3={description:N(`Removes space characters.`),args:[H(`text (string)`,N(`The text or reference to a cell containing text to be trimmed.`))],compute:function(e){return{value:vn(Jo(e,this.locale))}},isExported:!0},r3={description:N(`Converts a specified string to uppercase.`),args:[H(`text (string)`,N(`The string to convert to uppercase.`))],compute:function(e){return{value:Jo(e,this.locale).toUpperCase()}},isExported:!0},i3={description:N(`Converts a number to text according to a specified format.`),args:[H(`number (number)`,N(`The number, date or time to format.`)),H(`format (string)`,N(`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{value:V(I(e,this.locale),{format:L(t),locale:this.locale})}},isExported:!0},a3={description:N(`Converts a string to a numeric value.`),args:[H(`value (number)`,N(`the string to be converted`))],compute:function(e){return{value:I(e,this.locale)}},isExported:!0},o3={description:N(`Returns text that occurs after a given substring or delimiter.`),args:[H(`text (string)`,N(`The source text.`)),H(`delimiter (string)`,N(`The substring after which text will be returned.`)),H(`instance_num (number, default=1)`,N(`The desired instance of the delimiter after which we extract the text. A negative number searches from the end.`)),H(`match_mode (number, default=0)`,N(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),M4),H(`match_end (number, default=0))`,N(`Whether to treat the end of text as a delimiter.`),N4),H(`if_not_found (string, default="${P.NotAvailable}")`,N(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new Ao){let o=L(e),s=I(n,this.locale),c=I(r,this.locale),l=I(i,this.locale);if(s===0)return new F(N(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new F(N(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new F(N(`match_end should have a value of 0 or 1.`));let u=L(t);if(u===``)return Math.sign(s)>0?{value:o}:{value:``};let d=c===1?`gi`:`g`,f=At(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},s3={description:N(`Returns text that occurs before a given substring or delimiter.`),args:[H(`text (string)`,N(`The source text.`)),H(`delimiter (string)`,N(`The substring after which text will be returned.`)),H(`instance_num (number, default=1)`,N(`The desired instance of the delimiter before which we extract the text. A negative number searches from the end.`)),H(`match_mode (number, default=0)`,N(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),M4),H(`match_end (number, default=0))`,N(`Whether to match a delimiter against the end of the text.`),N4),H(`if_not_found (string, default="${P.NotAvailable}")`,N(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new Ao){let o=L(e),s=I(n,this.locale),c=I(r,this.locale),l=I(i,this.locale);if(s===0)return new F(N(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new F(N(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new F(N(`match_end should have a value of 0 or 1.`));let u=L(t);if(u===``)return Math.sign(s)>0?{value:``}:{value:o};let d=c===1?`gi`:`g`,f=At(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 c3=l({HYPERLINK:()=>l3});let l3={description:N(`Creates a hyperlink in a cell.`),args:[H(`url (string)`,N(`The full URL of the link enclosed in quotation marks.`)),H(`link_label (string, optional)`,N(`The text to display in the cell, enclosed in quotation marks.`))],compute:function(e,t){let n=L(e).trim(),r=Jo(t,this.locale)||n;return n===``?{value:r}:{value:Ut(r,n)}},isExported:!0},u3=[{name:N(`Array`),functions:pY},{name:N(`Database`),functions:AQ},{name:N(`Date`),functions:K$},{name:N(`Filter`),functions:A1},{name:N(`Financial`),functions:I1},{name:N(`Info`),functions:G0},{name:N(`Lookup`),functions:b2},{name:N(`Logical`),functions:i2},{name:N(`Math`),functions:UY},{name:N(`Operator`),functions:W2},{name:N(`Statistical`),functions:aZ},{name:N(`Text`),functions:A4},{name:N(`Engineering`),functions:O1},{name:N(`Web`),functions:c3},{name:N(`Parser`),functions:O4}];for(let e of u3){let t=e.functions;for(let n in t){let r=t[n];r.category=r.category||e.name,n=n.replace(/_/g,`.`),ul.add(n,{isExported:!1,...r})}}let d3={},f3={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},p3={autoCompleteProviders:$M,autofillModifiersRegistry:Xj,autofillRulesRegistry:Zj,cellMenuRegistry:AA,colMenuRegistry:Ij,errorTypes:Eo,functionRegistry:ul,featurePluginRegistry:YV,iconsOnCellRegistry:HV,statefulUIPluginRegistry:XV,evaluationPluginRegistry:ZV,corePluginRegistry:JV,rowMenuRegistry:Uj,sidePanelRegistry:Bg,figureRegistry:nD,chartSidePanelComponentRegistry:AL,chartDataSourceSidePanelComponentRegistry:mP,chartComponentRegistry:Ew,chartTypeRegistry:Tb,chartSubtypeRegistry:Ug,chartDataSourceRegistry:wb,topbarMenuRegistry:bH,topbarComponentRegistry:nG,topBarToolBarRegistry:uK,clickableCellRegistry:vE,otRegistry:LB,inverseCommandRegistry:QV,urlRegistry:Qd,cellPopoverRegistry:AE,numberFormatMenuRegistry:gH,repeatLocalCommandTransformRegistry:OV,repeatCommandTransformRegistry:DV,clipboardHandlersRegistries:iw,pivotRegistry:qT,pivotTimeAdapterRegistry:RS,pivotSidePanelRegistry:RR,pivotNormalizationValueRegistry:gC,supportedPivotPositionalFormulaRegistry:sR,pivotToFunctionValueRegistry:_C,migrationStepRegistry:FC,chartJsExtensionRegistry:ri,onIterationEndEvaluationRegistry:eB,specificRangeTransformRegistry:RB,unusedDataSourceRegistry:pW,NonSquishableFunctionRegistry:dl},m3={arg:H,isEvaluationError:Lo,toBoolean:R,toJsDate:Qo,toNumber:I,toString:L,toNormalizedPivotValue:fC,toFunctionPivotValue:mC,toXC:E,toZone:tr,toUnboundedZone:er,toCartesian:Un,numberToLetters:Pn,lettersToNumber:Fn,UuidGenerator:K,formatValue:V,createCurrencyFormat:Tc,ColorGenerator:pp,computeTextWidth:Dp,createEmptyWorkbookData:tw,createEmptySheet:ew,createEmptyExcelSheet:nw,doesCellContainFunction:kn,rgbaToHex:zf,colorToRGBA:Bf,positionToZone:D,isDefined:w,isMatrix:wt,lazy:en,genericRepeat:RH,createAction:we,createActions:be,transformRangeData:Gr,deepEquals:T,overlap:hr,union:dr,isInside:_r,deepCopy:x,expandZoneOnInsertion:sr,reduceZoneOnDeletion:ur,unquote:Nt,getMaxObjectId:iC,getFirstPivotFunction:ZL,getNumberOfPivotFunctions:$L,parseDimension:sC,isDateOrDatetimeField:cC,makeFieldProposal:eR,periodYearToComparable:LS,insertTokenAfterArgSeparator:nR,insertTokenAfterLeftParenthesis:rR,mergeContiguousZones:Vr,getPivotHighlights:pR,pivotTimeAdapter:zS,UNDO_REDO_PIVOT_COMMANDS:VR,createPivotFormula:dC,areDomainArgsFieldsValid:uC,splitReference:wl,sanitizeSheetName:Ft,getUniqueText:En,isNumber:mo,isDateTime:Fa,createCustomFields:CC,schemeToColorScale:MC,isDateTimeFormat:vc,jsDateToNumber:Ya,numberToJsDate:qa,DateTime:xa,parseFormat:Vs,isFormula:Dn,domainToColRowDomain:qw,collapseHierarchicalDisplayName:kC,getCanonicalSymbolName:Pt,fuzzyLookup:QM,PositionMap:Bw,replaceSymbolInFormula:rd,isSingleCellReference:Cl,computeCachedTextDimension:jp,createComputeFunction:nl,isMobileOS:_e,drawHighlight:EE,getBoundingRectWithMargins:te,hasInteractiveElementInEventTree:ye},h3={isMarkdownLink:Vt,parseMarkdownLink:Wt,markdownLink:Ut,openLink:rf,urlRepresentation:nf},g3={Checkbox:fP,Section:Q,Select:XE,RoundColorPicker:zP,ChartDataSeries:hP,ChartErrorSection:vP,ChartLabelRange:gP,ChartRangeDataSourceComponent:QI,ChartTitle:jP,ChartPanel:FL,ChartFigure:eD,ChartJsComponent:sg,ClickableCellSortIcon:Hw,ZoomableChartJsComponent:vw,Grid:rP,GridOverlay:PE,ScorecardChart:zg,GaugeChartComponent:ww,LineConfigPanel:hL,BarConfigPanel:bP,PieChartDesignPanel:vL,GenericChartConfigPanel:yP,ChartWithAxisDesignPanel:KP,GenericZoomableChartDesignPanel:qP,LineChartDesignPanel:gL,GaugeChartConfigPanel:sL,GaugeChartDesignPanel:uL,ScorecardChartConfigPanel:xL,ScorecardChartDesignPanel:SL,GeoChartDesignPanel:pL,RadarChartDesignPanel:yL,WaterfallChartDesignPanel:kL,ComboChartDesignPanel:iL,FunnelChartDesignPanel:oL,SunburstChartDesignPanel:CL,TreeMapChartDesignPanel:OL,ChartTypePicker:NL,FigureComponent:rD,MenuPopover:zw,Popover:Fw,SelectionInput:dP,StandaloneComposer:lL,ValidationMessages:wE,AddDimensionButton:VL,PivotDimensionGranularity:UL,PivotDimensionOrder:WL,PivotDimension:HL,PivotLayoutConfigurator:YL,PivotHTMLRenderer:lR,PivotDeferUpdate:zL,PivotTitleSection:oR,CogWheelMenu:IL,TextInput:wP,SidePanelCollapsible:MP,RadioSelection:RP,GeoChartRegionSelectSection:dL,ChartMenu:QE,FullScreenFigure:cR,NumberInput:PP,TopBar:dK,Composer:hN,CalendarButton:yR,Spreadsheet:mK,CarouselFigure:$E},_3={useDragAndDropListItems:iP,useHighlights:eP,useHighlightsOnHover:$N},v3={Component:k,EnvPlugin:Hi,App:Gi},y3={useStoreProvider:Yi,proxifyStoreMutation:$i,DependencyContainer:qi,CellPopoverStore:jE,ComposerFocusStore:ni,CellComposerStore:rN,FindAndReplaceStore:RL,HighlightStore:DE,DelayedHoveredCellStore:CE,HoveredTableStore:dR,ModelStore:Yr,NotificationStore:Vg,RendererStore:$r,SelectionInputStore:uP,SpreadsheetStore:ei,useStore:A,useLocalStore:Zi,SidePanelStore:U,PivotSidePanelStore:aR,PivotMeasureDisplayPanelStore:uR,TableAutofillStore:uM,AutofillStore:lM,ClientFocusStore:qj,GridRenderer:HE,ViewportsStore:W,ClipboardStore:aw,ZoomStore:Rg,globalStores:oG},b3={PopoverContainerPlugin:Mw};function x3(e,t){return ul.add(e,t),{addFunction:(e,t)=>x3(e,t)}}let S3={DEFAULT_LOCALE:B,HIGHLIGHT_COLOR:Ae,PIVOT_STATIC_TABLE_CONFIG:ht,PIVOT_INSERT_TABLE_STYLE_ID:gt,ChartTerms:pT,FIGURE_ID_SPLITTER:`??`,GRID_ICON_EDGE_LENGTH:17,GRID_ICON_MARGIN:2,CHART_TYPES:jC,DARK_MODE_FILTER_STRING:Zf},C3={...ZI,...fR};e.AbstractCellClipboardHandler=UW,e.AbstractChart=gg,e.AbstractFigureClipboardHandler=CJ,e.BadExpressionError=Do,e.CHART_TYPES=jC,e.CellErrorType=P,e.CellValueType=Ed,e.CircularDependencyError=Oo,e.ClientDisconnectedError=yV,e.ClipboardMIMEType=I_,e.CommandResult=Xd,e.CompiledFormula=yd,e.CorePlugin=lv,e.DEFAULT_LOCALE=B,e.DEFAULT_LOCALES=Es,e.DEFAULT_LOCALE_DIGIT_GROUPING=`[3,0]`,e.DIRECTION=Et,e.DispatchResult=Jd,e.DivisionByZeroError=No,e.EvaluationError=F,e.EvaluationPlugin=LE,e.InvalidReferenceError=ko,e.LocalTransportService=rG,e.Model=bJ,e.NEXT_VALUE=Ww,e.NotAvailableError=Ao,e.NumberTooLargeError=Po,e.OrderedLayers=Zr,e.PREVIOUS_VALUE=Uw,e.PivotRuntimeDefinition=uT,e.Registry=O,e.Revision=vV,e.SPREADSHEET_DIMENSIONS=f3,e.SplillBlockedError=Mo,e.Spreadsheet=mK,e.SpreadsheetPivotTable=jT,e.UIPlugin=jB,e.UnknownFunctionError=jo,e.__info__=d3,e.addFunction=x3,e.addRenderingLayer=Qr,e.astToFormula=MM,e.availableConditionalFormatOperators=QR,e.availableDataValidationOperators=vW,e.availableFiltersOperators=hR,e.borderPositions=Tt,e.borderStyles=Ct,e.canExecuteInReadonly=qd,e.categories=u3,e.chartHelpers=C3,e.compatibility=v3,e.components=g3,e.composerFocusTypes=Dt,e.constants=S3,e.convertAstNodes=yu,e.coreTypes=Vd,e.createAutocompleteArgumentsProvider=YJ,e.dispatcheableEvaluationCommandTypes=Hd,e.errorTypes=Eo,e.evaluationCommandTypes=Ud,e.filterDateCriterionOperators=vR,e.filterNumberCriterionOperators=_R,e.filterTextCriterionOperators=gR,e.findCellInNewZone=Or,e.functionCache=gd,e.getCaretDownSvg=Dy,e.getCaretUpSvg=Oy,e.helpers=m3,e.hooks=_3,e.invalidSubtotalFormulasCommands=Rd,e.invalidateBordersCommands=Ld,e.invalidateCFEvaluationCommands=Id,e.invalidateChartEvaluationCommands=Pd,e.invalidateDependenciesCommands=Fd,e.invalidateEvaluationCommands=Nd,e.isCoreCommand=Wd,e.isDispatcheableEvaluationCommand=Gd,e.isEvaluationCommand=Kd,e.isHeadersDependant=Od,e.isMatrix=wt,e.isPositionDependent=jd,e.isRangeDependant=Ad,e.isSheetDependent=Dd,e.isTargetDependent=kd,e.isZoneDependent=Md,e.iterateAstNodes=bu,e.links=h3,e.load=BC,e.lockedSheetAllowedCommands=Bd,e.owlPlugins=b3,e.parse=_u,e.parseTokens=vu,e.readonlyAllowedCommands=zd,e.registries=p3,e.schemeToColorScale=MC,e.setDefaultSheetViewSize=pt,e.setTranslationMethod=Co,e.stores=y3,e.tokenColors=St,e.tokenize=Il,d3.version=`20.1.0-alpha.1`,d3.date=`2026-09-19T08:05:57.456Z`,d3.hash=`c2bc431`})(this.o_spreadsheet=this.o_spreadsheet||{},owl);
1011
+ `),`_rels/.rels`)}function vJ(e){let t={},n=[];for(let r of e.sheets){let e=r.name.slice(0,31);e=En(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(`'?${At(e)}'?!`,`g`);i=i.replaceAll(n,n=>{let r=t[e];return n.replace(e,r)})}return JSON.parse(i)}function yJ(e){for(let t of e.sheets)t.tables=t.tables.filter(e=>yr(tr(e.range)).numberOfRows>1);return e}var bJ=class e extends Ki{statefulUIPlugins=[];range;formulasPlugin;session;isReplayingCommand=!1;renderers={};status=0;config;corePluginConfig;evaluationPluginConfig;uiPluginConfig;state;selection;getters;coreGetters;evaluationGetters;handlers=[];uiHandlers=[];coreHandlers=[];evaluationHandlers=[];constructor(e={},t={},n=[],r=!1){let i=performance.now();console.debug(`##### Model creation #####`),super(),wo(),n=JC(e,n);let a=BC(e,r);this.state=new MK,this.config=this.setupConfig(t),this.getters={isReadonly:()=>this.config.mode===`readonly`||this.config.mode===`dashboard`,isDashboard:()=>this.config.mode===`dashboard`},this.evaluationGetters={isReadonly:()=>this.config.mode===`readonly`||this.config.mode===`dashboard`,isDashboard:()=>this.config.mode===`dashboard`},this.coreGetters={},this.session=this.setupSession(a.revisionId),this.range=new OK(this.coreGetters);for(let e of OK.getters)this.registerCoreGetter(this.range,e);this.formulasPlugin=new DK;for(let e of DK.getters)this.registerCoreGetter(this.formulasPlugin,e);this.selection=new AK(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.getCorePluginConfig(),this.evaluationPluginConfig=this.getEvaluationPluginConfig(),this.uiPluginConfig=this.getUiPluginConfig();for(let e of JV.getAll())this.setupCorePlugin(e,a);this.session.loadInitialMessages(n);for(let e of ZV.getAll()){let t=this.setupEvaluationPlugin(e);this.handlers.push(t),this.uiHandlers.push(t),this.coreHandlers.push(t),this.evaluationHandlers.push(t)}for(let e of XV.getAll()){let t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t),this.uiHandlers.push(t),this.evaluationHandlers.push(t)}for(let e of YV.getAll()){let t=this.setupUiPlugin(e);this.handlers.push(t),this.uiHandlers.push(t),this.evaluationHandlers.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()?en(()=>this.exportData()):void 0;await this.session.leave(t)}registerCoreGetter(e,t){if(!(t in e))throw Error(`Invalid getter name: ${t} for plugin ${e.constructor}`);if(t in this.coreGetters)throw Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=e[t].bind(e),this.evaluationGetters[t]=e[t].bind(e),this.getters[t]=e[t].bind(e)}registerEvaluationGetter(e,t){if(!(t in e))throw Error(`Invalid getter name: ${t} for plugin ${e.constructor}`);if(t in this.evaluationGetters)throw Error(`Getter "${t}" is already defined.`);this.evaluationGetters[t]=e[t].bind(e),this.getters[t]=e[t].bind(e)}registerUiGetter(e,t){if(!(t in e))throw Error(`Invalid getter name: ${t} for plugin ${e.constructor}`);if(t in this.getters)throw Error(`Getter "${t}" is already defined.`);this.getters[t]=e[t].bind(e)}setupUiPlugin(e){let t=new e(this.uiPluginConfig);for(let n of e.getters)this.registerUiGetter(t,n);for(let n of e.layers)this.renderers[n]||(this.renderers[n]=[]),this.renderers[n].push(t);return t}setupEvaluationPlugin(e){let t=new e(this.evaluationPluginConfig);for(let n of e.getters)this.registerEvaluationGetter(t,n);return t}setupCorePlugin(e,t){let n=new e(this.corePluginConfig);for(let t of e.getters)this.registerCoreGetter(n,t);n.import(t),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 bV(wK({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 hK(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:K.smallUuid(),name:N(`Anonymous`).toString()},n=e.transportService||new rG,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 gK(n):n,client:t,moveClient:()=>{},snapshotRequested:!1,customColors:e.customColors||[]}}setupExternalConfig(e){let t=e.loadLocales||(()=>Promise.resolve(Es));return{...e,loadLocales:t}}getCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,formulasPlugin:this.formulasPlugin,dispatch:this.dispatchFromCorePlugin,canDispatch:this.canDispatch,custom:this.config.custom,external:this.config.external}}getEvaluationPluginConfig(){return{getters:this.evaluationGetters,stateObserver:this.state,custom:this.config.custom,session:this.session,dispatch:this.dispatchFromEvaluationPlugin,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external}}getUiPluginConfig(){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,session:this.session,defaultCurrency:this.config.defaultCurrency,customColors:this.config.customColors||[],external:this.config.external,colorScheme:this.config.colorScheme}}checkDispatchAllowed(e){let t=Wd(e)?this.checkDispatchAllowedCoreCommand(e):this.checkDispatchAllowedLocalCommand(e);return this.processCommandResults(t)}processCommandResults(e){return e.some(e=>e!==`Success`)?new Jd(e.flat()):Jd.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.filter(t=>this.canHandle(t,e)).map(t=>t.allowDispatch(e))}canHandle(e,t){return e instanceof lv?Wd(t):e instanceof LE?Kd(t):!0}finalize(){this.status=4;for(let e of this.handlers)e.finalize();this.status=0,this.trigger(`command-finalized`)}canDispatch=(e,t)=>this.checkDispatchAllowed(xJ(e,t));dispatch=(e,t)=>{let n=xJ(e,t),r=this.status;if(this.getters.isReadonly()&&!qd(n))return new Jd(`Readonly`);if(!this.session.canApplyOptimisticUpdate())return new Jd(`WaitingSessionConfirmation`);switch(r){case 0:if(Gd(n)){this.status=3;let t=performance.now();this.dispatchToHandlers(this.handlers,n),this.finalize();let r=performance.now()-t;r>5&&console.debug(e,r,`ms`),this.status=0,this.trigger(`update`);break}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();Wd(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(Wd(n)){let e=this.checkDispatchAllowed(n);if(!e.isSuccessful)return e;this.state.addCommand(n)}this.dispatchToHandlers(this.handlers,n);break;case 4:throw Error(`Cannot dispatch commands in the finalize state`);case 2:if(Wd(n))throw Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,n);break;case 3:if(!Gd(n))throw Error(`A top level evaluation command cannot dispatch non-evaluation commands (${e})`);break}return Jd.Success};dispatchFromCorePlugin=(e,t)=>{let n=xJ(e,t),r=this.status;this.status=2;let i=this.isReplayingCommand?this.coreHandlers:this.handlers;return this.dispatchToHandlers(i,n),this.status=r,Jd.Success};dispatchFromEvaluationPlugin=(e,t)=>{let n=xJ(e,t);if(!Gd(n))throw Error(`An evaluation plugin cannot dispatch non-evaluation commands (${e})`);return this.status===0?(this.status=3,this.dispatchToHandlers(this.evaluationHandlers,n),this.finalize(),this.status=0,this.trigger(`update`),Jd.Success):(this.dispatchToHandlers(this.evaluationHandlers,n),Jd.Success)};dispatchToHandlers(e,t){let n=e.filter(e=>this.canHandle(e,t));for(let e of n)e.beforeHandle(t);for(let e of n)e.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 rG};return T(n,new e(x(t),r)._exportData(!1))?t:(n.isNotSquishable=!0,n)}_exportData(e){let t=tw();for(let n of this.handlers)n instanceof lv&&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=rw();for(let t of this.handlers)t instanceof cv&&await t.exportForExcel(e);return e=x(e),lJ(e)}};function xJ(e,t={}){let n=x(t);return n.type=e,n}var SJ=class extends UW{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(D(t))}executeQueuedChanges(e){for(let t in this.queuedBordersToAdd){let n=this.queuedBordersToAdd[t],r=JSON.parse(t),i=Wn(n,[]);this.dispatch(`SET_BORDERS_ON_TARGET`,{sheetId:e,target:i,border:r})}this.queuedBordersToAdd={}}},CJ=class extends HW{copy(e){}getCopyRect(e){return Ng(...e.figureIds.map(t=>this.getters.getFigure(e.sheetId,t)).filter(w).map(t=>this.getters.getFigureUI(e.sheetId,t)))}},wJ=class extends CJ{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]=K.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}=A_(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=K.smallUuid(),r=bN.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:this.getters.carouselToCarouselData({...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`}},TJ=class extends CJ{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]=K.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=bN.fromDefinition(this.getters,i,l.copyInSheetId(i)).getDefinition();u=bN.fromStrDefinition(this.getters,i,u).getDefinition();let{col:d,row:f,offset:p}=A_(this.getters,i,{col:r[0].left,row:r[0].top},{...a.copiedFigure,offset:a.offset});this.dispatch(`CREATE_CHART`,{figureId:o,chartId:K.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`}},EJ=class extends UW{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=D(e.position),i=D(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:K.smallUuid(),ranges:[]}}},DJ=class extends UW{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=D(t),i=D(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?K.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=Wn([...Wn(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})}}},OJ=class extends UW{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 qe){t.style[n]={sheetDefault:this.getters.getDefaultStyle(e.sheetId,n,`SHEET`,void 0)??qe[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}adaptContentToZone(e,t){let n=Math.max(Math.floor((e.right-e.left+1)/t.width),1),r=Math.max(Math.floor((e.bottom-e.top+1)/t.height),1);if(n===1&&r===1)return t;let i=x(t);i.height*=r,i.width*=n,r>1&&i.format.rowDefault&&(i.format.rowDefault.length=t.height,i.format.rowDefault=Nn(i.format.rowDefault,r)),n>1&&i.format.colDefault&&(i.format.colDefault.length=t.width,i.format.colDefault=Nn(i.format.colDefault,n));for(let e in t.style)r>1&&i.style[e].rowDefault&&(i.style[e].rowDefault.length=t.height,i.style[e].rowDefault=Nn(i.style[e].rowDefault,r)),n>1&&i.style[e].colDefault&&(i.style[e].colDefault.length=t.width,i.style[e].colDefault=Nn(i.style[e].colDefault,n));return i}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){let n=this.adaptContentToZone(e,t);this.pasteStyle(r,e.left,e.top,n.width,n.height,n.style),this.pasteFormat(r,e.left,e.top,n.width,n.height,n.format)}}clearClippedZones(e){this.dispatch(`CLEAR_FORMATTING`,{sheetId:e.sheetId,target:e.zones})}pasteStyle(e,t,n,r,i,a){let o=jn({}),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},qe);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);Yt(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];r!==void 0&&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})}},kJ=class extends CJ{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]=K.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}=A_(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`}},AJ=class extends UW{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}]})}},jJ=class extends UW{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})}}},MJ=class extends UW{isPasteAllowed(e,t,n,r){if(!(`cells`in n))return`Success`;let{xSplit:i,ySplit:a}=this.getters.getPaneDivisions(e);return Pr(B_(t,n.cells),i,a)?`FrozenPaneOverlap`:`Success`}},NJ=class extends UW{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=>vr(f,e))){s.add(u.id);let{numberOfRows:e}=yr(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=>vr(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=sn({...this.getters.getCellTableStyle(e),hideGridLines:!1}),n=this.getters.getCellStyle(e),r=this.getters.getCellTableBorder(e),i=this.getters.getCellBorder(e);return{style:{...t,...sn(n)},border:{...r,...sn(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=yr(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}))}};iw.figureHandlers.add(`chart`,TJ).add(`image`,kJ).add(`carousel`,wJ),iw.cellHandlers.add(`dataValidation`,DJ).add(`default`,OJ).add(`cell`,WW).add(`sheet`,MJ).add(`merge`,AJ).add(`border`,SJ).add(`table`,NJ).add(`conditionalFormat`,EJ).add(`references`,jJ);var PJ=class extends k{static maxSize={maxHeight:80};static template=`o-spreadsheet-ErrorToolTip`;props=(0,t.useProps)({cellPosition:M.CellPosition(),onClosed:M.function().optional()});viewStore;setup(){this.viewStore=A(W)}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,D(e)),this.viewStore.displayedSheetId)}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===P.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 An(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?N(`Add missing columns and rows`):e.missingCols>0?N(`Add missing columns`):N(`Add missing rows`)}};let FJ={onHover:(e,t)=>{let n=t.getEvaluatedCell(e);return n.type===`error`&&n.message||t.getInvalidDataValidationMessage(e)?{isOpen:!0,props:{cellPosition:e},Component:PJ,cellCorner:`top-right`}:{isOpen:!1}}};var IJ=class extends k{static template=`o-spreadsheet-FilterMenu`;static components={FilterMenuValueList:PR,SidePanelCollapsible:MP,FilterMenuCriterion:MR};props=(0,t.useProps)({filterPosition:M.Position(),onClosed:M.function().optional()});state;criterionCategory=`text`;updatedCriterionValue;viewStore;setup(){this.viewStore=A(W),(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.viewStore.displayedSheetId,t=this.props.filterPosition;return this.env.model.getters.getTable({sheetId:e,...t})}get filterValueType(){let e=this.viewStore.displayedSheetId,t=this.props.filterPosition;return this.env.model.getters.getFilterValue({sheetId:e,...t})?.filterType}getCriterionCategory(e){let t=this.viewStore.displayedSheetId,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&&vc(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.viewStore.displayedSheetId,value:this.updatedCriterionValue}),this.props.onClosed?.()}get criterionOperators(){return this.criterionCategory===`date`?vR:this.criterionCategory===`number`?_R:gR}cancel(){this.props.onClosed?.()}sortFilterZone(e){let t=this.props.filterPosition,n=this.table,r=n?.range.zone;if(!t||!r||r.top===r.bottom)return;let i=this.viewStore.displayedSheetId,a={...r,top:r.top+n.config.numberOfHeaders},o={col:t.col,row:a.top};Rk(this.env,i,o,a,e,{emptyCellAsZero:!0,sortHeaders:!0}),this.props.onClosed?.()}getFilterHiddenValues(e){let t=this.viewStore.displayedSheetId,n=this.env.model.getters.getFilter({sheetId:t,...e});if(!n?.filteredRange)return[];let r=this.env.model.getters.getFilterValue({sheetId:t,...e}),i=Sr(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(Rp)),c=new Set,l=[],u=e=>{let t=Rp(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.viewStore.displayedSheetId,n=this.env.model.getters.getFilterCriterionValue({sheetId:t,...e});return n?.filterType===`criterion`?x(n):{filterType:`criterion`,type:`none`,values:[]}}};let LJ={onOpen:(e,t)=>({isOpen:!0,props:{filterPosition:e},Component:IJ,cellCorner:`bottom-left`})};var RJ=class extends k{static template=`o-spreadsheet-LinkDisplay`;props=(0,t.useProps)({cellPosition:M.CellPosition(),onClosed:M.function().optional()});cellPopovers;viewStore;setup(){this.cellPopovers=A(jE),this.viewStore=A(W)}get cell(){let{col:e,row:t}=this.props.cellPosition,n=this.viewStore.displayedSheetId;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 nf(e,this.env.model.getters)}openLink(e){rf(this.link,this.env,de(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.viewStore.displayedSheetId,{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 zJ={onHover:(e,t)=>{let n=t.getEvaluatedCell(e);return!t.isDashboard()&&n.link?{isOpen:!0,Component:RJ,props:{cellPosition:e},cellCorner:`bottom-left`}:{isOpen:!1}}};var BJ=class extends k{static template=`o-spreadsheet-LinkEditor`;static components={MenuPopover:zw};props=(0,t.useProps)({cellPosition:M.CellPosition(),onClosed:M.function().optional()});static size={maxHeight:500};urlInput=t.signal.ref(HTMLInputElement);suggestionListRef=t.signal.ref();urlInputContainer=t.signal.ref();state;viewStore;setup(){this.viewStore=A(W),this.state=(0,t.proxy)(this.defaultState),this.computeLinks(),(0,t.onMounted)(()=>this.urlInput()?.focus())}onLinkUrlInput(e){this.state.url=e.target.value,this.computeLinks()}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 Qd.getKeys()){let i=Qd.get(r),a=i.getLinkProposals?.(this.env)||[],o=n&&this.state.isUrlEditable?QM(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.viewStore.displayedSheetId,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 nf(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?J_(this.state.label,n):this.state.url;this.env.model.dispatch(`UPDATE_CELL`,{col:e,row:t,sheetId:this.viewStore.displayedSheetId,content:Ut(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`})}};AE.add(`ErrorToolTip`,FJ).add(`LinkCell`,zJ).add(`LinkEditor`,{onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:BJ,cellCorner:`bottom-left`})}).add(`FilterMenu`,LJ);let VJ=Object.freeze({value:null}),HJ=Object.freeze({value:1}),UJ={supportedChartTypes:jC,fromExternalDefinition(e,t,n){let r=bm(n,t,e),i=ju(n,t,e.labelRange);return{...e,dataSets:r,labelRange:i}},fromContextCreation(e){return{type:`range`,dataSets:[],dataSetsHaveTitle:!1,labelRange:e.auxiliaryRange,...e.dataSource}},fromHierarchicalContextCreation(e){if(e.dataSource?.type!==`range`||e.hierarchicalDataSource!==void 0&&e.hierarchicalDataSource.type!==`range`)return{type:`range`,dataSets:[],dataSetsHaveTitle:!1};let t={type:`range`,dataSets:[],dataSetsHaveTitle:e.dataSource?.dataSetsHaveTitle??!1,labelRange:e.dataSource?.dataSets?.[0]?.dataRange};return e.hierarchicalDataSource?.dataSets.length?t=e.hierarchicalDataSource:e.auxiliaryRange&&(t={...t,dataSets:[{dataRange:e.auxiliaryRange,dataSetId:`0`}]}),t},validate:(e,t)=>t.checkValidations(e,Em,Dm),transform(e,t,{adaptRangeString:n}){let r;if(e.labelRange){let{changeType:i,range:a}=n(t,e.labelRange);i!==`REMOVE`&&(r=a)}let i=[];for(let r of e.dataSets){let e={...r},{changeType:a,range:o}=n(t,r.dataRange);a!==`REMOVE`&&(e.dataRange=o,i.push(e))}return{...e,dataSets:i,labelRange:r}},extractData:(e,t,n)=>WJ(n,e),extractHierarchicalData(e,t,n){let r=e.dataSets,i=e.labelRange,a=KJ(n,r,i),o=qJ(n,r),s={labelValues:a,dataSetsValues:o};return Om(a.length,o[0]?.data.length+(o[0]?.label===void 0?0:1),e.dataSetsHaveTitle||!1)&&a.shift(),s},adaptRanges(e,{applyChange:t}){let n=e.dataSets.map(e=>{let{range:n,changeType:r}=t(e.dataRange);if(r===`REMOVE`)return;let i;if(e.labelCell){let{range:n,changeType:r}=t(e.labelCell);r!==`REMOVE`&&(i=n)}return{...e,dataRange:n,labelCell:i}}).filter(w),r=e.labelRange;if(r){let{range:e,changeType:n}=t(r);r=n===`REMOVE`?void 0:e}let i=n;return{...e,dataSets:i,labelRange:r?.invalidSheetName||r?.invalidXc?void 0:r}},getDefinition(e,t,n){return{labelRange:e.labelRange?n.getRangeString(e.labelRange,t):void 0,type:`range`,dataSets:e.dataSets.map(e=>({dataSetId:e.dataSetId,dataRange:n.getRangeString(e.dataRange,t)})),dataSetsHaveTitle:e.dataSetsHaveTitle}},duplicateInDuplicatedSheet(e,t,n,r){return{...e,labelRange:vm(t,n,e.labelRange),dataSets:e.dataSets.map(e=>({...e,dataRange:Au(t,n,e.dataRange)}))}},getContextCreation:e=>({auxiliaryRange:e.labelRange,dataSource:e}),getHierarchicalContextCreation(e){let t=e.dataSets.at(-1)?.dataRange,n=e.dataSetsHaveTitle;return{auxiliaryRange:t,hierarchicalDataSource:e,dataSource:e.labelRange?{type:`range`,dataSets:[{dataRange:e.labelRange,dataSetId:`0`}],dataSetsHaveTitle:n}:{type:`range`,dataSets:[],dataSetsHaveTitle:n}}},toExcelDataSets(e,t,n){let r=e.dataSets,i=e.labelRange,a=r.map(e=>Sm(n,t,e)).filter(e=>e.range!==``&&e.range!==P.InvalidReference),o=r[0]?Mr(r[0].dataRange.zone):void 0;return{dataSets:a,labelRange:Cm(n,i,Om(i?Mr(i.zone):0,o,e.dataSetsHaveTitle))}}};function WJ(e,t){let n=t.dataSets,r=t.labelRange,i=KJ(e,n,r),a=GJ(e,n,r),o={labelValues:i,dataSetsValues:a},s=a.length?a[0]?.data.length+(a[0]?.label===void 0?0:1):0;return Om(i.length,s,t.dataSetsHaveTitle||!1)&&i.shift(),o}function GJ(e,t,n){let r=[];for(let[i,a]of Object.entries(t)){let t=`${pT.Series} ${parseInt(i)+1}`,o=e.isColHidden(a.dataRange.sheetId,a.dataRange.zone.left);if(a.labelCell){let{sheetId:n,zone:r}=a.labelCell,i=e.getEvaluatedCell({sheetId:n,col:r.left,row:r.top});i&&(t=i.formattedValue)}let s=a.dataRange?JJ(e,a):[];if(!s.some(e=>mf(e))&&s.some(e=>gf(e))){let e=!n||n.sheetId===a.dataRange.sheetId&&mr(n.zone,a.dataRange.zone);s=s.map(t=>gf(t)?e?HJ:{value:+!!t.value}:VJ)}else s.every(e=>!e.value||hf(e))&&s.filter(hf).length>1?s=s.map(e=>e.value&&!_f(e)?HJ:VJ):s.every(e=>!mf(e))&&(o=!0);r.push({data:s,label:t,hidden:o,dataSetId:a.dataSetId})}return r}function KJ(e,t,n){if(n){let{left:t}=n.zone;if(!n.invalidXc&&!n.invalidSheetName&&!e.isColHidden(n.sheetId,t))return e.getVisibleRangeValues(n)}if(t[0]){let n=JJ(e,t[0]).length;return Array.from({length:n},()=>({value:``}))}return[]}function qJ(e,t){t=t.filter(t=>!e.isColHidden(t.dataRange.sheetId,t.dataRange.zone.left));let n=t.map(e=>({data:[],label:``,dataSetId:e.dataSetId})),r=e.getLocale(),i=t.map(t=>JJ(e,t)).map(e=>e.map(({value:e,format:t})=>e===null?VJ:{value:V(e,{format:t,locale:r})}));if(!i.length)return n;let a=Math.min(...i.map(e=>e.length)),o=[],s=t.length-1;for(let e=0;e<a;e++)for(let t=0;t<i.length;t++){let r=i[t][e];(r===void 0||r.value===null)&&t!==s&&(r=o[t]),r?.value!==o[t]?.value&&(o=o.slice(0,t),o[t]=r),n[t].data.push(r??VJ)}return n.filter(e=>e.data.some(e=>e.value!==null))}function JJ(e,t){if(t.dataRange){let n=t.labelCell?[t.labelCell.zone]:[],r=Wn([t.dataRange.zone],n)[0];if(r===void 0)return[];let i=e.getRangeFromZone(t.dataRange.sheetId,r);return e.getVisibleRangeValues(i).map(e=>e.value===``?VJ:e)}return[]}wb.add(`range`,UJ),wb.add(`none`,{supportedChartTypes:[],fromExternalDefinition:()=>({type:`none`}),fromContextCreation:()=>({type:`none`}),fromHierarchicalContextCreation:()=>({type:`none`}),validate:()=>`Success`,transform:()=>({type:`none`}),extractData:()=>({dataSetsValues:[],labelValues:[]}),extractHierarchicalData:()=>({dataSetsValues:[],labelValues:[]}),adaptRanges:e=>e,getDefinition:e=>e,duplicateInDuplicatedSheet:e=>e,getContextCreation:()=>({}),getHierarchicalContextCreation:()=>({}),toExcelDataSets:()=>({dataSets:[],labelRange:void 0})}),$M.add(`dataValidation`,{displayAllOnInitialContent:!0,canBeToggled:!1,getProposals(e,t){if(Dn(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:tp(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()}}),$M.add(`functions_and_named_ranges`,{sequence:100,autoSelectFirstProposal:!0,maxDisplayedProposals:10,getProposals(e){if(e.type!==`SYMBOL`)return[];let t=e.value;if(!Dn(this.composer.currentContent))return[];let n=Object.entries(ul.content).filter(([e,{hidden:t}])=>!t).map(([e,{description:n}])=>({type:`function`,text:e,icon:`o-spreadsheet-Icon.FX_SVG`,description:n,htmlContent:BL(t,e,Fe,`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:BL(t,e.name,Fe,`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 YJ(e,t){for(let n=0;n<t.length;n++){let r=t[n].proposalValues;r===void 0||r.length===0||$M.add(`${e}_function_${t[n].name}_argument_proposals`,{sequence:50,autoSelectFirstProposal:!0,selectProposal:XJ,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`?St.STRING:St.NUMBER}],fuzzySearchKey:o,alwaysExpanded:!0})}return a}})}}function XJ(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)}ul.getAll().forEach(e=>YJ(e.name,e.args)),$M.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:St.NUMBER}],fuzzySearchKey:n+t.name,alwaysExpanded:!0}}).filter(w)},selectProposal:XJ}),$M.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=iR(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:N(`Count`),htmlContent:[{value:e,color:St.STRING}],fuzzySearchKey:N(`Count`)+e}}return tR(e)}).filter(w):[]},selectProposal:XJ}),$M.add(`pivot_group_fields`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!ZJ(e)&&!QJ(e))return;let n=iR(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=sR.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?eR(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:N(`%s (positional)`,t.string)+(t.help?` (${t.help})`:``),htmlContent:[{value:n,color:St.STRING}],fuzzySearchKey:t.string+n}})).filter(w)},selectProposal:XJ});function ZJ(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==0}function QJ(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==1}$M.add(`pivot_group_values`,{sequence:50,autoSelectFirstProposal:!0,getProposals(e){let t=e.functionContext;if(!t||!e||!$J(e)&&!eY(e))return;let n=iR(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(tc).map((e,t)=>({text:`${t+1}`,fuzzySearchKey:e.toString(),description:e.toString(),htmlContent:[{value:`${t+1}`,color:St.NUMBER}]})):s.granularity===`quarter_number`?[1,2,3,4].map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:N(`Quarter %s`,e),htmlContent:[{value:`${e}`,color:St.NUMBER}]})):s.granularity===`day_of_month`?C(1,32).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:St.NUMBER}]})):s.granularity===`iso_week_number`?C(0,54).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:St.NUMBER}]})):s.granularity===`day_of_week`?C(1,8).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:St.NUMBER}]})):s.granularity===`hour_number`?C(0,24).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:St.NUMBER}]})):s.granularity===`minute_number`?C(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:St.NUMBER}]})):s.granularity===`second_number`?C(0,60).map(e=>({text:`${e}`,fuzzySearchKey:`${e}`,description:``,htmlContent:[{value:`${e}`,color:St.NUMBER}]})):i.getPossibleFieldValues(s).map(({value:e,label:t})=>{let n=typeof e==`string`,r=n?`"${e}"`:e.toString(),i=n?St.STRING:St.NUMBER,a=t===e?``:t;return{text:r,description:a,htmlContent:[{value:r,color:i}],fuzzySearchKey:r+a}})},selectProposal:XJ});function $J(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.VALUE`&&t.argPosition>=2&&t.argPosition%2==1}function eY(e){let t=e.functionContext;return t?.parent.toUpperCase()===`PIVOT.HEADER`&&t.argPosition>=1&&t.argPosition%2==0}$M.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=Pt(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 tY(e){return e.yRanges.length&&!vl.test(e.yRanges[0])?`InvalidYRange`:e.xRange&&!vl.test(e.xRange)?`InvalidXRange`:e.labelRange&&!vl.test(e.labelRange)?`InvalidLabelRange`:e.sizeRange&&!vl.test(e.sizeRange)?`InvalidBubbleSizeRange`:`Success`}let nY={sequence:40,allowedDefinitionKeys:[...gg.commonKeys,`yRanges`,`xRange`,`labelRange`,`sizeRange`,`dataSetsHaveTitle`,`verticalAxisPosition`,`labelsAsText`,`bubbleColor`,`legendPosition`,`axesDesign`,`showValues`],fromStrDefinition(e,t,n){let r=e.yRanges.map(e=>ju(n,t,e)).filter(w),i=ju(n,t,e.xRange),a=ju(n,t,e.labelRange),o=ju(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,tY)},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)}},getFormulas:()=>[],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=>ym(e,t)).filter(w),r=ym(e.xRange,t),i=ym(e.labelRange,t),a=ym(e.sizeRange,t);return{...e,yRanges:n,xRange:r,labelRange:i,sizeRange:a}},duplicateInDuplicatedSheet(e,t,n){let r=e=>vm(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,n,r,i,a){let o=dF(t,e,a);return{chartJsConfig:{type:`line`,data:{datasets:Mh(t,o),labels:o.labels},options:{...m_,layout:IF(t,o),scales:mh(t,o),plugins:{title:vI(t,e),legend:tI(t,o),tooltip:TI(t,o),chartShowValuesPlugin:fI(t,o),background:{color:o.background}}}}}}};function rY(e){return!$I.includes(e.horizontalGroupBy)||!$I.includes(e.verticalGroupBy)?`InvalidChartDefinition`:`Success`}let iY={sequence:110,dataSeriesLimit:1,allowedDefinitionKeys:[...gg.commonKeys,`dataSource`,`dataSetStyles`,`showValues`,`colorScale`,`missingValueColor`,`axesDesign`,`horizontalGroupBy`,`verticalGroupBy`,`legendPosition`],validateDefinition(e,t){return e.checkValidations(t,rY)},fromStrDefinition:e=>e,toStrDefinition:e=>e,copyInSheetId:e=>e,duplicateInDuplicatedSheet:e=>e,transformDefinition:e=>e,updateRanges:e=>e,getContextCreation:e=>e,getFormulas:()=>[],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},r,i,a){let o=rF(t,n(),e,a),{labels:s,datasets:c}=Oh(t,o);return{chartJsConfig:{type:`calendar`,data:{labels:s,datasets:c},options:{...m_,indexAxis:`x`,layout:LF(t,o),scales:ch(t,c),plugins:{title:vI(t,e),legend:{display:!1},tooltip:CI(t,o),chartShowValuesPlugin:pI(t,o),chartColorScalePlugin:lh(t,o),background:{color:o.background}}}}}}},aY={sequence:15,allowedDefinitionKeys:[...gg.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,getFormulas:()=>[],getDefinitionForExcel(e,t,{dataSets:n,labelRange:r}){return{...t,backgroundColor:ZP(t.background||`#FFFFFF`),fontColor:ZP(wm(t.background)),dataSets:n,labelRange:r,verticalAxis:km(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,a){let o=eF(t,n(),e,a);return{chartJsConfig:{type:`bar`,data:{labels:o.labels,datasets:Fh(t,o)},options:{...m_,layout:IF(t,o),scales:sh(t,o),plugins:{title:vI(t,e),legend:nI(t,o),tooltip:SI(t,o),chartShowValuesPlugin:fI(t,o),background:{color:o.background}},...i}},customizableSeries:o.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},oY={sequence:100,dataSeriesLimit:1,allowedDefinitionKeys:[...gg.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,getFormulas:()=>[],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,a){let o=lF(t,n(),e,a);return{chartJsConfig:{type:`funnel`,data:{labels:o.labels,datasets:Rh(t,o)},options:{...m_,indexAxis:`y`,layout:IF(t,o),scales:yh(t,o),plugins:{title:vI(t,e),legend:{display:!1},tooltip:jI(t,o),chartShowValuesPlugin:fI(t,o),background:{color:o.background}},...i}}}}},sY={sequence:90,dataSeriesLimit:1,allowedDefinitionKeys:[...gg.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,getFormulas:()=>[],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,a){let o=cF(t,n(),e,a);return{chartJsConfig:{type:`choropleth`,data:{datasets:Lh(t,o)},options:{...m_,layout:IF(t,o),scales:vh(t,o),plugins:{title:vI(t,e),tooltip:AI(t,o),legend:{display:!1},background:{color:o.background}},...i}}}},loadDataForExport:async e=>e.loadUsedGeoJsonFeatures()},cY={sequence:80,dataSeriesLimit:2,allowedDefinitionKeys:[...gg.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,getFormulas:()=>[],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{dataSetsValues:i}=iF(t,WJ(e,t.dataSource),e,`light`),a=Math.max(...i.map(e=>Math.max(...e.data.map(e=>mf(e)?Math.abs(e.value):-1/0))));return{...t,horizontal:!0,backgroundColor:ZP(t.background||`#FFFFFF`),fontColor:ZP(wm(t.background)),dataSets:n,labelRange:r,verticalAxis:km(t),maxValue:a}},getRuntime(e,t,{extractData:n},r,i,a){let o=iF(t,n(),e,a);return{chartJsConfig:{type:`bar`,data:{labels:o.labels,datasets:Eh(t,o)},options:{...m_,indexAxis:`y`,layout:IF(t,o),scales:gh(t,o),plugins:{title:vI(t,e),legend:ZF(t,o),tooltip:OI(t,o),chartShowValuesPlugin:hI(t,o),background:{color:o.background}},...i}},customizableSeries:o.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},lY={sequence:80,allowedDefinitionKeys:[...gg.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,getFormulas:()=>[],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:ZP(t.background||`#FFFFFF`),fontColor:ZP(wm(t.background)),dataSets:n,labelRange:r}},getRuntime(e,t,{extractData:n},r,i,a){let o=sF(t,n(),e,a);return{chartJsConfig:{type:`radar`,data:{labels:o.labels,datasets:Ih(t,o)},options:{...m_,layout:IF(t,o),scales:_h(t,o),plugins:{title:vI(t,e),legend:iI(t,o),tooltip:kI(t,o),chartShowValuesPlugin:fI(t,o),background:{color:o.background}},...i}},customizableSeries:o.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},uY={sequence:60,allowedDefinitionKeys:[...gg.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,getFormulas:()=>[],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:ZP(t.background||`#FFFFFF`),fontColor:ZP(wm(t.background)),dataSets:n,labelRange:r,verticalAxis:km(t)}},getRuntime(e,t,{extractData:n},r,i,a){let o=aF(t,n(),e,a);return{chartJsConfig:{type:`line`,data:{labels:o.labels,datasets:jh(t,o)},options:{...m_,layout:IF(t,o),scales:ph(t,o),plugins:{title:vI(t,e),legend:eI(t,o),tooltip:wI(t,o),chartShowValuesPlugin:fI(t,o),background:{color:o.background}},...i}},customizableSeries:o.dataSetsValues.map(({dataSetId:e,label:t})=>({dataSetId:e,label:t}))}}},dY={sequence:30,allowedDefinitionKeys:[...gg.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,getFormulas:()=>[],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,a){let o=uF(t,n(),e,a);return{chartJsConfig:{type:`doughnut`,data:{datasets:Bh(t,o)},options:{cutout:t.pieHolePercentage===void 0?`25%`:`${t.pieHolePercentage}%`,...m_,layout:IF(t,o),plugins:{title:vI(t,e),legend:aI(t,o),tooltip:MI(t,o),sunburstLabelsPlugin:mI(t,o),sunburstHoverPlugin:{enabled:!0},background:{color:o.background}},...i}}}}},fY={sequence:100,allowedDefinitionKeys:[...gg.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,getFormulas:()=>[],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,a){let o=uF(t,n(),e,a);return{chartJsConfig:{type:`treemap`,data:{labels:o.labels,datasets:Gh(t,o)},options:{...m_,layout:IF(t,o),plugins:{title:vI(t,e),legend:{display:!1},tooltip:NI(t,o),background:{color:o.background}},...i}}}}};Tb.add(`bar`,LI),Tb.add(`combo`,aY),Tb.add(`line`,JI),Tb.add(`pie`,YI),Tb.add(`scorecard`,Eg),Tb.add(`gauge`,UI),Tb.add(`scatter`,uY),Tb.add(`waterfall`,XI),Tb.add(`pyramid`,cY),Tb.add(`radar`,lY),Tb.add(`geo`,sY),Tb.add(`funnel`,oY),Tb.add(`sunburst`,dY),Tb.add(`treemap`,fY),Tb.add(`calendar`,iY),Tb.add(`bubble`,nY),Ug.add(`line`,{matcher:e=>e.type===`line`&&!e.stacked&&!e.fillArea,displayName:N(`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:N(`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:N(`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:N(`Stacked Area`),chartType:`line`,chartSubtype:`stacked_area`,subtypeDefinition:{stacked:!0,fillArea:!0},category:`area`,preview:`o-spreadsheet-ChartPreview.STACKED_AREA_CHART`}).add(`scatter`,{displayName:N(`Scatter`),chartType:`scatter`,chartSubtype:`scatter`,category:`misc`,preview:`o-spreadsheet-ChartPreview.SCATTER_CHART`}).add(`bubble`,{displayName:N(`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:N(`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:N(`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:N(`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:N(`Stacked Bar`),chartType:`bar`,chartSubtype:`stacked_bar`,subtypeDefinition:{horizontal:!0,stacked:!0},category:`bar`,preview:`o-spreadsheet-ChartPreview.STACKED_BAR_CHART`}).add(`combo`,{displayName:N(`Combo`),chartSubtype:`combo`,chartType:`combo`,category:`line`,preview:`o-spreadsheet-ChartPreview.COMBO_CHART`}).add(`pie`,{matcher:e=>e.type===`pie`&&!e.isDoughnut,displayName:N(`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:N(`Doughnut`),chartSubtype:`doughnut`,chartType:`pie`,subtypeDefinition:{isDoughnut:!0},category:`pie`,preview:`o-spreadsheet-ChartPreview.DOUGHNUT_CHART`}).add(`gauge`,{displayName:N(`Gauge`),chartSubtype:`gauge`,chartType:`gauge`,category:`misc`,preview:`o-spreadsheet-ChartPreview.GAUGE_CHART`}).add(`scorecard`,{displayName:N(`Scorecard`),chartSubtype:`scorecard`,chartType:`scorecard`,category:`misc`,preview:`o-spreadsheet-ChartPreview.SCORECARD_CHART`}).add(`waterfall`,{displayName:N(`Waterfall`),chartSubtype:`waterfall`,chartType:`waterfall`,category:`misc`,preview:`o-spreadsheet-ChartPreview.WATERFALL_CHART`}).add(`pyramid`,{displayName:N(`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:N(`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:N(`Filled Radar`),chartType:`radar`,chartSubtype:`filled_radar`,subtypeDefinition:{fillArea:!0},category:`misc`,preview:`o-spreadsheet-ChartPreview.FILLED_RADAR_CHART`}).add(`geo`,{displayName:N(`Geo Chart`),chartSubtype:`geo`,chartType:`geo`,category:`misc`,preview:`o-spreadsheet-ChartPreview.GEO_CHART`}).add(`funnel`,{displayName:N(`Funnel`),chartSubtype:`funnel`,chartType:`funnel`,category:`misc`,preview:`o-spreadsheet-ChartPreview.FUNNEL_CHART`}).add(`sunburst`,{matcher:e=>e.type===`sunburst`,displayName:N(`Sunburst`),chartSubtype:`sunburst`,chartType:`sunburst`,category:`hierarchical`,preview:`o-spreadsheet-ChartPreview.SUNBURST_CHART`}).add(`treemap`,{matcher:e=>e.type===`treemap`,displayName:N(`Tree Map`),chartType:`treemap`,chartSubtype:`treemap`,category:`hierarchical`,preview:`o-spreadsheet-ChartPreview.TREE_MAP_CHART`}).add(`calendar`,{displayName:N(`Calendar`),chartSubtype:`calendar`,chartType:`calendar`,category:`misc`,preview:`o-spreadsheet-ChartPreview.CALENDAR_CHART`}),HV.add(`filter_icon`,(e,t)=>{if(e.isFilterHeader(t)){let n=e.isFilterActive(t),r=Lf(e.getCellComputedStyle(t).fillColor||`#fff`)<.45;return{type:`filter_icon`,svg:Py(n,r,!1),hoverSvg:Py(n,r,!0),priority:3,horizontalAlign:`right`,size:17,margin:2,position:t,onClick:(e,t)=>{let n=t.getStore(jE),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 pY=l({ARRAYTOTEXT:()=>HY,ARRAY_CONSTRAIN:()=>gY,ARRAY_LITERAL:()=>_Y,ARRAY_ROW:()=>vY,CHOOSECOLS:()=>yY,CHOOSEROWS:()=>bY,EXPAND:()=>xY,FLATTEN:()=>SY,FREQUENCY:()=>CY,HSTACK:()=>wY,MDETERM:()=>TY,MINVERSE:()=>EY,MMULT:()=>DY,SUMPRODUCT:()=>OY,SUMX2MY2:()=>AY,SUMX2PY2:()=>jY,SUMXMY2:()=>MY,TOCOL:()=>FY,TOROW:()=>IY,TRANSPOSE:()=>LY,VSTACK:()=>RY,WRAPCOLS:()=>zY,WRAPROWS:()=>BY});function mY(e,t){let n=e.map(z),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 F(N(`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 hY(e,t){let n=e.map(z),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 F(N(`All ranges in [[FUNCTION_NAME]] must have the same number of columns (got %s).`,r.join(`, `)))}let a=ss(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 gY={description:N(`Returns a result array constrained to a specific width and height.`),args:[H(`input_range (any, range<any>)`,N(`The range to constrain.`)),H(`rows (number)`,N(`The number of rows in the constrained array.`)),H(`columns (number)`,N(`The number of columns in the constrained array.`))],computeArray:function(e,t,n){let r=z(e),i=Ko(t?.value,this.locale),a=Ko(n?.value,this.locale);if(i<=0)return new F(N(`The rows argument (%s) must be strictly positive.`,i.toString()));if(a<=0)return new F(N(`The columns argument (%s) must be strictly positive.`,a.toString()));let o=Math.min(i,r[0].length);return ss(Math.min(a,r.length),o,(e,t)=>r[e][t])},isExported:!1},_Y={description:N(`Appends ranges vertically and in sequence to return a larger array. All ranges must have the same number of columns.`),args:[H(`range (any, range<any>, repeating)`,N(`The range to be appended.`))],computeArray:function(...e){return hY(e,{requireSameColCount:!0})},isExported:!1,hidden:!0},vY={description:N(`Appends ranges horizontally and in sequence to return a larger array. All ranges must have the same number of rows.`),args:[H(`range (any, range<any>, repeating)`,N(`The range to be appended.`))],computeArray:function(...e){return mY(e,{requireSameRowCount:!0})},isExported:!1,hidden:!0},yY={description:N(`Creates a new array from the selected columns in the existing range.`),args:[H(`array (any, range<any>)`,N(`The array that contains the columns to be returned.`)),H(`col_num (number, range<number>, repeating)`,N(`The column index of the column to be returned.`))],computeArray:function(e,...t){let n=z(e),r=Ss(t,e=>Ko(e?.value,this.locale)),i=r.filter(e=>e===0||n.length<Math.abs(e));if(i.length!==0)return new F(N(`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},bY={description:N(`Creates a new array from the selected rows in the existing range.`),args:[H(`array (any, range<any>)`,N(`The array that contains the rows to be returned.`)),H(`row_num (number, range<number>, repeating)`,N(`The row index of the row to be returned.`))],computeArray:function(e,...t){let n=z(e),r=Ss(t,e=>Ko(e?.value,this.locale)),i=n.length,a=r.filter(e=>e===0||n[0].length<Math.abs(e));return a.length===0?ss(i,r.length,(e,t)=>r[t]>0?n[e][r[t]-1]:n[e][n[e].length+r[t]]):new F(N(`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},xY={description:N(`Expands or pads an array to specified row and column dimensions.`),args:[H(`array (any, range<any>)`,N(`The array to expand.`)),H(`rows (number)`,N(`The number of rows in the expanded array. If missing, rows will not be expanded.`)),H(`columns (number, optional)`,N(`The number of columns in the expanded array. If missing, columns will not be expanded.`)),H(`pad_with (any, default=0)`,N(`The value with which to pad.`))],computeArray:function(e,t,n,r={value:0}){let i=z(e),a=Ko(t?.value,this.locale),o=n===void 0?i.length:Ko(n.value,this.locale);return a<i[0].length?new F(N(`The rows arguments (%s) must be greater or equal than the number of rows of the array.`,a.toString())):o<i.length?new F(N(`The columns arguments (%s) must be greater or equal than the number of columns of the array.`,o.toString())):ss(o,a,(e,t)=>e>=i.length||t>=i[e].length?r:i[e][t])},isExported:!0},SY={description:N(`Flattens all the values from one or more ranges into a single column.`),args:[H(`range (any, range<any>, repeating)`,N(`The range to flatten.`))],computeArray:function(...e){return[Ss(e,e=>e===void 0?{value:``}:e)]},isExported:!1},CY={description:N(`Calculates the frequency distribution of a range.`),args:[H(`data (range<number>)`,N(`The array of ranges containing the values to be counted.`)),H(`classes (number, range<number>)`,N(`The range containing the set of classes.`))],computeArray:function(e,t){let n=Ss([e],e=>e.value).filter(e=>typeof e==`number`),r=Ss([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=>({value:e.count}))]},isExported:!0},wY={description:N(`Appends ranges horizontally and in sequence to return a larger array.`),args:[H(`range (any, range<any>, repeating)`,N(`The range to be appended.`))],computeArray:function(...e){return mY(e)},isExported:!0},TY={description:N(`Returns the matrix determinant of a square matrix.`),args:[H(`square_matrix (number, range<number>)`,N(`An range with an equal number of rows and columns representing a matrix whose determinant will be calculated.`))],compute:function(e){let t=Wo(e,`square_matrix`);return fS(t)?{value:lg(t).determinant}:new F(N(`The argument square_matrix must have the same number of columns and rows.`))},isExported:!0},EY={description:N(`Returns the multiplicative inverse of a square matrix.`),args:[H(`square_matrix (number, range<number>)`,N(`An range with an equal number of rows and columns representing a matrix whose multiplicative inverse will be calculated.`))],computeArray:function(e){let t=Wo(e,`square_matrix`);if(!fS(t))return new F(N(`The argument square_matrix must have the same number of columns and rows.`));let{inverted:n}=lg(t);return n?cs(n,e=>({value:e})):new F(N(`The matrix is not invertible.`))},isExported:!0},DY={description:N(`Calculates the matrix product of two matrices.`),args:[H(`matrix1 (number, range<number>)`,N(`The first matrix in the matrix multiplication operation.`)),H(`matrix2 (number, range<number>)`,N(`The second matrix in the matrix multiplication operation.`))],computeArray:function(e,t){let n=Wo(e,`matrix1`),r=Wo(t,`matrix2`);return n.length===0||r.length===0?new F(N(`The first and second arguments of [[FUNCTION_NAME]] must be non-empty matrices.`)):n.length===r[0].length?cs(dg(n,r),e=>({value:e})):new F(N(`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},OY={description:N(`Calculates the sum of the products of corresponding entries in equal-sized ranges.`),args:[H(`range (number, range<number>, repeating)`,N(`The range whose entries will be multiplied with corresponding entries in the other range.`))],compute:function(...e){if(!dS(...e))return new F(N(`All the ranges must have the same dimensions.`));let t=e.map(z),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*=I(n[e][r],this.locale);n+=i}return{value:n}},isExported:!0};function kY(e,t,n){if(!dS(e,t))return new F(N(`The arguments array_x and array_y must have the same dimensions.`));let r=z(e),i=z(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 F(N(`The arguments array_x and array_y must contain at least one pair of numbers.`))}let AY={description:N(`Calculates the sum of the difference of the squares of the values in two array.`),args:[H(`array_x (number, range<number>)`,N(`The array or range of values whose squares will be reduced by the squares of corresponding entries in array_y and added together.`)),H(`array_y (number, range<number>)`,N(`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){let n=kY(e,t,(e,t)=>e**2-t**2);return n instanceof F?n:{value:n}},isExported:!0},jY={description:N(`Calculates the sum of the sum of the squares of the values in two array.`),args:[H(`array_x (number, range<number>)`,N(`The array or range of values whose squares will be added to the squares of corresponding entries in array_y and added together.`)),H(`array_y (number, range<number>)`,N(`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){let n=kY(e,t,(e,t)=>e**2+t**2);return n instanceof F?n:{value:n}},isExported:!0},MY={description:N(`Calculates the sum of squares of the differences of values in two array.`),args:[H(`array_x (number, range<number>)`,N(`The array or range of values that will be reduced by corresponding entries in array_y, squared, and added together.`)),H(`array_y (number, range<number>)`,N(`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){let n=kY(e,t,(e,t)=>(e-t)**2);return n instanceof F?n:{value:n}},isExported:!0},NY=[H(`array (any, range<any>)`,N(`The array which will be transformed.`)),H(`ignore (number, default=0)`,N(`Whether to ignore certain types of values. By default, no values are ignored.`),[{value:0,label:N(`Keep all values (default)`)},{value:1,label:N(`Ignore blanks`)},{value:2,label:N(`Ignore errors`)},{value:3,label:N(`Ignore blanks and errors`)}]),H(`scan_by_column (number, default=false)`,N(`Scan the array by column. By default, the array is scanned by row.`),[{value:!1,label:N(`Scan by row (default)`)},{value:!0,label:N(`Scan by column`)}])];function PY(e){let t=Math.trunc(e);if(t===0)return()=>!0;if(t===1)return e=>e.value!==null;if(t===2)return e=>!Lo(e.value);if(t===3)return e=>e.value!==null&&!Lo(e.value);throw new F(N(`Argument ignore must be between 0 and 3`))}let FY={description:N(`Transforms a range of cells into a single column.`),args:NY,computeArray:function(e,t={value:0},n={value:!1}){let r=z(e),i=I(t.value,this.locale),a=(R(n.value)?r:us(r)).flat().filter(PY(i));return a.length===0?new Ao(N(`No results for the given arguments of TOCOL.`)):[a]},isExported:!0},IY={description:N(`Transforms a range of cells into a single row.`),args:NY,computeArray:function(e,t={value:0},n={value:!1}){let r=z(e),i=I(t.value,this.locale),a=(R(n.value)?r:us(r)).flat().filter(PY(i)).map(e=>[e]);return a.length===0||a[0].length===0?new Ao(N(`No results for the given arguments of TOROW.`)):a},isExported:!0},LY={description:N(`Transposes the rows and columns of a range.`),args:[H(`range (any, range<any>)`,N(`The range to be transposed.`))],computeArray:function(e){let t=z(e),n=t[0].length,r=t.length;return ss(n,r,(e,n)=>t[n][e])},isExported:!0},RY={description:N(`Appends ranges vertically and in sequence to return a larger array.`),args:[H(`range (any, range<any>, repeating)`,N(`The range to be appended.`))],computeArray:function(...e){return hY(e)},isExported:!0},zY={description:N(`Wraps the provided row or column of cells by columns after a specified number of elements to form a new array.`),args:[H(`range (any, range<any>)`,N(`The range to wrap.`)),H(`wrap_count (number)`,N(`The maximum number of cells for each column, rounded down to the nearest whole number.`)),H(`pad_with (any, default=0)`,N(`The value with which to fill the extra cells in the range.`))],computeArray:function(e,t,n={value:0}){let r=z(e),i=Ko(t?.value,this.locale);if(!uS(r))return new F(N(`Argument range must be a single row or column.`));if(i<1)return new F(N(`The wrap_count (%s) must be strictly positive.`,i),P.InvalidNumber);let a=r.flat();return ss(Math.ceil(a.length/i),i,(e,t)=>{let r=e*i+t;return r<a.length?a[r]:n})},isExported:!0},BY={description:N(`Wraps the provided row or column of cells by rows after a specified number of elements to form a new array.`),args:[H(`range (any, range<any>)`,N(`The range to wrap.`)),H(`wrap_count (number)`,N(`The maximum number of cells for each row, rounded down to the nearest whole number.`)),H(`pad_with (any, default=0)`,N(`The value with which to fill the extra cells in the range.`))],computeArray:function(e,t,n={value:0}){let r=z(e),i=Ko(t?.value,this.locale);if(!uS(r))return new F(N(`Argument range must be a single row or column.`));if(i<1)return new F(N(`The wrap_count (%s) must be strictly positive.`,i),P.InvalidNumber);let a=r.flat();return ss(i,Math.ceil(a.length/i),(e,t)=>{let r=t*i+e;return r<a.length?a[r]:n})},isExported:!0},VY=[{value:0,label:N(`Concise format\xA0(default)`)},{value:1,label:N(`Strict format`)}],HY={description:N(`returns an array of text values from any specified range. It passes text values unchanged, and converts non-text values to text.`),args:[H(`array (range)`,N(`The array to convert into text`)),H(`format (number, default=0)`,N(`The format of the returned data.`),VY)],compute:function(e,t={value:0}){let n=I(t,this.locale),r=z(e);if(n===1)return{value:JM(r,``,this.locale)};if(n===0){let e=this.locale.decimalSeparator===`,`?`/`:`,`;return{value:us(r).flatMap(e=>e.map(e=>Lo(e.value)?e.value:Jo(e,this.locale))).join(e)}}else return new F(N(`Format must be 0 or 1`))},isExported:!0};var UY=l({ABS:()=>GY,ACOS:()=>KY,ACOSH:()=>qY,ACOT:()=>JY,ACOTH:()=>YY,ASIN:()=>XY,ASINH:()=>ZY,ATAN:()=>QY,ATAN2:()=>$Y,ATANH:()=>eX,CEILING:()=>tX,CEILING_MATH:()=>rX,CEILING_PRECISE:()=>iX,COS:()=>aX,COSH:()=>oX,COT:()=>sX,COTH:()=>cX,COUNTBLANK:()=>lX,COUNTIF:()=>uX,COUNTIFS:()=>dX,COUNTUNIQUE:()=>fX,COUNTUNIQUEIFS:()=>pX,CSC:()=>mX,CSCH:()=>hX,DECIMAL:()=>gX,DEGREES:()=>_X,EXP:()=>vX,FLOOR:()=>yX,FLOOR_MATH:()=>xX,FLOOR_PRECISE:()=>SX,INT:()=>iZ,ISEVEN:()=>CX,ISODD:()=>TX,ISO_CEILING:()=>wX,LN:()=>EX,LOG:()=>DX,MOD:()=>kX,MUNIT:()=>AX,ODD:()=>jX,PI:()=>MX,POWER:()=>NX,PRODUCT:()=>PX,RAND:()=>FX,RANDARRAY:()=>IX,RANDBETWEEN:()=>LX,ROUND:()=>RX,ROUNDDOWN:()=>zX,ROUNDUP:()=>BX,SEC:()=>VX,SECH:()=>HX,SEQUENCE:()=>UX,SIN:()=>WX,SINH:()=>GX,SQRT:()=>KX,SUBTOTAL:()=>XX,SUM:()=>ZX,SUMIF:()=>QX,SUMIFS:()=>$X,TAN:()=>eZ,TANH:()=>tZ,TRUNC:()=>rZ});let WY=/^-?[a-z0-9]+$/i,GY={description:N(`Absolute value of a number.`),args:[H(`value (number)`,N(`The number of which to return the absolute value.`))],compute:function(e){return{value:Math.abs(I(e,this.locale))}},isExported:!0},KY={description:N(`Inverse cosine of a value, in radians.`),args:[H(`value (number)`,N(`The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive.`))],compute:function(e){let t=I(e,this.locale);return Math.abs(t)>1?new F(N(`The value (%s) must be between -1 and 1 inclusive.`,t)):{value:Math.acos(t)}},isExported:!0},qY={description:N(`Inverse hyperbolic cosine of a number.`),args:[H(`value (number)`,N(`The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1.`))],compute:function(e){let t=I(e,this.locale);return t<1?new F(N(`The value (%s) must be greater than or equal to 1.`,t)):{value:Math.acosh(t)}},isExported:!0},JY={description:N(`Inverse cotangent of a value.`),args:[H(`value (number)`,N(`The value for which to calculate the inverse cotangent.`))],compute:function(e){let t=I(e,this.locale);return{value:(Math.sign(t)||1)*Math.PI/2-Math.atan(t)}},isExported:!0},YY={description:N(`Inverse hyperbolic cotangent of a value.`),args:[H(`value (number)`,N(`The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive.`))],compute:function(e){let t=I(e,this.locale);return Math.abs(t)<=1?new F(N(`The value (%s) cannot be between -1 and 1 inclusive.`,t)):{value:Math.log((t+1)/(t-1))/2}},isExported:!0},XY={description:N(`Inverse sine of a value, in radians.`),args:[H(`value (number)`,N(`The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive.`))],compute:function(e){let t=I(e,this.locale);return Math.abs(t)>1?new F(N(`The value (%s) must be between -1 and 1 inclusive.`,t)):{value:Math.asin(t)}},isExported:!0},ZY={description:N(`Inverse hyperbolic sine of a number.`),args:[H(`value (number)`,N(`The value for which to calculate the inverse hyperbolic sine.`))],compute:function(e){return{value:Math.asinh(I(e,this.locale))}},isExported:!0},QY={description:N(`Inverse tangent of a value, in radians.`),args:[H(`value (number)`,N(`The value for which to calculate the inverse tangent.`))],compute:function(e){return{value:Math.atan(I(e,this.locale))}},isExported:!0},$Y={description:N(`Angle from the X axis to a point (x,y), in radians.`),args:[H(`x (number)`,N(`The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.`)),H(`y (number)`,N(`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=I(e,this.locale),r=I(t,this.locale);return n===0&&r===0?new No(N(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:Math.atan2(r,n)}},isExported:!0},eX={description:N(`Inverse hyperbolic tangent of a number.`),args:[H(`value (number)`,N(`The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive.`))],compute:function(e){let t=I(e,this.locale);return Math.abs(t)>=1?new F(N(`The value (%s) must be between -1 and 1 exclusive.`,t)):{value:Math.atanh(t)}},isExported:!0},tX={description:N(`Rounds number up to nearest multiple of factor.`),args:[H(`value (number)`,N(`The value to round up to the nearest integer multiple of factor.`)),H(`factor (number, default=1)`,N(`The number to whose multiples value will be rounded.`))],compute:function(e,t={value:1}){let n=I(e,this.locale),r=I(t,this.locale);return r<0&&n>0?new F(N(`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 nX(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 rX={description:N(`Rounds number up to nearest multiple of factor.`),args:[H(`number (number)`,N(`The value to round up to the nearest integer multiple of significance.`)),H(`significance (number, default=1)`,N(`The number to whose multiples number will be rounded. The sign of significance will be ignored.`)),H(`mode (number, default=0)`,N(`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=I(t,this.locale);return{value:nX(I(e,this.locale),r,I(n,this.locale)),format:e?.format}},isExported:!0},iX={description:N(`Rounds number up to nearest multiple of factor.`),args:[H(`number (number)`,N(`The value to round up to the nearest integer multiple of significance.`)),H(`significance (number, default=1)`,N(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){let n=I(t,this.locale);return{value:nX(I(e,this.locale),n),format:e?.format}},isExported:!0},aX={description:N(`Cosine of an angle provided in radians.`),args:[H(`angle (number)`,N(`The angle to find the cosine of, in radians.`))],compute:function(e){return{value:Math.cos(I(e,this.locale))}},isExported:!0},oX={description:N(`Hyperbolic cosine of any real number.`),args:[H(`value (number)`,N(`Any real value to calculate the hyperbolic cosine of.`))],compute:function(e){return{value:Math.cosh(I(e,this.locale))}},isExported:!0},sX={description:N(`Cotangent of an angle provided in radians.`),args:[H(`angle (number)`,N(`The angle to find the cotangent of, in radians.`))],compute:function(e){let t=I(e,this.locale);return t===0?new No(N(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:1/Math.tan(t)}},isExported:!0},cX={description:N(`Hyperbolic cotangent of any real number.`),args:[H(`value (number)`,N(`Any real value to calculate the hyperbolic cotangent of.`))],compute:function(e){let t=I(e,this.locale);return t===0?new No(N(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:1/Math.tanh(t)}},isExported:!0},lX={description:N(`Number of empty values.`),args:[H(`value (any, range, repeating)`,N(`Value or range in which to count the number of blanks.`))],compute:function(...e){return{value:is(e,(e,t)=>t===void 0||t.value===null||t.value===``?e+1:e,0)}},isExported:!0},uX={description:N(`A conditional count across a range.`),args:[H(`range (range)`,N(`The range that is tested against criterion.`)),H(`criterion (string)`,N(`The pattern or test to apply to range.`))],compute:function(...e){let t=0;return gs(e,(e,n)=>{t+=1},this.locale),{value:t}},isExported:!0},dX={description:N(`Count values depending on multiple criteria.`),args:[H(`criteria_range (any, range, repeating)`,N(`Range over which to evaluate criteria.`)),H(`criterion (string, repeating)`,N(`Criteria to check.`))],compute:function(...e){let t=0;return gs(e,(e,n)=>{t+=1},this.locale),{value:t}},isExported:!0},fX={description:N(`Counts number of unique values in a range.`),args:[H(`value (any, range, repeating)`,N(`Value or range to consider for uniqueness.`))],compute:function(...e){return{value:sS(e)}}},pX={description:N(`Counts number of unique values in a range, filtered by a set of criteria.`),args:[H(`range (range)`,N(`The range of cells from which the number of unique values will be counted.`)),H(`criteria_range (any, range, repeating)`,N(`Range over which to evaluate criteria.`)),H(`criterion (string, repeating)`,N(`Criteria to check.`))],compute:function(e,...t){let n=new Set;return gs(t,(t,r)=>{let i=e[t]?.[r];Cs(i)&&n.add(i.value)},this.locale),{value:n.size}}},mX={description:N(`Cosecant of an angle provided in radians.`),args:[H(`angle (number)`,N(`The angle to find the cosecant of, in radians.`))],compute:function(e){let t=I(e,this.locale);return t===0?new No(N(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:1/Math.sin(t)}},isExported:!0},hX={description:N(`Hyperbolic cosecant of any real number.`),args:[H(`value (number)`,N(`Any real value to calculate the hyperbolic cosecant of.`))],compute:function(e){let t=I(e,this.locale);return t===0?new No(N(`Function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:1/Math.sinh(t)}},isExported:!0},gX={description:N(`Converts from another base to decimal.`),args:[H(`value (string)`,N(`The number to convert.`)),H(`base (number)`,N(`The base to convert the value from.`))],compute:function(e,t){let n=I(t,this.locale);if(n=Math.floor(n),2>n||n>36)return new F(N(`The base (%s) must be between 2 and 36 inclusive.`,n));let r=L(e);if(r===``)return{value:0};if(!WY.test(r))return new F(N(`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 F(N(`The value (%s) must be a valid base %s representation.`,r,n));let a=parseInt(r,n);return isNaN(a)?new F(N(`The value (%s) must be a valid base %s representation.`,r,n)):{value:a}},isExported:!0},_X={description:N(`Converts an angle value in radians to degrees.`),args:[H(`angle (number)`,N(`The angle to convert from radians to degrees.`))],compute:function(e){return{value:I(e,this.locale)*180/Math.PI}},isExported:!0},vX={description:N(`Euler's number, e (~2.718) raised to a power.`),args:[H(`value (number)`,N(`The exponent to raise e.`))],compute:function(e){return{value:Math.exp(I(e,this.locale))}},isExported:!0},yX={description:N(`Rounds number down to nearest multiple of factor.`),args:[H(`value (number)`,N(`The value to round down to the nearest integer multiple of factor.`)),H(`factor (number, default=1)`,N(`The number to whose multiples value will be rounded.`))],compute:function(e,t={value:1}){let n=I(e,this.locale),r=I(t,this.locale);return r<0&&n>0?new F(N(`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 bX(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 xX={description:N(`Rounds number down to nearest multiple of factor.`),args:[H(`number (number)`,N(`The value to round down to the nearest integer multiple of significance.`)),H(`significance (number, default=1)`,N(`The number to whose multiples number will be rounded. The sign of significance will be ignored.`)),H(`mode (number, default=0)`,N(`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=I(t,this.locale);return{value:bX(I(e,this.locale),r,I(n,this.locale)),format:e?.format}},isExported:!0},SX={description:N(`Rounds number down to nearest multiple of factor.`),args:[H(`number (number)`,N(`The value to round down to the nearest integer multiple of significance.`)),H(`significance (number, default=1)`,N(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){let n=I(t,this.locale);return{value:bX(I(e,this.locale),n),format:e?.format}},isExported:!0},CX={description:N(`Whether the provided value is even.`),args:[H(`value (number)`,N(`The value to be verified as even.`))],compute:function(e){let t=Go(e,this.locale);return{value:!(Math.floor(Math.abs(t))&1)}},isExported:!0},wX={description:N(`Rounds number up to nearest multiple of factor.`),args:[H(`number (number)`,N(`The value to round up to the nearest integer multiple of significance.`)),H(`significance (number, default=1)`,N(`The number to whose multiples number will be rounded.`))],compute:function(e,t={value:1}){return{value:nX(I(e,this.locale),I(t,this.locale)),format:e?.format}},isExported:!0},TX={description:N(`Whether the provided value is even.`),args:[H(`value (number)`,N(`The value to be verified as even.`))],compute:function(e){let t=Go(e,this.locale);return{value:!!(Math.floor(Math.abs(t))&1)}},isExported:!0},EX={description:N(`The logarithm of a number, base e (euler's number).`),args:[H(`value (number)`,N(`The value for which to calculate the logarithm, base e.`))],compute:function(e){let t=I(e,this.locale);return t<=0?new F(N(`The value (%s) must be strictly positive.`,t)):{value:Math.log(t)}},isExported:!0},DX={description:N(`The logarithm of a number, for a given base.`),args:[H(`value (number)`,N(`The value for which to calculate the logarithm.`)),H(`base (number, default=10)`,N(`The base of the logarithm.`))],compute:function(e,t={value:10}){let n=I(e,this.locale),r=I(t,this.locale);return n<=0?new F(N(`The value (%s) must be strictly positive.`,n)):r<=0?new F(N(`The base (%s) must be strictly positive.`,r)):r===1?new F(N(`The base must be different from 1.`)):{value:Math.log10(n)/Math.log10(r)}},isExported:!0};function OX(e,t){lS(t,N(`The divisor must be different from 0.`));let n=e%t;return n>0&&t<0||n<0&&t>0?n+t:n}let kX={description:N(`Modulo (remainder) operator.`),args:[H(`dividend (number)`,N(`The number to be divided to find the remainder.`)),H(`divisor (number)`,N(`The number to divide by.`))],compute:function(e,t){let n=I(t,this.locale);return{value:OX(I(e,this.locale),n),format:e?.format}},isExported:!0},AX={description:N(`Returns a n x n unit matrix, where n is the input dimension.`),args:[H(`dimension (number)`,N(`An integer specifying the dimension size of the unit matrix. It must be positive.`))],computeArray:function(e){let t=Ko(e,this.locale);return t<1?new F(N(`The argument dimension must be positive`)):cs(cg(t),e=>({value:e}))},isExported:!0},jX={description:N(`Rounds a number up to the nearest odd integer.`),args:[H(`value (number)`,N(`The value to round to the next greatest odd number.`))],compute:function(e){let t=I(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},MX={description:N(`The number pi.`),args:[],compute:function(){return{value:Math.PI}},isExported:!0},NX={description:N(`A number raised to a power.`),args:[H(`base (number)`,N(`The number to raise to the exponent power.`)),H(`exponent (number)`,N(`The exponent to raise base to.`))],compute:function(e,t){let n=I(e,this.locale),r=I(t,this.locale);return n<0&&!Number.isInteger(r)?new F(N(`The exponent (%s) must be an integer when the base is negative.`,r)):{value:n**+r,format:e?.format}},isExported:!0},PX={description:N(`Result of multiplying a series of numbers together.`),args:[H(`factor (number, range<number>, repeating)`,N(`Number or range to calculate for the product.`))],compute:function(...e){let t=0,n=1;for(let r of e)if(wt(r))for(let e of r)for(let r of e){let e=r.value;if(typeof e==`number`&&(n*=e,t+=1),Lo(e))return r}else r!==void 0&&r.value!==null&&(n*=Go(r,this.locale),t+=1);return{value:t===0?0:n,format:Io(e[0])}},isExported:!0},FX={description:N(`A random number between 0 inclusive and 1 exclusive.`),args:[],compute:function(){return{value:Math.random()}},isExported:!0},IX={description:N(`Returns a grid of random numbers between 0 inclusive and 1 exclusive.`),args:[H(`rows (number, default=1)`,N(`The number of rows to be returned.`)),H(`columns (number, default=1)`,N(`The number of columns to be returned.`)),H(`min (number, default=0)`,N(`The minimum number you would like returned.`)),H(`max (number, default=1)`,N(`The maximum number you would like returned.`)),H(`whole_number (boolean, default=FALSE)`,N(`Return a whole number or a decimal value.`),[{value:!1,label:N(`Decimal (default)`)},{value:!0,label:N(`Integer`)}])],computeArray:function(e={value:1},t={value:1},n={value:0},r={value:1},i={value:!1}){let a=Ko(t,this.locale),o=Ko(e,this.locale),s=I(n,this.locale),c=I(r,this.locale),l=R(i);if(a<1)return new F(N(`The number of columns (%s) must be positive.`,a));if(o<1)return new F(N(`The number of rows (%s) must be positive.`,o));if(s>c)return new F(N(`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 F(N(`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 cs(u,e=>({value:e}))},isExported:!0},LX={description:N(`Random integer between two values, inclusive.`),args:[H(`low (number)`,N(`The low end of the random range.`)),H(`high (number)`,N(`The high end of the random range.`))],compute:function(e,t){let n=I(e,this.locale);Number.isInteger(n)||(n=Math.ceil(n));let r=I(t,this.locale);return Number.isInteger(r)||(r=Math.floor(r)),n>r?new F(N(`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},RX={description:N(`Rounds a number according to standard rules.`),args:[H(`value (number)`,N(`The value to round to places number of places.`)),H(`places (number, default=0)`,N(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=I(e,this.locale),r=I(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},zX={description:N(`Rounds down a number.`),args:[H(`value (number)`,N(`The value to round to places number of places, always rounding down.`)),H(`places (number, default=0)`,N(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=I(e,this.locale),r=I(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},BX={description:N(`Rounds up a number.`),args:[H(`value (number)`,N(`The value to round to places number of places, always rounding up.`)),H(`places (number, default=0)`,N(`The number of decimal places to which to round.`))],compute:function(e,t={value:0}){let n=I(e,this.locale),r=I(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},VX={description:N(`Secant of an angle provided in radians.`),args:[H(`angle (number)`,N(`The angle to find the secant of, in radians.`))],compute:function(e){return{value:1/Math.cos(I(e,this.locale))}},isExported:!0},HX={description:N(`Hyperbolic secant of any real number.`),args:[H(`value (number)`,N(`Any real value to calculate the hyperbolic secant of.`))],compute:function(e){return{value:1/Math.cosh(I(e,this.locale))}},isExported:!0},UX={description:N(`Returns a sequence of numbers.`),args:[H(`rows (number)`,N(`The number of rows to return`)),H(`columns (number, optional, default=1)`,N(`The number of columns to return`)),H(`start (number, optional, default=1)`,N(`The first number in the sequence`)),H(`step (number, optional, default=1)`,N(`The amount to increment each value in the sequence`))],computeArray:function(e,t={value:1},n={value:1},r={value:1}){let i=I(n,this.locale),a=I(r,this.locale),o=Ko(e,this.locale),s=Ko(t,this.locale);return s<1?new F(N(`The number of columns (%s) must be positive.`,s)):o<1?new F(N(`The number of rows (%s) must be positive.`,o)):ss(s,o,(e,t)=>({value:i+t*s*a+e*a}))},isExported:!0},WX={description:N(`Sine of an angle provided in radians.`),args:[H(`angle (number)`,N(`The angle to find the sine of, in radians.`))],compute:function(e){return{value:Math.sin(I(e,this.locale))}},isExported:!0},GX={description:N(`Hyperbolic sine of any real number.`),args:[H(`value (number)`,N(`Any real value to calculate the hyperbolic sine of.`))],compute:function(e){return{value:Math.sinh(I(e,this.locale))}},isExported:!0},KX={description:N(`Positive square root of a positive number.`),args:[H(`value (number)`,N(`The number for which to calculate the positive square root.`))],compute:function(e){let t=I(e,this.locale);return t<0?new F(N(`The value (%s) must be positive or null.`,t)):{value:Math.sqrt(t),format:e?.format}},isExported:!0},qX={1:`AVERAGE`,2:`COUNT`,3:`COUNTA`,4:`MAX`,5:`MIN`,6:`PRODUCT`,7:`STDEV`,8:`STDEVP`,9:`SUM`,10:`VAR`,11:`VARP`},JX=Object.entries(qX).map(([e,t])=>({value:parseInt(e),label:N(`%s (include manually-hidden rows)`,t)})),YX=Object.entries(qX).map(([e,t])=>({value:parseInt(e)+100,label:N(`%s (exclude manually-hidden rows)`,t)})),XX={description:N(`Returns a subtotal for a vertical range of cells using a specified aggregation function.`),args:[H(`function_code (number)`,N(`The function to use in subtotal aggregation.`),[...JX,...YX]),H(`ref (any, range<any>, repeating)`,N(`Range or reference for which you want the subtotal.`))],compute:function(e,...t){let n=Ko(e,this.locale),r=!0;if(n>100&&(n-=100,r=!1),n<1||n>11)return new F(N(`The function code (%s) must be between 1 to 11 or 101 to 111.`,n));let i=[];for(let e of t){let t=z(e),n=t[0][0]?.position;if(n===void 0)return new ko(Bo);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||!kn(n,`SUBTOTAL`))&&i.push(this.getFormulaResult({sheetId:s,col:t,row:e}))}}let a=qX[n],o=[i];return fg(nl(ul.get(a),o.length)(this,o))},isExported:!0},ZX={description:N(`Sum of a series of numbers and/or cells.`),args:[H(`value (number, range<number>, repeating)`,N(`Number or range to add together.`))],compute:function(...e){let t=e[0];return{value:oS(e,this.locale),format:Io(t)}},isExported:!0},QX={description:N(`A conditional sum across a range.`),args:[H(`criteria_range (range)`,N(`The range which is tested against criterion.`)),H(`criterion (string)`,N(`The pattern or test to apply to range.`)),H(`sum_range (range, default=criteria_range)`,N(`The range to be summed, if different from range.`))],compute:function(e,t,n){n===void 0&&(n=e);let r=0;return gs([e,t],(e,t)=>{let i=n[e]?.[t]?.value;typeof i==`number`&&(r+=i)},this.locale),{value:r}},isExported:!0},$X={description:N(`Sums a range depending on multiple criteria.`),args:[H(`sum_range (range)`,N(`The range to sum.`)),H(`criteria_range (any, range, repeating)`,N(`Range to check.`)),H(`criterion (string, repeating)`,N(`Criteria to check.`))],compute:function(e,...t){let n=0;return gs(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n+=i)},this.locale),{value:n}},isExported:!0},eZ={description:N(`Tangent of an angle provided in radians.`),args:[H(`angle (number)`,N(`The angle to find the tangent of, in radians.`))],compute:function(e){return{value:Math.tan(I(e,this.locale))}},isExported:!0},tZ={description:N(`Hyperbolic tangent of any real number.`),args:[H(`value (number)`,N(`Any real value to calculate the hyperbolic tangent of.`))],compute:function(e){return{value:Math.tanh(I(e,this.locale))}},isExported:!0};function nZ(e,t){return t===0?Math.trunc(e):(Number.isInteger(t)||(t=Math.trunc(t)),Math.trunc(e*10**t)/10**t)}let rZ={description:N(`Truncates a number.`),args:[H(`value (number)`,N(`The value to be truncated.`)),H(`places (number, default=0)`,N(`The number of significant digits to the right of the decimal point to retain.`))],compute:function(e,t={value:0}){return{value:nZ(I(e,this.locale),I(t,this.locale)),format:e?.format}},isExported:!0},iZ={description:N(`Rounds a number down to the nearest integer that is less than or equal to it.`),args:[H(`value (number)`,N(`The number to round down to the nearest integer.`))],compute:function(e){return{value:Math.floor(I(e,this.locale))}},isExported:!0};var aZ=l({AVEDEV:()=>hZ,AVERAGE:()=>gZ,AVERAGEA:()=>bZ,AVERAGEIF:()=>xZ,AVERAGEIFS:()=>SZ,AVERAGE_WEIGHTED:()=>yZ,CHISQ_DIST_RT:()=>OZ,CHISQ_TEST:()=>kZ,CONFIDENCE_NORM:()=>AZ,CONFIDENCE_T:()=>jZ,CORREL:()=>QZ,COUNT:()=>CZ,COUNTA:()=>wZ,COVAR:()=>TZ,COVARIANCE_P:()=>EZ,COVARIANCE_S:()=>DZ,FORECAST:()=>NZ,F_TEST:()=>MZ,GEOMEAN:()=>PZ,GROWTH:()=>FZ,HARMEAN:()=>IZ,INTERCEPT:()=>LZ,KURT:()=>RZ,LARGE:()=>zZ,LINEST:()=>BZ,LOGEST:()=>VZ,MATTHEWS:()=>HZ,MAX:()=>UZ,MAXA:()=>WZ,MAXIFS:()=>GZ,MEDIAN:()=>KZ,MIN:()=>qZ,MINA:()=>JZ,MINIFS:()=>YZ,PEARSON:()=>ZZ,PERCENTILE:()=>$Z,PERCENTILE_EXC:()=>eQ,PERCENTILE_INC:()=>tQ,POLYFIT_COEFFS:()=>nQ,POLYFIT_FORECAST:()=>rQ,QUARTILE:()=>iQ,QUARTILE_EXC:()=>aQ,QUARTILE_INC:()=>oQ,RANK:()=>sQ,RSQ:()=>cQ,SKEW:()=>uQ,SKEW_P:()=>dQ,SLOPE:()=>lQ,SMALL:()=>fQ,SPEARMAN:()=>pQ,STDEV:()=>mQ,STDEVA:()=>_Q,STDEVP:()=>vQ,STDEVPA:()=>yQ,STDEV_P:()=>hQ,STDEV_S:()=>gQ,STEYX:()=>xQ,TREND:()=>SQ,TRIMMEAN:()=>CQ,T_TEST:()=>bQ,VAR:()=>wQ,VARA:()=>DQ,VARP:()=>OQ,VARPA:()=>kQ,VAR_P:()=>TQ,VAR_S:()=>EQ});let oZ=[{value:!0,label:N(`b is calculated normally`)},{value:!1,label:N(`b is forced to 1`)}],sZ=[{value:!1,label:N(`do not return additional regression statistics`)},{value:!0,label:N(`return additional regression statistics`)}],cZ=[{value:1,label:N(`order 1 (Linear)`)},{value:2,label:N(`order 2 (Quadratic)`)},{value:3,label:N(`order 3 (Cubic)`)},{value:4,label:N(`order 4 (Quartic)`)},{value:5,label:N(`order 5 (Quintic)`)},{value:6,label:N(`order 6 (Sextic)`)}],lZ=[{value:!0,label:N(`Compute intercept`)},{value:!1,label:N(`Force intercept to 0`)}],uZ=[{value:0,label:N(`Minimum value`)},{value:1,label:N(`First quartile (25th percentile)`)},{value:2,label:N(`Median value (50th percentile)`)},{value:3,label:N(`Third quartile (75th percentile)`)},{value:4,label:N(`Maximum value`)}];function dZ(e,t){let n=[],r=[],i=0,a=0;ts([e],e=>{n.push(e),i+=1}),ts([t],e=>{r.push(e),a+=1}),cS(i===a,N(`[[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 fZ(e,t,n){let{flatDataX:r,flatDataY:i}=dZ(e,t),a=i.length;lS(a),n&&lS(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 pZ(e,t,n,r){let i=0,a=n?os:as,o=a(e,(e,t)=>(i+=1,e+t),0,r);lS(i),t&&lS(i-1);let s=o/i;return a(e,(e,t)=>e+(t-s)**2,0,r)/(i-+!!t)}function mZ(e,t,n,r){let i=I(t,r);cS(n?0<=i&&i<=1:0<i&&i<1,N(`Function [[FUNCTION_NAME]] parameter 2 value is out of range.`));let a=[],o,s=0;return ts(e,e=>{let t=e?.value;typeof t==`number`&&(o=_s(a,e,`nextSmaller`,`asc`,a.length,(e,t)=>e[t]),a.splice(o+1,0,t),s++)}),cS(s!==0,ws),n||cS(1/(s+1)<=i&&i<=s/(s+1),N(`Function [[FUNCTION_NAME]] parameter 2 value is out of range.`)),_o(a,i,n)}let hZ={description:N(`Average magnitude of deviations from mean.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the sample.`))],compute:function(...e){let t=0,n=as(e,(e,n)=>(t+=1,e+n),0,this.locale);if(t===0)return new No(N(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`));let r=n/t;return{value:as(e,(e,t)=>e+Math.abs(r-t),0,this.locale)/t}},isExported:!0},gZ={description:N(`Numerical average value in a dataset, ignoring text.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to consider when calculating the average value.`))],compute:function(...e){return{value:hS(e,this.locale),format:Io(e[0])}},isExported:!0},_Z=N(`[[FUNCTION_NAME]] has mismatched range sizes.`),vZ=N(`[[FUNCTION_NAME]] expects the weight to be positive or equal to 0.`),yZ={description:N(`Weighted average.`),args:[H(`values (number, range<number>, repeating)`,N(`Value to average.`)),H(`weights (number, range<number>, repeating)`,N(`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(!dS(i,a))return new F(_Z);if(wt(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=wt(a)?a?.[e][r].value:I(a,this.locale),c=typeof o==`number`,l=typeof s==`number`;if(c&&l){if(s<0)return new F(vZ);t+=o*s,n+=s;continue}if(c!==l)return new F(N(`[[FUNCTION_NAME]] expects number values.`))}else{let e=I(i,this.locale),r=wt(a)?a?.[0][0].value:I(a,this.locale);if(typeof r==`number`){if(r<0)return new F(vZ);t+=e*r,n+=r}}}return n===0?new No(N(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:t/n,format:Io(e[0])}}},bZ={description:N(`Numerical average value in a dataset.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to consider when calculating the average value.`))],compute:function(...e){let t=0,n=os(e,(e,n)=>(t+=1,e+n),0,this.locale);return t===0?new No(N(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:n/t,format:Io(e[0])}},isExported:!0},xZ={description:N(`Average of values depending on criteria.`),args:[H(`criteria_range (number, range<number>)`,N(`The range to check against criterion.`)),H(`criterion (string)`,N(`The pattern or test to apply to criteria_range.`)),H(`average_range (number, range<number>, default=criteria_range)`,N(`The range to average. If not included, criteria_range is used for the average instead.`))],compute:function(e,t,n){let r=z(n===void 0?e:n),i=0,a=0;return gs([e,t],(e,t)=>{let n=r[e]?.[t]?.value;typeof n==`number`&&(i+=1,a+=n)},this.locale),i===0?new No(N(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:a/i}},isExported:!0},SZ={description:N(`Average of values depending on multiple criteria.`),args:[H(`average_range (range)`,N(`The range to average.`)),H(`criteria_range (any, range, repeating)`,N(`Range to check.`)),H(`criterion (string, repeating)`,N(`Criterion to check.`))],compute:function(e,...t){let n=z(e),r=0,i=0;return gs(t,(e,t)=>{let a=n[e]?.[t]?.value;typeof a==`number`&&(r+=1,i+=a)},this.locale),r===0?new No(N(`Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.`)):{value:i/r}},isExported:!0},CZ={description:N(`The number of numeric values in dataset.`),args:[H(`value (number, any, range<number>, repeating)`,N(`Value or range to consider when counting.`))],compute:function(...e){return{value:_S(e,this.locale)}},isExported:!0},wZ={description:N(`The number of values in a dataset.`),args:[H(`value (any, range, repeating)`,N(`Value or range to consider when counting.`))],compute:function(...e){return{value:vS(e)}},isExported:!0},TZ={description:N(`The covariance of a dataset.`),args:[H(`data_y (any, range)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (any, range)`,N(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return{value:fZ(e,t,!1)}},isExported:!0},EZ={description:N(`The covariance of a dataset.`),args:[H(`data_y (any, range)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (any, range)`,N(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return{value:fZ(e,t,!1)}},isExported:!0},DZ={description:N(`The sample covariance of a dataset.`),args:[H(`data_y (any, range)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (any, range)`,N(`The range representing the array or matrix of independent data.`))],compute:function(e,t){return{value:fZ(e,t,!0)}},isExported:!0},OZ={description:N(`Upper tail of the chi-square distribution.`),args:[H(`x (number)`,N(`The value to evaluate.`)),H(`degrees_of_freedom (number)`,N(`The degrees of freedom.`))],compute:function(e,t){let n=I(e,this.locale),r=Math.round(I(t,this.locale));return cS(n>=0,N(`x must be non-negative.`)),cS(r>=1,N(`Degrees of freedom must be >= 1.`)),{value:jS(r/2,n/2)}},isExported:!0},kZ={description:N(`Returns the p-value of a chi-square test for independence, comparing actual to expected values.`),args:[H(`actual_range (range<number>)`,N(`The range containing the observed values.`)),H(`expected_range (range<number>)`,N(`The range containing the expected values.`))],compute:function(e,t){cS(dS(e,t),N(`The two ranges must have the same dimensions.`));let n=Wo(e,`actual_range`),r=Wo(t,`expected_range`),i=n.length,a=n[0]?.length??0;cS(i*a>0,ws);let o=0;for(let e=0;e<i;e++)for(let t=0;t<a;t++){let i=r[e][t];lS(i);let a=n[e][t]-i;o+=a*a/i}let s;return s=a>1&&i>1?(a-1)*(i-1):a===1?i-1:a-1,cS(s>=1,N(`The ranges must contain at least 2 values.`)),{value:jS(s/2,o/2)}},isExported:!0},AZ={description:N(`Half-width of the confidence interval for a population mean (normal distribution).`),args:[H(`alpha (number)`,N(`The significance level (e.g. 0.05 for 95% CI).`)),H(`standard_deviation (number)`,N(`The population standard deviation.`)),H(`size (number)`,N(`The sample size.`))],compute:function(e,t,n){let r=I(e,this.locale),i=I(t,this.locale),a=Math.round(I(n,this.locale));return cS(r>0&&r<1,N(`Alpha must be between 0 and 1.`)),cS(i>0,N(`Standard deviation must be positive.`)),cS(a>=1,N(`Size must be >= 1.`)),{value:-PS(r/2)*i/Math.sqrt(a)}},isExported:!0},jZ={description:N(`Half-width of the confidence interval for a population mean (t-distribution).`),args:[H(`alpha (number)`,N(`The significance level (e.g. 0.05 for 95% CI).`)),H(`standard_deviation (number)`,N(`The sample standard deviation.`)),H(`size (number)`,N(`The sample size.`))],compute:function(e,t,n){let r=I(e,this.locale),i=I(t,this.locale),a=Math.round(I(n,this.locale));return cS(r>0&&r<1,N(`Alpha must be between 0 and 1.`)),cS(i>0,N(`Standard deviation must be positive.`)),cS(a>=2,N(`Size must be >= 2.`)),{value:IS(r,a-1)*i/Math.sqrt(a)}},isExported:!0},MZ={description:N(`Returns the two-tailed p-value of an F-test comparing the variances of two datasets.`),args:[H(`range1 (range<number>)`,N(`The first sample.`)),H(`range2 (range<number>)`,N(`The second sample.`))],compute:function(e,t){let n=[],r=[];ns([e],e=>n.push(e.value),this.locale),ns([t],e=>r.push(e.value),this.locale);let i=n.length,a=r.length;cS(i>=2&&a>=2,N(`Each range must contain at least 2 numeric values.`));let o=n.reduce((e,t)=>e+t,0)/i,s=r.reduce((e,t)=>e+t,0)/a,c=n.reduce((e,t)=>e+(t-o)**2,0)/(i-1),l=r.reduce((e,t)=>e+(t-s)**2,0)/(a-1);lS(c),lS(l);let u=c/l,d=i-1,f=a-1,p=MS(d*u/(d*u+f),d/2,f/2);return{value:2*Math.min(p,1-p)}},isExported:!0},NZ={description:N(`Calculates the expected y-value for a specified x based on a linear regression of a dataset.`),args:[H(`x (number, range<number>)`,N(`The value(s) on the x-axis to forecast.`)),H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>)`,N(`The range representing the array or matrix of independent data.`))],computeArray:function(e,t,n){let{flatDataX:r,flatDataY:i}=dZ(t,n);return r.length===0||i.length===0?new Ao(ws):cs(OS([i],[r],cs(z(e),e=>I(e,this.locale)),!0),e=>({value:e}))},isExported:!0},PZ={description:N(`Geometric mean of a dataset.`),args:[H(`value (number, range<number>, repeating)`,N(`Values to include.`))],compute:function(...e){let t=0,n=0;return ns(e,e=>{cS(e.value>0,N(`GEOMEAN requires strictly positive values.`)),t+=Math.log(e.value),n++},this.locale),cS(n>0,ws),{value:Math.exp(t/n)}},isExported:!0},FZ={description:N(`Fits points to exponential growth trend.`),args:[H(`known_data_y (range<number>)`,N(`The array or range containing dependent (y) values that are already known, used to curve fit an ideal exponential growth curve.`)),H(`known_data_x (range<number>, default={1;2;3;...})`,N(`The values of the independent variable(s) corresponding with known_data_y.`)),H(`new_data_x (any, range, default=known_data_x)`,N(`The data points to return the y values for on the ideal curve fit.`)),H(`b (boolean, default=TRUE)`,N(`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.`),oZ)],computeArray:function(e,t=[[]],n=[[]],r={value:!0}){return e.length===0||e[0].length===0?new F(Ts(`known_data_y`)):cs(ES(OS(DS(Wo(e,`known_data_y`)),Wo(t,`known_data_x`),Wo(n,`new_data_y`),R(r))),e=>({value:e}))}},IZ={description:N(`Harmonic mean of a dataset.`),args:[H(`value (number, range<number>, repeating)`,N(`Values to include.`))],compute:function(...e){let t=0,n=0;return ns(e,e=>{cS(e.value>0,N(`HARMEAN requires strictly positive values.`)),t+=1/e.value,n++},this.locale),cS(n>0,ws),{value:n/t}},isExported:!0},LZ={description:N(`Compute the intercept of the linear regression.`),args:[H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>)`,N(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=dZ(e,t);if(n.length===0||r.length===0)return new Ao(ws);let[[],[i]]=SS([n],[r]);return{value:i}},isExported:!0},RZ={description:N(`Excess kurtosis of a dataset.`),args:[H(`value (number, range<number>, repeating)`,N(`Values to include.`))],compute:function(...e){let t=[];ns(e,e=>t.push(e.value),this.locale);let n=t.length;cS(n>=4,N(`KURT requires at least 4 values.`));let r=t.reduce((e,t)=>e+t,0)/n,i=t.reduce((e,t)=>e+(t-r)**2,0)/(n-1);cS(i>0,N(`KURT requires non-constant data.`));let a=Math.sqrt(i),o=t.reduce((e,t)=>e+((t-r)/a)**4,0);return{value:n*(n+1)/((n-1)*(n-2)*(n-3))*o-3*(n-1)**2/((n-2)*(n-3))}},isExported:!0},zZ={description:N(`Nth largest element from a data set.`),args:[H(`data (any, range)`,N(`Array or range containing the dataset to consider.`)),H(`n (number)`,N(`The rank from largest to smallest of the element to return.`))],compute:function(e,t){let n=Math.trunc(I(t?.value,this.locale)),r=[],i,a=0;ts([e],e=>{typeof e?.value==`number`&&(i=_s(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 F(ws):a<n?new F(N(`Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.`,n)):o},isExported:!0},BZ={description:N(`Given partial data about a linear trend, calculates various parameters about the ideal linear trend using the least-squares method.`),args:[H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>, default={1;2;3;...})`,N(`The range representing the array or matrix of independent data.`)),H(`calculate_b (boolean, default=TRUE)`,N(`A flag specifying whether to compute the slope or not`),oZ),H(`verbose (boolean, default=FALSE)`,N(`A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept`),sZ)],computeArray:function(e,t=[[]],n={value:!0},r={value:!1}){return e.length===0||e[0].length===0?new F(Ts(`data_y`)):cs(SS(Wo(t,`data_x`),Wo(e,`data_y`),R(n),R(r)),e=>({value:e}))},isExported:!0},VZ={description:N(`Given partial data about an exponential growth curve, calculates various parameters about the best fit ideal exponential growth curve.`),args:[H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>, optional, default={1;2;3;...})`,N(`The range representing the array or matrix of independent data.`)),H(`calculate_b (boolean, default=TRUE)`,N(`A flag specifying whether to compute the slope or not`),oZ),H(`verbose (boolean, default=FALSE)`,N(`A flag specifying whether to return additional regression statistics or only the linear coefficients and the y-intercept`),sZ)],computeArray:function(e,t=[[]],n={value:!0},r={value:!1}){if(e.length===0||e[0].length===0)return new F(Ts(`data_y`));let i=SS(Wo(t,`data_x`),DS(Wo(e,`data_y`)),R(n),R(r));for(let e=0;e<i.length;e++)i[e][0]=Math.exp(i[e][0]);return cs(i,e=>({value:e}))},isExported:!0},HZ={description:N(`Compute the Matthews correlation coefficient of a dataset.`),args:[H(`data_x (range)`,N(`The range representing the array or matrix of observed data.`)),H(`data_y (range)`,N(`The range representing the array or matrix of predicted data.`))],compute:function(e,t){let n=e.flat(),r=t.flat();if(mS(n,r),n.length===0||r.length===0)return new Ao(ws);let i=n.length,a=0,o=0,s=0,c=0;for(let e=0;e<i;++e){let t=R(n[e]);t===R(r[e])?t?o++:a++:t?c++:s++}return{value:(o*a-s*c)/Math.sqrt((o+s)*(o+c)*(a+s)*(a+c))}},isExported:!1},UZ={description:N(`Maximum value in a numeric dataset.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to consider when calculating the maximum value.`))],compute:function(...e){return yS(e,this.locale)},isExported:!0},WZ={description:N(`Maximum numeric value in a dataset.`),args:[H(`value (any, range, repeating)`,N(`Value or range to consider when calculating the maximum value.`))],compute:function(...e){let t=os(e,(e,t)=>Math.max(t,e),-1/0,this.locale);return{value:t===-1/0?0:t,format:Io(e[0])}},isExported:!0},GZ={description:N(`Returns the maximum value in a range of cells, filtered by a set of criteria.`),args:[H(`range (range)`,N(`The range of cells from which the maximum will be determined.`)),H(`criteria_range (any, range, repeating)`,N(`Range to evaluate criteria.`)),H(`criterion (string, repeating)`,N(`Criteria to check.`))],compute:function(e,...t){let n=-1/0;return gs(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n=n<i?i:n)},this.locale),{value:n===-1/0?0:n}},isExported:!0},KZ={description:N(`Median value in a numeric dataset.`),args:[H(`value (any, range, repeating)`,N(`Value or range to consider when calculating the median value.`))],compute:function(...e){let t=[];return ns(e,e=>{t.push(e)},this.locale),{value:mZ(t,{value:.5},!0,this.locale),format:Io(t[0])}},isExported:!0},qZ={description:N(`Minimum value in a numeric dataset.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to consider when calculating the minimum value.`))],compute:function(...e){return bS(e,this.locale)},isExported:!0},JZ={description:N(`Minimum numeric value in a dataset.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to consider when calculating the minimum value.`))],compute:function(...e){let t=os(e,(e,t)=>Math.min(t,e),1/0,this.locale);return{value:t===1/0?0:t,format:Io(e[0])}},isExported:!0},YZ={description:N(`Returns the minimum value in a range of cells, filtered by a set of criteria.`),args:[H(`range (range)`,N(`The range of cells from which the minimum will be determined.`)),H(`criteria_range (any, range, repeating)`,N(`Range to evaluate criteria.`)),H(`criterion (string, repeating)`,N(`Criterion to check.`))],compute:function(e,...t){let n=1/0;return gs(t,(t,r)=>{let i=e[t]?.[r]?.value;typeof i==`number`&&(n=n>i?i:n)},this.locale),{value:n===1/0?0:n}},isExported:!0};function XZ(e,t){let{flatDataX:n,flatDataY:r}=dZ(e,t);if(n.length===0||r.length===0)return new Ao(ws);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 No:(i*s-a*o)/u}let ZZ={description:N(`Compute the Pearson product-moment correlation coefficient of a dataset.`),args:[H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>)`,N(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let n=XZ(e,t);return n instanceof No||n instanceof Ao?n:{value:n}},isExported:!0},QZ=ZZ,$Z={description:N(`Value at a given percentile of a dataset.`),args:[H(`data (any, range)`,N(`The array or range containing the dataset to consider.`)),H(`percentile (number)`,N(`The percentile whose value within data will be calculated and returned.`))],compute:function(e,t){return tQ.compute.bind(this)(e,t)},isExported:!0},eQ={description:N(`Value at a given percentile of a dataset exclusive of 0 and 1.`),args:[H(`data (any, range)`,N(`The array or range containing the dataset to consider.`)),H(`percentile (number)`,N(`The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned.`))],compute:function(e,t){return{value:mZ([e],t,!1,this.locale),format:Io(e)}},isExported:!0},tQ={description:N(`Value at a given percentile of a dataset.`),args:[H(`data (any, range)`,N(`The array or range containing the dataset to consider.`)),H(`percentile (number)`,N(`The percentile whose value within data will be calculated and returned.`))],compute:function(e,t){return{value:mZ([e],t,!0,this.locale),format:Io(e)}},isExported:!0},nQ={description:N(`Compute the coefficients of polynomial regression of the dataset.`),args:[H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>)`,N(`The range representing the array or matrix of independent data.`)),H(`order (number)`,N(`The order of the polynomial to fit the data, between 1 and 6.`),cZ),H(`intercept (boolean, default=TRUE)`,N(`A flag specifying whether to compute the intercept or not.`),lZ)],computeArray:function(e,t,n,r={value:!0}){let{flatDataX:i,flatDataY:a}=dZ(e,t);return i.length===0||a.length===0?new Ao(ws):cs(CS(a,i,I(n,this.locale),R(r)),e=>({value:e}))},isExported:!1},rQ={description:N(`Predict value by computing a polynomial regression of the dataset.`),args:[H(`x (number, range<number>)`,N(`The value(s) on the x-axis to forecast.`)),H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>)`,N(`The range representing the array or matrix of independent data.`)),H(`order (number)`,N(`The order of the polynomial to fit the data, between 1 and 6.`),cZ),H(`intercept (boolean, default=TRUE)`,N(`A flag specifying whether to compute the intercept or not.`),lZ)],computeArray:function(e,t,n,r,i={value:!0}){let a=I(r,this.locale),{flatDataX:o,flatDataY:s}=dZ(t,n);if(o.length===0||s.length===0)return new Ao(ws);let c=CS(s,o,a,R(i)).flat();return cs(z(e),e=>({value:TS(c,I(e,this.locale),a)}))},isExported:!1},iQ={description:N(`Value nearest to a specific quartile of a dataset.`),args:[H(`data (any, range)`,N(`The array or range containing the dataset to consider.`)),H(`quartile_number (number)`,N(`Which quartile value to return.`),uZ)],compute:function(e,t){return oQ.compute.bind(this)(e,t)},isExported:!0},aQ={description:N(`Value nearest to a specific quartile of a dataset exclusive of 0 and 4.`),args:[H(`data (any, range)`,N(`The array or range containing the dataset to consider.`)),H(`quartile_number (number)`,N(`Which quartile value, exclusive of 0 and 4, to return.`),[{value:1,label:N(`First quartile (25th percentile)`)},{value:2,label:N(`Median value (50th percentile)`)},{value:3,label:N(`Third quartile (75th percentile)`)}])],compute:function(e,t){let n={value:.25*Math.trunc(I(t,this.locale))};return{value:mZ([e],n,!1,this.locale),format:Io(e)}},isExported:!0},oQ={description:N(`Value nearest to a specific quartile of a dataset.`),args:[H(`data (any, range)`,N(`The array or range containing the dataset to consider.`)),H(`quartile_number (number)`,N(`Which quartile value to return.`),uZ)],compute:function(e,t){let n={value:.25*Math.trunc(I(t,this.locale))};return{value:mZ([e],n,!0,this.locale),format:Io(e)}},isExported:!0},sQ={description:N(`Returns the rank of a specified value in a dataset.`),args:[H(`value (number)`,N(`The value whose rank will be determined.`)),H(`data (range)`,N(`The range containing the dataset to consider.`)),H(`is_ascending (boolean, default=FALSE)`,N(`Whether to consider the values in data in descending or ascending order.`),[{value:!1,label:N(`Descending`)},{value:!0,label:N(`Ascending`)}])],compute:function(e,t,n={value:!1}){let r=R(n),i=I(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=I(t,this.locale);e===i?o=!0:e>i!==r&&a++}return o?{value:a}:new Ao(N(`Value not found in the given data.`))},isExported:!0},cQ={description:N(`Compute the square of r, the Pearson product-moment correlation coefficient of a dataset.`),args:[H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>)`,N(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let n=XZ(e,t);return n instanceof No||n instanceof Ao?n:{value:n**2}},isExported:!0},lQ={description:N(`Compute the slope of the linear regression.`),args:[H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>)`,N(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=dZ(e,t);if(n.length===0||r.length===0)return new Ao(ws);let[[i]]=SS([n],[r]);return{value:i}},isExported:!0},uQ={description:N(`Skewness of a dataset.`),args:[H(`value (number, range<number>, repeating)`,N(`Values to include.`))],compute:function(...e){let t=[];ns(e,e=>t.push(e.value),this.locale);let n=t.length;cS(n>=3,N(`SKEW requires at least 3 values.`));let r=t.reduce((e,t)=>e+t,0)/n,i=t.reduce((e,t)=>e+(t-r)**2,0)/(n-1);cS(i>0,N(`SKEW requires non-constant data.`));let a=Math.sqrt(i),o=t.reduce((e,t)=>e+((t-r)/a)**3,0);return{value:n/((n-1)*(n-2))*o}},isExported:!0},dQ={description:N(`Population skewness of a dataset.`),args:[H(`value (number, range<number>, repeating)`,N(`Values to include.`))],compute:function(...e){let t=[];ns(e,e=>t.push(e.value),this.locale);let n=t.length;cS(n>=3,N(`SKEW.P requires at least 3 values.`));let r=t.reduce((e,t)=>e+t,0)/n,i=t.reduce((e,t)=>e+(t-r)**2,0)/n;cS(i>0,N(`SKEW.P requires non-constant data.`));let a=Math.sqrt(i);return{value:t.reduce((e,t)=>e+((t-r)/a)**3,0)/n}},isExported:!0},fQ={description:N(`Nth smallest element in a data set.`),args:[H(`data (any, range)`,N(`The array or range containing the dataset to consider.`)),H(`n (number)`,N(`The rank from smallest to largest of the element to return.`))],compute:function(e,t){let n=Math.trunc(I(t?.value,this.locale)),r=[],i,a=0;ts([e],e=>{typeof e?.value==`number`&&(i=_s(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 F(ws):a<n?new F(N(`Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.`,n)):o},isExported:!0},pQ={description:N(`Compute the Spearman rank correlation coefficient of a dataset.`),args:[H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>)`,N(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=dZ(t,e);if(n.length===0||r.length===0)return new Ao(ws);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{value:1-6*o/(i**3-i)}},isExported:!1},mQ={description:N(`Standard deviation.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the sample.`))],compute:function(...e){return{value:Math.sqrt(wQ.compute.bind(this)(...e).value)}},isExported:!0},hQ={description:N(`Standard deviation of entire population.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the population.`))],compute:function(...e){return{value:Math.sqrt(TQ.compute.bind(this)(...e).value)}},isExported:!0},gQ={description:N(`Standard deviation.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the sample.`))],compute:function(...e){return{value:Math.sqrt(EQ.compute.bind(this)(...e).value)}},isExported:!0},_Q={description:N(`Standard deviation of sample (text as 0).`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the sample.`))],compute:function(...e){return{value:Math.sqrt(DQ.compute.bind(this)(...e).value)}},isExported:!0},vQ={description:N(`Standard deviation of entire population.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the population.`))],compute:function(...e){return{value:Math.sqrt(OQ.compute.bind(this)(...e).value)}},isExported:!0},yQ={description:N(`Standard deviation of entire population (text as 0).`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the population.`))],compute:function(...e){return{value:Math.sqrt(kQ.compute.bind(this)(...e).value)}},isExported:!0},bQ={description:N(`Returns the p-value of a Student's t-test.`),args:[H(`range1 (range<number>)`,N(`The first sample.`)),H(`range2 (range<number>)`,N(`The second sample.`)),H(`tails (number)`,N(`1 for one-tailed, 2 for two-tailed.`)),H(`type (number)`,N(`1 = paired, 2 = two-sample equal variance, 3 = two-sample unequal variance (Welch).`))],compute:function(e,t,n,r){let i=Math.round(I(n,this.locale)),a=Math.round(I(r,this.locale));cS(i===1||i===2,N(`Tails must be 1 or 2.`)),cS(a>=1&&a<=3,N(`Type must be 1, 2, or 3.`));let o=[],s=[];ns([e],e=>o.push(e.value),this.locale),ns([t],e=>s.push(e.value),this.locale);let c,l;if(a===1){cS(o.length===s.length,N(`Paired t-test requires equal-length ranges.`));let e=o.map((e,t)=>e-s[t]),t=e.length;cS(t>=2,N(`Paired t-test requires at least 2 pairs.`));let n=e.reduce((e,t)=>e+t,0)/t,r=e.reduce((e,t)=>e+(t-n)**2,0)/(t-1);if(r===0){let e=+(n===0);return{value:i===1?e/2:e}}c=Math.abs(n)/Math.sqrt(r/t),l=t-1}else{let e=o.length,t=s.length;cS(e>=2&&t>=2,N(`Each range must contain at least 2 numeric values.`));let n=o.reduce((e,t)=>e+t,0)/e,r=s.reduce((e,t)=>e+t,0)/t,i=o.reduce((e,t)=>e+(t-n)**2,0)/(e-1),u=s.reduce((e,t)=>e+(t-r)**2,0)/(t-1);if(a===2){let a=((e-1)*i+(t-1)*u)/(e+t-2);cS(a>0,N(`T.TEST requires non-constant data.`)),c=Math.abs(n-r)/Math.sqrt(a*(1/e+1/t)),l=e+t-2}else{let a=i/e,o=u/t;cS(a+o>0,N(`T.TEST requires non-constant data.`)),c=Math.abs(n-r)/Math.sqrt(a+o),l=(a+o)**2/(a**2/(e-1)+o**2/(t-1))}}let u=FS(c,l);return{value:i===1?u/2:u}},isExported:!0},xQ={description:N(`Calculates the standard error of the predicted y-value for each x in the regression of a dataset.`),args:[H(`data_y (range<number>)`,N(`The range representing the array or matrix of dependent data.`)),H(`data_x (range<number>)`,N(`The range representing the array or matrix of independent data.`))],compute:function(e,t){let{flatDataX:n,flatDataY:r}=dZ(e,t);return n.length===0||r.length===0?new Ao(ws):{value:SS([n],[r],!0,!0)[1][2]}},isExported:!0},SQ={description:N(`Fits points to linear trend derived via least-squares.`),args:[H(`known_data_y (number, range<number>)`,N(`The array or range containing dependent (y) values that are already known, used to curve fit an ideal linear trend.`)),H(`known_data_x (number, range<number>, optional, default={1;2;3;...})`,N(`The values of the independent variable(s) corresponding with known_data_y.`)),H(`new_data_x (number, range<number>, optional, default=known_data_x)`,N(`The data points to return the y values for on the ideal curve fit.`)),H(`b (boolean, optional, default=TRUE)`,N(`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.`),oZ)],computeArray:function(e,t=[[]],n=[[]],r={value:!0}){return e.length===0||e[0].length===0?new F(Ts(`known_data_y`)):cs(OS(Wo(e,`known_data_y`),Wo(t,`known_data_x`),Wo(n,`new_data_y`),R(r)),e=>({value:e}))}},CQ={description:N(`Average of a dataset after discarding a fraction of data from the ends.`),args:[H(`range (number, range<number>)`,N(`The data to average.`)),H(`percent (number)`,N(`Fraction of data to trim from each end (0 to 0.5).`))],compute:function(e,t){let n=I(t,this.locale);cS(n>=0&&n<.5,N(`Percent must be between 0 (inclusive) and 0.5 (exclusive).`));let r=[];ns([e],e=>r.push(e.value),this.locale),cS(r.length>0,ws),r.sort((e,t)=>e-t);let i=Math.floor(r.length*n/2),a=r.slice(i,r.length-i);return{value:a.reduce((e,t)=>e+t,0)/a.length}},isExported:!0},wQ={description:N(`Variance.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the sample.`))],compute:function(...e){return{value:pZ(e,!0,!1,this.locale)}},isExported:!0},TQ={description:N(`Variance of entire population.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the population.`))],compute:function(...e){return{value:pZ(e,!1,!1,this.locale)}},isExported:!0},EQ={description:N(`Variance.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the sample.`))],compute:function(...e){return{value:pZ(e,!0,!1,this.locale)}},isExported:!0},DQ={description:N(`Variance of sample (text as 0).`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the sample.`))],compute:function(...e){return{value:pZ(e,!0,!0,this.locale)}},isExported:!0},OQ={description:N(`Variance of entire population.`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the population.`))],compute:function(...e){return{value:pZ(e,!1,!1,this.locale)}},isExported:!0},kQ={description:N(`Variance of entire population (text as 0).`),args:[H(`value (number, range<number>, repeating)`,N(`Value or range to include in the population.`))],compute:function(...e){return{value:pZ(e,!1,!0,this.locale)}},isExported:!0};var AQ=l({DAVERAGE:()=>NQ,DCOUNT:()=>PQ,DCOUNTA:()=>FQ,DGET:()=>IQ,DMAX:()=>LQ,DMIN:()=>RQ,DPRODUCT:()=>zQ,DSTDEV:()=>BQ,DSTDEVP:()=>VQ,DSUM:()=>HQ,DVAR:()=>UQ,DVARP:()=>WQ});function jQ(e,t,n,r){let i=new Map,a=e.length;for(let t=a-1;t>=0;t--)i.set(L(e[t][0]).toUpperCase(),t);let o=t?.value;if(typeof o!=`number`&&typeof o!=`string`)throw new F(N(`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 F(N(`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=L(t).toUpperCase();if(s=i.get(e)??-1,s===-1)throw new F(N(`The field (%s) must be one of %s.`,L(t),[...i.keys()].toString()))}let c=n[0].length;if(c<2)throw new F(N(`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=L(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)gs(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 MQ=[H(`database (range)`,N(`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.`)),H(`field (number, string)`,N(`Indicates which column in database contains the values to be extracted and operated on.`)),H(`criteria (range)`,N(`An array or range containing zero or more criteria to filter the database values by before operating.`))],NQ={description:N(`Average of a set of values from a table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return gZ.compute.bind(this)([r])},isExported:!0},PQ={description:N(`Counts values from a table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return CZ.compute.bind(this)([r])},isExported:!0},FQ={description:N(`Counts values and text from a table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return wZ.compute.bind(this)([r])},isExported:!0},IQ={description:N(`Single value from a table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return r.length===0?new F(N(`No match found in DGET evaluation.`)):r.length>1?new F(N(`More than one match found in DGET evaluation.`)):r[0]},isExported:!0},LQ={description:N(`Maximum of values from a table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return UZ.compute.bind(this)([r])},isExported:!0},RQ={description:N(`Minimum of values from a table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return qZ.compute.bind(this)([r])},isExported:!0},zQ={description:N(`Product of values from a table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return PX.compute.bind(this)([r])},isExported:!0},BQ={description:N(`Standard deviation of population sample from table.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return mQ.compute.bind(this)([r])},isExported:!0},VQ={description:N(`Standard deviation of entire population from table.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return vQ.compute.bind(this)([r])},isExported:!0},HQ={description:N(`Sum of values from a table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return ZX.compute.bind(this)([r])},isExported:!0},UQ={description:N(`Variance of population sample from table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return wQ.compute.bind(this)([r])},isExported:!0},WQ={description:N(`Variance of a population from a table-like range.`),args:MQ,compute:function(e,t,n){let r=jQ(e,t,n,this.locale);return OQ.compute.bind(this)([r])},isExported:!0},GQ=N(`The cashflow_amounts and cashflow_dates ranges must have the same dimensions.`),KQ=N(`There must be both positive and negative values in cashflow_amounts.`),qQ=e=>N(`The cost (%s) must be positive or null.`,e),JQ=e=>N(`The cost (%s) must be strictly positive.`,e),YQ=e=>N(`The frequency (%s) must be one of %s`,e,[1,2,4].toString()),XQ=e=>N(`The day_count_convention (%s) must be between 0 and 4 inclusive.`,e),ZQ=e=>N(`The depreciation factor (%s) must be strictly positive.`,e),QQ=e=>N(`The discount (%s) must be different from -1.`,e),$Q=e=>N(`The discount (%s) must be strictly positive.`,e),e$=e=>N(`The discount (%s) must be smaller than 1.`,e),t$=e=>N(`The effective_rate (%s) must be strictly positive.`,e),n$=e=>N(`The end_period (%s) must be positive or null.`,e),r$=(e,t)=>N(`The end_period (%(end)s) must be smaller or equal to the life (%(life)s).`,{end:e,life:t}),i$=e=>N(`All the dates should be greater or equal to the first date in cashflow_dates (%s).`,e),a$=(e,t)=>N(`The first_period (%(first)s) must be smaller or equal to the last_period (%(last)s).`,{first:e,last:t}),o$=e=>N(`The first_period (%s) must be strictly positive.`,e),s$=e=>N(`The future_value (%s) must be strictly positive.`,e),c$=e=>N(`The investment (%s) must be strictly positive.`,e),l$=e=>N(`The issue (%s) must be positive or null.`,e),u$=(e,t)=>N(`The last_period (%(last)s) must be smaller or equal to the number_of_periods (%(nPeriods)s).`,{last:e,nPeriods:t}),d$=e=>N(`The last_period (%s) must be strictly positive.`,e),f$=e=>N(`The life (%s) must be strictly positive.`,e),p$=(e,t)=>N(`The maturity (%(maturity)s) must be strictly greater than the settlement (%(settlement)s).`,{maturity:t,settlement:e}),m$=e=>N(`The month (%s) must be between 1 and 12 inclusive.`,e),h$=e=>N(`The nominal_rate (%s) must be strictly positive.`,e),g$=e=>N(`The number_of_periods (%s) must be different from zero.`,e),_$=e=>N(`The number_of_periods (%s) must be strictly positive.`,e),v$=e=>N(`The period must be between 1 and number_of_periods (%s)`,e),y$=(e,t)=>N(`The period (%(period)s) must be less than or equal to %(lifeLimit)s.`,{period:e,lifeLimit:t}),b$=e=>N(`The period (%s) must be positive or null.`,e),x$=e=>N(`The periods_by_year (%s) must be strictly positive.`,e),S$=(e,t)=>N(`The period (%(period)s) must be less than or equal life (%(life)s).`,{period:e,life:t}),C$=e=>N(`The period (%s) must be strictly positive.`,e),w$=e=>N(`The present_value (%s) must be strictly positive.`,e),T$=e=>N(`The price (%s) must be strictly positive.`,e),E$=(e,t)=>N(`The purchase_date (%(purchaseDate)s) must be before the first_period_end (%(firstPeriodEnd)s).`,{purchaseDate:e,firstPeriodEnd:t}),D$=e=>N(`The purchase_date (%s) must be positive or null.`,e),O$=e=>N(`The rate_guess (%s) must be strictly greater than -1.`,e),k$=e=>N(`The rate (%s) must be positive or null.`,e),A$=e=>N(`The rate (%s) must be strictly positive.`,e),j$=e=>N(`The redemption (%s) must be strictly positive.`,e),M$=e=>N(`The salvage (%s) must be positive or null.`,e),N$=(e,t)=>N(`The salvage (%(salvage)s) must be smaller or equal than the cost (%(cost)s).`,{salvage:e,cost:t}),P$=(e,t)=>N(`The settlement date (%(settlement)s) must be greater or equal to the issue date (%(issue)s).`,{settlement:e,issue:t}),F$=(e,t)=>N(`The settlement date (%(settlement)s) must at most one year after the maturity date (%(maturity)s).`,{settlement:e,maturity:t}),I$=(e,t)=>N(`The settlement date (%(settlement)s) must be strictly greater than the issue date (%(issue)s).`,{settlement:e,issue:t}),L$=e=>N(`The start_period (%s) must be positive or null.`,e),R$=(e,t)=>N(`The start_period (%(start)s) must be smaller or equal to the end_period (%(end)s).`,{start:e,end:t}),z$=e=>N(`The unit (%s) must be strictly positive.`,e),B$=e=>N(`The yield (%s) must be positive or null.`,e);function V$(e){return e.some(e=>e>0)&&e.some(e=>e<0)}function H$(e){return![0,1,2,3,4].includes(e)}function U$(e){return![1,2,4].includes(e)}function W$(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 G$=[{value:0,label:N(`US (NASD) 30/360`)},{value:1,label:N(`Actual/Actual`)},{value:2,label:N(`Actual/360`)},{value:3,label:N(`Actual/365`)},{value:4,label:N(`European 30/360`)}];var K$=l({DATE:()=>J$,DATEDIF:()=>Y$,DATEVALUE:()=>X$,DAY:()=>Z$,DAYS:()=>Q$,DAYS360:()=>$$,EDATE:()=>e1,EOMONTH:()=>t1,HOUR:()=>n1,ISOWEEKNUM:()=>r1,MINUTE:()=>i1,MONTH:()=>a1,MONTH_END:()=>S1,MONTH_START:()=>x1,NETWORKDAYS:()=>o1,NETWORKDAYS_INTL:()=>l1,NOW:()=>u1,QUARTER:()=>C1,QUARTER_END:()=>T1,QUARTER_START:()=>w1,SECOND:()=>d1,TIME:()=>f1,TIMEVALUE:()=>p1,TODAY:()=>m1,WEEKDAY:()=>h1,WEEKNUM:()=>g1,WORKDAY:()=>_1,WORKDAY_INTL:()=>v1,YEAR:()=>y1,YEARFRAC:()=>b1,YEAR_END:()=>D1,YEAR_START:()=>E1}),q$=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}(q$||{});let J$={description:N(`Converts year/month/day into a date.`),args:[H(`year (number)`,N(`The year component of the date.`)),H(`month (number)`,N(`The month component of the date.`)),H(`day (number)`,N(`The day component of the date.`))],compute:function(e,t,n){let r=Math.trunc(I(e,this.locale)),i=Math.trunc(I(t,this.locale)),a=Math.trunc(I(n,this.locale));if(r<0||r>9999)return new F(N(`The year (%s) must be between 0 and 9999 inclusive.`,r.toString()));r<1900&&(r+=1900);let o=Ja(new xa(r,i-1,a));return o<0?new F(N(`The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.`)):{value:o,format:this.locale.dateFormat}},isExported:!0},Y$={description:N(`Calculates the number of days, months, or years between two dates.`),args:[H(`start_date (date)`,N(`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.`)),H(`end_date (date)`,N(`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.`)),H(`unit (string)`,N(`A text abbreviation for unit of time.`),[{value:`Y`,label:N(`The number of whole years between start_date and end_date`)},{value:`M`,label:N(`The number of whole months between start_date and end_date`)},{value:`D`,label:N(`The number of days between start_date and end_date`)},{value:`MD`,label:N(`The number of days between start_date and end_date after subtracting whole months`)},{value:`YM`,label:N(`The number of whole months between start_date and end_date after subtracting whole years`)},{value:`YD`,label:N(`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=L(n).toUpperCase();if(!Object.values(q$).includes(r))return new F(Ho(Object.values(q$),L(n)));let i=Math.trunc(I(e,this.locale)),a=Math.trunc(I(t,this.locale)),o=qa(i),s=qa(a);if(a<i)return new F(N(`start_date (%s) should be on or before end_date (%s).`,o.toLocaleDateString(),s.toLocaleDateString()));switch(r){case`Y`:return{value:ro(o,s)};case`M`:return{value:to(o,s)};case`D`:return{value:no(o,s)};case`YM`:return{value:to(o,s)-ro(o,s)*12};case`MD`:let e=s.getDate()-o.getDate();return e<0&&(e=Xa(new xa(s.getFullYear(),s.getMonth()-1,1))-Math.abs(e)),{value:e};case`YD`:{if(io(i,a))return{value:no(o,s)};let e=new xa(o.getFullYear(),s.getMonth(),s.getDate()),t=no(o,e);return t<0&&(e.setFullYear(o.getFullYear()+1),t=no(o,e)),{value:t}}}},isExported:!0},X$={description:N(`Converts a date string to a date value.`),args:[H(`date_string (string)`,N(`The string representing the date.`))],compute:function(e){let t=L(e),n=La(t,this.locale);return n===null?new F(N(`The date_string (%s) cannot be parsed to date/time.`,t.toString())):{value:Math.trunc(n.value)}},isExported:!0},Z$={description:N(`Day of the month that a specific date falls on.`),args:[H(`date (string)`,N(`The date from which to extract the day.`))],compute:function(e){return{value:Qo(e,this.locale).getDate()}},isExported:!0},Q$={description:N(`Number of days between two dates.`),args:[H(`end_date (date)`,N(`The end of the date range.`)),H(`start_date (date)`,N(`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{value:Math.round(i/Ca)}},isExported:!0},$$={description:N(`Number of days between two dates on a 360-day year (months of 30 days).`),args:[H(`start_date (date)`,N(`The start date to consider in the calculation.`)),H(`end_date (date)`,N(`The end date to consider in the calculation.`)),H(`method (boolean, default=false)`,N(`An indicator of what day count method to use.`),[{value:!1,label:N(`U.S. NASD method (default)`)},{value:!0,label:N(`European method`)}])],compute:function(e,t,n={value:!1}){let r=Math.trunc(I(e,this.locale)),i=Math.trunc(I(t,this.locale)),a=eo(r,i,R(n)?4:0);return{value:Math.sign(i-r)*Math.round(a*360)}},isExported:!0},e1={description:N(`Date a number of months before/after another date.`),args:[H(`start_date (date)`,N(`The date from which to calculate the result.`)),H(`months (number)`,N(`The number of months before (negative) or after (positive) 'start_date' to calculate.`))],compute:function(e,t){return{value:Ja(Qa(Qo(e,this.locale),Math.trunc(I(t,this.locale)),!1)),format:this.locale.dateFormat}},isExported:!0},t1={description:N(`Last day of a month before or after a date.`),args:[H(`start_date (date)`,N(`The date from which to calculate the result.`)),H(`months (number)`,N(`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(I(t,this.locale));return{value:Ja(new xa(n.getFullYear(),n.getMonth()+r+1,0)),format:this.locale.dateFormat}},isExported:!0},n1={description:N(`Hour component of a specific time.`),args:[H(`time (date)`,N(`The time from which to calculate the hour component.`))],compute:function(e){return{value:Qo(e,this.locale).getHours()}},isExported:!0},r1={description:N(`ISO week number of the year.`),args:[H(`date (date)`,N(`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 xa(n,0,r).getDay()!==4;)r+=1;let i=new xa(n,0,r-3),a=31;for(;new xa(n,11,a).getDay()!==4;)--a;let o=new xa(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 xa(n,11,a+3+1);break;case-1:let e=1;for(;new xa(n-1,0,e).getDay()!==4;)e+=1;c=new xa(n-1,0,e-3);break}let l=(t.getTime()-c.getTime())/Ca;return{value:Math.floor(l/7)+1}},isExported:!0},i1={description:N(`Minute component of a specific time.`),args:[H(`time (date)`,N(`The time from which to calculate the minute component.`))],compute:function(e){return{value:Qo(e,this.locale).getMinutes()}},isExported:!0},a1={description:N(`Month of the year a specific date falls in`),args:[H(`date (date)`,N(`The date from which to extract the month.`))],compute:function(e){return{value:Qo(e,this.locale).getMonth()+1}},isExported:!0},o1={description:N(`Net working days between two provided days.`),args:[H(`start_date (date)`,N(`The start date of the period from which to calculate the number of net working days.`)),H(`end_date (date)`,N(`The end date of the period from which to calculate the number of net working days.`)),H(`holidays (date, range<date>, optional)`,N(`A range or array constant containing the date serial numbers to consider holidays.`))],compute:function(e,t,n){return l1.compute.bind(this)(e,t,{value:1},n)},isExported:!0};function s1(e){let t=e?.value;if(typeof t==`string`){cS(t.length===7&&[...t].every(e=>e===`0`||e===`1`),N(`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 cS(1<=t&&t<=7||11<=t&&t<=17,N(`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 F(N(`The weekend must be a number or a string.`))}let c1=[{value:1,label:N(`Saturday/Sunday are weekends`)},{value:2,label:N(`Sunday/Monday are weekends`)},{value:3,label:N(`Monday/Tuesday are weekends`)},{value:4,label:N(`Tuesday/Wednesday are weekends`)},{value:5,label:N(`Wednesday/Thursday are weekends`)},{value:6,label:N(`Thursday/Friday are weekends`)},{value:7,label:N(`Friday/Saturday are weekends`)},{value:11,label:N(`Sunday is the only weekend`)},{value:12,label:N(`Monday is the only weekend`)},{value:13,label:N(`Tuesday is the only weekend`)},{value:14,label:N(`Wednesday is the only weekend`)},{value:15,label:N(`Thursday is the only weekend`)},{value:16,label:N(`Friday is the only weekend`)},{value:17,label:N(`Saturday is the only weekend`)}],l1={description:N(`Net working days between two dates (specifying weekends).`),args:[H(`start_date (date)`,N(`The start date of the period from which to calculate the number of net working days.`)),H(`end_date (date)`,N(`The end date of the period from which to calculate the number of net working days.`)),H(`weekend (any, default=1)`,N(`A number or string representing which days of the week are considered weekends.`),c1),H(`holidays (date, range<date>, optional)`,N(`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=s1(n),s=new Set;r!==void 0&&ts([r],e=>{let t=Qo(e,this.locale);s.add(t.getTime())});let c=i.getTime()>a.getTime(),l=xa.fromTimestamp((c?i:a).getTime()),u=xa.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{value:c?-p:p}},isExported:!0},u1={description:N(`Current date and time as a date value.`),args:[],compute:function(){let e=xa.now(),t=e.getTime()-Sa.getTime(),n=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return{value:Math.floor(t/Ca)+n,format:av(this.locale)}},isExported:!0},d1={description:N(`Minute component of a specific time.`),args:[H(`time (date)`,N(`The time from which to calculate the second component.`))],compute:function(e){return{value:Qo(e,this.locale).getSeconds()}},isExported:!0},f1={description:N(`Converts hour/minute/second into a time.`),args:[H(`hour (number)`,N(`The hour component of the time.`)),H(`minute (number)`,N(`The minute component of the time.`)),H(`second (number)`,N(`The second component of the time.`))],compute:function(e,t,n){let r=Math.trunc(I(e,this.locale)),i=Math.trunc(I(t,this.locale)),a=Math.trunc(I(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 F(N(`The function [[FUNCTION_NAME]] result cannot be negative`)):{value:r/24+i/1440+a/(1440*60),format:this.locale.timeFormat}},isExported:!0},p1={description:N(`Converts a time string into its serial number representation.`),args:[H(`time_string (string)`,N(`The string that holds the time representation.`))],compute:function(e){let t=L(e),n=La(t,this.locale);if(n===null)return new F(N(`The time_string (%s) cannot be parsed to date/time.`,t));let r=n.value-Math.trunc(n.value);return{value:r<0?1+r:r}},isExported:!0},m1={description:N(`Current date as a date value.`),args:[],compute:function(){let e=xa.now();return{value:Ja(new xa(e.getFullYear(),e.getMonth(),e.getDate())),format:this.locale.dateFormat}},isExported:!0},h1={description:N(`Day of the week of the date provided (as number).`),args:[H(`date (date)`,N(`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.`)),H(`type (number, default=1)`,N(`A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1.`),[{value:1,label:N(`Numbers 1 (Sunday) trough 7 (Saturday)`)},{value:2,label:N(`Numbers 1 (Monday) trough 7 (Sunday)`)},{value:3,label:N(`Numbers 0 (Monday) trough 6 (Sunday)`)},{value:11,label:N(`Numbers 1 (Monday) trough 7 (Sunday)`)},{value:12,label:N(`Numbers 1 (Tuesday) trough 7 (Monday)`)},{value:13,label:N(`Numbers 1 (Wednesday) trough 7 (Tuesday)`)},{value:14,label:N(`Numbers 1 (Thursday) trough 7 (Wednesday)`)},{value:15,label:N(`Numbers 1 (Friday) trough 7 (Thursday)`)},{value:16,label:N(`Numbers 1 (Saturday) trough 7 (Friday)`)},{value:17,label:N(`Numbers 1 (Sunday) trough 7 (Saturday)`)}])],compute:function(e,t={value:1}){let n=Qo(e,this.locale),r=Math.round(I(t,this.locale)),i=n.getDay();if(!(1<=r&&r<=3)&&!(11<=r&&r<=17))return new F(N(`The type (%s) must be between 1 and 3 or between 11 and 17.`,r));switch(r){case 1:return{value:i+1};case 2:return{value:i===0?7:i};case 3:return{value:i===0?6:i-1}}let a=r-10,o=(i+1-a+7)%7;return{value:o===0?7:o}},isExported:!0},g1={description:N(`Week number of the year.`),args:[H(`date (date)`,N(`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.`)),H(`type (number, default=1)`,N(`A number representing the day that a week starts on. Sunday = 1.`),[{value:1,label:N(`Sunday`)},{value:2,label:N(`Monday`)},{value:11,label:N(`Monday`)},{value:12,label:N(`Tuesday`)},{value:13,label:N(`Wednesday`)},{value:14,label:N(`Thursday`)},{value:15,label:N(`Friday`)},{value:16,label:N(`Saturday`)},{value:17,label:N(`Sunday`)},{value:21,label:N(`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(I(t,this.locale));if(![1,2,11,12,13,14,15,16,17,21].includes(r))return new F(N(`The type (%s) is out of range.`,r.toString()));if(r===21)return r1.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 xa(a,0,o);for(;s.getDay()!==i;)o+=1,s=new xa(a,0,o);let c=(n.getTime()-s.getTime())/Ca;return c<0?{value:1}:{value:Math.floor(c/7)+(o===1?1:2)}},isExported:!0},_1={description:N(`Date after a number of workdays.`),args:[H(`start_date (date)`,N(`The date from which to begin counting.`)),H(`num_days (number)`,N(`The number of working days to advance from start_date. If negative, counts backwards.`)),H(`holidays (date, range<date>, optional)`,N(`A range or array constant containing the dates to consider holidays.`))],compute:function(e,t,n={value:null}){return v1.compute.bind(this)(e,t,{value:1},n)},isExported:!0},v1={description:N(`Date after a number of workdays (specifying weekends).`),args:[H(`start_date (date)`,N(`The date from which to begin counting.`)),H(`num_days (number)`,N(`The number of working days to advance from start_date. If negative, counts backwards.`)),H(`weekend (any, default=1)`,N(`A number or string representing which days of the week are considered weekends.`),c1),H(`holidays (date, range<date>, optional)`,N(`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(I(t,this.locale));if(n.value===`1111111`)return new F(N(`The weekend must be different from '1111111'.`));let o=s1(n),s=new Set;r!==void 0&&ts([r],e=>{let t=Qo(e,this.locale);s.add(t.getTime())});let c=xa.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-Sa.getTime();return{value:Math.round(f/Ca),format:this.locale.dateFormat}},isExported:!0},y1={description:N(`Year specified by a given date.`),args:[H(`date (date)`,N(`The date from which to extract the year.`))],compute:function(e){return{value:Qo(e,this.locale).getFullYear()}},isExported:!0},b1={description:N(`Exact number of years between two dates.`),args:[H(`start_date (date)`,N(`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.`)),H(`end_date (date)`,N(`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.`)),H(`day_count_convention (number, default=0)`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n={value:0}){let r=Math.trunc(I(e,this.locale)),i=Math.trunc(I(t,this.locale)),a=Math.trunc(I(n,this.locale));return r<0?new F(N(`The start_date (%s) must be positive or null.`,r)):i<0?new F(N(`The end_date (%s) must be positive or null.`,i)):0>a||a>4?new F(N(`The day_count_convention (%s) must be between 0 and 4 inclusive.`,a)):{value:eo(r,i,a)}}},x1={description:N(`First day of the month a date falls in.`),args:[H(`date (date)`,N(`The date from which to calculate the result.`))],compute:function(e){let t=Qo(e,this.locale);return{value:Ja(new xa(t.getFullYear(),t.getMonth(),1)),format:this.locale.dateFormat}}},S1={description:N(`Last day of the month a date falls in.`),args:[H(`date (date)`,N(`The date from which to calculate the result.`))],compute:function(e){return t1.compute.bind(this)(e,{value:0})}},C1={description:N(`Quarter of the year a specific date falls in`),args:[H(`date (date)`,N(`The date from which to extract the quarter.`))],compute:function(e){return{value:Math.ceil((Qo(e,this.locale).getMonth()+1)/3)}}},w1={description:N(`First day of the quarter of the year a specific date falls in.`),args:[H(`date (date)`,N(`The date from which to calculate the start of quarter.`))],compute:function(e){let t=C1.compute.bind(this)(e).value,n=y1.compute.bind(this)(e).value;return{value:Ja(new xa(n,(t-1)*3,1)),format:this.locale.dateFormat}}},T1={description:N(`Last day of the quarter of the year a specific date falls in.`),args:[H(`date (date)`,N(`The date from which to calculate the end of quarter.`))],compute:function(e){let t=C1.compute.bind(this)(e).value,n=y1.compute.bind(this)(e).value;return{value:Ja(new xa(n,t*3,0)),format:this.locale.dateFormat}}},E1={description:N(`First day of the year a specific date falls in.`),args:[H(`date (date)`,N(`The date from which to calculate the start of the year.`))],compute:function(e){let t=y1.compute.bind(this)(e).value;return{value:Ja(new xa(t,0,1)),format:this.locale.dateFormat}}},D1={description:N(`Last day of the year a specific date falls in.`),args:[H(`date (date)`,N(`The date from which to calculate the end of the year.`))],compute:function(e){let t=y1.compute.bind(this)(e).value;return{value:Ja(new xa(t+1,0,0)),format:this.locale.dateFormat}}};var O1=l({DELTA:()=>k1});let k1={description:N(`Compare two numeric values, returning 1 if they're equal.`),args:[H(`number1 (number)`,N(`The first number to compare.`)),H(`number2 (number, default=0)`,N(`The second number to compare.`))],compute:function(e,t={value:0}){return{value:+(I(e,this.locale)===I(t,this.locale))}},isExported:!0};var A1=l({FILTER:()=>M1,SORT:()=>N1,SORTN:()=>P1,UNIQUE:()=>F1});function j1(e,t,...n){for(let e=0;e<n.length;e++){let t=e%2==0?`sort_column`:`is_ascending`;cS(n[e]!==void 0,N(`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(R(fg(n[o+1])?.value)?`asc`:`desc`);let s=n[o];if(wt(s)&&(s.length>1||s[0].length>1))cS(s.length===1&&s[0].length===a,N(`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=I(fg(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:IV(`desc`),asc:IV(`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 M1={description:N(`Returns a filtered version of the source range, returning only rows or columns that meet the specified conditions.`),args:[H(`range (any, range<any>)`,N(`The data to be filtered.`)),H(`condition (boolean, range<boolean>, repeating)`,N(`Column or row containing true or false values corresponding to the range.`))],computeArray:function(e,...t){let n=z(e),r=t.map(e=>cs(z(e),e=>e.value));for(let e of r)if(!uS(e))return new F(N(`The arguments condition must be a single column or row.`));if(!dS(...t))return new F(N(`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`?us(n):n,i.some(e=>e.length!==n.length))return new F(N(`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`?us(o):o:new Ao(N(`No match found in FILTER evaluation`))},isExported:!1},N1={description:N(`Sorts the rows of a given array or range by the values in one or more columns.`),args:[H(`range (range)`,N(`The data to be sorted.`)),H(`sort_column (any, range<number>, repeating, optional)`,N(`The index of the column in range or a range outside of range containing the value by which to sort.`)),H(`is_ascending (boolean, repeating, optional)`,N(`TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.`),[{value:!0,label:N(`Ascending`)},{value:!1,label:N(`Descending`)}])],computeArray:function(e,...t){return us(j1(us(e),this.locale,...t))},isExported:!0},P1={description:N(`Returns the first n items in a data set after performing a sort.`),args:[H(`range (range)`,N(`The data to be sorted.`)),H(`n (number)`,N(`The number of items to return.`)),H(`display_ties_mode (number, default=0)`,N(`A number representing the way to display ties.`)),H(`sort_column (number, range<number>, repeating, optional)`,N(`The index of the column in range or a range outside of range containing the value by which to sort.`)),H(`is_ascending (boolean, repeating, optional)`,N(`TRUE or FALSE indicating whether to sort sort_column in ascending order. FALSE sorts in descending order.`),[{value:!0,label:N(`Ascending`)},{value:!1,label:N(`Descending`)}])],compute:function(e,t,...n){let r=I(t?.value??1,this.locale),i=n.length%2==0?0:I(n[0]?.value,this.locale),a=n.length%2==0?n:n.slice(1);if(r<0)return new F(N(`Wrong value of 'n'. Expected a positive number. Got %s.`,r));if(i<0||i>3)return new F(N(`Wrong value of 'display_ties_mode'. Expected a positive number between 0 and 3. Got %s.`,i));let o=j1(us(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 us(o.slice(0,r));case 1:for(let e=r;e<o.length;e++)if(!s(e,r-1))return us(o.slice(0,e));return us(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 us(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 us(e)}}},isExported:!1},F1={description:N(`Unique rows in the provided source range.`),args:[H(`range (any, range<any>)`,N(`The data to filter by unique entries.`)),H(`by_column (boolean, default=FALSE)`,N(`Whether to filter the data by columns or by rows.`),[{value:!0,label:N(`Return unique columns`)},{value:!1,label:N(`Return unique rows`)}]),H(`exactly_once (boolean, default=FALSE)`,N(`Whether to return only entries with no duplicates.`),[{value:!0,label:N(`Return items that appear exactly once`)},{value:!1,label:N(`Return every distinct item`)}])],computeArray:function(e={value:``},t,n){if(!wt(e))return[[e]];let r=R(t?.value)||!1,i=R(n?.value)||!1;r||(e=us(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:us(o):new F(N(`No unique values found`))},isExported:!0};var I1=l({ACCRINTM:()=>V1,AMORLINC:()=>H1,COUPDAYBS:()=>W1,COUPDAYS:()=>U1,COUPDAYSNC:()=>G1,COUPNCD:()=>K1,COUPNUM:()=>q1,COUPPCD:()=>J1,CUMIPMT:()=>Y1,CUMPRINC:()=>X1,DB:()=>Z1,DDB:()=>$1,DISC:()=>e0,DOLLARDE:()=>t0,DOLLARFR:()=>n0,DURATION:()=>r0,EFFECT:()=>i0,FV:()=>o0,FVSCHEDULE:()=>s0,INTRATE:()=>c0,IPMT:()=>u0,IRR:()=>f0,ISPMT:()=>p0,MDURATION:()=>m0,MIRR:()=>h0,NOMINAL:()=>g0,NPER:()=>_0,NPV:()=>y0,PDURATION:()=>b0,PMT:()=>S0,PPMT:()=>w0,PRICE:()=>E0,PRICEDISC:()=>D0,PRICEMAT:()=>O0,PV:()=>T0,RATE:()=>A0,RECEIVED:()=>j0,RRI:()=>M0,SLN:()=>N0,SYD:()=>P0,TBILLEQ:()=>L0,TBILLPRICE:()=>I0,TBILLYIELD:()=>R0,VDB:()=>z0,XIRR:()=>B0,XNPV:()=>V0,YIELD:()=>H0,YIELDDISC:()=>U0,YIELDMAT:()=>W0});let L1=[{value:1,label:N(`Annual`)},{value:2,label:N(`Semi-annual`)},{value:4,label:N(`Quarterly`)}],R1=[{value:0,label:N(`End of period (default)`)},{value:1,label:N(`Beginning of period`)}],z1=[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`frequency (number)`,N(`The number of interest or coupon payments per year (1, 2, or 4).`),L1),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)];function B1(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)){cS(d<r&&a!==void 0,N(`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,cS(d<r,N(`Function [[FUNCTION_NAME]] didn't find any result.`)),d++}while(!u);return o}let V1={description:N(`Accrued interest of security paying at maturity.`),args:[H(`issue (date)`,N(`The date the security was initially issued.`)),H(`maturity (date)`,N(`The maturity date of the security.`)),H(`rate (number)`,N(`The annualized rate of interest.`)),H(`redemption (number)`,N(`The redemption amount per 100 face value, or par.`)),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i={value:0}){let a=Math.trunc(I(e,this.locale)),o=Math.trunc(I(t,this.locale)),s=I(r,this.locale),c=I(n,this.locale),l=Math.trunc(I(i,this.locale));if(a<0)return new F(l$(a));if(a>=o)return new F(p$(a,o));if(H$(l))return new F(XQ(l));if(s<=0)return new F(j$(s));if(c<=0)return new F(A$(c));let u=eo(a,o,l);return{value:s*c*u}},isExported:!0},H1={description:N(`Depreciation for an accounting period.`),args:[H(`cost (number)`,N(`The initial cost of the asset.`)),H(`purchase_date (date)`,N(`The date the asset was purchased.`)),H(`first_period_end (date)`,N(`The date the first period ended.`)),H(`salvage (number)`,N(`The value of the asset at the end of depreciation.`)),H(`period (number)`,N(`The single period within life for which to calculate depreciation.`)),H(`rate (number)`,N(`The deprecation rate.`)),H(`day_count_convention (number, optional)`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=I(e,this.locale),c=Math.trunc(I(t,this.locale)),l=Math.trunc(I(n,this.locale)),u=I(r,this.locale),d=I(i,this.locale),f=I(a,this.locale),p=Math.trunc(I(o,this.locale));if(s<=0)return new F(JQ(s));if(c<0)return new F(D$(c));if(u<0)return new F(M$(u));if(u>s)return new F(N$(u,s));if(d<0)return new F(b$(d));if(f<=0)return new F(A$(f));if(H$(p))return new F(XQ(p));if(c>l)return new F(E$(c,l));let m=d<1&&d>0?1:Math.trunc(d),h=s*f,g=eo(c,l,p),_=c===l?h:h*g,v=s-_-h*m;return v>=u?{value:m===0?_:h}:{value:u-v<h?h-(u-v):0}},isExported:!0},U1={description:N(`Days in coupon period containing settlement date.`),args:z1,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(I(e,this.locale)),a=Math.trunc(I(t,this.locale)),o=Math.trunc(I(n,this.locale)),s=Math.trunc(I(r,this.locale));if(i>=a)return new F(p$(i,a));if(U$(o))return new F(YQ(o));if(H$(s))return new F(XQ(s));if(s===1){let i=J1.compute.bind(this)(e,t,n,r).value,a=K1.compute.bind(this)(e,t,n,r).value;return{value:I(a,this.locale)-I(i,this.locale)}}return{value:(s===3?365:360)/o}},isExported:!0},W1={description:N(`Days from settlement until next coupon.`),args:z1,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(I(e,this.locale)),a=Math.trunc(I(t,this.locale)),o=Math.trunc(I(n,this.locale)),s=Math.trunc(I(r,this.locale));if(i>=a)return new F(p$(i,a));if(U$(o))return new F(YQ(o));if(H$(s))return new F(XQ(s));let c=J1.compute.bind(this)(e,t,n,r).value,l=I(c,this.locale);if([1,2,3].includes(s))return{value:i-l};if(s===4){let e=eo(l,i,s);return{value: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&&Za(d)&&Za(u)&&(_=30),_===31&&(g===30||g===31)&&(_=30),m===2&&Za(d)&&(g=30),g===31&&(g=30),{value:(p-f)*360+(h-m)*30+(_-g)}},isExported:!0},G1={description:N(`Days from settlement until next coupon.`),args:z1,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(I(e,this.locale)),a=Math.trunc(I(t,this.locale)),o=Math.trunc(I(n,this.locale)),s=Math.trunc(I(r,this.locale));if(i>=a)return new F(p$(i,a));if(U$(o))return new F(YQ(o));if(H$(s))return new F(XQ(s));let c=K1.compute.bind(this)(e,t,n,r).value,l=I(c,this.locale);if([1,2,3].includes(s))return{value:l-i};if(s===4){let e=eo(i,l,s);return{value:Math.round(e*360)}}let u=W1.compute.bind(this)(e,t,n,r);return{value:I(U1.compute.bind(this)(e,t,n,r),this.locale)-I(u,this.locale)}},isExported:!0},K1={description:N(`Next coupon date after the settlement date.`),args:z1,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(I(e,this.locale)),a=Math.trunc(I(t,this.locale)),o=Math.trunc(I(n,this.locale)),s=Math.trunc(I(r,this.locale));if(i>=a)return new F(p$(i,a));if(U$(o))return new F(YQ(o));if(H$(s))return new F(XQ(s));let c=12/o,l=q1.compute.bind(this)(e,t,n,r);return{value:Ja(Qa(Qo(a,this.locale),-(I(l,this.locale)-1)*c,!0)),format:this.locale.dateFormat}},isExported:!0},q1={description:N(`Number of coupons between settlement and maturity.`),args:z1,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(I(e,this.locale)),a=Math.trunc(I(t,this.locale)),o=Math.trunc(I(n,this.locale)),s=Math.trunc(I(r,this.locale));if(i>=a)return new F(p$(i,a));if(U$(o))return new F(YQ(o));if(H$(s))return new F(XQ(s));let c=1,l=a,u=12/o;for(;l>i;)l=Ja(Qa(Qo(l,this.locale),-u,!1)),c++;return{value:c-1}},isExported:!0},J1={description:N(`Last coupon date prior to or on the settlement date.`),args:z1,compute:function(e,t,n,r={value:0}){r||=0;let i=Math.trunc(I(e,this.locale)),a=Math.trunc(I(t,this.locale)),o=Math.trunc(I(n,this.locale)),s=Math.trunc(I(r,this.locale));if(i>=a)return new F(p$(i,a));if(U$(o))return new F(YQ(o));if(H$(s))return new F(XQ(s));let c=12/o,l=q1.compute.bind(this)(e,t,n,r).value;return{value:Ja(Qa(Qo(a,this.locale),-l*c,!0)),format:this.locale.dateFormat}},isExported:!0},Y1={description:N(`Cumulative interest paid over a set of periods.`),args:[H(`rate (number)`,N(`The interest rate.`)),H(`number_of_periods (number)`,N(`The number of payments to be made.`)),H(`present_value (number)`,N(`The current value of the annuity.`)),H(`first_period (number)`,N(`The number of the payment period to begin the cumulative calculation.`)),H(`last_period (number)`,N(`The number of the payment period to end the cumulative calculation.`)),H(`end_or_beginning (number, default=0)`,N(`The timing of the payment payments are due for each period.`),R1)],compute:function(e,t,n,r,i,a={value:0}){let o=I(r,this.locale),s=I(i,this.locale),c=I(e,this.locale),l=I(n,this.locale),u=I(t,this.locale),d=+!!R(a);if(u<=0)return new F(_$(u));if(o<=0)return new F(o$(o));if(s<=0)return new F(d$(s));if(o>s)return new F(a$(o,s));if(s>u)return new F(u$(s,u));if(c<=0)return new F(A$(c));if(l<=0)return new F(w$(l));let f=0;for(let e=o;e<=s;e++)f+=l0(c,e,u,l,0,d);return{value:f}},isExported:!0},X1={description:N(`Cumulative principal paid over a set of periods.`),args:[H(`rate (number)`,N(`The interest rate.`)),H(`number_of_periods (number)`,N(`The number of payments to be made.`)),H(`present_value (number)`,N(`The current value of the annuity.`)),H(`first_period (number)`,N(`The number of the payment period to begin the cumulative calculation.`)),H(`last_period (number)`,N(`The number of the payment period to end the cumulative calculation.`)),H(`end_or_beginning (number, default=0)`,N(`The timing of the payment payments are due for each period.`),R1)],compute:function(e,t,n,r,i,a={value:0}){let o=I(r,this.locale),s=I(i,this.locale),c=I(e,this.locale),l=I(n,this.locale),u=I(t,this.locale),d=+!!R(a);if(u<=0)return new F(_$(u));if(o<=0)return new F(o$(o));if(s<=0)return new F(d$(s));if(o>s)return new F(a$(o,s));if(s>u)return new F(u$(s,u));if(c<=0)return new F(A$(c));if(l<=0)return new F(w$(l));let f=0;for(let e=o;e<=s;e++)f+=C0(c,e,u,l,0,d);return{value:f}},isExported:!0},Z1={description:N(`Depreciation via declining balance method.`),args:[H(`cost (number)`,N(`The initial cost of the asset.`)),H(`salvage (number)`,N(`The value of the asset at the end of depreciation.`)),H(`life (number)`,N(`The number of periods over which the asset is depreciated.`)),H(`period (number)`,N(`The single period within life for which to calculate depreciation.`)),H(`month (number, optional)`,N(`The number of months in the first year of depreciation.`))],compute:function(e,t,n,r,...i){let a=I(e,this.locale),o=I(t,this.locale),s=I(n,this.locale),c=Math.trunc(I(r,this.locale)),l=i.length?Math.trunc(I(i[0],this.locale)):12,u=s+(l===12?0:1);if(a<0)return new F(qQ(a));if(o<0)return new F(M$(o));if(c<=0)return new F(C$(c));if(s<=0)return new F(f$(s));if(1>l||l>12)return new F(m$(l));if(c>u)return new F(y$(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},Q1=`#,##0.00`,$1={description:N(`Depreciation via double-declining balance method.`),args:[H(`cost (number)`,N(`The initial cost of the asset.`)),H(`salvage (number)`,N(`The value of the asset at the end of depreciation.`)),H(`life (number)`,N(`The number of periods over which the asset is depreciated.`)),H(`period (number)`,N(`The single period within life for which to calculate depreciation.`)),H(`factor (number, default=2)`,N(`The factor by which depreciation decreases.`))],compute:function(e,t,n,r,i={value:2}){let a=I(e,this.locale),o=I(t,this.locale),s=I(n,this.locale),c=I(r,this.locale),l=I(i,this.locale);if(a<0)return new F(qQ(a));if(o<0)return new F(M$(o));if(c<=0)return new F(C$(c));if(s<=0)return new F(f$(s));if(c>s)return new F(S$(c,s));if(l<=0)return new F(ZQ(l));if(a===0||o>=a)return{value:0,format:Q1};let u=l/s;if(u>1)return{value:c===1?a-o:0,format:Q1};if(c<=1)return{value:a*u,format:Q1};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:Q1}},isExported:!0},e0={description:N(`Discount rate of a security based on price.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`price (number)`,N(`The price at which the security is bought per 100 face value.`)),H(`redemption (number)`,N(`The redemption amount per 100 face value, or par.`)),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(I(e,this.locale)),o=Math.trunc(I(t,this.locale)),s=I(n,this.locale),c=I(r,this.locale),l=Math.trunc(I(i,this.locale));if(a>=o)return new F(p$(a,o));if(H$(l))return new F(XQ(l));if(s<=0)return new F(T$(s));if(c<=0)return new F(j$(c));let u=eo(a,o,l);return{value:(c-s)/c/u}},isExported:!0},t0={description:N(`Convert a decimal fraction to decimal value.`),args:[H(`fractional_price (number)`,N(`The price quotation given using fractional decimal conventions.`)),H(`unit (number)`,N(`The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.`))],compute:function(e,t){let n=I(e,this.locale),r=Math.trunc(I(t,this.locale));if(r<=0)return new F(z$(r));let i=Math.trunc(n);return{value:i+(n-i)*(10**Math.ceil(Math.log10(r))/r)}},isExported:!0},n0={description:N(`Convert a decimal value to decimal fraction.`),args:[H(`decimal_price (number)`,N(`The price quotation given as a decimal value.`)),H(`unit (number)`,N(`The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds.`))],compute:function(e,t){let n=I(e,this.locale),r=Math.trunc(I(t,this.locale));if(r<=0)return new F(z$(r));let i=Math.trunc(n);return{value:i+(n-i)*(r/10**Math.ceil(Math.log10(r)))}},isExported:!0},r0={description:N(`Number of periods for an investment to reach a value.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`rate (number)`,N(`The annualized rate of interest.`)),H(`yield (number)`,N(`The expected annual yield of the security.`)),H(`frequency (number)`,N(`The number of interest or coupon payments per year (1, 2, or 4).`),L1),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i,a={value:0}){let o=Math.trunc(I(e,this.locale)),s=Math.trunc(I(t,this.locale)),c=I(n,this.locale),l=I(r,this.locale),u=Math.trunc(I(i,this.locale)),d=Math.trunc(I(a,this.locale));if(o>=s)return new F(p$(o,s));if(U$(u))return new F(YQ(u));if(H$(d))return new F(XQ(d));if(c<0)return new F(k$(c));if(l<0)return new F(B$(l));let f=eo(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{value:_===0?0:v/_}},isExported:!0},i0={description:N(`Annual effective interest rate.`),args:[H(`nominal_rate (number)`,N(`The nominal interest rate per year.`)),H(`periods_per_year (number)`,N(`The number of compounding periods per year.`))],compute:function(e,t){let n=I(e,this.locale),r=Math.trunc(I(t,this.locale));return n<=0?new F(h$(n)):r<=0?new F(x$(r)):{value:(1+n/r)**+r-1}},isExported:!0};function a0(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 o0={description:N(`Future value of an annuity investment.`),args:[H(`rate (number)`,N(`The interest rate.`)),H(`number_of_periods (number)`,N(`The number of payments to be made.`)),H(`payment_amount (number)`,N(`The amount per period to be paid.`)),H(`present_value (number, default=0)`,N(`The current value of the annuity.`)),H(`end_or_beginning (number, default=0)`,N(`The timing of the payment payments are due for each period.`),R1)],compute:function(e,t,n,r={value:0},i={value:0}){return r||=0,i||=0,{value:a0(I(e,this.locale),I(t,this.locale),I(n,this.locale),I(r,this.locale),+!!R(i)),format:`#,##0.00`}},isExported:!0},s0={description:N(`Future value of principal from series of rates.`),args:[H(`principal (number)`,N(`The amount of initial capital or value to compound against.`)),H(`rate_schedule (number, range<number>)`,N(`A series of interest rates to compound against the principal.`))],compute:function(e,t){let n=I(e,this.locale);return{value:is([t],(e,t)=>e*(1+I(t,this.locale)),n)}},isExported:!0},c0={description:N(`Calculates effective interest rate.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`investment (number)`,N(`The amount invested in the security.`)),H(`redemption (number)`,N(`The amount to be received at maturity.`)),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i={value:0}){let a=Math.trunc(I(e,this.locale)),o=Math.trunc(I(t,this.locale)),s=I(r,this.locale),c=I(n,this.locale),l=Math.trunc(I(i,this.locale));if(a>=o)return new F(p$(a,o));if(c<=0)return new F(c$(c));if(s<=0)return new F(j$(s));if(H$(l))return new F(XQ(l));let u=eo(a,o,l);return{value:(s-c)/c/u}},isExported:!0};function l0(e,t,n,r,i,a){return x0(e,n,r,i,a)-C0(e,t,n,r,i,a)}let u0={description:N(`Payment on the principal of an investment.`),args:[H(`rate (number)`,N(`The annualized rate of interest.`)),H(`period (number)`,N(`The amortization period, in terms of number of periods.`)),H(`number_of_periods (number)`,N(`The number of payments to be made.`)),H(`present_value (number)`,N(`The current value of the annuity.`)),H(`future_value (number, default=0)`,N(`The future value remaining after the final payment has been made.`)),H(`end_or_beginning (number, default=0)`,N(`The timing of the payment payments are due for each period.`),R1)],compute:function(e,t,n,r,i={value:0},a={value:0}){return{value:l0(I(e,this.locale),I(t,this.locale),I(n,this.locale),I(r,this.locale),I(i,this.locale),+!!R(a)),format:`#,##0.00`}},isExported:!0},d0=.1,f0={description:N(`Internal rate of return given periodic cashflows.`),args:[H(`cashflow_amounts (number, range<number>)`,N(`An array or range containing the income or payments associated with the investment.`)),H(`rate_guess (number, default=${d0})`,N(`An estimate for what the internal rate of return will be.`))],compute:function(e,t={value:d0}){let n=I(t,this.locale);if(n<=-1)return new F(O$(n));let r=!1,i=!1,a=[];if(ns([e],({value:e})=>{e>0&&(r=!0),e<0&&(i=!0),a.push(e)},this.locale),!r||!i)return new F(KQ);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:B1(l,u,n+1,20,1e-5)-1,format:`0%`}},isExported:!0},p0={description:N(`Returns the interest paid at a particular period of an investment.`),args:[H(`rate (number)`,N(`The interest rate.`)),H(`period (number)`,N(`The period for which you want to view the interest payment.`)),H(`number_of_periods (number)`,N(`The number of payments to be made.`)),H(`present_value (number)`,N(`The current value of the annuity.`))],compute:function(e,t,n,r){let i=I(e,this.locale),a=I(t,this.locale),o=I(n,this.locale),s=I(r,this.locale);return o===0?new F(g$(o)):{value:-1*(s-a/o*s)*i}},isExported:!0},m0={description:N(`Modified Macaulay duration.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`rate (number)`,N(`The annualized rate of interest.`)),H(`yield (number)`,N(`The expected annual yield of the security.`)),H(`frequency (number)`,N(`The number of interest or coupon payments per year (1, 2, or 4).`),L1),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`))],compute:function(e,t,n,r,i,a={value:0}){let o=r0.compute.bind(this)(e,t,n,r,i,a),s=I(r,this.locale),c=Math.trunc(I(i,this.locale));return{value:I(o,this.locale)/(1+s/c)}},isExported:!0},h0={description:N(`Modified internal rate of return.`),args:[H(`cashflow_amounts (range<number>)`,N(`A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.`)),H(`financing_rate (number)`,N(`The interest rate paid on funds invested.`)),H(`reinvestment_return_rate (number)`,N(`The return (as a percentage) earned on reinvestment of income received from the investment.`))],compute:function(e,t,n){let r=I(t,this.locale),i=I(n,this.locale),a=us(e).flat().filter(e=>e.value!==null).map(e=>I(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 F(KQ);let l=1/(o-1);return{value:(-s/c)**l-1}},isExported:!0},g0={description:N(`Annual nominal interest rate.`),args:[H(`effective_rate (number)`,N(`The effective interest rate per year.`)),H(`periods_per_year (number)`,N(`The number of compounding periods per year.`))],compute:function(e,t){let n=I(e,this.locale),r=Math.trunc(I(t,this.locale));return n<=0?new F(t$(n)):r<=0?new F(x$(r)):{value:((n+1)**(1/r)-1)*r}},isExported:!0},_0={description:N(`Number of payment periods for an investment.`),args:[H(`rate (number)`,N(`The interest rate.`)),H(`payment_amount (number)`,N(`The amount of each payment made.`)),H(`present_value (number)`,N(`The current value of the annuity.`)),H(`future_value (number, default=0)`,N(`The future value remaining after the final payment has been made.`)),H(`end_or_beginning (number, default=0)`,N(`The timing of the payment payments are due for each period.`),R1)],compute:function(e,t,n,r={value:0},i={value:0}){r||=0,i||=0;let a=I(e,this.locale),o=I(t,this.locale),s=I(n,this.locale),c=I(r,this.locale),l=+!!R(i);if(a===0)return{value:-(c+s)/o};let u=o*(1+a*l)/a;return{value:Math.log((u-c)/(s+u))/Math.log(1+a)}},isExported:!0};function v0(e,t,n,r){let i=0;return as(n,(t,n)=>(i++,t+n/(1+e)**i),t,r)}let y0={description:N(`The net present value of an investment based on a series of periodic cash flows and a discount rate.`),args:[H(`discount (number)`,N(`The discount rate of the investment over one period.`)),H(`cashflow (number, range<number>, repeating)`,N(`The future cash flows.`))],compute:function(e,...t){let n=I(e,this.locale);return n===-1?new F(QQ(n)):{value:v0(n,0,t,this.locale),format:`#,##0.00`}},isExported:!0},b0={description:N(`Computes the number of periods needed for an investment to reach a value.`),args:[H(`rate (number)`,N(`The rate at which the investment grows each period.`)),H(`present_value (number)`,N(`The investment's current value.`)),H(`future_value (number)`,N(`The investment's desired future value.`))],compute:function(e,t,n){let r=I(e,this.locale),i=I(t,this.locale),a=I(n,this.locale);return r<=0?new F(A$(r)):i<=0?new F(w$(i)):a<=0?new F(s$(a)):{value:(Math.log(a)-Math.log(i))/Math.log(1+r)}},isExported:!0};function x0(e,t,n,r,i){if(t<=0)throw new F(_$(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 S0={description:N(`Periodic payment for an annuity investment.`),args:[H(`rate (number)`,N(`The annualized rate of interest.`)),H(`number_of_periods (number)`,N(`The number of payments to be made.`)),H(`present_value (number)`,N(`The current value of the annuity.`)),H(`future_value (number, default=0)`,N(`The future value remaining after the final payment has been made.`)),H(`end_or_beginning (number, default=0)`,N(`The timing of the payment payments are due for each period.`),R1)],compute:function(e,t,n,r={value:0},i={value:0}){let a=I(t,this.locale),o=I(e,this.locale),s=+!!R(i),c=I(r,this.locale);return{value:x0(o,a,I(n,this.locale),c,s),format:`#,##0.00`}},isExported:!0};function C0(e,t,n,r,i,a){if(n<=0)throw new F(_$(n));if(t<=0||t>n)throw new F(v$(n));let o=x0(e,n,r,i,a);return a===1&&t===1?o:o+-a0(e,a===0?t-1:t-2,o,r+o*a,0)*e}let w0={description:N(`Payment on the principal of an investment.`),args:[H(`rate (number)`,N(`The annualized rate of interest.`)),H(`period (number)`,N(`The amortization period, in terms of number of periods.`)),H(`number_of_periods (number)`,N(`The number of payments to be made.`)),H(`present_value (number)`,N(`The current value of the annuity.`)),H(`future_value (number, default=0)`,N(`The future value remaining after the final payment has been made.`)),H(`end_or_beginning (number, default=0)`,N(`The timing of the payment payments are due for each period.`),R1)],compute:function(e,t,n,r,i={value:0},a={value:0}){let o=I(n,this.locale),s=I(e,this.locale),c=I(t,this.locale),l=+!!R(a),u=I(i,this.locale);return{value:C0(s,c,o,I(r,this.locale),u,l),format:`#,##0.00`}},isExported:!0},T0={description:N(`Present value of an annuity investment.`),args:[H(`rate (number)`,N(`The interest rate.`)),H(`number_of_periods (number)`,N(`The number of payments to be made.`)),H(`payment_amount (number)`,N(`The amount per period to be paid.`)),H(`future_value (number, default=0)`,N(`The future value remaining after the final payment has been made.`)),H(`end_or_beginning (number, default=0)`,N(`The timing of the payment payments are due for each period.`),R1)],compute:function(e,t,n,r={value:0},i={value:0}){r||=0,i||=0;let a=I(e,this.locale),o=I(t,this.locale),s=I(n,this.locale),c=I(r,this.locale),l=+!!R(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},E0={description:N(`Price of a security paying periodic interest.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`rate (number)`,N(`The annualized rate of interest.`)),H(`yield (number)`,N(`The expected annual yield of the security.`)),H(`redemption (number)`,N(`The redemption amount per 100 face value, or par.`)),H(`frequency (number)`,N(`The number of interest or coupon payments per year (1, 2, or 4).`),L1),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=Math.trunc(I(e,this.locale)),c=Math.trunc(I(t,this.locale)),l=I(n,this.locale),u=I(r,this.locale),d=I(i,this.locale),f=Math.trunc(I(a,this.locale)),p=Math.trunc(I(o,this.locale));if(s>=c)return new F(p$(s,c));if(U$(f))return new F(YQ(f));if(H$(p))return new F(XQ(p));if(l<0)return new F(k$(l));if(u<0)return new F(B$(u));if(d<=0)return new F(j$(d));let m=eo(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{value:(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{value:d/_**(h-1+g)+ee-v*(1-g)}},isExported:!0},D0={description:N(`Price of a discount security.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`discount (number)`,N(`The discount rate of the security at time of purchase.`)),H(`redemption (number)`,N(`The redemption amount per 100 face value, or par.`)),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(I(e,this.locale)),o=Math.trunc(I(t,this.locale)),s=I(n,this.locale),c=I(r,this.locale),l=Math.trunc(I(i,this.locale));if(a>=o)return new F(p$(a,o));if(H$(l))return new F(XQ(l));if(s<=0)return new F($Q(s));if(c<=0)return new F(j$(c));let u=eo(a,o,l);return{value:c-s*c*u}},isExported:!0},O0={description:N(`Calculates the price of a security paying interest at maturity, based on expected yield.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`issue (date)`,N(`The date the security was initially issued.`)),H(`rate (number)`,N(`The annualized rate of interest.`)),H(`yield (number)`,N(`The expected annual yield of the security.`)),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i,a={value:0}){a||=0;let o=Math.trunc(I(e,this.locale)),s=Math.trunc(I(t,this.locale)),c=Math.trunc(I(n,this.locale)),l=I(r,this.locale),u=I(i,this.locale),d=Math.trunc(I(a,this.locale));if(o<=c)return new F(I$(o,c));if(o>=s)return new F(p$(o,s));if(H$(d))return new F(XQ(d));if(l<0)return new F(k$(l));if(u<0)return new F(B$(u));let f=eo(o,s,d),p=eo(o,c,d),m=100+eo(c,s,d)*l*100,h=1+f*u,g=p*l*100;return{value:m/h-g}},isExported:!0},k0=.1,A0={description:N(`Interest rate of an annuity investment.`),args:[H(`number_of_periods (number)`,N(`The number of payments to be made.`)),H(`payment_per_period (number)`,N(`The amount per period to be paid.`)),H(`present_value (number)`,N(`The current value of the annuity.`)),H(`future_value (number, default=0)`,N(`The future value remaining after the final payment has been made.`)),H(`end_or_beginning (number, default=0)`,N(`The timing of the payment payments are due for each period.`),R1),H(`rate_guess (number, default=${k0})`,N(`An estimate for what the interest rate will be.`))],compute:function(e,t,n,r={value:0},i={value:0},a={value:k0}){let o=I(e,this.locale),s=I(t,this.locale),c=+!!R(i),l=I(a,this.locale)||k0,u=I(r,this.locale),d=I(n,this.locale);return o<=0?new F(_$(o)):V$([s,d,u])?l<=-1?new F(O$(l)):(u-=s*c,d+=s*c,{value:B1(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 F(N(`There must be both positive and negative values in [payment_amount, present_value, future_value].`))},isExported:!0},j0={description:N(`Amount received at maturity for a security.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`investment (number)`,N(`The amount invested (irrespective of face value of each security).`)),H(`discount (number)`,N(`The discount rate of the security invested in.`)),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(I(e,this.locale)),o=Math.trunc(I(t,this.locale)),s=I(n,this.locale),c=I(r,this.locale),l=Math.trunc(I(i,this.locale));return a>=o?new F(p$(a,o)):H$(l)?new F(XQ(l)):s<=0?new F(c$(s)):c<=0?new F($Q(c)):{value:s/(1-c*eo(a,o,l))}},isExported:!0},M0={description:N(`Computes the rate needed for an investment to reach a specific value within a specific number of periods.`),args:[H(`number_of_periods (number)`,N(`The number of periods.`)),H(`present_value (number)`,N(`The present value of the investment.`)),H(`future_value (number)`,N(`The future value of the investment.`))],compute:function(e,t,n){let r=I(e,this.locale),i=I(t,this.locale),a=I(n,this.locale);return r<=0?new F(_$(r)):{value:(a/i)**(1/r)-1}},isExported:!0},N0={description:N(`Depreciation of an asset using the straight-line method.`),args:[H(`cost (number)`,N(`The initial cost of the asset.`)),H(`salvage (number)`,N(`The value of the asset at the end of depreciation.`)),H(`life (number)`,N(`The number of periods over which the asset is depreciated.`))],compute:function(e,t,n){let r=I(e,this.locale),i=I(t,this.locale),a=I(n,this.locale);return{value:(r-i)/a,format:`#,##0.00`}},isExported:!0},P0={description:N(`Depreciation via sum of years digit method.`),args:[H(`cost (number)`,N(`The initial cost of the asset.`)),H(`salvage (number)`,N(`The value of the asset at the end of depreciation.`)),H(`life (number)`,N(`The number of periods over which the asset is depreciated.`)),H(`period (number)`,N(`The single period within life for which to calculate depreciation.`))],compute:function(e,t,n,r){let i=I(e,this.locale),a=I(t,this.locale),o=I(n,this.locale),s=I(r,this.locale);if(s<=0)return new F(C$(s));if(o<=0)return new F(f$(o));if(s>o)return new F(S$(s,o));let c=o*(o+1)/2,l=o-s+1;return{value:(i-a)*(l/c),format:`#,##0.00`}},isExported:!0};function F0(e,t,n){return 100*(1-n*eo(e,t,2))}let I0={description:N(`Price of a US Treasury bill.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`discount (number)`,N(`The discount rate of the bill at time of purchase.`))],compute:function(e,t,n){let r=Math.trunc(I(e,this.locale)),i=Math.trunc(I(t,this.locale)),a=I(n,this.locale);return r>=i?new F(p$(r,i)):W$(r,i,this.locale)?a<=0?new F($Q(a)):a>=1?new F(e$(a)):{value:F0(r,i,a)}:new F(F$(r,i))},isExported:!0},L0={description:N(`Equivalent rate of return for a US Treasury bill.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`discount (number)`,N(`The discount rate of the bill at time of purchase.`))],compute:function(e,t,n){let r=Math.trunc(I(e,this.locale)),i=Math.trunc(I(t,this.locale)),a=I(n,this.locale);if(r>=i)return new F(p$(r,i));if(!W$(r,i,this.locale))return new F(F$(r,i));if(a<=0)return new F($Q(a));if(a>=1)return new F(e$(a));let o=Q$.compute.bind(this)({value:i},{value:r}).value;if(o<=182)return{value:365*a/(360-a*o)};let s=F0(r,i,a)/100,c=o/(o===366?366:365);return{value:(-2*c+2*Math.sqrt(c**2-(2*c-1)*(1-1/s)))/(2*c-1)}},isExported:!0},R0={description:N(`The yield of a US Treasury bill based on price.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`price (number)`,N(`The price at which the security is bought per 100 face value.`))],compute:function(e,t,n){let r=Math.trunc(I(e,this.locale)),i=Math.trunc(I(t,this.locale)),a=I(n,this.locale);if(r>=i)return new F(p$(r,i));if(!W$(r,i,this.locale))return new F(F$(r,i));if(a<=0)return new F(T$(a));let o=eo(r,i,2);return{value:(100-a)/a*(1/o)}},isExported:!0},z0={description:N(`Variable declining balance. WARNING : does not handle decimal periods.`),args:[H(`cost (number)`,N(`The initial cost of the asset.`)),H(`salvage (number)`,N(`The value of the asset at the end of depreciation.`)),H(`life (number)`,N(`The number of periods over which the asset is depreciated.`)),H(`start (number)`,N(`Starting period to calculate depreciation.`)),H(`end (number)`,N(`Ending period to calculate depreciation.`)),H(`factor (number, default=2)`,N(`The number of months in the first year of depreciation.`)),H(`no_switch (number, default=false)`,N(`Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation.`),[{value:!1,label:N(`Switch to straight-line depreciation`)},{value:!0,label:N(`Do not switch to straight-line depreciation`)}])],compute:function(e,t,n,r,i,a={value:2},o={value:!1}){a||=0;let s=I(e,this.locale),c=I(t,this.locale),l=I(n,this.locale),u=Math.trunc(I(r,this.locale)),d=Math.trunc(I(i,this.locale)),f=I(a,this.locale),p=R(o);if(s<0)return new F(qQ(s));if(c<0)return new F(M$(c));if(l<=0)return new F(f$(l));if(u<0)return new F(L$(u));if(d<0)return new F(n$(d));if(u>d)return new F(R$(u,d));if(d>l)return new F(r$(d,l));if(f<=0)return new F(ZQ(f));if(s===0)return{value:0};if(c>=s)return{value:u<1?s-c:0};let m=f/l;if(m>=1)return{value: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{value:_}},isExported:!0},B0={description:N(`Internal rate of return given non-periodic cash flows.`),args:[H(`cashflow_amounts (range<number>)`,N(`An range containing the income or payments associated with the investment.`)),H(`cashflow_dates (range<number>)`,N(`An range with dates corresponding to the cash flows in cashflow_amounts.`)),H(`rate_guess (number, default=${k0})`,N(`An estimate for what the internal rate of return will be.`))],compute:function(e,t,n={value:k0}){let r=I(n,this.locale);if(!dS(e,t))return new F(GQ);let i=e.flat().map(e=>I(e,this.locale)),a=t.flat().map(e=>I(e,this.locale));if(!V$(i))return new F(KQ);if(a.some(e=>e<a[0]))return new F(i$(a[0]));if(r<=-1)return new F(O$(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{value:B1(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},V0={description:N(`Net present value given to non-periodic cash flows..`),args:[H(`discount (number)`,N(`The discount rate of the investment over one period.`)),H(`cashflow_amounts (number, range<number>)`,N(`An range containing the income or payments associated with the investment.`)),H(`cashflow_dates (number, range<number>)`,N(`An range with dates corresponding to the cash flows in cashflow_amounts.`))],compute:function(e,t,n){let r=I(e,this.locale);if(!dS(t,n))return new F(GQ);let i=z(t).flat().map(e=>Go(e,this.locale)),a=z(n).flat().map(e=>Go(e,this.locale));if(a.some(e=>e<a[0]))return new F(i$(a[0]));if(r<=0)return new F(A$(r));if(i.length===1)return{value: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{value:l}},isExported:!0},H0={description:N(`Annual yield of a security paying periodic interest.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`rate (number)`,N(`The annualized rate of interest.`)),H(`price (number)`,N(`The price at which the security is bought per 100 face value.`)),H(`redemption (number)`,N(`The redemption amount per 100 face value, or par.`)),H(`frequency (number)`,N(`The number of interest or coupon payments per year (1, 2, or 4).`),L1),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i,a,o={value:0}){o||=0;let s=Math.trunc(I(e,this.locale)),c=Math.trunc(I(t,this.locale)),l=I(n,this.locale),u=I(r,this.locale),d=I(i,this.locale),f=Math.trunc(I(a,this.locale)),p=Math.trunc(I(o,this.locale));if(s>=c)return new F(p$(s,c));if(U$(f))return new F(YQ(f));if(H$(p))return new F(XQ(p));if(l<0)return new F(k$(l));if(u<=0)return new F(T$(u));if(d<=0)return new F(j$(d));let m=eo(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{value:(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{value:(B1(y,b,1+(l+1)/f,100,1e-5)-1)*f}},isExported:!0},U0={description:N(`Annual yield of a discount security.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`price (number)`,N(`The price at which the security is bought per 100 face value.`)),H(`redemption (number)`,N(`The redemption amount per 100 face value, or par.`)),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i={value:0}){i||=0;let a=Math.trunc(I(e,this.locale)),o=Math.trunc(I(t,this.locale)),s=I(n,this.locale),c=I(r,this.locale),l=Math.trunc(I(i,this.locale));if(a>=o)return new F(p$(a,o));if(H$(l))return new F(XQ(l));if(s<=0)return new F(T$(s));if(c<=0)return new F(j$(c));let u=eo(a,o,l);return{value:(c/s-1)/u}},isExported:!0},W0={description:N(`Annual yield of a security paying interest at maturity.`),args:[H(`settlement (date)`,N(`The settlement date of the security, the date after issuance when the security is delivered to the buyer.`)),H(`maturity (date)`,N(`The maturity or end date of the security, when it can be redeemed at face, or par value.`)),H(`issue (date)`,N(`The date the security was initially issued.`)),H(`rate (number)`,N(`The annualized rate of interest.`)),H(`price (number)`,N(`The price at which the security is bought.`)),H(`day_count_convention (number, default=0 )`,N(`An indicator of what day count method to use.`),G$)],compute:function(e,t,n,r,i,a={value:0}){a||=0;let o=Math.trunc(I(e,this.locale)),s=Math.trunc(I(t,this.locale)),c=Math.trunc(I(n,this.locale)),l=I(r,this.locale),u=I(i,this.locale),d=Math.trunc(I(a,this.locale));if(o>=s)return new F(p$(o,s));if(H$(d))return new F(XQ(d));if(o<c)return new F(P$(o,c));if(l<0)return new F(k$(l));if(u<=0)return new F(T$(u));let f=eo(c,s,d),p=eo(c,o,d),m=eo(o,s,d);return{value:(100*(1+l*f)/(u+100*l*p)-1)/m}},isExported:!0};var G0=l({CELL:()=>q0,ISBLANK:()=>t2,ISERR:()=>J0,ISERROR:()=>Y0,ISFORMULA:()=>r2,ISLOGICAL:()=>X0,ISNA:()=>Z0,ISNONTEXT:()=>Q0,ISNUMBER:()=>$0,ISTEXT:()=>e2,NA:()=>n2});let K0=[{value:`address`,label:N(`Returns an absolute reference as plain text of the top left cell in reference.`)},{value:`col`,label:N(`Returns the column number of the cell in reference.`)},{value:`contents`,label:N(`Returns the value contained in the top left cell in reference.`)},{value:`format`,label:N(`Returns the format of the top left cell in reference.`)},{value:`row`,label:N(`Returns the row number of the top left cell in reference.`)},{value:`type`,label:N(`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.`)}],q0={description:N(`Gets information about a cell.`),args:[H(`info_type (string)`,N(`The type of information requested.`),K0),H(`reference (any, range<any>)`,N(`The reference to the cell.`))],compute:function(e,t){let n=L(e).toLowerCase();if(!K0.map(e=>e.value).includes(n))return new F(N(`The info_type should be one of %s.`,K0.join(`, `)));let r=z(t)[0][0],i=r.position;if(i===void 0)return new F(N(`The reference is invalid.`));switch(n){case`address`:return{value:(this.__originSheetId===i.sheetId?``:this.getters.getSheetName(i.sheetId)+`!`)+E(i.col,i.row,{colFixed:!0,rowFixed:!0})};case`col`:return{value:i.col+1};case`contents`:return{value:r.value};case`format`:return{value:r.format||``};case`row`:return{value:i.row+1};case`type`:return r.value===null?{value:`b`}:Bc(r.format)?{value:`l`}:typeof r.value==`number`||typeof r.value==`boolean`?{value:`v`}:{value:`l`}}return{value:``}},isExported:!0},J0={description:N(`Whether a value is an error other than #N/A.`),args:[H(`value (any)`,N(`The value to be verified as an error type.`))],compute:function(e){let t=e?.value;return{value:Lo(t)&&t!==P.NotAvailable}},isExported:!0},Y0={description:N(`Whether a value is an error.`),args:[H(`value (any)`,N(`The value to be verified as an error type.`))],compute:function(e){let t=e?.value;return{value:Lo(t)}},isExported:!0},X0={description:N("Whether a value is `true` or `false`."),args:[H(`value (any)`,N(`The value to be verified as a logical TRUE or FALSE.`))],compute:function(e){return{value:typeof e?.value==`boolean`}},isExported:!0},Z0={description:N(`Whether a value is the error #N/A.`),args:[H(`value (any)`,N(`The value to be verified as an error type.`))],compute:function(e){return{value:e?.value===P.NotAvailable}},isExported:!0},Q0={description:N(`Whether a value is non-textual.`),args:[H(`value (any)`,N(`The value to be checked.`))],compute:function(e){return{value:!e2.compute.bind(this)(e).value}},isExported:!0},$0={description:N(`Whether a value is a number.`),args:[H(`value (any)`,N(`The value to be verified as a number.`))],compute:function(e){return{value:typeof e?.value==`number`}},isExported:!0},e2={description:N(`Whether a value is text.`),args:[H(`value (any)`,N(`The value to be verified as text.`))],compute:function(e){return{value:typeof e?.value==`string`&&Lo(e?.value)===!1}},isExported:!0},t2={description:N(`Whether the referenced cell is empty`),args:[H(`value (any)`,N(`Reference to the cell that will be checked for emptiness.`))],compute:function(e){return{value:e?.value===null}},isExported:!0},n2={description:N(`Returns the error value #N/A.`),args:[],compute:function(){return{value:P.NotAvailable}},isExported:!0},r2={description:N(`Checks whether there is a reference to a cell that contains a formula, and returns TRUE or FALSE.`),args:[H(`cell_reference (any)`,N(`A reference to a cell.`))],compute:function(e){return e?.position===void 0?new ko(Bo):{value:this.getters.getCell(e.position)?.isFormula??!1}},isExported:!0};var i2=l({AND:()=>a2,FALSE:()=>o2,IF:()=>s2,IFERROR:()=>c2,IFNA:()=>l2,IFS:()=>u2,NOT:()=>d2,OR:()=>f2,SWITCH:()=>p2,TRUE:()=>m2,XOR:()=>h2});let a2={description:N("Logical `and` operator."),args:[H(`logical_expression (boolean, range<boolean>, repeating)`,N(`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}=iS(e);return n?{value:t}:new F(ws)},isExported:!0},o2={description:N("Logical value `false`."),args:[],compute:function(){return{value:!1}},isExported:!0},s2={description:N(`Returns value depending on logical expression.`),args:[H(`logical_expression (boolean, range<boolean>)`,N(`An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.`)),H(`value_if_true (any, range)`,N(`The value the function returns if logical_expression is TRUE.`)),H(`value_if_false (any, range, default=FALSE)`,N(`The value the function returns if logical_expression is FALSE.`))],computeArray:function(e,t,n){if(mg(e)){let r=ul.get(`IF`);return $c(this,r,[e,t,n],tl(r,3),hg([e,t,n]))}return(R(fg(e))?t:n)??{value:0}},isExported:!0},c2={description:N(`Value if it is not an error, otherwise 2nd argument.`),args:[H(`value (any, range)`,N(`The value to return if value itself is not an error.`)),H(`value_if_error (any, range, default="empty")`,N(`The value the function returns if value is an error.`))],computeArray:function(e,t){if(mg(e)){let n=ul.get(`IFERROR`);return $c(this,n,[e,t],tl(n,2),hg([e,t]))}return(Lo(fg(e)?.value)?t:e)??{value:0}},isExported:!0},l2={description:N(`Value if it is not an #N/A error, otherwise 2nd argument.`),args:[H(`value (any, range)`,N(`The value to return if value itself is not #N/A an error.`)),H(`value_if_error (any, range, default="empty")`,N(`The value the function returns if value is an #N/A error.`))],computeArray:function(e,t){if(mg(e)){let n=ul.get(`IFNA`);return $c(this,n,[e,t],tl(n,2),hg([e,t]))}return(fg(e)?.value===P.NotAvailable?t:e)??{value:0}},isExported:!0},u2={description:N(`Returns a value depending on multiple logical expressions.`),args:[H(`condition (any, range, repeating)`,N(`The condition to be evaluated. It can be a boolean, a number, an array, or a reference to any of those.`)),H(`value (any, range, repeating)`,N(`The value to be returned if its corresponding condition is TRUE.`))],computeArray:function(...e){if(e.length%2!=0)return new F(N(`Wrong number of arguments. Expected an even number of arguments.`));for(;e.length>0;){if(mg(e[0])){let t=ul.get(`IFS`);return $c(this,t,e,tl(t,e.length),hg(e))}let t=R(fg(e.shift())),n=e.shift();if(t)return n??{value:0}}return new F(N(`No match.`))},isExported:!0},d2={description:N(`Returns opposite of provided logical value.`),args:[H(`logical_expression (boolean)`,N(`An expression or reference to a cell holding an expression that represents some logical value.`))],compute:function(e){return{value:!R(e)}},isExported:!0},f2={description:N("Logical `or` operator."),args:[H(`logical_expression (boolean, range<boolean>, repeating)`,N(`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}=aS(e);return n?{value:t}:new F(ws)},isExported:!0},p2={description:N(`Returns a value by comparing cases to an expression.`),args:[H(`expression (number, boolean, string)`,N(`The value to be checked.`)),H(`case (any, repeating)`,N(`Case to be checked against expression.`)),H(`value (any, repeating)`,N(`Value to be returned if its corresponding case matches expression.`)),H(`default (any, default="empty")`,N(`An optional default value to be returned if none of the cases match expression.`))],compute:function(e,...t){let n=t.length%2==0?Ro(e):t.pop();for(let n=0;n<t.length;n+=2){let r=t[n];if(r&&Lo(r.value))return r;if(e?.value===r?.value)return t[n+1]||{value:0}}return n||{value:0}},isExported:!0},m2={description:N("Logical value `true`."),args:[],compute:function(){return{value:!0}},isExported:!0},h2={description:N("Logical `xor` operator."),args:[H(`logical_expression (boolean, range<boolean>, repeating)`,N(`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 fs(e,e=>(t=!0,n=n?!e:e,!0)),t?{value:n}:new F(ws)},isExported:!0};function g2(e,t){let n=t.getPivotId(e);if(!n)throw new F(N(`There is no pivot with id "%s"`,e));return n}function _2(e,t,n){let{measures:r}=n.getPivotCoreDefinition(e);if(!r.find(e=>e.id===t))throw new F(N(`The argument %s is not a valid measure. Here are the measures: %s`,t,`(${r.map(e=>e.id).join(`, `)})`))}function v2(e){if(e.length%2!=0)throw new F(N(`Function PIVOT takes an even number of arguments.`))}function y2(e,t,n){let r=[],i=e.getters.getPivotCoreDefinition(t);if(i.type===`SPREADSHEET`&&i.dataSet){let{sheetId:t,zone:n}=i.dataSet,a=or(n),o=e.getters.getRangeFromSheetXC(t,a);if(o===void 0||o.invalidXc||o.invalidSheetName)throw new ko;if(e.__originCellPosition&&o.sheetId===e.__originSheetId&&vr(D(e.__originCellPosition),n))throw new Oo;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 b2=l({ADDRESS:()=>C2,CHOOSE:()=>B2,COLUMN:()=>w2,COLUMNS:()=>T2,DROP:()=>V2,FORMULATEXT:()=>U2,HLOOKUP:()=>E2,INDEX:()=>D2,INDIRECT:()=>O2,LOOKUP:()=>k2,MATCH:()=>A2,OFFSET:()=>z2,PIVOT:()=>R2,PIVOT_HEADER:()=>L2,PIVOT_VALUE:()=>I2,ROW:()=>j2,ROWS:()=>M2,TAKE:()=>H2,VLOOKUP:()=>N2,XLOOKUP:()=>F2});let x2=[{value:!0,label:N(`A1 style (default)`)},{value:!1,label:N(`R1C1 style`)}],S2=[{value:!0,label:N(`Approximate match (default)`)},{value:!1,label:N(`Exact match`)}],C2={description:N(`Returns a cell reference as a string. `),args:[H(`row (number)`,N(`The row number of the cell reference. `)),H(`column (number)`,N(`The column number (not name) of the cell reference. A is column number 1. `)),H(`absolute_relative_mode (number, default=1)`,N(`An indicator of whether the reference is row/column absolute.`),[{value:1,label:N(`Absolute row and column (e.g. $A$1)`)},{value:2,label:N(`Absolute row, relative column (e.g. A$1)`)},{value:3,label:N(`Relative row, absolute column (e.g. $A1)`)},{value:4,label:N(`Relative row and column (e.g. A1)`)}]),H(`use_a1_notation (boolean, default=TRUE)`,N(`A boolean indicating whether to use A1 style notation or R1C1 style notation.`),x2),H(`sheet (string, optional)`,N(`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=qo(e,this.locale),o=qo(t,this.locale);if(a<1)return new F(pS(a));if(o<1)return new F(pS(o));let s=qo(n,this.locale);if(![1,2,3,4].includes(s))return new F(Vo(1,4,s));let c=R(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?{value:l}:{value:Tl(L(i),l)}},isExported:!0},w2={description:N(`Column number of a specified cell.`),args:[H(`cell_reference (any, range<any>, default='this cell')`,N(`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.`))],computeArray:function(e){if(e===void 0)return this.__originCellPosition===void 0?new F(N(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):{value:this.__originCellPosition.col+1};let t=z(e),n=t[0][0];if(n===void 0)return new F(N(`The range is out of bounds.`));if(n.position===void 0)return new ko(Bo);let r=n.position.col;return t.length===1?{value:r+1}:ss(t.length,1,e=>({value:r+e+1}))},isExported:!0},T2={description:N(`Number of columns in a specified array or range.`),args:[H(`range (any, range<any>)`,N(`The range whose column count will be returned.`))],compute:function(e){let t=z(e);return t[0][0]===void 0?new F(N(`The range is out of bounds.`)):t[0][0].value===P.InvalidReference?t[0][0]:{value:t.length}},isExported:!0},E2={description:N(`Horizontal lookup`),args:[H(`search_key (string, number, boolean)`,N(`The value to search for. For example, 42, 'Cats', or I24.`)),H(`range (any, range)`,N(`The range to consider for the search. The first row in the range is searched for the key specified in search_key.`)),H(`index (number)`,N(`The row index of the value to be returned, where the first row in range is numbered 1.`)),H(`is_sorted (boolean, default=true)`,N(`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.`),S2)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(I(n?.value,this.locale)),a=z(t);if(1>i||i>a[0].length)return new F(N(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[t][0].value,s=a[R(r.value)?_s(a,e,`nextSmaller`,`asc`,a.length,o):vs(a,e,`wildcard`,a.length,o,this.lookupCaches)];return s===void 0?Ro(e):s[i-1]},isExported:!0},D2={description:N(`Returns the content of a cell, specified by row and column offset.`),args:[H(`reference (any, range)`,N(`The range of cells from which the values are returned.`)),H(`row (number, default=0)`,N(`The index of the row to be returned from within the reference range of cells.`)),H(`column (number, default=0)`,N(`The index of the column to be returned from within the reference range of cells.`))],computeArray:function(e,t={value:0},n={value:0}){let r=z(e),i=I(t.value,this.locale),a=I(n.value,this.locale);return a<0||a-1>=r.length||i<0||i-1>=r[0].length?new F(N(`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},O2={description:N(`Returns the content of a cell, specified by a string.`),args:[H(`reference (string)`,N(`The range of cells from which the values are returned.`)),H(`use_a1_notation (boolean, default=TRUE)`,N(`A boolean indicating whether to use A1 style notation (TRUE) or R1C1 style notation (FALSE).`),x2)],computeArray:function(e,t={value:!0}){let n=e?.value?.toString();if(!n)return new ko(N(`Reference should be defined.`));if(!R(t))return new F(N(`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 ko;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},k2={description:N(`Look up a value.`),args:[H(`search_key (string, number, boolean)`,N(`The value to search for. For example, 42, 'Cats', or I24.`)),H(`search_array (any, range)`,N(`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.`)),H(`result_range (any, range, optional)`,N(`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=z(t),i=z(n),a=r.length,o=r[0].length,s=o>=a,c=_s(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?Ro(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 F(N(`The result_range must be a single row or a single column.`)):a>1?c>a-1?new F(N(`[[FUNCTION_NAME]] evaluates to an out of range row value %s.`,c+1)):i[c][0]:c>o-1?new F(N(`[[FUNCTION_NAME]] evaluates to an out of range column value %s.`,c+1)):i[0][c])},isExported:!0},A2={description:N(`Position of item in range that matches value.`),args:[H(`search_key (string, number, boolean)`,N(`The value to search for. For example, 42, 'Cats', or I24.`)),H(`range (any, range)`,N(`The one-dimensional array to be searched.`)),H(`search_type (number, default=1)`,N(`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:N(`Ascending order (default)`)},{value:0,label:N(`Exact match`)},{value:-1,label:N(`Descending order`)}])],compute:function(e,t,n={value:1}){let r=I(n,this.locale),i=z(t),a=i.length,o=i[0].length;if(a!==1&&o!==1)return new F(N(`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=_s(i,e,`nextSmaller`,`asc`,l,c);break;case 0:s=vs(i,e,`wildcard`,l,c,this.lookupCaches);break;case-1:s=_s(i,e,`nextGreater`,`desc`,l,c);break}return a===1&&i[0][s]===void 0||a!==1&&i[s]===void 0?Ro(e):{value:s+1}},isExported:!0},j2={description:N(`Row number of a specified cell.`),args:[H(`cell_reference (any, range<any>, default='this cell')`,N(`The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered.`))],computeArray:function(e){if(e===void 0)return this.__originCellPosition?.row===void 0?new F(N(`In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.`)):{value:this.__originCellPosition.row+1};let t=z(e),n=t[0][0];if(n===void 0)return new F(N(`The range is out of bounds.`));if(n.position===void 0)return new ko(Bo);let r=n.position.row;return t[0].length===1?{value:r+1}:ss(1,t[0].length,(e,t)=>({value:r+t+1}))},isExported:!0},M2={description:N(`Number of rows in a specified array or range.`),args:[H(`range (any, range<any>)`,N(`The range whose row count will be returned.`))],compute:function(e){let t=z(e);return t[0][0]===void 0?new F(N(`The range is out of bounds.`)):t[0][0].value===P.InvalidReference?t[0][0]:{value:t[0].length}},isExported:!0},N2={description:N(`Vertical lookup.`),args:[H(`search_key (string, number, boolean)`,N(`The value to search for. For example, 42, 'Cats', or I24.`)),H(`range (any, range)`,N(`The range to consider for the search. The first column in the range is searched for the key specified in search_key.`)),H(`index (number)`,N(`The column index of the value to be returned, where the first column in range is numbered 1.`)),H(`is_sorted (boolean, default=true)`,N(`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.`),S2)],compute:function(e,t,n,r={value:!0}){let i=Math.trunc(I(n?.value,this.locale)),a=z(t);if(1>i||i>a.length)return new F(N(`[[FUNCTION_NAME]] evaluates to an out of bounds range.`));let o=(e,t)=>e[0][t].value,s=R(r.value)?_s(a,e,`nextSmaller`,`asc`,a[0].length,o):vs(a,e,`wildcard`,a[0].length,o,this.lookupCaches),c=a[i-1][s];return c===void 0?Ro(e):c},isExported:!0},P2={0:`strict`,1:`nextGreater`,"-1":`nextSmaller`,2:`wildcard`},F2={description:N(`Search a range for a match and return the corresponding item from a second range.`),args:[H(`search_key (string,number,boolean)`,N(`The value to search for.`)),H(`lookup_range (any, range)`,N(`The range to consider for the search. Should be a single column or a single row.`)),H(`return_range (any, range)`,N(`The range containing the return value. Should have the same dimensions as lookup_range.`)),H(`if_not_found (any, optional)`,N(`If a valid match is not found, return this value.`)),H(`match_mode (any, default=0)`,N(`Specifies how to match search_key with the items in lookup_range. `),[{value:0,label:N(`Exact match (default)`)},{value:-1,label:N(`Exact match or next smaller item`)},{value:1,label:N(`Exact match or next larger item`)},{value:2,label:N(`Wildcard character match`)}]),H(`search_mode (any, default=1)`,N(`Specifies the search mode to use. By default, a first to last search will be used.`),[{value:1,label:N(`Search first to last (default)`)},{value:-1,label:N(`Search last to first`)},{value:2,label:N(`Binary search (sorted ascending order)`)},{value:-2,label:N(`Binary search (sorted descending order)`)}])],computeArray:function(e,t,n,r,i={value:0},a={value:1}){let o=Math.trunc(I(i.value,this.locale)),s=Math.trunc(I(a.value,this.locale)),c=z(t),l=z(n);if(c.length!==1&&c[0].length!==1)return new F(N(`lookup_range should be either a single row or single column.`));if(![1,-1,2,-2].includes(s))return new F(N(`search_mode should be a value in [-1, 1, -2, 2].`));if(![-1,0,1,2].includes(o))return new F(N(`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 F(N(`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 F(N(`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=P2[o],m=s===-1,h=s===2||s===-2?_s(c,e,p,s===2?`asc`:`desc`,f,d):vs(c,e,p,f,d,this.lookupCaches,m);return h===-1?r===void 0?Ro(e):[[r]]:u===`col`?l.map(e=>[e[h]]):[l[h]]},isExported:!0},I2={description:N(`Get the value from a pivot.`),args:[H(`pivot_id (number,string)`,N(`ID of the pivot.`)),H(`measure_name (string)`,N(`Name of the measure.`)),H(`domain_field_name (string,repeating,optional)`,N(`Field name.`)),H(`domain_value (number,string,boolean,repeating,optional)`,N(`Value.`))],compute:function(e,t,...n){let r=L(e),i=L(t),a=g2(r,this.getters);_2(a,i,this.getters),v2(n);let o=this.getters.getPivot(a),s=this.getters.getPivotCoreDefinition(a);y2(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=N(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${r})`);return{value:P.GenericError,message:N(`Dimensions don't match the pivot definition`)+`. `+e}}let l=o.parseArgsToPivotDomain(n);return this.getters.getPivotPresenceTracker(a,this.__originSheetId)?.trackValue(i,l),o.getPivotCellValueAndFormat(i,l)}},L2={description:N(`Get the header of a pivot.`),args:[H(`pivot_id (number,string)`,N(`ID of the pivot.`)),H(`domain_field_name (string,repeating,optional)`,N(`Field name.`)),H(`domain_value (number,string,value,repeating,optional)`,N(`Value.`))],compute:function(e,...t){let n=L(e),r=g2(n,this.getters);v2(t);let i=this.getters.getPivot(r);y2(this,r,[]),i.init({reload:i.needsReevaluation});let a=i.assertIsValid({throwOnError:!1});if(a)return a;if(!i.areDomainArgsFieldsValid(t)){let e=N(`Consider using a dynamic pivot formula: %s. Or re-insert the static pivot from the Data menu.`,`=PIVOT(${n})`);return{value:P.GenericError,message:N(`Dimensions don't match the pivot definition`)+`. `+e}}let o=i.parseArgsToPivotDomain(t);this.getters.getPivotPresenceTracker(r,this.__originSheetId)?.trackHeader(o);let s=o.at(-1);if(s?.field===`measure`)return i.getPivotMeasureValue(L(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}}},R2={description:N(`Get a pivot table.`),args:[H(`pivot_id (string)`,N(`ID of the pivot.`)),H(`row_count (number, optional)`,N(`number of rows`)),H(`include_total (boolean, default=TRUE)`,N(`Whether to include total/sub-totals or not.`)),H(`include_column_titles (boolean, default=TRUE)`,N(`Whether to include the column titles or not.`)),H(`column_count (number, optional)`,N(`number of columns`)),H(`include_measure_titles (boolean, default=TRUE)`,N(`Whether to include the measure titles row or not.`))],computeArray:function(e,t,n,r,i,a){let o=g2(L(e),this.getters),s=this.getters.getPivot(o),c=this.getters.getPivotCoreDefinition(o),l=OC(c,t,n,r,i,a,this.locale);if(l.numberOfRows<0)return new F(N(`The number of rows must be positive.`));if(l.numberOfColumns<0)return new F(N(`The number of columns must be positive.`));y2(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 F(ST(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(yC(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}},z2={description:N(`Returns a range reference shifted by a specified number of rows and columns from a starting cell reference.`),args:[H(`cell_reference (any, range<any>)`,N(`The starting point from which to count the offset rows and columns.`)),H(`offset_rows (number)`,N(`The number of rows to offset by.`)),H(`offset_columns (number)`,N(`The number of columns to offset by.`)),H(`height (number, default='height of cell_reference')`,N(`The number of rows of the range to return starting at the offset target.`)),H(`width (number, default='width of cell_reference')`,N(`The number of columns of the range to return starting at the offset target.`))],computeArray:function(e,t,n,r,i){if(e===void 0)return new ko(Bo);let a=z(e),o=a[0][0];if(o===void 0)return new F(N(`The range is out of bounds.`));if(o.position===void 0)return new ko(Bo);let s=a[0].length,c=a.length;if(r){let e=I(r,this.locale);if(e<1)return new F(N(`Height value is %(_height)s. It should be greater than or equal to 1.`,{_height:e}));s=e}if(i){let e=I(i,this.locale);if(e<1)return new F(N(`Width value is %(_width)s. It should be greater than or equal to 1.`,{_width:e}));c=e}let l=I(t,this.locale),u=I(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 ko(N(`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 ko:(d&&this.addDependencies?.(d,[g]),ss(c,s,(e,t)=>this.getFormulaResult({sheetId:h,col:f+e,row:p+t})))}},B2={description:N(`Returns an element from a list of choices based on index.`),args:[H(`index (number)`,N(`Which choice to return.`)),H(`choice (any, range<any>, repeating)`,N(`A potential value to return. May be a reference to a cell or an individual value.`))],computeArray:function(e,...t){let n=Math.floor(I(e,this.locale))-1;return n<0||n>=t.length?new F(N(`Index for CHOOSE is invalid. Valid values are between 1 and %(choices)s inclusive.`,{choices:t.length})):t[n]??new F(N(`Choice is undefined.`))},isExported:!0},V2={description:N(`Excludes a specified number of rows or columns from the start or end of an array.`),args:[H(`array (range)`,N(`The array from which to drop rows or columns`)),H(`rows (number)`,N(`The number of rows to drop. A negative value drops from the end of the array.`)),H(`columns (number, optional)`,N(`The number of columns to exclude. A negative value drops from the end of the array.`))],computeArray:function(e,t,n){let r=I(t,this.locale),i=I(n,this.locale),a=e;if(Math.abs(i)>=e.length||Math.abs(r)>=e[0].length)return new F(N(`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},H2={description:N(`Returns a specified number of contiguous rows or columns from the start or end of an array.`),args:[H(`array (range)`,N(`The array from which to take rows or columns.`)),H(`rows (number)`,N(`The number of rows to take. A negative value takes from the end of the array.`)),H(`columns (number, optional)`,N(`The number of columns to take. A negative value takes from the end of the array.`))],computeArray:function(e,t,n){let r=t?I(t,this.locale):e[0].length,i=I(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 F(N(`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},U2={description:N(`Returns a formula as a string.`),args:[H(`cell_reference (any)`,N(`A reference to a cell.`))],compute:function(e){if(e?.position===void 0)return new ko(Bo);let t=this.getters.getCell(e.position);return t?.isFormula?{value:t.compiledFormula.toFormulaString(this.getters)}:new Ao(N(`The cell does not contain a formula.`))},isExported:!0};var W2=l({ADD:()=>G2,CONCAT:()=>K2,DIVIDE:()=>q2,EQ:()=>Z2,GT:()=>e4,GTE:()=>t4,LT:()=>n4,LTE:()=>r4,MINUS:()=>i4,MULTIPLY:()=>a4,NE:()=>o4,POW:()=>s4,SPILLED_RANGE:()=>c4,UMINUS:()=>l4,UNARY_PERCENT:()=>u4,UPLUS:()=>d4});let G2={description:N(`Sum of two numbers.`),args:[H(`value1 (number)`,N(`The first addend.`)),H(`value2 (number)`,N(`The second addend.`))],compute:function(e,t){return{value:I(e,this.locale)+I(t,this.locale),format:e?.format||t?.format}}},K2={description:N(`Concatenation of two values.`),args:[H(`value1 (string)`,N(`The value to which value2 will be appended.`)),H(`value2 (string)`,N(`The value to append to value1.`))],compute:function(e,t){return{value:Jo(e,this.locale)+Jo(t,this.locale)}},isExported:!0},q2={description:N(`One number divided by another.`),args:[H(`dividend (number)`,N(`The number to be divided.`)),H(`divisor (number)`,N(`The number to divide by.`))],compute:function(e,t){let n=I(t,this.locale);return n===0?new No(N(`The divisor must be different from zero.`)):{value:I(e,this.locale)/n,format:e?.format||t?.format}}};function J2(e){return e===void 0||e.value===null}let Y2={number:0,string:``,boolean:!1};function X2(e,t,n=2e-16){return Math.abs(e-t)<n}let Z2={description:N(`Equal.`),args:[H(`value1 (string, number, boolean)`,N(`The first value.`)),H(`value2 (string, number, boolean)`,N(`The value to test against value1 for equality.`))],compute:function(e,t){if(Lo(e?.value))return e;if(Lo(t?.value))return t;let n=J2(e)?Y2[typeof t?.value]:e?.value,r=J2(t)?Y2[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:X2(n,r)}:{value:n===r}}};function Q2(e,t,n){if(Lo(e?.value))return e;if(Lo(t?.value))return t;let r=J2(e)?Y2[typeof t?.value]??``:e?.value,i=J2(t)?Y2[typeof e?.value]??``:t?.value,a=$2[typeof r],o=$2[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 $2={number:0,string:1,boolean:2},e4={description:N(`Strictly greater than.`),args:[H(`value1 (number, string, boolean)`,N(`The value to test as being greater than value2.`)),H(`value2 (number, string, boolean)`,N(`The second value.`))],compute:function(e,t){return Q2(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?!X2(e,t)&&e>t:e>t)}},t4={description:N(`Greater than or equal to.`),args:[H(`value1 (number, string, boolean)`,N(`The value to test as being greater than or equal to value2.`)),H(`value2 (number, string, boolean)`,N(`The second value.`))],compute:function(e,t){return Q2(e,t,(e,t)=>typeof e==`number`&&typeof t==`number`?X2(e,t)||e>t:e>=t)}},n4={description:N(`Less than.`),args:[H(`value1 (number, string, boolean)`,N(`The value to test as being less than value2.`)),H(`value2 (number, string, boolean)`,N(`The second value.`))],compute:function(e,t){let n=t4.compute.bind(this)(e,t);return Lo(n.value)?n:{value:!n.value}}},r4={description:N(`Less than or equal to.`),args:[H(`value1 (number, string, boolean)`,N(`The value to test as being less than or equal to value2.`)),H(`value2 (number, string, boolean)`,N(`The second value.`))],compute:function(e,t){let n=e4.compute.bind(this)(e,t);return Lo(n.value)?n:{value:!n.value}}},i4={description:N(`Difference of two numbers.`),args:[H(`value1 (number)`,N(`The minuend, or number to be subtracted from.`)),H(`value2 (number)`,N(`The subtrahend, or number to subtract from value1.`))],compute:function(e,t){return{value:I(e,this.locale)-I(t,this.locale),format:e?.format||t?.format}}},a4={description:N(`Product of two numbers`),args:[H(`factor1 (number)`,N(`The first multiplicand.`)),H(`factor2 (number)`,N(`The second multiplicand.`))],compute:function(e,t){return{value:I(e,this.locale)*I(t,this.locale),format:e?.format||t?.format}}},o4={description:N(`Not equal.`),args:[H(`value1 (string, number, boolean)`,N(`The first value.`)),H(`value2 (string, number, boolean)`,N(`The value to test against value1 for inequality.`))],compute:function(e,t){let n=Z2.compute.bind(this)(e,t);return Lo(n.value)?n:{value:!n.value}}},s4={description:N(`A number raised to a power.`),args:[H(`base (number)`,N(`The number to raise to the exponent power.`)),H(`exponent (number)`,N(`The exponent to raise base to.`))],compute:function(e,t){return NX.compute.bind(this)(e,t)}},c4={description:N(`Gets the spilled range of an array formula.`),args:[H(`ref (any, range<any>)`,N(`The reference to get the spilled range from.`))],computeArray:function(e){if(e===void 0)return new ko(Bo);let t=z(e);if(t.length!==1||t[0].length!==1)return new F(N(`Only single-cell references are allowed to get the spilled range.`));let n=t[0][0];if(Lo(n.value))return n;if(n.position===void 0)return new ko(Bo);let r=this.__originCellPosition;r&&this.updateDependencies?.(r);let i=this.getters.getSpreadZone(n.position);if(i===void 0)return new ko;let a=this.getters.getRangeFromZone(this.__originSheetId,i);return r&&this.addDependencies?.(r,[a]),ss(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},l4={description:N(`A number with the sign reversed.`),args:[H(`value (number)`,N(`The number to have its sign reversed. Equivalently, the number to multiply by -1.`))],compute:function(e){return{value:-I(e,this.locale),format:e?.format}}},u4={description:N(`Value interpreted as a percentage.`),args:[H(`percentage (number)`,N(`The value to interpret as a percentage.`))],compute:function(e){return{value:I(e,this.locale)/100}}},d4={description:N(`A specified number, unchanged.`),args:[H(`value (any)`,N(`The number to return.`))],compute:function(e={value:null}){return e}},$=e=>({transform:t=>t*e,inverseTransform:t=>t/e}),f4={transform:e=>e,inverseTransform:e=>e},p4=1e-10,m4=.0254,h4=m4/72,g4=.3048,_4=.9144,v4=1609.34,y4=1852,b4=946073047258e4,x4={g:{...f4,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:{...f4,category:`distance`},km:{...$(1e3),category:`distance`},ang:{...$(p4),category:`distance`},Picapt:{...$(h4),category:`distance`},pica:{...$(m4/6),category:`distance`},in:{...$(m4),category:`distance`},ft:{...$(g4),category:`distance`},yd:{...$(_4),category:`distance`},ell:{...$(1.143),category:`distance`},mi:{...$(v4),category:`distance`},survey_mi:{...$(1609.34),category:`distance`},Nmi:{...$(y4),category:`distance`},ly:{...$(b4),category:`distance`},parsec:{...$(0x6da012f95c9fd0),category:`distance`},sec:{...f4,category:`time`},min:{...$(60),category:`time`},hr:{...$(3600),category:`time`},day:{...$(86400),category:`time`},yr:{...$(31556952),category:`time`},Pa:{...f4,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:{...f4,category:`force`},dyn:{...$(1e-5),category:`force`},pond:{...$(.00980665),category:`force`},lbf:{...$(4.44822),category:`force`},J:{...f4,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:{...f4,category:`power`},PS:{...$(735.499),category:`power`},HP:{...$(745.7),category:`power`},T:{...f4,category:`magnetism`},ga:{...$(1e-4),category:`magnetism`},K:{...f4,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":{...f4,category:`volume`,order:3},"ang^3":{...$(p4**3),category:`volume`,order:3},"Picapt^3":{...$(h4**3),category:`volume`,order:3},tsp:{...$(492892e-11),category:`volume`},tspm:{...$(5e-6),category:`volume`},tbs:{...$(14786764825785619e-21),category:`volume`},"in^3":{...$(m4**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":{...$(g4**3),category:`volume`,order:3},bushel:{...$(.0352390704),category:`volume`},barrel:{...$(.158987295),category:`volume`},"yd^3":{...$(_4**3),category:`volume`,order:3},MTON:{...$(1.13267386368),category:`volume`},GRT:{...$(2.83168),category:`volume`},"mi^3":{...$(v4**3),category:`volume`,order:3},"Nmi^3":{...$(y4**3),category:`volume`,order:3},"ly^3":{...$(b4**3),category:`volume`,order:3},"m^2":{...f4,category:`area`,order:2},"ang^2":{...$(p4**2),category:`area`,order:2},"Picapt^2":{...$(h4**2),category:`area`,order:2},"in^2":{...$(m4**2),category:`area`,order:2},"ft^2":{...$(g4**2),category:`area`,order:2},"yd^2":{...$(_4**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":{...$(v4**2),category:`area`,order:2},"Nmi^2":{...$(y4**2),category:`area`,order:2},"ly^2":{...$(b4**2),category:`area`,order:2},bit:{...f4,category:`information`},byte:{...$(8),category:`information`},"m/s":{...f4,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`}},S4={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`},C4={"":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},w4={weight:N(`Weight`),distance:N(`Distance`),time:N(`Time`),pressure:N(`Pressure`),force:N(`Force`),energy:N(`Energy`),power:N(`Power`),magnetism:N(`Magnetism`),temperature:N(`Temperature`),volume:N(`Volume`),area:N(`Area`),information:N(`Information`),speed:N(`Speed`)},T4=Object.entries(x4).map(([e,t])=>({value:e,label:E4(t.category)}));function E4(e){return w4[e]??``}function D4(e){for(let[t,n]of Object.entries(C4)){if(t&&!e.startsWith(t))continue;let r=e.slice(t.length),i=x4[r];if(!i&&S4[r]&&(i=x4[S4[r]]),i)return{...i,factor:i.order?n**+i.order:n}}}var O4=l({CONVERT:()=>k4});let k4={description:N(`Converts a numeric value to a different unit of measure.`),args:[H(`value (number)`,N(`the numeric value in start_unit to convert to end_unit`)),H(`start_unit (string)`,N(`The starting unit, the unit currently assigned to value`),T4),H(`end_unit (string)`,N(`The unit of measure into which to convert value`),T4)],compute:function(e,t,n){let r=I(e,this.locale),i=L(t),a=L(n),o=D4(i),s=D4(a);return o?s?o.category===s.category?{value:s.inverseTransform(o.factor*o.transform(r))/s.factor,format:e?.format}:{value:P.GenericError,message:N(`Incompatible units of measure ('%s' vs '%s')`,E4(o.category),E4(s.category))}:{value:P.GenericError,message:N(`Invalid units of measure ('%s')`,a)}:{value:P.GenericError,message:N(`Invalid units of measure ('%s')`,i)}},isExported:!0};var A4=l({CHAR:()=>P4,CLEAN:()=>F4,CONCATENATE:()=>I4,EXACT:()=>L4,FIND:()=>R4,FORMAT_LARGE_NUMBER:()=>z4,JOIN:()=>B4,LEFT:()=>V4,LEN:()=>H4,LOWER:()=>U4,MID:()=>W4,PROPER:()=>G4,REGEXEXTRACT:()=>q4,REGEXREPLACE:()=>J4,REGEXTEST:()=>K4,REPLACE:()=>Y4,RIGHT:()=>X4,SEARCH:()=>Z4,SPLIT:()=>Q4,SUBSTITUTE:()=>$4,TEXT:()=>i3,TEXTAFTER:()=>o3,TEXTBEFORE:()=>s3,TEXTJOIN:()=>e3,TEXTSPLIT:()=>t3,TRIM:()=>n3,UPPER:()=>r3,VALUE:()=>a3});let j4=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,M4=[{value:0,label:N(`Case-sensitive (default)`)},{value:1,label:N(`Case-insensitive`)}],N4=[{value:0,label:N(`Don't match to end (default)`)},{value:1,label:N(`Match to end`)}],P4={description:N(`Gets character associated with number.`),args:[H(`table_number (number)`,N(`The number of the character to look up from the current Unicode table in decimal format.`))],compute:function(e){let t=Math.trunc(I(e,this.locale));return t<1?new F(N(`The table_number (%s) is out of range.`,t)):{value:String.fromCharCode(t)}},isExported:!0},F4={description:N(`Remove non-printable characters from a piece of text.`),args:[H(`text (string)`,N(`The text whose non-printable characters are to be removed.`))],compute:function(e){let t=Jo(e,this.locale),n=``;for(let e of t)e&&e.charCodeAt(0)>31&&(n+=e);return{value:n}},isExported:!0},I4={description:N(`Appends strings to one another.`),args:[H(`string (string, range<string>, repeating)`,N(`String to append in sequence.`))],compute:function(...e){return{value:is(e,(e,t)=>e+Jo(t,this.locale),``)}},isExported:!0},L4={description:N(`Tests whether two strings are identical.`),args:[H(`string1 (string)`,N(`The first string to compare.`)),H(`string2 (string)`,N(`The second string to compare.`))],compute:function(e,t){return{value:Jo(e,this.locale)===Jo(t,this.locale)}},isExported:!0},R4={description:N(`First position of string found in text, case-sensitive.`),args:[H(`search_for (string)`,N(`The string to look for within text_to_search.`)),H(`text_to_search (string)`,N(`The text to search for the first occurrence of search_for.`)),H(`starting_at (number, default=1)`,N(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=Jo(e,this.locale),i=Jo(t,this.locale),a=I(n,this.locale);if(i===``)return new F(N(`The text_to_search must be non-empty.`));if(a<1)return new F(N(`The starting_at (%s) must be greater than or equal to 1.`,a));let o=i.indexOf(r,a-1);return o===-1?new F(N(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)):{value:o+1}},isExported:!0},z4={description:N(`Apply a large number format`),args:[H(`value (number)`,N(`The number.`)),H(`unit (string, optional)`,N(`The formatting unit. Use 'k', 'm', or 'b' to force the unit`),[{value:`k`,label:N(`Thousand`)},{value:`m`,label:N(`Million`)},{value:`b`,label:N(`Billion`)}])],compute:function(e,t){let n=t?.value;return n!==void 0&&(typeof n!=`string`||![`k`,`m`,`b`].includes(n))?new F(N(`The formatting unit should be 'k', 'm' or 'b'.`)):{value:I(e,this.locale),format:Mc(e,t,this.locale)}}},B4={description:N(`Concatenates elements of arrays with delimiter.`),args:[H(`delimiter (string)`,N(`The character or string to place between each concatenated value.`)),H(`value_or_array (string, range<string>, repeating)`,N(`Value to be appended using delimiter.`))],compute:function(e,...t){let n=Jo(e,this.locale);return{value:is(t,(e,t)=>(e?e+n:``)+Jo(t,this.locale),``)}}},V4={description:N(`Substring from beginning of specified string.`),args:[H(`text (string)`,N(`The string from which the left portion will be returned.`)),H(`number_of_characters (number, optional)`,N(`The number of characters to return from the left side of string.`))],compute:function(e,...t){let n=t.length?I(t[0],this.locale):1;return n<0?new F(N(`The number_of_characters (%s) must be positive or null.`,n)):{value:Jo(e,this.locale).substring(0,n)}},isExported:!0},H4={description:N(`Length of a string.`),args:[H(`text (string)`,N(`The string whose length will be returned.`))],compute:function(e){return{value:Jo(e,this.locale).length}},isExported:!0},U4={description:N(`Converts a specified string to lowercase.`),args:[H(`text (string)`,N(`The string to convert to lowercase.`))],compute:function(e){return{value:Jo(e,this.locale).toLowerCase()}},isExported:!0},W4={description:N(`A segment of a string.`),args:[H(`text (string)`,N(`The string to extract a segment from.`)),H(`starting_at (number)`,N(`The index from the left of string from which to begin extracting. The first character in string has the index 1.`)),H(`extract_length (number)`,N(`The length of the segment to extract.`))],compute:function(e,t,n){let r=Jo(e,this.locale),i=I(t,this.locale),a=I(n,this.locale);return i<1?new F(N(`The starting_at argument (%s) must be positive greater than one.`,i.toString())):a<0?new F(N(`The extract_length argument (%s) must be positive or null.`,a)):{value:r.slice(i-1,i+a-1)}},isExported:!0},G4={description:N(`Capitalizes each word in a specified string.`),args:[H(`text_to_capitalize (string)`,N(`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{value:Jo(e,this.locale).replace(j4,e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())}},isExported:!0},K4={description:N(`Checks whether a string matches the supplied regular expression.`),args:[H(`text (string)`,N(`The string to test.`)),H(`pattern (string)`,N(`The regular expression pattern to match against the text.`)),H(`case_sensitivity (number, default=0)`,N(`Whether the match is case-sensitive.`),[{value:0,label:N(`Case-sensitive`)},{value:1,label:N(`Case-insensitive`)}])],compute:function(e,t,n={value:0}){let r=L(e),i=L(t),a=I(n,this.locale);if(i===``)return{value:!0};if(r===``)return{value:!1};if(a!==0&&a!==1)return new F(N(`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 F(N(`Invalid regular expression`))}return{value:s.test(r)}},isExported:!0},q4={description:N(`Extract text from a string based on the supplied regular expression.`),args:[H(`text (string)`,N(`The string on which you want to extract text.`)),H(`pattern (string)`,N(`The regular expression pattern to match against the text.`)),H(`return_mode (number, default=0)`,N(`0 = first match, 1 = all matches as an array, 2 = capturing groups from the first match as an array.`),[{value:0,label:N(`First match`)},{value:1,label:N(`All matches`)},{value:2,label:N(`Capture groups of first match`)}]),H(`case_sensitivity (number, default=0)`,N(`Whether the match is case-sensitive.`),[{value:0,label:N(`Case-sensitive`)},{value:1,label:N(`Case-insensitive`)}])],computeArray:function(e,t,n={value:0},r={value:0}){let i=L(e),a=L(t),o=I(n,this.locale),s=I(r,this.locale);if(i===``||a===``)return{value:``};if(o<0||o>2)return new F(N(`The return_mode (%s) must be 0, 1 or 2.`,o));if(s!==0&&s!==1)return new F(N(`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 F(N(`Invalid regular expression`))}let u=[...i.matchAll(l)];return u.length===0?{value:P.NotAvailable,message:N(`No matches found.`)}:o===0?{value:u[0][0]}:o===1?u.map(e=>[{value:e[0]}]):u[0].length<2?new F(N(`No capturing groups found.`)):u[0].slice(1).map(e=>[{value:e}])},isExported:!0},J4={description:N(`Replace text in a string based on the supplied regular expression.`),args:[H(`text (string)`,N(`The string in which you want to replace text.`)),H(`pattern (string)`,N(`The regular expression pattern to match against the text.`)),H(`replacement (string)`,N(`The text to use as the replacement.`)),H(`occurrence (number, default=0)`,N(`0 = replace all matches. A negative number counts from the end.`)),H(`case_sensitivity (number, default=0)`,N(`Whether the match is case-sensitive.`),[{value:0,label:N(`Case-sensitive`)},{value:1,label:N(`Case-insensitive`)}])],compute:function(e,t,n,r={value:0},i={value:0}){let a=L(e),o=L(t),s=L(n),c=I(r,this.locale),l=I(i,this.locale);if(l!==0&&l!==1)return new F(N(`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 F(N(`Invalid regular expression`))}if(c!==0){let e=[...a.matchAll(d)];if(e.length===0||Math.abs(c)>e.length)return{value:a};let t=c>0?c-1:e.length+c,n=e[t][0].length,r=e[t].index;return{value:a.substring(0,r)+s+a.substring(r+n)}}return{value:a.replace(d,s)}},isExported:!0},Y4={description:N(`Replaces part of a text string with different text.`),args:[H(`text (string)`,N(`The text, a part of which will be replaced.`)),H(`position (number)`,N(`The position where the replacement will begin (starting from 1).`)),H(`length (number)`,N(`The number of characters in the text to be replaced.`)),H(`new_text (string)`,N(`The text which will be inserted into the original text.`))],compute:function(e,t,n,r){let i=I(t,this.locale);if(i<1)return new F(N(`The position (%s) must be greater than or equal to 1.`,i));let a=I(n,this.locale);if(a<0)return new F(N(`The length (%s) must be positive or zero.`,a));let o=Jo(e,this.locale),s=Jo(r,this.locale);return{value:o.substring(0,i-1)+s+o.substring(i-1+a)}},isExported:!0},X4={description:N(`A substring from the end of a specified string.`),args:[H(`text (string)`,N(`The string from which the right portion will be returned.`)),H(`number_of_characters (number, optional)`,N(`The number of characters to return from the right side of string.`))],compute:function(e,...t){let n=t.length?I(t[0],this.locale):1;if(n<0)return new F(N(`The number_of_characters (%s) must be positive or zero.`,n));let r=Jo(e,this.locale),i=r.length;return{value:r.substring(i-n,i)}},isExported:!0},Z4={description:N(`First position of string found in text, ignoring case.`),args:[H(`search_for (string)`,N(`The string to look for within text_to_search.`)),H(`text_to_search (string)`,N(`The text to search for the first occurrence of search_for.`)),H(`starting_at (number, default=1)`,N(`The character within text_to_search at which to start the search.`))],compute:function(e,t,n={value:1}){let r=Jo(e,this.locale).toLowerCase(),i=Jo(t,this.locale).toLowerCase(),a=I(n,this.locale);if(i===``)return{value:P.GenericError,message:N(`The text_to_search must be non-empty.`)};if(a<1)return{value:P.GenericError,message:N(`The starting_at (%s) must be greater than or equal to 1.`,a)};let o=i.indexOf(r,a-1);return o===-1?{value:P.GenericError,message:N(`In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.`,r,i)}:{value:o+1}},isExported:!0},Q4={description:N(`Split text by specific character delimiter(s).`),args:[H(`text (string)`,N(`The text to divide.`)),H(`delimiter (string)`,N(`The character or characters to use to split text.`)),H(`split_by_each (boolean, default=true})`,N(`Whether or not to divide text around each character contained in delimiter.`)),H(`remove_empty_text (boolean, default=true)`,N(`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.`))],computeArray:function(e,t,n={value:!0},r={value:!0}){let i=Jo(e,this.locale),a=At(Jo(t,this.locale)),o=R(n),s=R(r);if(a.length<=0)return new F(N(`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!==``)),cs(us([l]),e=>({value:e}))},isExported:!1},$4={description:N(`Replaces existing text with new text in a string.`),args:[H(`text_to_search (string)`,N(`The text within which to search and replace.`)),H(`search_for (string)`,N(`The string to search for within text_to_search.`)),H(`replace_with (string)`,N(`The string that will replace search_for.`)),H(`occurrence_number (number, optional)`,N(`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=I(r,this.locale);if(i<0)return new F(N(`The occurrenceNumber (%s) must be positive or null.`,i));let a=Jo(e,this.locale),o=Jo(t,this.locale);if(o===``)return{value:a};let s=Jo(n,this.locale),c=new RegExp(At(o),`g`);if(i===0)return{value:a.replace(c,s)};let l=0;return{value:a.replace(c,e=>++l===i?s:e)}},isExported:!0},e3={description:N(`Combines text from multiple strings and/or arrays.`),args:[H(`delimiter (string)`,N(`A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.`)),H(`ignore_empty (boolean)`,N(`A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.`),[{value:!0,label:N(`Ignore empty cells`)},{value:!1,label:N(`Include empty cells (default)`)}]),H(`texts (string, range<string>, repeating)`,N(`Text item to join.`))],compute:function(e,t={value:!0},...n){let r=Jo(e,this.locale),i=R(t),a=0;return{value:is(n,(e,t)=>i&&Jo(t,this.locale)===``?e:(a++?e+r:``)+Jo(t,this.locale),``)}},isExported:!0},t3={description:N(`Splits text into rows or columns using specified column and row delimiters.`),args:[H(`text (string)`,N(`The text to split.`)),H(`col_delimiter (string, range<string>)`,N(`Character or string to split columns by.`)),H(`row_delimiter (string, range<string>, optional)`,N(`Character or string to split rows by.`)),H(`ignore_empty (boolean, default=false)`,N(`Whether to ignore empty cells.`),[{value:!1,label:N(`Include empty cells (default)`)},{value:!0,label:N(`Ignore empty cells`)}]),H(`match_mode (number, default=0)`,N(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),M4),H(`pad_with (string, default="${P.NotAvailable}")`,N(`The value to use for padding empty cells.`))],computeArray:function(e,t,n,r={value:!1},i={value:0},a=new Ao){let o=L(e);if(o.length<=0)return new F(N(`No text to split.`));if(t===void 0&&n===void 0)return new F(N(`At least one delimiter must be provided.`));let s=z(t).flat().map(e=>At(L(e))),c=z(n).flat().map(e=>At(L(e)));if(s.some(e=>e===``)||c.some(e=>e===``))return new F(N(`The delimiters cannot be empty values.`));let l=R(r),u=I(i,this.locale);if(![0,1].includes(u))return new F(N(`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 us(d)},isExported:!0},n3={description:N(`Removes space characters.`),args:[H(`text (string)`,N(`The text or reference to a cell containing text to be trimmed.`))],compute:function(e){return{value:vn(Jo(e,this.locale))}},isExported:!0},r3={description:N(`Converts a specified string to uppercase.`),args:[H(`text (string)`,N(`The string to convert to uppercase.`))],compute:function(e){return{value:Jo(e,this.locale).toUpperCase()}},isExported:!0},i3={description:N(`Converts a number to text according to a specified format.`),args:[H(`number (number)`,N(`The number, date or time to format.`)),H(`format (string)`,N(`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{value:V(I(e,this.locale),{format:L(t),locale:this.locale})}},isExported:!0},a3={description:N(`Converts a string to a numeric value.`),args:[H(`value (number)`,N(`the string to be converted`))],compute:function(e){return{value:I(e,this.locale)}},isExported:!0},o3={description:N(`Returns text that occurs after a given substring or delimiter.`),args:[H(`text (string)`,N(`The source text.`)),H(`delimiter (string)`,N(`The substring after which text will be returned.`)),H(`instance_num (number, default=1)`,N(`The desired instance of the delimiter after which we extract the text. A negative number searches from the end.`)),H(`match_mode (number, default=0)`,N(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),M4),H(`match_end (number, default=0))`,N(`Whether to treat the end of text as a delimiter.`),N4),H(`if_not_found (string, default="${P.NotAvailable}")`,N(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new Ao){let o=L(e),s=I(n,this.locale),c=I(r,this.locale),l=I(i,this.locale);if(s===0)return new F(N(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new F(N(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new F(N(`match_end should have a value of 0 or 1.`));let u=L(t);if(u===``)return Math.sign(s)>0?{value:o}:{value:``};let d=c===1?`gi`:`g`,f=At(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},s3={description:N(`Returns text that occurs before a given substring or delimiter.`),args:[H(`text (string)`,N(`The source text.`)),H(`delimiter (string)`,N(`The substring after which text will be returned.`)),H(`instance_num (number, default=1)`,N(`The desired instance of the delimiter before which we extract the text. A negative number searches from the end.`)),H(`match_mode (number, default=0)`,N(`Searches the text for a delimiter match. By default, a case-sensitive match is done.`),M4),H(`match_end (number, default=0))`,N(`Whether to match a delimiter against the end of the text.`),N4),H(`if_not_found (string, default="${P.NotAvailable}")`,N(`Value to return if the delimiter is not found.`))],compute:function(e,t,n={value:1},r={value:0},i={value:0},a=new Ao){let o=L(e),s=I(n,this.locale),c=I(r,this.locale),l=I(i,this.locale);if(s===0)return new F(N(`The instance_num (%s) must not be zero.`,s));if(c!==0&&c!==1)return new F(N(`match_mode should have a value of 0 or 1.`));if(l!==0&&l!==1)return new F(N(`match_end should have a value of 0 or 1.`));let u=L(t);if(u===``)return Math.sign(s)>0?{value:``}:{value:o};let d=c===1?`gi`:`g`,f=At(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 c3=l({HYPERLINK:()=>l3});let l3={description:N(`Creates a hyperlink in a cell.`),args:[H(`url (string)`,N(`The full URL of the link enclosed in quotation marks.`)),H(`link_label (string, optional)`,N(`The text to display in the cell, enclosed in quotation marks.`))],compute:function(e,t){let n=L(e).trim(),r=Jo(t,this.locale)||n;return n===``?{value:r}:{value:Ut(r,n)}},isExported:!0},u3=[{name:N(`Array`),functions:pY},{name:N(`Database`),functions:AQ},{name:N(`Date`),functions:K$},{name:N(`Filter`),functions:A1},{name:N(`Financial`),functions:I1},{name:N(`Info`),functions:G0},{name:N(`Lookup`),functions:b2},{name:N(`Logical`),functions:i2},{name:N(`Math`),functions:UY},{name:N(`Operator`),functions:W2},{name:N(`Statistical`),functions:aZ},{name:N(`Text`),functions:A4},{name:N(`Engineering`),functions:O1},{name:N(`Web`),functions:c3},{name:N(`Parser`),functions:O4}];for(let e of u3){let t=e.functions;for(let n in t){let r=t[n];r.category=r.category||e.name,n=n.replace(/_/g,`.`),ul.add(n,{isExported:!1,...r})}}let d3={},f3={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},p3={autoCompleteProviders:$M,autofillModifiersRegistry:Xj,autofillRulesRegistry:Zj,cellMenuRegistry:AA,colMenuRegistry:Ij,errorTypes:Eo,functionRegistry:ul,featurePluginRegistry:YV,iconsOnCellRegistry:HV,statefulUIPluginRegistry:XV,evaluationPluginRegistry:ZV,corePluginRegistry:JV,rowMenuRegistry:Uj,sidePanelRegistry:Bg,figureRegistry:nD,chartSidePanelComponentRegistry:AL,chartDataSourceSidePanelComponentRegistry:mP,chartComponentRegistry:Ew,chartTypeRegistry:Tb,chartSubtypeRegistry:Ug,chartDataSourceRegistry:wb,topbarMenuRegistry:bH,topbarComponentRegistry:nG,topBarToolBarRegistry:uK,clickableCellRegistry:vE,otRegistry:LB,inverseCommandRegistry:QV,urlRegistry:Qd,cellPopoverRegistry:AE,numberFormatMenuRegistry:gH,repeatLocalCommandTransformRegistry:OV,repeatCommandTransformRegistry:DV,clipboardHandlersRegistries:iw,pivotRegistry:qT,pivotTimeAdapterRegistry:RS,pivotSidePanelRegistry:RR,pivotNormalizationValueRegistry:gC,supportedPivotPositionalFormulaRegistry:sR,pivotToFunctionValueRegistry:_C,migrationStepRegistry:FC,chartJsExtensionRegistry:ri,onIterationEndEvaluationRegistry:eB,specificRangeTransformRegistry:RB,unusedDataSourceRegistry:pW,NonSquishableFunctionRegistry:dl},m3={arg:H,isEvaluationError:Lo,toBoolean:R,toJsDate:Qo,toNumber:I,toString:L,toNormalizedPivotValue:fC,toFunctionPivotValue:mC,toXC:E,toZone:tr,toUnboundedZone:er,toCartesian:Un,numberToLetters:Pn,lettersToNumber:Fn,UuidGenerator:K,formatValue:V,createCurrencyFormat:Tc,ColorGenerator:pp,computeTextWidth:Dp,createEmptyWorkbookData:tw,createEmptySheet:ew,createEmptyExcelSheet:nw,doesCellContainFunction:kn,rgbaToHex:zf,colorToRGBA:Bf,positionToZone:D,isDefined:w,isMatrix:wt,lazy:en,genericRepeat:RH,createAction:we,createActions:be,transformRangeData:Gr,deepEquals:T,overlap:hr,union:dr,isInside:_r,deepCopy:x,expandZoneOnInsertion:sr,reduceZoneOnDeletion:ur,unquote:Nt,getMaxObjectId:iC,getFirstPivotFunction:ZL,getNumberOfPivotFunctions:$L,parseDimension:sC,isDateOrDatetimeField:cC,makeFieldProposal:eR,periodYearToComparable:LS,insertTokenAfterArgSeparator:nR,insertTokenAfterLeftParenthesis:rR,mergeContiguousZones:Vr,getPivotHighlights:pR,pivotTimeAdapter:zS,UNDO_REDO_PIVOT_COMMANDS:VR,createPivotFormula:dC,areDomainArgsFieldsValid:uC,splitReference:wl,sanitizeSheetName:Ft,getUniqueText:En,isNumber:mo,isDateTime:Fa,createCustomFields:CC,schemeToColorScale:MC,isDateTimeFormat:vc,jsDateToNumber:Ya,numberToJsDate:qa,DateTime:xa,parseFormat:Vs,isFormula:Dn,domainToColRowDomain:qw,collapseHierarchicalDisplayName:kC,getCanonicalSymbolName:Pt,fuzzyLookup:QM,PositionMap:Bw,replaceSymbolInFormula:rd,isSingleCellReference:Cl,computeCachedTextDimension:jp,createComputeFunction:nl,isMobileOS:_e,drawHighlight:EE,getBoundingRectWithMargins:te,hasInteractiveElementInEventTree:ye},h3={isMarkdownLink:Vt,parseMarkdownLink:Wt,markdownLink:Ut,openLink:rf,urlRepresentation:nf},g3={Checkbox:fP,Section:Q,Select:XE,RoundColorPicker:zP,ChartDataSeries:hP,ChartErrorSection:vP,ChartLabelRange:gP,ChartRangeDataSourceComponent:QI,ChartTitle:jP,ChartPanel:FL,ChartFigure:eD,ChartJsComponent:sg,ClickableCellSortIcon:Hw,ZoomableChartJsComponent:vw,Grid:rP,GridOverlay:PE,ScorecardChart:zg,GaugeChartComponent:ww,LineConfigPanel:hL,BarConfigPanel:bP,PieChartDesignPanel:vL,GenericChartConfigPanel:yP,ChartWithAxisDesignPanel:KP,GenericZoomableChartDesignPanel:qP,LineChartDesignPanel:gL,GaugeChartConfigPanel:sL,GaugeChartDesignPanel:uL,ScorecardChartConfigPanel:xL,ScorecardChartDesignPanel:SL,GeoChartDesignPanel:pL,RadarChartDesignPanel:yL,WaterfallChartDesignPanel:kL,ComboChartDesignPanel:iL,FunnelChartDesignPanel:oL,SunburstChartDesignPanel:CL,TreeMapChartDesignPanel:OL,ChartTypePicker:NL,FigureComponent:rD,MenuPopover:zw,Popover:Fw,SelectionInput:dP,StandaloneComposer:lL,ValidationMessages:wE,AddDimensionButton:VL,PivotDimensionGranularity:UL,PivotDimensionOrder:WL,PivotDimension:HL,PivotLayoutConfigurator:YL,PivotHTMLRenderer:lR,PivotDeferUpdate:zL,PivotTitleSection:oR,CogWheelMenu:IL,TextInput:wP,SidePanelCollapsible:MP,RadioSelection:RP,GeoChartRegionSelectSection:dL,ChartMenu:QE,FullScreenFigure:cR,NumberInput:PP,TopBar:dK,Composer:hN,CalendarButton:yR,Spreadsheet:mK,CarouselFigure:$E},_3={useDragAndDropListItems:iP,useHighlights:eP,useHighlightsOnHover:$N},v3={Component:k,EnvPlugin:Hi,App:Gi},y3={useStoreProvider:Yi,proxifyStoreMutation:$i,DependencyContainer:qi,CellPopoverStore:jE,ComposerFocusStore:ni,CellComposerStore:rN,FindAndReplaceStore:RL,HighlightStore:DE,DelayedHoveredCellStore:CE,HoveredTableStore:dR,ModelStore:Yr,NotificationStore:Vg,RendererStore:$r,SelectionInputStore:uP,SpreadsheetStore:ei,useStore:A,useLocalStore:Zi,SidePanelStore:U,PivotSidePanelStore:aR,PivotMeasureDisplayPanelStore:uR,TableAutofillStore:uM,AutofillStore:lM,ClientFocusStore:qj,GridRenderer:HE,ViewportsStore:W,ClipboardStore:aw,ZoomStore:Rg,globalStores:oG},b3={PopoverContainerPlugin:Mw};function x3(e,t){return ul.add(e,t),{addFunction:(e,t)=>x3(e,t)}}let S3={DEFAULT_LOCALE:B,HIGHLIGHT_COLOR:Ae,PIVOT_STATIC_TABLE_CONFIG:ht,PIVOT_INSERT_TABLE_STYLE_ID:gt,ChartTerms:pT,FIGURE_ID_SPLITTER:`??`,GRID_ICON_EDGE_LENGTH:17,GRID_ICON_MARGIN:2,CHART_TYPES:jC,DARK_MODE_FILTER_STRING:Zf},C3={...ZI,...fR};e.AbstractCellClipboardHandler=UW,e.AbstractChart=gg,e.AbstractFigureClipboardHandler=CJ,e.BadExpressionError=Do,e.CHART_TYPES=jC,e.CellErrorType=P,e.CellValueType=Ed,e.CircularDependencyError=Oo,e.ClientDisconnectedError=yV,e.ClipboardMIMEType=I_,e.CommandResult=Xd,e.CompiledFormula=yd,e.CorePlugin=lv,e.DEFAULT_LOCALE=B,e.DEFAULT_LOCALES=Es,e.DEFAULT_LOCALE_DIGIT_GROUPING=`[3,0]`,e.DIRECTION=Et,e.DispatchResult=Jd,e.DivisionByZeroError=No,e.EvaluationError=F,e.EvaluationPlugin=LE,e.InvalidReferenceError=ko,e.LocalTransportService=rG,e.Model=bJ,e.NEXT_VALUE=Ww,e.NotAvailableError=Ao,e.NumberTooLargeError=Po,e.OrderedLayers=Zr,e.PREVIOUS_VALUE=Uw,e.PivotRuntimeDefinition=uT,e.Registry=O,e.Revision=vV,e.SPREADSHEET_DIMENSIONS=f3,e.SplillBlockedError=Mo,e.Spreadsheet=mK,e.SpreadsheetPivotTable=jT,e.UIPlugin=jB,e.UnknownFunctionError=jo,e.__info__=d3,e.addFunction=x3,e.addRenderingLayer=Qr,e.astToFormula=MM,e.availableConditionalFormatOperators=QR,e.availableDataValidationOperators=vW,e.availableFiltersOperators=hR,e.borderPositions=Tt,e.borderStyles=Ct,e.canExecuteInReadonly=qd,e.categories=u3,e.chartHelpers=C3,e.compatibility=v3,e.components=g3,e.composerFocusTypes=Dt,e.constants=S3,e.convertAstNodes=yu,e.coreTypes=Vd,e.createAutocompleteArgumentsProvider=YJ,e.dispatcheableEvaluationCommandTypes=Hd,e.errorTypes=Eo,e.evaluationCommandTypes=Ud,e.filterDateCriterionOperators=vR,e.filterNumberCriterionOperators=_R,e.filterTextCriterionOperators=gR,e.findCellInNewZone=Or,e.functionCache=gd,e.getCaretDownSvg=Dy,e.getCaretUpSvg=Oy,e.helpers=m3,e.hooks=_3,e.invalidSubtotalFormulasCommands=Rd,e.invalidateBordersCommands=Ld,e.invalidateCFEvaluationCommands=Id,e.invalidateChartEvaluationCommands=Pd,e.invalidateDependenciesCommands=Fd,e.invalidateEvaluationCommands=Nd,e.isCoreCommand=Wd,e.isDispatcheableEvaluationCommand=Gd,e.isEvaluationCommand=Kd,e.isHeadersDependant=Od,e.isMatrix=wt,e.isPositionDependent=jd,e.isRangeDependant=Ad,e.isSheetDependent=Dd,e.isTargetDependent=kd,e.isZoneDependent=Md,e.iterateAstNodes=bu,e.links=h3,e.load=BC,e.lockedSheetAllowedCommands=Bd,e.owlPlugins=b3,e.parse=_u,e.parseTokens=vu,e.readonlyAllowedCommands=zd,e.registries=p3,e.schemeToColorScale=MC,e.setDefaultSheetViewSize=pt,e.setTranslationMethod=Co,e.stores=y3,e.tokenColors=St,e.tokenize=Il,d3.version=`20.1.0-alpha.2`,d3.date=`2026-09-21T06:31:52.788Z`,d3.hash=`63c49a8`})(this.o_spreadsheet=this.o_spreadsheet||{},owl);