@odoo/o-spreadsheet 16.2.24 → 16.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/o-spreadsheet.cjs.js +68 -58
- package/dist/o-spreadsheet.d.ts +9 -9
- package/dist/o-spreadsheet.esm.js +68 -58
- package/dist/o-spreadsheet.iife.js +68 -58
- package/dist/o-spreadsheet.iife.min.js +232 -232
- package/dist/o_spreadsheet.xml +3 -3
- package/package.json +1 -1
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
`;class Un extends t.Component{constructor(){super(...arguments),this.state=t.useState({values:[],textFilter:"",selectedValue:void 0}),this.searchBar=t.useRef("filterMenuSearchBar")}setup(){t.onWillUpdateProps((e=>{ct(e.filterPosition,this.props.filterPosition)||(this.state.values=this.getFilterValues(e.filterPosition))})),this.state.values=this.getFilterValues(this.props.filterPosition)}get isReadonly(){return this.env.model.getters.isReadonly()}getFilterValues(e){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getFilter({sheetId:t,...e});if(!i)return[];const o=(i.filteredZone?no(i.filteredZone):[]).filter((({row:e})=>!this.env.model.getters.isRowHidden(t,e))).map((({col:e,row:i})=>this.env.model.getters.getEvaluatedCell({sheetId:t,col:e,row:i}).formattedValue)),n=this.env.model.getters.getFilterValues({sheetId:t,...e}),s=[...o,...n],r=n.map(ut);return[...new Set(s.map(ut))].sort(((e,t)=>e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"}))).map((e=>({checked:-1===r.findIndex((t=>t===e)),string:s.find((t=>ut(t)===e))||""})))}checkValue(e){var t;this.state.selectedValue=e.string,e.checked=!e.checked,null===(t=this.searchBar.el)||void 0===t||t.focus()}onMouseMove(e){this.state.selectedValue=e.string}selectAll(){this.state.values.forEach((e=>e.checked=!0))}clearAll(){this.state.values.forEach((e=>e.checked=!1))}get filterTable(){const e=this.env.model.getters.getActiveSheetId(),t=this.props.filterPosition;return this.env.model.getters.getFilterTable({sheetId:e,...t})}get displayedValues(){return this.state.textFilter?Pi(this.state.textFilter,this.state.values,(e=>e.string)):this.state.values}confirm(){var e,t;const i=this.props.filterPosition;this.env.model.dispatch("UPDATE_FILTER",{...i,sheetId:this.env.model.getters.getActiveSheetId(),values:this.state.values.filter((e=>!e.checked)).map((e=>e.string))}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){const t=this.displayedValues;if(0===t.length)return;let i;if(void 0!==this.state.selectedValue){const e=t.findIndex((e=>e.string===this.state.selectedValue));i=-1===e?void 0:e}switch(e.key){case"ArrowDown":i=void 0===i?0:Math.min(i+1,t.length-1),e.preventDefault(),e.stopPropagation();break;case"ArrowUp":i=void 0===i?t.length-1:Math.max(i-1,0),e.preventDefault(),e.stopPropagation();break;case"Enter":void 0!==i&&this.checkValue(t[i]),e.stopPropagation(),e.preventDefault()}this.state.selectedValue=void 0!==i?t[i].string:void 0,"ArrowUp"!==e.key&&"ArrowDown"!==e.key||this.scrollListToSelectedValue(e.key)}clearScrolledToValue(){this.state.values.forEach((e=>e.scrolledTo=void 0))}scrollListToSelectedValue(e){this.clearScrolledToValue();const t=this.state.values.find((e=>e.string===this.state.selectedValue));t&&(t.scrolledTo="ArrowUp"===e?"top":"bottom")}sortFilterZone(e){var t,i;const o=this.props.filterPosition,n=this.filterTable;if(!o||!n||!n.contentZone)return;const s=this.env.model.getters.getActiveSheetId();this.env.model.dispatch("SORT_CELLS",{sheetId:s,col:o.col,row:n.contentZone.top,zone:n.contentZone,sortDirection:e,sortOptions:{emptyCellAsZero:!0,sortHeaders:!0}}),null===(i=(t=this.props).onClosed)||void 0===i||i.call(t)}}Un.size={width:$,height:295},Un.template="o-spreadsheet-FilterMenu",Un.style=Pn,Un.components={FilterMenuValueItem:Ln},Un.props={filterPosition:Object,onClosed:{type:Function,optional:!0}};const Vn={onOpen:(e,t)=>({isOpen:!0,props:{filterPosition:e},Component:Un,cellCorner:"BottomLeft"})};function
|
|
165
|
+
`;class Un extends t.Component{constructor(){super(...arguments),this.state=t.useState({values:[],textFilter:"",selectedValue:void 0}),this.searchBar=t.useRef("filterMenuSearchBar")}setup(){t.onWillUpdateProps((e=>{ct(e.filterPosition,this.props.filterPosition)||(this.state.values=this.getFilterValues(e.filterPosition))})),this.state.values=this.getFilterValues(this.props.filterPosition)}get isReadonly(){return this.env.model.getters.isReadonly()}getFilterValues(e){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getFilter({sheetId:t,...e});if(!i)return[];const o=(i.filteredZone?no(i.filteredZone):[]).filter((({row:e})=>!this.env.model.getters.isRowHidden(t,e))).map((({col:e,row:i})=>this.env.model.getters.getEvaluatedCell({sheetId:t,col:e,row:i}).formattedValue)),n=this.env.model.getters.getFilterValues({sheetId:t,...e}),s=[...o,...n],r=n.map(ut);return[...new Set(s.map(ut))].sort(((e,t)=>e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"}))).map((e=>({checked:-1===r.findIndex((t=>t===e)),string:s.find((t=>ut(t)===e))||""})))}checkValue(e){var t;this.state.selectedValue=e.string,e.checked=!e.checked,null===(t=this.searchBar.el)||void 0===t||t.focus()}onMouseMove(e){this.state.selectedValue=e.string}selectAll(){this.state.values.forEach((e=>e.checked=!0))}clearAll(){this.state.values.forEach((e=>e.checked=!1))}get filterTable(){const e=this.env.model.getters.getActiveSheetId(),t=this.props.filterPosition;return this.env.model.getters.getFilterTable({sheetId:e,...t})}get displayedValues(){return this.state.textFilter?Pi(this.state.textFilter,this.state.values,(e=>e.string)):this.state.values}confirm(){var e,t;const i=this.props.filterPosition;this.env.model.dispatch("UPDATE_FILTER",{...i,sheetId:this.env.model.getters.getActiveSheetId(),values:this.state.values.filter((e=>!e.checked)).map((e=>e.string))}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){const t=this.displayedValues;if(0===t.length)return;let i;if(void 0!==this.state.selectedValue){const e=t.findIndex((e=>e.string===this.state.selectedValue));i=-1===e?void 0:e}switch(e.key){case"ArrowDown":i=void 0===i?0:Math.min(i+1,t.length-1),e.preventDefault(),e.stopPropagation();break;case"ArrowUp":i=void 0===i?t.length-1:Math.max(i-1,0),e.preventDefault(),e.stopPropagation();break;case"Enter":void 0!==i&&this.checkValue(t[i]),e.stopPropagation(),e.preventDefault()}this.state.selectedValue=void 0!==i?t[i].string:void 0,"ArrowUp"!==e.key&&"ArrowDown"!==e.key||this.scrollListToSelectedValue(e.key)}clearScrolledToValue(){this.state.values.forEach((e=>e.scrolledTo=void 0))}scrollListToSelectedValue(e){this.clearScrolledToValue();const t=this.state.values.find((e=>e.string===this.state.selectedValue));t&&(t.scrolledTo="ArrowUp"===e?"top":"bottom")}sortFilterZone(e){var t,i;const o=this.props.filterPosition,n=this.filterTable;if(!o||!n||!n.contentZone)return;const s=this.env.model.getters.getActiveSheetId();this.env.model.dispatch("SORT_CELLS",{sheetId:s,col:o.col,row:n.contentZone.top,zone:n.contentZone,sortDirection:e,sortOptions:{emptyCellAsZero:!0,sortHeaders:!0}}),null===(i=(t=this.props).onClosed)||void 0===i||i.call(t)}}Un.size={width:$,height:295},Un.template="o-spreadsheet-FilterMenu",Un.style=Pn,Un.components={FilterMenuValueItem:Ln},Un.props={filterPosition:Object,onClosed:{type:Function,optional:!0}};const Vn={onOpen:(e,t)=>({isOpen:!0,props:{filterPosition:e},Component:Un,cellCorner:"BottomLeft"})},zn=/Mac/i;function Bn(e,t){return!!t.target&&e.contains(t.target)}function Hn(){const e=document.querySelector(".o-grid-overlay");if(e){const{top:t,left:i}=null==e?void 0:e.getBoundingClientRect();return{top:t,left:i}}throw new Error("Can't find spreadsheet position")}function $n(e){const t=e.getBoundingClientRect();return{x:t.x,y:t.y,width:t.width,height:t.height}}function*Wn(e){if(yield e,e.hasChildNodes())for(let t of e.childNodes)yield*Wn(t)}function Gn(){return Boolean(zn.test(navigator.userAgent))}function qn(e){return Gn()?e.metaKey:e.ctrlKey}function Zn(){const e=t.useState({x:0,y:0,width:0,height:0});let i=document.querySelector(".o-spreadsheet");function o(){if(i||(i=document.querySelector(".o-spreadsheet")),i){const{top:t,left:o,width:n,height:s}=i.getBoundingClientRect();e.x=o,e.y=t,e.width=n,e.height=s}}return o(),t.onMounted(o),t.onPatched(o),e}function jn(e){const i=t.useState({x:0,y:0,width:0,height:0});function o(){const t=e.el;if(null===t)return;const{top:o,left:n,width:s,height:r}=t.getBoundingClientRect();i.x=n,i.y=o,i.width=s,i.height=r}return t.onMounted(o),t.onPatched(o),i}function Xn(e,t){return(i=Xi(Yn(e),Yn(t)))?{x:i.left,y:i.top,width:i.right-i.left,height:i.bottom-i.top}:void 0;var i}function Yn(e){return{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height}}fo`
|
|
166
166
|
.o-popover {
|
|
167
167
|
position: absolute;
|
|
168
168
|
z-index: ${ce.Popover};
|
|
@@ -171,7 +171,7 @@
|
|
|
171
171
|
width: fit-content;
|
|
172
172
|
height: fit-content;
|
|
173
173
|
}
|
|
174
|
-
`;class
|
|
174
|
+
`;class Kn extends t.Component{constructor(){super(...arguments),this.popoverRef=t.useRef("popover"),this.currentPosition=void 0,this.currentDisplayValue=void 0,this.spreadsheetRect=Zn()}setup(){this.containerRect=function(){const e=t.useState({x:0,y:0,width:0,height:0}),i=t.useComponent(),o=Zn();function n(){const t=i.env,n="getPopoverContainerRect"in t?t.getPopoverContainerRect():o;e.x=n.x,e.y=n.y,e.width=n.width,e.height=n.height}return n(),t.onMounted(n),t.onPatched(n),e}(),t.useEffect((()=>{var e,t,i,o;if(!this.containerRect)throw new Error("Popover container is not defined");const n=this.popoverRef.el,s=Xn(this.props.anchorRect,this.containerRect),r=s?"block":"none";if("none"!==this.currentDisplayValue&&"none"===r&&(null===(t=(e=this.props).onPopoverHidden)||void 0===t||t.call(e)),n.style.display=r,this.currentDisplayValue=r,!s)return;const a={width:this.props.maxWidth,height:this.props.maxHeight},l={width:n.getBoundingClientRect().width,height:n.getBoundingClientRect().height},c=this.spreadsheetRect,h="BottomLeft"===this.props.positioning?new Jn(s,this.containerRect,a,c):new es(s,this.containerRect,a,c),d=h.getCss(l,this.props.verticalOffset);for(const e of Object.keys(d))n.style[e]=d[e];const u=h.getCurrentPosition(l);this.currentPosition&&u!==this.currentPosition&&(null===(o=(i=this.props).onPopoverMoved)||void 0===o||o.call(i)),this.currentPosition=u}))}get popoverStyle(){return Co({"z-index":`${this.props.zIndex}`})}}Kn.template="o-spreadsheet-Popover",Kn.defaultProps={positioning:"BottomLeft",verticalOffset:0,onMouseWheel:()=>{},onPopoverMoved:()=>{},onPopoverHidden:()=>{},zIndex:ce.Popover},Kn.props={anchorRect:Object,containerRect:{type:Object,optional:!0},positioning:{type:String,optional:!0},maxWidth:{type:Number,optional:!0},maxHeight:{type:Number,optional:!0},verticalOffset:{type:Number,optional:!0},onMouseWheel:{type:Function,optional:!0},onPopoverHidden:{type:Function,optional:!0},onPopoverMoved:{type:Function,optional:!0},zIndex:{type:Number,optional:!0},slots:Object};class Qn{constructor(e,t,i,o){this.anchorRect=e,this.containerRect=t,this.propsMaxSize=i,this.spreadsheetOffset=o}shouldRenderAtBottom(e){return e<=this.availableHeightDown||this.availableHeightDown>=this.availableHeightUp}shouldRenderAtRight(e){return e<=this.availableWidthRight||this.availableWidthRight>=this.availableWidthLeft}getMaxHeight(e){const t=this.shouldRenderAtBottom(e)?this.availableHeightDown:this.availableHeightUp;return this.propsMaxSize.height?Math.min(t,this.propsMaxSize.height):t}getMaxWidth(e){const t=this.shouldRenderAtRight(e)?this.availableWidthRight:this.availableWidthLeft;return this.propsMaxSize.width?Math.min(t,this.propsMaxSize.width):t}getCss(e,t){const i=this.getMaxHeight(e.height),o=this.getMaxWidth(e.width),n=Math.min(i,e.height),s=Math.min(o,e.width),r=this.shouldRenderAtBottom(e.height),a=this.shouldRenderAtRight(e.width);t=r?t:-t;return{"max-height":i+"px","max-width":o+"px",top:this.getTopCoordinate(n,r)-this.spreadsheetOffset.y-t+"px",left:this.getLeftCoordinate(s,a)-this.spreadsheetOffset.x+"px"}}getCurrentPosition(e){const t=this.shouldRenderAtBottom(e.height),i=this.shouldRenderAtRight(e.width);return t&&i?"BottomRight":t&&!i?"BottomLeft":!t&&i?"TopRight":"TopLeft"}}class Jn extends Qn{get availableHeightUp(){return this.anchorRect.y-this.containerRect.y}get availableHeightDown(){return this.containerRect.height-this.availableHeightUp-this.anchorRect.height}get availableWidthRight(){return this.containerRect.x+this.containerRect.width-this.anchorRect.x}get availableWidthLeft(){return this.anchorRect.x+this.anchorRect.width-this.containerRect.x}getTopCoordinate(e,t){return t?this.anchorRect.y+this.anchorRect.height:this.anchorRect.y-e}getLeftCoordinate(e,t){return t?this.anchorRect.x:this.anchorRect.x+this.anchorRect.width-e}}class es extends Qn{get availableHeightUp(){return this.anchorRect.y+this.anchorRect.height-this.containerRect.y}get availableHeightDown(){return this.containerRect.y+this.containerRect.height-this.anchorRect.y}get availableWidthRight(){return this.containerRect.width-this.anchorRect.width-this.availableWidthLeft}get availableWidthLeft(){return this.anchorRect.x-this.containerRect.x}getTopCoordinate(e,t){return t?this.anchorRect.y:this.anchorRect.y+this.anchorRect.height-e}getLeftCoordinate(e,t){return t?this.anchorRect.x+this.anchorRect.width:this.anchorRect.x-e}}fo`
|
|
175
175
|
.o-menu {
|
|
176
176
|
background-color: white;
|
|
177
177
|
padding: ${8}px 0px;
|
|
@@ -221,7 +221,7 @@
|
|
|
221
221
|
}
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
|
-
`;class
|
|
224
|
+
`;class ts extends t.Component{constructor(){super(...arguments),this.subMenu=t.useState({isOpen:!1,position:null,scrollOffset:0,menuItems:[]}),this.menuRef=t.useRef("menu"),this.position=jn(this.menuRef)}setup(){t.useExternalListener(window,"click",this.onExternalClick,{capture:!0}),t.useExternalListener(window,"contextmenu",this.onExternalClick,{capture:!0}),t.onWillUpdateProps((e=>{e.menuItems!==this.props.menuItems&&this.closeSubMenu()}))}get visibleMenuItems(){return this.props.menuItems.filter((e=>e.isVisible(this.env)))}get subMenuPosition(){const e=Object.assign({},this.subMenu.position);return e.y-=this.subMenu.scrollOffset||0,e}get menuHeight(){const e=this.visibleMenuItems;let t=this.getMenuItemsHeight(e);e[e.length-1].separator&&(t-=11);const i=16+t;return this.props.maxHeight?Math.min(i,this.props.maxHeight):i}get popoverProps(){const e=1===this.props.depth;return{anchorRect:{x:this.props.position.x-$*(this.props.depth-1),y:this.props.position.y,width:e?0:$,height:e?0:28},positioning:"TopRight",verticalOffset:e?0:8,onPopoverHidden:()=>this.closeSubMenu(),onPopoverMoved:()=>this.closeSubMenu(),maxHeight:this.menuHeight}}getColor(e){return e.textColor?`color: ${e.textColor}`:void 0}async activateMenu(e){var t,i,o;const n=await(null===(t=e.action)||void 0===t?void 0:t.call(e,this.env));this.close(),null===(o=(i=this.props).onMenuClicked)||void 0===o||o.call(i,{detail:n})}close(){this.closeSubMenu(),this.props.onClose()}subMenuVerticalPosition(e){const t=this.visibleMenuItems.slice(0,e);return this.position.y+this.getMenuItemsHeight(t)+8}onExternalClick(e){this.menuRef.el&&Array.from(document.querySelectorAll(".o-spreadsheet .o-menu")).some((t=>Bn(t,e)))||(e.closedMenuId=this.props.menuId,this.close())}getMenuItemsHeight(e){const t=e.filter((e=>e.separator)).length;return 28*e.length+11*t}getName(e){return e.name(this.env)}isRoot(e){return!e.action}isEnabled(e){return!!e.isEnabled(this.env)&&(!this.env.model.getters.isReadonly()||e.isReadonlyAllowed)}onScroll(e){this.subMenu.scrollOffset=e.target.scrollTop}openSubMenu(e,t){const i=this.subMenuVerticalPosition(t);this.subMenu.position={x:this.position.x+this.props.depth*$,y:i-(this.subMenu.scrollOffset||0)},this.subMenu.menuItems=e.children(this.env),this.subMenu.isOpen=!0,this.subMenu.parentMenu=e}isParentMenu(e,t){var i;return(null===(i=e.parentMenu)||void 0===i?void 0:i.id)===t.id}closeSubMenu(){this.subMenu.isOpen=!1,this.subMenu.parentMenu=void 0}onClickMenu(e,t){this.isEnabled(e)&&(this.isRoot(e)?this.openSubMenu(e,t):this.activateMenu(e))}onMouseOver(e,t){e.isEnabled(this.env)&&(this.isRoot(e)?this.openSubMenu(e,t):this.closeSubMenu())}}ts.template="o-spreadsheet-Menu",ts.components={Menu:ts,Popover:Kn},ts.defaultProps={depth:1},ts.props={position:Object,menuItems:Array,depth:{type:Number,optional:!0},maxHeight:{type:Number,optional:!0},onClose:Function,onMenuClicked:{type:Function,optional:!0},menuId:{type:String,optional:!0}};fo`
|
|
225
225
|
.o-link-tool {
|
|
226
226
|
font-size: 13px;
|
|
227
227
|
background-color: white;
|
|
@@ -268,7 +268,7 @@
|
|
|
268
268
|
cursor: pointer;
|
|
269
269
|
color: #000;
|
|
270
270
|
}
|
|
271
|
-
`;class
|
|
271
|
+
`;class is extends t.Component{get cell(){const{col:e,row:t}=this.props.cellPosition,i=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getEvaluatedCell({sheetId:i,col:e,row:t})}get link(){if(this.cell.link)return this.cell.link;const{col:e,row:t}=this.props.cellPosition;throw new Error(`LinkDisplay Component can only be used with link cells. ${qt(e,t)} is not a link.`)}getUrlRepresentation(e){return No(e,this.env.model.getters)}openLink(){_o(this.link,this.env)}edit(){const{col:e,row:t}=this.props.cellPosition;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:e,row:t,popoverType:"LinkEditor"})}unlink(){const e=this.env.model.getters.getActiveSheetId(),{col:t,row:i}=this.props.cellPosition,o=this.env.model.getters.getCellComputedStyle({sheetId:e,col:t,row:i}),n=(null==o?void 0:o.textColor)===I||null==o?void 0:o.textColor;this.env.model.dispatch("UPDATE_CELL",{col:t,row:i,sheetId:e,content:this.link.label,style:{...o,textColor:n,underline:void 0}})}}is.components={Menu:ts},is.template="o-spreadsheet-LinkDisplay";const os={onHover:(e,t)=>{const i=t.getEvaluatedCell(e);return!t.isDashboard()&&i.link&&t.isVisibleInViewport(e)?{isOpen:!0,Component:is,props:{cellPosition:e},cellCorner:"BottomLeft"}:{isOpen:!1}}};function ns(e){return e.map(rs).sort(((e,t)=>e.sequence-t.sequence))}is.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const ss=new Vi;function rs(e){const t=e.name,i=e.children;return{id:e.id||ss.uuidv4(),name:"function"==typeof t?t:()=>t,isVisible:e.isVisible?e.isVisible:()=>!0,isEnabled:e.isEnabled?e.isEnabled:()=>!0,action:e.action,children:i?e=>i.map((t=>"function"==typeof t?t(e):t)).flat().map(rs):()=>[],isReadonlyAllowed:e.isReadonlyAllowed||!1,separator:e.separator||!1,icon:e.icon,description:e.description||"",textColor:e.textColor,sequence:e.sequence||0}}class as extends Io{add(e,t){return void 0===t.id&&(t.id=e),this.content[e]=t,this}addChild(e,t,i){"function"!=typeof i&&void 0===i.id&&(i.id=e);const o=t.splice(0,1)[0];let n=this.content[o];if(!n)throw new Error(`Path ${o+":"+t.join(":")} not found`);for(let e of t){const i=n.children;if(!i||"function"==typeof i)throw new Error(`${e} is either not a node or it's dynamically computed`);if(n=i.find((t=>t.id===e)),!n)throw new Error(`Path ${o+":"+t.join(":")} not found`)}return n.children||(n.children=[]),n.children.push(i),this}getMenuItems(){return ns(this.getAll())}}const ls=new as;ls.add("sheet",{name:s("Link sheet"),sequence:10}).addChild("sheet_list",["sheet"],(e=>e.model.getters.getSheetIds().map((t=>e.model.getters.getSheet(t))).map((e=>({id:e.id,name:e.name,action:()=>Ye(e.name,et(e.id))})))));fo`
|
|
272
272
|
.o-link-editor {
|
|
273
273
|
font-size: 13px;
|
|
274
274
|
background-color: white;
|
|
@@ -341,13 +341,13 @@
|
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
343
|
}
|
|
344
|
-
`;class as extends t.Component{constructor(){super(...arguments),this.menuItems=rs.getMenuItems(),this.link=t.useState(this.defaultState),this.menu=t.useState({isOpen:!1}),this.linkEditorRef=t.useRef("linkEditor"),this.position=qn(this.linkEditorRef),this.urlInput=t.useRef("urlInput")}setup(){t.onMounted((()=>{var e;return null===(e=this.urlInput.el)||void 0===e?void 0:e.focus()}))}get defaultState(){const{col:e,row:t}=this.props.cellPosition,i=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getEvaluatedCell({sheetId:i,col:e,row:t});return o.link?{url:o.link.url,label:o.formattedValue,isUrlEditable:o.link.isUrlEditable}:{label:o.formattedValue,url:"",isUrlEditable:!0}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){const{detail:t}=e,i=Fo(t);i&&(this.link.url=i.url,this.link.label=i.label,this.link.isUrlEditable=i.isUrlEditable)}getUrlRepresentation(e){return No(e,this.env.model.getters)}openMenu(){this.menu.isOpen=!0}removeLink(){this.link.url="",this.link.isUrlEditable=!0}save(){var e,t;const{col:i,row:o}=this.props.cellPosition,n=this.link.label||this.link.url;this.env.model.dispatch("UPDATE_CELL",{col:i,row:o,sheetId:this.env.model.getters.getActiveSheetId(),content:Ye(n,this.link.url)}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){switch(e.key){case"Enter":this.link.url&&this.save(),e.stopPropagation();break;case"Escape":this.cancel(),e.stopPropagation()}}}as.template="o-spreadsheet-LinkEditor",as.components={Menu:Jn};const ls={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:as,cellCorner:"BottomLeft"})};as.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const cs=new Io;function hs(e){return 8===(e=Et(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}cs.add("ErrorToolTip",kn).add("LinkCell",ts).add("LinkEditor",ls).add("FilterMenu",Vn);class ds{constructor(e,t,i){this.title=e.title,this.sheetId=t,this.getters=i}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function us(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?Zi(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?Wi(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function gs(e,t,i,o){let n=!1;const s=[];for(let o in i){let r=i[o];if(r.labelCell){const e=fs(r.labelCell,t);r.labelCell!==e&&(n=!0,r={...r,labelCell:e})}const a=fs(r.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===K?(n=!0,r=void 0):a!==r.dataRange&&(n=!0,r={...r,dataRange:a}),s[o]=r}let r=o;const a=fs(r,t);a!==r&&(n=!0,r=a);return{isStale:n,dataSets:s.filter(it),labelRange:r}}function ps(e,t,i){return i.map((i=>({dataRange:ki(e,t,i.dataRange),labelCell:i.labelCell?ki(e,t,i.labelCell):void 0})))}function ms(e,t,i){return i?ki(e,t,i):void 0}function fs(e,t){if(!e)return;const i=t(e);switch(i.changeType){case"NONE":return e;case"REMOVE":return;default:return i.range}}function vs(e,t,i,o){const n=[];for(const s of t){const t=e.getRangeFromSheetXC(i,s),{unboundedZone:r,sheetId:a,invalidSheetName:l}=t;if(!l)if(r.left!==r.right&&r.top!==r.bottom){if(void 0===r.right)continue;for(let t=r.left;t<=r.right;t++){const i={...r,left:t,right:t};n.push(bs(e,a,i,o?{top:i.top,bottom:i.top,left:i.left,right:i.left}:void 0))}}else r.left===r.right&&r.top===r.bottom?o||n.push(bs(e,a,r,void 0)):n.push(bs(e,a,r,o?{top:r.top,bottom:r.top,left:r.left,right:r.left}:void 0))}return n}function bs(e,t,i,o){if(i.left!==i.right&&i.top!==i.bottom)throw new Error(`Zone should be a single column or row: ${$i(i)}`);if(o){const n=$i(i),s=$i(o);return{labelCell:e.getRangeFromSheetXC(t,s),dataRange:e.getRangeFromSheetXC(t,n)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,$i(i))}}function Ss(e,t){var i;const o=null===(i=t.labelCell)||void 0===i?void 0:i.zone;let n=t.dataRange.zone;if(o){const{numberOfRows:e,numberOfCols:t}=io(n);1===e?n={...n,left:n.left+1}:1===t&&(n={...n,top:n.top+1})}const s=t.dataRange.clone({zone:n});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference"):void 0,range:e.getRangeString(s,"forceSheetReference")}}function Cs(e,t){let i;if(e.labelRange){const o=us(zi(e.labelRange),t);i=o?$i(o):void 0}const o=e.dataSets.map(zi).map((e=>us(e,t))).filter(it).map($i);return{...e,labelRange:i,dataSets:o}}const Es=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];class ws{constructor(){this.graphColorIndex=0}next(){return Es[this.graphColorIndex++%Es.length]}}function ys(e){return e&&It(e)<.3?"#FFFFFF":"#000000"}function xs(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!Lt.test(e)));if(t)return 32;if(e.dataSets.map(zi).some((e=>e.top!==e.bottom&&co(e))))return 32}return 0}function Is(e){if(e.labelRange){if(!Lt.test(e.labelRange||""))return 33}return 0}function Rs(e,t,i){if(e){if("text"===i||(null==t?void 0:t.type)!==ln.number||e.type!==ln.number)return e.formattedValue;{let o=t.value-e.value;if("percentage"===i&&0!==o&&(o=o/e.value*100),"percentage"!==i&&e.format)return mi(o,e.format);const n=Math.abs(parseFloat(o.toFixed(2))).toLocaleString();return"percentage"===i?n+"%":n}}return""}function Ts(e,t,i,o,n){if("text"===t||(null==e?void 0:e.type)!==ln.number||(null==i?void 0:i.type)!==ln.number)return;const s=i.value-e.value;return s>0?o:s<0?n:void 0}function As(e,t,i){if("text"===i||(null==e?void 0:e.type)!==ln.number||(null==t?void 0:t.type)!==ln.number)return"neutral";const o=t.value-e.value;return o>0?"up":o<0?"down":"neutral"}const Ms={Errors:{25:s("The range is invalid"),51:s("The argument is missing. Please provide a value"),52:s("The second argument is missing. Please provide a value"),53:s("The minpoint must be a number"),54:s("The midpoint must be a number"),55:s("The maxpoint must be a number"),56:s("The first value must be a number"),57:s("The second value must be a number"),47:s("Minimum must be smaller then Maximum"),50:s("Minimum must be smaller then Midpoint"),49:s("Midpoint must be smaller then Maximum"),48:s("Lower inflection point must be smaller than upper inflection point"),58:s("Invalid Minpoint formula"),60:s("Invalid Maxpoint formula"),59:s("Invalid Midpoint formula"),61:s("Invalid upper inflection point formula"),62:s("Invalid lower inflection point formula"),24:s("A range needs to be defined"),Unexpected:s("The rule is invalid for an unknown reason")},ColorScale:s("Color scale"),IconSet:s("Icon set")},Os={IsEmpty:s("Is empty"),IsNotEmpty:s("Is not empty"),ContainsText:s("Contains"),NotContains:s("Does not contain"),BeginsWith:s("Starts with"),EndsWith:s("Ends with"),Equal:s("Is equal to"),NotEqual:s("Is not equal to"),GreaterThan:s("Is greater than"),GreaterThanOrEqual:s("Is greater than or equal to"),LessThan:s("Is less than"),LessThanOrEqual:s("Is less than or equal to"),Between:s("Is between"),NotBetween:s("Is not between")},Ns={Series:s("Series"),Errors:{Unexpected:s("The chart definition is invalid for an unknown reason"),32:s("The dataset is invalid"),33:s("Labels are invalid"),34:s("The key value is invalid"),35:s("The baseline value is invalid"),36:s("The data range is invalid"),37:s("A minimum range limit value is needed"),38:s("The minimum range limit value must be a number"),39:s("A maximum range limit value is needed"),40:s("The maximum range limit value must be a number"),41:s("Minimum range limit must be smaller than maximum range limit"),42:s("The lower inflection point value must be a number"),43:s("The upper inflection point value must be a number")}},_s={Automatic:s("Automatic"),Number:s("Number"),Percent:s("Percent"),Currency:s("Currency"),CurrencyRounded:s("Currency rounded"),Date:s("Date"),Time:s("Time"),DateTime:s("Date time"),Duration:s("Duration"),CustomCurrency:s("Custom currency")},Fs={Custom:s("Custom")},Ds=s("Merged cells are preventing this operation. Unmerge those cells and try again.");function ks(e,t){if(t.dataRange){const i=t.labelCell?[$i(t.labelCell.zone)]:[],o=eo([$i(t.dataRange.zone)],i)[0];if(void 0===o)return[];const n=e.getRangeFromSheetXC(t.dataRange.sheetId,o);return e.getRangeValues(n).map((e=>""===e?void 0:e))}return[]}function Ls(e,t){const i=He(0,Math.max(e.length,...t.map((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.length)||0})))).filter((i=>{const o=e[i],n=t.map((e=>{var t;return null===(t=e.data)||void 0===t?void 0:t[i]}));return o||n.some((e=>0===e||Boolean(e)))}));return{labels:i.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:i.map((t=>e.data[t]))})))}}function Ps(e,t){const i=new Set(e),o={};i.forEach((e=>{o[e]=new Array(t.length).fill(0)}));for(const i of He(0,e.length)){const s=e[i];for(const e of He(0,t.length))o[s][e]+="number"==typeof(n=t[e].data[i])?n:0}var n;return{labels:Object.keys(o),dataSetsValues:t.map(((e,t)=>({...e,data:Object.values(o).map((e=>e[t]))})))}}function Us(e){return e?e.length>J?e.substring(0,J)+"…":e:""}function Vs(e,t,i,o){return{type:e.type,options:{responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:{duration:0},hover:{animationDuration:10},responsiveAnimationDuration:0,title:{display:!!e.title,fontSize:22,fontStyle:"normal",text:n(e.title),fontColor:i},legend:{onClick:void 0},tooltips:{callbacks:{label:function(e,t){var i,n,s,r,a;let l=null===(n=null===(i=t.datasets)||void 0===i?void 0:i[e.datasetIndex||0])||void 0===n?void 0:n.label;const c=""!==e.yLabel?e.yLabel:null===(a=null===(r=null===(s=t.datasets)||void 0===s?void 0:s[e.datasetIndex||0])||void 0===r?void 0:r.data)||void 0===a?void 0:a[e.index||0],h=o&&"number"==typeof c?mi(c,o):(null==c?void 0:c.toLocaleString())||"";return l?`${l}: ${h}`:h}}}},data:{labels:t.map(Us),datasets:[]}}}function zs(e,t,i){let o={values:[],formattedValues:[]};if(i)i.invalidXc||i.invalidSheetName||(o={formattedValues:e.getRangeFormattedValues(i),values:e.getRangeValues(i).map((e=>String(e)))});else if(1===t.length)for(let i=0;i<ks(e,t[0]).length;i++)o.formattedValues.push(""),o.values.push("");else if(t[0]){o={formattedValues:He(0,ks(e,t[0]).length).map((e=>e.toString())),values:o.formattedValues}}return o}function Bs(e,t){for(const i of t){const t=e.getRangeFormats(i.dataRange).find((e=>void 0!==e&&!Ei(e)));if(t)return t}}function Hs(e,t){const i=[];for(const[o,n]of Object.entries(t)){let t;if(n.labelCell){const i=n.labelCell,s=i?e.getEvaluatedCell({sheetId:i.sheetId,col:i.zone.left,row:i.zone.top}):void 0;t=s&&i?Us(s.formattedValue):t=`${Ns.Series} ${parseInt(o)+1}`}else t=t=`${Ns.Series} ${parseInt(o)+1}`;let s=n.dataRange?ks(e,n):[];i.push({data:s,label:t})}return i}function $s(e){return 0===e?"origin":e-1}class Ws extends ds{constructor(e,t,i){super(e,t,i),this.type="bar",this.dataSets=vs(i,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Li(i,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated}static transformDefinition(e,t){return Cs(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,xs,Is)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,aggregated:!1,legendPosition:"top",title:e.title||"",type:"bar",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}copyForSheetId(e){const t=ps(this.sheetId,e,this.dataSets),i=ms(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new Ws(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new Ws(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,i){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Ss(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:hs(this.background||w),fontColor:hs(ys(this.background)),dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=gs(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new Ws(n,this.sheetId,this.getters)}}function Gs(e){return e.dataRange&&!Lt.test(e.dataRange)?36:0}function qs(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function Zs(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?41:0}function js(e,t){if(""===e)switch(t){case"rangeMin":return 37;case"rangeMax":return 39}return 0}function Xs(e,t){if(isNaN(e))switch(t){case"rangeMin":return 38;case"rangeMax":return 40;case"lowerInflectionPointValue":return 42;case"upperInflectionPointValue":return 43}return 0}class Ys extends ds{constructor(e,t,i){super(e,t,i),this.type="gauge",this.dataRange=Li(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,Gs,e.chainValidations(qs(js,e.batchValidations),qs(Xs,e.batchValidations),Zs),e.chainValidations((i=Xs,(0,e.batchValidations)((e=>e.sectionRule?i(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?i(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var i}static transformDefinition(e,t){let i;return e.dataRange&&(i=us(zi(e.dataRange),t)),{...e,dataRange:i?$i(i):void 0}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||"",type:"gauge",dataRange:e.range?e.range[0]:void 0,sectionRule:{colors:{lowerColor:"#cc0000",middleColor:"#f1c232",upperColor:"#6aa84f"},rangeMin:"0",rangeMax:"100",lowerInflectionPoint:{type:"percentage",value:"15"},upperInflectionPoint:{type:"percentage",value:"40"}}}}copyForSheetId(e){const t=ms(this.sheetId,e,this.dataRange),i=this.getDefinitionWithSpecificRanges(t,e);return new Ys(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new Ys(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.dataRange)}getDefinitionWithSpecificRanges(e,t){return{background:this.background,sectionRule:this.sectionRule,title:this.title,type:"gauge",dataRange:e?this.getters.getRangeString(e,t||this.sheetId):void 0}}getDefinitionForExcel(){}getContextCreation(){return{background:this.background,title:this.title,range:this.dataRange?[this.getters.getRangeString(this.dataRange,this.sheetId)]:void 0}}updateRanges(e){const t=fs(this.dataRange,e);if(this.dataRange===t)return this;const i=this.getDefinitionWithSpecificRanges(t);return new Ys(i,this.sheetId,this.getters)}}const Ks={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},Qs={inSeconds:function(e){return Math.floor(e/Ks.second)},inMinutes:function(e){return Math.floor(e/Ks.minute)},inHours:function(e){return Math.floor(e/Ks.hour)},inDays:function(e){return Math.floor(e/Ks.day)},inMonths:function(e){return Math.floor(e/Ks.month)},inYears:function(e){return Math.floor(e/Ks.year)}},Js=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function er(e,t){const i=function(e){const t=(e=(e=e.replace(/y/g,"Y")).replace(/d/g,"D")).indexOf("h");e=t>=0?e.slice(0,t).replace(/m/g,"M")+e.slice(t):e.replace(/m/g,"M");e.includes("a")||(e=e.replace(/h/g,"H"));return e}(t),o=function(e,t){const i=e.map((e=>{var t;return null===(t=Ee(e))||void 0===t?void 0:t.jsDate}));if(i.some((e=>void 0===e))||e.length<2)return;const o=i.map((e=>e.getTime())),n=Math.max(...o)-Math.min(...o),s=function(e){if(e.includes("s"))return"second";if(e.includes("m"))return"minute";if(e.includes("h")||e.includes("H"))return"hour";if(e.includes("D"))return"day";if(e.includes("M"))return"month";return"year"}(t);if(Ks.second>=Ks[s]&&Qs.inSeconds(n)<180)return"second";if(Ks.minute>=Ks[s]&&Qs.inMinutes(n)<180)return"minute";if(Ks.hour>=Ks[s]&&Qs.inHours(n)<96)return"hour";if(Ks.day>=Ks[s]&&Qs.inDays(n)<90)return"day";if(Ks.month>=Ks[s]&&Qs.inMonths(n)<36)return"month";return"year"}(e,i),n={};return o&&(n[o]=i),{parser:i,displayFormats:n,unit:o}}class tr extends ds{constructor(e,t,i){super(e,t,i),this.type="line",this.dataSets=vs(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Li(this.getters,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.stacked=e.stacked,this.aggregated=e.aggregated,this.cumulative=e.cumulative}static validateChartDefinition(e,t){return e.checkValidations(t,xs,Is)}static transformDefinition(e,t){return Cs(e,t)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,labelsAsText:!1,legendPosition:"top",title:e.title||"",type:"line",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0,stacked:!1,aggregated:!1,cumulative:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,i){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated,cumulative:this.cumulative}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=gs(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new tr(n,this.sheetId,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Ss(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:hs(this.background||w),fontColor:hs(ys(this.background)),dataSets:e}}copyForSheetId(e){const t=ps(this.sheetId,e,this.dataSets),i=ms(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new tr(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new tr(t,e,this.getters)}}function ir(e,t){return nr(e,t)||sr(e,t)}function or(e,t){return function(e,t){return!e.labelsAsText&&nr(e.labelRange,t)}(e,t)?"time":function(e,t){return!e.labelsAsText&&sr(e.labelRange,t)}(e,t)?"linear":"category"}function nr(e,t){if(!e||!sr(e,t))return!1;const i=t.getEvaluatedCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}).format;return Boolean(i&&Js.test(i))}function sr(e,t){if(!e)return!1;const i=t.getRangeValues(e);return!i.some((e=>isNaN(Number(e))&&e))&&!i.every((e=>!e))}class rr extends ds{constructor(e,t,i){super(e,t,i),this.type="pie",this.dataSets=vs(i,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Li(i,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated}static transformDefinition(e,t){return Cs(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,xs,Is)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,legendPosition:"top",title:e.title||"",type:"pie",labelRange:e.auxiliaryRange||void 0,aggregated:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinitionWithSpecificDataSets(e,t,i){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,aggregated:this.aggregated}}copyForSheetId(e){const t=ps(this.sheetId,e,this.dataSets),i=ms(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new rr(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new rr(t,e,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Ss(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:hs(this.background||w),fontColor:hs(ys(this.background)),verticalAxisPosition:"left",dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=gs(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new rr(n,this.sheetId,this.getters)}}function ar(e,t){const i=[],o=Math.max(...t.map((e=>e.data.length)));for(let t=0;t<=o;t++)i.push(e.next());return i}function lr(e){return e.keyValue&&!Lt.test(e.keyValue)?34:0}function cr(e){return e.baseline&&!Lt.test(e.baseline)?35:0}class hr extends ds{constructor(e,t,i){super(e,t,i),this.type="scorecard",this.keyValue=Li(i,t,e.keyValue),this.baseline=Li(i,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown}static validateChartDefinition(e,t){return e.checkValidations(t,lr,cr)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:te,baselineColorUp:ie,baselineColorDown:oe,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let i,o;return e.baseline&&(i=us(zi(e.baseline),t)),e.keyValue&&(o=us(zi(e.keyValue),t)),{...e,baseline:i?$i(i):void 0,keyValue:o?$i(o):void 0}}copyForSheetId(e){const t=ms(this.sheetId,e,this.baseline),i=ms(this.sheetId,e,this.keyValue),o=this.getDefinitionWithSpecificRanges(t,i,e);return new hr(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new hr(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{background:this.background,title:this.title,range:this.keyValue?[this.getters.getRangeString(this.keyValue,this.sheetId)]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,i){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,i||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,i||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(e){const t=fs(this.baseline,e),i=fs(this.keyValue,e);if(this.baseline===t&&this.keyValue===i)return this;const o=this.getDefinitionWithSpecificRanges(t,i);return new hr(o,this.sheetId,this.getters)}}const dr=new Io;dr.add("bar",{match:e=>"bar"===e,createChart:(e,t,i)=>new Ws(e,t,i),getChartRuntime:function(e,t){let i=zs(t,e.dataSets,e.labelRange).formattedValues,o=Hs(t,e.dataSets);({labels:i,dataSetsValues:o}=Ls(i,o)),e.aggregated&&({labels:i,dataSetsValues:o}=Ps(i,o));const n=function(e,t,i){var o;const n=ys(e.background),s=Vs(e,t,n,i),r={labels:{fontColor:n}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:n}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:n,beginAtZero:!0,callback:e=>i?mi(e,i):(null==e?void 0:e.toLocaleString())||e}}]},e.stacked&&(s.options.scales.xAxes[0].stacked=!0,s.options.scales.yAxes[0].stacked=!0),s}(e,i,Bs(t,e.dataSets)),s=new ws;for(let{label:e,data:t}of o){const i=s.next(),o={label:e,data:t,borderColor:i,backgroundColor:i};n.data.datasets.push(o)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>Ws.validateChartDefinition(e,t),transformDefinition:(e,t)=>Ws.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Ws.getDefinitionFromContextCreation(e),name:s("Bar"),sequence:10}),dr.add("line",{match:e=>"line"===e,createChart:(e,t,i)=>new tr(e,t,i),getChartRuntime:function(e,t){const i=or(e,t),o=zs(t,e.dataSets,e.labelRange);let n="linear"===i?o.values:o.formattedValues,s=Hs(t,e.dataSets);({labels:n,dataSetsValues:s}=Ls(n,s)),"time"===i&&({labels:n,dataSetsValues:s}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const i=[...e],o=_e(t);for(let e=0;e<i.length;e++)if(!i[e]){i[e]=at(i,e);for(let t of o)t.data[e]=void 0}return{labels:i,dataSetsValues:o}}(n,s)),e.aggregated&&({labels:n,dataSetsValues:s}=Ps(n,s));const r=Bs(t,e.dataSets),a=function(e,t,i){var o;const n=ys(e.background),s=Vs(e,t,n,i),r={labels:{fontColor:n,generateLabels(e){const{data:t}=e,i=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,o]of i.entries())o.fillStyle=t.datasets[e].borderColor;return i}}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:n}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:n,beginAtZero:!0,callback:e=>i?mi(e,i):(null==e?void 0:e.toLocaleString())||e}}]},e.stacked&&(s.options.scales.yAxes[0].stacked=!0),s}(e,n,r),l=function(e,t){if(t)return e.getEvaluatedCell({sheetId:t.sheetId,col:t.zone.left,row:t.zone.top}).format}(t,e.labelRange);"time"===i?(a.options.scales.xAxes[0].type="time",a.options.scales.xAxes[0].time=er(n,l),a.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===i&&(a.options.scales.xAxes[0].type="linear",a.options.scales.xAxes[0].ticks.callback=e=>mi(e,l),a.options.tooltips.callbacks.title=e=>{var t;return mi((null===(t=e[0])||void 0===t?void 0:t.xLabel)||"",l)});const c=new ws;for(let[t,{label:o,data:r}]of s.entries()){["linear","time"].includes(i)&&(r=r.map(((e,t)=>({x:n[t]||void 0,y:e}))));const s=c.next();let l=Tt(s);if(e.stacked&&(l.a=ne),e.cumulative){let e=0;r=r.map((t=>isNaN(t)?t:(e+=parseFloat(t),e)))}const h={label:o,data:r,lineTension:0,borderColor:s,backgroundColor:Rt(l),pointBackgroundColor:s,fill:!!e.stacked&&$s(t)};a.data.datasets.push(h)}return{chartJsConfig:a,background:e.background||w}},validateChartDefinition:(e,t)=>tr.validateChartDefinition(e,t),transformDefinition:(e,t)=>tr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>tr.getDefinitionFromContextCreation(e),name:s("Line"),sequence:20}),dr.add("pie",{match:e=>"pie"===e,createChart:(e,t,i)=>new rr(e,t,i),getChartRuntime:function(e,t){let i=zs(t,e.dataSets,e.labelRange).formattedValues,o=Hs(t,e.dataSets);({labels:i,dataSetsValues:o}=Ls(i,o)),e.aggregated&&({labels:i,dataSetsValues:o}=Ps(i,o));const n=function(e,t,i){var o;const n=ys(e.background),s=Vs(e,t,n,i),r={labels:{fontColor:n}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.tooltips.callbacks.title=function(e,t){return t.datasets[e[0].datasetIndex].label},s}(e,i,Bs(t,e.dataSets)),s=new ws;for(let{label:e,data:t}of o){const i={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:ar(s,o)};n.data.datasets.push(i)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>rr.validateChartDefinition(e,t),transformDefinition:(e,t)=>rr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>rr.getDefinitionFromContextCreation(e),name:s("Pie"),sequence:30}),dr.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,i)=>new hr(e,t,i),getChartRuntime:function(e,t){let i,o,s="",r="";if(e.keyValue){const o={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};i=t.getEvaluatedCell(o),s=String(i.value),r=i.formattedValue}const a=e.baseline;if(a){const i={sheetId:e.baseline.sheetId,col:e.baseline.zone.left,row:e.baseline.zone.top};o=t.getEvaluatedCell(i)}const{background:l,fontColor:c}=t.getStyleOfSingleCellChart(e.background,e.keyValue);return{title:n(e.title),keyValue:r||s,baselineDisplay:Rs(o,i,e.baselineMode),baselineArrow:As(o,i,e.baselineMode),baselineColor:Ts(o,e.baselineMode,i,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?n(e.baselineDescr):"",fontColor:c,background:l,baselineStyle:"percentage"!==e.baselineMode&&a?t.getCellStyle({sheetId:a.sheetId,col:a.zone.left,row:a.zone.top}):void 0,keyValueStyle:e.keyValue?t.getCellStyle({sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top}):void 0}},validateChartDefinition:(e,t)=>hr.validateChartDefinition(e,t),transformDefinition:(e,t)=>hr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>hr.getDefinitionFromContextCreation(e),name:s("Scorecard"),sequence:40}),dr.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,i)=>new Ys(e,t,i),getChartRuntime:function(e,t){const i=function(e){const t=Vs(e,[],ys(e.background));return t.options.hover=void 0,t.options.events=[],t.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},t.options.needle={radiusPercentage:2,widthPercentage:3.2,lengthPercentage:80,color:"#000000"},t.options.valueLabel={display:!1,formatter:null,color:"#FFFFFF",backgroundColor:"#000000",fontSize:30,borderRadius:5,padding:{top:5,right:5,bottom:5,left:5},bottomMarginPercentage:5},t}(e),o=e.sectionRule.colors,n=e.sectionRule.lowerInflectionPoint,s=e.sectionRule.upperInflectionPoint,r=Number(n.value),a=Number(s.value),l=Number(e.sectionRule.rangeMin),c=Number(e.sectionRule.rangeMax),h=c-l,d=[];if(""!==n.value){const e="number"===n.type?r:l+h*r/100;d.push({value:ke(e,l,c),color:o.lowerColor})}if(""!==s.value){const e="number"===s.type?a:l+h*a/100;d.push({value:ke(e,l,c),color:o.middleColor})}const u=[],g=[];d.sort(((e,t)=>e.value-t.value)).map((e=>{u.push(e.value),g.push(e.color)})),u.push(c),g.push(o.upperColor);const p=e.dataRange,m=h/30;let f=l-m,v=null,b=!1;if(void 0!==p){const e=t.getEvaluatedCell({sheetId:p.sheetId,col:p.zone.left,row:p.zone.top});e.type===ln.number&&(f=ke(e.value,l-m,c+m),v=()=>t.getRangeFormattedValues(p)[0],b=!0)}return i.options.valueLabel.display=b,i.options.valueLabel.formatter=v,i.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:f,backgroundColor:g}),{chartJsConfig:i,background:t.getStyleOfSingleCellChart(e.background,p).background}},validateChartDefinition:(e,t)=>Ys.validateChartDefinition(e,t),transformDefinition:(e,t)=>Ys.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Ys.getDefinitionFromContextCreation(e),name:s("Gauge"),sequence:50});const ur=new Io;ur.add("line",go),ur.add("bar",go),ur.add("pie",go),ur.add("gauge",go),ur.add("scorecard",wo);const gr=new Io;fo`
|
|
344
|
+
`;class cs extends t.Component{constructor(){super(...arguments),this.menuItems=ls.getMenuItems(),this.link=t.useState(this.defaultState),this.menu=t.useState({isOpen:!1}),this.linkEditorRef=t.useRef("linkEditor"),this.position=jn(this.linkEditorRef),this.urlInput=t.useRef("urlInput")}setup(){t.onMounted((()=>{var e;return null===(e=this.urlInput.el)||void 0===e?void 0:e.focus()}))}get defaultState(){const{col:e,row:t}=this.props.cellPosition,i=this.env.model.getters.getActiveSheetId(),o=this.env.model.getters.getEvaluatedCell({sheetId:i,col:e,row:t});return o.link?{url:o.link.url,label:o.formattedValue,isUrlEditable:o.link.isUrlEditable}:{label:o.formattedValue,url:"",isUrlEditable:!0}}get menuPosition(){return{x:this.position.x+320-12-2,y:this.position.y+100}}onSpecialLink(e){const{detail:t}=e,i=Fo(t);i&&(this.link.url=i.url,this.link.label=i.label,this.link.isUrlEditable=i.isUrlEditable)}getUrlRepresentation(e){return No(e,this.env.model.getters)}openMenu(){this.menu.isOpen=!0}removeLink(){this.link.url="",this.link.isUrlEditable=!0}save(){var e,t;const{col:i,row:o}=this.props.cellPosition,n=this.link.label||this.link.url;this.env.model.dispatch("UPDATE_CELL",{col:i,row:o,sheetId:this.env.model.getters.getActiveSheetId(),content:Ye(n,this.link.url)}),null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}cancel(){var e,t;null===(t=(e=this.props).onClosed)||void 0===t||t.call(e)}onKeyDown(e){switch(e.key){case"Enter":this.link.url&&this.save(),e.stopPropagation();break;case"Escape":this.cancel(),e.stopPropagation()}}}cs.template="o-spreadsheet-LinkEditor",cs.components={Menu:ts};const hs={onOpen:(e,t)=>({isOpen:!0,props:{cellPosition:e},Component:cs,cellCorner:"BottomLeft"})};cs.props={cellPosition:Object,onClosed:{type:Function,optional:!0}};const ds=new Io;function us(e){return 8===(e=Et(e).replace("#","")).length?e.slice(6)+e.slice(0,6):e}ds.add("ErrorToolTip",kn).add("LinkCell",os).add("LinkEditor",hs).add("FilterMenu",Vn);class gs{constructor(e,t,i){this.title=e.title,this.sheetId=t,this.getters=i}static validateChartDefinition(e,t){throw new Error("This method should be implemented by sub class")}static transformDefinition(e,t){throw new Error("This method should be implemented by sub class")}static getDefinitionFromContextCreation(e){throw new Error("This method should be implemented by sub class")}}function ps(e,t){return"REMOVE_COLUMNS_ROWS"===t.type?Zi(e,"COL"===t.dimension?"left":"top",t.elements):"ADD_COLUMNS_ROWS"===t.type?Wi(e,"COL"===t.dimension?"left":"top",t.base,t.position,t.quantity):{...e}}function ms(e,t,i,o){let n=!1;const s=[];for(let o in i){let r=i[o];if(r.labelCell){const e=bs(r.labelCell,t);r.labelCell!==e&&(n=!0,r={...r,labelCell:e})}const a=bs(r.dataRange,t);void 0===a||e.getRangeString(a,a.sheetId)===K?(n=!0,r=void 0):a!==r.dataRange&&(n=!0,r={...r,dataRange:a}),s[o]=r}let r=o;const a=bs(r,t);a!==r&&(n=!0,r=a);return{isStale:n,dataSets:s.filter(it),labelRange:r}}function fs(e,t,i){return i.map((i=>({dataRange:ki(e,t,i.dataRange),labelCell:i.labelCell?ki(e,t,i.labelCell):void 0})))}function vs(e,t,i){return i?ki(e,t,i):void 0}function bs(e,t){if(!e)return;const i=t(e);switch(i.changeType){case"NONE":return e;case"REMOVE":return;default:return i.range}}function Ss(e,t,i,o){const n=[];for(const s of t){const t=e.getRangeFromSheetXC(i,s),{unboundedZone:r,sheetId:a,invalidSheetName:l}=t;if(!l)if(r.left!==r.right&&r.top!==r.bottom){if(void 0===r.right)continue;for(let t=r.left;t<=r.right;t++){const i={...r,left:t,right:t};n.push(Cs(e,a,i,o?{top:i.top,bottom:i.top,left:i.left,right:i.left}:void 0))}}else r.left===r.right&&r.top===r.bottom?o||n.push(Cs(e,a,r,void 0)):n.push(Cs(e,a,r,o?{top:r.top,bottom:r.top,left:r.left,right:r.left}:void 0))}return n}function Cs(e,t,i,o){if(i.left!==i.right&&i.top!==i.bottom)throw new Error(`Zone should be a single column or row: ${$i(i)}`);if(o){const n=$i(i),s=$i(o);return{labelCell:e.getRangeFromSheetXC(t,s),dataRange:e.getRangeFromSheetXC(t,n)}}return{labelCell:void 0,dataRange:e.getRangeFromSheetXC(t,$i(i))}}function Es(e,t){var i;const o=null===(i=t.labelCell)||void 0===i?void 0:i.zone;let n=t.dataRange.zone;if(o){const{numberOfRows:e,numberOfCols:t}=io(n);1===e?n={...n,left:n.left+1}:1===t&&(n={...n,top:n.top+1})}const s=t.dataRange.clone({zone:n});return{label:t.labelCell?e.getRangeString(t.labelCell,"forceSheetReference"):void 0,range:e.getRangeString(s,"forceSheetReference")}}function ws(e,t){let i;if(e.labelRange){const o=ps(zi(e.labelRange),t);i=o?$i(o):void 0}const o=e.dataSets.map(zi).map((e=>ps(e,t))).filter(it).map($i);return{...e,labelRange:i,dataSets:o}}const ys=["rgb(31,119,180)","rgb(255,127,14)","rgb(174,199,232)","rgb(255,187,120)","rgb(44,160,44)","rgb(152,223,138)","rgb(214,39,40)","rgb(255,152,150)","rgb(148,103,189)","rgb(197,176,213)","rgb(140,86,75)","rgb(196,156,148)","rgb(227,119,194)","rgb(247,182,210)","rgb(127,127,127)","rgb(199,199,199)","rgb(188,189,34)","rgb(219,219,141)","rgb(23,190,207)","rgb(158,218,229)"];class xs{constructor(){this.graphColorIndex=0}next(){return ys[this.graphColorIndex++%ys.length]}}function Is(e){return e&&It(e)<.3?"#FFFFFF":"#000000"}function Rs(e){if(e.dataSets){const t=void 0!==e.dataSets.find((e=>!Lt.test(e)));if(t)return 32;if(e.dataSets.map(zi).some((e=>e.top!==e.bottom&&co(e))))return 32}return 0}function Ts(e){if(e.labelRange){if(!Lt.test(e.labelRange||""))return 33}return 0}function As(e,t,i){if(e){if("text"===i||(null==t?void 0:t.type)!==ln.number||e.type!==ln.number)return e.formattedValue;{let o=t.value-e.value;if("percentage"===i&&0!==o&&(o=o/e.value*100),"percentage"!==i&&e.format)return mi(o,e.format);const n=Math.abs(parseFloat(o.toFixed(2))).toLocaleString();return"percentage"===i?n+"%":n}}return""}function Ms(e,t,i,o,n){if("text"===t||(null==e?void 0:e.type)!==ln.number||(null==i?void 0:i.type)!==ln.number)return;const s=i.value-e.value;return s>0?o:s<0?n:void 0}function Os(e,t,i){if("text"===i||(null==e?void 0:e.type)!==ln.number||(null==t?void 0:t.type)!==ln.number)return"neutral";const o=t.value-e.value;return o>0?"up":o<0?"down":"neutral"}const Ns={Errors:{25:s("The range is invalid"),51:s("The argument is missing. Please provide a value"),52:s("The second argument is missing. Please provide a value"),53:s("The minpoint must be a number"),54:s("The midpoint must be a number"),55:s("The maxpoint must be a number"),56:s("The first value must be a number"),57:s("The second value must be a number"),47:s("Minimum must be smaller then Maximum"),50:s("Minimum must be smaller then Midpoint"),49:s("Midpoint must be smaller then Maximum"),48:s("Lower inflection point must be smaller than upper inflection point"),58:s("Invalid Minpoint formula"),60:s("Invalid Maxpoint formula"),59:s("Invalid Midpoint formula"),61:s("Invalid upper inflection point formula"),62:s("Invalid lower inflection point formula"),24:s("A range needs to be defined"),Unexpected:s("The rule is invalid for an unknown reason")},ColorScale:s("Color scale"),IconSet:s("Icon set")},_s={IsEmpty:s("Is empty"),IsNotEmpty:s("Is not empty"),ContainsText:s("Contains"),NotContains:s("Does not contain"),BeginsWith:s("Starts with"),EndsWith:s("Ends with"),Equal:s("Is equal to"),NotEqual:s("Is not equal to"),GreaterThan:s("Is greater than"),GreaterThanOrEqual:s("Is greater than or equal to"),LessThan:s("Is less than"),LessThanOrEqual:s("Is less than or equal to"),Between:s("Is between"),NotBetween:s("Is not between")},Fs={Series:s("Series"),Errors:{Unexpected:s("The chart definition is invalid for an unknown reason"),32:s("The dataset is invalid"),33:s("Labels are invalid"),34:s("The key value is invalid"),35:s("The baseline value is invalid"),36:s("The data range is invalid"),37:s("A minimum range limit value is needed"),38:s("The minimum range limit value must be a number"),39:s("A maximum range limit value is needed"),40:s("The maximum range limit value must be a number"),41:s("Minimum range limit must be smaller than maximum range limit"),42:s("The lower inflection point value must be a number"),43:s("The upper inflection point value must be a number")}},Ds={Automatic:s("Automatic"),Number:s("Number"),Percent:s("Percent"),Currency:s("Currency"),CurrencyRounded:s("Currency rounded"),Date:s("Date"),Time:s("Time"),DateTime:s("Date time"),Duration:s("Duration"),CustomCurrency:s("Custom currency")},ks={Custom:s("Custom")},Ls=s("Merged cells are preventing this operation. Unmerge those cells and try again.");function Ps(e,t){if(t.dataRange){const i=t.labelCell?[$i(t.labelCell.zone)]:[],o=eo([$i(t.dataRange.zone)],i)[0];if(void 0===o)return[];const n=e.getRangeFromSheetXC(t.dataRange.sheetId,o);return e.getRangeValues(n).map((e=>""===e?void 0:e))}return[]}function Us(e,t){const i=He(0,Math.max(e.length,...t.map((e=>{var t;return(null===(t=e.data)||void 0===t?void 0:t.length)||0})))).filter((i=>{const o=e[i],n=t.map((e=>{var t;return null===(t=e.data)||void 0===t?void 0:t[i]}));return o||n.some((e=>0===e||Boolean(e)))}));return{labels:i.map((t=>e[t]||"")),dataSetsValues:t.map((e=>({...e,data:i.map((t=>e.data[t]))})))}}function Vs(e,t){const i=new Set(e),o={};i.forEach((e=>{o[e]=new Array(t.length).fill(0)}));for(const i of He(0,e.length)){const s=e[i];for(const e of He(0,t.length))o[s][e]+="number"==typeof(n=t[e].data[i])?n:0}var n;return{labels:Object.keys(o),dataSetsValues:t.map(((e,t)=>({...e,data:Object.values(o).map((e=>e[t]))})))}}function zs(e){return e?e.length>J?e.substring(0,J)+"…":e:""}function Bs(e,t,i,o){return{type:e.type,options:{responsive:!0,maintainAspectRatio:!1,layout:{padding:{left:20,right:20,top:e.title?10:25,bottom:10}},elements:{line:{fill:!1},point:{hitRadius:15}},animation:{duration:0},hover:{animationDuration:10},responsiveAnimationDuration:0,title:{display:!!e.title,fontSize:22,fontStyle:"normal",text:n(e.title),fontColor:i},legend:{onClick:void 0},tooltips:{callbacks:{label:function(e,t){var i,n,s,r,a;let l=null===(n=null===(i=t.datasets)||void 0===i?void 0:i[e.datasetIndex||0])||void 0===n?void 0:n.label;const c=""!==e.yLabel?e.yLabel:null===(a=null===(r=null===(s=t.datasets)||void 0===s?void 0:s[e.datasetIndex||0])||void 0===r?void 0:r.data)||void 0===a?void 0:a[e.index||0],h=o&&"number"==typeof c?mi(c,o):(null==c?void 0:c.toLocaleString())||"";return l?`${l}: ${h}`:h}}}},data:{labels:t.map(zs),datasets:[]}}}function Hs(e,t,i){let o={values:[],formattedValues:[]};if(i)i.invalidXc||i.invalidSheetName||(o={formattedValues:e.getRangeFormattedValues(i),values:e.getRangeValues(i).map((e=>String(e)))});else if(1===t.length)for(let i=0;i<Ps(e,t[0]).length;i++)o.formattedValues.push(""),o.values.push("");else if(t[0]){o={formattedValues:He(0,Ps(e,t[0]).length).map((e=>e.toString())),values:o.formattedValues}}return o}function $s(e,t){for(const i of t){const t=e.getRangeFormats(i.dataRange).find((e=>void 0!==e&&!Ei(e)));if(t)return t}}function Ws(e,t){const i=[];for(const[o,n]of Object.entries(t)){let t;if(n.labelCell){const i=n.labelCell,s=i?e.getEvaluatedCell({sheetId:i.sheetId,col:i.zone.left,row:i.zone.top}):void 0;t=s&&i?zs(s.formattedValue):t=`${Fs.Series} ${parseInt(o)+1}`}else t=t=`${Fs.Series} ${parseInt(o)+1}`;let s=n.dataRange?Ps(e,n):[];i.push({data:s,label:t})}return i}function Gs(e){return 0===e?"origin":e-1}class qs extends gs{constructor(e,t,i){super(e,t,i),this.type="bar",this.dataSets=Ss(i,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Li(i,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.stacked=e.stacked,this.aggregated=e.aggregated}static transformDefinition(e,t){return ws(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Rs,Ts)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,stacked:!1,aggregated:!1,legendPosition:"top",title:e.title||"",type:"bar",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}copyForSheetId(e){const t=fs(this.sheetId,e,this.dataSets),i=vs(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new qs(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new qs(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,i){return{type:"bar",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,stacked:this.stacked,aggregated:this.aggregated}}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Es(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:us(this.background||w),fontColor:us(Is(this.background)),dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=ms(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new qs(n,this.sheetId,this.getters)}}function Zs(e){return e.dataRange&&!Lt.test(e.dataRange)?36:0}function js(e,t){return t((t=>t.sectionRule?e(t.sectionRule.rangeMin,"rangeMin"):0),(t=>t.sectionRule?e(t.sectionRule.rangeMax,"rangeMax"):0))}function Xs(e){return e.sectionRule&&Number(e.sectionRule.rangeMin)>=Number(e.sectionRule.rangeMax)?41:0}function Ys(e,t){if(""===e)switch(t){case"rangeMin":return 37;case"rangeMax":return 39}return 0}function Ks(e,t){if(isNaN(e))switch(t){case"rangeMin":return 38;case"rangeMax":return 40;case"lowerInflectionPointValue":return 42;case"upperInflectionPointValue":return 43}return 0}class Qs extends gs{constructor(e,t,i){super(e,t,i),this.type="gauge",this.dataRange=Li(this.getters,this.sheetId,e.dataRange),this.sectionRule=e.sectionRule,this.background=e.background}static validateChartDefinition(e,t){return e.checkValidations(t,Zs,e.chainValidations(js(Ys,e.batchValidations),js(Ks,e.batchValidations),Xs),e.chainValidations((i=Ks,(0,e.batchValidations)((e=>e.sectionRule?i(e.sectionRule.lowerInflectionPoint.value,"lowerInflectionPointValue"):0),(e=>e.sectionRule?i(e.sectionRule.upperInflectionPoint.value,"upperInflectionPointValue"):0)))));var i}static transformDefinition(e,t){let i;return e.dataRange&&(i=ps(zi(e.dataRange),t)),{...e,dataRange:i?$i(i):void 0}}static getDefinitionFromContextCreation(e){return{background:e.background,title:e.title||"",type:"gauge",dataRange:e.range?e.range[0]:void 0,sectionRule:{colors:{lowerColor:"#cc0000",middleColor:"#f1c232",upperColor:"#6aa84f"},rangeMin:"0",rangeMax:"100",lowerInflectionPoint:{type:"percentage",value:"15"},upperInflectionPoint:{type:"percentage",value:"40"}}}}copyForSheetId(e){const t=vs(this.sheetId,e,this.dataRange),i=this.getDefinitionWithSpecificRanges(t,e);return new Qs(i,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.dataRange,e);return new Qs(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.dataRange)}getDefinitionWithSpecificRanges(e,t){return{background:this.background,sectionRule:this.sectionRule,title:this.title,type:"gauge",dataRange:e?this.getters.getRangeString(e,t||this.sheetId):void 0}}getDefinitionForExcel(){}getContextCreation(){return{background:this.background,title:this.title,range:this.dataRange?[this.getters.getRangeString(this.dataRange,this.sheetId)]:void 0}}updateRanges(e){const t=bs(this.dataRange,e);if(this.dataRange===t)return this;const i=this.getDefinitionWithSpecificRanges(t);return new Qs(i,this.sheetId,this.getters)}}const Js={second:1e3,minute:6e4,hour:36e5,day:864e5,month:2592e6,year:31536e6},er={inSeconds:function(e){return Math.floor(e/Js.second)},inMinutes:function(e){return Math.floor(e/Js.minute)},inHours:function(e){return Math.floor(e/Js.hour)},inDays:function(e){return Math.floor(e/Js.day)},inMonths:function(e){return Math.floor(e/Js.month)},inYears:function(e){return Math.floor(e/Js.year)}},tr=/^((d|dd|m|mm|yyyy|yy|hh|h|ss|a)(-|:|\s|\/))*(d|dd|m|mm|yyyy|yy|hh|h|ss|a)$/i;function ir(e,t){const i=function(e){const t=(e=(e=e.replace(/y/g,"Y")).replace(/d/g,"D")).indexOf("h");e=t>=0?e.slice(0,t).replace(/m/g,"M")+e.slice(t):e.replace(/m/g,"M");e.includes("a")||(e=e.replace(/h/g,"H"));return e}(t),o=function(e,t){const i=e.map((e=>{var t;return null===(t=Ee(e))||void 0===t?void 0:t.jsDate}));if(i.some((e=>void 0===e))||e.length<2)return;const o=i.map((e=>e.getTime())),n=Math.max(...o)-Math.min(...o),s=function(e){if(e.includes("s"))return"second";if(e.includes("m"))return"minute";if(e.includes("h")||e.includes("H"))return"hour";if(e.includes("D"))return"day";if(e.includes("M"))return"month";return"year"}(t);if(Js.second>=Js[s]&&er.inSeconds(n)<180)return"second";if(Js.minute>=Js[s]&&er.inMinutes(n)<180)return"minute";if(Js.hour>=Js[s]&&er.inHours(n)<96)return"hour";if(Js.day>=Js[s]&&er.inDays(n)<90)return"day";if(Js.month>=Js[s]&&er.inMonths(n)<36)return"month";return"year"}(e,i),n={};return o&&(n[o]=i),{parser:i,displayFormats:n,unit:o}}class or extends gs{constructor(e,t,i){super(e,t,i),this.type="line",this.dataSets=Ss(this.getters,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Li(this.getters,t,e.labelRange),this.background=e.background,this.verticalAxisPosition=e.verticalAxisPosition,this.legendPosition=e.legendPosition,this.labelsAsText=e.labelsAsText,this.stacked=e.stacked,this.aggregated=e.aggregated,this.cumulative=e.cumulative}static validateChartDefinition(e,t){return e.checkValidations(t,Rs,Ts)}static transformDefinition(e,t){return ws(e,t)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,labelsAsText:!1,legendPosition:"top",title:e.title||"",type:"line",verticalAxisPosition:"left",labelRange:e.auxiliaryRange||void 0,stacked:!1,aggregated:!1,cumulative:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getDefinitionWithSpecificDataSets(e,t,i){return{type:"line",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,verticalAxisPosition:this.verticalAxisPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,labelsAsText:this.labelsAsText,stacked:this.stacked,aggregated:this.aggregated,cumulative:this.cumulative}}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=ms(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new or(n,this.sheetId,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Es(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:us(this.background||w),fontColor:us(Is(this.background)),dataSets:e}}copyForSheetId(e){const t=fs(this.sheetId,e,this.dataSets),i=vs(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new or(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new or(t,e,this.getters)}}function nr(e,t){return rr(e,t)||ar(e,t)}function sr(e,t){return function(e,t){return!e.labelsAsText&&rr(e.labelRange,t)}(e,t)?"time":function(e,t){return!e.labelsAsText&&ar(e.labelRange,t)}(e,t)?"linear":"category"}function rr(e,t){if(!e||!ar(e,t))return!1;const i=t.getEvaluatedCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}).format;return Boolean(i&&tr.test(i))}function ar(e,t){if(!e)return!1;const i=t.getRangeValues(e);return!i.some((e=>isNaN(Number(e))&&e))&&!i.every((e=>!e))}class lr extends gs{constructor(e,t,i){super(e,t,i),this.type="pie",this.dataSets=Ss(i,e.dataSets,t,e.dataSetsHaveTitle),this.labelRange=Li(i,t,e.labelRange),this.background=e.background,this.legendPosition=e.legendPosition,this.aggregated=e.aggregated}static transformDefinition(e,t){return ws(e,t)}static validateChartDefinition(e,t){return e.checkValidations(t,Rs,Ts)}static getDefinitionFromContextCreation(e){return{background:e.background,dataSets:e.range?e.range:[],dataSetsHaveTitle:!1,legendPosition:"top",title:e.title||"",type:"pie",labelRange:e.auxiliaryRange||void 0,aggregated:!1}}getDefinition(){return this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange)}getContextCreation(){return{background:this.background,title:this.title,range:this.dataSets.map((e=>this.getters.getRangeString(e.dataRange,this.sheetId))),auxiliaryRange:this.labelRange?this.getters.getRangeString(this.labelRange,this.sheetId):void 0}}getDefinitionWithSpecificDataSets(e,t,i){return{type:"pie",dataSetsHaveTitle:!!e.length&&Boolean(e[0].labelCell),background:this.background,dataSets:e.map((e=>this.getters.getRangeString(e.dataRange,i||this.sheetId))),legendPosition:this.legendPosition,labelRange:t?this.getters.getRangeString(t,i||this.sheetId):void 0,title:this.title,aggregated:this.aggregated}}copyForSheetId(e){const t=fs(this.sheetId,e,this.dataSets),i=vs(this.sheetId,e,this.labelRange),o=this.getDefinitionWithSpecificDataSets(t,i,e);return new lr(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificDataSets(this.dataSets,this.labelRange,e);return new lr(t,e,this.getters)}getDefinitionForExcel(){if(this.aggregated)return;const e=this.dataSets.map((e=>Es(this.getters,e))).filter((e=>""!==e.range));return{...this.getDefinition(),backgroundColor:us(this.background||w),fontColor:us(Is(this.background)),verticalAxisPosition:"left",dataSets:e}}updateRanges(e){const{dataSets:t,labelRange:i,isStale:o}=ms(this.getters,e,this.dataSets,this.labelRange);if(!o)return this;const n=this.getDefinitionWithSpecificDataSets(t,i);return new lr(n,this.sheetId,this.getters)}}function cr(e,t){const i=[],o=Math.max(...t.map((e=>e.data.length)));for(let t=0;t<=o;t++)i.push(e.next());return i}function hr(e){return e.keyValue&&!Lt.test(e.keyValue)?34:0}function dr(e){return e.baseline&&!Lt.test(e.baseline)?35:0}class ur extends gs{constructor(e,t,i){super(e,t,i),this.type="scorecard",this.keyValue=Li(i,t,e.keyValue),this.baseline=Li(i,t,e.baseline),this.baselineMode=e.baselineMode,this.baselineDescr=e.baselineDescr,this.background=e.background,this.baselineColorUp=e.baselineColorUp,this.baselineColorDown=e.baselineColorDown}static validateChartDefinition(e,t){return e.checkValidations(t,hr,dr)}static getDefinitionFromContextCreation(e){return{background:e.background,type:"scorecard",keyValue:e.range?e.range[0]:void 0,title:e.title||"",baselineMode:te,baselineColorUp:ie,baselineColorDown:oe,baseline:e.auxiliaryRange||""}}static transformDefinition(e,t){let i,o;return e.baseline&&(i=ps(zi(e.baseline),t)),e.keyValue&&(o=ps(zi(e.keyValue),t)),{...e,baseline:i?$i(i):void 0,keyValue:o?$i(o):void 0}}copyForSheetId(e){const t=vs(this.sheetId,e,this.baseline),i=vs(this.sheetId,e,this.keyValue),o=this.getDefinitionWithSpecificRanges(t,i,e);return new ur(o,e,this.getters)}copyInSheetId(e){const t=this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue,e);return new ur(t,e,this.getters)}getDefinition(){return this.getDefinitionWithSpecificRanges(this.baseline,this.keyValue)}getContextCreation(){return{background:this.background,title:this.title,range:this.keyValue?[this.getters.getRangeString(this.keyValue,this.sheetId)]:void 0,auxiliaryRange:this.baseline?this.getters.getRangeString(this.baseline,this.sheetId):void 0}}getDefinitionWithSpecificRanges(e,t,i){return{baselineColorDown:this.baselineColorDown,baselineColorUp:this.baselineColorUp,baselineMode:this.baselineMode,title:this.title,type:"scorecard",background:this.background,baseline:e?this.getters.getRangeString(e,i||this.sheetId):void 0,baselineDescr:this.baselineDescr,keyValue:t?this.getters.getRangeString(t,i||this.sheetId):void 0}}getDefinitionForExcel(){}updateRanges(e){const t=bs(this.baseline,e),i=bs(this.keyValue,e);if(this.baseline===t&&this.keyValue===i)return this;const o=this.getDefinitionWithSpecificRanges(t,i);return new ur(o,this.sheetId,this.getters)}}const gr=new Io;gr.add("bar",{match:e=>"bar"===e,createChart:(e,t,i)=>new qs(e,t,i),getChartRuntime:function(e,t){let i=Hs(t,e.dataSets,e.labelRange).formattedValues,o=Ws(t,e.dataSets);({labels:i,dataSetsValues:o}=Us(i,o)),e.aggregated&&({labels:i,dataSetsValues:o}=Vs(i,o));const n=function(e,t,i){var o;const n=Is(e.background),s=Bs(e,t,n,i),r={labels:{fontColor:n}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:n}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:n,beginAtZero:!0,callback:e=>i?mi(e,i):(null==e?void 0:e.toLocaleString())||e}}]},e.stacked&&(s.options.scales.xAxes[0].stacked=!0,s.options.scales.yAxes[0].stacked=!0),s}(e,i,$s(t,e.dataSets)),s=new xs;for(let{label:e,data:t}of o){const i=s.next(),o={label:e,data:t,borderColor:i,backgroundColor:i};n.data.datasets.push(o)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>qs.validateChartDefinition(e,t),transformDefinition:(e,t)=>qs.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>qs.getDefinitionFromContextCreation(e),name:s("Bar"),sequence:10}),gr.add("line",{match:e=>"line"===e,createChart:(e,t,i)=>new or(e,t,i),getChartRuntime:function(e,t){const i=sr(e,t),o=Hs(t,e.dataSets,e.labelRange);let n="linear"===i?o.values:o.formattedValues,s=Ws(t,e.dataSets);({labels:n,dataSetsValues:s}=Us(n,s)),"time"===i&&({labels:n,dataSetsValues:s}=function(e,t){if(0===e.length||e.every((e=>!e)))return{labels:e,dataSetsValues:t};const i=[...e],o=_e(t);for(let e=0;e<i.length;e++)if(!i[e]){i[e]=at(i,e);for(let t of o)t.data[e]=void 0}return{labels:i,dataSetsValues:o}}(n,s)),e.aggregated&&({labels:n,dataSetsValues:s}=Vs(n,s));const r=$s(t,e.dataSets),a=function(e,t,i){var o;const n=Is(e.background),s=Bs(e,t,n,i),r={labels:{fontColor:n,generateLabels(e){const{data:t}=e,i=window.Chart.defaults.global.legend.labels.generateLabels(e);for(const[e,o]of i.entries())o.fillStyle=t.datasets[e].borderColor;return i}}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.scales={xAxes:[{ticks:{maxRotation:60,minRotation:15,padding:5,labelOffset:2,fontColor:n}}],yAxes:[{position:e.verticalAxisPosition,ticks:{fontColor:n,beginAtZero:!0,callback:e=>i?mi(e,i):(null==e?void 0:e.toLocaleString())||e}}]},e.stacked&&(s.options.scales.yAxes[0].stacked=!0),s}(e,n,r),l=function(e,t){if(t)return e.getEvaluatedCell({sheetId:t.sheetId,col:t.zone.left,row:t.zone.top}).format}(t,e.labelRange);"time"===i?(a.options.scales.xAxes[0].type="time",a.options.scales.xAxes[0].time=ir(n,l),a.options.scales.xAxes[0].ticks.maxTicksLimit=15):"linear"===i&&(a.options.scales.xAxes[0].type="linear",a.options.scales.xAxes[0].ticks.callback=e=>mi(e,l),a.options.tooltips.callbacks.title=e=>{var t;return mi((null===(t=e[0])||void 0===t?void 0:t.xLabel)||"",l)});const c=new xs;for(let[t,{label:o,data:r}]of s.entries()){["linear","time"].includes(i)&&(r=r.map(((e,t)=>({x:n[t]||void 0,y:e}))));const s=c.next();let l=Tt(s);if(e.stacked&&(l.a=ne),e.cumulative){let e=0;r=r.map((t=>isNaN(t)?t:(e+=parseFloat(t),e)))}const h={label:o,data:r,lineTension:0,borderColor:s,backgroundColor:Rt(l),pointBackgroundColor:s,fill:!!e.stacked&&Gs(t)};a.data.datasets.push(h)}return{chartJsConfig:a,background:e.background||w}},validateChartDefinition:(e,t)=>or.validateChartDefinition(e,t),transformDefinition:(e,t)=>or.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>or.getDefinitionFromContextCreation(e),name:s("Line"),sequence:20}),gr.add("pie",{match:e=>"pie"===e,createChart:(e,t,i)=>new lr(e,t,i),getChartRuntime:function(e,t){let i=Hs(t,e.dataSets,e.labelRange).formattedValues,o=Ws(t,e.dataSets);({labels:i,dataSetsValues:o}=Us(i,o)),e.aggregated&&({labels:i,dataSetsValues:o}=Vs(i,o));const n=function(e,t,i){var o;const n=Is(e.background),s=Bs(e,t,n,i),r={labels:{fontColor:n}};return!e.labelRange&&1===e.dataSets.length||"none"===e.legendPosition?r.display=!1:r.position=e.legendPosition,s.options.legend={...null===(o=s.options)||void 0===o?void 0:o.legend,...r},s.options.layout={padding:{left:20,right:20,top:e.title?10:25,bottom:10}},s.options.tooltips.callbacks.title=function(e,t){return t.datasets[e[0].datasetIndex].label},s}(e,i,$s(t,e.dataSets)),s=new xs;for(let{label:e,data:t}of o){const i={label:e,data:t,borderColor:"#FFFFFF",backgroundColor:cr(s,o)};n.data.datasets.push(i)}return{chartJsConfig:n,background:e.background||w}},validateChartDefinition:(e,t)=>lr.validateChartDefinition(e,t),transformDefinition:(e,t)=>lr.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>lr.getDefinitionFromContextCreation(e),name:s("Pie"),sequence:30}),gr.add("scorecard",{match:e=>"scorecard"===e,createChart:(e,t,i)=>new ur(e,t,i),getChartRuntime:function(e,t){let i,o,s="",r="";if(e.keyValue){const o={sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top};i=t.getEvaluatedCell(o),s=String(i.value),r=i.formattedValue}const a=e.baseline;if(a){const i={sheetId:e.baseline.sheetId,col:e.baseline.zone.left,row:e.baseline.zone.top};o=t.getEvaluatedCell(i)}const{background:l,fontColor:c}=t.getStyleOfSingleCellChart(e.background,e.keyValue);return{title:n(e.title),keyValue:r||s,baselineDisplay:As(o,i,e.baselineMode),baselineArrow:Os(o,i,e.baselineMode),baselineColor:Ms(o,e.baselineMode,i,e.baselineColorUp,e.baselineColorDown),baselineDescr:e.baselineDescr?n(e.baselineDescr):"",fontColor:c,background:l,baselineStyle:"percentage"!==e.baselineMode&&a?t.getCellStyle({sheetId:a.sheetId,col:a.zone.left,row:a.zone.top}):void 0,keyValueStyle:e.keyValue?t.getCellStyle({sheetId:e.keyValue.sheetId,col:e.keyValue.zone.left,row:e.keyValue.zone.top}):void 0}},validateChartDefinition:(e,t)=>ur.validateChartDefinition(e,t),transformDefinition:(e,t)=>ur.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>ur.getDefinitionFromContextCreation(e),name:s("Scorecard"),sequence:40}),gr.add("gauge",{match:e=>"gauge"===e,createChart:(e,t,i)=>new Qs(e,t,i),getChartRuntime:function(e,t){const i=function(e){const t=Bs(e,[],Is(e.background));return t.options.hover=void 0,t.options.events=[],t.options.layout={padding:{left:30,right:30,top:e.title?10:25,bottom:25}},t.options.needle={radiusPercentage:2,widthPercentage:3.2,lengthPercentage:80,color:"#000000"},t.options.valueLabel={display:!1,formatter:null,color:"#FFFFFF",backgroundColor:"#000000",fontSize:30,borderRadius:5,padding:{top:5,right:5,bottom:5,left:5},bottomMarginPercentage:5},t}(e),o=e.sectionRule.colors,n=e.sectionRule.lowerInflectionPoint,s=e.sectionRule.upperInflectionPoint,r=Number(n.value),a=Number(s.value),l=Number(e.sectionRule.rangeMin),c=Number(e.sectionRule.rangeMax),h=c-l,d=[];if(""!==n.value){const e="number"===n.type?r:l+h*r/100;d.push({value:ke(e,l,c),color:o.lowerColor})}if(""!==s.value){const e="number"===s.type?a:l+h*a/100;d.push({value:ke(e,l,c),color:o.middleColor})}const u=[],g=[];d.sort(((e,t)=>e.value-t.value)).map((e=>{u.push(e.value),g.push(e.color)})),u.push(c),g.push(o.upperColor);const p=e.dataRange,m=h/30;let f=l-m,v=null,b=!1;if(void 0!==p){const e=t.getEvaluatedCell({sheetId:p.sheetId,col:p.zone.left,row:p.zone.top});e.type===ln.number&&(f=ke(e.value,l-m,c+m),v=()=>t.getRangeFormattedValues(p)[0],b=!0)}return i.options.valueLabel.display=b,i.options.valueLabel.formatter=v,i.data.datasets.push({data:u,minValue:Number(e.sectionRule.rangeMin),value:f,backgroundColor:g}),{chartJsConfig:i,background:t.getStyleOfSingleCellChart(e.background,p).background}},validateChartDefinition:(e,t)=>Qs.validateChartDefinition(e,t),transformDefinition:(e,t)=>Qs.transformDefinition(e,t),getChartDefinitionFromContextCreation:e=>Qs.getDefinitionFromContextCreation(e),name:s("Gauge"),sequence:50});const pr=new Io;pr.add("line",go),pr.add("bar",go),pr.add("pie",go),pr.add("gauge",go),pr.add("scorecard",wo);const mr=new Io;fo`
|
|
345
345
|
.o-chart-container {
|
|
346
346
|
width: 100%;
|
|
347
347
|
height: 100%;
|
|
348
348
|
position: relative;
|
|
349
349
|
}
|
|
350
|
-
`;class pr extends t.Component{get chartType(){return this.env.model.getters.getChartType(this.props.figure.id)}get chartComponent(){const e=this.chartType,t=ur.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}pr.template="o-spreadsheet-ChartFigure",pr.components={},pr.props={figure:Object,onFigureDeleted:Function};class mr extends t.Component{get figureId(){return this.props.figure.id}get getImagePath(){return this.env.model.getters.getImagePath(this.figureId)}}function fr(e,t){const i=_e(t),o=e.getSheetViewDimension(),n=o.width,s=o.height;if(i.width>n){const e=n/i.width;i.width=n,i.height=i.height*e}if(i.height>s){const e=s/i.height;i.height=s,i.width=i.width*e}return i}mr.template="o-spreadsheet-ImageFigure",mr.components={},mr.props={figure:Object,onFigureDeleted:Function};const vr=new Io;function br(e,t){return{id:"copy",name:s("Copy"),sequence:2,description:"Ctrl+C",action:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("COPY"),await t.clipboard.write(t.model.getters.getClipboardContent())}}}function Sr(e,t){return{id:"cut",name:s("Cut"),sequence:3,description:"Ctrl+X",action:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("CUT"),await t.clipboard.write(t.model.getters.getClipboardContent())}}}function Cr(e,t,i){return{id:"delete",name:s("Delete"),sequence:10,action:()=>{i.model.dispatch("DELETE_FIGURE",{sheetId:i.model.getters.getActiveSheetId(),id:e}),t()}}}vr.add("chart",{Component:pr,SidePanelComponent:"ChartPanel",menuBuilder:function(e,t,i){return is([{id:"edit",name:s("Edit"),sequence:1,action:()=>{i.model.dispatch("SELECT_FIGURE",{id:e}),i.openSidePanel("ChartPanel")}},br(e,i),Sr(e,i),Cr(e,t,i)])}}),vr.add("image",{Component:mr,keepRatio:!0,minFigSize:20,borderWidth:0,menuBuilder:function(e,t,i){return is([br(e,i),Sr(e,i),{id:"reset_size",name:s("Reset size"),sequence:4,action:()=>{const t=i.model.getters.getImageSize(e),{height:o,width:n}=fr(i.model.getters,t);i.model.dispatch("UPDATE_FIGURE",{sheetId:i.model.getters.getActiveSheetId(),id:e,height:o,width:n})}},Cr(e,t,i)])}});const Er=(new Io).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let i=e.base;"after"===e.position&&i++;for(let o=0;o<e.quantity;o++)t.push(o+i);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],i=[...e.elements].sort(((e,t)=>e-t));for(let o of $e(i)){const i=0===o[0]?0:o[0]-1,n=0===o[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:o.length,base:i,sheetId:e.sheetId,position:n})}return t})).add("ADD_MERGE",(function(e){return[{type:"REMOVE_MERGE",sheetId:e.sheetId,target:e.target}]})).add("REMOVE_MERGE",(function(e){return[{type:"ADD_MERGE",sheetId:e.sheetId,target:e.target}]})).add("CREATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetId}]})).add("DELETE_SHEET",(function(e){return[{type:"CREATE_SHEET",sheetId:e.sheetId,position:1}]})).add("DUPLICATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetIdTo}]})).add("CREATE_FIGURE",(function(e){return[{type:"DELETE_FIGURE",id:e.figure.id,sheetId:e.sheetId}]})).add("CREATE_CHART",(function(e){return[{type:"DELETE_FIGURE",id:e.id,sheetId:e.sheetId}]})).add("HIDE_COLUMNS_ROWS",(function(e){return[{type:"UNHIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]})).add("UNHIDE_COLUMNS_ROWS",(function(e){return[{type:"HIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}));for(const e of gn.values())Er.contains(e)||Er.add(e,wr);function wr(e){return[e]}function yr(e,t){const i=dr.getAll().find((t=>t.match(e.type)));if(!i)throw new Error("Unknown chart type.");return i.transformDefinition(e,t)}function xr(e,t){var i;let o=e;e.left!==e.right&&(o={...e,left:e.left+1});const s=[$i(o)],r=t.getActiveSheetId(),a=t.getCell({sheetId:r,col:e.left,row:e.top});if(1===ho(e)&&(null==a?void 0:a.content))return{type:"scorecard",title:"",background:(null===(i=a.style)||void 0===i?void 0:i.fillColor)||void 0,keyValue:$i(e),baselineMode:te,baselineColorUp:ie,baselineColorDown:oe};let l="";const c=t.getEvaluatedCellsInZone(r,{...o,bottom:o.top}),h=!!c.find((e=>e.type!==ln.empty&&e.type!==ln.number));if(h){const e=c.filter((e=>e.type!==ln.error&&e.type!==ln.empty)).map((e=>e.formattedValue)),t=e.splice(-1)[0];l=e.join(", "),t&&(l+=(l?" "+n("and")+" ":"")+t)}let d;e.left!==e.right&&(d=$i({...e,right:e.left,top:h?e.top+1:e.top}));const u=o.right===o.left?"none":"top";return ir(d?t.getRangeFromSheetXC(r,d):void 0,t)?{title:l,dataSets:s,labelsAsText:!1,stacked:!1,aggregated:!1,cumulative:!1,labelRange:d,type:"line",dataSetsHaveTitle:h,verticalAxisPosition:"left",legendPosition:u}:{title:l,dataSets:s,labelRange:d,type:"bar",stacked:!1,aggregated:!1,dataSetsHaveTitle:h,verticalAxisPosition:"left",legendPosition:u}}const Ir=[ln.number,ln.error,ln.text,ln.boolean];function Rr(e,t,i,o,n){let r=mn.Success,a=o.right>o.left;if(e.model.getters.doesIntersectMerge(t,o)){let i;a=!1;for(let n=o.top;n<=o.bottom;n++){i=[];for(let s=o.left;s<=o.right;s++){let o=e.model.getters.getMerge({sheetId:t,col:s,row:n});o&&!i.includes(o.id.toString())&&i.push(o.id.toString())}if(i.length>=2){a=!0;break}}}const{col:l,row:c}=i;if(a)r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n});else{const i=e.model.getters.getContiguousZone(t,o);Yi(i,o)?r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n}):e.askConfirmation(s("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>{o=i,r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n})}),(()=>{r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n})}))}if(r.isCancelledBecause(63)){const{col:t,row:n}=i;e.model.selection.selectZone({cell:{col:t,row:n},zone:o}),e.raiseError(s("Cannot sort. To sort, select only cells or only merges that have the same size."))}}function Tr(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(19)&&e.raiseError(s("This operation is not allowed with multiple selections."))}const Ar={filterOverlap:s("You cannot create overlapping filters."),nonContinuousTargets:s("A filter can only be created on a continuous selection."),mergeInFilter:s("You can't create a filter over a range that contains a merge.")};function Mr(e,t,i){const o=e.model.dispatch("CREATE_FILTER_TABLE",{target:i,sheetId:t});o.isCancelledBecause(78)?e.raiseError(Ar.filterOverlap):o.isCancelledBecause(80)?e.raiseError(Ar.mergeInFilter):o.isCancelledBecause(81)&&e.raiseError(Ar.nonContinuousTargets)}const Or={wrongPasteSelection:s("This operation is not allowed with multiple selections."),willRemoveExistingMerge:s("This operation is not possible due to a merge. Please remove the merges first than try again."),wrongFigurePasteOption:s("Cannot do a special paste of a figure."),frozenPaneOverlap:s("Cannot paste merged cells over a frozen pane.")};function Nr(e,t){t.isSuccessful||(t.reasons.includes(20)?e.raiseError(Or.wrongPasteSelection):t.reasons.includes(2)?e.raiseError(Or.willRemoveExistingMerge):t.reasons.includes(22)?e.raiseError(Or.wrongFigurePasteOption):t.reasons.includes(75)&&e.raiseError(Or.frozenPaneOverlap))}function _r(e,t,i){const o=e.model.dispatch("PASTE",{target:t,pasteOption:i});Nr(e,o)}function Fr(e,t,i){const o=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:i});Nr(e,o)}function Dr(e){const t=e.model.getters.getActiveCols();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.right-t.left+1}}function kr(e){const t=e.model.getters.getActiveRows();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function Lr(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function Pr(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}const Ur=async e=>{e.model.dispatch("COPY"),await e.clipboard.write(e.model.getters.getClipboardContent())},Vr=async e=>{Tr(e),await e.clipboard.write(e.model.getters.getClipboardContent())},zr=async e=>Hr(e),Br=async e=>Hr(e,"onlyValue");async function Hr(e,t){const i=e.model.getters.getClipboardTextContent(),o=await e.clipboard.readText();switch(o.status){case"ok":const n=e.model.getters.getSelectedZones();o&&o.content!==i?Fr(e,n,o.content):_r(e,n,t);break;case"notImplemented":e.raiseError(s("Pasting from the context menu is not supported in this browser. Use keyboard shortcuts ctrl+c / ctrl+v instead."));break;case"permissionDenied":e.raiseError(s("Access to the clipboard denied by the browser. Please enable clipboard permission for this page in your browser settings."))}}const $r=e=>_r(e,e.model.getters.getSelectedZones(),"onlyFormat"),Wr=e=>!e.model.getters.isCutOperation(),Gr=e=>{if(e.model.getters.getSelectedZones().length>1)return s("Delete rows");let t,i;const o=e.model.getters.getActiveRows();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.top,i=o.bottom}return t===i?s("Delete row %s",(t+1).toString()):s("Delete rows %s - %s",(t+1).toString(),(i+1).toString())},qr=e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const i=e.model.getters.getSelectedZones()[0];for(let e=i.top;e<=i.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},Zr=(e,t)=>{const i=t.model.getters.getActiveSheetId(),o=t.model.getters.getElementsFromSelection(e),n=t.model.getters.checkElementsIncludeAllVisibleHeaders(i,e,o),s=t.model.getters.checkElementsIncludeAllNonFrozenHeaders(i,e,o);return!n&&!s},jr=e=>{if(e.model.getters.getSelectedZones().length>1)return s("Delete columns");let t,i;const o=e.model.getters.getActiveCols();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.left,i=o.right}return t===i?s("Delete column %s",$t(t)):s("Delete columns %s - %s",$t(t),$t(i))},Xr=e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const i=e.model.getters.getSelectedZones()[0];for(let e=i.left;e<=i.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},Yr=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});Nr(e,i)},Kr=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});Nr(e,i)},Qr=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});Nr(e,i)},Jr=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});Nr(e,i)},ea=e=>{const t=e.model.getters.getActiveRows();let i,o;if(t.size)i=Math.min(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.top,o=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:i,quantity:o,dimension:"ROW"})},ta=e=>{const t=e.model.getters.getActiveRows();let i,o;if(t.size)i=Math.max(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.bottom,o=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:i,quantity:o,dimension:"ROW"})},ia=e=>{const t=e.model.getters.getActiveCols();let i,o;if(t.size)i=Math.min(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.left,o=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:i,quantity:o})},oa=e=>{const t=e.model.getters.getActiveCols();let i,o;if(t.size)i=Math.max(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.right,o=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:i,quantity:o})};const na=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},sa=e=>{let{col:t,row:i}=e.model.getters.getActivePosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:i,popoverType:"LinkEditor"})},ra=e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,i)},aa=e=>{const{anchor:t,zones:i}=e.model.getters.getSelection(),o=e.model.getters.getActiveSheetId();Rr(e,o,t.cell,i[0],"ascending")},la=e=>{const{anchor:t,zones:i}=e.model.getters.getSelection(),o=e.model.getters.getActiveSheetId();Rr(e,o,t.cell,i[0],"descending")},ca=e=>1===e.model.getters.getSelectedZones().length,ha=new ss;ha.add("cut",{name:s("Cut"),description:"Ctrl+X",sequence:10,action:Vr}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Ur}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:zr}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:Wr}).addChild("paste_value_only",["paste_special"],{name:s("Paste values only"),sequence:10,action:Br}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:$r}).add("add_row_before",{name:e=>{const t=kr(e);return 1===t?s("Insert row"):s("Insert %s rows",t.toString())},sequence:70,action:ea,isVisible:ca}).add("add_column_before",{name:e=>{const t=Dr(e);return 1===t?s("Insert column"):s("Insert %s columns",t.toString())},sequence:90,action:ia,isVisible:ca}).add("insert_cell",{name:s("Insert cells"),sequence:100,isVisible:ca,separator:!0}).addChild("insert_cell_down",["insert_cell"],{name:s("Shift down"),sequence:10,action:Yr}).addChild("insert_cell_right",["insert_cell"],{name:s("Shift right"),sequence:20,action:Kr}).add("delete_row",{name:Gr,sequence:110,action:qr,isVisible:ca}).add("delete_column",{name:jr,sequence:120,action:Xr,isVisible:ca}).add("delete_cell",{name:s("Delete cells"),sequence:130,isVisible:ca}).addChild("delete_cell_up",["delete_cell"],{name:s("Shift up"),sequence:10,action:Qr}).addChild("delete_cell_down",["delete_cell"],{name:s("Shift left"),sequence:20,action:Jr}).add("insert_link",{name:s("Insert link"),separator:!0,sequence:150,action:sa});const da=new ss;da.add("cut",{name:s("Cut"),description:"Ctrl+X",sequence:10,action:Vr}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Ur}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:zr}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:Wr}).addChild("paste_value_only",["paste_special"],{name:s("Paste value only"),sequence:10,action:Br}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:$r}).add("sort_columns",{name:e=>e.model.getters.getActiveCols().size>1?s("Sort columns"):s("Sort column"),sequence:50,isVisible:ca,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:s("Ascending (A ⟶ Z)"),sequence:10,action:aa}).addChild("sort_descending",["sort_columns"],{name:s("Descending (Z ⟶ A)"),sequence:20,action:la}).add("add_column_before",{name:e=>{const t=Dr(e);return 1===t?s("Insert column left"):s("Insert %s columns left",t.toString())},sequence:70,action:ia}).add("add_column_after",{name:e=>{const t=Dr(e);return 1===t?s("Insert column right"):s("Insert %s columns right",t.toString())},sequence:80,action:oa}).add("delete_column",{name:jr,sequence:90,action:Xr,isVisible:e=>Zr("COL",e)}).add("clear_column",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return s("Clear columns");let t,i;const o=e.model.getters.getActiveCols();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.left,i=o.right}return t===i?s("Clear column %s",$t(t)):s("Clear columns %s - %s",$t(t),$t(i))},sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId(),i=[...e.model.getters.getActiveCols()].map((i=>e.model.getters.getColsZone(t,i,i)));e.model.dispatch("DELETE_CONTENT",{target:i,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_columns",{name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let i=t[0],o=t[t.length-1];return 1===t.length?s("Hide column %s",$t(i).toString()):o-i+1===t.length?s("Hide columns %s - %s",$t(i).toString(),$t(o).toString()):s("Hide columns")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getElementsFromSelection("COL");return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,"COL",i)},separator:!0}).add("unhide_columns",{name:s("Unhide columns"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("COL").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:s("Conditional formatting"),sequence:110,action:na});const ua=new ss;ua.add("cut",{name:s("Cut"),sequence:10,description:"Ctrl+X",action:Vr}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:Ur}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:zr}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:Wr}).addChild("paste_value_only",["paste_special"],{name:s("Paste value only"),sequence:10,action:Br}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:$r}).add("add_row_before",{name:e=>{const t=kr(e);return 1===t?s("Insert row above"):s("Insert %s rows above",t.toString())},sequence:50,action:ea}).add("add_row_after",{name:e=>{const t=kr(e);return 1===t?s("Insert row below"):s("Insert %s rows below",t.toString())},sequence:60,action:ta}).add("delete_row",{name:Gr,sequence:70,action:qr,isVisible:e=>Zr("ROW",e)}).add("clear_row",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return s("Clear rows");let t,i;const o=e.model.getters.getActiveRows();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.top,i=o.bottom}return t===i?s("Clear row %s",(t+1).toString()):s("Clear rows %s - %s",(t+1).toString(),(i+1).toString())},sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),i=[...e.model.getters.getActiveRows()].map((i=>e.model.getters.getRowsZone(t,i,i)));e.model.dispatch("DELETE_CONTENT",{target:i,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_rows",{name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let i=t[0],o=t[t.length-1];return 1===t.length?s("Hide row %s",(i+1).toString()):o-i+1===t.length?s("Hide rows %s - %s",(i+1).toString(),(o+1).toString()):s("Hide rows")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getElementsFromSelection("ROW");return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,"ROW",i)},separator:!0}).add("unhide_rows",{name:s("Unhide rows"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("ROW").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:s("Conditional formatting"),sequence:90,action:na});const ga=/(.*?)\((.*?)\)(.*)/,pa=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function ma(e,t=""){return function(e){let t,i=e.match(ga),o=i[1].trim(),n=[],s=!1,r=!1,a=!1;for(let e of i[2].split(",")){const i=e.trim().toUpperCase();let o=pa.find((e=>i===e));o?n.push(o):"RANGE<ANY>"===i?n.push("RANGE"):"OPTIONAL"===i?s=!0:"REPEATING"===i?r=!0:"LAZY"===i?a=!0:i.startsWith("DEFAULT=")&&(t=e.trim().slice(8))}let l=i[3].trim();const c={name:o,description:l,type:n};s&&(c.optional=!0);r&&(c.repeating=!0);a&&(c.lazy=!0);void 0!==t&&(c.default=!0,c.defaultValue=t);return c}(`${e} ${t}`)}function fa(e){let t=0,i=0,o=0;for(let n of e.args)t++,n.optional||n.repeating||n.default||i++,n.repeating&&o++;const n=e;return n.minArgRequired=i,n.maxArgPossible=o?1/0:t,n.nbrArgRepeating=o,n.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const i=e-t;return e=>{if(e<=i)return e;return i+((e-i)%t||t)}}(t,o),n.hidden=e.hidden||!1,n}const va={description:s("Apply a large number format"),args:[ma("value (number)",s("The number.")),ma("unit (string, optional)",s("The formatting unit. Use 'k', 'm', or 'b' to force the unit"))],returns:["NUMBER"],computeFormat:(e,t)=>{const i=Math.abs(Po(e.value)),o=e.format;if(void 0!==t){switch(null==t?void 0:t.value){case"k":return Ti(o,1e3,"k");case"m":return Ti(o,1e6,"m");case"b":return Ti(o,1e9,"b");default:throw new Error(s("The formatting unit should be 'k', 'm' or 'b'."))}}return i<1e5?Ti(o,0,""):i<1e8?Ti(o,1e3,"k"):i<1e11?Ti(o,1e6,"m"):Ti(o,1e9,"b")},compute:function(e){return Po(e)}};var ba=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:va});const Sa={description:s("Absolute value of a number."),args:[ma("value (number)",s("The number of which to return the absolute value."))],returns:["NUMBER"],compute:function(e){return Math.abs(Po(e))},isExported:!0},Ca={description:s("Inverse cosine of a value, in radians."),args:[ma("value (number)",s("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>Math.abs(t)<=1),s("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},Ea={description:s("Inverse hyperbolic cosine of a number."),args:[ma("value (number)",s("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>t>=1),s("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},wa={description:s("Inverse cotangent of a value."),args:[ma("value (number)",s("The value for which to calculate the inverse cotangent."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},ya={description:s("Inverse hyperbolic cotangent of a value."),args:[ma("value (number)",s("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>Math.abs(t)>1),s("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},xa={description:s("Inverse sine of a value, in radians."),args:[ma("value (number)",s("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>Math.abs(t)<=1),s("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Ia={description:s("Inverse hyperbolic sine of a number."),args:[ma("value (number)",s("The value for which to calculate the inverse hyperbolic sine."))],returns:["NUMBER"],compute:function(e){return Math.asinh(Po(e))},isExported:!0},Ra={description:s("Inverse tangent of a value, in radians."),args:[ma("value (number)",s("The value for which to calculate the inverse tangent."))],returns:["NUMBER"],compute:function(e){return Math.atan(Po(e))},isExported:!0},Ta={description:s("Angle from the X axis to a point (x,y), in radians."),args:[ma("x (number)",s("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),ma("y (number)",s("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis."))],returns:["NUMBER"],compute:function(e,t){const i=Po(e),o=Po(t);return ko((()=>0!==i||0!==o),s("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(o,i)},isExported:!0},Aa={description:s("Inverse hyperbolic tangent of a number."),args:[ma("value (number)",s("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>Math.abs(t)<1),s("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},Ma={description:s("Rounds number up to nearest multiple of factor."),args:[ma("value (number)",s("The value to round up to the nearest integer multiple of factor.")),ma("factor (number, default=1)",s("The number to whose multiples value will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Po(e),o=Po(t);return ko((()=>o>=0||i<=0),s("The factor (%s) must be positive when the value (%s) is positive.",o.toString(),i.toString())),o?Math.ceil(i/o)*o:0},isExported:!0},Oa={description:s("Rounds number up to nearest multiple of factor."),args:[ma("number (number)",s("The value to round up to the nearest integer multiple of significance.")),ma("significance (number, default=1)",s("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),ma("mode (number, default=0)",s("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let o=Po(t);if(0===o)return 0;const n=Po(e);if(o=Math.abs(o),n>=0)return Math.ceil(n/o)*o;return 0===Po(i)?-Math.floor(Math.abs(n)/o)*o:-Math.ceil(Math.abs(n)/o)*o},isExported:!0},Na={description:s("Rounds number up to nearest multiple of factor."),args:[ma("number (number)",s("The value to round up to the nearest integer multiple of significance.")),ma("significance (number, default=1)",s("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){return Oa.compute(e,t,0)},isExported:!0},_a={description:s("Cosine of an angle provided in radians."),args:[ma("angle (number)",s("The angle to find the cosine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.cos(Po(e))},isExported:!0},Fa={description:s("Hyperbolic cosine of any real number."),args:[ma("value (number)",s("Any real value to calculate the hyperbolic cosine of."))],returns:["NUMBER"],compute:function(e){return Math.cosh(Po(e))},isExported:!0},Da={description:s("Cotangent of an angle provided in radians."),args:[ma("angle (number)",s("The angle to find the cotangent of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},ka={description:s("Hyperbolic cotangent of any real number."),args:[ma("value (number)",s("Any real value to calculate the hyperbolic cotangent of."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},La={description:s("Number of empty values."),args:[ma("value1 (any, range)",s("The first value or range in which to count the number of blanks.")),ma("value2 (any, range, repeating)",s("Additional values or ranges in which to count the number of blanks."))],returns:["NUMBER"],compute:function(...e){return Xo(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},Pa={description:s("A conditional count across a range."),args:[ma("range (range)",s("The range that is tested against criterion.")),ma("criterion (string)",s("The pattern or test to apply to range."))],returns:["NUMBER"],compute:function(...e){let t=0;return tn(e,((e,i)=>{t+=1})),t},isExported:!0},Ua={description:s("Count values depending on multiple criteria."),args:[ma("criteria_range1 (range)",s("The range to check against criterion1.")),ma("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),ma("criteria_range2 (any, range, repeating)",s("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),ma("criterion2 (string, repeating)",s("Additional criteria to check."))],returns:["NUMBER"],compute:function(...e){let t=0;return tn(e,((e,i)=>{t+=1})),t},isExported:!0};function Va(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const za={description:s("Counts number of unique values in a range."),args:[ma("value1 (any, range)",s("The first value or range to consider for uniqueness.")),ma("value2 (any, range, repeating)",s("Additional values or ranges to consider for uniqueness."))],returns:["NUMBER"],compute:function(...e){return Xo(e,((e,t)=>Va(t)?e.add(t):e),new Set).size}},Ba={description:s("Counts number of unique values in a range, filtered by a set of criteria."),args:[ma("range (range)",s("The range of cells from which the number of unique values will be counted.")),ma("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),ma("criterion1 (string)",s("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),ma("criteria_range2 (any, range, repeating)",s("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),ma("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=new Set;return tn(t,((t,o)=>{const n=e[t][o];Va(n)&&i.add(n)})),i.size}},Ha={description:s("Cosecant of an angle provided in radians."),args:[ma("angle (number)",s("The angle to find the cosecant of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},$a={description:s("Hyperbolic cosecant of any real number."),args:[ma("value (number)",s("Any real value to calculate the hyperbolic cosecant of."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},Wa={description:s("Converts from another base to decimal."),args:[ma("value (string)",s("The number to convert.")),ma(",base (number)",s("The base to convert the value from."))],returns:["NUMBER"],compute:function(e,t){let i=Po(t);i=Math.floor(i),ko((()=>2<=i&&i<=36),s("The base (%s) must be between 2 and 36 inclusive.",i.toString()));const o=Vo(e);if(""===o)return 0;ko((()=>!!o.match(/^-?[a-z0-9]+$/i)),s("The value (%s) must be a valid base %s representation.",o,i.toString()));const n=parseInt(o,i);return ko((()=>!isNaN(n)),s("The value (%s) must be a valid base %s representation.",o,i.toString())),n},isExported:!0},Ga={description:s("Converts an angle value in radians to degrees."),args:[ma("angle (number)",s("The angle to convert from radians to degrees."))],returns:["NUMBER"],compute:function(e){return 180*Po(e)/Math.PI},isExported:!0},qa={description:s("Euler's number, e (~2.718) raised to a power."),args:[ma("value (number)",s("The exponent to raise e."))],returns:["NUMBER"],compute:function(e){return Math.exp(Po(e))},isExported:!0},Za={description:s("Rounds number down to nearest multiple of factor."),args:[ma("value (number)",s("The value to round down to the nearest integer multiple of factor.")),ma("factor (number, default=1)",s("The number to whose multiples value will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Po(e),o=Po(t);return ko((()=>o>=0||i<=0),s("The factor (%s) must be positive when the value (%s) is positive.",o.toString(),i.toString())),o?Math.floor(i/o)*o:0},isExported:!0},ja={description:s("Rounds number down to nearest multiple of factor."),args:[ma("number (number)",s("The value to round down to the nearest integer multiple of significance.")),ma("significance (number, default=1)",s("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),ma("mode (number, default=0)",s("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let o=Po(t);if(0===o)return 0;const n=Po(e);if(o=Math.abs(o),n>=0)return Math.floor(n/o)*o;return 0===Po(i)?-Math.ceil(Math.abs(n)/o)*o:-Math.floor(Math.abs(n)/o)*o},isExported:!0},Xa={description:s("Rounds number down to nearest multiple of factor."),args:[ma("number (number)",s("The value to round down to the nearest integer multiple of significance.")),ma("significance (number, default=1)",s("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return ja.compute(e,t,0)},isExported:!0},Ya={description:s("Whether the provided value is even."),args:[ma("value (number)",s("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Uo(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},Ka={description:s("Rounds number up to nearest multiple of factor."),args:[ma("number (number)",s("The value to round up to the nearest integer multiple of significance.")),ma("significance (number, default=1)",s("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return Oa.compute(e,t,0)},isExported:!0},Qa={description:s("Whether the provided value is even."),args:[ma("value (number)",s("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Uo(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},Ja={description:s("The logarithm of a number, base e (euler's number)."),args:[ma("value (number)",s("The value for which to calculate the logarithm, base e."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>t>0),s("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},el={description:s("Modulo (remainder) operator."),args:[ma("dividend (number)",s("The number to be divided to find the remainder.")),ma("divisor (number)",s("The number to divide by."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Po(t);ko((()=>0!==i),s("The divisor must be different from 0."));const o=Po(e)%i;return o>0&&i<0||o<0&&i>0?o+i:o},isExported:!0},tl={description:s("Rounds a number up to the nearest odd integer."),args:[ma("value (number)",s("The value to round to the next greatest odd number."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Po(e);let i=Math.ceil(Math.abs(t));return i=1&i?i:i+1,t<0?-i:i},isExported:!0},il={description:s("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},ol={description:s("A number raised to a power."),args:[ma("base (number)",s("The number to raise to the exponent power.")),ma("exponent (number)",s("The exponent to raise base to."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Po(e),o=Po(t);return ko((()=>i>=0||Number.isInteger(o)),s("The exponent (%s) must be an integer when the base is negative.",o.toString())),Math.pow(i,o)},isExported:!0},nl={description:s("Result of multiplying a series of numbers together."),args:[ma("factor1 (number, range<number>)",s("The first number or range to calculate for the product.")),ma("factor2 (number, range<number>, repeating)",s("More numbers or ranges to calculate for the product."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0,i=1;for(let o of e)if(Array.isArray(o))for(let e of o)for(let o of e)"number"==typeof o&&(i*=o,t+=1);else null!=o&&(i*=Uo(o),t+=1);return 0===t?0:i},isExported:!0},sl={description:s("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},rl={description:s("Random integer between two values, inclusive."),args:[ma("low (number)",s("The low end of the random range.")),ma("high (number)",s("The high end of the random range."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){let i=Po(e);Number.isInteger(i)||(i=Math.ceil(i));let o=Po(t);return Number.isInteger(o)||(o=Math.floor(o)),ko((()=>i<=o),s("The high (%s) must be greater than or equal to the low (%s).",o.toString(),i.toString())),i+Math.ceil((o-i+1)*Math.random())-1},isExported:!0},al={description:s("Rounds a number according to standard rules."),args:[ma("value (number)",s("The value to round to places number of places.")),ma("places (number, default=0)",s("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Po(e);let o=Po(t);const n=Math.abs(i);let s;return 0===o?s=Math.round(n):(Number.isInteger(o)||(o=Math.trunc(o)),s=Math.round(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?s:-s},isExported:!0},ll={description:s("Rounds down a number."),args:[ma("value (number)",s("The value to round to places number of places, always rounding down.")),ma("places (number, default=0)",s("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Po(e);let o=Po(t);const n=Math.abs(i);let s;return 0===o?s=Math.floor(n):(Number.isInteger(o)||(o=Math.trunc(o)),s=Math.floor(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?s:-s},isExported:!0},cl={description:s("Rounds up a number."),args:[ma("value (number)",s("The value to round to places number of places, always rounding up.")),ma("places (number, default=0)",s("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Po(e);let o=Po(t);const n=Math.abs(i);let s;return 0===o?s=Math.ceil(n):(Number.isInteger(o)||(o=Math.trunc(o)),s=Math.ceil(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?s:-s},isExported:!0},hl={description:s("Secant of an angle provided in radians."),args:[ma("angle (number)",s("The angle to find the secant of, in radians."))],returns:["NUMBER"],compute:function(e){return 1/Math.cos(Po(e))},isExported:!0},dl={description:s("Hyperbolic secant of any real number."),args:[ma("value (number)",s("Any real value to calculate the hyperbolic secant of."))],returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Po(e))},isExported:!0},ul={description:s("Sine of an angle provided in radians."),args:[ma("angle (number)",s("The angle to find the sine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.sin(Po(e))},isExported:!0},gl={description:s("Hyperbolic sine of any real number."),args:[ma("value (number)",s("Any real value to calculate the hyperbolic sine of."))],returns:["NUMBER"],compute:function(e){return Math.sinh(Po(e))},isExported:!0},pl={description:s("Positive square root of a positive number."),args:[ma("value (number)",s("The number for which to calculate the positive square root."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Po(e);return ko((()=>t>=0),s("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},ml={description:s("Sum of a series of numbers and/or cells."),args:[ma("value1 (number, range<number>)",s("The first number or range to add together.")),ma("value2 (number, range<number>, repeating)",s("Additional numbers or ranges to add to value1."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){return Yo(e,((e,t)=>e+t),0)},isExported:!0},fl={description:s("A conditional sum across a range."),args:[ma("criteria_range (range)",s("The range which is tested against criterion.")),ma("criterion (string)",s("The pattern or test to apply to range.")),ma("sum_range (range, default=criteria_range)",s("The range to be summed, if different from range."))],returns:["NUMBER"],compute:function(e,t,i){void 0===i&&(i=e);let o=0;return tn([e,t],((e,t)=>{const n=i[e][t];"number"==typeof n&&(o+=n)})),o},isExported:!0},vl={description:s("Sums a range depending on multiple criteria."),args:[ma("sum_range (range)",s("The range to sum.")),ma("criteria_range1 (range)",s("The range to check against criterion1.")),ma("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),ma("criteria_range2 (any, range, repeating)",s("Additional ranges to check.")),ma("criterion2 (string, repeating)",s("Additional criteria to check."))],returns:["NUMBER"],compute:function(e,...t){let i=0;return tn(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i+=n)})),i},isExported:!0},bl={description:s("Tangent of an angle provided in radians."),args:[ma("angle (number)",s("The angle to find the tangent of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.tan(Po(e))},isExported:!0},Sl={description:s("Hyperbolic tangent of any real number."),args:[ma("value (number)",s("Any real value to calculate the hyperbolic tangent of."))],returns:["NUMBER"],compute:function(e){return Math.tanh(Po(e))},isExported:!0},Cl={description:s("Truncates a number."),args:[ma("value (number)",s("The value to be truncated.")),ma("places (number, default=0)",s("The number of significant digits to the right of the decimal point to retain."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Po(e);let o=Po(t);return 0===o?Math.trunc(i):(Number.isInteger(o)||(o=Math.trunc(o)),Math.trunc(i*Math.pow(10,o))/Math.pow(10,o))},isExported:!0};var El=Object.freeze({__proto__:null,ABS:Sa,ACOS:Ca,ACOSH:Ea,ACOT:wa,ACOTH:ya,ASIN:xa,ASINH:Ia,ATAN:Ra,ATAN2:Ta,ATANH:Aa,CEILING:Ma,CEILING_MATH:Oa,CEILING_PRECISE:Na,COS:_a,COSH:Fa,COT:Da,COTH:ka,COUNTBLANK:La,COUNTIF:Pa,COUNTIFS:Ua,COUNTUNIQUE:za,COUNTUNIQUEIFS:Ba,CSC:Ha,CSCH:$a,DECIMAL:Wa,DEGREES:Ga,EXP:qa,FLOOR:Za,FLOOR_MATH:ja,FLOOR_PRECISE:Xa,ISEVEN:Ya,ISO_CEILING:Ka,ISODD:Qa,LN:Ja,MOD:el,ODD:tl,PI:il,POWER:ol,PRODUCT:nl,RAND:sl,RANDBETWEEN:rl,ROUND:al,ROUNDDOWN:ll,ROUNDUP:cl,SEC:hl,SECH:dl,SIN:ul,SINH:gl,SQRT:pl,SUM:ml,SUMIF:fl,SUMIFS:vl,TAN:bl,TANH:Sl,TRUNC:Cl});function wl(e,t,i){let o=[],n=[],r=0,a=0;qo([e],(e=>{o.push(e),r+=1})),qo([t],(e=>{n.push(e),a+=1})),ko((()=>r===a),s("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",r.toString(),a.toString()));let l=0,c=0,h=0;for(let e=0;e<r;e++){const t=o[e],i=n[e];"number"==typeof t&&"number"==typeof i&&(l+=1,c+=t,h+=i)}ko((()=>0!==l&&(!i||1!==l)),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const d=c/l,u=h/l;let g=0;for(let e=0;e<r;e++){const t=o[e],i=n[e];"number"==typeof t&&"number"==typeof i&&(g+=(t-d)*(i-u))}return g/(l-(i?1:0))}function yl(e,t,i){let o=0,n=0;const r=i?Ko:Yo;n=r(e,((e,t)=>(o+=1,e+t)),0),ko((()=>0!==o&&(!t||1!==o)),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const a=n/o;return r(e,((e,t)=>e+Math.pow(t-a,2)),0)/(o-(t?1:0))}function xl(e,t,i){const o=Po(t);ko((()=>i?0<=o&&o<=1:0<o&&o<1),s("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let n,r=[],a=0;return qo(e,(e=>{"number"==typeof e&&(n=sn(r,e,"nextSmaller","asc",r.length,((e,t)=>e[t])),r.splice(n+1,0,e),a++)})),ko((()=>0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),i||ko((()=>1/(a+1)<=o&&o<=a/(a+1)),s("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),ri(r,o,i)}const Il={description:s("Average magnitude of deviations from mean."),args:[ma("value1 (number, range<number>)",s("The first value or range of the sample.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){let t=0;const i=Yo(e,((e,i)=>(t+=1,e+i)),0);ko((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const o=i/t;return Yo(e,((e,t)=>e+Math.abs(o-t)),0)/t},isExported:!0},Rl={description:s("Numerical average value in a dataset, ignoring text."),args:[ma("value1 (number, range<number>)",s("The first value or range to consider when calculating the average value.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the average value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const i=Yo(e,((e,i)=>(t+=1,e+i)),0);return ko((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},Tl=s("[[FUNCTION_NAME]] has mismatched range sizes."),Al=s("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),Ml={description:s("Weighted average."),args:[ma("values (number, range<number>)",s("Values to average.")),ma("weights (number, range<number>)",s("Weights for each corresponding value.")),ma("additional_values (number, range<number>, repeating)",s("Additional values to average.")),ma("additional_weights (number, range<number>, repeating)",s("Additional weights."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t,i,o=0,n=0;ko((()=>e.length%2==0),s("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let r=0;r<e.length-1;r+=2)if(t=e[r],i=e[r+1],Array.isArray(t)){ko((()=>Array.isArray(i)),Tl);let e=t.length,r=t[0].length;ko((()=>e===i.length&&r===i[0].length),Tl);for(let a=0;a<e;a++)for(let e=0;e<r;e++){let r=t[a][e],l=i[a][e],c="number"==typeof r,h="number"==typeof l;ko((()=>c===h),s("[[FUNCTION_NAME]] expects number values.")),h&&(ko((()=>l>=0),Al),o+=r*l,n+=l)}}else i=Po(i),t=Po(t),ko((()=>i>=0),Al),o+=t*i,n+=i;return ko((()=>0!==n),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/n}},Ol={description:s("Numerical average value in a dataset."),args:[ma("value1 (number, range<number>)",s("The first value or range to consider when calculating the average value.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the average value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const i=Ko(e,((e,i)=>(t+=1,e+i)),0);return ko((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},Nl={description:s("Average of values depending on criteria."),args:[ma("criteria_range (range)",s("The range to check against criterion.")),ma("criterion (string)",s("The pattern or test to apply to criteria_range.")),ma("average_range (range, default=criteria_range)",s("The range to average. If not included, criteria_range is used for the average instead."))],returns:["NUMBER"],compute:function(e,t,i){null==i&&(i=e);let o=0,n=0;return tn([e,t],((t,s)=>{const r=(i||e)[t][s];"number"==typeof r&&(o+=1,n+=r)})),ko((()=>0!==o),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/o},isExported:!0},_l={description:s("Average of values depending on multiple criteria."),args:[ma("average_range (range)",s("The range to average.")),ma("criteria_range1 (range)",s("The range to check against criterion1.")),ma("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),ma("criteria_range2 (any, range, repeating)",s("Additional criteria_range and criterion to check.")),ma("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=0,o=0;return tn(t,((t,n)=>{const s=e[t][n];"number"==typeof s&&(i+=1,o+=s)})),ko((()=>0!==i),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/i},isExported:!0},Fl={description:s("The number of numeric values in dataset."),args:[ma("value1 (number, range<number>)",s("The first value or range to consider when counting.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){let t=0;for(let i of e)if(Array.isArray(i))for(let e of i)for(let i of e)"number"==typeof i&&(t+=1);else("string"!=typeof i||oi(i)||Ee(i))&&(t+=1);return t},isExported:!0},Dl={description:s("The number of values in a dataset."),args:[ma("value1 (any, range)",s("The first value or range to consider when counting.")),ma("value2 (any, range, repeating)",s("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){return Xo(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},kl={description:s("The covariance of a dataset."),args:[ma("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),ma("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return wl(e,t,!1)},isExported:!0},Ll={description:s("The covariance of a dataset."),args:[ma("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),ma("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return wl(e,t,!1)},isExported:!0},Pl={description:s("The sample covariance of a dataset."),args:[ma("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),ma("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return wl(e,t,!0)},isExported:!0},Ul={description:s("Nth largest element from a data set."),args:[ma("data (any, range)",s("Array or range containing the dataset to consider.")),ma("n (number)",s("The rank from largest to smallest of the element to return."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const i=Math.trunc(Po(t));let o,n=[],r=0;qo([e],(e=>{"number"==typeof e&&(o=sn(n,e,"nextSmaller","asc",n.length,((e,t)=>e[t])),n.splice(o+1,0,e),r++,r>i&&(n.shift(),r--))}));const a=n.shift();return ko((()=>void 0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),ko((()=>r>=i),s("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},Vl={description:s("Maximum value in a numeric dataset."),args:[ma("value1 (number, range<number>)",s("The first value or range to consider when calculating the maximum value.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the maximum value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Yo(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},zl={description:s("Maximum numeric value in a dataset."),args:[ma("value1 (any, range)",s("The first value or range to consider when calculating the maximum value.")),ma("value2 (any, range, repeating)",s("Additional values or ranges to consider when calculating the maximum value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Ko(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},Bl={description:s("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:[ma("range (range)",s("The range of cells from which the maximum will be determined.")),ma("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),ma("criterion1 (string)",s("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),ma("criteria_range2 (any, range, repeating)",s("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),ma("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=-1/0;return tn(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i=i<n?n:i)})),i===-1/0?0:i},isExported:!0},Hl={description:s("Median value in a numeric dataset."),args:[ma("value1 (any, range)",s("The first value or range to consider when calculating the median value.")),ma("value2 (any, range, repeating)",s("Additional values or ranges to consider when calculating the median value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=[];return Zo(e,(e=>{t.push(e)})),xl(t,.5,!0)},isExported:!0},$l={description:s("Minimum value in a numeric dataset."),args:[ma("value1 (number, range<number>)",s("The first value or range to consider when calculating the minimum value.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the minimum value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Yo(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},Wl={description:s("Minimum numeric value in a dataset."),args:[ma("value1 (number, range<number>)",s("The first value or range to consider when calculating the minimum value.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the minimum value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Ko(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},Gl={description:s("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:[ma("range (range)",s("The range of cells from which the minimum will be determined.")),ma("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),ma("criterion1 (string)",s("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),ma("criteria_range2 (any, range, repeating)",s("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),ma("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=1/0;return tn(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i=i>n?n:i)})),i===1/0?0:i},isExported:!0},ql={description:s("Value at a given percentile of a dataset."),args:[ma("data (any, range)",s("The array or range containing the dataset to consider.")),ma("percentile (number)",s("The percentile whose value within data will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return jl.compute(e,t)},isExported:!0},Zl={description:s("Value at a given percentile of a dataset exclusive of 0 and 1."),args:[ma("data (any, range)",s("The array or range containing the dataset to consider.")),ma("percentile (number)",s("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return xl([e],t,!1)},isExported:!0},jl={description:s("Value at a given percentile of a dataset."),args:[ma("data (any, range)",s("The array or range containing the dataset to consider.")),ma("percentile (number)",s("The percentile whose value within data will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return xl([e],t,!0)},isExported:!0},Xl={description:s("Value nearest to a specific quartile of a dataset."),args:[ma("data (any, range)",s("The array or range containing the dataset to consider.")),ma("quartile_number (number)",s("Which quartile value to return."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Kl.compute(e,t)},isExported:!0},Yl={description:s("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:[ma("data (any, range)",s("The array or range containing the dataset to consider.")),ma("quartile_number (number)",s("Which quartile value, exclusive of 0 and 4, to return."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return xl([e],.25*Math.trunc(Po(t)),!1)},isExported:!0},Kl={description:s("Value nearest to a specific quartile of a dataset."),args:[ma("data (any, range)",s("The array or range containing the dataset to consider.")),ma("quartile_number (number)",s("Which quartile value to return."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return xl([e],.25*Math.trunc(Po(t)),!0)},isExported:!0},Ql={description:s("Nth smallest element in a data set."),args:[ma("data (any, range)",s("The array or range containing the dataset to consider.")),ma("n (number)",s("The rank from smallest to largest of the element to return."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const i=Math.trunc(Po(t));let o,n=[],r=0;qo([e],(e=>{"number"==typeof e&&(o=sn(n,e,"nextSmaller","asc",n.length,((e,t)=>e[t])),n.splice(o+1,0,e),r++,r>i&&(n.pop(),r--))}));const a=n.pop();return ko((()=>void 0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),ko((()=>r>=i),s("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},Jl={description:s("Standard deviation."),args:[ma("value1 (number, range<number>)",s("The first value or range of the sample.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(sc.compute(...e))},isExported:!0},ec={description:s("Standard deviation of entire population."),args:[ma("value1 (number, range<number>)",s("The first value or range of the population.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(rc.compute(...e))},isExported:!0},tc={description:s("Standard deviation."),args:[ma("value1 (number, range<number>)",s("The first value or range of the sample.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(ac.compute(...e))},isExported:!0},ic={description:s("Standard deviation of sample (text as 0)."),args:[ma("value1 (number, range<number>)",s("The first value or range of the sample.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(lc.compute(...e))},isExported:!0},oc={description:s("Standard deviation of entire population."),args:[ma("value1 (number, range<number>)",s("The first value or range of the population.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(cc.compute(...e))},isExported:!0},nc={description:s("Standard deviation of entire population (text as 0)."),args:[ma("value1 (number, range<number>)",s("The first value or range of the population.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(hc.compute(...e))},isExported:!0},sc={description:s("Variance."),args:[ma("value1 (number, range<number>)",s("The first value or range of the sample.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return yl(e,!0,!1)},isExported:!0},rc={description:s("Variance of entire population."),args:[ma("value1 (number, range<number>)",s("The first value or range of the population.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return yl(e,!1,!1)},isExported:!0},ac={description:s("Variance."),args:[ma("value1 (number, range<number>)",s("The first value or range of the sample.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return yl(e,!0,!1)},isExported:!0},lc={description:s("Variance of sample (text as 0)."),args:[ma("value1 (number, range<number>)",s("The first value or range of the sample.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return yl(e,!0,!0)},isExported:!0},cc={description:s("Variance of entire population."),args:[ma("value1 (number, range<number>)",s("The first value or range of the population.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return yl(e,!1,!1)},isExported:!0},hc={description:s("Variance of entire population (text as 0)."),args:[ma("value1 (number, range<number>)",s("The first value or range of the population.")),ma("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return yl(e,!1,!0)},isExported:!0};var dc=Object.freeze({__proto__:null,AVEDEV:Il,AVERAGE:Rl,AVERAGE_WEIGHTED:Ml,AVERAGEA:Ol,AVERAGEIF:Nl,AVERAGEIFS:_l,COUNT:Fl,COUNTA:Dl,COVAR:kl,COVARIANCE_P:Ll,COVARIANCE_S:Pl,LARGE:Ul,MAX:Vl,MAXA:zl,MAXIFS:Bl,MEDIAN:Hl,MIN:$l,MINA:Wl,MINIFS:Gl,PERCENTILE:ql,PERCENTILE_EXC:Zl,PERCENTILE_INC:jl,QUARTILE:Xl,QUARTILE_EXC:Yl,QUARTILE_INC:Kl,SMALL:Ql,STDEV:Jl,STDEV_P:ec,STDEV_S:tc,STDEVA:ic,STDEVP:oc,STDEVPA:nc,VAR:sc,VAR_P:rc,VAR_S:ac,VARA:lc,VARP:cc,VARPA:hc});function uc(e,t,i){var o;const n=new Map,r=e.length;for(let t=r-1;t>=0;t--)n.set(Vo(e[t][0]).toUpperCase(),t);if("number"!=typeof t&&"string"!=typeof t)throw new Error(s("The field must be a number or a string"));let a;if("number"==typeof t){if(a=Math.trunc(t)-1,a<0||r-1<a)throw new Error(s("The field (%s) must be one of %s or must be a number between 1 and %s inclusive.",t.toString(),r.toString()))}else{const e=Vo(t).toUpperCase();if(a=null!==(o=n.get(e))&&void 0!==o?o:-1,-1===a)throw new Error(s("The field (%s) must be one of %s.",Vo(t),[...n.keys()].toString()))}const l=i[0].length;if(l<2)throw new Error(s("The criteria range contains %s row, it must be at least 2 rows.",l.toString()));let c=new Set;const h=e[0].length;for(let t=1;t<l;t++){let o=[],s=!0;for(let r=0;r<i.length;r++){const a=Vo(i[r][0]).toUpperCase(),l=n.get(a),c=i[r][t];if(void 0!==c){if(void 0===l){s=!1;break}o.push([e[l].slice(1,h)]),o.push(c)}}if(s){if(!(o.length>0)){c=new Set(Array(h-1).keys());break}tn(o,((e,t)=>{c.add(t)}),!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const gc=[ma("database (range)",s("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.")),ma("field (any)",s("Indicates which column in database contains the values to be extracted and operated on.")),ma("criteria (range)",s("An array or range containing zero or more criteria to filter the database values by before operating."))],pc={description:s("Average of a set of values from a table-like range."),args:gc,returns:["NUMBER"],compute:function(e,t,i){const o=uc(e,t,i);return Rl.compute([o])},isExported:!0},mc={description:s("Counts values from a table-like range."),args:gc,returns:["NUMBER"],compute:function(e,t,i){const o=uc(e,t,i);return Fl.compute([o])},isExported:!0},fc={description:s("Counts values and text from a table-like range."),args:gc,returns:["NUMBER"],compute:function(e,t,i){const o=uc(e,t,i);return Dl.compute([o])},isExported:!0},vc={description:s("Single value from a table-like range."),args:gc,returns:["NUMBER"],compute:function(e,t,i){const o=uc(e,t,i);return ko((()=>1===o.length),s("More than one match found in DGET evaluation.")),o[0]},isExported:!0},bc={description:s("Maximum of values from a table-like range."),args:gc,returns:["NUMBER"],compute:function(e,t,i){const o=uc(e,t,i);return Vl.compute([o])},isExported:!0},Sc={description:s("Minimum of values from a table-like range."),args:gc,returns:["NUMBER"],compute:function(e,t,i){const o=uc(e,t,i);return $l.compute([o])},isExported:!0},Cc={description:s("Product of values from a table-like range."),args:gc,returns:["NUMBER"],compute:function(e,t,i){const o=uc(e,t,i);return nl.compute([o])},isExported:!0},Ec={description:s("Standard deviation of population sample from table."),args:gc,returns:["NUMBER"],compute:function(e,t,i){const o=uc(e,t,i);return Jl.compute([o])},isExported:!0},wc={description:s("Standard deviation of entire population from table."),args:gc,returns:["NUMBER"],compute:function(e,t,i){const o=uc(e,t,i);return oc.compute([o])},isExported:!0},yc={description:s("Sum of values from a table-like range."),args:gc,returns:["NUMBER"],compute:function(e,t,i){const o=uc(e,t,i);return ml.compute([o])},isExported:!0},xc={description:s("Variance of population sample from table-like range."),args:gc,returns:["NUMBER"],compute:function(e,t,i){const o=uc(e,t,i);return sc.compute([o])},isExported:!0},Ic={description:s("Variance of a population from a table-like range."),args:gc,returns:["NUMBER"],compute:function(e,t,i){const o=uc(e,t,i);return cc.compute([o])},isExported:!0};var Rc=Object.freeze({__proto__:null,DAVERAGE:pc,DCOUNT:mc,DCOUNTA:fc,DGET:vc,DMAX:bc,DMIN:Sc,DPRODUCT:Cc,DSTDEV:Ec,DSTDEVP:wc,DSUM:yc,DVAR:xc,DVARP:Ic});const Tc={description:s("Converts year/month/day into a date."),args:[ma("year (number)",s("The year component of the date.")),ma("month (number)",s("The month component of the date.")),ma("day (number)",s("The day component of the date."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){let o=Math.trunc(Po(e));const n=Math.trunc(Po(t)),r=Math.trunc(Po(i));ko((()=>0<=o&&o<=9999),s("The year (%s) must be between 0 and 9999 inclusive.",o.toString())),o<1900&&(o+=1900);const a=xe(new Date(o,n-1,r));return ko((()=>a>=0),s("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},Ac={description:s("Converts a date string to a date value."),args:[ma("date_string (string)",s("The string representing the date."))],returns:["NUMBER"],compute:function(e){const t=Vo(e),i=Ee(t);return ko((()=>null!==i),s("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(i.value)},isExported:!0},Mc={description:s("Day of the month that a specific date falls on."),args:[ma("date (string)",s("The date from which to extract the day."))],returns:["NUMBER"],compute:function(e){return Wo(e).getDate()},isExported:!0},Oc={description:s("Number of days between two dates."),args:[ma("end_date (date)",s("The end of the date range.")),ma("start_date (date)",s("The start of the date range."))],returns:["NUMBER"],compute:function(e,t){const i=Wo(e),o=Wo(t),n=i.getTime()-o.getTime();return Math.round(n/ge)},isExported:!0},Nc={description:s("Number of days between two dates on a 360-day year (months of 30 days)."),args:[ma("start_date (date)",s("The start date to consider in the calculation.")),ma("end_date (date)",s("The end date to consider in the calculation.")),ma("method (number, default=0)",s("An indicator of what day count method to use. (0) US NASD method (1) European method"))],returns:["NUMBER"],compute:function(e,t,i=0){const o=Po(e),n=Po(t),s=$o(i)?4:0,r=Kc.compute(e,t,s);return Math.sign(n-o)*Math.round(360*r)},isExported:!0},_c={description:s("Date a number of months before/after another date."),args:[ma("start_date (date)",s("The date from which to calculate the result.")),ma("months (number)",s("The number of months before (negative) or after (positive) 'start_date' to calculate."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){return xe(Te(Wo(e),Math.trunc(Po(t)),!1))},isExported:!0},Fc={description:s("Last day of a month before or after a date."),args:[ma("start_date (date)",s("The date from which to calculate the result.")),ma("months (number)",s("The number of months before (negative) or after (positive) 'start_date' to consider."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){const i=Wo(e),o=Math.trunc(Po(t)),n=i.getFullYear(),s=i.getMonth();return xe(new Date(n,s+o+1,0))},isExported:!0},Dc={description:s("Hour component of a specific time."),args:[ma("time (date)",s("The time from which to calculate the hour component."))],returns:["NUMBER"],compute:function(e){return Wo(e).getHours()},isExported:!0},kc={description:s("ISO week number of the year."),args:[ma("date (date)",s("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."))],returns:["NUMBER"],compute:function(e){const t=Wo(e),i=t.getFullYear();let o=1;for(;4!==new Date(i,0,o).getDay();)o+=1;const n=new Date(i,0,o-3);let s=31;for(;4!==new Date(i,11,s).getDay();)s-=1;const r=new Date(i,11,s+3);let a,l;switch(a=n.getTime()<=t.getTime()?t.getTime()<=r.getTime()?0:1:-1,a){case 0:l=n;break;case 1:l=new Date(i,11,s+3+1);break;case-1:let e=1;for(;4!==new Date(i-1,0,e).getDay();)e+=1;l=new Date(i-1,0,e-3)}const c=(t.getTime()-l.getTime())/ge;return Math.floor(c/7)+1},isExported:!0},Lc={description:s("Minute component of a specific time."),args:[ma("time (date)",s("The time from which to calculate the minute component."))],returns:["NUMBER"],compute:function(e){return Wo(e).getMinutes()},isExported:!0},Pc={description:s("Month of the year a specific date falls in"),args:[ma("date (date)",s("The date from which to extract the month."))],returns:["NUMBER"],compute:function(e){return Wo(e).getMonth()+1},isExported:!0},Uc={description:s("Net working days between two provided days."),args:[ma("start_date (date)",s("The start date of the period from which to calculate the number of net working days.")),ma("end_date (date)",s("The end date of the period from which to calculate the number of net working days.")),ma("holidays (date, range<date>, optional)",s("A range or array constant containing the date serial numbers to consider holidays."))],returns:["NUMBER"],compute:function(e,t,i){return zc.compute(e,t,1,i)},isExported:!0};function Vc(e){if("string"==typeof e){ko((()=>{if(7!==e.length)return!1;for(let t of e)if("0"!==t&&"1"!==t)return!1;return!0}),s('When weekend is a string (%s) it must be composed of "0" or "1".',e));let t=[];for(let i=0;i<7;i++)"1"===e[i]&&t.push((i+1)%7);return t}if("number"==typeof e)return ko((()=>1<=e&&e<=7||11<=e&&e<=17),s("The weekend (%s) must be a string or a number in the range 1-7 or 11-17.",e.toString())),e<=7?[e-2==-1?6:e-2,e-1]:[e-11];throw Error(s("The weekend must be a number or a string."))}const zc={description:s("Net working days between two dates (specifying weekends)."),args:[ma("start_date (date)",s("The start date of the period from which to calculate the number of net working days.")),ma("end_date (date)",s("The end date of the period from which to calculate the number of net working days.")),ma("weekend (any, default=1)",s("A number or string representing which days of the week are considered weekends.")),ma("holidays (date, range<date>, optional)",s("A range or array constant containing the dates to consider as holidays."))],returns:["NUMBER"],compute:function(e,t,i=1,o){const n=Wo(e),s=Wo(t),r=Vc(i);let a=new Set;void 0!==o&&qo([o],(e=>{const t=Wo(e);a.add(t.getTime())}));const l=n.getTime()>s.getTime(),c=new Date((l?n:s).getTime());let h=new Date((l?s:n).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)r.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},Bc={description:s("Current date and time as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy hh:mm:ss",compute:function(){let e=new Date;e.setMilliseconds(0);const t=e.getTime()-ue.getTime(),i=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/ge)+i},isExported:!0},Hc={description:s("Minute component of a specific time."),args:[ma("time (date)",s("The time from which to calculate the second component."))],returns:["NUMBER"],compute:function(e){return Wo(e).getSeconds()},isExported:!0},$c={description:s("Converts hour/minute/second into a time."),args:[ma("hour (number)",s("The hour component of the time.")),ma("minute (number)",s("The minute component of the time.")),ma("second (number)",s("The second component of the time."))],returns:["DATE"],computeFormat:()=>"hh:mm:ss a",compute:function(e,t,i){let o=Math.trunc(Po(e)),n=Math.trunc(Po(t)),r=Math.trunc(Po(i));return n+=Math.floor(r/60),r=r%60+(r<0?60:0),o+=Math.floor(n/60),n=n%60+(n<0?60:0),o%=24,ko((()=>o>=0),s("The function [[FUNCTION_NAME]] result cannot be negative")),o/24+n/1440+r/86400},isExported:!0},Wc={description:s("Converts a time string into its serial number representation."),args:[ma("time_string (string)",s("The string that holds the time representation."))],returns:["NUMBER"],compute:function(e){const t=Vo(e),i=Ee(t);ko((()=>null!==i),s("The time_string (%s) cannot be parsed to date/time.",t));const o=i.value-Math.trunc(i.value);return o<0?1+o:o},isExported:!0},Gc={description:s("Current date as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(){const e=new Date;return xe(new Date(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},qc={description:s("Day of the week of the date provided (as number)."),args:[ma("date (date)",s("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.")),ma("type (number, default=1)",s("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1."))],returns:["NUMBER"],compute:function(e,t=1){const i=Wo(e),o=Math.round(Po(t)),n=i.getDay();return ko((()=>[1,2,3].includes(o)),s("The type (%s) must be 1, 2 or 3.",o.toString())),1===o?n+1:2===o?0===n?7:n:0===n?6:n-1},isExported:!0},Zc={description:s("Week number of the year."),args:[ma("date (date)",s("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.")),ma("type (number, default=1)",s("A number representing the day that a week starts on. Sunday = 1."))],returns:["NUMBER"],compute:function(e,t=1){const i=Wo(e),o=Math.round(Po(t));if(ko((()=>1===o||2===o||11<=o&&o<=17||21===o),s("The type (%s) is out of range.",o.toString())),21===o)return kc.compute(e);let n;n=1===o||2===o?o-1:o-10==7?0:o-10;const r=i.getFullYear();let a=1,l=new Date(r,0,a);for(;l.getDay()!==n;)a+=1,l=new Date(r,0,a);const c=(i.getTime()-l.getTime())/ge;return c<0?1:Math.floor(c/7)+(1===a?1:2)},isExported:!0},jc={description:s("Date after a number of workdays."),args:[ma("start_date (date)",s("The date from which to begin counting.")),ma("num_days (number)",s("The number of working days to advance from start_date. If negative, counts backwards.")),ma("holidays (date, range<date>, optional)",s("A range or array constant containing the dates to consider holidays."))],returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){return Xc.compute(e,t,1,i)},isExported:!0},Xc={description:s("Date after a number of workdays (specifying weekends)."),args:[ma("start_date (date)",s("The date from which to begin counting.")),ma("num_days (number)",s("The number of working days to advance from start_date. If negative, counts backwards.")),ma("weekend (any, default=1)",s("A number or string representing which days of the week are considered weekends.")),ma("holidays (date, range<date>, optional)",s("A range or array constant containing the dates to consider holidays."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i=1,o){let n=Wo(e),r=Math.trunc(Po(t));"string"==typeof i&&ko((()=>"1111111"!==i),s("The weekend (%s) must be different from '1111111'.",i));const a=Vc(i);let l=new Set;void 0!==o&&qo([o],(e=>{const t=Wo(e);l.add(t.getTime())}));let c=new Date(n.getTime()),h=c.getTime();const d=Math.sign(r);let u=Math.abs(r);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),a.includes(c.getDay())||l.has(h)||(u-=1);const g=h-ue.getTime();return Math.round(g/ge)},isExported:!0},Yc={description:s("Year specified by a given date."),args:[ma("date (date)",s("The date from which to extract the year."))],returns:["NUMBER"],compute:function(e){return Wo(e).getFullYear()},isExported:!0},Kc={description:s("Exact number of years between two dates."),args:[ma("start_date (date)",s("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.")),ma("end_date (date)",s("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.")),ma("day_count_convention (number, default=0)",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i=0){let o=Math.trunc(Po(e)),n=Math.trunc(Po(t));const r=Math.trunc(Po(i));return ko((()=>o>=0),s("The start_date (%s) must be positive or null.",o.toString())),ko((()=>n>=0),s("The end_date (%s) must be positive or null.",n.toString())),ko((()=>0<=r&&r<=4),s("The day_count_convention (%s) must be between 0 and 4 inclusive.",r.toString())),Me(o,n,r)}},Qc={description:s("First day of the month preceding a date."),args:[ma("date (date)",s("The date from which to calculate the result."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Wo(e),i=t.getFullYear(),o=t.getMonth();return xe(new Date(i,o,1))}},Jc={description:s("Last day of the month following a date."),args:[ma("date (date)",s("The date from which to calculate the result."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){return Fc.compute(e,0)}},eh={description:s("Quarter of the year a specific date falls in"),args:[ma("date (date)",s("The date from which to extract the quarter."))],returns:["NUMBER"],compute:function(e){return Math.ceil((Wo(e).getMonth()+1)/3)}},th={description:s("First day of the quarter of the year a specific date falls in."),args:[ma("date (date)",s("The date from which to calculate the start of quarter."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=eh.compute(e),i=Yc.compute(e);return xe(new Date(i,3*(t-1),1))}},ih={description:s("Last day of the quarter of the year a specific date falls in."),args:[ma("date (date)",s("The date from which to calculate the end of quarter."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=eh.compute(e),i=Yc.compute(e);return xe(new Date(i,3*t,0))}},oh={description:s("First day of the year a specific date falls in."),args:[ma("date (date)",s("The date from which to calculate the start of the year."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Yc.compute(e);return xe(new Date(t,0,1))}},nh={description:s("Last day of the year a specific date falls in."),args:[ma("date (date)",s("The date from which to calculate the end of the year."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Yc.compute(e);return xe(new Date(t+1,0,0))}};var sh=Object.freeze({__proto__:null,DATE:Tc,DATEVALUE:Ac,DAY:Mc,DAYS:Oc,DAYS360:Nc,EDATE:_c,EOMONTH:Fc,HOUR:Dc,ISOWEEKNUM:kc,MINUTE:Lc,MONTH:Pc,NETWORKDAYS:Uc,NETWORKDAYS_INTL:zc,NOW:Bc,SECOND:Hc,TIME:$c,TIMEVALUE:Wc,TODAY:Gc,WEEKDAY:qc,WEEKNUM:Zc,WORKDAY:jc,WORKDAY_INTL:Xc,YEAR:Yc,YEARFRAC:Kc,MONTH_START:Qc,MONTH_END:Jc,QUARTER:eh,QUARTER_START:th,QUARTER_END:ih,YEAR_START:oh,YEAR_END:nh});const rh={description:s("Compare two numeric values, returning 1 if they're equal."),args:[ma(" (number)",s("The first number to compare.")),ma(" (number, default=0)",s("The second number to compare."))],returns:["NUMBER"],compute:function(e,t=0){return Po(e)===Po(t)?1:0},isExported:!0};var ah=Object.freeze({__proto__:null,DELTA:rh});function lh(e,t){ko((()=>e<t),s("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function ch(e,t){ko((()=>t<e),s("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function hh(e){ko((()=>[1,2,4].includes(e)),s("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function dh(e){ko((()=>0<=e&&e<=4),s("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function uh(e){ko((()=>e>0),s("The redemption (%s) must be strictly positive.",e.toString()))}function gh(e){ko((()=>e>0),s("The price (%s) must be strictly positive.",e.toString()))}function ph(e){ko((()=>e>0),s("The number_of_periods (%s) must be greater than 0.",e.toString()))}function mh(e){ko((()=>e>0),s("The rate (%s) must be strictly positive.",e.toString()))}function fh(e){ko((()=>e>0),s("The life (%s) must be strictly positive.",e.toString()))}function vh(e){ko((()=>e>=0),s("The cost (%s) must be positive or null.",e.toString()))}function bh(e){ko((()=>e>0),s("The period (%s) must be strictly positive.",e.toString()))}function Sh(e){ko((()=>e>=0),s("The salvage (%s) must be positive or null.",e.toString()))}function Ch(e){ko((()=>e>0),s("The present value (%s) must be strictly positive.",e.toString()))}function Eh(e,t){ko((()=>e<=t),s("The period (%s) must be less than or equal life (%s).",e.toString(),t.toString()))}function wh(e){ko((()=>e>0),s("The investment (%s) must be strictly positive.",e.toString()))}function yh(e){ko((()=>e>0),s("The discount (%s) must be strictly positive.",e.toString()))}function xh(e){ko((()=>e<1),s("The discount (%s) must be smaller than 1.",e.toString()))}function Ih(e){ko((()=>e>0),s("The depreciation factor (%s) must be strictly positive.",e.toString()))}function Rh(e,t){const i=Wo(e),o=Wo(t),n=new Date(i);n.setFullYear(i.getFullYear()+1),ko((()=>o.getTime()<=n.getTime()),s("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function Th(e,t,i){ph(i),ko((()=>e>0),s("The first_period (%s) must be strictly positive.",e.toString())),ko((()=>t>0),s("The last_period (%s) must be strictly positive.",t.toString())),ko((()=>e<=t),s("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),ko((()=>t<=i),s("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),i.toString()))}function Ah(e){ko((()=>e>-1),s("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function Mh(e,t){ko((()=>e.length===t.length&&e[0].length===t[0].length),s("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function Oh(e){ko((()=>e.every((t=>t>=e[0]))),s("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const Nh=[ma("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ma("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ma("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),ma("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))];function _h(e,t,i,o,n=1e-10,r){let a,l,c,h,d=i,u=!1,g=0;do{c=e(d),isNaN(c)?(ko((()=>g<o&&void 0!==r),s("Function [[FUNCTION_NAME]] didn't find any result.")),g++,d=r(h),h=d):(a=d-c/t(d),l=Math.abs(a-d),d=a,u=l<n||Math.abs(c)<n,ko((()=>g<o),s("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const Fh={description:s("Accrued interest of security paying at maturity."),args:[ma("issue (date)",s("The date the security was initially issued.")),ma("maturity (date)",s("The maturity date of the security.")),ma("rate (number)",s("The annualized rate of interest.")),ma("redemption (number)",s("The redemption amount per 100 face value, or par.")),ma("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Po(e)),r=Math.trunc(Po(t)),a=Po(o),l=Po(i),c=Math.trunc(Po(n));ch(r,s),dh(c),uh(a),mh(l);return a*l*Kc.compute(s,r,n)},isExported:!0},Dh={description:s("Depreciation for an accounting period."),args:[ma("cost (number)",s("The initial cost of the asset.")),ma("purchase_date (date)",s("The date the asset was purchased.")),ma("first_period_end (date)",s("The date the first period ended.")),ma("salvage (number)",s("The value of the asset at the end of depreciation.")),ma("period (number)",s("The single period within life for which to calculate depreciation.")),ma("rate (number)",s("The deprecation rate.")),ma(" (number, optional)",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r,a=0){a=a||0;const l=Po(e),c=Math.trunc(Po(t)),h=Math.trunc(Po(i)),d=Po(o),u=Po(n),g=Po(r),p=Math.trunc(Po(a));!function(e){ko((()=>e>0),s("The cost (%s) must be strictly positive.",e.toString()))}(l),Sh(d),function(e,t){ko((()=>e<=t),s("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){ko((()=>e>=0),s("The period (%s) must be positive or null.",e.toString()))}(u),mh(g),dh(p),ko((()=>c<=h),s("The purchase_date (%s) must be before the first_period_end (%s).",c.toString(),h.toString()));const m=u<1&&u>0?1:Math.trunc(u),f=l*g,v=Kc.compute(c,h,p),b=c===h?f:f*v,S=l-b-f*m;return S>=d?0===m?b:f:d-S<f?f-(d-S):0},isExported:!0},kh={description:s("Days in coupon period containing settlement date."),args:Nh,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Po(e)),s=Math.trunc(Po(t)),r=Math.trunc(Po(i)),a=Math.trunc(Po(o));if(lh(n,s),hh(r),dh(a),1===a){const n=zh.compute(e,t,i,o);return Uh.compute(e,t,i,o)-n}return(3===a?365:360)/r},isExported:!0},Lh={description:s("Days from settlement until next coupon."),args:Nh,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Po(e)),s=Math.trunc(Po(t)),r=Math.trunc(Po(i)),a=Math.trunc(Po(o));lh(n,s),hh(r),dh(a);const l=zh.compute(n,s,i,o);if([1,2,3].includes(a))return n-l;if(4===a){const e=Me(l,n,a);return Math.round(360*e)}const c=Wo(n),h=Wo(l),d=h.getFullYear(),u=c.getFullYear(),g=h.getMonth()+1,p=c.getMonth()+1;let m=h.getDate(),f=c.getDate();return 2===g&&2===p&&Re(h)&&Re(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&Re(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Ph={description:s("Days from settlement until next coupon."),args:Nh,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Po(e)),s=Math.trunc(Po(t)),r=Math.trunc(Po(i)),a=Math.trunc(Po(o));lh(n,s),hh(r),dh(a);const l=Uh.compute(n,s,i,o);if([1,2,3].includes(a))return l-n;if(4===a){const e=Me(n,l,a);return Math.round(360*e)}const c=Lh.compute(e,t,i,a);return kh.compute(e,t,i,a)-c},isExported:!0},Uh={description:s("Next coupon date after the settlement date."),args:Nh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Po(e)),s=Math.trunc(Po(t)),r=Math.trunc(Po(i)),a=Math.trunc(Po(o));lh(n,s),hh(r),dh(a);const l=12/r,c=Vh.compute(e,t,i,o);return xe(Te(Wo(s),-(c-1)*l,!0))},isExported:!0},Vh={description:s("Number of coupons between settlement and maturity."),args:Nh,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Po(e)),s=Math.trunc(Po(t)),r=Math.trunc(Po(i)),a=Math.trunc(Po(o));lh(n,s),hh(r),dh(a);let l=1,c=s;const h=12/r;for(;c>n;)c=xe(Te(Wo(c),-h,!1)),l++;return l-1},isExported:!0},zh={description:s("Last coupon date prior to or on the settlement date."),args:Nh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Po(e)),s=Math.trunc(Po(t)),r=Math.trunc(Po(i)),a=Math.trunc(Po(o));lh(n,s),hh(r),dh(a);const l=12/r,c=Vh.compute(e,t,i,o);return xe(Te(Wo(s),-c*l,!0))},isExported:!0},Bh={description:s("Cumulative interest paid over a set of periods."),args:[ma("rate (number)",s("The interest rate.")),ma("number_of_periods (number)",s("The number of payments to be made.")),ma("present_value (number)",s("The current value of the annuity.")),ma("first_period (number)",s("The number of the payment period to begin the cumulative calculation.")),ma("last_period (number)",s("The number of the payment period to end the cumulative calculation.")),ma("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){const r=Po(o),a=Po(n),l=Po(e),c=Po(i),h=Po(t);Th(r,a,h),mh(l),Ch(c);let d=0;for(let t=r;t<=a;t++){d+=Jh.compute(e,t,h,i,0,s)}return d},isExported:!0},Hh={description:s("Cumulative principal paid over a set of periods."),args:[ma("rate (number)",s("The interest rate.")),ma("number_of_periods (number)",s("The number of payments to be made.")),ma("present_value (number)",s("The current value of the annuity.")),ma("first_period (number)",s("The number of the payment period to begin the cumulative calculation.")),ma("last_period (number)",s("The number of the payment period to end the cumulative calculation.")),ma("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){const r=Po(o),a=Po(n),l=Po(e),c=Po(i),h=Po(t);Th(r,a,h),mh(l),Ch(c);let d=0;for(let t=r;t<=a;t++){d+=cd.compute(e,t,h,i,0,s)}return d},isExported:!0},$h={description:s("Depreciation via declining balance method."),args:[ma("cost (number)",s("The initial cost of the asset.")),ma("salvage (number)",s("The value of the asset at the end of depreciation.")),ma("life (number)",s("The number of periods over which the asset is depreciated.")),ma("period (number)",s("The single period within life for which to calculate depreciation.")),ma("month (number, optional)",s("The number of months in the first year of depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,...n){const r=Po(e),a=Po(t),l=Po(i),c=Math.trunc(Po(o)),h=n.length?Math.trunc(Po(n[0])):12,d=l+(12===h?0:1);vh(r),Sh(a),bh(c),fh(l),ko((()=>1<=h&&h<=12),s("The month (%s) must be between 1 and 12 inclusive.",h.toString())),ko((()=>c<=d),s("The period (%s) must be less than or equal to %s.",c.toString(),d.toString()));const u=h/12;let g=1-Math.pow(a/r,1/l);g=Math.round(1e3*g)/1e3;let p=r,m=r*(1-g*u);for(let e=1;e<c;e++)p=m,m=p*(1-g),e===l&&(m=p*(1-g*(1-u)));return p-m},isExported:!0},Wh={description:s("Depreciation via double-declining balance method."),args:[ma("cost (number)",s("The initial cost of the asset.")),ma("salvage (number)",s("The value of the asset at the end of depreciation.")),ma("life (number)",s("The number of periods over which the asset is depreciated.")),ma("period (number)",s("The single period within life for which to calculate depreciation.")),ma("factor (number, default=2)",s("The factor by which depreciation decreases."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=2){n=n||0;const s=Po(e),r=Po(t),a=Po(i),l=Po(o),c=Po(n);if(vh(s),Sh(r),bh(l),fh(a),Eh(l,a),Ih(c),0===s||r>=s)return 0;const h=c/a;if(h>1)return 1===o?s-r:0;if(l<=1)return s*h;const d=s*Math.pow(1-h,l-1),u=s*Math.pow(1-h,l),g=u<r?d-r:d-u;return Math.max(g,0)},isExported:!0},Gh={description:s("Discount rate of a security based on price."),args:[ma("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ma("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ma("price (number)",s("The price at which the security is bought per 100 face value.")),ma("redemption (number)",s("The redemption amount per 100 face value, or par.")),ma("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Po(e)),r=Math.trunc(Po(t)),a=Po(i),l=Po(o),c=Math.trunc(Po(n));lh(s,r),dh(c),gh(a),uh(l);return(l-a)/l/Kc.compute(s,r,c)},isExported:!0},qh={description:s("Convert a decimal fraction to decimal value."),args:[ma("fractional_price (number)",s("The price quotation given using fractional decimal conventions.")),ma("unit (number)",s("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const i=Po(e),o=Math.trunc(Po(t));ko((()=>o>0),s("The unit (%s) must be strictly positive.",o.toString()));const n=Math.trunc(i);return n+(i-n)*(10**Math.ceil(Math.log10(o))/o)},isExported:!0},Zh={description:s("Convert a decimal value to decimal fraction."),args:[ma("decimal_price (number)",s("The price quotation given as a decimal value.")),ma("unit (number)",s("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const i=Po(e),o=Math.trunc(Po(t));ko((()=>o>0),s("The unit (%s) must be strictly positive.",o.toString()));const n=Math.trunc(i);return n+(i-n)*(o/10**Math.ceil(Math.log10(o)))},isExported:!0},jh={description:s("Number of periods for an investment to reach a value."),args:[ma("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ma("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ma("rate (number)",s("The annualized rate of interest.")),ma("yield (number)",s("The expected annual yield of the security.")),ma("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),ma("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){r=r||0;const a=Math.trunc(Po(e)),l=Math.trunc(Po(t)),c=Po(i),h=Po(o),d=Math.trunc(Po(n)),u=Math.trunc(Po(r));lh(a,l),hh(d),dh(u),ko((()=>c>=0),s("The rate (%s) must be positive or null.",c.toString())),ko((()=>h>=0),s("The yield (%s) must be positive or null.",h.toString()));const g=Kc.compute(a,l,u),p=g-Math.trunc(g)||1/d,m=Math.ceil(g*d),f=c/d,v=h/d;let b=0,S=0;for(let e=1;e<=m;e++){const t=(f+(e===m?1:0))/(1+v)**e;S+=(p+(e-1)/d)*t,b+=t}return 0===b?0:S/b},isExported:!0},Xh={description:s("Annual effective interest rate."),args:[ma("nominal_rate (number)",s("The nominal interest rate per year.")),ma("periods_per_year (number)",s("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const i=Po(e),o=Math.trunc(Po(t));return ko((()=>i>0),s("The nominal rate (%s) must be strictly greater than 0.",i.toString())),ko((()=>o>0),s("The number of periods by year (%s) must strictly greater than 0.",o.toString())),Math.pow(1+i/o,o)-1},isExported:!0},Yh={description:s("Future value of an annuity investment."),args:[ma("rate (number)",s("The interest rate.")),ma("number_of_periods (number)",s("The number of payments to be made.")),ma("payment_amount (number)",s("The amount per period to be paid.")),ma("present_value (number, default=0)",s("The current value of the annuity.")),ma("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=Po(e),r=Po(t),a=Po(i),l=Po(o),c=$o(n)?1:0;return s?-l*(1+s)**r-a*(1+s*c)*((1+s)**r-1)/s:-(l+a*r)},isExported:!0},Kh={description:s("Future value of principal from series of rates."),args:[ma("principal (number)",s("The amount of initial capital or value to compound against.")),ma("rate_schedule (number, range<number>)",s("A series of interest rates to compound against the principal."))],returns:["NUMBER"],compute:function(e,t){return Xo([t],((e,t)=>e*(1+Po(t))),Po(e))},isExported:!0},Qh={description:s("Calculates effective interest rate."),args:[ma("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ma("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ma("investment (number)",s("The amount invested in the security.")),ma("redemption (number)",s("The amount to be received at maturity.")),ma("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){const s=Math.trunc(Po(e)),r=Math.trunc(Po(t)),a=Po(o),l=Po(i);lh(s,r),wh(l),uh(a);return(a-l)/l/Kc.compute(s,r,n)},isExported:!0},Jh={description:s("Payment on the principal of an investment."),args:[ma("rate (number)",s("The annualized rate of interest.")),ma("period (number)",s("The amortization period, in terms of number of periods.")),ma("number_of_periods (number)",s("The number of payments to be made.")),ma("present_value (number)",s("The current value of the annuity.")),ma("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),ma("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=0,s=0){return ld.compute(e,i,o,n,s)-cd.compute(e,t,i,o,n,s)},isExported:!0},ed={description:s("Internal rate of return given periodic cashflows."),args:[ma("cashflow_amounts (number, range<number>)",s("An array or range containing the income or payments associated with the investment.")),ma("rate_guess (number, default=0.1)",s("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t=.1){const i=Po(t);Ah(i);let o=!1,n=!1,r=[];Zo([e],(e=>{e>0&&(o=!0),e<0&&(n=!0),r.push(e)})),ko((()=>o&&n),s("The cashflow_amounts must include negative and positive values."));const a=r.shift();return _h((function(e){return function(e,t,i){const o=i.length;let n=0;return i.reduce(((t,i)=>(n++,t+i*e**(o-n))),t*e**o)}(e,a,r)}),(function(e){return function(e,t,i){const o=i.length;let n=0;return i.reduce(((t,i)=>(n++,t+i*(o-n)*e**(o-n-1))),t*o*e**(o-1))}(e,a,r)}),i+1,20,1e-5)-1},isExported:!0},td={description:s("Returns the interest paid at a particular period of an investment."),args:[ma("rate (number)",s("The interest rate.")),ma("period (number)",s("The period for which you want to view the interest payment.")),ma("number_of_periods (number)",s("The number of payments to be made.")),ma("present_value (number)",s("The current value of the annuity."))],returns:["NUMBER"],compute:function(e,t,i,o){const n=Po(e),r=Po(t),a=Po(i),l=Po(o);ko((()=>0!==a),s("The number of periods must be different than 0.",a.toString()));return-1*(l-l*(r/a))*n},isExported:!0},id={description:s("Modified Macaulay duration."),args:[ma("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ma("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ma("rate (number)",s("The annualized rate of interest.")),ma("yield (number)",s("The expected annual yield of the security.")),ma("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),ma("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){return jh.compute(e,t,i,o,n,s)/(1+Po(o)/Math.trunc(Po(n)))},isExported:!0},od={description:s("Modified internal rate of return."),args:[ma("cashflow_amounts (range<number>)",s("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")),ma("financing_rate (number)",s("The interest rate paid on funds invested.")),ma("reinvestment_return_rate (number)",s("The return (as a percentage) earned on reinvestment of income received from the investment."))],returns:["NUMBER"],compute:function(e,t,i){const o=Po(t),n=Po(i),r=(a=e,a.length?a[0].map(((e,t)=>a.map((e=>e[t])))):a).flat().filter(it).map(Po);var a;const l=r.length;let c=0,h=0;for(const e of He(0,l)){const t=r[e];t>=0?c+=t*(n+1)**(l-e-1):h+=t/(o+1)**e}ko((()=>0!==h&&0!==c),s("There must be both positive and negative values in cashflow_amounts."));return(-c/h)**(1/(l-1))-1},isExported:!0},nd={description:s("Annual nominal interest rate."),args:[ma("effective_rate (number)",s("The effective interest rate per year.")),ma("periods_per_year (number)",s("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const i=Po(e),o=Math.trunc(Po(t));return ko((()=>i>0),s("The effective rate (%s) must must strictly greater than 0.",i.toString())),ko((()=>o>0),s("The number of periods by year (%s) must strictly greater than 0.",o.toString())),(Math.pow(i+1,1/o)-1)*o},isExported:!0},sd={description:s("Number of payment periods for an investment."),args:[ma("rate (number)",s("The interest rate.")),ma("payment_amount (number)",s("The amount of each payment made.")),ma("present_value (number)",s("The current value of the annuity.")),ma("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),ma("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=Po(e),r=Po(t),a=Po(i),l=Po(o),c=$o(n)?1:0;if(0===s)return-(l+a)/r;const h=r*(1+s*c)/s;return Math.log((h-l)/(a+h))/Math.log(1+s)},isExported:!0};const rd={description:s("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:[ma("discount (number)",s("The discount rate of the investment over one period.")),ma("cashflow1 (number, range<number>)",s("The first future cash flow.")),ma("cashflow2 (number, range<number>, repeating)",s("Additional future cash flows."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const i=Po(e);return ko((()=>-1!==i),s("The discount (%s) must be different from -1.",i.toString())),function(e,t,i){let o=0;return Yo(i,((t,i)=>(o++,t+i/(1+e)**o)),t)}(i,0,t)},isExported:!0},ad={description:s("Computes the number of periods needed for an investment to reach a value."),args:[ma("rate (number)",s("The rate at which the investment grows each period.")),ma("present_value (number)",s("The investment's current value.")),ma("future_value (number)",s("The investment's desired future value."))],returns:["NUMBER"],compute:function(e,t,i){const o=Po(e),n=Po(t),r=Po(i);return mh(o),ko((()=>n>0),s("The present_value (%s) must be strictly positive.",n.toString())),ko((()=>r>0),s("The future_value (%s) must be strictly positive.",r.toString())),(Math.log(r)-Math.log(n))/Math.log(1+o)},isExported:!0},ld={description:s("Periodic payment for an annuity investment."),args:[ma("rate (number)",s("The annualized rate of interest.")),ma("number_of_periods (number)",s("The number of payments to be made.")),ma("present_value (number)",s("The current value of the annuity.")),ma("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),ma("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=Po(t),r=Po(e),a=$o(n)?1:0;let l=Po(o),c=Po(i);if(ph(s),0===r)return-(l+c)/s;let h=-(c*(1+r)**s+l);return h=h*r/((1+r*a)*((1+r)**s-1)),h},isExported:!0},cd={description:s("Payment on the principal of an investment."),args:[ma("rate (number)",s("The annualized rate of interest.")),ma("period (number)",s("The amortization period, in terms of number of periods.")),ma("number_of_periods (number)",s("The number of payments to be made.")),ma("present_value (number)",s("The current value of the annuity.")),ma("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),ma("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=0,r=0){n=n||0,r=r||0;const a=Po(i),l=Po(e),c=Po(t),h=$o(r)?1:0,d=Po(n),u=Po(o);ph(a),ko((()=>c>0&&c<=a),s("The period must be between 1 and number_of_periods",a.toString()));const g=ld.compute(l,a,u,d,r);if(1===h&&1===c)return g;return g+-Yh.compute(l,0===h?c-1:c-2,g,u+g*h,0)*l},isExported:!0},hd={description:s("Present value of an annuity investment."),args:[ma("rate (number)",s("The interest rate.")),ma("number_of_periods (number)",s("The number of payments to be made.")),ma("payment_amount (number)",s("The amount per period to be paid.")),ma("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),ma("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=Po(e),r=Po(t),a=Po(i),l=Po(o),c=$o(n)?1:0;return s?-(a*(1+s*c)*((1+s)**r-1)/s+l)/(1+s)**r:-(l+a*r)},isExported:!0},dd={description:s("Price of a security paying periodic interest."),args:[ma("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ma("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ma("rate (number)",s("The annualized rate of interest.")),ma("yield (number)",s("The expected annual yield of the security.")),ma("redemption (number)",s("The redemption amount per 100 face value, or par.")),ma("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),ma("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r,a=0){a=a||0;const l=Math.trunc(Po(e)),c=Math.trunc(Po(t)),h=Po(i),d=Po(o),u=Po(n),g=Math.trunc(Po(r)),p=Math.trunc(Po(a));lh(l,c),hh(g),dh(p),ko((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),ko((()=>d>=0),s("The yield (%s) must be positive or null.",d.toString())),uh(u);const m=Kc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=1+d/g,S=100*h/g;if(1===f)return(S+u)/(v*d/g+1)-S*(1-v);let C=0;for(let e=1;e<=f;e++)C+=S/b**(e-1+v);return u/b**(f-1+v)+C-S*(1-v)},isExported:!0},ud={description:s("Price of a discount security."),args:[ma("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ma("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ma("discount (number)",s("The discount rate of the security at time of purchase.")),ma("redemption (number)",s("The redemption amount per 100 face value, or par.")),ma("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Po(e)),r=Math.trunc(Po(t)),a=Po(i),l=Po(o),c=Math.trunc(Po(n));lh(s,r),dh(c),yh(a),uh(l);return l-a*l*Kc.compute(s,r,c)},isExported:!0},gd={description:s("Calculates the price of a security paying interest at maturity, based on expected yield."),args:[ma("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ma("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ma("issue (date)",s("The date the security was initially issued.")),ma("rate (number)",s("The annualized rate of interest.")),ma("yield (number)",s("The expected annual yield of the security.")),ma("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){r=r||0;const a=Math.trunc(Po(e)),l=Math.trunc(Po(t)),c=Math.trunc(Po(i)),h=Po(o),d=Po(n),u=Math.trunc(Po(r));ch(a,c),lh(a,l),dh(u),ko((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),ko((()=>d>=0),s("The yield (%s) must be positive or null.",d.toString()));const g=Kc.compute(a,l,u),p=Kc.compute(a,c,u);return(100+Kc.compute(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},pd=.1,md={description:s("Interest rate of an annuity investment."),args:[ma("number_of_periods (number)",s("The number of payments to be made.")),ma("payment_per_period (number)",s("The amount per period to be paid.")),ma("present_value (number)",s("The current value of the annuity.")),ma("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),ma("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period.")),ma("rate_guess (number, default=0.1)",s("An estimate for what the interest rate will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,i,o=0,n=0,r=.1){o=o||0,n=n||0,r=r||pd;const a=Po(e),l=Po(t),c=$o(n)?1:0,h=Po(r);let d=Po(o),u=Po(i);ph(a),ko((()=>[l,u,d].some((e=>e>0))&&[l,u,d].some((e=>e<0))),s("There must be both positive and negative values in [payment_amount, present_value, future_value].",a.toString())),Ah(h),d-=l*c,u+=l*c;return _h((e=>{const t=Math.pow(1+e,a);return d+u*t+l*((t-1)/e)}),(e=>{const t=Math.pow(1+e,a-1),i=Math.pow(1+e,a);return u*a*t+l*(a*t/e-(i-1)/e/e)}),h,40,1e-5)},isExported:!0},fd={description:s("Amount received at maturity for a security."),args:[ma("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ma("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ma("investment (number)",s("The amount invested (irrespective of face value of each security).")),ma("discount (number)",s("The discount rate of the security invested in.")),ma("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Po(e)),r=Math.trunc(Po(t)),a=Po(i),l=Po(o),c=Math.trunc(Po(n));lh(s,r),dh(c),wh(a),yh(l);return a/(1-l*Kc.compute(s,r,c))},isExported:!0},vd={description:s("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:[ma("number_of_periods (number)",s("The number of periods.")),ma("present_value (number)",s("The present value of the investment.")),ma("future_value (number)",s("The future value of the investment."))],returns:["NUMBER"],compute:function(e,t,i){const o=Po(e),n=Po(t),s=Po(i);return ph(o),(s/n)**(1/o)-1},isExported:!0},bd={description:s("Depreciation of an asset using the straight-line method."),args:[ma("cost (number)",s("The initial cost of the asset.")),ma("salvage (number)",s("The value of the asset at the end of depreciation.")),ma("life (number)",s("The number of periods over which the asset is depreciated."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i){return(Po(e)-Po(t))/Po(i)},isExported:!0},Sd={description:s("Depreciation via sum of years digit method."),args:[ma("cost (number)",s("The initial cost of the asset.")),ma("salvage (number)",s("The value of the asset at the end of depreciation.")),ma("life (number)",s("The number of periods over which the asset is depreciated.")),ma("period (number)",s("The single period within life for which to calculate depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o){const n=Po(e),s=Po(t),r=Po(i),a=Po(o);bh(a),fh(r),Eh(a,r);return(r-a+1)/(r*(r+1)/2)*(n-s)},isExported:!0},Cd={description:s("Price of a US Treasury bill."),args:[ma("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ma("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ma("discount (number)",s("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(Po(e)),n=Math.trunc(Po(t)),s=Po(i);lh(o,n),Rh(o,n),yh(s),xh(s);return 100*(1-s*Kc.compute(o,n,2))},isExported:!0},Ed={description:s("Equivalent rate of return for a US Treasury bill."),args:[ma("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ma("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ma("discount (number)",s("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(Po(e)),n=Math.trunc(Po(t)),s=Po(i);lh(o,n),Rh(o,n),yh(s),xh(s);const r=Oc.compute(n,o);if(r<=182)return 365*s/(360-s*r);const a=Cd.compute(o,n,s)/100,l=r/(366===r?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},wd={description:s("The yield of a US Treasury bill based on price."),args:[ma("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ma("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ma("price (number)",s("The price at which the security is bought per 100 face value."))],returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(Po(e)),n=Math.trunc(Po(t)),s=Po(i);lh(o,n),Rh(o,n),gh(s);return(100-s)/s*(1/Kc.compute(o,n,2))},isExported:!0},yd={description:s("Variable declining balance. WARNING : does not handle decimal periods."),args:[ma("cost (number)",s("The initial cost of the asset.")),ma("salvage (number)",s("The value of the asset at the end of depreciation.")),ma("life (number)",s("The number of periods over which the asset is depreciated.")),ma("start (number)",s("Starting period to calculate depreciation.")),ma("end (number)",s("Ending period to calculate depreciation.")),ma("factor (number, default=2)",s("The number of months in the first year of depreciation.")),ma("no_switch (number, default=false)",s("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=2,a=false){r=r||0;const l=Po(e),c=Po(t),h=Po(i),d=Math.trunc(Po(o)),u=Math.trunc(Po(n)),g=Po(r),p=$o(a);if(vh(l),Sh(c),function(e,t,i){fh(i),ko((()=>e>=0),s("The start_period (%s) must be greater or equal than 0.",e.toString())),ko((()=>t>=0),s("The end_period (%s) must be greater or equal than 0.",t.toString())),ko((()=>e<=t),s("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),ko((()=>t<=i),s("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),i.toString()))}(d,u,h),Ih(g),0===l)return 0;if(c>=l)return d<1?l-c:0;const m=g/h;if(m>=1)return d<1?l-c:0;let f=l,v=0,b=0,S=!1;for(let e=0;e<u;e++){if(!S||p){const t=f*m,i=(f-c)/(h-e);!p&&i>t?(S=!0,v=i):v=t}const t=Math.max(f-v,c);e>=d&&(b+=f-t),f=t}return b},isExported:!0},xd={description:s("Internal rate of return given non-periodic cash flows."),args:[ma("cashflow_amounts (range<number>)",s("An range containing the income or payments associated with the investment.")),ma("cashflow_dates (range<number>)",s("An range with dates corresponding to the cash flows in cashflow_amounts.")),ma("rate_guess (number, default=0.1)",s("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],compute:function(e,t,i=.1){const o=Po(i=i||0),n=e.flat().map(Po),r=t.flat().map(Po);var a;Mh(e,t),a=n,ko((()=>a.some((e=>e>0))&&a.some((e=>e<0))),s("There must be both positive and negative values in cashflow_amounts.")),Oh(r),Ah(o);const l=new Map;for(const e of He(0,r.length)){const t=r[e];l.has(t)?l.set(t,l.get(t)+n[e]):l.set(t,n[e])}const c=Array.from(l.keys()),h=c.map((e=>l.get(e)));return _h((e=>{let t=h[0];for(const i of He(1,h.length)){const o=(c[0]-c[i])/365;t+=h[i]*(1+e)**o}return t}),(e=>{let t=0;for(const i of He(1,h.length)){const o=(c[0]-c[i])/365;t+=o*h[i]*(1+e)**(o-1)}return t}),o,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},Id={description:s("Net present value given to non-periodic cash flows.."),args:[ma("discount (number)",s("The discount rate of the investment over one period.")),ma("cashflow_amounts (number, range<number>)",s("An range containing the income or payments associated with the investment.")),ma("cashflow_dates (number, range<number>)",s("An range with dates corresponding to the cash flows in cashflow_amounts."))],returns:["NUMBER"],compute:function(e,t,i){const o=Po(e),n=Array.isArray(t)?t.flat().map(Uo):[Uo(t)],r=Array.isArray(i)?i.flat().map(Uo):[Uo(i)];if(Array.isArray(i)&&Array.isArray(t)?Mh(t,i):ko((()=>n.length===r.length),s("There must be the same number of values in cashflow_amounts and cashflow_dates.")),Oh(r),mh(o),1===n.length)return n[0];const a=new Map;for(const e of He(0,r.length)){const t=r[e];a.has(t)?a.set(t,a.get(t)+n[e]):a.set(t,n[e])}const l=Array.from(a.keys()),c=l.map((e=>a.get(e)));let h=c[0];for(const e of He(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+o)**t}return h},isExported:!0},Rd={description:s("Annual yield of a security paying periodic interest."),args:[ma("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ma("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ma("rate (number)",s("The annualized rate of interest.")),ma("price (number)",s("The price at which the security is bought per 100 face value.")),ma("redemption (number)",s("The redemption amount per 100 face value, or par.")),ma("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),ma("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r,a=0){a=a||0;const l=Math.trunc(Po(e)),c=Math.trunc(Po(t)),h=Po(i),d=Po(o),u=Po(n),g=Math.trunc(Po(r)),p=Math.trunc(Po(a));lh(l,c),hh(g),dh(p),ko((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),gh(d),uh(u);const m=Kc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=100*h/g;if(1===f){const e=d+b*(1-v);return(u+b-e)*g*(1/v)/e}const S=_h((function(e){return function(e,t,i,o,n,s){let r=s-(e+n*(1-t))*o**(i-1+t);for(let e=1;e<=i;e++)r+=n*o**(e-1);return r}(d,v,f,e,b,u)}),(function(e){return function(e,t,i,o,n){let s=-(e+n*(1-t))*(i-1+t)*o**(i-2+t);for(let e=1;e<=i;e++)s+=n*(e-1)*o**(e-2);return s}(d,v,f,e,b)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},Td={description:s("Annual yield of a discount security."),args:[ma("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ma("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ma("price (number)",s("The price at which the security is bought per 100 face value.")),ma("redemption (number)",s("The redemption amount per 100 face value, or par.")),ma("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Po(e)),r=Math.trunc(Po(t)),a=Po(i),l=Po(o),c=Math.trunc(Po(n));lh(s,r),dh(c),gh(a),uh(l);return(l/a-1)/Kc.compute(e,t,n)},isExported:!0},Ad={description:s("Annual yield of a security paying interest at maturity."),args:[ma("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),ma("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),ma("issue (date)",s("The date the security was initially issued.")),ma("rate (number)",s("The annualized rate of interest.")),ma("price (number)",s("The price at which the security is bought.")),ma("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){r=r||0;const a=Math.trunc(Po(e)),l=Math.trunc(Po(t)),c=Math.trunc(Po(i)),h=Po(o),d=Po(n),u=Math.trunc(Po(r));lh(a,l),dh(u),ko((()=>a>=c),s("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),ko((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),gh(d);const g=Kc.compute(c,l,u),p=Kc.compute(c,a,u),m=Kc.compute(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var Md=Object.freeze({__proto__:null,ACCRINTM:Fh,AMORLINC:Dh,COUPDAYS:kh,COUPDAYBS:Lh,COUPDAYSNC:Ph,COUPNCD:Uh,COUPNUM:Vh,COUPPCD:zh,CUMIPMT:Bh,CUMPRINC:Hh,DB:$h,DDB:Wh,DISC:Gh,DOLLARDE:qh,DOLLARFR:Zh,DURATION:jh,EFFECT:Xh,FV:Yh,FVSCHEDULE:Kh,INTRATE:Qh,IPMT:Jh,IRR:ed,ISPMT:td,MDURATION:id,MIRR:od,NOMINAL:nd,NPER:sd,NPV:rd,PDURATION:ad,PMT:ld,PPMT:cd,PV:hd,PRICE:dd,PRICEDISC:ud,PRICEMAT:gd,RATE:md,RECEIVED:fd,RRI:vd,SLN:bd,SYD:Sd,TBILLPRICE:Cd,TBILLEQ:Ed,TBILLYIELD:wd,VDB:yd,XIRR:xd,XNPV:Id,YIELD:Rd,YIELDDISC:Td,YIELDMAT:Ad});const Od={description:s("Whether a value is an error other than #N/A."),args:[ma("value (any, lazy)",s("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return(null==e?void 0:e.errorType)!=a.NotAvailable}},isExported:!0},Nd={description:s("Whether a value is an error."),args:[ma("value (any, lazy)",s("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return!0}},isExported:!0},_d={description:s("Whether a value is `true` or `false`."),args:[ma("value (any, lazy)",s("The value to be verified as a logical TRUE or FALSE."))],returns:["BOOLEAN"],compute:function(e){try{return"boolean"==typeof e()}catch(e){return!1}},isExported:!0},Fd={description:s("Whether a value is the error #N/A."),args:[ma("value (any, lazy)",s("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return(null==e?void 0:e.errorType)==a.NotAvailable}},isExported:!0},Dd={description:s("Whether a value is non-textual."),args:[ma("value (any, lazy)",s("The value to be checked."))],returns:["BOOLEAN"],compute:function(e){try{return"string"!=typeof e()}catch(e){return!0}},isExported:!0},kd={description:s("Whether a value is a number."),args:[ma("value (any, lazy)",s("The value to be verified as a number."))],returns:["BOOLEAN"],compute:function(e){try{return"number"==typeof e()}catch(e){return!1}},isExported:!0},Ld={description:s("Whether a value is text."),args:[ma("value (any, lazy)",s("The value to be verified as text."))],returns:["BOOLEAN"],compute:function(e){try{return"string"==typeof e()}catch(e){return!1}},isExported:!0},Pd={description:s("Whether the referenced cell is empty"),args:[ma("value (any, lazy)",s("Reference to the cell that will be checked for emptiness."))],returns:["BOOLEAN"],compute:function(e){try{return null===e()}catch(e){return!1}},isExported:!0},Ud={description:s("Returns the error value #N/A."),args:[],returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var Vd=Object.freeze({__proto__:null,ISERR:Od,ISERROR:Nd,ISLOGICAL:_d,ISNA:Fd,ISNONTEXT:Dd,ISNUMBER:kd,ISTEXT:Ld,ISBLANK:Pd,NA:Ud});const zd={description:s("Logical `and` operator."),args:[ma("logical_expression1 (boolean, range<boolean>)",s("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),ma("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that represent logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!0;return Qo(e,(e=>(t=!0,i=i&&e,i))),ko((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Bd={description:s("Returns value depending on logical expression."),args:[ma("logical_expression (boolean)",s("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")),ma("value_if_true (any, lazy)",s("The value the function returns if logical_expression is TRUE.")),ma("value_if_false (any, lazy, default=FALSE)",s("The value the function returns if logical_expression is FALSE."))],returns:["ANY"],compute:function(e,t,i=(()=>!1)){const o=$o(e)?t():i();return null==o?"":o},isExported:!0},Hd={description:s("Value if it is not an error, otherwise 2nd argument."),args:[ma("value (any, lazy)",s("The value to return if value itself is not an error.")),ma('value_if_error (any, lazy, default="empty")',s("The value the function returns if value is an error."))],returns:["ANY"],computeFormat:(e,t=(()=>({value:""})))=>{var i;try{return e().format}catch(e){return null===(i=t())||void 0===i?void 0:i.format}},compute:function(e,t=(()=>"")){let i;try{i=e()}catch(e){i=t()}return null==i?"":i},isExported:!0},$d={description:s("Value if it is not an #N/A error, otherwise 2nd argument."),args:[ma("value (any, lazy)",s("The value to return if value itself is not #N/A an error.")),ma('value_if_error (any, lazy, default="empty")',s("The value the function returns if value is an #N/A error."))],returns:["ANY"],compute:function(e,t=(()=>"")){let i;try{i=e()}catch(o){i=o.errorType===a.NotAvailable?t():e()}return null==i?"":i},isExported:!0},Wd={description:s("Returns a value depending on multiple logical expressions."),args:[ma("condition1 (boolean, lazy)",s("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")),ma("value1 (any, lazy)",s("The returned value if condition1 is TRUE.")),ma("condition2 (boolean, lazy, repeating)",s("Additional conditions to be evaluated if the previous ones are FALSE.")),ma("value2 (any, lazy, repeating)",s("Additional values to be returned if their corresponding conditions are TRUE."))],returns:["ANY"],compute:function(...e){ko((()=>e.length%2==0),s("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if($o(e[t]())){const i=e[t+1]();return null!==i?i:""}throw new Error(s("No match."))},isExported:!0},Gd={description:s("Returns opposite of provided logical value."),args:[ma("logical_expression (boolean)",s("An expression or reference to a cell holding an expression that represents some logical value."))],returns:["BOOLEAN"],compute:function(e){return!$o(e)},isExported:!0},qd={description:s("Logical `or` operator."),args:[ma("logical_expression1 (boolean, range<boolean>)",s("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),ma("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return Qo(e,(e=>(t=!0,i=i||e,!i))),ko((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Zd={description:s("Logical `xor` operator."),args:[ma("logical_expression1 (boolean, range<boolean>)",s("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),ma("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return Qo(e,(e=>(t=!0,i=i?!e:e,!0))),ko((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0};var jd=Object.freeze({__proto__:null,AND:zd,IF:Bd,IFERROR:Hd,IFNA:$d,IFS:Wd,NOT:Gd,OR:qd,XOR:Zd});function Xd(e,t){if(void 0===e)throw new g(s("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Vo(t)))}const Yd={description:s("Column number of a specified cell."),args:[ma("cell_reference (meta, default='this cell')",s("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."))],returns:["NUMBER"],compute:function(e){var t;const i=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this));ko((()=>!!i),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Bi(i).left+1},isExported:!0},Kd={description:s("Number of columns in a specified array or range."),args:[ma("range (meta)",s("The range whose column count will be returned."))],returns:["NUMBER"],compute:function(e){const t=Bi(e);return t.right-t.left+1},isExported:!0},Qd={description:s("Horizontal lookup"),args:[ma("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),ma("range (range)",s("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")),ma("index (number)",s("The row index of the value to be returned, where the first row in range is numbered 1.")),ma("is_sorted (boolean, default=true)",s("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."))],returns:["ANY"],compute:function(e,t,i,o=true){const n=Math.trunc(Po(i)),r=Bo(e);ko((()=>1<=n&&n<=t[0].length),s("[[FUNCTION_NAME]] evaluates to an out of bounds range."));let a;a=$o(o)?sn(t,r,"nextSmaller","asc",t.length,nn):rn(t,r,"strict",t.length,nn);const l=t[a];return Xd(l,e),l[n-1]},isExported:!0},Jd={description:s("Returns the content of a cell, specified by row and column offset."),args:[ma("reference (any, range)",s("The range of cells from which the values are returned.")),ma("row (number)",s("The index of the row to be returned from within the reference range of cells.")),ma("column (number)",s("The index of the column to be returned from within the reference range of cells."))],returns:["ANY"],computeFormat:(e,t,i)=>{var o;const n=Po(t.value);return null===(o=e[Po(i.value)-1][n-1])||void 0===o?void 0:o.format},compute:function(e,t,i){const o=(n=e,Array.isArray(n)&&Array.isArray(n[0])?e:[[e]]);var n;const r=Po(t),a=Po(i);return ko((()=>a>=0&&a-1<o.length&&r>=0&&r-1<o[0].length),s("Index out of range.")),ko((()=>0!==t&&0!==i),s("This function can only return a single cell value, not an array. Provide valid row and column indices.")),o[a-1][r-1]},isExported:!0},eu={description:s("Look up a value."),args:[ma("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),ma("search_array (range)",s("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.")),ma("result_range (range, optional)",s("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."))],returns:["ANY"],compute:function(e,t,i){let o=t.length,n=t[0].length;const r=Bo(e),a=n>=o,l=sn(t,r,"nextSmaller","asc",a?n:o,a?on:nn);return-1===l&&Xd(void 0,e),Xd(a?t[0][l]:t[l][n-1],e),void 0===i?a?t[o-1][l]:t[l][n-1]:(o=i.length,n=i[0].length,ko((()=>1===o||1===n),s("The result_range must be a single row or a single column.")),o>1?(ko((()=>l<=o-1),s("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),i[l][0]):(ko((()=>l<=n-1),s("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),i[0][l]))},isExported:!0},tu={description:s("Position of item in range that matches value."),args:[ma("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),ma("range (any, range)",s("The one-dimensional array to be searched.")),ma("search_type (number, default=1)",s("The search method. 1 (default) 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."))],returns:["NUMBER"],compute:function(e,t,i=1){let o=Po(i);const n=Bo(e),r=t.length,a=t[0].length;ko((()=>1===r||1===a),s("The range must be a single row or a single column."));let l=-1;const c=1===r?on:nn,h=1===r?t[0].length:t.length;switch(o=Math.sign(o),o){case 1:l=sn(t,n,"nextSmaller","asc",h,c);break;case 0:l=rn(t,n,"strict",h,c);break;case-1:l=sn(t,n,"nextGreater","desc",h,c)}return Xd(1===r?t[0][l]:t[l],e),l+1},isExported:!0},iu={description:s("Row number of a specified cell."),args:[ma("cell_reference (meta, default='this cell')",s("The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered."))],returns:["NUMBER"],compute:function(e){var t;e=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this)),ko((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Bi(e).top+1},isExported:!0},ou={description:s("Number of rows in a specified array or range."),args:[ma("range (meta)",s("The range whose row count will be returned."))],returns:["NUMBER"],compute:function(e){const t=Bi(e);return t.bottom-t.top+1},isExported:!0},nu={description:s("Vertical lookup."),args:[ma("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),ma("range (any, range)",s("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")),ma("index (number)",s("The column index of the value to be returned, where the first column in range is numbered 1.")),ma("is_sorted (boolean, default=true)",s("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."))],returns:["ANY"],compute:function(e,t,i,o=true){const n=Math.trunc(Po(i)),r=Bo(e);ko((()=>1<=n&&n<=t.length),s("[[FUNCTION_NAME]] evaluates to an out of bounds range."));let a;a=$o(o)?sn(t,r,"nextSmaller","asc",t[0].length,on):rn(t,r,"strict",t[0].length,on);const l=t[n-1][a];return Xd(l,e),l},isExported:!0},su={description:s("Search a range for a match and return the corresponding item from a second range."),args:[ma("search_key (any)",s("The value to search for.")),ma("lookup_range (any, range)",s("The range to consider for the search. Should be a single column or a single row.")),ma("return_range (any, range)",s("The range containing the return value. Should have the same dimensions as lookup_range.")),ma("if_not_found (any, lazy, optional)",s("If a valid match is not found, return this value.")),ma("match_mode (any, default=0)",s("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match.")),ma("search_mode (any, default=1)",s("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. "))],returns:["ANY"],compute:function(e,t,i,o,n=0,r=1){const a=Math.trunc(Po(n)),l=Math.trunc(Po(r)),c=Bo(e);ko((()=>1===t.length||1===t[0].length),s("lookup_range should be either a single row or single column.")),ko((()=>1===i.length||1===i[0].length),s("return_range should be either a single row or single column.")),ko((()=>i.length===t.length&&i[0].length===t[0].length),s("return_range should have the same dimensions as lookup_range.")),ko((()=>[-1,1,-2,2].includes(l)),s("searchMode should be a value in [-1, 1, -2, 2].")),ko((()=>[-1,0,1].includes(a)),s("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?on:nn,d=1===t.length?t[0].length:t.length,u=0===a?"strict":1===a?"nextGreater":"nextSmaller",g=-1===l;let p;if(2===l||-2===l){p=sn(t,c,u,2===l?"asc":"desc",d,h)}else p=rn(t,c,u,d,h,g);if(-1!==p)return 1===t.length?i[0][p]:i[p][0];const m=null==o?void 0:o();return Xd(m,e),m},isExported:!0};var ru=Object.freeze({__proto__:null,COLUMN:Yd,COLUMNS:Kd,HLOOKUP:Qd,INDEX:Jd,LOOKUP:eu,MATCH:tu,ROW:iu,ROWS:ou,VLOOKUP:nu,XLOOKUP:su});const au={description:s("Sum of two numbers."),args:[ma("value1 (number)",s("The first addend.")),ma("value2 (number)",s("The second addend."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Po(e)+Po(t)}},lu={description:s("Concatenation of two values."),args:[ma("value1 (string)",s("The value to which value2 will be appended.")),ma("value2 (string)",s("The value to append to value1."))],returns:["STRING"],compute:function(e,t){return Vo(e)+Vo(t)},isExported:!0},cu={description:s("One number divided by another."),args:[ma("dividend (number)",s("The number to be divided.")),ma("divisor (number)",s("The number to divide by."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){const i=Po(t);return ko((()=>0!==i),s("The divisor must be different from zero.")),Po(e)/i}};function hu(e){return null==e}const du={number:0,string:"",boolean:!1},uu={description:s("Equal."),args:[ma("value1 (any)",s("The first value.")),ma("value2 (any)",s("The value to test against value1 for equality."))],returns:["BOOLEAN"],compute:function(e,t){return e=hu(e)?du[typeof t]:e,t=hu(t)?du[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function gu(e,t,i){e=hu(e)?du[typeof t]:e,t=hu(t)?du[typeof e]:t,"number"!=typeof e&&(e=Vo(e).toUpperCase()),"number"!=typeof t&&(t=Vo(t).toUpperCase());const o=typeof e,n=typeof t;return"string"===o&&"number"===n||("string"!==n||"number"!==o)&&i(e,t)}const pu={description:s("Strictly greater than."),args:[ma("value1 (any)",s("The value to test as being greater than value2.")),ma("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return gu(e,t,((e,t)=>e>t))}},mu={description:s("Greater than or equal to."),args:[ma("value1 (any)",s("The value to test as being greater than or equal to value2.")),ma("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return gu(e,t,((e,t)=>e>=t))}},fu={description:s("Less than."),args:[ma("value1 (any)",s("The value to test as being less than value2.")),ma("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!mu.compute(e,t)}},vu={description:s("Less than or equal to."),args:[ma("value1 (any)",s("The value to test as being less than or equal to value2.")),ma("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!pu.compute(e,t)}},bu={description:s("Difference of two numbers."),args:[ma("value1 (number)",s("The minuend, or number to be subtracted from.")),ma("value2 (number)",s("The subtrahend, or number to subtract from value1."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Po(e)-Po(t)}},Su={description:s("Product of two numbers"),args:[ma("factor1 (number)",s("The first multiplicand.")),ma("factor2 (number)",s("The second multiplicand."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Po(e)*Po(t)}},Cu={description:s("Not equal."),args:[ma("value1 (any)",s("The first value.")),ma("value2 (any)",s("The value to test against value1 for inequality."))],returns:["BOOLEAN"],compute:function(e,t){return!uu.compute(e,t)}},Eu={description:s("A number raised to a power."),args:[ma("base (number)",s("The number to raise to the exponent power.")),ma("exponent (number)",s("The exponent to raise base to."))],returns:["NUMBER"],compute:function(e,t){return ol.compute(e,t)}},wu={description:s("A number with the sign reversed."),args:[ma("value (number)",s("The number to have its sign reversed. Equivalently, the number to multiply by -1."))],computeFormat:e=>null==e?void 0:e.format,returns:["NUMBER"],compute:function(e){return-Po(e)}},yu={description:s("Value interpreted as a percentage."),args:[ma("percentage (number)",s("The value to interpret as a percentage."))],returns:["NUMBER"],compute:function(e){return Po(e)/100}},xu={description:s("A specified number, unchanged."),args:[ma("value (any)",s("The number to return."))],returns:["ANY"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){return null===e?"":e}};var Iu=Object.freeze({__proto__:null,ADD:au,CONCAT:lu,DIVIDE:cu,EQ:uu,GT:pu,GTE:mu,LT:fu,LTE:vu,MINUS:bu,MULTIPLY:Su,NE:Cu,POW:Eu,UMINUS:wu,UNARY_PERCENT:yu,UPLUS:xu});const Ru=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,Tu={description:s("Gets character associated with number."),args:[ma("table_number (number)",s("The number of the character to look up from the current Unicode table in decimal format."))],returns:["STRING"],compute:function(e){const t=Math.trunc(Po(e));return ko((()=>t>=1),s("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},Au={description:s("Remove non-printable characters from a piece of text."),args:[ma("text (string)",s("The text whose non-printable characters are to be removed."))],returns:["STRING"],compute:function(e){const t=Vo(e);let i="";for(const e of t)e&&e.charCodeAt(0)>31&&(i+=e);return i},isExported:!0},Mu={description:s("Appends strings to one another."),args:[ma("string1 (string, range<string>)",s("The initial string.")),ma("string2 (string, range<string>, repeating)",s("More strings to append in sequence."))],returns:["STRING"],compute:function(...e){return Xo(e,((e,t)=>e+Vo(t)),"")},isExported:!0},Ou={description:s("Tests whether two strings are identical."),args:[ma("string1 (string)",s("The first string to compare.")),ma("string2 (string)",s("The second string to compare."))],returns:["BOOLEAN"],compute:function(e,t){return Vo(e)===Vo(t)},isExported:!0},Nu={description:s("First position of string found in text, case-sensitive."),args:[ma("search_for (string)",s("The string to look for within text_to_search.")),ma("text_to_search (string)",s("The text to search for the first occurrence of search_for.")),ma("starting_at (number, default=1)",s("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,i=1){const o=Vo(e),n=Vo(t),r=Po(i);ko((()=>""!==n),s("The text_to_search must be non-empty.")),ko((()=>r>=1),s("The starting_at (%s) must be greater than or equal to 1.",r.toString()));const a=n.indexOf(o,r-1);return ko((()=>a>=0),s("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",o.toString(),n)),a+1},isExported:!0},_u={description:s("Concatenates elements of arrays with delimiter."),args:[ma("delimiter (string)",s("The character or string to place between each concatenated value.")),ma("value_or_array1 (string, range<string>)",s("The value or values to be appended using delimiter.")),ma("value_or_array2 (string, range<string>, repeating)",s("More values to be appended using delimiter."))],returns:["STRING"],compute:function(e,...t){const i=Vo(e);return Xo(t,((e,t)=>(e?e+i:"")+Vo(t)),"")}},Fu={description:s("Substring from beginning of specified string."),args:[ma("text (string)",s("The string from which the left portion will be returned.")),ma("number_of_characters (number, optional)",s("The number of characters to return from the left side of string."))],returns:["STRING"],compute:function(e,...t){const i=t.length?Po(t[0]):1;return ko((()=>i>=0),s("The number_of_characters (%s) must be positive or null.",i.toString())),Vo(e).substring(0,i)},isExported:!0},Du={description:s("Length of a string."),args:[ma("text (string)",s("The string whose length will be returned."))],returns:["NUMBER"],compute:function(e){return Vo(e).length},isExported:!0},ku={description:s("Converts a specified string to lowercase."),args:[ma("text (string)",s("The string to convert to lowercase."))],returns:["STRING"],compute:function(e){return Vo(e).toLowerCase()},isExported:!0},Lu={description:s("A segment of a string."),args:[ma("text (string)",s("The string to extract a segment from.")),ma(" (number)",s("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),ma(" (number)",s("The length of the segment to extract."))],returns:["STRING"],compute:function(e,t,i){const o=Vo(e),n=Po(t),r=Po(i);return ko((()=>n>=1),s("The starting_at argument (%s) must be positive greater than one.",n.toString())),ko((()=>r>=0),s("The extract_length argument (%s) must be positive or null.",r.toString())),o.slice(n-1,n+r-1)},isExported:!0},Pu={description:s("Capitalizes each word in a specified string."),args:[ma("text_to_capitalize (string)",s("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase."))],returns:["STRING"],compute:function(e){return Vo(e).replace(Ru,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},Uu={description:s("Replaces part of a text string with different text."),args:[ma("text (string)",s("The text, a part of which will be replaced.")),ma("position (number)",s("The position where the replacement will begin (starting from 1).")),ma("length (number)",s("The number of characters in the text to be replaced.")),ma("new_text (string)",s("The text which will be inserted into the original text."))],returns:["STRING"],compute:function(e,t,i,o){const n=Po(t);ko((()=>n>=1),s("The position (%s) must be greater than or equal to 1.",n.toString()));const r=Vo(e),a=Po(i),l=Vo(o);return r.substring(0,n-1)+l+r.substring(n-1+a)},isExported:!0},Vu={description:s("A substring from the end of a specified string."),args:[ma("text (string)",s("The string from which the right portion will be returned.")),ma("number_of_characters (number, optional)",s("The number of characters to return from the right side of string."))],returns:["STRING"],compute:function(e,...t){const i=t.length?Po(t[0]):1;ko((()=>i>=0),s("The number_of_characters (%s) must be positive or null.",i.toString()));const o=Vo(e),n=o.length;return o.substring(n-i,n)},isExported:!0},zu={description:s("First position of string found in text, ignoring case."),args:[ma("search_for (string)",s("The string to look for within text_to_search.")),ma("text_to_search (string)",s("The text to search for the first occurrence of search_for.")),ma("starting_at (number, default=1)",s("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,i=1){const o=Vo(e).toLowerCase(),n=Vo(t).toLowerCase(),r=Po(i);ko((()=>""!==n),s("The text_to_search must be non-empty.")),ko((()=>r>=1),s("The starting_at (%s) must be greater than or equal to 1.",r.toString()));const a=n.indexOf(o,r-1);return ko((()=>a>=0),s("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",o,n)),a+1},isExported:!0},Bu={description:s("Replaces existing text with new text in a string."),args:[ma("text_to_search (string)",s("The text within which to search and replace.")),ma("search_for (string)",s("The string to search for within text_to_search.")),ma("replace_with (string)",s("The string that will replace search_for.")),ma("occurrence_number (number, optional)",s("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."))],returns:["NUMBER"],compute:function(e,t,i,o){const n=Po(o);ko((()=>n>=0),s("The occurrenceNumber (%s) must be positive or null.",n.toString()));const r=Vo(e),a=Vo(t);if(""===a)return r;const l=Vo(i),c=new RegExp(Ne(a),"g");if(0===n)return r.replace(c,l);let h=0;return r.replace(c,(e=>++h===n?l:e))},isExported:!0},Hu={description:s("Combines text from multiple strings and/or arrays."),args:[ma("delimiter (string)",s(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")),ma("ignore_empty (boolean)",s("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")),ma("text1 (string, range<string>)",s("Any text item. This could be a string, or an array of strings in a range.")),ma("text2 (string, range<string>, repeating)",s("Additional text item(s)."))],returns:["STRING"],compute:function(e,t,...i){const o=Vo(e),n=$o(t);let s=0;return Xo(i,((e,t)=>n&&""===Vo(t)?e:(s++?e+o:"")+Vo(t)),"")},isExported:!0},$u={description:s("Removes space characters."),args:[ma("text (string)",s("The text or reference to a cell containing text to be trimmed."))],returns:["STRING"],compute:function(e){return Vo(e).trim()},isExported:!0},Wu={description:s("Converts a specified string to uppercase."),args:[ma("text (string)",s("The string to convert to uppercase."))],returns:["STRING"],compute:function(e){return Vo(e).toUpperCase()},isExported:!0},Gu={description:s("Converts a number to text according to a specified format."),args:[ma("number (number)",s("The number, date or time to format.")),ma("format (string)",s("The pattern by which to format the number, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){return mi(Po(e),Vo(t))},isExported:!0};var qu=Object.freeze({__proto__:null,CHAR:Tu,CLEAN:Au,CONCATENATE:Mu,EXACT:Ou,FIND:Nu,JOIN:_u,LEFT:Fu,LEN:Du,LOWER:ku,MID:Lu,PROPER:Pu,REPLACE:Uu,RIGHT:Vu,SEARCH:zu,SUBSTITUTE:Bu,TEXTJOIN:Hu,TRIM:$u,UPPER:Wu,TEXT:Gu});const Zu={description:s("Creates a hyperlink in a cell."),args:[ma("url (string)",s("The full URL of the link enclosed in quotation marks.")),ma("link_label (string, optional)",s("The text to display in the cell, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){const i=Vo(e).trim(),o=Vo(t)||i;return""===i?o:Ye(o,i)},isExported:!0};var ju=Object.freeze({__proto__:null,HYPERLINK:Zu});const Xu=[{name:s("Database"),functions:Rc},{name:s("Date"),functions:sh},{name:s("Financial"),functions:Md},{name:s("Info"),functions:Vd},{name:s("Lookup"),functions:ru},{name:s("Logical"),functions:jd},{name:s("Math"),functions:El},{name:s("Misc"),functions:ba},{name:s("Operator"),functions:Iu},{name:s("Statistical"),functions:dc},{name:s("Text"),functions:qu},{name:s("Engineering"),functions:ah},{name:s("Web"),functions:ju}],Yu=/^[A-Z0-9\_\.]+$/;function Ku(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>Qu(e()):Qu(e)}))}function Qu(e){return Array.isArray(e)?e.map((e=>e.map((e=>null==e?void 0:e.value)))):null==e?void 0:e.value}const Ju=new class extends Io{constructor(){super(...arguments),this.mapping={}}add(e,t){if(!(e=e.toUpperCase()).match(Yu))throw new Error(s("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const i=fa(t);return function(e){let t=!1,i=!1,o=!1;for(let n of e){if(n.type.includes("META")&&n.type.length>1)throw new Error(s("Function ${name} has an argument that has been declared with more than one type whose type 'META'. The 'META' type can only be declared alone."));if(t&&!n.repeating)throw new Error(s("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=i||t||o,r=!(n.optional||n.repeating||n.default);if(e&&r)throw new Error(s("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=n.repeating,i=n.optional,o=n.default}}(i.args),this.mapping[e]=function(...e){const t=i.compute.bind(this),o=i.computeFormat?i.computeFormat.bind(this):()=>{};return{value:t(...Ku(e)),format:o(...e)}},super.add(e,i),this}};for(let e of Xu){const t=e.functions;for(let i in t){const o=t[i];o.category=o.category||e.name,i=i.replace(/_/g,"."),Ju.add(i,{isExported:!1,...o})}}function eg(e,t,i){const o=e.model.getters.getActiveSheetId(),n="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(n,{sheetId:o,quantity:i}).isCancelledBecause(65)&&e.raiseError(Ds)}const tg=new ss;tg.add("file",{name:s("File"),sequence:10}).add("edit",{name:s("Edit"),sequence:20}).add("view",{name:s("View"),sequence:30}).add("insert",{name:s("Insert"),sequence:40}).add("format",{name:s("Format"),sequence:50}).add("data",{name:s("Data"),sequence:60}).addChild("save",["file"],{name:s("Save"),description:"Ctrl+S",sequence:10,action:()=>console.log("Not implemented")}).addChild("undo",["edit"],{name:s("Undo"),description:"Ctrl+Z",sequence:10,action:e=>e.model.dispatch("REQUEST_UNDO")}).addChild("redo",["edit"],{name:s("Redo"),description:"Ctrl+Y",sequence:20,action:e=>e.model.dispatch("REQUEST_REDO"),separator:!0}).addChild("copy",["edit"],{name:s("Copy"),description:"Ctrl+C",sequence:30,isReadonlyAllowed:!0,action:Ur}).addChild("cut",["edit"],{name:s("Cut"),description:"Ctrl+X",sequence:40,action:Vr}).addChild("paste",["edit"],{name:s("Paste"),description:"Ctrl+V",sequence:50,action:zr}).addChild("paste_special",["edit"],{name:s("Paste special"),sequence:60,separator:!0,isVisible:Wr}).addChild("paste_special_value",["edit","paste_special"],{name:s("Paste value only"),sequence:10,action:Br}).addChild("paste_special_format",["edit","paste_special"],{name:s("Paste format only"),sequence:20,action:$r}).addChild("sort_range",["data"],{name:s("Sort range"),sequence:20,isVisible:ca,separator:!0}).addChild("sort_ascending",["data","sort_range"],{name:s("Ascending (A ⟶ Z)"),sequence:10,action:aa}).addChild("sort_descending",["data","sort_range"],{name:s("Descending (Z ⟶ A)"),sequence:20,action:la}).addChild("find_and_replace",["edit"],{name:s("Find and replace"),description:"Ctrl+H",sequence:65,isReadonlyAllowed:!0,action:e=>{e.openSidePanel("FindAndReplace",{})},separator:!0}).addChild("edit_delete_cell_values",["edit"],{name:s("Delete values"),sequence:70,action:e=>e.model.dispatch("DELETE_CONTENT",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})}).addChild("edit_delete_row",["edit"],{name:Gr,sequence:80,action:qr,isVisible:e=>Zr("ROW",e)}).addChild("edit_delete_column",["edit"],{name:jr,sequence:90,action:Xr,isVisible:e=>Zr("COL",e)}).addChild("edit_delete_cell_shift_up",["edit"],{name:s("Delete cell and shift up"),sequence:93,action:Qr}).addChild("edit_delete_cell_shift_left",["edit"],{name:s("Delete cell and shift left"),sequence:97,action:Jr}).addChild("edit_unhide_columns",["edit"],{name:s("Unhide all columns"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"COL",elements:Array.from(Array(e.model.getters.getNumberCols(t)).keys())})},isVisible:e=>e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("edit_unhide_rows",["edit"],{name:s("Unhide all rows"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"ROW",elements:Array.from(Array(e.model.getters.getNumberRows(t)).keys())})},isVisible:e=>e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("insert_row_before",["insert"],{name:e=>{const t=kr(e);return 1===t?s("Row above"):s("%s Rows above",t.toString())},sequence:10,action:ea,isVisible:e=>0===e.model.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=kr(e);return 1===t?s("Row below"):s("%s Rows below",t.toString())},sequence:20,action:ta,isVisible:e=>0===e.model.getters.getActiveCols().size,separator:!0}).addChild("insert_column_before",["insert"],{name:e=>{const t=Dr(e);return 1===t?s("Column left"):s("%s Columns left",t.toString())},sequence:30,action:ia,isVisible:e=>0===e.model.getters.getActiveRows().size}).addChild("insert_column_after",["insert"],{name:e=>{const t=Dr(e);return 1===t?s("Column right"):s("%s Columns right",t.toString())},sequence:40,action:oa,isVisible:e=>0===e.model.getters.getActiveRows().size,separator:!0}).addChild("insert_insert_cell_shift_down",["insert"],{name:s("Insert cells and shift down"),sequence:43,action:Yr}).addChild("insert_insert_cell_shift_right",["insert"],{name:s("Insert cells and shift right"),sequence:47,action:Kr,separator:!0}).addChild("insert_chart",["insert"],{name:s("Chart"),sequence:50,action:e=>{const t=e.model.getters,i=e.model.uuidGenerator.uuidv4(),o=t.getActiveSheetId();1===ho(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection();const n={width:536,height:335},s=function(e,t){const{x:i,y:o}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=e.getActiveSheetScrollInfo(),{width:r,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:i+n+Math.max(0,(r-t.width)/2),y:o+s+Math.max(0,(a-t.height)/2)}}(t,n);e.model.dispatch("CREATE_CHART",{sheetId:o,id:i,position:s,size:n,definition:xr(e.model.getters.getSelectedZone(),e.model.getters)}).isSuccessful&&(e.model.dispatch("SELECT_FIGURE",{id:i}),e.openSidePanel("ChartPanel"))}}).addChild("insert_image",["insert"],{name:s("Image"),sequence:55,action:async e=>{if(e.imageProvider){const t=e.model.getters.getActiveSheetId(),i=e.model.uuidGenerator.uuidv4(),o=await async function(e){try{return await e.imageProvider.requestImage()}catch{return void e.raiseError(s("An unexpected error occurred during the image transfer"))}}(e);if(!o)throw new Error("No image provider was given to the environment");const n=fr(e.model.getters,o.size),r=function(e,t){const{x:i,y:o}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=e.getActiveSheetScrollInfo(),r=e.getSheetViewDimension(),a=e.getVisibleRect(e.getActiveMainViewport()),l=Math.min(a.width,r.width-i),c=Math.min(a.height,r.height-o);return{x:i+n+Math.max(0,(l-t.width)/2),y:o+s+Math.max(0,(c-t.height)/2)}}(e.model.getters,n);e.model.dispatch("CREATE_IMAGE",{sheetId:t,figureId:i,position:r,size:n,definition:o})}},isVisible:e=>void 0!==e.imageProvider}).addChild("insert_function",["insert"],{name:s("Function"),sequence:60}).addChild("insert_function_sum",["insert","insert_function"],{name:s("SUM"),action:e=>e.startCellEdition("=SUM("),sequence:0}).addChild("insert_function_average",["insert","insert_function"],{name:s("AVERAGE"),action:e=>e.startCellEdition("=AVERAGE("),sequence:10}).addChild("insert_function_count",["insert","insert_function"],{name:s("COUNT"),action:e=>e.startCellEdition("=COUNT("),sequence:20}).addChild("insert_function_max",["insert","insert_function"],{name:s("MAX"),action:e=>e.startCellEdition("=MAX("),sequence:30}).addChild("insert_function_min",["insert","insert_function"],{name:s("MIN"),action:e=>e.startCellEdition("=MIN("),sequence:40,separator:!0}).addChild("categorie_function_all",["insert","insert_function"],{name:s("All"),sequence:50}).addChild("all_function_list",["insert","insert_function","categorie_function_all"],(()=>ig(Ju.getKeys()))).addChild("categories_function_list",["insert","insert_function"],(()=>{const e=Ju.content;return[...new Set(Ju.getAll().map((e=>e.category)))].filter(it).sort().map(((t,i)=>{const o=Object.keys(e).filter((i=>e[i].category===t));return{name:t,sequence:60+10*i,children:ig(o)}}))})).addChild("insert_link",["insert"],{name:s("Link"),separator:!0,sequence:70,action:sa}).addChild("insert_sheet",["insert"],{name:s("New sheet"),sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSheetIds().indexOf(t)+1,o=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:o,position:i}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})},separator:!0}).addChild("unfreeze_panes",["view"],{name:s("Unfreeze"),sequence:4,isVisible:e=>{const{xSplit:t,ySplit:i}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+i>0},action:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()})}).addChild("freeze_panes",["view"],{name:s("Freeze"),sequence:5,separator:!0}).addChild("unfreeze_rows",["view","freeze_panes"],{name:s("No rows"),action:e=>e.model.dispatch("UNFREEZE_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:5,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).ySplit}).addChild("freeze_first_row",["view","freeze_panes"],{name:s("1 row"),action:e=>eg(e,"ROW",1),isReadonlyAllowed:!0,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{name:s("2 rows"),action:e=>eg(e,"ROW",2),isReadonlyAllowed:!0,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{name:s("Up to current row"),action:e=>{const{bottom:t}=e.model.getters.getSelectedZone();eg(e,"ROW",t+1)},isReadonlyAllowed:!0,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{name:s("No columns"),action:e=>e.model.dispatch("UNFREEZE_COLUMNS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:25,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).xSplit}).addChild("freeze_first_col",["view","freeze_panes"],{name:s("1 column"),action:e=>eg(e,"COL",1),isReadonlyAllowed:!0,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{name:s("2 columns"),action:e=>eg(e,"COL",2),isReadonlyAllowed:!0,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{name:s("Up to current column"),action:e=>{const{right:t}=e.model.getters.getSelectedZone();eg(e,"COL",t+1)},isReadonlyAllowed:!0,sequence:40}).addChild("view_gridlines",["view"],{name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?s("Hide gridlines"):s("Show gridlines"),action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.model.getters.getGridLinesVisibility(t)})},sequence:10}).addChild("view_formulas",["view"],{name:e=>e.model.getters.shouldShowFormulas()?s("Hide formulas"):s("Show formulas"),action:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,sequence:15}).addChild("format_number",["format"],{name:s("Numbers"),sequence:10,separator:!0}).addChild("format_number_automatic",["format","format_number"],{name:_s.Automatic,sequence:10,separator:!0,action:e=>Lr(e,"")}).addChild("format_number_number",["format","format_number"],{name:_s.Number,description:"1,000.12",sequence:20,action:e=>Lr(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:_s.Percent,description:"10.12%",sequence:30,separator:!0,action:e=>Lr(e,"0.00%")}).addChild("format_number_currency",["format","format_number"],{name:_s.Currency,description:"$1,000.12",sequence:37,action:e=>Lr(e,"[$$]#,##0.00")}).addChild("format_number_currency_rounded",["format","format_number"],{name:_s.CurrencyRounded,description:"$1,000",sequence:38,action:e=>Lr(e,"[$$]#,##0")}).addChild("format_custom_currency",["format","format_number"],{name:_s.CustomCurrency,sequence:39,separator:!0,isVisible:e=>void 0!==e.loadCurrencies,action:e=>{e.openSidePanel("CustomCurrency",{})}}).addChild("format_number_date",["format","format_number"],{name:_s.Date,description:"9/26/2008",sequence:40,action:e=>Lr(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:_s.Time,description:"10:43:00 PM",sequence:50,action:e=>Lr(e,"hh:mm:ss a")}).addChild("format_number_date_time",["format","format_number"],{name:_s.DateTime,description:"9/26/2008 22:43:00",sequence:60,action:e=>Lr(e,"m/d/yyyy hh:mm:ss")}).addChild("format_number_duration",["format","format_number"],{name:_s.Duration,description:"27:51:38",sequence:70,separator:!0,action:e=>Lr(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:s("Bold"),sequence:20,description:"Ctrl+B",action:e=>Pr(e,{bold:!e.model.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:s("Italic"),sequence:30,description:"Ctrl+I",action:e=>Pr(e,{italic:!e.model.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:s("Underline"),description:"Ctrl+U",sequence:40,action:e=>Pr(e,{underline:!e.model.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:s("Strikethrough"),sequence:50,action:e=>Pr(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),separator:!0}).addChild("format_font_size",["format"],{name:s("Font size"),sequence:60,separator:!0}).addChild("format_alignment",["format"],{name:s("Alignment"),sequence:70}).addChild("format_alignment_left",["format","format_alignment"],{name:"Left",sequence:10,action:e=>Pr(e,{align:"left"})}).addChild("format_alignment_center",["format","format_alignment"],{name:"Center",sequence:20,action:e=>Pr(e,{align:"center"})}).addChild("format_alignment_right",["format","format_alignment"],{name:"Right",sequence:30,action:e=>Pr(e,{align:"right"}),separator:!0}).addChild("format_alignment_top",["format","format_alignment"],{name:"Top",sequence:40,action:e=>Pr(e,{verticalAlign:"top"})}).addChild("format_alignment_middle",["format","format_alignment"],{name:"Middle",sequence:50,action:e=>Pr(e,{verticalAlign:"middle"})}).addChild("format_alignment_bottom",["format","format_alignment"],{name:"Bottom",sequence:60,action:e=>Pr(e,{verticalAlign:"bottom"}),separator:!0}).addChild("format_wrapping",["format"],{name:s("Wrapping"),sequence:80,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{name:s("Overflow"),sequence:10,action:e=>Pr(e,{wrapping:"overflow"})}).addChild("format_wrapping_wrap",["format","format_wrapping"],{name:s("Wrap"),sequence:20,action:e=>Pr(e,{wrapping:"wrap"})}).addChild("format_wrapping_clip",["format","format_wrapping"],{name:s("Clip"),sequence:30,action:e=>Pr(e,{wrapping:"clip"})}).addChild("format_cf",["format"],{name:s("Conditional formatting"),sequence:90,action:na,separator:!0}).addChild("format_clearFormat",["format"],{name:s("Clear formatting"),sequence:100,action:e=>{e.model.dispatch("CLEAR_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})},separator:!0}).addChild("add_data_filter",["data"],{name:s("Create filter"),sequence:10,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSelection().zones;Mr(e,t,i)},isVisible:e=>!ra(e),isEnabled:e=>(e=>uo(...e.model.getters.getSelectedZones()))(e)}).addChild("remove_data_filter",["data"],{name:s("Remove filter"),sequence:10,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:t,target:e.model.getters.getSelectedZones()})},isVisible:ra});for(let e of de)tg.addChild(`format_font_size_${e}`,["format","format_font_size"],{name:e.toString(),sequence:e,action:t=>Pr(t,{fontSize:e})});function ig(e){return e.sort().map(((e,t)=>({name:e,sequence:10*t,action:t=>t.startCellEdition(`=${e}(`)})))}const og=new class extends Io{addTransformation(e,t,i){for(let o of t)this.content[o]||(this.content[o]=new Map),this.content[o].set(e,i);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},ng={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"};function sg(e,t){const i=ng[e.key];e.shiftKey?t.resizeAnchorZone(i,e.ctrlKey?"end":1):t.moveAnchorCell(i,e.ctrlKey?"end":1)}const rg=new Vi;fo`
|
|
350
|
+
`;class fr extends t.Component{get chartType(){return this.env.model.getters.getChartType(this.props.figure.id)}get chartComponent(){const e=this.chartType,t=pr.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}}fr.template="o-spreadsheet-ChartFigure",fr.components={},fr.props={figure:Object,onFigureDeleted:Function};class vr extends t.Component{get figureId(){return this.props.figure.id}get getImagePath(){return this.env.model.getters.getImagePath(this.figureId)}}function br(e,t){const i=_e(t),o=e.getSheetViewDimension(),n=o.width,s=o.height;if(i.width>n){const e=n/i.width;i.width=n,i.height=i.height*e}if(i.height>s){const e=s/i.height;i.height=s,i.width=i.width*e}return i}vr.template="o-spreadsheet-ImageFigure",vr.components={},vr.props={figure:Object,onFigureDeleted:Function};const Sr=new Io;function Cr(e,t){return{id:"copy",name:s("Copy"),sequence:2,description:"Ctrl+C",action:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("COPY"),await t.clipboard.write(t.model.getters.getClipboardContent())}}}function Er(e,t){return{id:"cut",name:s("Cut"),sequence:3,description:"Ctrl+X",action:async()=>{t.model.dispatch("SELECT_FIGURE",{id:e}),t.model.dispatch("CUT"),await t.clipboard.write(t.model.getters.getClipboardContent())}}}function wr(e,t,i){return{id:"delete",name:s("Delete"),sequence:10,action:()=>{i.model.dispatch("DELETE_FIGURE",{sheetId:i.model.getters.getActiveSheetId(),id:e}),t()}}}Sr.add("chart",{Component:fr,SidePanelComponent:"ChartPanel",menuBuilder:function(e,t,i){return ns([{id:"edit",name:s("Edit"),sequence:1,action:()=>{i.model.dispatch("SELECT_FIGURE",{id:e}),i.openSidePanel("ChartPanel")}},Cr(e,i),Er(e,i),wr(e,t,i)])}}),Sr.add("image",{Component:vr,keepRatio:!0,minFigSize:20,borderWidth:0,menuBuilder:function(e,t,i){return ns([Cr(e,i),Er(e,i),{id:"reset_size",name:s("Reset size"),sequence:4,action:()=>{const t=i.model.getters.getImageSize(e),{height:o,width:n}=br(i.model.getters,t);i.model.dispatch("UPDATE_FIGURE",{sheetId:i.model.getters.getActiveSheetId(),id:e,height:o,width:n})}},wr(e,t,i)])}});const yr=(new Io).add("ADD_COLUMNS_ROWS",(function(e){const t=[];let i=e.base;"after"===e.position&&i++;for(let o=0;o<e.quantity;o++)t.push(o+i);return[{type:"REMOVE_COLUMNS_ROWS",dimension:e.dimension,elements:t,sheetId:e.sheetId}]})).add("REMOVE_COLUMNS_ROWS",(function(e){const t=[],i=[...e.elements].sort(((e,t)=>e-t));for(let o of $e(i)){const i=0===o[0]?0:o[0]-1,n=0===o[0]?"before":"after";t.push({type:"ADD_COLUMNS_ROWS",dimension:e.dimension,quantity:o.length,base:i,sheetId:e.sheetId,position:n})}return t})).add("ADD_MERGE",(function(e){return[{type:"REMOVE_MERGE",sheetId:e.sheetId,target:e.target}]})).add("REMOVE_MERGE",(function(e){return[{type:"ADD_MERGE",sheetId:e.sheetId,target:e.target}]})).add("CREATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetId}]})).add("DELETE_SHEET",(function(e){return[{type:"CREATE_SHEET",sheetId:e.sheetId,position:1}]})).add("DUPLICATE_SHEET",(function(e){return[{type:"DELETE_SHEET",sheetId:e.sheetIdTo}]})).add("CREATE_FIGURE",(function(e){return[{type:"DELETE_FIGURE",id:e.figure.id,sheetId:e.sheetId}]})).add("CREATE_CHART",(function(e){return[{type:"DELETE_FIGURE",id:e.id,sheetId:e.sheetId}]})).add("HIDE_COLUMNS_ROWS",(function(e){return[{type:"UNHIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]})).add("UNHIDE_COLUMNS_ROWS",(function(e){return[{type:"HIDE_COLUMNS_ROWS",sheetId:e.sheetId,dimension:e.dimension,elements:e.elements}]}));for(const e of gn.values())yr.contains(e)||yr.add(e,xr);function xr(e){return[e]}function Ir(e,t){const i=gr.getAll().find((t=>t.match(e.type)));if(!i)throw new Error("Unknown chart type.");return i.transformDefinition(e,t)}function Rr(e,t){var i;let o=e;e.left!==e.right&&(o={...e,left:e.left+1});const s=[$i(o)],r=t.getActiveSheetId(),a=t.getCell({sheetId:r,col:e.left,row:e.top});if(1===ho(e)&&(null==a?void 0:a.content))return{type:"scorecard",title:"",background:(null===(i=a.style)||void 0===i?void 0:i.fillColor)||void 0,keyValue:$i(e),baselineMode:te,baselineColorUp:ie,baselineColorDown:oe};let l="";const c=t.getEvaluatedCellsInZone(r,{...o,bottom:o.top}),h=!!c.find((e=>e.type!==ln.empty&&e.type!==ln.number));if(h){const e=c.filter((e=>e.type!==ln.error&&e.type!==ln.empty)).map((e=>e.formattedValue)),t=e.splice(-1)[0];l=e.join(", "),t&&(l+=(l?" "+n("and")+" ":"")+t)}let d;e.left!==e.right&&(d=$i({...e,right:e.left,top:h?e.top+1:e.top}));const u=o.right===o.left?"none":"top";return nr(d?t.getRangeFromSheetXC(r,d):void 0,t)?{title:l,dataSets:s,labelsAsText:!1,stacked:!1,aggregated:!1,cumulative:!1,labelRange:d,type:"line",dataSetsHaveTitle:h,verticalAxisPosition:"left",legendPosition:u}:{title:l,dataSets:s,labelRange:d,type:"bar",stacked:!1,aggregated:!1,dataSetsHaveTitle:h,verticalAxisPosition:"left",legendPosition:u}}const Tr=[ln.number,ln.error,ln.text,ln.boolean];function Ar(e,t,i,o,n){let r=mn.Success,a=o.right>o.left;if(e.model.getters.doesIntersectMerge(t,o)){let i;a=!1;for(let n=o.top;n<=o.bottom;n++){i=[];for(let s=o.left;s<=o.right;s++){let o=e.model.getters.getMerge({sheetId:t,col:s,row:n});o&&!i.includes(o.id.toString())&&i.push(o.id.toString())}if(i.length>=2){a=!0;break}}}const{col:l,row:c}=i;if(a)r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n});else{const i=e.model.getters.getContiguousZone(t,o);Yi(i,o)?r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n}):e.askConfirmation(s("We found data next to your selection. Since this data was not selected, it will not be sorted. Do you want to extend your selection?"),(()=>{o=i,r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n})}),(()=>{r=e.model.dispatch("SORT_CELLS",{sheetId:t,col:l,row:c,zone:o,sortDirection:n})}))}if(r.isCancelledBecause(63)){const{col:t,row:n}=i;e.model.selection.selectZone({cell:{col:t,row:n},zone:o}),e.raiseError(s("Cannot sort. To sort, select only cells or only merges that have the same size."))}}function Mr(e){const t=e.model.dispatch("CUT");t.isSuccessful||t.isCancelledBecause(19)&&e.raiseError(s("This operation is not allowed with multiple selections."))}const Or={filterOverlap:s("You cannot create overlapping filters."),nonContinuousTargets:s("A filter can only be created on a continuous selection."),mergeInFilter:s("You can't create a filter over a range that contains a merge.")};function Nr(e,t,i){const o=e.model.dispatch("CREATE_FILTER_TABLE",{target:i,sheetId:t});o.isCancelledBecause(78)?e.raiseError(Or.filterOverlap):o.isCancelledBecause(80)?e.raiseError(Or.mergeInFilter):o.isCancelledBecause(81)&&e.raiseError(Or.nonContinuousTargets)}const _r={wrongPasteSelection:s("This operation is not allowed with multiple selections."),willRemoveExistingMerge:s("This operation is not possible due to a merge. Please remove the merges first than try again."),wrongFigurePasteOption:s("Cannot do a special paste of a figure."),frozenPaneOverlap:s("Cannot paste merged cells over a frozen pane.")};function Fr(e,t){t.isSuccessful||(t.reasons.includes(20)?e.raiseError(_r.wrongPasteSelection):t.reasons.includes(2)?e.raiseError(_r.willRemoveExistingMerge):t.reasons.includes(22)?e.raiseError(_r.wrongFigurePasteOption):t.reasons.includes(75)&&e.raiseError(_r.frozenPaneOverlap))}function Dr(e,t,i){const o=e.model.dispatch("PASTE",{target:t,pasteOption:i});Fr(e,o)}function kr(e,t,i){const o=e.model.dispatch("PASTE_FROM_OS_CLIPBOARD",{target:t,text:i});Fr(e,o)}function Lr(e){const t=e.model.getters.getActiveCols();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.right-t.left+1}}function Pr(e){const t=e.model.getters.getActiveRows();if(t.size)return t.size;{const t=e.model.getters.getSelectedZones()[0];return t.bottom-t.top+1}}function Ur(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),format:t})}function Vr(e,t){e.model.dispatch("SET_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones(),style:t})}const zr=async e=>{e.model.dispatch("COPY"),await e.clipboard.write(e.model.getters.getClipboardContent())},Br=async e=>{Mr(e),await e.clipboard.write(e.model.getters.getClipboardContent())},Hr=async e=>Wr(e),$r=async e=>Wr(e,"onlyValue");async function Wr(e,t){const i=e.model.getters.getClipboardTextContent(),o=await e.clipboard.readText();switch(o.status){case"ok":const n=e.model.getters.getSelectedZones();o&&o.content!==i?kr(e,n,o.content):Dr(e,n,t);break;case"notImplemented":e.raiseError(s("Pasting from the context menu is not supported in this browser. Use keyboard shortcuts ctrl+c / ctrl+v instead."));break;case"permissionDenied":e.raiseError(s("Access to the clipboard denied by the browser. Please enable clipboard permission for this page in your browser settings."))}}const Gr=e=>Dr(e,e.model.getters.getSelectedZones(),"onlyFormat"),qr=e=>!e.model.getters.isCutOperation(),Zr=e=>{if(e.model.getters.getSelectedZones().length>1)return s("Delete rows");let t,i;const o=e.model.getters.getActiveRows();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.top,i=o.bottom}return t===i?s("Delete row %s",(t+1).toString()):s("Delete rows %s - %s",(t+1).toString(),(i+1).toString())},jr=e=>{let t=[...e.model.getters.getActiveRows()];if(!t.length){const i=e.model.getters.getSelectedZones()[0];for(let e=i.top;e<=i.bottom;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},Xr=(e,t)=>{const i=t.model.getters.getActiveSheetId(),o=t.model.getters.getElementsFromSelection(e),n=t.model.getters.checkElementsIncludeAllVisibleHeaders(i,e,o),s=t.model.getters.checkElementsIncludeAllNonFrozenHeaders(i,e,o);return!n&&!s},Yr=e=>{if(e.model.getters.getSelectedZones().length>1)return s("Delete columns");let t,i;const o=e.model.getters.getActiveCols();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.left,i=o.right}return t===i?s("Delete column %s",$t(t)):s("Delete columns %s - %s",$t(t),$t(i))},Kr=e=>{let t=[...e.model.getters.getActiveCols()];if(!t.length){const i=e.model.getters.getSelectedZones()[0];for(let e=i.left;e<=i.right;e++)t.push(e)}e.model.dispatch("REMOVE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},Qr=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"ROW"});Fr(e,i)},Jr=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("INSERT_CELL",{zone:t,shiftDimension:"COL"});Fr(e,i)},ea=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"ROW"});Fr(e,i)},ta=e=>{const t=e.model.getters.getSelectedZone(),i=e.model.dispatch("DELETE_CELL",{zone:t,shiftDimension:"COL"});Fr(e,i)},ia=e=>{const t=e.model.getters.getActiveRows();let i,o;if(t.size)i=Math.min(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.top,o=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",base:i,quantity:o,dimension:"ROW"})},oa=e=>{const t=e.model.getters.getActiveRows();let i,o;if(t.size)i=Math.max(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.bottom,o=t.bottom-t.top+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",base:i,quantity:o,dimension:"ROW"})},na=e=>{const t=e.model.getters.getActiveCols();let i,o;if(t.size)i=Math.min(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.left,o=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"before",dimension:"COL",base:i,quantity:o})},sa=e=>{const t=e.model.getters.getActiveCols();let i,o;if(t.size)i=Math.max(...t),o=t.size;else{const t=e.model.getters.getSelectedZones()[0];i=t.right,o=t.right-t.left+1}e.model.dispatch("ADD_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),position:"after",dimension:"COL",base:i,quantity:o})};const ra=e=>{e.openSidePanel("ConditionalFormatting",{selection:e.model.getters.getSelectedZones()})},aa=e=>{let{col:t,row:i}=e.model.getters.getActivePosition();e.model.dispatch("OPEN_CELL_POPOVER",{col:t,row:i,popoverType:"LinkEditor"})},la=e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSelectedZones();return e.model.getters.doesZonesContainFilter(t,i)},ca=e=>{const{anchor:t,zones:i}=e.model.getters.getSelection(),o=e.model.getters.getActiveSheetId();Ar(e,o,t.cell,i[0],"ascending")},ha=e=>{const{anchor:t,zones:i}=e.model.getters.getSelection(),o=e.model.getters.getActiveSheetId();Ar(e,o,t.cell,i[0],"descending")},da=e=>1===e.model.getters.getSelectedZones().length,ua=new as;ua.add("cut",{name:s("Cut"),description:"Ctrl+X",sequence:10,action:Br}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:zr}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:Hr}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:qr}).addChild("paste_value_only",["paste_special"],{name:s("Paste values only"),sequence:10,action:$r}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:Gr}).add("add_row_before",{name:e=>{const t=Pr(e);return 1===t?s("Insert row"):s("Insert %s rows",t.toString())},sequence:70,action:ia,isVisible:da}).add("add_column_before",{name:e=>{const t=Lr(e);return 1===t?s("Insert column"):s("Insert %s columns",t.toString())},sequence:90,action:na,isVisible:da}).add("insert_cell",{name:s("Insert cells"),sequence:100,isVisible:da,separator:!0}).addChild("insert_cell_down",["insert_cell"],{name:s("Shift down"),sequence:10,action:Qr}).addChild("insert_cell_right",["insert_cell"],{name:s("Shift right"),sequence:20,action:Jr}).add("delete_row",{name:Zr,sequence:110,action:jr,isVisible:da}).add("delete_column",{name:Yr,sequence:120,action:Kr,isVisible:da}).add("delete_cell",{name:s("Delete cells"),sequence:130,isVisible:da}).addChild("delete_cell_up",["delete_cell"],{name:s("Shift up"),sequence:10,action:ea}).addChild("delete_cell_down",["delete_cell"],{name:s("Shift left"),sequence:20,action:ta}).add("insert_link",{name:s("Insert link"),separator:!0,sequence:150,action:aa});const ga=new as;ga.add("cut",{name:s("Cut"),description:"Ctrl+X",sequence:10,action:Br}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:zr}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:Hr}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:qr}).addChild("paste_value_only",["paste_special"],{name:s("Paste value only"),sequence:10,action:$r}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:Gr}).add("sort_columns",{name:e=>e.model.getters.getActiveCols().size>1?s("Sort columns"):s("Sort column"),sequence:50,isVisible:da,separator:!0}).addChild("sort_ascending",["sort_columns"],{name:s("Ascending (A ⟶ Z)"),sequence:10,action:ca}).addChild("sort_descending",["sort_columns"],{name:s("Descending (Z ⟶ A)"),sequence:20,action:ha}).add("add_column_before",{name:e=>{const t=Lr(e);return 1===t?s("Insert column left"):s("Insert %s columns left",t.toString())},sequence:70,action:na}).add("add_column_after",{name:e=>{const t=Lr(e);return 1===t?s("Insert column right"):s("Insert %s columns right",t.toString())},sequence:80,action:sa}).add("delete_column",{name:Yr,sequence:90,action:Kr,isVisible:e=>Xr("COL",e)}).add("clear_column",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return s("Clear columns");let t,i;const o=e.model.getters.getActiveCols();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.left,i=o.right}return t===i?s("Clear column %s",$t(t)):s("Clear columns %s - %s",$t(t),$t(i))},sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId(),i=[...e.model.getters.getActiveCols()].map((i=>e.model.getters.getColsZone(t,i,i)));e.model.dispatch("DELETE_CONTENT",{target:i,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_columns",{name:e=>{const t=e.model.getters.getElementsFromSelection("COL");let i=t[0],o=t[t.length-1];return 1===t.length?s("Hide column %s",$t(i).toString()):o-i+1===t.length?s("Hide columns %s - %s",$t(i).toString(),$t(o).toString()):s("Hide columns")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getElementsFromSelection("COL");return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,"COL",i)},separator:!0}).add("unhide_columns",{name:s("Unhide columns"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("COL");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"COL",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("COL").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:s("Conditional formatting"),sequence:110,action:ra});const pa=new as;pa.add("cut",{name:s("Cut"),sequence:10,description:"Ctrl+X",action:Br}).add("copy",{name:s("Copy"),description:"Ctrl+C",sequence:20,isReadonlyAllowed:!0,action:zr}).add("paste",{name:s("Paste"),description:"Ctrl+V",sequence:30,action:Hr}).add("paste_special",{name:s("Paste special"),sequence:40,separator:!0,isVisible:qr}).addChild("paste_value_only",["paste_special"],{name:s("Paste value only"),sequence:10,action:$r}).addChild("paste_format_only",["paste_special"],{name:s("Paste format only"),sequence:20,action:Gr}).add("add_row_before",{name:e=>{const t=Pr(e);return 1===t?s("Insert row above"):s("Insert %s rows above",t.toString())},sequence:50,action:ia}).add("add_row_after",{name:e=>{const t=Pr(e);return 1===t?s("Insert row below"):s("Insert %s rows below",t.toString())},sequence:60,action:oa}).add("delete_row",{name:Zr,sequence:70,action:jr,isVisible:e=>Xr("ROW",e)}).add("clear_row",{name:e=>{if(e.model.getters.getSelectedZones().length>1)return s("Clear rows");let t,i;const o=e.model.getters.getActiveRows();if(0!==o.size)t=Math.min(...o),i=Math.max(...o);else{const o=e.model.getters.getSelectedZones()[0];t=o.top,i=o.bottom}return t===i?s("Clear row %s",(t+1).toString()):s("Clear rows %s - %s",(t+1).toString(),(i+1).toString())},sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),i=[...e.model.getters.getActiveRows()].map((i=>e.model.getters.getRowsZone(t,i,i)));e.model.dispatch("DELETE_CONTENT",{target:i,sheetId:e.model.getters.getActiveSheetId()})}}).add("hide_rows",{name:e=>{const t=e.model.getters.getElementsFromSelection("ROW");let i=t[0],o=t[t.length-1];return 1===t.length?s("Hide row %s",(i+1).toString()):o-i+1===t.length?s("Hide rows %s - %s",(i+1).toString(),(o+1).toString()):s("Hide rows")},sequence:85,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("HIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getElementsFromSelection("ROW");return!e.model.getters.checkElementsIncludeAllVisibleHeaders(t,"ROW",i)},separator:!0}).add("unhide_rows",{name:s("Unhide rows"),sequence:86,action:e=>{const t=e.model.getters.getElementsFromSelection("ROW");e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId(),dimension:"ROW",elements:t})},isVisible:e=>{const t=e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).flat();return e.model.getters.getElementsFromSelection("ROW").some((e=>t.includes(e)))},separator:!0}).add("conditional_formatting",{name:s("Conditional formatting"),sequence:90,action:ra});const ma=/(.*?)\((.*?)\)(.*)/,fa=["ANY","BOOLEAN","DATE","NUMBER","STRING","RANGE","RANGE<BOOLEAN>","RANGE<DATE>","RANGE<NUMBER>","RANGE<STRING>","META"];function va(e,t=""){return function(e){let t,i=e.match(ma),o=i[1].trim(),n=[],s=!1,r=!1,a=!1;for(let e of i[2].split(",")){const i=e.trim().toUpperCase();let o=fa.find((e=>i===e));o?n.push(o):"RANGE<ANY>"===i?n.push("RANGE"):"OPTIONAL"===i?s=!0:"REPEATING"===i?r=!0:"LAZY"===i?a=!0:i.startsWith("DEFAULT=")&&(t=e.trim().slice(8))}let l=i[3].trim();const c={name:o,description:l,type:n};s&&(c.optional=!0);r&&(c.repeating=!0);a&&(c.lazy=!0);void 0!==t&&(c.default=!0,c.defaultValue=t);return c}(`${e} ${t}`)}function ba(e){let t=0,i=0,o=0;for(let n of e.args)t++,n.optional||n.repeating||n.default||i++,n.repeating&&o++;const n=e;return n.minArgRequired=i,n.maxArgPossible=o?1/0:t,n.nbrArgRepeating=o,n.getArgToFocus=function(e,t){if(!t)return e=>e;if(1===t)return t=>Math.min(t,e);const i=e-t;return e=>{if(e<=i)return e;return i+((e-i)%t||t)}}(t,o),n.hidden=e.hidden||!1,n}const Sa={description:s("Apply a large number format"),args:[va("value (number)",s("The number.")),va("unit (string, optional)",s("The formatting unit. Use 'k', 'm', or 'b' to force the unit"))],returns:["NUMBER"],computeFormat:(e,t)=>{const i=Math.abs(Po(e.value)),o=e.format;if(void 0!==t){switch(null==t?void 0:t.value){case"k":return Ti(o,1e3,"k");case"m":return Ti(o,1e6,"m");case"b":return Ti(o,1e9,"b");default:throw new Error(s("The formatting unit should be 'k', 'm' or 'b'."))}}return i<1e5?Ti(o,0,""):i<1e8?Ti(o,1e3,"k"):i<1e11?Ti(o,1e6,"m"):Ti(o,1e9,"b")},compute:function(e){return Po(e)}};var Ca=Object.freeze({__proto__:null,FORMAT_LARGE_NUMBER:Sa});const Ea={description:s("Absolute value of a number."),args:[va("value (number)",s("The number of which to return the absolute value."))],returns:["NUMBER"],compute:function(e){return Math.abs(Po(e))},isExported:!0},wa={description:s("Inverse cosine of a value, in radians."),args:[va("value (number)",s("The value for which to calculate the inverse cosine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>Math.abs(t)<=1),s("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.acos(t)},isExported:!0},ya={description:s("Inverse hyperbolic cosine of a number."),args:[va("value (number)",s("The value for which to calculate the inverse hyperbolic cosine. Must be greater than or equal to 1."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>t>=1),s("The value (%s) must be greater than or equal to 1.",t.toString())),Math.acosh(t)},isExported:!0},xa={description:s("Inverse cotangent of a value."),args:[va("value (number)",s("The value for which to calculate the inverse cotangent."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return(Math.sign(t)||1)*Math.PI/2-Math.atan(t)},isExported:!0},Ia={description:s("Inverse hyperbolic cotangent of a value."),args:[va("value (number)",s("The value for which to calculate the inverse hyperbolic cotangent. Must not be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>Math.abs(t)>1),s("The value (%s) cannot be between -1 and 1 inclusive.",t.toString())),Math.log((t+1)/(t-1))/2},isExported:!0},Ra={description:s("Inverse sine of a value, in radians."),args:[va("value (number)",s("The value for which to calculate the inverse sine. Must be between -1 and 1, inclusive."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>Math.abs(t)<=1),s("The value (%s) must be between -1 and 1 inclusive.",t.toString())),Math.asin(t)},isExported:!0},Ta={description:s("Inverse hyperbolic sine of a number."),args:[va("value (number)",s("The value for which to calculate the inverse hyperbolic sine."))],returns:["NUMBER"],compute:function(e){return Math.asinh(Po(e))},isExported:!0},Aa={description:s("Inverse tangent of a value, in radians."),args:[va("value (number)",s("The value for which to calculate the inverse tangent."))],returns:["NUMBER"],compute:function(e){return Math.atan(Po(e))},isExported:!0},Ma={description:s("Angle from the X axis to a point (x,y), in radians."),args:[va("x (number)",s("The x coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis.")),va("y (number)",s("The y coordinate of the endpoint of the line segment for which to calculate the angle from the x-axis."))],returns:["NUMBER"],compute:function(e,t){const i=Po(e),o=Po(t);return ko((()=>0!==i||0!==o),s("Function [[FUNCTION_NAME]] caused a divide by zero error.")),Math.atan2(o,i)},isExported:!0},Oa={description:s("Inverse hyperbolic tangent of a number."),args:[va("value (number)",s("The value for which to calculate the inverse hyperbolic tangent. Must be between -1 and 1, exclusive."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>Math.abs(t)<1),s("The value (%s) must be between -1 and 1 exclusive.",t.toString())),Math.atanh(t)},isExported:!0},Na={description:s("Rounds number up to nearest multiple of factor."),args:[va("value (number)",s("The value to round up to the nearest integer multiple of factor.")),va("factor (number, default=1)",s("The number to whose multiples value will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Po(e),o=Po(t);return ko((()=>o>=0||i<=0),s("The factor (%s) must be positive when the value (%s) is positive.",o.toString(),i.toString())),o?Math.ceil(i/o)*o:0},isExported:!0},_a={description:s("Rounds number up to nearest multiple of factor."),args:[va("number (number)",s("The value to round up to the nearest integer multiple of significance.")),va("significance (number, default=1)",s("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),va("mode (number, default=0)",s("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded towards zero. Otherwise, it is rounded away from zero."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let o=Po(t);if(0===o)return 0;const n=Po(e);if(o=Math.abs(o),n>=0)return Math.ceil(n/o)*o;return 0===Po(i)?-Math.floor(Math.abs(n)/o)*o:-Math.ceil(Math.abs(n)/o)*o},isExported:!0},Fa={description:s("Rounds number up to nearest multiple of factor."),args:[va("number (number)",s("The value to round up to the nearest integer multiple of significance.")),va("significance (number, default=1)",s("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){return _a.compute(e,t,0)},isExported:!0},Da={description:s("Cosine of an angle provided in radians."),args:[va("angle (number)",s("The angle to find the cosine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.cos(Po(e))},isExported:!0},ka={description:s("Hyperbolic cosine of any real number."),args:[va("value (number)",s("Any real value to calculate the hyperbolic cosine of."))],returns:["NUMBER"],compute:function(e){return Math.cosh(Po(e))},isExported:!0},La={description:s("Cotangent of an angle provided in radians."),args:[va("angle (number)",s("The angle to find the cotangent of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tan(t)},isExported:!0},Pa={description:s("Hyperbolic cotangent of any real number."),args:[va("value (number)",s("Any real value to calculate the hyperbolic cotangent of."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.tanh(t)},isExported:!0},Ua={description:s("Number of empty values."),args:[va("value1 (any, range)",s("The first value or range in which to count the number of blanks.")),va("value2 (any, range, repeating)",s("Additional values or ranges in which to count the number of blanks."))],returns:["NUMBER"],compute:function(...e){return Xo(e,((e,t)=>null==t||""===t?e+1:e),0)},isExported:!0},Va={description:s("A conditional count across a range."),args:[va("range (range)",s("The range that is tested against criterion.")),va("criterion (string)",s("The pattern or test to apply to range."))],returns:["NUMBER"],compute:function(...e){let t=0;return tn(e,((e,i)=>{t+=1})),t},isExported:!0},za={description:s("Count values depending on multiple criteria."),args:[va("criteria_range1 (range)",s("The range to check against criterion1.")),va("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),va("criteria_range2 (any, range, repeating)",s("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),va("criterion2 (string, repeating)",s("Additional criteria to check."))],returns:["NUMBER"],compute:function(...e){let t=0;return tn(e,((e,i)=>{t+=1})),t},isExported:!0};function Ba(e){switch(e){case void 0:case"":case null:return!1;default:return!0}}const Ha={description:s("Counts number of unique values in a range."),args:[va("value1 (any, range)",s("The first value or range to consider for uniqueness.")),va("value2 (any, range, repeating)",s("Additional values or ranges to consider for uniqueness."))],returns:["NUMBER"],compute:function(...e){return Xo(e,((e,t)=>Ba(t)?e.add(t):e),new Set).size}},$a={description:s("Counts number of unique values in a range, filtered by a set of criteria."),args:[va("range (range)",s("The range of cells from which the number of unique values will be counted.")),va("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),va("criterion1 (string)",s("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),va("criteria_range2 (any, range, repeating)",s("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),va("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=new Set;return tn(t,((t,o)=>{const n=e[t][o];Ba(n)&&i.add(n)})),i.size}},Wa={description:s("Cosecant of an angle provided in radians."),args:[va("angle (number)",s("The angle to find the cosecant of, in radians."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sin(t)},isExported:!0},Ga={description:s("Hyperbolic cosecant of any real number."),args:[va("value (number)",s("Any real value to calculate the hyperbolic cosecant of."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),1/Math.sinh(t)},isExported:!0},qa={description:s("Converts from another base to decimal."),args:[va("value (string)",s("The number to convert.")),va(",base (number)",s("The base to convert the value from."))],returns:["NUMBER"],compute:function(e,t){let i=Po(t);i=Math.floor(i),ko((()=>2<=i&&i<=36),s("The base (%s) must be between 2 and 36 inclusive.",i.toString()));const o=Vo(e);if(""===o)return 0;ko((()=>!!o.match(/^-?[a-z0-9]+$/i)),s("The value (%s) must be a valid base %s representation.",o,i.toString()));const n=parseInt(o,i);return ko((()=>!isNaN(n)),s("The value (%s) must be a valid base %s representation.",o,i.toString())),n},isExported:!0},Za={description:s("Converts an angle value in radians to degrees."),args:[va("angle (number)",s("The angle to convert from radians to degrees."))],returns:["NUMBER"],compute:function(e){return 180*Po(e)/Math.PI},isExported:!0},ja={description:s("Euler's number, e (~2.718) raised to a power."),args:[va("value (number)",s("The exponent to raise e."))],returns:["NUMBER"],compute:function(e){return Math.exp(Po(e))},isExported:!0},Xa={description:s("Rounds number down to nearest multiple of factor."),args:[va("value (number)",s("The value to round down to the nearest integer multiple of factor.")),va("factor (number, default=1)",s("The number to whose multiples value will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){const i=Po(e),o=Po(t);return ko((()=>o>=0||i<=0),s("The factor (%s) must be positive when the value (%s) is positive.",o.toString(),i.toString())),o?Math.floor(i/o)*o:0},isExported:!0},Ya={description:s("Rounds number down to nearest multiple of factor."),args:[va("number (number)",s("The value to round down to the nearest integer multiple of significance.")),va("significance (number, default=1)",s("The number to whose multiples number will be rounded. The sign of significance will be ignored.")),va("mode (number, default=0)",s("If number is negative, specifies the rounding direction. If 0 or blank, it is rounded away from zero. Otherwise, it is rounded towards zero."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1,i=0){let o=Po(t);if(0===o)return 0;const n=Po(e);if(o=Math.abs(o),n>=0)return Math.floor(n/o)*o;return 0===Po(i)?-Math.ceil(Math.abs(n)/o)*o:-Math.floor(Math.abs(n)/o)*o},isExported:!0},Ka={description:s("Rounds number down to nearest multiple of factor."),args:[va("number (number)",s("The value to round down to the nearest integer multiple of significance.")),va("significance (number, default=1)",s("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return Ya.compute(e,t,0)},isExported:!0},Qa={description:s("Whether the provided value is even."),args:[va("value (number)",s("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Uo(e);return!(1&Math.floor(Math.abs(t)))},isExported:!0},Ja={description:s("Rounds number up to nearest multiple of factor."),args:[va("number (number)",s("The value to round up to the nearest integer multiple of significance.")),va("significance (number, default=1)",s("The number to whose multiples number will be rounded."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=1){return _a.compute(e,t,0)},isExported:!0},el={description:s("Whether the provided value is even."),args:[va("value (number)",s("The value to be verified as even."))],returns:["BOOLEAN"],compute:function(e){const t=Uo(e);return!!(1&Math.floor(Math.abs(t)))},isExported:!0},tl={description:s("The logarithm of a number, base e (euler's number)."),args:[va("value (number)",s("The value for which to calculate the logarithm, base e."))],returns:["NUMBER"],compute:function(e){const t=Po(e);return ko((()=>t>0),s("The value (%s) must be strictly positive.",t.toString())),Math.log(t)},isExported:!0},il={description:s("Modulo (remainder) operator."),args:[va("dividend (number)",s("The number to be divided to find the remainder.")),va("divisor (number)",s("The number to divide by."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Po(t);ko((()=>0!==i),s("The divisor must be different from 0."));const o=Po(e)%i;return o>0&&i<0||o<0&&i>0?o+i:o},isExported:!0},ol={description:s("Rounds a number up to the nearest odd integer."),args:[va("value (number)",s("The value to round to the next greatest odd number."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Po(e);let i=Math.ceil(Math.abs(t));return i=1&i?i:i+1,t<0?-i:i},isExported:!0},nl={description:s("The number pi."),args:[],returns:["NUMBER"],compute:function(){return Math.PI},isExported:!0},sl={description:s("A number raised to a power."),args:[va("base (number)",s("The number to raise to the exponent power.")),va("exponent (number)",s("The exponent to raise base to."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){const i=Po(e),o=Po(t);return ko((()=>i>=0||Number.isInteger(o)),s("The exponent (%s) must be an integer when the base is negative.",o.toString())),Math.pow(i,o)},isExported:!0},rl={description:s("Result of multiplying a series of numbers together."),args:[va("factor1 (number, range<number>)",s("The first number or range to calculate for the product.")),va("factor2 (number, range<number>, repeating)",s("More numbers or ranges to calculate for the product."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0,i=1;for(let o of e)if(Array.isArray(o))for(let e of o)for(let o of e)"number"==typeof o&&(i*=o,t+=1);else null!=o&&(i*=Uo(o),t+=1);return 0===t?0:i},isExported:!0},al={description:s("A random number between 0 inclusive and 1 exclusive."),args:[],returns:["NUMBER"],compute:function(){return Math.random()},isExported:!0},ll={description:s("Random integer between two values, inclusive."),args:[va("low (number)",s("The low end of the random range.")),va("high (number)",s("The high end of the random range."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t){let i=Po(e);Number.isInteger(i)||(i=Math.ceil(i));let o=Po(t);return Number.isInteger(o)||(o=Math.floor(o)),ko((()=>i<=o),s("The high (%s) must be greater than or equal to the low (%s).",o.toString(),i.toString())),i+Math.ceil((o-i+1)*Math.random())-1},isExported:!0},cl={description:s("Rounds a number according to standard rules."),args:[va("value (number)",s("The value to round to places number of places.")),va("places (number, default=0)",s("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Po(e);let o=Po(t);const n=Math.abs(i);let s;return 0===o?s=Math.round(n):(Number.isInteger(o)||(o=Math.trunc(o)),s=Math.round(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?s:-s},isExported:!0},hl={description:s("Rounds down a number."),args:[va("value (number)",s("The value to round to places number of places, always rounding down.")),va("places (number, default=0)",s("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Po(e);let o=Po(t);const n=Math.abs(i);let s;return 0===o?s=Math.floor(n):(Number.isInteger(o)||(o=Math.trunc(o)),s=Math.floor(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?s:-s},isExported:!0},dl={description:s("Rounds up a number."),args:[va("value (number)",s("The value to round to places number of places, always rounding up.")),va("places (number, default=0)",s("The number of decimal places to which to round."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Po(e);let o=Po(t);const n=Math.abs(i);let s;return 0===o?s=Math.ceil(n):(Number.isInteger(o)||(o=Math.trunc(o)),s=Math.ceil(n*Math.pow(10,o))/Math.pow(10,o)),i>=0?s:-s},isExported:!0},ul={description:s("Secant of an angle provided in radians."),args:[va("angle (number)",s("The angle to find the secant of, in radians."))],returns:["NUMBER"],compute:function(e){return 1/Math.cos(Po(e))},isExported:!0},gl={description:s("Hyperbolic secant of any real number."),args:[va("value (number)",s("Any real value to calculate the hyperbolic secant of."))],returns:["NUMBER"],compute:function(e){return 1/Math.cosh(Po(e))},isExported:!0},pl={description:s("Sine of an angle provided in radians."),args:[va("angle (number)",s("The angle to find the sine of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.sin(Po(e))},isExported:!0},ml={description:s("Hyperbolic sine of any real number."),args:[va("value (number)",s("Any real value to calculate the hyperbolic sine of."))],returns:["NUMBER"],compute:function(e){return Math.sinh(Po(e))},isExported:!0},fl={description:s("Positive square root of a positive number."),args:[va("value (number)",s("The number for which to calculate the positive square root."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){const t=Po(e);return ko((()=>t>=0),s("The value (%s) must be positive or null.",t.toString())),Math.sqrt(t)},isExported:!0},vl={description:s("Sum of a series of numbers and/or cells."),args:[va("value1 (number, range<number>)",s("The first number or range to add together.")),va("value2 (number, range<number>, repeating)",s("Additional numbers or ranges to add to value1."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){return Yo(e,((e,t)=>e+t),0)},isExported:!0},bl={description:s("A conditional sum across a range."),args:[va("criteria_range (range)",s("The range which is tested against criterion.")),va("criterion (string)",s("The pattern or test to apply to range.")),va("sum_range (range, default=criteria_range)",s("The range to be summed, if different from range."))],returns:["NUMBER"],compute:function(e,t,i){void 0===i&&(i=e);let o=0;return tn([e,t],((e,t)=>{const n=i[e][t];"number"==typeof n&&(o+=n)})),o},isExported:!0},Sl={description:s("Sums a range depending on multiple criteria."),args:[va("sum_range (range)",s("The range to sum.")),va("criteria_range1 (range)",s("The range to check against criterion1.")),va("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),va("criteria_range2 (any, range, repeating)",s("Additional ranges to check.")),va("criterion2 (string, repeating)",s("Additional criteria to check."))],returns:["NUMBER"],compute:function(e,...t){let i=0;return tn(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i+=n)})),i},isExported:!0},Cl={description:s("Tangent of an angle provided in radians."),args:[va("angle (number)",s("The angle to find the tangent of, in radians."))],returns:["NUMBER"],compute:function(e){return Math.tan(Po(e))},isExported:!0},El={description:s("Hyperbolic tangent of any real number."),args:[va("value (number)",s("Any real value to calculate the hyperbolic tangent of."))],returns:["NUMBER"],compute:function(e){return Math.tanh(Po(e))},isExported:!0},wl={description:s("Truncates a number."),args:[va("value (number)",s("The value to be truncated.")),va("places (number, default=0)",s("The number of significant digits to the right of the decimal point to retain."))],returns:["NUMBER"],computeFormat:e=>null==e?void 0:e.format,compute:function(e,t=0){const i=Po(e);let o=Po(t);return 0===o?Math.trunc(i):(Number.isInteger(o)||(o=Math.trunc(o)),Math.trunc(i*Math.pow(10,o))/Math.pow(10,o))},isExported:!0};var yl=Object.freeze({__proto__:null,ABS:Ea,ACOS:wa,ACOSH:ya,ACOT:xa,ACOTH:Ia,ASIN:Ra,ASINH:Ta,ATAN:Aa,ATAN2:Ma,ATANH:Oa,CEILING:Na,CEILING_MATH:_a,CEILING_PRECISE:Fa,COS:Da,COSH:ka,COT:La,COTH:Pa,COUNTBLANK:Ua,COUNTIF:Va,COUNTIFS:za,COUNTUNIQUE:Ha,COUNTUNIQUEIFS:$a,CSC:Wa,CSCH:Ga,DECIMAL:qa,DEGREES:Za,EXP:ja,FLOOR:Xa,FLOOR_MATH:Ya,FLOOR_PRECISE:Ka,ISEVEN:Qa,ISO_CEILING:Ja,ISODD:el,LN:tl,MOD:il,ODD:ol,PI:nl,POWER:sl,PRODUCT:rl,RAND:al,RANDBETWEEN:ll,ROUND:cl,ROUNDDOWN:hl,ROUNDUP:dl,SEC:ul,SECH:gl,SIN:pl,SINH:ml,SQRT:fl,SUM:vl,SUMIF:bl,SUMIFS:Sl,TAN:Cl,TANH:El,TRUNC:wl});function xl(e,t,i){let o=[],n=[],r=0,a=0;qo([e],(e=>{o.push(e),r+=1})),qo([t],(e=>{n.push(e),a+=1})),ko((()=>r===a),s("[[FUNCTION_NAME]] has mismatched argument count %s vs %s.",r.toString(),a.toString()));let l=0,c=0,h=0;for(let e=0;e<r;e++){const t=o[e],i=n[e];"number"==typeof t&&"number"==typeof i&&(l+=1,c+=t,h+=i)}ko((()=>0!==l&&(!i||1!==l)),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const d=c/l,u=h/l;let g=0;for(let e=0;e<r;e++){const t=o[e],i=n[e];"number"==typeof t&&"number"==typeof i&&(g+=(t-d)*(i-u))}return g/(l-(i?1:0))}function Il(e,t,i){let o=0,n=0;const r=i?Ko:Yo;n=r(e,((e,t)=>(o+=1,e+t)),0),ko((()=>0!==o&&(!t||1!==o)),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const a=n/o;return r(e,((e,t)=>e+Math.pow(t-a,2)),0)/(o-(t?1:0))}function Rl(e,t,i){const o=Po(t);ko((()=>i?0<=o&&o<=1:0<o&&o<1),s("Function [[FUNCTION_NAME]] parameter 2 value is out of range."));let n,r=[],a=0;return qo(e,(e=>{"number"==typeof e&&(n=sn(r,e,"nextSmaller","asc",r.length,((e,t)=>e[t])),r.splice(n+1,0,e),a++)})),ko((()=>0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),i||ko((()=>1/(a+1)<=o&&o<=a/(a+1)),s("Function [[FUNCTION_NAME]] parameter 2 value is out of range.")),ri(r,o,i)}const Tl={description:s("Average magnitude of deviations from mean."),args:[va("value1 (number, range<number>)",s("The first value or range of the sample.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){let t=0;const i=Yo(e,((e,i)=>(t+=1,e+i)),0);ko((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error."));const o=i/t;return Yo(e,((e,t)=>e+Math.abs(o-t)),0)/t},isExported:!0},Al={description:s("Numerical average value in a dataset, ignoring text."),args:[va("value1 (number, range<number>)",s("The first value or range to consider when calculating the average value.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the average value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const i=Yo(e,((e,i)=>(t+=1,e+i)),0);return ko((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},Ml=s("[[FUNCTION_NAME]] has mismatched range sizes."),Ol=s("[[FUNCTION_NAME]] expects the weight to be positive or equal to 0."),Nl={description:s("Weighted average."),args:[va("values (number, range<number>)",s("Values to average.")),va("weights (number, range<number>)",s("Weights for each corresponding value.")),va("additional_values (number, range<number>, repeating)",s("Additional values to average.")),va("additional_weights (number, range<number>, repeating)",s("Additional weights."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t,i,o=0,n=0;ko((()=>e.length%2==0),s("Wrong number of Argument[]. Expected an even number of Argument[]."));for(let r=0;r<e.length-1;r+=2)if(t=e[r],i=e[r+1],Array.isArray(t)){ko((()=>Array.isArray(i)),Ml);let e=t.length,r=t[0].length;ko((()=>e===i.length&&r===i[0].length),Ml);for(let a=0;a<e;a++)for(let e=0;e<r;e++){let r=t[a][e],l=i[a][e],c="number"==typeof r,h="number"==typeof l;ko((()=>c===h),s("[[FUNCTION_NAME]] expects number values.")),h&&(ko((()=>l>=0),Ol),o+=r*l,n+=l)}}else i=Po(i),t=Po(t),ko((()=>i>=0),Ol),o+=t*i,n+=i;return ko((()=>0!==n),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/n}},_l={description:s("Numerical average value in a dataset."),args:[va("value1 (number, range<number>)",s("The first value or range to consider when calculating the average value.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the average value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=0;const i=Ko(e,((e,i)=>(t+=1,e+i)),0);return ko((()=>0!==t),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),i/t},isExported:!0},Fl={description:s("Average of values depending on criteria."),args:[va("criteria_range (range)",s("The range to check against criterion.")),va("criterion (string)",s("The pattern or test to apply to criteria_range.")),va("average_range (range, default=criteria_range)",s("The range to average. If not included, criteria_range is used for the average instead."))],returns:["NUMBER"],compute:function(e,t,i){null==i&&(i=e);let o=0,n=0;return tn([e,t],((t,s)=>{const r=(i||e)[t][s];"number"==typeof r&&(o+=1,n+=r)})),ko((()=>0!==o),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),n/o},isExported:!0},Dl={description:s("Average of values depending on multiple criteria."),args:[va("average_range (range)",s("The range to average.")),va("criteria_range1 (range)",s("The range to check against criterion1.")),va("criterion1 (string)",s("The pattern or test to apply to criteria_range1.")),va("criteria_range2 (any, range, repeating)",s("Additional criteria_range and criterion to check.")),va("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=0,o=0;return tn(t,((t,n)=>{const s=e[t][n];"number"==typeof s&&(i+=1,o+=s)})),ko((()=>0!==i),s("Evaluation of function [[FUNCTION_NAME]] caused a divide by zero error.")),o/i},isExported:!0},kl={description:s("The number of numeric values in dataset."),args:[va("value1 (number, range<number>)",s("The first value or range to consider when counting.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){let t=0;for(let i of e)if(Array.isArray(i))for(let e of i)for(let i of e)"number"==typeof i&&(t+=1);else("string"!=typeof i||oi(i)||Ee(i))&&(t+=1);return t},isExported:!0},Ll={description:s("The number of values in a dataset."),args:[va("value1 (any, range)",s("The first value or range to consider when counting.")),va("value2 (any, range, repeating)",s("Additional values or ranges to consider when counting."))],returns:["NUMBER"],compute:function(...e){return Xo(e,((e,t)=>null!=t?e+1:e),0)},isExported:!0},Pl={description:s("The covariance of a dataset."),args:[va("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),va("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return xl(e,t,!1)},isExported:!0},Ul={description:s("The covariance of a dataset."),args:[va("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),va("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return xl(e,t,!1)},isExported:!0},Vl={description:s("The sample covariance of a dataset."),args:[va("data_y (any, range)",s("The range representing the array or matrix of dependent data.")),va("data_x (any, range)",s("The range representing the array or matrix of independent data."))],returns:["NUMBER"],compute:function(e,t){return xl(e,t,!0)},isExported:!0},zl={description:s("Nth largest element from a data set."),args:[va("data (any, range)",s("Array or range containing the dataset to consider.")),va("n (number)",s("The rank from largest to smallest of the element to return."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const i=Math.trunc(Po(t));let o,n=[],r=0;qo([e],(e=>{"number"==typeof e&&(o=sn(n,e,"nextSmaller","asc",n.length,((e,t)=>e[t])),n.splice(o+1,0,e),r++,r>i&&(n.shift(),r--))}));const a=n.shift();return ko((()=>void 0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),ko((()=>r>=i),s("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},Bl={description:s("Maximum value in a numeric dataset."),args:[va("value1 (number, range<number>)",s("The first value or range to consider when calculating the maximum value.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the maximum value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Yo(e,((e,t)=>e<t?t:e),-1/0);return t===-1/0?0:t},isExported:!0},Hl={description:s("Maximum numeric value in a dataset."),args:[va("value1 (any, range)",s("The first value or range to consider when calculating the maximum value.")),va("value2 (any, range, repeating)",s("Additional values or ranges to consider when calculating the maximum value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Ko(e,((e,t)=>Math.max(t,e)),-1/0);return t===-1/0?0:t},isExported:!0},$l={description:s("Returns the maximum value in a range of cells, filtered by a set of criteria."),args:[va("range (range)",s("The range of cells from which the maximum will be determined.")),va("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),va("criterion1 (string)",s("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),va("criteria_range2 (any, range, repeating)",s("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),va("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=-1/0;return tn(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i=i<n?n:i)})),i===-1/0?0:i},isExported:!0},Wl={description:s("Median value in a numeric dataset."),args:[va("value1 (any, range)",s("The first value or range to consider when calculating the median value.")),va("value2 (any, range, repeating)",s("Additional values or ranges to consider when calculating the median value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){let t=[];return Zo(e,(e=>{t.push(e)})),Rl(t,.5,!0)},isExported:!0},Gl={description:s("Minimum value in a numeric dataset."),args:[va("value1 (number, range<number>)",s("The first value or range to consider when calculating the minimum value.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the minimum value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Yo(e,((e,t)=>t<e?t:e),1/0);return t===1/0?0:t},isExported:!0},ql={description:s("Minimum numeric value in a dataset."),args:[va("value1 (number, range<number>)",s("The first value or range to consider when calculating the minimum value.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to consider when calculating the minimum value."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(...e){const t=Ko(e,((e,t)=>Math.min(t,e)),1/0);return t===1/0?0:t},isExported:!0},Zl={description:s("Returns the minimum value in a range of cells, filtered by a set of criteria."),args:[va("range (range)",s("The range of cells from which the minimum will be determined.")),va("criteria_range1 (range)",s("The range of cells over which to evaluate criterion1.")),va("criterion1 (string)",s("The pattern or test to apply to criteria_range1, such that each cell that evaluates to TRUE will be included in the filtered set.")),va("criteria_range2 (any, range, repeating)",s("Additional ranges over which to evaluate the additional criteria. The filtered set will be the intersection of the sets produced by each criterion-range pair.")),va("criterion2 (string, repeating)",s("The pattern or test to apply to criteria_range2."))],returns:["NUMBER"],compute:function(e,...t){let i=1/0;return tn(t,((t,o)=>{const n=e[t][o];"number"==typeof n&&(i=i>n?n:i)})),i===1/0?0:i},isExported:!0},jl={description:s("Value at a given percentile of a dataset."),args:[va("data (any, range)",s("The array or range containing the dataset to consider.")),va("percentile (number)",s("The percentile whose value within data will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Yl.compute(e,t)},isExported:!0},Xl={description:s("Value at a given percentile of a dataset exclusive of 0 and 1."),args:[va("data (any, range)",s("The array or range containing the dataset to consider.")),va("percentile (number)",s("The percentile, exclusive of 0 and 1, whose value within 'data' will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Rl([e],t,!1)},isExported:!0},Yl={description:s("Value at a given percentile of a dataset."),args:[va("data (any, range)",s("The array or range containing the dataset to consider.")),va("percentile (number)",s("The percentile whose value within data will be calculated and returned."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Rl([e],t,!0)},isExported:!0},Kl={description:s("Value nearest to a specific quartile of a dataset."),args:[va("data (any, range)",s("The array or range containing the dataset to consider.")),va("quartile_number (number)",s("Which quartile value to return."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Jl.compute(e,t)},isExported:!0},Ql={description:s("Value nearest to a specific quartile of a dataset exclusive of 0 and 4."),args:[va("data (any, range)",s("The array or range containing the dataset to consider.")),va("quartile_number (number)",s("Which quartile value, exclusive of 0 and 4, to return."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Rl([e],.25*Math.trunc(Po(t)),!1)},isExported:!0},Jl={description:s("Value nearest to a specific quartile of a dataset."),args:[va("data (any, range)",s("The array or range containing the dataset to consider.")),va("quartile_number (number)",s("Which quartile value to return."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){return Rl([e],.25*Math.trunc(Po(t)),!0)},isExported:!0},ec={description:s("Nth smallest element in a data set."),args:[va("data (any, range)",s("The array or range containing the dataset to consider.")),va("n (number)",s("The rank from smallest to largest of the element to return."))],returns:["NUMBER"],computeFormat:e=>{var t;return Array.isArray(e)?null===(t=e[0][0])||void 0===t?void 0:t.format:null==e?void 0:e.format},compute:function(e,t){const i=Math.trunc(Po(t));let o,n=[],r=0;qo([e],(e=>{"number"==typeof e&&(o=sn(n,e,"nextSmaller","asc",n.length,((e,t)=>e[t])),n.splice(o+1,0,e),r++,r>i&&(n.pop(),r--))}));const a=n.pop();return ko((()=>void 0!==a),s("[[FUNCTION_NAME]] has no valid input data.")),ko((()=>r>=i),s("Function [[FUNCTION_NAME]] parameter 2 value (%s) is out of range.",i.toString())),a},isExported:!0},tc={description:s("Standard deviation."),args:[va("value1 (number, range<number>)",s("The first value or range of the sample.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(ac.compute(...e))},isExported:!0},ic={description:s("Standard deviation of entire population."),args:[va("value1 (number, range<number>)",s("The first value or range of the population.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(lc.compute(...e))},isExported:!0},oc={description:s("Standard deviation."),args:[va("value1 (number, range<number>)",s("The first value or range of the sample.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(cc.compute(...e))},isExported:!0},nc={description:s("Standard deviation of sample (text as 0)."),args:[va("value1 (number, range<number>)",s("The first value or range of the sample.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(hc.compute(...e))},isExported:!0},sc={description:s("Standard deviation of entire population."),args:[va("value1 (number, range<number>)",s("The first value or range of the population.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(dc.compute(...e))},isExported:!0},rc={description:s("Standard deviation of entire population (text as 0)."),args:[va("value1 (number, range<number>)",s("The first value or range of the population.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Math.sqrt(uc.compute(...e))},isExported:!0},ac={description:s("Variance."),args:[va("value1 (number, range<number>)",s("The first value or range of the sample.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Il(e,!0,!1)},isExported:!0},lc={description:s("Variance of entire population."),args:[va("value1 (number, range<number>)",s("The first value or range of the population.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Il(e,!1,!1)},isExported:!0},cc={description:s("Variance."),args:[va("value1 (number, range<number>)",s("The first value or range of the sample.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Il(e,!0,!1)},isExported:!0},hc={description:s("Variance of sample (text as 0)."),args:[va("value1 (number, range<number>)",s("The first value or range of the sample.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the sample."))],returns:["NUMBER"],compute:function(...e){return Il(e,!0,!0)},isExported:!0},dc={description:s("Variance of entire population."),args:[va("value1 (number, range<number>)",s("The first value or range of the population.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Il(e,!1,!1)},isExported:!0},uc={description:s("Variance of entire population (text as 0)."),args:[va("value1 (number, range<number>)",s("The first value or range of the population.")),va("value2 (number, range<number>, repeating)",s("Additional values or ranges to include in the population."))],returns:["NUMBER"],compute:function(...e){return Il(e,!1,!0)},isExported:!0};var gc=Object.freeze({__proto__:null,AVEDEV:Tl,AVERAGE:Al,AVERAGE_WEIGHTED:Nl,AVERAGEA:_l,AVERAGEIF:Fl,AVERAGEIFS:Dl,COUNT:kl,COUNTA:Ll,COVAR:Pl,COVARIANCE_P:Ul,COVARIANCE_S:Vl,LARGE:zl,MAX:Bl,MAXA:Hl,MAXIFS:$l,MEDIAN:Wl,MIN:Gl,MINA:ql,MINIFS:Zl,PERCENTILE:jl,PERCENTILE_EXC:Xl,PERCENTILE_INC:Yl,QUARTILE:Kl,QUARTILE_EXC:Ql,QUARTILE_INC:Jl,SMALL:ec,STDEV:tc,STDEV_P:ic,STDEV_S:oc,STDEVA:nc,STDEVP:sc,STDEVPA:rc,VAR:ac,VAR_P:lc,VAR_S:cc,VARA:hc,VARP:dc,VARPA:uc});function pc(e,t,i){var o;const n=new Map,r=e.length;for(let t=r-1;t>=0;t--)n.set(Vo(e[t][0]).toUpperCase(),t);if("number"!=typeof t&&"string"!=typeof t)throw new Error(s("The field must be a number or a string"));let a;if("number"==typeof t){if(a=Math.trunc(t)-1,a<0||r-1<a)throw new Error(s("The field (%s) must be one of %s or must be a number between 1 and %s inclusive.",t.toString(),r.toString()))}else{const e=Vo(t).toUpperCase();if(a=null!==(o=n.get(e))&&void 0!==o?o:-1,-1===a)throw new Error(s("The field (%s) must be one of %s.",Vo(t),[...n.keys()].toString()))}const l=i[0].length;if(l<2)throw new Error(s("The criteria range contains %s row, it must be at least 2 rows.",l.toString()));let c=new Set;const h=e[0].length;for(let t=1;t<l;t++){let o=[],s=!0;for(let r=0;r<i.length;r++){const a=Vo(i[r][0]).toUpperCase(),l=n.get(a),c=i[r][t];if(void 0!==c){if(void 0===l){s=!1;break}o.push([e[l].slice(1,h)]),o.push(c)}}if(s){if(!(o.length>0)){c=new Set(Array(h-1).keys());break}tn(o,((e,t)=>{c.add(t)}),!0)}}const d=e[a];return[...c].map((e=>d[e+1]))}const mc=[va("database (range)",s("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.")),va("field (any)",s("Indicates which column in database contains the values to be extracted and operated on.")),va("criteria (range)",s("An array or range containing zero or more criteria to filter the database values by before operating."))],fc={description:s("Average of a set of values from a table-like range."),args:mc,returns:["NUMBER"],compute:function(e,t,i){const o=pc(e,t,i);return Al.compute([o])},isExported:!0},vc={description:s("Counts values from a table-like range."),args:mc,returns:["NUMBER"],compute:function(e,t,i){const o=pc(e,t,i);return kl.compute([o])},isExported:!0},bc={description:s("Counts values and text from a table-like range."),args:mc,returns:["NUMBER"],compute:function(e,t,i){const o=pc(e,t,i);return Ll.compute([o])},isExported:!0},Sc={description:s("Single value from a table-like range."),args:mc,returns:["NUMBER"],compute:function(e,t,i){const o=pc(e,t,i);return ko((()=>1===o.length),s("More than one match found in DGET evaluation.")),o[0]},isExported:!0},Cc={description:s("Maximum of values from a table-like range."),args:mc,returns:["NUMBER"],compute:function(e,t,i){const o=pc(e,t,i);return Bl.compute([o])},isExported:!0},Ec={description:s("Minimum of values from a table-like range."),args:mc,returns:["NUMBER"],compute:function(e,t,i){const o=pc(e,t,i);return Gl.compute([o])},isExported:!0},wc={description:s("Product of values from a table-like range."),args:mc,returns:["NUMBER"],compute:function(e,t,i){const o=pc(e,t,i);return rl.compute([o])},isExported:!0},yc={description:s("Standard deviation of population sample from table."),args:mc,returns:["NUMBER"],compute:function(e,t,i){const o=pc(e,t,i);return tc.compute([o])},isExported:!0},xc={description:s("Standard deviation of entire population from table."),args:mc,returns:["NUMBER"],compute:function(e,t,i){const o=pc(e,t,i);return sc.compute([o])},isExported:!0},Ic={description:s("Sum of values from a table-like range."),args:mc,returns:["NUMBER"],compute:function(e,t,i){const o=pc(e,t,i);return vl.compute([o])},isExported:!0},Rc={description:s("Variance of population sample from table-like range."),args:mc,returns:["NUMBER"],compute:function(e,t,i){const o=pc(e,t,i);return ac.compute([o])},isExported:!0},Tc={description:s("Variance of a population from a table-like range."),args:mc,returns:["NUMBER"],compute:function(e,t,i){const o=pc(e,t,i);return dc.compute([o])},isExported:!0};var Ac=Object.freeze({__proto__:null,DAVERAGE:fc,DCOUNT:vc,DCOUNTA:bc,DGET:Sc,DMAX:Cc,DMIN:Ec,DPRODUCT:wc,DSTDEV:yc,DSTDEVP:xc,DSUM:Ic,DVAR:Rc,DVARP:Tc});const Mc={description:s("Converts year/month/day into a date."),args:[va("year (number)",s("The year component of the date.")),va("month (number)",s("The month component of the date.")),va("day (number)",s("The day component of the date."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){let o=Math.trunc(Po(e));const n=Math.trunc(Po(t)),r=Math.trunc(Po(i));ko((()=>0<=o&&o<=9999),s("The year (%s) must be between 0 and 9999 inclusive.",o.toString())),o<1900&&(o+=1900);const a=xe(new Date(o,n-1,r));return ko((()=>a>=0),s("The function [[FUNCTION_NAME]] result must be greater than or equal 01/01/1900.")),a},isExported:!0},Oc={description:s("Converts a date string to a date value."),args:[va("date_string (string)",s("The string representing the date."))],returns:["NUMBER"],compute:function(e){const t=Vo(e),i=Ee(t);return ko((()=>null!==i),s("The date_string (%s) cannot be parsed to date/time.",t.toString())),Math.trunc(i.value)},isExported:!0},Nc={description:s("Day of the month that a specific date falls on."),args:[va("date (string)",s("The date from which to extract the day."))],returns:["NUMBER"],compute:function(e){return Wo(e).getDate()},isExported:!0},_c={description:s("Number of days between two dates."),args:[va("end_date (date)",s("The end of the date range.")),va("start_date (date)",s("The start of the date range."))],returns:["NUMBER"],compute:function(e,t){const i=Wo(e),o=Wo(t),n=i.getTime()-o.getTime();return Math.round(n/ge)},isExported:!0},Fc={description:s("Number of days between two dates on a 360-day year (months of 30 days)."),args:[va("start_date (date)",s("The start date to consider in the calculation.")),va("end_date (date)",s("The end date to consider in the calculation.")),va("method (number, default=0)",s("An indicator of what day count method to use. (0) US NASD method (1) European method"))],returns:["NUMBER"],compute:function(e,t,i=0){const o=Po(e),n=Po(t),s=$o(i)?4:0,r=Jc.compute(e,t,s);return Math.sign(n-o)*Math.round(360*r)},isExported:!0},Dc={description:s("Date a number of months before/after another date."),args:[va("start_date (date)",s("The date from which to calculate the result.")),va("months (number)",s("The number of months before (negative) or after (positive) 'start_date' to calculate."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){return xe(Te(Wo(e),Math.trunc(Po(t)),!1))},isExported:!0},kc={description:s("Last day of a month before or after a date."),args:[va("start_date (date)",s("The date from which to calculate the result.")),va("months (number)",s("The number of months before (negative) or after (positive) 'start_date' to consider."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t){const i=Wo(e),o=Math.trunc(Po(t)),n=i.getFullYear(),s=i.getMonth();return xe(new Date(n,s+o+1,0))},isExported:!0},Lc={description:s("Hour component of a specific time."),args:[va("time (date)",s("The time from which to calculate the hour component."))],returns:["NUMBER"],compute:function(e){return Wo(e).getHours()},isExported:!0},Pc={description:s("ISO week number of the year."),args:[va("date (date)",s("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."))],returns:["NUMBER"],compute:function(e){const t=Wo(e),i=t.getFullYear();let o=1;for(;4!==new Date(i,0,o).getDay();)o+=1;const n=new Date(i,0,o-3);let s=31;for(;4!==new Date(i,11,s).getDay();)s-=1;const r=new Date(i,11,s+3);let a,l;switch(a=n.getTime()<=t.getTime()?t.getTime()<=r.getTime()?0:1:-1,a){case 0:l=n;break;case 1:l=new Date(i,11,s+3+1);break;case-1:let e=1;for(;4!==new Date(i-1,0,e).getDay();)e+=1;l=new Date(i-1,0,e-3)}const c=(t.getTime()-l.getTime())/ge;return Math.floor(c/7)+1},isExported:!0},Uc={description:s("Minute component of a specific time."),args:[va("time (date)",s("The time from which to calculate the minute component."))],returns:["NUMBER"],compute:function(e){return Wo(e).getMinutes()},isExported:!0},Vc={description:s("Month of the year a specific date falls in"),args:[va("date (date)",s("The date from which to extract the month."))],returns:["NUMBER"],compute:function(e){return Wo(e).getMonth()+1},isExported:!0},zc={description:s("Net working days between two provided days."),args:[va("start_date (date)",s("The start date of the period from which to calculate the number of net working days.")),va("end_date (date)",s("The end date of the period from which to calculate the number of net working days.")),va("holidays (date, range<date>, optional)",s("A range or array constant containing the date serial numbers to consider holidays."))],returns:["NUMBER"],compute:function(e,t,i){return Hc.compute(e,t,1,i)},isExported:!0};function Bc(e){if("string"==typeof e){ko((()=>{if(7!==e.length)return!1;for(let t of e)if("0"!==t&&"1"!==t)return!1;return!0}),s('When weekend is a string (%s) it must be composed of "0" or "1".',e));let t=[];for(let i=0;i<7;i++)"1"===e[i]&&t.push((i+1)%7);return t}if("number"==typeof e)return ko((()=>1<=e&&e<=7||11<=e&&e<=17),s("The weekend (%s) must be a string or a number in the range 1-7 or 11-17.",e.toString())),e<=7?[e-2==-1?6:e-2,e-1]:[e-11];throw Error(s("The weekend must be a number or a string."))}const Hc={description:s("Net working days between two dates (specifying weekends)."),args:[va("start_date (date)",s("The start date of the period from which to calculate the number of net working days.")),va("end_date (date)",s("The end date of the period from which to calculate the number of net working days.")),va("weekend (any, default=1)",s("A number or string representing which days of the week are considered weekends.")),va("holidays (date, range<date>, optional)",s("A range or array constant containing the dates to consider as holidays."))],returns:["NUMBER"],compute:function(e,t,i=1,o){const n=Wo(e),s=Wo(t),r=Bc(i);let a=new Set;void 0!==o&&qo([o],(e=>{const t=Wo(e);a.add(t.getTime())}));const l=n.getTime()>s.getTime(),c=new Date((l?n:s).getTime());let h=new Date((l?s:n).getTime());const d=c.getTime();let u=h.getTime(),g=0;for(;u<=d;)r.includes(h.getDay())||a.has(u)||(g+=1),h.setDate(h.getDate()+1),u=h.getTime();return l?-g:g},isExported:!0},$c={description:s("Current date and time as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy hh:mm:ss",compute:function(){let e=new Date;e.setMilliseconds(0);const t=e.getTime()-ue.getTime(),i=e.getHours()/24+e.getMinutes()/1440+e.getSeconds()/86400;return Math.floor(t/ge)+i},isExported:!0},Wc={description:s("Minute component of a specific time."),args:[va("time (date)",s("The time from which to calculate the second component."))],returns:["NUMBER"],compute:function(e){return Wo(e).getSeconds()},isExported:!0},Gc={description:s("Converts hour/minute/second into a time."),args:[va("hour (number)",s("The hour component of the time.")),va("minute (number)",s("The minute component of the time.")),va("second (number)",s("The second component of the time."))],returns:["DATE"],computeFormat:()=>"hh:mm:ss a",compute:function(e,t,i){let o=Math.trunc(Po(e)),n=Math.trunc(Po(t)),r=Math.trunc(Po(i));return n+=Math.floor(r/60),r=r%60+(r<0?60:0),o+=Math.floor(n/60),n=n%60+(n<0?60:0),o%=24,ko((()=>o>=0),s("The function [[FUNCTION_NAME]] result cannot be negative")),o/24+n/1440+r/86400},isExported:!0},qc={description:s("Converts a time string into its serial number representation."),args:[va("time_string (string)",s("The string that holds the time representation."))],returns:["NUMBER"],compute:function(e){const t=Vo(e),i=Ee(t);ko((()=>null!==i),s("The time_string (%s) cannot be parsed to date/time.",t));const o=i.value-Math.trunc(i.value);return o<0?1+o:o},isExported:!0},Zc={description:s("Current date as a date value."),args:[],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(){const e=new Date;return xe(new Date(e.getFullYear(),e.getMonth(),e.getDate()))},isExported:!0},jc={description:s("Day of the week of the date provided (as number)."),args:[va("date (date)",s("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.")),va("type (number, default=1)",s("A number indicating which numbering system to use to represent weekdays. By default, counts starting with Sunday = 1."))],returns:["NUMBER"],compute:function(e,t=1){const i=Wo(e),o=Math.round(Po(t)),n=i.getDay();return ko((()=>[1,2,3].includes(o)),s("The type (%s) must be 1, 2 or 3.",o.toString())),1===o?n+1:2===o?0===n?7:n:0===n?6:n-1},isExported:!0},Xc={description:s("Week number of the year."),args:[va("date (date)",s("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.")),va("type (number, default=1)",s("A number representing the day that a week starts on. Sunday = 1."))],returns:["NUMBER"],compute:function(e,t=1){const i=Wo(e),o=Math.round(Po(t));if(ko((()=>1===o||2===o||11<=o&&o<=17||21===o),s("The type (%s) is out of range.",o.toString())),21===o)return Pc.compute(e);let n;n=1===o||2===o?o-1:o-10==7?0:o-10;const r=i.getFullYear();let a=1,l=new Date(r,0,a);for(;l.getDay()!==n;)a+=1,l=new Date(r,0,a);const c=(i.getTime()-l.getTime())/ge;return c<0?1:Math.floor(c/7)+(1===a?1:2)},isExported:!0},Yc={description:s("Date after a number of workdays."),args:[va("start_date (date)",s("The date from which to begin counting.")),va("num_days (number)",s("The number of working days to advance from start_date. If negative, counts backwards.")),va("holidays (date, range<date>, optional)",s("A range or array constant containing the dates to consider holidays."))],returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i){return Kc.compute(e,t,1,i)},isExported:!0},Kc={description:s("Date after a number of workdays (specifying weekends)."),args:[va("start_date (date)",s("The date from which to begin counting.")),va("num_days (number)",s("The number of working days to advance from start_date. If negative, counts backwards.")),va("weekend (any, default=1)",s("A number or string representing which days of the week are considered weekends.")),va("holidays (date, range<date>, optional)",s("A range or array constant containing the dates to consider holidays."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i=1,o){let n=Wo(e),r=Math.trunc(Po(t));"string"==typeof i&&ko((()=>"1111111"!==i),s("The weekend (%s) must be different from '1111111'.",i));const a=Bc(i);let l=new Set;void 0!==o&&qo([o],(e=>{const t=Wo(e);l.add(t.getTime())}));let c=new Date(n.getTime()),h=c.getTime();const d=Math.sign(r);let u=Math.abs(r);for(;u>0;)c.setDate(c.getDate()+d),h=c.getTime(),a.includes(c.getDay())||l.has(h)||(u-=1);const g=h-ue.getTime();return Math.round(g/ge)},isExported:!0},Qc={description:s("Year specified by a given date."),args:[va("date (date)",s("The date from which to extract the year."))],returns:["NUMBER"],compute:function(e){return Wo(e).getFullYear()},isExported:!0},Jc={description:s("Exact number of years between two dates."),args:[va("start_date (date)",s("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.")),va("end_date (date)",s("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.")),va("day_count_convention (number, default=0)",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i=0){let o=Math.trunc(Po(e)),n=Math.trunc(Po(t));const r=Math.trunc(Po(i));return ko((()=>o>=0),s("The start_date (%s) must be positive or null.",o.toString())),ko((()=>n>=0),s("The end_date (%s) must be positive or null.",n.toString())),ko((()=>0<=r&&r<=4),s("The day_count_convention (%s) must be between 0 and 4 inclusive.",r.toString())),Me(o,n,r)}},eh={description:s("First day of the month preceding a date."),args:[va("date (date)",s("The date from which to calculate the result."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Wo(e),i=t.getFullYear(),o=t.getMonth();return xe(new Date(i,o,1))}},th={description:s("Last day of the month following a date."),args:[va("date (date)",s("The date from which to calculate the result."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){return kc.compute(e,0)}},ih={description:s("Quarter of the year a specific date falls in"),args:[va("date (date)",s("The date from which to extract the quarter."))],returns:["NUMBER"],compute:function(e){return Math.ceil((Wo(e).getMonth()+1)/3)}},oh={description:s("First day of the quarter of the year a specific date falls in."),args:[va("date (date)",s("The date from which to calculate the start of quarter."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=ih.compute(e),i=Qc.compute(e);return xe(new Date(i,3*(t-1),1))}},nh={description:s("Last day of the quarter of the year a specific date falls in."),args:[va("date (date)",s("The date from which to calculate the end of quarter."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=ih.compute(e),i=Qc.compute(e);return xe(new Date(i,3*t,0))}},sh={description:s("First day of the year a specific date falls in."),args:[va("date (date)",s("The date from which to calculate the start of the year."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Qc.compute(e);return xe(new Date(t,0,1))}},rh={description:s("Last day of the year a specific date falls in."),args:[va("date (date)",s("The date from which to calculate the end of the year."))],returns:["DATE"],computeFormat:()=>"m/d/yyyy",compute:function(e){const t=Qc.compute(e);return xe(new Date(t+1,0,0))}};var ah=Object.freeze({__proto__:null,DATE:Mc,DATEVALUE:Oc,DAY:Nc,DAYS:_c,DAYS360:Fc,EDATE:Dc,EOMONTH:kc,HOUR:Lc,ISOWEEKNUM:Pc,MINUTE:Uc,MONTH:Vc,NETWORKDAYS:zc,NETWORKDAYS_INTL:Hc,NOW:$c,SECOND:Wc,TIME:Gc,TIMEVALUE:qc,TODAY:Zc,WEEKDAY:jc,WEEKNUM:Xc,WORKDAY:Yc,WORKDAY_INTL:Kc,YEAR:Qc,YEARFRAC:Jc,MONTH_START:eh,MONTH_END:th,QUARTER:ih,QUARTER_START:oh,QUARTER_END:nh,YEAR_START:sh,YEAR_END:rh});const lh={description:s("Compare two numeric values, returning 1 if they're equal."),args:[va(" (number)",s("The first number to compare.")),va(" (number, default=0)",s("The second number to compare."))],returns:["NUMBER"],compute:function(e,t=0){return Po(e)===Po(t)?1:0},isExported:!0};var ch=Object.freeze({__proto__:null,DELTA:lh});function hh(e,t){ko((()=>e<t),s("The maturity (%s) must be strictly greater than the settlement (%s).",t.toString(),e.toString()))}function dh(e,t){ko((()=>t<e),s("The settlement date (%s) must be strictly greater than the issue date (%s).",e.toString(),t.toString()))}function uh(e){ko((()=>[1,2,4].includes(e)),s("The frequency (%s) must be one of %s",e.toString(),[1,2,4].toString()))}function gh(e){ko((()=>0<=e&&e<=4),s("The day_count_convention (%s) must be between 0 and 4 inclusive.",e.toString()))}function ph(e){ko((()=>e>0),s("The redemption (%s) must be strictly positive.",e.toString()))}function mh(e){ko((()=>e>0),s("The price (%s) must be strictly positive.",e.toString()))}function fh(e){ko((()=>e>0),s("The number_of_periods (%s) must be greater than 0.",e.toString()))}function vh(e){ko((()=>e>0),s("The rate (%s) must be strictly positive.",e.toString()))}function bh(e){ko((()=>e>0),s("The life (%s) must be strictly positive.",e.toString()))}function Sh(e){ko((()=>e>=0),s("The cost (%s) must be positive or null.",e.toString()))}function Ch(e){ko((()=>e>0),s("The period (%s) must be strictly positive.",e.toString()))}function Eh(e){ko((()=>e>=0),s("The salvage (%s) must be positive or null.",e.toString()))}function wh(e){ko((()=>e>0),s("The present value (%s) must be strictly positive.",e.toString()))}function yh(e,t){ko((()=>e<=t),s("The period (%s) must be less than or equal life (%s).",e.toString(),t.toString()))}function xh(e){ko((()=>e>0),s("The investment (%s) must be strictly positive.",e.toString()))}function Ih(e){ko((()=>e>0),s("The discount (%s) must be strictly positive.",e.toString()))}function Rh(e){ko((()=>e<1),s("The discount (%s) must be smaller than 1.",e.toString()))}function Th(e){ko((()=>e>0),s("The depreciation factor (%s) must be strictly positive.",e.toString()))}function Ah(e,t){const i=Wo(e),o=Wo(t),n=new Date(i);n.setFullYear(i.getFullYear()+1),ko((()=>o.getTime()<=n.getTime()),s("The settlement date (%s) must at most one year after the maturity date (%s).",e.toString(),t.toString()))}function Mh(e,t,i){fh(i),ko((()=>e>0),s("The first_period (%s) must be strictly positive.",e.toString())),ko((()=>t>0),s("The last_period (%s) must be strictly positive.",t.toString())),ko((()=>e<=t),s("The first_period (%s) must be smaller or equal to the last_period (%s).",e.toString(),t.toString())),ko((()=>t<=i),s("The last_period (%s) must be smaller or equal to the number_of_periods (%s).",e.toString(),i.toString()))}function Oh(e){ko((()=>e>-1),s("The rate_guess (%s) must be strictly greater than -1.",e.toString()))}function Nh(e,t){ko((()=>e.length===t.length&&e[0].length===t[0].length),s("The cashflow_amounts and cashflow_dates ranges must have the same dimensions."))}function _h(e){ko((()=>e.every((t=>t>=e[0]))),s("All the dates should be greater or equal to the first date in cashflow_dates (%s).",e[0].toString()))}const Fh=[va("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),va("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),va("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),va("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))];function Dh(e,t,i,o,n=1e-10,r){let a,l,c,h,d=i,u=!1,g=0;do{c=e(d),isNaN(c)?(ko((()=>g<o&&void 0!==r),s("Function [[FUNCTION_NAME]] didn't find any result.")),g++,d=r(h),h=d):(a=d-c/t(d),l=Math.abs(a-d),d=a,u=l<n||Math.abs(c)<n,ko((()=>g<o),s("Function [[FUNCTION_NAME]] didn't find any result.")),g++)}while(!u);return d}const kh={description:s("Accrued interest of security paying at maturity."),args:[va("issue (date)",s("The date the security was initially issued.")),va("maturity (date)",s("The maturity date of the security.")),va("rate (number)",s("The annualized rate of interest.")),va("redemption (number)",s("The redemption amount per 100 face value, or par.")),va("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Po(e)),r=Math.trunc(Po(t)),a=Po(o),l=Po(i),c=Math.trunc(Po(n));dh(r,s),gh(c),ph(a),vh(l);return a*l*Jc.compute(s,r,n)},isExported:!0},Lh={description:s("Depreciation for an accounting period."),args:[va("cost (number)",s("The initial cost of the asset.")),va("purchase_date (date)",s("The date the asset was purchased.")),va("first_period_end (date)",s("The date the first period ended.")),va("salvage (number)",s("The value of the asset at the end of depreciation.")),va("period (number)",s("The single period within life for which to calculate depreciation.")),va("rate (number)",s("The deprecation rate.")),va(" (number, optional)",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r,a=0){a=a||0;const l=Po(e),c=Math.trunc(Po(t)),h=Math.trunc(Po(i)),d=Po(o),u=Po(n),g=Po(r),p=Math.trunc(Po(a));!function(e){ko((()=>e>0),s("The cost (%s) must be strictly positive.",e.toString()))}(l),Eh(d),function(e,t){ko((()=>e<=t),s("The salvage (%s) must be smaller or equal than the cost (%s).",e.toString(),t.toString()))}(d,l),function(e){ko((()=>e>=0),s("The period (%s) must be positive or null.",e.toString()))}(u),vh(g),gh(p),ko((()=>c<=h),s("The purchase_date (%s) must be before the first_period_end (%s).",c.toString(),h.toString()));const m=u<1&&u>0?1:Math.trunc(u),f=l*g,v=Jc.compute(c,h,p),b=c===h?f:f*v,S=l-b-f*m;return S>=d?0===m?b:f:d-S<f?f-(d-S):0},isExported:!0},Ph={description:s("Days in coupon period containing settlement date."),args:Fh,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Po(e)),s=Math.trunc(Po(t)),r=Math.trunc(Po(i)),a=Math.trunc(Po(o));if(hh(n,s),uh(r),gh(a),1===a){const n=Hh.compute(e,t,i,o);return zh.compute(e,t,i,o)-n}return(3===a?365:360)/r},isExported:!0},Uh={description:s("Days from settlement until next coupon."),args:Fh,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Po(e)),s=Math.trunc(Po(t)),r=Math.trunc(Po(i)),a=Math.trunc(Po(o));hh(n,s),uh(r),gh(a);const l=Hh.compute(n,s,i,o);if([1,2,3].includes(a))return n-l;if(4===a){const e=Me(l,n,a);return Math.round(360*e)}const c=Wo(n),h=Wo(l),d=h.getFullYear(),u=c.getFullYear(),g=h.getMonth()+1,p=c.getMonth()+1;let m=h.getDate(),f=c.getDate();return 2===g&&2===p&&Re(h)&&Re(c)&&(f=30),31!==f||30!==m&&31!==m||(f=30),2===g&&Re(h)&&(m=30),31===m&&(m=30),360*(u-d)+30*(p-g)+(f-m)},isExported:!0},Vh={description:s("Days from settlement until next coupon."),args:Fh,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Po(e)),s=Math.trunc(Po(t)),r=Math.trunc(Po(i)),a=Math.trunc(Po(o));hh(n,s),uh(r),gh(a);const l=zh.compute(n,s,i,o);if([1,2,3].includes(a))return l-n;if(4===a){const e=Me(n,l,a);return Math.round(360*e)}const c=Uh.compute(e,t,i,a);return Ph.compute(e,t,i,a)-c},isExported:!0},zh={description:s("Next coupon date after the settlement date."),args:Fh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Po(e)),s=Math.trunc(Po(t)),r=Math.trunc(Po(i)),a=Math.trunc(Po(o));hh(n,s),uh(r),gh(a);const l=12/r,c=Bh.compute(e,t,i,o);return xe(Te(Wo(s),-(c-1)*l,!0))},isExported:!0},Bh={description:s("Number of coupons between settlement and maturity."),args:Fh,returns:["NUMBER"],compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Po(e)),s=Math.trunc(Po(t)),r=Math.trunc(Po(i)),a=Math.trunc(Po(o));hh(n,s),uh(r),gh(a);let l=1,c=s;const h=12/r;for(;c>n;)c=xe(Te(Wo(c),-h,!1)),l++;return l-1},isExported:!0},Hh={description:s("Last coupon date prior to or on the settlement date."),args:Fh,returns:["NUMBER"],computeFormat:()=>"m/d/yyyy",compute:function(e,t,i,o=0){o=o||0;const n=Math.trunc(Po(e)),s=Math.trunc(Po(t)),r=Math.trunc(Po(i)),a=Math.trunc(Po(o));hh(n,s),uh(r),gh(a);const l=12/r,c=Bh.compute(e,t,i,o);return xe(Te(Wo(s),-c*l,!0))},isExported:!0},$h={description:s("Cumulative interest paid over a set of periods."),args:[va("rate (number)",s("The interest rate.")),va("number_of_periods (number)",s("The number of payments to be made.")),va("present_value (number)",s("The current value of the annuity.")),va("first_period (number)",s("The number of the payment period to begin the cumulative calculation.")),va("last_period (number)",s("The number of the payment period to end the cumulative calculation.")),va("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){const r=Po(o),a=Po(n),l=Po(e),c=Po(i),h=Po(t);Mh(r,a,h),vh(l),wh(c);let d=0;for(let t=r;t<=a;t++){d+=td.compute(e,t,h,i,0,s)}return d},isExported:!0},Wh={description:s("Cumulative principal paid over a set of periods."),args:[va("rate (number)",s("The interest rate.")),va("number_of_periods (number)",s("The number of payments to be made.")),va("present_value (number)",s("The current value of the annuity.")),va("first_period (number)",s("The number of the payment period to begin the cumulative calculation.")),va("last_period (number)",s("The number of the payment period to end the cumulative calculation.")),va("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){const r=Po(o),a=Po(n),l=Po(e),c=Po(i),h=Po(t);Mh(r,a,h),vh(l),wh(c);let d=0;for(let t=r;t<=a;t++){d+=dd.compute(e,t,h,i,0,s)}return d},isExported:!0},Gh={description:s("Depreciation via declining balance method."),args:[va("cost (number)",s("The initial cost of the asset.")),va("salvage (number)",s("The value of the asset at the end of depreciation.")),va("life (number)",s("The number of periods over which the asset is depreciated.")),va("period (number)",s("The single period within life for which to calculate depreciation.")),va("month (number, optional)",s("The number of months in the first year of depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,...n){const r=Po(e),a=Po(t),l=Po(i),c=Math.trunc(Po(o)),h=n.length?Math.trunc(Po(n[0])):12,d=l+(12===h?0:1);Sh(r),Eh(a),Ch(c),bh(l),ko((()=>1<=h&&h<=12),s("The month (%s) must be between 1 and 12 inclusive.",h.toString())),ko((()=>c<=d),s("The period (%s) must be less than or equal to %s.",c.toString(),d.toString()));const u=h/12;let g=1-Math.pow(a/r,1/l);g=Math.round(1e3*g)/1e3;let p=r,m=r*(1-g*u);for(let e=1;e<c;e++)p=m,m=p*(1-g),e===l&&(m=p*(1-g*(1-u)));return p-m},isExported:!0},qh={description:s("Depreciation via double-declining balance method."),args:[va("cost (number)",s("The initial cost of the asset.")),va("salvage (number)",s("The value of the asset at the end of depreciation.")),va("life (number)",s("The number of periods over which the asset is depreciated.")),va("period (number)",s("The single period within life for which to calculate depreciation.")),va("factor (number, default=2)",s("The factor by which depreciation decreases."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=2){n=n||0;const s=Po(e),r=Po(t),a=Po(i),l=Po(o),c=Po(n);if(Sh(s),Eh(r),Ch(l),bh(a),yh(l,a),Th(c),0===s||r>=s)return 0;const h=c/a;if(h>1)return 1===o?s-r:0;if(l<=1)return s*h;const d=s*Math.pow(1-h,l-1),u=s*Math.pow(1-h,l),g=u<r?d-r:d-u;return Math.max(g,0)},isExported:!0},Zh={description:s("Discount rate of a security based on price."),args:[va("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),va("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),va("price (number)",s("The price at which the security is bought per 100 face value.")),va("redemption (number)",s("The redemption amount per 100 face value, or par.")),va("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Po(e)),r=Math.trunc(Po(t)),a=Po(i),l=Po(o),c=Math.trunc(Po(n));hh(s,r),gh(c),mh(a),ph(l);return(l-a)/l/Jc.compute(s,r,c)},isExported:!0},jh={description:s("Convert a decimal fraction to decimal value."),args:[va("fractional_price (number)",s("The price quotation given using fractional decimal conventions.")),va("unit (number)",s("The units of the fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const i=Po(e),o=Math.trunc(Po(t));ko((()=>o>0),s("The unit (%s) must be strictly positive.",o.toString()));const n=Math.trunc(i);return n+(i-n)*(10**Math.ceil(Math.log10(o))/o)},isExported:!0},Xh={description:s("Convert a decimal value to decimal fraction."),args:[va("decimal_price (number)",s("The price quotation given as a decimal value.")),va("unit (number)",s("The units of the desired fraction, e.g. 8 for 1/8ths or 32 for 1/32nds."))],returns:["NUMBER"],compute:function(e,t){const i=Po(e),o=Math.trunc(Po(t));ko((()=>o>0),s("The unit (%s) must be strictly positive.",o.toString()));const n=Math.trunc(i);return n+(i-n)*(o/10**Math.ceil(Math.log10(o)))},isExported:!0},Yh={description:s("Number of periods for an investment to reach a value."),args:[va("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),va("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),va("rate (number)",s("The annualized rate of interest.")),va("yield (number)",s("The expected annual yield of the security.")),va("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),va("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){r=r||0;const a=Math.trunc(Po(e)),l=Math.trunc(Po(t)),c=Po(i),h=Po(o),d=Math.trunc(Po(n)),u=Math.trunc(Po(r));hh(a,l),uh(d),gh(u),ko((()=>c>=0),s("The rate (%s) must be positive or null.",c.toString())),ko((()=>h>=0),s("The yield (%s) must be positive or null.",h.toString()));const g=Jc.compute(a,l,u),p=g-Math.trunc(g)||1/d,m=Math.ceil(g*d),f=c/d,v=h/d;let b=0,S=0;for(let e=1;e<=m;e++){const t=(f+(e===m?1:0))/(1+v)**e;S+=(p+(e-1)/d)*t,b+=t}return 0===b?0:S/b},isExported:!0},Kh={description:s("Annual effective interest rate."),args:[va("nominal_rate (number)",s("The nominal interest rate per year.")),va("periods_per_year (number)",s("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const i=Po(e),o=Math.trunc(Po(t));return ko((()=>i>0),s("The nominal rate (%s) must be strictly greater than 0.",i.toString())),ko((()=>o>0),s("The number of periods by year (%s) must strictly greater than 0.",o.toString())),Math.pow(1+i/o,o)-1},isExported:!0},Qh={description:s("Future value of an annuity investment."),args:[va("rate (number)",s("The interest rate.")),va("number_of_periods (number)",s("The number of payments to be made.")),va("payment_amount (number)",s("The amount per period to be paid.")),va("present_value (number, default=0)",s("The current value of the annuity.")),va("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=Po(e),r=Po(t),a=Po(i),l=Po(o),c=$o(n)?1:0;return s?-l*(1+s)**r-a*(1+s*c)*((1+s)**r-1)/s:-(l+a*r)},isExported:!0},Jh={description:s("Future value of principal from series of rates."),args:[va("principal (number)",s("The amount of initial capital or value to compound against.")),va("rate_schedule (number, range<number>)",s("A series of interest rates to compound against the principal."))],returns:["NUMBER"],compute:function(e,t){return Xo([t],((e,t)=>e*(1+Po(t))),Po(e))},isExported:!0},ed={description:s("Calculates effective interest rate."),args:[va("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),va("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),va("investment (number)",s("The amount invested in the security.")),va("redemption (number)",s("The amount to be received at maturity.")),va("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){const s=Math.trunc(Po(e)),r=Math.trunc(Po(t)),a=Po(o),l=Po(i);hh(s,r),xh(l),ph(a);return(a-l)/l/Jc.compute(s,r,n)},isExported:!0},td={description:s("Payment on the principal of an investment."),args:[va("rate (number)",s("The annualized rate of interest.")),va("period (number)",s("The amortization period, in terms of number of periods.")),va("number_of_periods (number)",s("The number of payments to be made.")),va("present_value (number)",s("The current value of the annuity.")),va("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),va("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=0,s=0){return hd.compute(e,i,o,n,s)-dd.compute(e,t,i,o,n,s)},isExported:!0},id={description:s("Internal rate of return given periodic cashflows."),args:[va("cashflow_amounts (number, range<number>)",s("An array or range containing the income or payments associated with the investment.")),va("rate_guess (number, default=0.1)",s("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t=.1){const i=Po(t);Oh(i);let o=!1,n=!1,r=[];Zo([e],(e=>{e>0&&(o=!0),e<0&&(n=!0),r.push(e)})),ko((()=>o&&n),s("The cashflow_amounts must include negative and positive values."));const a=r.shift();return Dh((function(e){return function(e,t,i){const o=i.length;let n=0;return i.reduce(((t,i)=>(n++,t+i*e**(o-n))),t*e**o)}(e,a,r)}),(function(e){return function(e,t,i){const o=i.length;let n=0;return i.reduce(((t,i)=>(n++,t+i*(o-n)*e**(o-n-1))),t*o*e**(o-1))}(e,a,r)}),i+1,20,1e-5)-1},isExported:!0},od={description:s("Returns the interest paid at a particular period of an investment."),args:[va("rate (number)",s("The interest rate.")),va("period (number)",s("The period for which you want to view the interest payment.")),va("number_of_periods (number)",s("The number of payments to be made.")),va("present_value (number)",s("The current value of the annuity."))],returns:["NUMBER"],compute:function(e,t,i,o){const n=Po(e),r=Po(t),a=Po(i),l=Po(o);ko((()=>0!==a),s("The number of periods must be different than 0.",a.toString()));return-1*(l-l*(r/a))*n},isExported:!0},nd={description:s("Modified Macaulay duration."),args:[va("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),va("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),va("rate (number)",s("The annualized rate of interest.")),va("yield (number)",s("The expected annual yield of the security.")),va("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),va("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,s=0){return Yh.compute(e,t,i,o,n,s)/(1+Po(o)/Math.trunc(Po(n)))},isExported:!0},sd={description:s("Modified internal rate of return."),args:[va("cashflow_amounts (range<number>)",s("A range containing the income or payments associated with the investment. The array should contain bot payments and incomes.")),va("financing_rate (number)",s("The interest rate paid on funds invested.")),va("reinvestment_return_rate (number)",s("The return (as a percentage) earned on reinvestment of income received from the investment."))],returns:["NUMBER"],compute:function(e,t,i){const o=Po(t),n=Po(i),r=(a=e,a.length?a[0].map(((e,t)=>a.map((e=>e[t])))):a).flat().filter(it).map(Po);var a;const l=r.length;let c=0,h=0;for(const e of He(0,l)){const t=r[e];t>=0?c+=t*(n+1)**(l-e-1):h+=t/(o+1)**e}ko((()=>0!==h&&0!==c),s("There must be both positive and negative values in cashflow_amounts."));return(-c/h)**(1/(l-1))-1},isExported:!0},rd={description:s("Annual nominal interest rate."),args:[va("effective_rate (number)",s("The effective interest rate per year.")),va("periods_per_year (number)",s("The number of compounding periods per year."))],returns:["NUMBER"],compute:function(e,t){const i=Po(e),o=Math.trunc(Po(t));return ko((()=>i>0),s("The effective rate (%s) must must strictly greater than 0.",i.toString())),ko((()=>o>0),s("The number of periods by year (%s) must strictly greater than 0.",o.toString())),(Math.pow(i+1,1/o)-1)*o},isExported:!0},ad={description:s("Number of payment periods for an investment."),args:[va("rate (number)",s("The interest rate.")),va("payment_amount (number)",s("The amount of each payment made.")),va("present_value (number)",s("The current value of the annuity.")),va("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),va("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=Po(e),r=Po(t),a=Po(i),l=Po(o),c=$o(n)?1:0;if(0===s)return-(l+a)/r;const h=r*(1+s*c)/s;return Math.log((h-l)/(a+h))/Math.log(1+s)},isExported:!0};const ld={description:s("The net present value of an investment based on a series of periodic cash flows and a discount rate."),args:[va("discount (number)",s("The discount rate of the investment over one period.")),va("cashflow1 (number, range<number>)",s("The first future cash flow.")),va("cashflow2 (number, range<number>, repeating)",s("Additional future cash flows."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,...t){const i=Po(e);return ko((()=>-1!==i),s("The discount (%s) must be different from -1.",i.toString())),function(e,t,i){let o=0;return Yo(i,((t,i)=>(o++,t+i/(1+e)**o)),t)}(i,0,t)},isExported:!0},cd={description:s("Computes the number of periods needed for an investment to reach a value."),args:[va("rate (number)",s("The rate at which the investment grows each period.")),va("present_value (number)",s("The investment's current value.")),va("future_value (number)",s("The investment's desired future value."))],returns:["NUMBER"],compute:function(e,t,i){const o=Po(e),n=Po(t),r=Po(i);return vh(o),ko((()=>n>0),s("The present_value (%s) must be strictly positive.",n.toString())),ko((()=>r>0),s("The future_value (%s) must be strictly positive.",r.toString())),(Math.log(r)-Math.log(n))/Math.log(1+o)},isExported:!0},hd={description:s("Periodic payment for an annuity investment."),args:[va("rate (number)",s("The annualized rate of interest.")),va("number_of_periods (number)",s("The number of payments to be made.")),va("present_value (number)",s("The current value of the annuity.")),va("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),va("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=Po(t),r=Po(e),a=$o(n)?1:0;let l=Po(o),c=Po(i);if(fh(s),0===r)return-(l+c)/s;let h=-(c*(1+r)**s+l);return h=h*r/((1+r*a)*((1+r)**s-1)),h},isExported:!0},dd={description:s("Payment on the principal of an investment."),args:[va("rate (number)",s("The annualized rate of interest.")),va("period (number)",s("The amortization period, in terms of number of periods.")),va("number_of_periods (number)",s("The number of payments to be made.")),va("present_value (number)",s("The current value of the annuity.")),va("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),va("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o,n=0,r=0){n=n||0,r=r||0;const a=Po(i),l=Po(e),c=Po(t),h=$o(r)?1:0,d=Po(n),u=Po(o);fh(a),ko((()=>c>0&&c<=a),s("The period must be between 1 and number_of_periods",a.toString()));const g=hd.compute(l,a,u,d,r);if(1===h&&1===c)return g;return g+-Qh.compute(l,0===h?c-1:c-2,g,u+g*h,0)*l},isExported:!0},ud={description:s("Present value of an annuity investment."),args:[va("rate (number)",s("The interest rate.")),va("number_of_periods (number)",s("The number of payments to be made.")),va("payment_amount (number)",s("The amount per period to be paid.")),va("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),va("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o=0,n=0){o=o||0,n=n||0;const s=Po(e),r=Po(t),a=Po(i),l=Po(o),c=$o(n)?1:0;return s?-(a*(1+s*c)*((1+s)**r-1)/s+l)/(1+s)**r:-(l+a*r)},isExported:!0},gd={description:s("Price of a security paying periodic interest."),args:[va("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),va("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),va("rate (number)",s("The annualized rate of interest.")),va("yield (number)",s("The expected annual yield of the security.")),va("redemption (number)",s("The redemption amount per 100 face value, or par.")),va("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),va("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r,a=0){a=a||0;const l=Math.trunc(Po(e)),c=Math.trunc(Po(t)),h=Po(i),d=Po(o),u=Po(n),g=Math.trunc(Po(r)),p=Math.trunc(Po(a));hh(l,c),uh(g),gh(p),ko((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),ko((()=>d>=0),s("The yield (%s) must be positive or null.",d.toString())),ph(u);const m=Jc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=1+d/g,S=100*h/g;if(1===f)return(S+u)/(v*d/g+1)-S*(1-v);let C=0;for(let e=1;e<=f;e++)C+=S/b**(e-1+v);return u/b**(f-1+v)+C-S*(1-v)},isExported:!0},pd={description:s("Price of a discount security."),args:[va("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),va("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),va("discount (number)",s("The discount rate of the security at time of purchase.")),va("redemption (number)",s("The redemption amount per 100 face value, or par.")),va("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Po(e)),r=Math.trunc(Po(t)),a=Po(i),l=Po(o),c=Math.trunc(Po(n));hh(s,r),gh(c),Ih(a),ph(l);return l-a*l*Jc.compute(s,r,c)},isExported:!0},md={description:s("Calculates the price of a security paying interest at maturity, based on expected yield."),args:[va("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),va("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),va("issue (date)",s("The date the security was initially issued.")),va("rate (number)",s("The annualized rate of interest.")),va("yield (number)",s("The expected annual yield of the security.")),va("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){r=r||0;const a=Math.trunc(Po(e)),l=Math.trunc(Po(t)),c=Math.trunc(Po(i)),h=Po(o),d=Po(n),u=Math.trunc(Po(r));dh(a,c),hh(a,l),gh(u),ko((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),ko((()=>d>=0),s("The yield (%s) must be positive or null.",d.toString()));const g=Jc.compute(a,l,u),p=Jc.compute(a,c,u);return(100+Jc.compute(c,l,u)*h*100)/(1+g*d)-p*h*100},isExported:!0},fd=.1,vd={description:s("Interest rate of an annuity investment."),args:[va("number_of_periods (number)",s("The number of payments to be made.")),va("payment_per_period (number)",s("The amount per period to be paid.")),va("present_value (number)",s("The current value of the annuity.")),va("future_value (number, default=0)",s("The future value remaining after the final payment has been made.")),va("end_or_beginning (number, default=0)",s("Whether payments are due at the end (0) or beginning (1) of each period.")),va("rate_guess (number, default=0.1)",s("An estimate for what the interest rate will be."))],returns:["NUMBER"],computeFormat:()=>"0%",compute:function(e,t,i,o=0,n=0,r=.1){o=o||0,n=n||0,r=r||fd;const a=Po(e),l=Po(t),c=$o(n)?1:0,h=Po(r);let d=Po(o),u=Po(i);fh(a),ko((()=>[l,u,d].some((e=>e>0))&&[l,u,d].some((e=>e<0))),s("There must be both positive and negative values in [payment_amount, present_value, future_value].",a.toString())),Oh(h),d-=l*c,u+=l*c;return Dh((e=>{const t=Math.pow(1+e,a);return d+u*t+l*((t-1)/e)}),(e=>{const t=Math.pow(1+e,a-1),i=Math.pow(1+e,a);return u*a*t+l*(a*t/e-(i-1)/e/e)}),h,40,1e-5)},isExported:!0},bd={description:s("Amount received at maturity for a security."),args:[va("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),va("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),va("investment (number)",s("The amount invested (irrespective of face value of each security).")),va("discount (number)",s("The discount rate of the security invested in.")),va("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Po(e)),r=Math.trunc(Po(t)),a=Po(i),l=Po(o),c=Math.trunc(Po(n));hh(s,r),gh(c),xh(a),Ih(l);return a/(1-l*Jc.compute(s,r,c))},isExported:!0},Sd={description:s("Computes the rate needed for an investment to reach a specific value within a specific number of periods."),args:[va("number_of_periods (number)",s("The number of periods.")),va("present_value (number)",s("The present value of the investment.")),va("future_value (number)",s("The future value of the investment."))],returns:["NUMBER"],compute:function(e,t,i){const o=Po(e),n=Po(t),s=Po(i);return fh(o),(s/n)**(1/o)-1},isExported:!0},Cd={description:s("Depreciation of an asset using the straight-line method."),args:[va("cost (number)",s("The initial cost of the asset.")),va("salvage (number)",s("The value of the asset at the end of depreciation.")),va("life (number)",s("The number of periods over which the asset is depreciated."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i){return(Po(e)-Po(t))/Po(i)},isExported:!0},Ed={description:s("Depreciation via sum of years digit method."),args:[va("cost (number)",s("The initial cost of the asset.")),va("salvage (number)",s("The value of the asset at the end of depreciation.")),va("life (number)",s("The number of periods over which the asset is depreciated.")),va("period (number)",s("The single period within life for which to calculate depreciation."))],returns:["NUMBER"],computeFormat:()=>"#,##0.00",compute:function(e,t,i,o){const n=Po(e),s=Po(t),r=Po(i),a=Po(o);Ch(a),bh(r),yh(a,r);return(r-a+1)/(r*(r+1)/2)*(n-s)},isExported:!0},wd={description:s("Price of a US Treasury bill."),args:[va("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),va("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),va("discount (number)",s("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(Po(e)),n=Math.trunc(Po(t)),s=Po(i);hh(o,n),Ah(o,n),Ih(s),Rh(s);return 100*(1-s*Jc.compute(o,n,2))},isExported:!0},yd={description:s("Equivalent rate of return for a US Treasury bill."),args:[va("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),va("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),va("discount (number)",s("The discount rate of the bill at time of purchase."))],returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(Po(e)),n=Math.trunc(Po(t)),s=Po(i);hh(o,n),Ah(o,n),Ih(s),Rh(s);const r=_c.compute(n,o);if(r<=182)return 365*s/(360-s*r);const a=wd.compute(o,n,s)/100,l=r/(366===r?366:365);return(-2*l+2*Math.sqrt(l**2-(2*l-1)*(1-1/a)))/(2*l-1)},isExported:!0},xd={description:s("The yield of a US Treasury bill based on price."),args:[va("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),va("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),va("price (number)",s("The price at which the security is bought per 100 face value."))],returns:["NUMBER"],compute:function(e,t,i){const o=Math.trunc(Po(e)),n=Math.trunc(Po(t)),s=Po(i);hh(o,n),Ah(o,n),mh(s);return(100-s)/s*(1/Jc.compute(o,n,2))},isExported:!0},Id={description:s("Variable declining balance. WARNING : does not handle decimal periods."),args:[va("cost (number)",s("The initial cost of the asset.")),va("salvage (number)",s("The value of the asset at the end of depreciation.")),va("life (number)",s("The number of periods over which the asset is depreciated.")),va("start (number)",s("Starting period to calculate depreciation.")),va("end (number)",s("Ending period to calculate depreciation.")),va("factor (number, default=2)",s("The number of months in the first year of depreciation.")),va("no_switch (number, default=false)",s("Whether to switch to straight-line depreciation when the depreciation is greater than the declining balance calculation."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=2,a=false){r=r||0;const l=Po(e),c=Po(t),h=Po(i),d=Math.trunc(Po(o)),u=Math.trunc(Po(n)),g=Po(r),p=$o(a);if(Sh(l),Eh(c),function(e,t,i){bh(i),ko((()=>e>=0),s("The start_period (%s) must be greater or equal than 0.",e.toString())),ko((()=>t>=0),s("The end_period (%s) must be greater or equal than 0.",t.toString())),ko((()=>e<=t),s("The start_period (%s) must be smaller or equal to the end_period (%s).",e.toString(),t.toString())),ko((()=>t<=i),s("The end_period (%s) must be smaller or equal to the life (%s).",e.toString(),i.toString()))}(d,u,h),Th(g),0===l)return 0;if(c>=l)return d<1?l-c:0;const m=g/h;if(m>=1)return d<1?l-c:0;let f=l,v=0,b=0,S=!1;for(let e=0;e<u;e++){if(!S||p){const t=f*m,i=(f-c)/(h-e);!p&&i>t?(S=!0,v=i):v=t}const t=Math.max(f-v,c);e>=d&&(b+=f-t),f=t}return b},isExported:!0},Rd={description:s("Internal rate of return given non-periodic cash flows."),args:[va("cashflow_amounts (range<number>)",s("An range containing the income or payments associated with the investment.")),va("cashflow_dates (range<number>)",s("An range with dates corresponding to the cash flows in cashflow_amounts.")),va("rate_guess (number, default=0.1)",s("An estimate for what the internal rate of return will be."))],returns:["NUMBER"],compute:function(e,t,i=.1){const o=Po(i=i||0),n=e.flat().map(Po),r=t.flat().map(Po);var a;Nh(e,t),a=n,ko((()=>a.some((e=>e>0))&&a.some((e=>e<0))),s("There must be both positive and negative values in cashflow_amounts.")),_h(r),Oh(o);const l=new Map;for(const e of He(0,r.length)){const t=r[e];l.has(t)?l.set(t,l.get(t)+n[e]):l.set(t,n[e])}const c=Array.from(l.keys()),h=c.map((e=>l.get(e)));return Dh((e=>{let t=h[0];for(const i of He(1,h.length)){const o=(c[0]-c[i])/365;t+=h[i]*(1+e)**o}return t}),(e=>{let t=0;for(const i of He(1,h.length)){const o=(c[0]-c[i])/365;t+=o*h[i]*(1+e)**(o-1)}return t}),o,40,1e-5,(e=>e?e/10-.9:-.9))},isExported:!0},Td={description:s("Net present value given to non-periodic cash flows.."),args:[va("discount (number)",s("The discount rate of the investment over one period.")),va("cashflow_amounts (number, range<number>)",s("An range containing the income or payments associated with the investment.")),va("cashflow_dates (number, range<number>)",s("An range with dates corresponding to the cash flows in cashflow_amounts."))],returns:["NUMBER"],compute:function(e,t,i){const o=Po(e),n=Array.isArray(t)?t.flat().map(Uo):[Uo(t)],r=Array.isArray(i)?i.flat().map(Uo):[Uo(i)];if(Array.isArray(i)&&Array.isArray(t)?Nh(t,i):ko((()=>n.length===r.length),s("There must be the same number of values in cashflow_amounts and cashflow_dates.")),_h(r),vh(o),1===n.length)return n[0];const a=new Map;for(const e of He(0,r.length)){const t=r[e];a.has(t)?a.set(t,a.get(t)+n[e]):a.set(t,n[e])}const l=Array.from(a.keys()),c=l.map((e=>a.get(e)));let h=c[0];for(const e of He(1,c.length)){const t=(l[0]-l[e])/365;h+=c[e]*(1+o)**t}return h},isExported:!0},Ad={description:s("Annual yield of a security paying periodic interest."),args:[va("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),va("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),va("rate (number)",s("The annualized rate of interest.")),va("price (number)",s("The price at which the security is bought per 100 face value.")),va("redemption (number)",s("The redemption amount per 100 face value, or par.")),va("frequency (number)",s("The number of interest or coupon payments per year (1, 2, or 4).")),va("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r,a=0){a=a||0;const l=Math.trunc(Po(e)),c=Math.trunc(Po(t)),h=Po(i),d=Po(o),u=Po(n),g=Math.trunc(Po(r)),p=Math.trunc(Po(a));hh(l,c),uh(g),gh(p),ko((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),mh(d),ph(u);const m=Jc.compute(l,c,p)*g,f=Math.ceil(m),v=m-Math.floor(m)||1,b=100*h/g;if(1===f){const e=d+b*(1-v);return(u+b-e)*g*(1/v)/e}const S=Dh((function(e){return function(e,t,i,o,n,s){let r=s-(e+n*(1-t))*o**(i-1+t);for(let e=1;e<=i;e++)r+=n*o**(e-1);return r}(d,v,f,e,b,u)}),(function(e){return function(e,t,i,o,n){let s=-(e+n*(1-t))*(i-1+t)*o**(i-2+t);for(let e=1;e<=i;e++)s+=n*(e-1)*o**(e-2);return s}(d,v,f,e,b)}),1+(h+1)/g,100,1e-5);return(S-1)*g},isExported:!0},Md={description:s("Annual yield of a discount security."),args:[va("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),va("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),va("price (number)",s("The price at which the security is bought per 100 face value.")),va("redemption (number)",s("The redemption amount per 100 face value, or par.")),va("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n=0){n=n||0;const s=Math.trunc(Po(e)),r=Math.trunc(Po(t)),a=Po(i),l=Po(o),c=Math.trunc(Po(n));hh(s,r),gh(c),mh(a),ph(l);return(l/a-1)/Jc.compute(e,t,n)},isExported:!0},Od={description:s("Annual yield of a security paying interest at maturity."),args:[va("settlement (date)",s("The settlement date of the security, the date after issuance when the security is delivered to the buyer.")),va("maturity (date)",s("The maturity or end date of the security, when it can be redeemed at face, or par value.")),va("issue (date)",s("The date the security was initially issued.")),va("rate (number)",s("The annualized rate of interest.")),va("price (number)",s("The price at which the security is bought.")),va("day_count_convention (number, default=0 )",s("An indicator of what day count method to use."))],returns:["NUMBER"],compute:function(e,t,i,o,n,r=0){r=r||0;const a=Math.trunc(Po(e)),l=Math.trunc(Po(t)),c=Math.trunc(Po(i)),h=Po(o),d=Po(n),u=Math.trunc(Po(r));hh(a,l),gh(u),ko((()=>a>=c),s("The settlement (%s) must be greater than or equal to the issue (%s).",a.toString(),c.toString())),ko((()=>h>=0),s("The rate (%s) must be positive or null.",h.toString())),mh(d);const g=Jc.compute(c,l,u),p=Jc.compute(c,a,u),m=Jc.compute(a,l,u);return(100*(1+h*g)/(d+100*h*p)-1)/m},isExported:!0};var Nd=Object.freeze({__proto__:null,ACCRINTM:kh,AMORLINC:Lh,COUPDAYS:Ph,COUPDAYBS:Uh,COUPDAYSNC:Vh,COUPNCD:zh,COUPNUM:Bh,COUPPCD:Hh,CUMIPMT:$h,CUMPRINC:Wh,DB:Gh,DDB:qh,DISC:Zh,DOLLARDE:jh,DOLLARFR:Xh,DURATION:Yh,EFFECT:Kh,FV:Qh,FVSCHEDULE:Jh,INTRATE:ed,IPMT:td,IRR:id,ISPMT:od,MDURATION:nd,MIRR:sd,NOMINAL:rd,NPER:ad,NPV:ld,PDURATION:cd,PMT:hd,PPMT:dd,PV:ud,PRICE:gd,PRICEDISC:pd,PRICEMAT:md,RATE:vd,RECEIVED:bd,RRI:Sd,SLN:Cd,SYD:Ed,TBILLPRICE:wd,TBILLEQ:yd,TBILLYIELD:xd,VDB:Id,XIRR:Rd,XNPV:Td,YIELD:Ad,YIELDDISC:Md,YIELDMAT:Od});const _d={description:s("Whether a value is an error other than #N/A."),args:[va("value (any, lazy)",s("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return(null==e?void 0:e.errorType)!=a.NotAvailable}},isExported:!0},Fd={description:s("Whether a value is an error."),args:[va("value (any, lazy)",s("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return!0}},isExported:!0},Dd={description:s("Whether a value is `true` or `false`."),args:[va("value (any, lazy)",s("The value to be verified as a logical TRUE or FALSE."))],returns:["BOOLEAN"],compute:function(e){try{return"boolean"==typeof e()}catch(e){return!1}},isExported:!0},kd={description:s("Whether a value is the error #N/A."),args:[va("value (any, lazy)",s("The value to be verified as an error type."))],returns:["BOOLEAN"],compute:function(e){try{return e(),!1}catch(e){return(null==e?void 0:e.errorType)==a.NotAvailable}},isExported:!0},Ld={description:s("Whether a value is non-textual."),args:[va("value (any, lazy)",s("The value to be checked."))],returns:["BOOLEAN"],compute:function(e){try{return"string"!=typeof e()}catch(e){return!0}},isExported:!0},Pd={description:s("Whether a value is a number."),args:[va("value (any, lazy)",s("The value to be verified as a number."))],returns:["BOOLEAN"],compute:function(e){try{return"number"==typeof e()}catch(e){return!1}},isExported:!0},Ud={description:s("Whether a value is text."),args:[va("value (any, lazy)",s("The value to be verified as text."))],returns:["BOOLEAN"],compute:function(e){try{return"string"==typeof e()}catch(e){return!1}},isExported:!0},Vd={description:s("Whether the referenced cell is empty"),args:[va("value (any, lazy)",s("Reference to the cell that will be checked for emptiness."))],returns:["BOOLEAN"],compute:function(e){try{return null===e()}catch(e){return!1}},isExported:!0},zd={description:s("Returns the error value #N/A."),args:[],returns:["BOOLEAN"],compute:function(e){throw new g},isExported:!0};var Bd=Object.freeze({__proto__:null,ISERR:_d,ISERROR:Fd,ISLOGICAL:Dd,ISNA:kd,ISNONTEXT:Ld,ISNUMBER:Pd,ISTEXT:Ud,ISBLANK:Vd,NA:zd});const Hd={description:s("Logical `and` operator."),args:[va("logical_expression1 (boolean, range<boolean>)",s("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),va("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that represent logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!0;return Qo(e,(e=>(t=!0,i=i&&e,i))),ko((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},$d={description:s("Returns value depending on logical expression."),args:[va("logical_expression (boolean)",s("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE.")),va("value_if_true (any, lazy)",s("The value the function returns if logical_expression is TRUE.")),va("value_if_false (any, lazy, default=FALSE)",s("The value the function returns if logical_expression is FALSE."))],returns:["ANY"],compute:function(e,t,i=(()=>!1)){const o=$o(e)?t():i();return null==o?"":o},isExported:!0},Wd={description:s("Value if it is not an error, otherwise 2nd argument."),args:[va("value (any, lazy)",s("The value to return if value itself is not an error.")),va('value_if_error (any, lazy, default="empty")',s("The value the function returns if value is an error."))],returns:["ANY"],computeFormat:(e,t=(()=>({value:""})))=>{var i;try{return e().format}catch(e){return null===(i=t())||void 0===i?void 0:i.format}},compute:function(e,t=(()=>"")){let i;try{i=e()}catch(e){i=t()}return null==i?"":i},isExported:!0},Gd={description:s("Value if it is not an #N/A error, otherwise 2nd argument."),args:[va("value (any, lazy)",s("The value to return if value itself is not #N/A an error.")),va('value_if_error (any, lazy, default="empty")',s("The value the function returns if value is an #N/A error."))],returns:["ANY"],compute:function(e,t=(()=>"")){let i;try{i=e()}catch(o){i=o.errorType===a.NotAvailable?t():e()}return null==i?"":i},isExported:!0},qd={description:s("Returns a value depending on multiple logical expressions."),args:[va("condition1 (boolean, lazy)",s("The first condition to be evaluated. This can be a boolean, a number, an array, or a reference to any of those.")),va("value1 (any, lazy)",s("The returned value if condition1 is TRUE.")),va("condition2 (boolean, lazy, repeating)",s("Additional conditions to be evaluated if the previous ones are FALSE.")),va("value2 (any, lazy, repeating)",s("Additional values to be returned if their corresponding conditions are TRUE."))],returns:["ANY"],compute:function(...e){ko((()=>e.length%2==0),s("Wrong number of arguments. Expected an even number of arguments."));for(let t=0;t<e.length-1;t+=2)if($o(e[t]())){const i=e[t+1]();return null!==i?i:""}throw new Error(s("No match."))},isExported:!0},Zd={description:s("Returns opposite of provided logical value."),args:[va("logical_expression (boolean)",s("An expression or reference to a cell holding an expression that represents some logical value."))],returns:["BOOLEAN"],compute:function(e){return!$o(e)},isExported:!0},jd={description:s("Logical `or` operator."),args:[va("logical_expression1 (boolean, range<boolean>)",s("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),va("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return Qo(e,(e=>(t=!0,i=i||e,!i))),ko((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0},Xd={description:s("Logical `xor` operator."),args:[va("logical_expression1 (boolean, range<boolean>)",s("An expression or reference to a cell containing an expression that represents some logical value, i.e. TRUE or FALSE, or an expression that can be coerced to a logical value.")),va("logical_expression2 (boolean, range<boolean>, repeating)",s("More expressions that evaluate to logical values."))],returns:["BOOLEAN"],compute:function(...e){let t=!1,i=!1;return Qo(e,(e=>(t=!0,i=i?!e:e,!0))),ko((()=>t),s("[[FUNCTION_NAME]] has no valid input data.")),i},isExported:!0};var Yd=Object.freeze({__proto__:null,AND:Hd,IF:$d,IFERROR:Wd,IFNA:Gd,IFS:qd,NOT:Zd,OR:jd,XOR:Xd});function Kd(e,t){if(void 0===e)throw new g(s("Did not find value '%s' in [[FUNCTION_NAME]] evaluation.",Vo(t)))}const Qd={description:s("Column number of a specified cell."),args:[va("cell_reference (meta, default='this cell')",s("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."))],returns:["NUMBER"],compute:function(e){var t;const i=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this));ko((()=>!!i),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Bi(i).left+1},isExported:!0},Jd={description:s("Number of columns in a specified array or range."),args:[va("range (meta)",s("The range whose column count will be returned."))],returns:["NUMBER"],compute:function(e){const t=Bi(e);return t.right-t.left+1},isExported:!0},eu={description:s("Horizontal lookup"),args:[va("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),va("range (range)",s("The range to consider for the search. The first row in the range is searched for the key specified in search_key.")),va("index (number)",s("The row index of the value to be returned, where the first row in range is numbered 1.")),va("is_sorted (boolean, default=true)",s("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."))],returns:["ANY"],compute:function(e,t,i,o=true){const n=Math.trunc(Po(i)),r=Bo(e);ko((()=>1<=n&&n<=t[0].length),s("[[FUNCTION_NAME]] evaluates to an out of bounds range."));let a;a=$o(o)?sn(t,r,"nextSmaller","asc",t.length,nn):rn(t,r,"strict",t.length,nn);const l=t[a];return Kd(l,e),l[n-1]},isExported:!0},tu={description:s("Returns the content of a cell, specified by row and column offset."),args:[va("reference (any, range)",s("The range of cells from which the values are returned.")),va("row (number)",s("The index of the row to be returned from within the reference range of cells.")),va("column (number)",s("The index of the column to be returned from within the reference range of cells."))],returns:["ANY"],computeFormat:(e,t,i)=>{var o;const n=Po(t.value);return null===(o=e[Po(i.value)-1][n-1])||void 0===o?void 0:o.format},compute:function(e,t,i){const o=(n=e,Array.isArray(n)&&Array.isArray(n[0])?e:[[e]]);var n;const r=Po(t),a=Po(i);return ko((()=>a>=0&&a-1<o.length&&r>=0&&r-1<o[0].length),s("Index out of range.")),ko((()=>0!==t&&0!==i),s("This function can only return a single cell value, not an array. Provide valid row and column indices.")),o[a-1][r-1]},isExported:!0},iu={description:s("Look up a value."),args:[va("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),va("search_array (range)",s("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.")),va("result_range (range, optional)",s("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."))],returns:["ANY"],compute:function(e,t,i){let o=t.length,n=t[0].length;const r=Bo(e),a=n>=o,l=sn(t,r,"nextSmaller","asc",a?n:o,a?on:nn);return-1===l&&Kd(void 0,e),Kd(a?t[0][l]:t[l][n-1],e),void 0===i?a?t[o-1][l]:t[l][n-1]:(o=i.length,n=i[0].length,ko((()=>1===o||1===n),s("The result_range must be a single row or a single column.")),o>1?(ko((()=>l<=o-1),s("[[FUNCTION_NAME]] evaluates to an out of range row value %s.",(l+1).toString())),i[l][0]):(ko((()=>l<=n-1),s("[[FUNCTION_NAME]] evaluates to an out of range column value %s.",(l+1).toString())),i[0][l]))},isExported:!0},ou={description:s("Position of item in range that matches value."),args:[va("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),va("range (any, range)",s("The one-dimensional array to be searched.")),va("search_type (number, default=1)",s("The search method. 1 (default) 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."))],returns:["NUMBER"],compute:function(e,t,i=1){let o=Po(i);const n=Bo(e),r=t.length,a=t[0].length;ko((()=>1===r||1===a),s("The range must be a single row or a single column."));let l=-1;const c=1===r?on:nn,h=1===r?t[0].length:t.length;switch(o=Math.sign(o),o){case 1:l=sn(t,n,"nextSmaller","asc",h,c);break;case 0:l=rn(t,n,"strict",h,c);break;case-1:l=sn(t,n,"nextGreater","desc",h,c)}return Kd(1===r?t[0][l]:t[l],e),l+1},isExported:!0},nu={description:s("Row number of a specified cell."),args:[va("cell_reference (meta, default='this cell')",s("The cell whose row number will be returned. By default, this function uses the cell in which the formula is entered."))],returns:["NUMBER"],compute:function(e){var t;e=e||(null===(t=this.__originCellXC)||void 0===t?void 0:t.call(this)),ko((()=>!!e),"In this context, the function [[FUNCTION_NAME]] needs to have a cell or range in parameter.");return Bi(e).top+1},isExported:!0},su={description:s("Number of rows in a specified array or range."),args:[va("range (meta)",s("The range whose row count will be returned."))],returns:["NUMBER"],compute:function(e){const t=Bi(e);return t.bottom-t.top+1},isExported:!0},ru={description:s("Vertical lookup."),args:[va("search_key (any)",s("The value to search for. For example, 42, 'Cats', or I24.")),va("range (any, range)",s("The range to consider for the search. The first column in the range is searched for the key specified in search_key.")),va("index (number)",s("The column index of the value to be returned, where the first column in range is numbered 1.")),va("is_sorted (boolean, default=true)",s("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."))],returns:["ANY"],compute:function(e,t,i,o=true){const n=Math.trunc(Po(i)),r=Bo(e);ko((()=>1<=n&&n<=t.length),s("[[FUNCTION_NAME]] evaluates to an out of bounds range."));let a;a=$o(o)?sn(t,r,"nextSmaller","asc",t[0].length,on):rn(t,r,"strict",t[0].length,on);const l=t[n-1][a];return Kd(l,e),l},isExported:!0},au={description:s("Search a range for a match and return the corresponding item from a second range."),args:[va("search_key (any)",s("The value to search for.")),va("lookup_range (any, range)",s("The range to consider for the search. Should be a single column or a single row.")),va("return_range (any, range)",s("The range containing the return value. Should have the same dimensions as lookup_range.")),va("if_not_found (any, lazy, optional)",s("If a valid match is not found, return this value.")),va("match_mode (any, default=0)",s("(0) Exact match. (-1) Return next smaller item if no match. (1) Return next greater item if no match.")),va("search_mode (any, default=1)",s("(1) Search starting at first item. (-1) Search starting at last item. (2) Perform a binary search that relies on lookup_array being sorted in ascending order. If not sorted, invalid results will be returned. (-2) Perform a binary search that relies on lookup_array being sorted in descending order. If not sorted, invalid results will be returned. "))],returns:["ANY"],compute:function(e,t,i,o,n=0,r=1){const a=Math.trunc(Po(n)),l=Math.trunc(Po(r)),c=Bo(e);ko((()=>1===t.length||1===t[0].length),s("lookup_range should be either a single row or single column.")),ko((()=>1===i.length||1===i[0].length),s("return_range should be either a single row or single column.")),ko((()=>i.length===t.length&&i[0].length===t[0].length),s("return_range should have the same dimensions as lookup_range.")),ko((()=>[-1,1,-2,2].includes(l)),s("searchMode should be a value in [-1, 1, -2, 2].")),ko((()=>[-1,0,1].includes(a)),s("matchMode should be a value in [-1, 0, 1]."));const h=1===t.length?on:nn,d=1===t.length?t[0].length:t.length,u=0===a?"strict":1===a?"nextGreater":"nextSmaller",g=-1===l;let p;if(2===l||-2===l){p=sn(t,c,u,2===l?"asc":"desc",d,h)}else p=rn(t,c,u,d,h,g);if(-1!==p)return 1===t.length?i[0][p]:i[p][0];const m=null==o?void 0:o();return Kd(m,e),m},isExported:!0};var lu=Object.freeze({__proto__:null,COLUMN:Qd,COLUMNS:Jd,HLOOKUP:eu,INDEX:tu,LOOKUP:iu,MATCH:ou,ROW:nu,ROWS:su,VLOOKUP:ru,XLOOKUP:au});const cu={description:s("Sum of two numbers."),args:[va("value1 (number)",s("The first addend.")),va("value2 (number)",s("The second addend."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Po(e)+Po(t)}},hu={description:s("Concatenation of two values."),args:[va("value1 (string)",s("The value to which value2 will be appended.")),va("value2 (string)",s("The value to append to value1."))],returns:["STRING"],compute:function(e,t){return Vo(e)+Vo(t)},isExported:!0},du={description:s("One number divided by another."),args:[va("dividend (number)",s("The number to be divided.")),va("divisor (number)",s("The number to divide by."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){const i=Po(t);return ko((()=>0!==i),s("The divisor must be different from zero.")),Po(e)/i}};function uu(e){return null==e}const gu={number:0,string:"",boolean:!1},pu={description:s("Equal."),args:[va("value1 (any)",s("The first value.")),va("value2 (any)",s("The value to test against value1 for equality."))],returns:["BOOLEAN"],compute:function(e,t){return e=uu(e)?gu[typeof t]:e,t=uu(t)?gu[typeof e]:t,"string"==typeof e&&(e=e.toUpperCase()),"string"==typeof t&&(t=t.toUpperCase()),e===t}};function mu(e,t,i){e=uu(e)?gu[typeof t]:e,t=uu(t)?gu[typeof e]:t,"number"!=typeof e&&(e=Vo(e).toUpperCase()),"number"!=typeof t&&(t=Vo(t).toUpperCase());const o=typeof e,n=typeof t;return"string"===o&&"number"===n||("string"!==n||"number"!==o)&&i(e,t)}const fu={description:s("Strictly greater than."),args:[va("value1 (any)",s("The value to test as being greater than value2.")),va("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return mu(e,t,((e,t)=>e>t))}},vu={description:s("Greater than or equal to."),args:[va("value1 (any)",s("The value to test as being greater than or equal to value2.")),va("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return mu(e,t,((e,t)=>e>=t))}},bu={description:s("Less than."),args:[va("value1 (any)",s("The value to test as being less than value2.")),va("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!vu.compute(e,t)}},Su={description:s("Less than or equal to."),args:[va("value1 (any)",s("The value to test as being less than or equal to value2.")),va("value2 (any)",s("The second value."))],returns:["BOOLEAN"],compute:function(e,t){return!fu.compute(e,t)}},Cu={description:s("Difference of two numbers."),args:[va("value1 (number)",s("The minuend, or number to be subtracted from.")),va("value2 (number)",s("The subtrahend, or number to subtract from value1."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Po(e)-Po(t)}},Eu={description:s("Product of two numbers"),args:[va("factor1 (number)",s("The first multiplicand.")),va("factor2 (number)",s("The second multiplicand."))],returns:["NUMBER"],computeFormat:(e,t)=>(null==e?void 0:e.format)||(null==t?void 0:t.format),compute:function(e,t){return Po(e)*Po(t)}},wu={description:s("Not equal."),args:[va("value1 (any)",s("The first value.")),va("value2 (any)",s("The value to test against value1 for inequality."))],returns:["BOOLEAN"],compute:function(e,t){return!pu.compute(e,t)}},yu={description:s("A number raised to a power."),args:[va("base (number)",s("The number to raise to the exponent power.")),va("exponent (number)",s("The exponent to raise base to."))],returns:["NUMBER"],compute:function(e,t){return sl.compute(e,t)}},xu={description:s("A number with the sign reversed."),args:[va("value (number)",s("The number to have its sign reversed. Equivalently, the number to multiply by -1."))],computeFormat:e=>null==e?void 0:e.format,returns:["NUMBER"],compute:function(e){return-Po(e)}},Iu={description:s("Value interpreted as a percentage."),args:[va("percentage (number)",s("The value to interpret as a percentage."))],returns:["NUMBER"],compute:function(e){return Po(e)/100}},Ru={description:s("A specified number, unchanged."),args:[va("value (any)",s("The number to return."))],returns:["ANY"],computeFormat:e=>null==e?void 0:e.format,compute:function(e){return null===e?"":e}};var Tu=Object.freeze({__proto__:null,ADD:cu,CONCAT:hu,DIVIDE:du,EQ:pu,GT:fu,GTE:vu,LT:bu,LTE:Su,MINUS:Cu,MULTIPLY:Eu,NE:wu,POW:yu,UMINUS:xu,UNARY_PERCENT:Iu,UPLUS:Ru});const Au=/[A-Za-zÀ-ÖØ-öø-ÿ]+/g,Mu={description:s("Gets character associated with number."),args:[va("table_number (number)",s("The number of the character to look up from the current Unicode table in decimal format."))],returns:["STRING"],compute:function(e){const t=Math.trunc(Po(e));return ko((()=>t>=1),s("The table_number (%s) is out of range.",t.toString())),String.fromCharCode(t)},isExported:!0},Ou={description:s("Remove non-printable characters from a piece of text."),args:[va("text (string)",s("The text whose non-printable characters are to be removed."))],returns:["STRING"],compute:function(e){const t=Vo(e);let i="";for(const e of t)e&&e.charCodeAt(0)>31&&(i+=e);return i},isExported:!0},Nu={description:s("Appends strings to one another."),args:[va("string1 (string, range<string>)",s("The initial string.")),va("string2 (string, range<string>, repeating)",s("More strings to append in sequence."))],returns:["STRING"],compute:function(...e){return Xo(e,((e,t)=>e+Vo(t)),"")},isExported:!0},_u={description:s("Tests whether two strings are identical."),args:[va("string1 (string)",s("The first string to compare.")),va("string2 (string)",s("The second string to compare."))],returns:["BOOLEAN"],compute:function(e,t){return Vo(e)===Vo(t)},isExported:!0},Fu={description:s("First position of string found in text, case-sensitive."),args:[va("search_for (string)",s("The string to look for within text_to_search.")),va("text_to_search (string)",s("The text to search for the first occurrence of search_for.")),va("starting_at (number, default=1)",s("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,i=1){const o=Vo(e),n=Vo(t),r=Po(i);ko((()=>""!==n),s("The text_to_search must be non-empty.")),ko((()=>r>=1),s("The starting_at (%s) must be greater than or equal to 1.",r.toString()));const a=n.indexOf(o,r-1);return ko((()=>a>=0),s("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",o.toString(),n)),a+1},isExported:!0},Du={description:s("Concatenates elements of arrays with delimiter."),args:[va("delimiter (string)",s("The character or string to place between each concatenated value.")),va("value_or_array1 (string, range<string>)",s("The value or values to be appended using delimiter.")),va("value_or_array2 (string, range<string>, repeating)",s("More values to be appended using delimiter."))],returns:["STRING"],compute:function(e,...t){const i=Vo(e);return Xo(t,((e,t)=>(e?e+i:"")+Vo(t)),"")}},ku={description:s("Substring from beginning of specified string."),args:[va("text (string)",s("The string from which the left portion will be returned.")),va("number_of_characters (number, optional)",s("The number of characters to return from the left side of string."))],returns:["STRING"],compute:function(e,...t){const i=t.length?Po(t[0]):1;return ko((()=>i>=0),s("The number_of_characters (%s) must be positive or null.",i.toString())),Vo(e).substring(0,i)},isExported:!0},Lu={description:s("Length of a string."),args:[va("text (string)",s("The string whose length will be returned."))],returns:["NUMBER"],compute:function(e){return Vo(e).length},isExported:!0},Pu={description:s("Converts a specified string to lowercase."),args:[va("text (string)",s("The string to convert to lowercase."))],returns:["STRING"],compute:function(e){return Vo(e).toLowerCase()},isExported:!0},Uu={description:s("A segment of a string."),args:[va("text (string)",s("The string to extract a segment from.")),va(" (number)",s("The index from the left of string from which to begin extracting. The first character in string has the index 1.")),va(" (number)",s("The length of the segment to extract."))],returns:["STRING"],compute:function(e,t,i){const o=Vo(e),n=Po(t),r=Po(i);return ko((()=>n>=1),s("The starting_at argument (%s) must be positive greater than one.",n.toString())),ko((()=>r>=0),s("The extract_length argument (%s) must be positive or null.",r.toString())),o.slice(n-1,n+r-1)},isExported:!0},Vu={description:s("Capitalizes each word in a specified string."),args:[va("text_to_capitalize (string)",s("The text which will be returned with the first letter of each word in uppercase and all other letters in lowercase."))],returns:["STRING"],compute:function(e){return Vo(e).replace(Au,(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()))},isExported:!0},zu={description:s("Replaces part of a text string with different text."),args:[va("text (string)",s("The text, a part of which will be replaced.")),va("position (number)",s("The position where the replacement will begin (starting from 1).")),va("length (number)",s("The number of characters in the text to be replaced.")),va("new_text (string)",s("The text which will be inserted into the original text."))],returns:["STRING"],compute:function(e,t,i,o){const n=Po(t);ko((()=>n>=1),s("The position (%s) must be greater than or equal to 1.",n.toString()));const r=Vo(e),a=Po(i),l=Vo(o);return r.substring(0,n-1)+l+r.substring(n-1+a)},isExported:!0},Bu={description:s("A substring from the end of a specified string."),args:[va("text (string)",s("The string from which the right portion will be returned.")),va("number_of_characters (number, optional)",s("The number of characters to return from the right side of string."))],returns:["STRING"],compute:function(e,...t){const i=t.length?Po(t[0]):1;ko((()=>i>=0),s("The number_of_characters (%s) must be positive or null.",i.toString()));const o=Vo(e),n=o.length;return o.substring(n-i,n)},isExported:!0},Hu={description:s("First position of string found in text, ignoring case."),args:[va("search_for (string)",s("The string to look for within text_to_search.")),va("text_to_search (string)",s("The text to search for the first occurrence of search_for.")),va("starting_at (number, default=1)",s("The character within text_to_search at which to start the search."))],returns:["NUMBER"],compute:function(e,t,i=1){const o=Vo(e).toLowerCase(),n=Vo(t).toLowerCase(),r=Po(i);ko((()=>""!==n),s("The text_to_search must be non-empty.")),ko((()=>r>=1),s("The starting_at (%s) must be greater than or equal to 1.",r.toString()));const a=n.indexOf(o,r-1);return ko((()=>a>=0),s("In [[FUNCTION_NAME]] evaluation, cannot find '%s' within '%s'.",o,n)),a+1},isExported:!0},$u={description:s("Replaces existing text with new text in a string."),args:[va("text_to_search (string)",s("The text within which to search and replace.")),va("search_for (string)",s("The string to search for within text_to_search.")),va("replace_with (string)",s("The string that will replace search_for.")),va("occurrence_number (number, optional)",s("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."))],returns:["NUMBER"],compute:function(e,t,i,o){const n=Po(o);ko((()=>n>=0),s("The occurrenceNumber (%s) must be positive or null.",n.toString()));const r=Vo(e),a=Vo(t);if(""===a)return r;const l=Vo(i),c=new RegExp(Ne(a),"g");if(0===n)return r.replace(c,l);let h=0;return r.replace(c,(e=>++h===n?l:e))},isExported:!0},Wu={description:s("Combines text from multiple strings and/or arrays."),args:[va("delimiter (string)",s(" A string, possible empty, or a reference to a valid string. If empty, the text will be simply concatenated.")),va("ignore_empty (boolean)",s("A boolean; if TRUE, empty cells selected in the text arguments won't be included in the result.")),va("text1 (string, range<string>)",s("Any text item. This could be a string, or an array of strings in a range.")),va("text2 (string, range<string>, repeating)",s("Additional text item(s)."))],returns:["STRING"],compute:function(e,t,...i){const o=Vo(e),n=$o(t);let s=0;return Xo(i,((e,t)=>n&&""===Vo(t)?e:(s++?e+o:"")+Vo(t)),"")},isExported:!0},Gu={description:s("Removes space characters."),args:[va("text (string)",s("The text or reference to a cell containing text to be trimmed."))],returns:["STRING"],compute:function(e){return Vo(e).trim()},isExported:!0},qu={description:s("Converts a specified string to uppercase."),args:[va("text (string)",s("The string to convert to uppercase."))],returns:["STRING"],compute:function(e){return Vo(e).toUpperCase()},isExported:!0},Zu={description:s("Converts a number to text according to a specified format."),args:[va("number (number)",s("The number, date or time to format.")),va("format (string)",s("The pattern by which to format the number, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){return mi(Po(e),Vo(t))},isExported:!0};var ju=Object.freeze({__proto__:null,CHAR:Mu,CLEAN:Ou,CONCATENATE:Nu,EXACT:_u,FIND:Fu,JOIN:Du,LEFT:ku,LEN:Lu,LOWER:Pu,MID:Uu,PROPER:Vu,REPLACE:zu,RIGHT:Bu,SEARCH:Hu,SUBSTITUTE:$u,TEXTJOIN:Wu,TRIM:Gu,UPPER:qu,TEXT:Zu});const Xu={description:s("Creates a hyperlink in a cell."),args:[va("url (string)",s("The full URL of the link enclosed in quotation marks.")),va("link_label (string, optional)",s("The text to display in the cell, enclosed in quotation marks."))],returns:["STRING"],compute:function(e,t){const i=Vo(e).trim(),o=Vo(t)||i;return""===i?o:Ye(o,i)},isExported:!0};var Yu=Object.freeze({__proto__:null,HYPERLINK:Xu});const Ku=[{name:s("Database"),functions:Ac},{name:s("Date"),functions:ah},{name:s("Financial"),functions:Nd},{name:s("Info"),functions:Bd},{name:s("Lookup"),functions:lu},{name:s("Logical"),functions:Yd},{name:s("Math"),functions:yl},{name:s("Misc"),functions:Ca},{name:s("Operator"),functions:Tu},{name:s("Statistical"),functions:gc},{name:s("Text"),functions:ju},{name:s("Engineering"),functions:ch},{name:s("Web"),functions:Yu}],Qu=/^[A-Z0-9\_\.]+$/;function Ju(e){return e.map((e=>{if(void 0!==e)return"function"==typeof e?()=>eg(e()):eg(e)}))}function eg(e){return Array.isArray(e)?e.map((e=>e.map((e=>null==e?void 0:e.value)))):null==e?void 0:e.value}const tg=new class extends Io{constructor(){super(...arguments),this.mapping={}}add(e,t){if(!(e=e.toUpperCase()).match(Qu))throw new Error(s("Invalid function name %s. Function names can exclusively contain alphanumerical values separated by dots (.) or underscore (_)",e));const i=ba(t);return function(e){let t=!1,i=!1,o=!1;for(let n of e){if(n.type.includes("META")&&n.type.length>1)throw new Error(s("Function ${name} has an argument that has been declared with more than one type whose type 'META'. The 'META' type can only be declared alone."));if(t&&!n.repeating)throw new Error(s("Function ${name} has no-repeatable arguments declared after repeatable ones. All repeatable arguments must be declared last."));const e=i||t||o,r=!(n.optional||n.repeating||n.default);if(e&&r)throw new Error(s("Function ${name} has at mandatory arguments declared after optional ones. All optional arguments must be after all mandatory arguments."));t=n.repeating,i=n.optional,o=n.default}}(i.args),this.mapping[e]=function(...e){const t=i.compute.bind(this),o=i.computeFormat?i.computeFormat.bind(this):()=>{};return{value:t(...Ju(e)),format:o(...e)}},super.add(e,i),this}};for(let e of Ku){const t=e.functions;for(let i in t){const o=t[i];o.category=o.category||e.name,i=i.replace(/_/g,"."),tg.add(i,{isExported:!1,...o})}}function ig(e,t,i){const o=e.model.getters.getActiveSheetId(),n="COL"===t?"FREEZE_COLUMNS":"FREEZE_ROWS";e.model.dispatch(n,{sheetId:o,quantity:i}).isCancelledBecause(65)&&e.raiseError(Ls)}const og=new as;og.add("file",{name:s("File"),sequence:10}).add("edit",{name:s("Edit"),sequence:20}).add("view",{name:s("View"),sequence:30}).add("insert",{name:s("Insert"),sequence:40}).add("format",{name:s("Format"),sequence:50}).add("data",{name:s("Data"),sequence:60}).addChild("save",["file"],{name:s("Save"),description:"Ctrl+S",sequence:10,action:()=>console.log("Not implemented")}).addChild("undo",["edit"],{name:s("Undo"),description:"Ctrl+Z",sequence:10,action:e=>e.model.dispatch("REQUEST_UNDO")}).addChild("redo",["edit"],{name:s("Redo"),description:"Ctrl+Y",sequence:20,action:e=>e.model.dispatch("REQUEST_REDO"),separator:!0}).addChild("copy",["edit"],{name:s("Copy"),description:"Ctrl+C",sequence:30,isReadonlyAllowed:!0,action:zr}).addChild("cut",["edit"],{name:s("Cut"),description:"Ctrl+X",sequence:40,action:Br}).addChild("paste",["edit"],{name:s("Paste"),description:"Ctrl+V",sequence:50,action:Hr}).addChild("paste_special",["edit"],{name:s("Paste special"),sequence:60,separator:!0,isVisible:qr}).addChild("paste_special_value",["edit","paste_special"],{name:s("Paste value only"),sequence:10,action:$r}).addChild("paste_special_format",["edit","paste_special"],{name:s("Paste format only"),sequence:20,action:Gr}).addChild("sort_range",["data"],{name:s("Sort range"),sequence:20,isVisible:da,separator:!0}).addChild("sort_ascending",["data","sort_range"],{name:s("Ascending (A ⟶ Z)"),sequence:10,action:ca}).addChild("sort_descending",["data","sort_range"],{name:s("Descending (Z ⟶ A)"),sequence:20,action:ha}).addChild("find_and_replace",["edit"],{name:s("Find and replace"),description:"Ctrl+H",sequence:65,isReadonlyAllowed:!0,action:e=>{e.openSidePanel("FindAndReplace",{})},separator:!0}).addChild("edit_delete_cell_values",["edit"],{name:s("Delete values"),sequence:70,action:e=>e.model.dispatch("DELETE_CONTENT",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})}).addChild("edit_delete_row",["edit"],{name:Zr,sequence:80,action:jr,isVisible:e=>Xr("ROW",e)}).addChild("edit_delete_column",["edit"],{name:Yr,sequence:90,action:Kr,isVisible:e=>Xr("COL",e)}).addChild("edit_delete_cell_shift_up",["edit"],{name:s("Delete cell and shift up"),sequence:93,action:ea}).addChild("edit_delete_cell_shift_left",["edit"],{name:s("Delete cell and shift left"),sequence:97,action:ta}).addChild("edit_unhide_columns",["edit"],{name:s("Unhide all columns"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"COL",elements:Array.from(Array(e.model.getters.getNumberCols(t)).keys())})},isVisible:e=>e.model.getters.getHiddenColsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("edit_unhide_rows",["edit"],{name:s("Unhide all rows"),sequence:100,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:t,dimension:"ROW",elements:Array.from(Array(e.model.getters.getNumberRows(t)).keys())})},isVisible:e=>e.model.getters.getHiddenRowsGroups(e.model.getters.getActiveSheetId()).length>0}).addChild("insert_row_before",["insert"],{name:e=>{const t=Pr(e);return 1===t?s("Row above"):s("%s Rows above",t.toString())},sequence:10,action:ia,isVisible:e=>0===e.model.getters.getActiveCols().size}).addChild("insert_row_after",["insert"],{name:e=>{const t=Pr(e);return 1===t?s("Row below"):s("%s Rows below",t.toString())},sequence:20,action:oa,isVisible:e=>0===e.model.getters.getActiveCols().size,separator:!0}).addChild("insert_column_before",["insert"],{name:e=>{const t=Lr(e);return 1===t?s("Column left"):s("%s Columns left",t.toString())},sequence:30,action:na,isVisible:e=>0===e.model.getters.getActiveRows().size}).addChild("insert_column_after",["insert"],{name:e=>{const t=Lr(e);return 1===t?s("Column right"):s("%s Columns right",t.toString())},sequence:40,action:sa,isVisible:e=>0===e.model.getters.getActiveRows().size,separator:!0}).addChild("insert_insert_cell_shift_down",["insert"],{name:s("Insert cells and shift down"),sequence:43,action:Qr}).addChild("insert_insert_cell_shift_right",["insert"],{name:s("Insert cells and shift right"),sequence:47,action:Jr,separator:!0}).addChild("insert_chart",["insert"],{name:s("Chart"),sequence:50,action:e=>{const t=e.model.getters,i=e.model.uuidGenerator.uuidv4(),o=t.getActiveSheetId();1===ho(e.model.getters.getSelectedZone())&&e.model.selection.selectTableAroundSelection();const n={width:536,height:335},s=function(e,t){const{x:i,y:o}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=e.getActiveSheetScrollInfo(),{width:r,height:a}=e.getVisibleRect(e.getActiveMainViewport());return{x:i+n+Math.max(0,(r-t.width)/2),y:o+s+Math.max(0,(a-t.height)/2)}}(t,n);e.model.dispatch("CREATE_CHART",{sheetId:o,id:i,position:s,size:n,definition:Rr(e.model.getters.getSelectedZone(),e.model.getters)}).isSuccessful&&(e.model.dispatch("SELECT_FIGURE",{id:i}),e.openSidePanel("ChartPanel"))}}).addChild("insert_image",["insert"],{name:s("Image"),sequence:55,action:async e=>{if(e.imageProvider){const t=e.model.getters.getActiveSheetId(),i=e.model.uuidGenerator.uuidv4(),o=await async function(e){try{return await e.imageProvider.requestImage()}catch{return void e.raiseError(s("An unexpected error occurred during the image transfer"))}}(e);if(!o)throw new Error("No image provider was given to the environment");const n=br(e.model.getters,o.size),r=function(e,t){const{x:i,y:o}=e.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=e.getActiveSheetScrollInfo(),r=e.getSheetViewDimension(),a=e.getVisibleRect(e.getActiveMainViewport()),l=Math.min(a.width,r.width-i),c=Math.min(a.height,r.height-o);return{x:i+n+Math.max(0,(l-t.width)/2),y:o+s+Math.max(0,(c-t.height)/2)}}(e.model.getters,n);e.model.dispatch("CREATE_IMAGE",{sheetId:t,figureId:i,position:r,size:n,definition:o})}},isVisible:e=>void 0!==e.imageProvider}).addChild("insert_function",["insert"],{name:s("Function"),sequence:60}).addChild("insert_function_sum",["insert","insert_function"],{name:s("SUM"),action:e=>e.startCellEdition("=SUM("),sequence:0}).addChild("insert_function_average",["insert","insert_function"],{name:s("AVERAGE"),action:e=>e.startCellEdition("=AVERAGE("),sequence:10}).addChild("insert_function_count",["insert","insert_function"],{name:s("COUNT"),action:e=>e.startCellEdition("=COUNT("),sequence:20}).addChild("insert_function_max",["insert","insert_function"],{name:s("MAX"),action:e=>e.startCellEdition("=MAX("),sequence:30}).addChild("insert_function_min",["insert","insert_function"],{name:s("MIN"),action:e=>e.startCellEdition("=MIN("),sequence:40,separator:!0}).addChild("categorie_function_all",["insert","insert_function"],{name:s("All"),sequence:50}).addChild("all_function_list",["insert","insert_function","categorie_function_all"],(()=>ng(tg.getKeys()))).addChild("categories_function_list",["insert","insert_function"],(()=>{const e=tg.content;return[...new Set(tg.getAll().map((e=>e.category)))].filter(it).sort().map(((t,i)=>{const o=Object.keys(e).filter((i=>e[i].category===t));return{name:t,sequence:60+10*i,children:ng(o)}}))})).addChild("insert_link",["insert"],{name:s("Link"),separator:!0,sequence:70,action:aa}).addChild("insert_sheet",["insert"],{name:s("New sheet"),sequence:80,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSheetIds().indexOf(t)+1,o=e.model.uuidGenerator.uuidv4();e.model.dispatch("CREATE_SHEET",{sheetId:o,position:i}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})},separator:!0}).addChild("unfreeze_panes",["view"],{name:s("Unfreeze"),sequence:4,isVisible:e=>{const{xSplit:t,ySplit:i}=e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId());return t+i>0},action:e=>e.model.dispatch("UNFREEZE_COLUMNS_ROWS",{sheetId:e.model.getters.getActiveSheetId()})}).addChild("freeze_panes",["view"],{name:s("Freeze"),sequence:5,separator:!0}).addChild("unfreeze_rows",["view","freeze_panes"],{name:s("No rows"),action:e=>e.model.dispatch("UNFREEZE_ROWS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:5,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).ySplit}).addChild("freeze_first_row",["view","freeze_panes"],{name:s("1 row"),action:e=>ig(e,"ROW",1),isReadonlyAllowed:!0,sequence:10}).addChild("freeze_second_row",["view","freeze_panes"],{name:s("2 rows"),action:e=>ig(e,"ROW",2),isReadonlyAllowed:!0,sequence:15}).addChild("freeze_current_row",["view","freeze_panes"],{name:s("Up to current row"),action:e=>{const{bottom:t}=e.model.getters.getSelectedZone();ig(e,"ROW",t+1)},isReadonlyAllowed:!0,sequence:20,separator:!0}).addChild("unfreeze_columns",["view","freeze_panes"],{name:s("No columns"),action:e=>e.model.dispatch("UNFREEZE_COLUMNS",{sheetId:e.model.getters.getActiveSheetId()}),isReadonlyAllowed:!0,sequence:25,isVisible:e=>!!e.model.getters.getPaneDivisions(e.model.getters.getActiveSheetId()).xSplit}).addChild("freeze_first_col",["view","freeze_panes"],{name:s("1 column"),action:e=>ig(e,"COL",1),isReadonlyAllowed:!0,sequence:30}).addChild("freeze_second_col",["view","freeze_panes"],{name:s("2 columns"),action:e=>ig(e,"COL",2),isReadonlyAllowed:!0,sequence:35}).addChild("freeze_current_col",["view","freeze_panes"],{name:s("Up to current column"),action:e=>{const{right:t}=e.model.getters.getSelectedZone();ig(e,"COL",t+1)},isReadonlyAllowed:!0,sequence:40}).addChild("view_gridlines",["view"],{name:e=>e.model.getters.getGridLinesVisibility(e.model.getters.getActiveSheetId())?s("Hide gridlines"):s("Show gridlines"),action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("SET_GRID_LINES_VISIBILITY",{sheetId:t,areGridLinesVisible:!e.model.getters.getGridLinesVisibility(t)})},sequence:10}).addChild("view_formulas",["view"],{name:e=>e.model.getters.shouldShowFormulas()?s("Hide formulas"):s("Show formulas"),action:e=>e.model.dispatch("SET_FORMULA_VISIBILITY",{show:!e.model.getters.shouldShowFormulas()}),isReadonlyAllowed:!0,sequence:15}).addChild("format_number",["format"],{name:s("Numbers"),sequence:10,separator:!0}).addChild("format_number_automatic",["format","format_number"],{name:Ds.Automatic,sequence:10,separator:!0,action:e=>Ur(e,"")}).addChild("format_number_number",["format","format_number"],{name:Ds.Number,description:"1,000.12",sequence:20,action:e=>Ur(e,"#,##0.00")}).addChild("format_number_percent",["format","format_number"],{name:Ds.Percent,description:"10.12%",sequence:30,separator:!0,action:e=>Ur(e,"0.00%")}).addChild("format_number_currency",["format","format_number"],{name:Ds.Currency,description:"$1,000.12",sequence:37,action:e=>Ur(e,"[$$]#,##0.00")}).addChild("format_number_currency_rounded",["format","format_number"],{name:Ds.CurrencyRounded,description:"$1,000",sequence:38,action:e=>Ur(e,"[$$]#,##0")}).addChild("format_custom_currency",["format","format_number"],{name:Ds.CustomCurrency,sequence:39,separator:!0,isVisible:e=>void 0!==e.loadCurrencies,action:e=>{e.openSidePanel("CustomCurrency",{})}}).addChild("format_number_date",["format","format_number"],{name:Ds.Date,description:"9/26/2008",sequence:40,action:e=>Ur(e,"m/d/yyyy")}).addChild("format_number_time",["format","format_number"],{name:Ds.Time,description:"10:43:00 PM",sequence:50,action:e=>Ur(e,"hh:mm:ss a")}).addChild("format_number_date_time",["format","format_number"],{name:Ds.DateTime,description:"9/26/2008 22:43:00",sequence:60,action:e=>Ur(e,"m/d/yyyy hh:mm:ss")}).addChild("format_number_duration",["format","format_number"],{name:Ds.Duration,description:"27:51:38",sequence:70,separator:!0,action:e=>Ur(e,"hhhh:mm:ss")}).addChild("format_bold",["format"],{name:s("Bold"),sequence:20,description:"Ctrl+B",action:e=>Vr(e,{bold:!e.model.getters.getCurrentStyle().bold})}).addChild("format_italic",["format"],{name:s("Italic"),sequence:30,description:"Ctrl+I",action:e=>Vr(e,{italic:!e.model.getters.getCurrentStyle().italic})}).addChild("format_underline",["format"],{name:s("Underline"),description:"Ctrl+U",sequence:40,action:e=>Vr(e,{underline:!e.model.getters.getCurrentStyle().underline})}).addChild("format_strikethrough",["format"],{name:s("Strikethrough"),sequence:50,action:e=>Vr(e,{strikethrough:!e.model.getters.getCurrentStyle().strikethrough}),separator:!0}).addChild("format_font_size",["format"],{name:s("Font size"),sequence:60,separator:!0}).addChild("format_alignment",["format"],{name:s("Alignment"),sequence:70}).addChild("format_alignment_left",["format","format_alignment"],{name:"Left",sequence:10,action:e=>Vr(e,{align:"left"})}).addChild("format_alignment_center",["format","format_alignment"],{name:"Center",sequence:20,action:e=>Vr(e,{align:"center"})}).addChild("format_alignment_right",["format","format_alignment"],{name:"Right",sequence:30,action:e=>Vr(e,{align:"right"}),separator:!0}).addChild("format_alignment_top",["format","format_alignment"],{name:"Top",sequence:40,action:e=>Vr(e,{verticalAlign:"top"})}).addChild("format_alignment_middle",["format","format_alignment"],{name:"Middle",sequence:50,action:e=>Vr(e,{verticalAlign:"middle"})}).addChild("format_alignment_bottom",["format","format_alignment"],{name:"Bottom",sequence:60,action:e=>Vr(e,{verticalAlign:"bottom"}),separator:!0}).addChild("format_wrapping",["format"],{name:s("Wrapping"),sequence:80,separator:!0}).addChild("format_wrapping_overflow",["format","format_wrapping"],{name:s("Overflow"),sequence:10,action:e=>Vr(e,{wrapping:"overflow"})}).addChild("format_wrapping_wrap",["format","format_wrapping"],{name:s("Wrap"),sequence:20,action:e=>Vr(e,{wrapping:"wrap"})}).addChild("format_wrapping_clip",["format","format_wrapping"],{name:s("Clip"),sequence:30,action:e=>Vr(e,{wrapping:"clip"})}).addChild("format_cf",["format"],{name:s("Conditional formatting"),sequence:90,action:ra,separator:!0}).addChild("format_clearFormat",["format"],{name:s("Clear formatting"),sequence:100,action:e=>{e.model.dispatch("CLEAR_FORMATTING",{sheetId:e.model.getters.getActiveSheetId(),target:e.model.getters.getSelectedZones()})},separator:!0}).addChild("add_data_filter",["data"],{name:s("Create filter"),sequence:10,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getSelection().zones;Nr(e,t,i)},isVisible:e=>!la(e),isEnabled:e=>(e=>uo(...e.model.getters.getSelectedZones()))(e)}).addChild("remove_data_filter",["data"],{name:s("Remove filter"),sequence:10,action:e=>{const t=e.model.getters.getActiveSheetId();e.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:t,target:e.model.getters.getSelectedZones()})},isVisible:la});for(let e of de)og.addChild(`format_font_size_${e}`,["format","format_font_size"],{name:e.toString(),sequence:e,action:t=>Vr(t,{fontSize:e})});function ng(e){return e.sort().map(((e,t)=>({name:e,sequence:10*t,action:t=>t.startCellEdition(`=${e}(`)})))}const sg=new class extends Io{addTransformation(e,t,i){for(let o of t)this.content[o]||(this.content[o]=new Map),this.content[o].set(e,i);return this}getTransformation(e,t){return this.content[e]&&this.content[e].get(t)}},rg={ArrowDown:"down",ArrowLeft:"left",ArrowRight:"right",ArrowUp:"up"};function ag(e,t){const i=rg[e.key];e.shiftKey?t.resizeAnchorZone(i,qn(e)?"end":1):t.moveAnchorCell(i,qn(e)?"end":1)}const lg=new Vi;fo`
|
|
351
351
|
.o-selection {
|
|
352
352
|
.o-selection-input {
|
|
353
353
|
display: flex;
|
|
@@ -397,7 +397,7 @@
|
|
|
397
397
|
font-size: calc(100% + 4px);
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
|
-
`;class
|
|
400
|
+
`;class cg extends t.Component{constructor(){super(...arguments),this.id=lg.uuidv4(),this.previousRanges=this.props.ranges||[],this.originSheet=this.env.model.getters.getActiveSheetId(),this.state=t.useState({isMissing:!1,mode:"select-range"}),this.focusedInput=t.useRef("focusedInput")}get ranges(){const e=this.env.model.getters.getSelectionInput(this.id);return(e.length?e:this.props.ranges?this.props.ranges.map(((e,t)=>({xc:e,id:t,isFocused:!1}))):[]).map((e=>({...e,isValidRange:""===e.xc||this.env.model.getters.isRangeValid(e.xc)})))}get hasFocus(){return this.ranges.filter((e=>e.isFocused)).length>0}get canAddRange(){return!this.props.hasSingleRange}get isInvalid(){return this.props.isInvalid||this.state.isMissing}setup(){t.useEffect((()=>{var e;return null===(e=this.focusedInput.el)||void 0===e?void 0:e.focus()}),(()=>[this.focusedInput.el])),t.onMounted((()=>this.enableNewSelectionInput())),t.onWillUnmount((async()=>this.disableNewSelectionInput())),t.onPatched((()=>this.checkChange()))}enableNewSelectionInput(){this.env.model.dispatch("ENABLE_NEW_SELECTION_INPUT",{id:this.id,initialRanges:this.props.ranges,hasSingleRange:this.props.hasSingleRange})}disableNewSelectionInput(){this.env.model.dispatch("DISABLE_SELECTION_INPUT",{id:this.id})}checkChange(){const e=this.env.model.getters.getSelectionInputValue(this.id);this.previousRanges.join()!==e.join()&&this.triggerChange()}getColor(e){return"color: "+(e.color||"#000")+";"}triggerChange(){var e,t;const i=this.env.model.getters.getSelectionInputValue(this.id);null===(t=(e=this.props).onSelectionChanged)||void 0===t||t.call(e,i),this.previousRanges=i}onKeydown(e){if("F2"===e.key)e.preventDefault(),e.stopPropagation(),this.state.mode="select-range"===this.state.mode?"text-edit":"select-range";else if(e.key.startsWith("Arrow"))e.stopPropagation(),"select-range"===this.state.mode&&(e.preventDefault(),ag(e,this.env.model.selection));else if("Enter"===e.key){e.target.blur(),this.confirm()}}extractRanges(e){return this.props.hasSingleRange?e.split(",")[0]:e}focus(e){this.state.isMissing=!1,this.state.mode="select-range",this.env.model.dispatch("FOCUS_RANGE",{id:this.id,rangeId:e})}addEmptyInput(){this.env.model.dispatch("ADD_EMPTY_RANGE",{id:this.id})}removeInput(e){var t,i;this.env.model.dispatch("REMOVE_RANGE",{id:this.id,rangeId:e}),this.triggerChange(),null===(i=(t=this.props).onSelectionConfirmed)||void 0===i||i.call(t)}onInputChanged(e,t){const i=t.target,o=this.extractRanges(i.value);this.env.model.dispatch("CHANGE_RANGE",{id:this.id,rangeId:e,value:o}),this.triggerChange()}confirm(){var e,t;this.env.model.dispatch("UNFOCUS_SELECTION_INPUT");const i=this.env.model.getters.getSelectionInputValue(this.id);this.props.required&&0===i.length&&(this.state.isMissing=!0);const o=this.env.model.getters.getActiveSheetId();this.originSheet!==o&&this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:o,sheetIdTo:this.originSheet}),null===(t=(e=this.props).onSelectionConfirmed)||void 0===t||t.call(e)}}cg.template="o-spreadsheet-SelectionInput",cg.props={ranges:Array,hasSingleRange:{type:Boolean,optional:!0},required:{type:Boolean,optional:!0},isInvalid:{type:Boolean,optional:!0},class:{type:String,optional:!0},onSelectionChanged:{type:Function,optional:!0},onSelectionConfirmed:{type:Function,optional:!0}};class hg extends t.Component{constructor(){super(...arguments),this.state=t.useState({datasetDispatchResult:void 0,labelsDispatchResult:void 0}),this.dataSeriesRanges=[]}setup(){this.dataSeriesRanges=this.props.definition.dataSets,this.labelRange=this.props.definition.labelRange}get errorMessages(){var e,t;return[...(null===(e=this.state.datasetDispatchResult)||void 0===e?void 0:e.reasons)||[],...(null===(t=this.state.labelsDispatchResult)||void 0===t?void 0:t.reasons)||[]].map((e=>Fs.Errors[e]||Fs.Errors.Unexpected))}get isDatasetInvalid(){var e;return!!(null===(e=this.state.datasetDispatchResult)||void 0===e?void 0:e.isCancelledBecause(32))}get isLabelInvalid(){var e;return!!(null===(e=this.state.labelsDispatchResult)||void 0===e?void 0:e.isCancelledBecause(33))}onUpdateDataSetsHaveTitle(e){this.props.updateChart(this.props.figureId,{dataSetsHaveTitle:e.target.checked})}onDataSeriesRangesChanged(e){this.dataSeriesRanges=e}onDataSeriesConfirmed(){this.state.datasetDispatchResult=this.props.updateChart(this.props.figureId,{dataSets:this.dataSeriesRanges})}onLabelRangeChanged(e){this.labelRange=e[0]}onLabelRangeConfirmed(){this.state.labelsDispatchResult=this.props.updateChart(this.props.figureId,{labelRange:this.labelRange})}onUpdateAggregated(e){this.props.updateChart(this.props.figureId,{aggregated:e.target.checked})}}hg.template="o-spreadsheet-LineBarPieConfigPanel",hg.components={SelectionInput:cg},hg.props={figureId:String,definition:Object,updateChart:Function};class dg extends hg{onUpdateStacked(e){this.props.updateChart(this.props.figureId,{stacked:e.target.checked})}onUpdateAggregated(e){this.props.updateChart(this.props.figureId,{aggregated:e.target.checked})}}dg.template="o-spreadsheet-BarConfigPanel";const ug=218,gg=182;function pg(e){return Rt(At({h:360*e.offsetX/ug,s:100,l:100*e.offsetY/gg,a:1}))}fo`
|
|
401
401
|
.o-color-picker {
|
|
402
402
|
padding: ${6}px 0px;
|
|
403
403
|
box-shadow: 1px 2px 5px 2px rgba(51, 51, 51, 0.15);
|
|
@@ -405,7 +405,7 @@
|
|
|
405
405
|
line-height: 1.2;
|
|
406
406
|
overflow-y: auto;
|
|
407
407
|
overflow-x: hidden;
|
|
408
|
-
width: ${
|
|
408
|
+
width: ${ug+12}px;
|
|
409
409
|
|
|
410
410
|
.o-color-picker-section-name {
|
|
411
411
|
margin: 0px ${1}px;
|
|
@@ -506,8 +506,8 @@
|
|
|
506
506
|
hsl(1turn 100% 50%) 100%
|
|
507
507
|
);
|
|
508
508
|
border: ${1}px solid #c0c0c0;
|
|
509
|
-
width: ${
|
|
510
|
-
height: ${
|
|
509
|
+
width: ${ug}px;
|
|
510
|
+
height: ${gg}px;
|
|
511
511
|
&:hover {
|
|
512
512
|
cursor: crosshair;
|
|
513
513
|
}
|
|
@@ -534,7 +534,7 @@
|
|
|
534
534
|
width: 30px;
|
|
535
535
|
height: 30px;
|
|
536
536
|
}
|
|
537
|
-
`;class
|
|
537
|
+
`;class mg extends t.Component{constructor(){super(...arguments),this.COLORS=O,this.state=t.useState({showGradient:!1,currentColor:wt(this.props.currentColor)?this.props.currentColor:"",isCurrentColorInvalid:!1,style:{display:"none",background:"#ffffff",left:"0",top:"0"}})}get colorPickerStyle(){return void 0!==this.props.maxHeight&&this.props.maxHeight<=0?Co({display:"none"}):""}get popoverProps(){return{anchorRect:this.props.anchorRect,maxHeight:this.props.maxHeight,positioning:"BottomLeft",verticalOffset:0}}onColorClick(e){e&&this.props.onColorPicked(Et(e))}getCheckMarkColor(){return Is(this.props.currentColor)}resetColor(){this.props.onColorPicked("")}setCustomColor(e){if(!wt(this.state.currentColor))return e.stopPropagation(),void(this.state.isCurrentColorInvalid=!0);const t=Et(this.state.currentColor);this.state.isCurrentColorInvalid=!1,this.props.onColorPicked(t),this.state.currentColor=t}toggleColorPicker(){this.state.showGradient=!this.state.showGradient}computeCustomColor(e){this.state.isCurrentColorInvalid=!1,this.state.currentColor=pg(e)}hideMagnifier(e){this.state.style.display="none"}showMagnifier(e){this.state.style.display="block"}moveMagnifier(e){this.state.style.background=pg(e);this.state.style.left=`${e.offsetX+10}px`,this.state.style.top=`${e.offsetY+10}px`}get magnifyingGlassStyle(){const{display:e,background:t,left:i,top:o}=this.state.style;return Co({display:e,"background-color":"block"===e?t:void 0,left:i,top:o})}isSameColor(e,t){return function(e,t){return wt(e)&&wt(t)&&Et(e)===Et(t)}(e,t)}}mg.template="o-spreadsheet-ColorPicker",mg.defaultProps={currentColor:""},mg.components={Popover:Kn},mg.props={onColorPicked:Function,currentColor:{type:String,optional:!0},maxHeight:{type:Number,optional:!0},anchorRect:Object},fo`
|
|
538
538
|
.o-color-picker-widget {
|
|
539
539
|
display: inline-block;
|
|
540
540
|
position: relative;
|
|
@@ -565,7 +565,7 @@
|
|
|
565
565
|
}
|
|
566
566
|
}
|
|
567
567
|
}
|
|
568
|
-
`;class
|
|
568
|
+
`;class fg extends t.Component{constructor(){super(...arguments),this.colorPickerButtonRef=t.useRef("colorPickerButton")}get iconStyle(){return this.props.currentColor?`border-color: ${this.props.currentColor}`:"border-bottom-style: hidden"}get colorPickerAnchorRect(){const e=this.colorPickerButtonRef.el.getBoundingClientRect();return{x:e.x,y:e.y,width:e.width,height:e.height}}}fg.template="o-spreadsheet-ColorPickerWidget",fg.components={ColorPicker:mg},fg.props={currentColor:{type:String,optional:!0},toggleColorPicker:Function,showColorPicker:Boolean,onColorPicked:Function,icon:String,title:{type:String,optional:!0},disabled:{type:Boolean,optional:!0},dropdownMaxHeight:{type:Number,optional:!0},class:{type:String,optional:!0}};class vg extends t.Component{constructor(){super(...arguments),this.state=t.useState({fillColorTool:!1})}onClick(e){this.state.fillColorTool=!1}setup(){t.useExternalListener(window,"click",this.onClick)}toggleColorPicker(){this.state.fillColorTool=!this.state.fillColorTool}updateBackgroundColor(e){this.props.updateChart(this.props.figureId,{background:e})}updateTitle(e){this.props.updateChart(this.props.figureId,{title:e.target.value})}updateSelect(e,t){this.props.updateChart(this.props.figureId,{[e]:t.target.value})}}vg.template="o-spreadsheet-LineBarPieDesignPanel",vg.components={ColorPickerWidget:fg},vg.props={figureId:String,definition:Object,updateChart:Function};class bg extends vg{}bg.template="o-spreadsheet-BarChartDesignPanel";class Sg extends t.Component{constructor(){super(...arguments),this.state=t.useState({dataRangeDispatchResult:void 0}),this.dataRange=this.props.definition.dataRange}get configurationErrorMessages(){var e;return[...(null===(e=this.state.dataRangeDispatchResult)||void 0===e?void 0:e.reasons)||[]].map((e=>Fs.Errors[e]||Fs.Errors.Unexpected))}get isDataRangeInvalid(){var e;return!!(null===(e=this.state.dataRangeDispatchResult)||void 0===e?void 0:e.isCancelledBecause(36))}onDataRangeChanged(e){this.dataRange=e[0]}updateDataRange(){this.state.dataRangeDispatchResult=this.props.updateChart(this.props.figureId,{dataRange:this.dataRange})}}Sg.template="o-spreadsheet-GaugeChartConfigPanel",Sg.components={SelectionInput:cg},Sg.props={figureId:String,definition:Object,updateChart:Function},fo`
|
|
569
569
|
.o-gauge-color-set {
|
|
570
570
|
table {
|
|
571
571
|
table-layout: fixed;
|
|
@@ -595,7 +595,7 @@
|
|
|
595
595
|
box-sizing: border-box;
|
|
596
596
|
}
|
|
597
597
|
}
|
|
598
|
-
`;class
|
|
598
|
+
`;class Cg extends t.Component{constructor(){super(...arguments),this.state=t.useState({openedMenu:void 0,sectionRuleDispatchResult:void 0})}setup(){t.useExternalListener(window,"click",this.closeMenus)}get designErrorMessages(){var e;return[...(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.reasons)||[]].map((e=>Fs.Errors[e]||Fs.Errors.Unexpected))}updateBackgroundColor(e){this.state.openedMenu=void 0,this.props.updateChart(this.props.figureId,{background:e})}updateTitle(e){this.props.updateChart(this.props.figureId,{title:e.target.value})}isRangeMinInvalid(){var e,t,i;return!!((null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(37))||(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(38))||(null===(i=this.state.sectionRuleDispatchResult)||void 0===i?void 0:i.isCancelledBecause(41)))}isRangeMaxInvalid(){var e,t,i;return!!((null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(39))||(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(40))||(null===(i=this.state.sectionRuleDispatchResult)||void 0===i?void 0:i.isCancelledBecause(41)))}get isLowerInflectionPointInvalid(){var e,t;return!(!(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(42))&&!(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(44)))}get isUpperInflectionPointInvalid(){var e,t;return!(!(null===(e=this.state.sectionRuleDispatchResult)||void 0===e?void 0:e.isCancelledBecause(43))&&!(null===(t=this.state.sectionRuleDispatchResult)||void 0===t?void 0:t.isCancelledBecause(44)))}updateInflectionPointValue(e,t){const i=_e(this.props.definition.sectionRule);i[e].value=t.target.value,this.updateSectionRule(i)}updateInflectionPointType(e,t){const i=_e(this.props.definition.sectionRule);i[e].type=t.target.value,this.updateSectionRule(i)}updateSectionColor(e,t){const i=_e(this.props.definition.sectionRule);i.colors[e]=t,this.updateSectionRule(i),this.closeMenus()}updateRangeMin(e){let t=_e(this.props.definition.sectionRule);t={...t,rangeMin:e.target.value},this.updateSectionRule(t)}updateRangeMax(e){let t=_e(this.props.definition.sectionRule);t={...t,rangeMax:e.target.value},this.updateSectionRule(t)}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}updateSectionRule(e){this.state.sectionRuleDispatchResult=this.props.updateChart(this.props.figureId,{sectionRule:e})}closeMenus(){this.state.openedMenu=void 0}}Cg.template="o-spreadsheet-GaugeChartDesignPanel",Cg.components={ColorPickerWidget:fg},Cg.props={figureId:String,definition:Object,updateChart:Function};class Eg extends hg{get canTreatLabelsAsText(){const e=this.env.model.getters.getChart(this.props.figureId);return!!(e&&e instanceof or)&&nr(e.labelRange,this.env.model.getters)}onUpdateLabelsAsText(e){this.props.updateChart(this.props.figureId,{labelsAsText:e.target.checked})}onUpdateStacked(e){this.props.updateChart(this.props.figureId,{stacked:e.target.checked})}onUpdateAggregated(e){this.props.updateChart(this.props.figureId,{aggregated:e.target.checked})}onUpdateCumulative(e){this.props.updateChart(this.props.figureId,{cumulative:e.target.checked})}}Eg.template="o-spreadsheet-LineConfigPanel";class wg extends vg{}wg.template="o-spreadsheet-LineChartDesignPanel";class yg extends t.Component{constructor(){super(...arguments),this.state=t.useState({keyValueDispatchResult:void 0,baselineDispatchResult:void 0}),this.keyValue=this.props.definition.keyValue,this.baseline=this.props.definition.baseline}get errorMessages(){var e,t;return[...(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.reasons)||[],...(null===(t=this.state.baselineDispatchResult)||void 0===t?void 0:t.reasons)||[]].map((e=>Fs.Errors[e]||Fs.Errors.Unexpected))}get isKeyValueInvalid(){var e;return!!(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.isCancelledBecause(34))}get isBaselineInvalid(){var e;return!!(null===(e=this.state.keyValueDispatchResult)||void 0===e?void 0:e.isCancelledBecause(35))}onKeyValueRangeChanged(e){this.keyValue=e[0]}updateKeyValueRange(){this.state.keyValueDispatchResult=this.props.updateChart(this.props.figureId,{keyValue:this.keyValue})}onBaselineRangeChanged(e){this.baseline=e[0]}updateBaselineRange(){this.state.baselineDispatchResult=this.props.updateChart(this.props.figureId,{baseline:this.baseline})}updateBaselineMode(e){this.props.updateChart(this.props.figureId,{baselineMode:e.target.value})}}yg.template="o-spreadsheet-ScorecardChartConfigPanel",yg.components={SelectionInput:cg},yg.props={figureId:String,definition:Object,updateChart:Function};class xg extends t.Component{constructor(){super(...arguments),this.state=t.useState({openedColorPicker:void 0})}setup(){t.useExternalListener(window,"click",this.closeMenus)}updateTitle(e){this.props.updateChart(this.props.figureId,{title:e.target.value})}updateBaselineDescr(e){this.props.updateChart(this.props.figureId,{baselineDescr:e.target.value})}toggleColorPicker(e){this.state.openedColorPicker===e?this.state.openedColorPicker=void 0:this.state.openedColorPicker=e}setColor(e,t){switch(t){case"backgroundColor":this.props.updateChart(this.props.figureId,{background:e});break;case"baselineColorDown":this.props.updateChart(this.props.figureId,{baselineColorDown:e});break;case"baselineColorUp":this.props.updateChart(this.props.figureId,{baselineColorUp:e})}this.closeMenus()}closeMenus(){this.state.openedColorPicker=void 0}}xg.template="o-spreadsheet-ScorecardChartDesignPanel",xg.components={ColorPickerWidget:fg},xg.props={figureId:String,definition:Object,updateChart:Function};const Ig=new Io;Ig.add("line",{configuration:Eg,design:wg}).add("bar",{configuration:dg,design:bg}).add("pie",{configuration:hg,design:vg}).add("gauge",{configuration:Sg,design:Cg}).add("scorecard",{configuration:yg,design:xg}),fo`
|
|
599
599
|
.o-chart {
|
|
600
600
|
.o-panel {
|
|
601
601
|
display: flex;
|
|
@@ -618,7 +618,7 @@
|
|
|
618
618
|
}
|
|
619
619
|
}
|
|
620
620
|
}
|
|
621
|
-
`;class
|
|
621
|
+
`;class Rg extends t.Component{get figureId(){return this.state.figureId}setup(){const e=this.env.model.getters.getSelectedFigureId();if(!e)throw new Error(s("Cannot open the chart side panel while no chart are selected"));this.state=t.useState({panel:"configuration",figureId:e}),t.onWillUpdateProps((()=>{const e=this.env.model.getters.getSelectedFigureId();e&&e!==this.state.figureId&&(this.state.figureId=e),this.env.model.getters.isChartDefined(this.figureId)||this.props.onCloseSidePanel()}))}updateChart(e,t){if(e!==this.figureId)return;const i={...this.getChartDefinition(),...t};return this.env.model.dispatch("UPDATE_CHART",{definition:i,id:e,sheetId:this.env.model.getters.getFigureSheetId(e)})}onTypeChange(e){const t=this.env.model.getters.getContextCreationChart(this.figureId);if(!t)throw new Error("Chart not defined.");const i=function(e,t){return gr.get(t).getChartDefinitionFromContextCreation(e)}(t,e);this.env.model.dispatch("UPDATE_CHART",{definition:i,id:this.figureId,sheetId:this.env.model.getters.getFigureSheetId(this.figureId)})}get chartPanel(){const e=this.env.model.getters.getChartType(this.figureId);if(!e)throw new Error("Chart not defined.");const t=Ig.get(e);if(!t)throw new Error(`Component is not defined for type ${e}`);return t}getChartDefinition(e=this.figureId){return this.env.model.getters.getChartDefinition(e)}get chartTypes(){return function(){const e={};for(const t of gr.getKeys())e[t]=gr.get(t).name;return e}()}activatePanel(e){this.state.panel=e}}Rg.template="o-spreadsheet-ChartPanel",Rg.props={onCloseSidePanel:Function};function Tg(e){e=`<svg xmlns="http://www.w3.org/2000/svg" ${e.slice(4)}`;const t=new Image;return t.src="data:image/svg+xml; charset=utf8, "+encodeURIComponent(e),t}const Ag={arrowGood:{template:"ARROW_UP",img:Tg('<svg class="o-cf-icon arrow-up" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#00A04A" d="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"></path></svg>')},arrowNeutral:{template:"ARROW_RIGHT",img:Tg('<svg class="o-cf-icon arrow-right" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#F0AD4E" d="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"></path></svg>')},arrowBad:{template:"ARROW_DOWN",img:Tg('<svg class="o-cf-icon arrow-down" width="10" height="10" focusable="false" viewBox="0 0 448 512"><path fill="#DC6965" d="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"></path></svg>')},smileyGood:{template:"SMILE",img:Tg('<svg class="o-cf-icon smile" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#00A04A" d="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"></path></svg>')},smileyNeutral:{template:"MEH",img:Tg('<svg class="o-cf-icon meh" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#F0AD4E" d="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"></path></svg>')},smileyBad:{template:"FROWN",img:Tg('<svg class="o-cf-icon frown" width="10" height="10" focusable="false" viewBox="0 0 496 512"><path fill="#DC6965" d="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"></path></svg>')},dotGood:{template:"GREEN_DOT",img:Tg('<svg class="o-cf-icon green-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#00A04A" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')},dotNeutral:{template:"YELLOW_DOT",img:Tg('<svg class="o-cf-icon yellow-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#F0AD4E" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')},dotBad:{template:"RED_DOT",img:Tg('<svg class="o-cf-icon red-dot" width="10" height="10" focusable="false" viewBox="0 0 512 512"><path fill="#DC6965" d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8z"></path></svg>')}},Mg={arrows:{good:"arrowGood",neutral:"arrowNeutral",bad:"arrowBad"},smiley:{good:"smileyGood",neutral:"smileyNeutral",bad:"smileyBad"},dots:{good:"dotGood",neutral:"dotNeutral",bad:"dotBad"}};fo`
|
|
622
622
|
.o-icon-picker {
|
|
623
623
|
position: absolute;
|
|
624
624
|
z-index: ${ce.IconPicker};
|
|
@@ -637,7 +637,7 @@
|
|
|
637
637
|
outline: 1px solid gray;
|
|
638
638
|
}
|
|
639
639
|
}
|
|
640
|
-
`;class
|
|
640
|
+
`;class Og extends t.Component{constructor(){super(...arguments),this.icons=Ag,this.iconSets=Mg}onIconClick(e){e&&this.props.onIconPicked(e)}}Og.template="o-spreadsheet-IconPicker",Og.props={onIconPicked:Function},fo`
|
|
641
641
|
label {
|
|
642
642
|
vertical-align: middle;
|
|
643
643
|
}
|
|
@@ -907,13 +907,13 @@
|
|
|
907
907
|
}
|
|
908
908
|
}
|
|
909
909
|
}
|
|
910
|
-
`;class
|
|
910
|
+
`;class Ng extends t.Component{constructor(){super(...arguments),this.icons=Ag,this.cellIsOperators=_s,this.iconSets=Mg,this.getTextDecoration=vo,this.colorNumberString=Ct}setup(){this.activeSheetId=this.env.model.getters.getActiveSheetId(),this.state=t.useState({mode:"list",errors:[],rules:this.getDefaultRules()});const e=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getRulesSelection(e,this.props.selection||[]);if(1===i.length){const e=this.conditionalFormats.find((e=>e.id===i[0]));e&&this.editConditionalFormat(e)}t.onWillUpdateProps((e=>{const t=this.env.model.getters.getActiveSheetId();if(t!==this.activeSheetId)this.activeSheetId=t,this.switchToList();else if(e.selection!==this.props.selection){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getRulesSelection(t,e.selection||[]);if(1===i.length){const e=this.conditionalFormats.find((e=>e.id===i[0]));e&&this.editConditionalFormat(e)}else this.switchToList()}})),t.useExternalListener(window,"click",this.closeMenus)}get conditionalFormats(){return this.env.model.getters.getConditionalFormats(this.env.model.getters.getActiveSheetId())}get isRangeValid(){return this.state.errors.includes(24)}errorMessage(e){return Ns.Errors[e]||Ns.Errors.Unexpected}switchToList(){this.state.mode="list",this.state.currentCF=void 0,this.state.currentCFType=void 0,this.state.errors=[],this.state.rules=this.getDefaultRules()}getStyle(e){if("CellIsRule"===e.type)return Co({"font-weight":e.style.bold?"bold":"normal","text-decoration":vo(e.style),"font-style":e.style.italic?"italic":"normal",color:e.style.textColor||"none","background-color":e.style.fillColor||"none"});if("ColorScaleRule"===e.type){const t=Ct(e.minimum.color),i=e.midpoint?Ct(e.midpoint.color):null,o=Ct(e.maximum.color),n="background-image: linear-gradient(to right, ";return i?n+t+", "+i+", "+o+")":n+t+", "+o+")"}return""}getDescription(e){switch(e.rule.type){case"CellIsRule":const t=_s[e.rule.operator];return 1===e.rule.values.length?`${t} ${e.rule.values[0]}`:2===e.rule.values.length?n("%s %s and %s",t,e.rule.values[0],e.rule.values[1]):t;case"ColorScaleRule":return Ns.ColorScale;case"IconSetRule":return Ns.IconSet;default:return""}}saveConditionalFormat(){if(this.state.currentCF){if(this.state.currentCF.ranges.some((e=>!e.match(Lt))))return void(this.state.errors=[25]);const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{rule:this.getEditorRule(),id:"edit"===this.state.mode?this.state.currentCF.id:this.env.model.uuidGenerator.uuidv4()},ranges:this.state.currentCF.ranges.map((t=>this.env.model.getters.getRangeDataFromXc(e,t))),sheetId:e});t.isSuccessful?this.switchToList():this.state.errors=t.reasons}}getEditorRule(){switch(this.state.currentCFType){case"CellIsRule":return this.state.rules.cellIs;case"ColorScaleRule":return this.state.rules.colorScale;case"IconSetRule":return this.state.rules.iconSet}throw new Error(`Invalid cf type: ${this.state.currentCFType}`)}getDefaultRules(){return{cellIs:{type:"CellIsRule",operator:"IsNotEmpty",values:[],style:{fillColor:"#b6d7a8"}},colorScale:{type:"ColorScaleRule",minimum:{type:"value",color:16777215},midpoint:void 0,maximum:{type:"value",color:6989903}},iconSet:{type:"IconSetRule",icons:{upper:"arrowGood",middle:"arrowNeutral",lower:"arrowBad"},upperInflectionPoint:{type:"percentage",value:"66",operator:"gt"},lowerInflectionPoint:{type:"percentage",value:"33",operator:"gt"}}}}addConditionalFormat(){this.state.mode="add",this.state.currentCFType="CellIsRule",this.state.currentCF={id:this.env.model.uuidGenerator.uuidv4(),ranges:this.env.model.getters.getSelectedZones().map((e=>this.env.model.getters.zoneToXC(this.env.model.getters.getActiveSheetId(),e)))}}deleteConditionalFormat(e){this.env.model.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:e.id,sheetId:this.env.model.getters.getActiveSheetId()})}editConditionalFormat(e){if("reorder"!==this.state.mode)switch(this.state.mode="edit",this.state.currentCF=e,this.state.currentCFType=e.rule.type,e.rule.type){case"CellIsRule":this.state.rules.cellIs=e.rule;break;case"ColorScaleRule":this.state.rules.colorScale=e.rule;break;case"IconSetRule":this.state.rules.iconSet=e.rule}}reorderConditionalFormats(){this.state.mode="reorder"}reorderRule(e,t){this.env.model.dispatch("MOVE_CONDITIONAL_FORMAT",{cfId:e.id,direction:t,sheetId:this.env.model.getters.getActiveSheetId()})}changeRuleType(e){this.state.currentCFType!==e&&this.state.rules&&(this.state.errors=[],this.state.currentCFType=e)}onRangesChanged(e){this.state.currentCF&&(this.state.currentCF.ranges=e)}toggleMenu(e){const t=this.state.openedMenu===e;this.closeMenus(),t||(this.state.openedMenu=e)}closeMenus(){this.state.openedMenu=void 0}get isValue1Invalid(){var e;return!!(null===(e=this.state.errors)||void 0===e?void 0:e.includes(51))}get isValue2Invalid(){var e;return!!(null===(e=this.state.errors)||void 0===e?void 0:e.includes(52))}toggleStyle(e){const t=this.state.rules.cellIs.style;t[e]=!t[e],this.closeMenus()}setColor(e,t){this.state.rules.cellIs.style[e]=t,this.closeMenus()}isValueInvalid(e){switch(e){case"minimum":return this.state.errors.includes(58)||this.state.errors.includes(50)||this.state.errors.includes(47)||this.state.errors.includes(53);case"midpoint":return this.state.errors.includes(59)||this.state.errors.includes(54)||this.state.errors.includes(49);case"maximum":return this.state.errors.includes(60)||this.state.errors.includes(55);default:return!1}}setColorScaleColor(e,t){const i=this.state.rules.colorScale[e];i&&(i.color=Number.parseInt(t.substr(1),16)),this.closeMenus()}getPreviewGradient(){var e;const t=this.state.rules.colorScale,i=Ct(t.minimum.color),o=Ct((null===(e=t.midpoint)||void 0===e?void 0:e.color)||x),n=Ct(t.maximum.color),s="background-image: linear-gradient(to right, ";return void 0===t.midpoint?s+i+", "+n+")":s+i+", "+o+", "+n+")"}getThresholdColor(e){return Ct(e?e.color:x)}onMidpointChange(e){const t=e.target.value,i=this.state.rules.colorScale;i.midpoint="none"===t?void 0:{color:x,value:"",...i.midpoint,type:t}}isInflectionPointInvalid(e){switch(e){case"lowerInflectionPoint":return this.state.errors.includes(57)||this.state.errors.includes(62)||this.state.errors.includes(48);case"upperInflectionPoint":return this.state.errors.includes(56)||this.state.errors.includes(61)||this.state.errors.includes(48);default:return!0}}reverseIcons(){const e=this.state.rules.iconSet.icons,t=e.upper;e.upper=e.lower,e.lower=t}setIconSet(e){const t=this.state.rules.iconSet.icons;t.upper=this.iconSets[e].good,t.middle=this.iconSets[e].neutral,t.lower=this.iconSets[e].bad}setIcon(e,t){this.state.rules.iconSet.icons[e]=t}}Ng.template="o-spreadsheet-ConditionalFormattingPanel",Ng.components={SelectionInput:cg,IconPicker:Og,ColorPickerWidget:fg},Ng.props={selection:{type:Object,optional:!0},onCloseSidePanel:Function},fo`
|
|
911
911
|
.o-custom-currency {
|
|
912
912
|
.o-format-proposals {
|
|
913
913
|
color: black;
|
|
914
914
|
}
|
|
915
915
|
}
|
|
916
|
-
`;class
|
|
916
|
+
`;class _g extends t.Component{setup(){this.availableCurrencies=[],this.state=t.useState({selectedCurrencyIndex:0,currencyCode:"",currencySymbol:"",selectedFormatIndex:0}),t.onWillStart((()=>this.updateAvailableCurrencies()))}get formatProposals(){const e=this.availableCurrencies[this.state.selectedCurrencyIndex],t=this.initProposalBases(e.decimalPlaces),i=e.position,o="before"===e.position?"after":"before",n=this.state.currencySymbol.trim()?this.state.currencySymbol:"",s=this.state.currencyCode.trim()?this.state.currencyCode:"";return s||n?[...this.createFormatProposals(t,n,s,i),...this.createFormatProposals(t,n,s,o)]:[]}get isSameFormat(){const e=this.formatProposals[this.state.selectedFormatIndex];return!!e&&e.format===this.getCommonFormat()}async updateAvailableCurrencies(){var e,t;if(0===mr.getAll().length){(await(null===(t=(e=this.env).loadCurrencies)||void 0===t?void 0:t.call(e))||[]).forEach(((e,t)=>{mr.add(t.toString(),e)}))}const i={name:this.env._t(ks.Custom),code:"",symbol:"",decimalPlaces:2,position:"after"};this.availableCurrencies=[i,...mr.getAll()]}updateSelectCurrency(e){const t=e.target;this.state.selectedCurrencyIndex=parseInt(t.value,10);const i=this.availableCurrencies[this.state.selectedCurrencyIndex];this.state.currencyCode=i.code,this.state.currencySymbol=i.symbol}updateCode(e){const t=e.target;this.state.currencyCode=t.value,this.initAvailableCurrencies()}updateSymbol(e){const t=e.target;this.state.currencySymbol=t.value,this.initAvailableCurrencies()}updateSelectFormat(e){const t=e.target;this.state.selectedFormatIndex=parseInt(t.value,10)}apply(){const e=this.formatProposals[this.state.selectedFormatIndex];this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),format:e.format})}initAvailableCurrencies(){this.state.selectedCurrencyIndex=0}initProposalBases(e){const t=[{format:"#,##0",example:"1,000"}],i=e?"."+"0".repeat(e):"";return i&&t.push({format:"#,##0"+i,example:"1,000"+i}),t}createFormatProposals(e,t,i,o){let n=[];if(t)for(let i of e)n.push(this.createFormatProposal(o,i.example,i.format,t));if(i)for(let s of e){const e=("after"===o?" ":"")+i+" "+t;n.push(this.createFormatProposal(o,s.example,s.format,e))}return n}createFormatProposal(e,t,i,o){const n="[$"+o+"]";return{example:"before"===e?o+t:t+o,format:"before"===e?n+i:i+n}}getCommonFormat(){const e=this.env.model.getters.getSelectedZones(),t=this.env.model.getters.getActiveSheetId(),i=e.map((e=>this.env.model.getters.getEvaluatedCellsInZone(t,e))).flat(),o=i[0].format;return i.every((e=>e.format===o))?o:void 0}currencyDisplayName(e){return e.name+(e.code?` (${e.code})`:"")}}_g.template="o-spreadsheet-CustomCurrencyPanel",_g.props={onCloseSidePanel:Function},fo`
|
|
917
917
|
.o-find-and-replace {
|
|
918
918
|
.o-far-item {
|
|
919
919
|
display: block;
|
|
@@ -946,7 +946,7 @@
|
|
|
946
946
|
}
|
|
947
947
|
}
|
|
948
948
|
}
|
|
949
|
-
`;class
|
|
949
|
+
`;class Fg extends t.Component{constructor(){super(...arguments),this.state=t.useState(this.initialState()),this.showFormulaState=!1,this.findAndReplaceRef=t.useRef("findAndReplace")}get hasSearchResult(){return null!==this.env.model.getters.getCurrentSelectedMatchIndex()}get pendingSearch(){return void 0!==this.debounceTimeoutId}setup(){this.showFormulaState=this.env.model.getters.shouldShowFormulas(),t.onMounted((()=>this.focusInput())),t.onWillUnmount((()=>{clearTimeout(this.debounceTimeoutId),this.env.model.dispatch("CLEAR_SEARCH"),this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.showFormulaState})})),t.useEffect((()=>{this.state.searchOptions.searchFormulas=this.env.model.getters.shouldShowFormulas(),this.searchFormulas()}),(()=>[this.env.model.getters.shouldShowFormulas()]))}onInput(e){this.state.toSearch=e.target.value,this.debouncedUpdateSearch()}onKeydownSearch(e){"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),this.onSelectNextCell())}onKeydownReplace(e){"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),this.replace())}searchFormulas(){this.env.model.dispatch("SET_FORMULA_VISIBILITY",{show:this.state.searchOptions.searchFormulas}),this.updateSearch()}onSelectPreviousCell(){this.env.model.dispatch("SELECT_SEARCH_PREVIOUS_MATCH")}onSelectNextCell(){this.env.model.dispatch("SELECT_SEARCH_NEXT_MATCH")}updateSearch(){this.env.model.dispatch("UPDATE_SEARCH",{toSearch:this.state.toSearch,searchOptions:this.state.searchOptions})}debouncedUpdateSearch(){clearTimeout(this.debounceTimeoutId),this.debounceTimeoutId=setTimeout((()=>{this.updateSearch(),this.debounceTimeoutId=void 0}),200)}replace(){this.env.model.dispatch("REPLACE_SEARCH",{replaceWith:this.state.replaceWith})}replaceAll(){this.env.model.dispatch("REPLACE_ALL_SEARCH",{replaceWith:this.state.replaceWith})}focusInput(){const e=this.findAndReplaceRef.el.querySelector("input");e&&e.focus()}initialState(){return{toSearch:"",replaceWith:"",searchOptions:{matchCase:!1,exactMatch:!1,searchFormulas:!1}}}}Fg.template="o-spreadsheet-FindAndReplacePanel",Fg.props={onCloseSidePanel:Function};const Dg=new Io;Dg.add("ConditionalFormatting",{title:s("Conditional formatting"),Body:Ng}),Dg.add("ChartPanel",{title:s("Chart"),Body:Rg}),Dg.add("FindAndReplace",{title:s("Find and Replace"),Body:Fg}),Dg.add("CustomCurrency",{title:s("Custom currency format"),Body:_g});const kg=new class extends Io{constructor(){super(...arguments),this.mapping={},this.uuidGenerator=new Vi}add(e,t){const i={...t,id:this.uuidGenerator.uuidv4()};return super.add(e,i)}};fo`
|
|
950
950
|
div.o-figure {
|
|
951
951
|
box-sizing: border-box;
|
|
952
952
|
position: absolute;
|
|
@@ -1019,7 +1019,7 @@
|
|
|
1019
1019
|
}
|
|
1020
1020
|
}
|
|
1021
1021
|
}
|
|
1022
|
-
`;class
|
|
1022
|
+
`;class Lg extends t.Component{constructor(){super(...arguments),this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.figureRef=t.useRef("figure"),this.menuButtonRef=t.useRef("menuButton"),this.menuButtonRect=jn(this.menuButtonRef)}get isSelected(){return this.env.model.getters.getSelectedFigureId()===this.props.figure.id}get figureRegistry(){return Sr}getBorderWidth(){return this.env.isDashboard()?0:this.isSelected?2:this.borderWidth}get borderStyle(){return`border: ${this.getBorderWidth()}px solid ${this.isSelected?E:"#c9ccd2"};`}get wrapperStyle(){const{x:e,y:t,width:i,height:o}=this.props.figure;return Co({left:`${e}px`,top:`${t}px`,width:`${i}px`,height:`${o}px`,"z-index":String(ce.Figure+(this.isSelected?1:0))})}getResizerPosition(e){let t={};return e.includes("top")?t.top="-3px":e.includes("bottom")?t.bottom="-3px":t.bottom="calc(50% - 3px)",e.includes("left")?t.left="-3px":e.includes("right")?t.right="-3px":t.right="calc(50% - 3px)",Co(t)}setup(){const e=Sr.get(this.props.figure.tag).borderWidth;this.borderWidth=void 0!==e?e:1,t.useEffect(((e,t,i)=>{e===t&&(null==i||i.focus({preventScroll:!0}))}),(()=>[this.env.model.getters.getSelectedFigureId(),this.props.figure.id,this.figureRef.el]))}clickAnchor(e,t,i){this.props.onClickAnchor(e,t,i)}onMouseDown(e){this.props.onMouseDown(e)}onKeyDown(e){const t=this.props.figure;switch(e.key){case"Delete":this.env.model.dispatch("DELETE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id}),this.props.onFigureDeleted(),e.stopPropagation(),e.preventDefault();break;case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":const i={ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0],ArrowUp:[0,-1]}[e.key];this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:t.id,x:t.x+i[0],y:t.y+i[1]}),e.stopPropagation(),e.preventDefault()}}onContextMenu(e){if(this.env.isDashboard())return;const t={x:e.clientX,y:e.clientY};this.openContextMenu(t)}showMenu(){const{x:e,y:t,width:i}=this.menuButtonRect,o={x:e>=$?e-$:e+i,y:t};this.openContextMenu(o)}openContextMenu(e){this.menuState.isOpen=!0,this.menuState.position=e,this.menuState.menuItems=Sr.get(this.props.figure.tag).menuBuilder(this.props.figure.id,this.props.onFigureDeleted,this.env)}}function Pg(e,t,i=(()=>{})){const o=s=>{t(s),window.removeEventListener("mousedown",i),window.removeEventListener("mouseup",o),window.removeEventListener("dragstart",n),window.removeEventListener("mousemove",e),window.removeEventListener("wheel",e)};function n(e){e.preventDefault()}window.addEventListener("mousedown",i),window.addEventListener("mouseup",o),window.addEventListener("dragstart",n),window.addEventListener("mousemove",e),window.addEventListener("wheel",e,{passive:!1})}function Ug(e,t,i,o=!1){let n,s,r,a,l,c=null;const h=e.model.getters,d=h.getActiveSheetId(),u=Hn();let g,p;const m=i=>{if(n=i,c)return;const{x:r,y:f}=h.getMainViewportCoordinates();let{top:v,left:b,bottom:S,right:C}=h.getActiveMainViewport(),{scrollX:E,scrollY:w}=h.getActiveSheetDOMScrollInfo();const{xSplit:y,ySplit:x}=h.getPaneDivisions(d);let I=!1,R=Zt;const T=n.clientX-u.left;if(g=h.getColIndex(T),"vertical"!==o){const t=s.clientX-u.left,i=h.getEdgeScrollCol(T,t,a);if(i.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,i.delay),i.direction){case"reset":g=y,t=y;break;case 1:g=C,t=b+1;break;case-1:for(g=b-1;e.model.getters.isColHidden(d,g);)g--;t=g}E=h.getColDimensions(d,t).start-r}}const A=n.clientY-u.top;if(p=h.getRowIndex(A),"horizontal"!==o){const t=s.clientY-u.top,i=h.getEdgeScrollRow(A,t,l);if(i.canEdgeScroll){let t;switch(I=!0,R=Math.min(R,i.delay),i.direction){case"reset":p=x,t=x;break;case 1:p=S,t=v+i.direction;break;case-1:for(p=v-1;e.model.getters.isRowHidden(d,p);)p--;t=p}w=e.model.getters.getRowDimensions(d,t).start-f}}I||(-1===p&&(p=A<0?0:h.getNumberRows(d)-1),-1===g&&T<0&&(g=T<0?0:h.getNumberCols(d)-1)),t(g,p,n),I&&(e.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:E,offsetY:w}),c=setTimeout((()=>{c=null,m(n)}),Math.round(R))),s=n};Pg(m,(()=>{clearTimeout(c),i()}),(e=>{s=e,r=e,a=r.clientX-u.left,l=r.clientY-u.top}))}Lg.template="o-spreadsheet-FigureComponent",Lg.components={Menu:ts},Lg.defaultProps={onFigureDeleted:()=>{},onMouseDown:()=>{},onClickAnchor:()=>{}},Lg.props={figure:Object,style:{type:String,optional:!0},onFigureDeleted:{type:Function,optional:!0},onMouseDown:{type:Function,optional:!0},onClickAnchor:{type:Function,optional:!0}},fo`
|
|
1023
1023
|
.o-autofill {
|
|
1024
1024
|
position: absolute;
|
|
1025
1025
|
height: ${8}px;
|
|
@@ -1047,9 +1047,9 @@
|
|
|
1047
1047
|
pointer-events: none;
|
|
1048
1048
|
white-space: nowrap;
|
|
1049
1049
|
}
|
|
1050
|
-
`;class
|
|
1050
|
+
`;class Vg extends t.Component{constructor(){super(...arguments),this.state=t.useState({position:{left:0,top:0},handler:!1})}get style(){const{left:e,top:t}=this.props.position;return Co({top:`${t}px`,left:`${e}px`,visibility:this.props.isVisible?"visible":"hidden"})}get handlerStyle(){const{left:e,top:t}=this.state.handler?this.state.position:this.props.position;return Co({top:`${t}px`,left:`${e}px`})}get styleNextValue(){const{left:e,top:t}=this.state.position;return Co({top:`${t+5}px`,left:`${e+15}px`})}getTooltip(){const e=this.env.model.getters.getAutofillTooltip();return e&&!e.component&&(e.component=zg),e}onMouseDown(e){let t,i;this.state.handler=!0;const o=e.clientX-this.props.position.left,n=e.clientY-this.props.position.top;Ug(this.env,((e,s,r)=>{if(this.state.position={left:r.clientX-o,top:r.clientY-n},t!==e||i!==s){const o=this.env.model.getters.getActiveSheetId(),n=this.env.model.getters.getNumberCols(o),r=this.env.model.getters.getNumberRows(o);t=-1===e?t:ke(e,0,n),i=-1===s?i:ke(s,0,r),void 0!==t&&void 0!==i&&this.env.model.dispatch("AUTOFILL_SELECT",{col:t,row:i})}}),(()=>{this.state.handler=!1,this.state.position={...this.props.position},this.env.model.dispatch("AUTOFILL")}))}onDblClick(){this.env.model.dispatch("AUTOFILL_AUTO")}}Vg.template="o-spreadsheet-Autofill",Vg.props={position:Object,isVisible:Boolean};class zg extends t.Component{}zg.template=t.xml`
|
|
1051
1051
|
<div t-esc="props.content"/>
|
|
1052
|
-
`,
|
|
1052
|
+
`,zg.props={content:String},fo`
|
|
1053
1053
|
.o-client-tag {
|
|
1054
1054
|
position: absolute;
|
|
1055
1055
|
border-top-left-radius: 4px;
|
|
@@ -1059,7 +1059,7 @@
|
|
|
1059
1059
|
opacity: 0;
|
|
1060
1060
|
pointer-events: none;
|
|
1061
1061
|
}
|
|
1062
|
-
`;class
|
|
1062
|
+
`;class Bg extends t.Component{get tagStyle(){const{col:e,row:t,color:i}=this.props,{height:o}=this.env.model.getters.getSheetViewDimensionWithHeaders(),{x:n,y:s}=this.env.model.getters.getVisibleRect({left:e,top:t,right:e,bottom:t});return Co({bottom:o-s+15+"px",left:n-1+"px",border:`1px solid ${i}`,"background-color":i,opacity:this.props.active?"1 !important":void 0})}}Bg.template="o-spreadsheet-ClientTag",Bg.props={active:Boolean,name:String,color:String,col:Number,row:Number},fo`
|
|
1063
1063
|
.o-autocomplete-dropdown {
|
|
1064
1064
|
pointer-events: auto;
|
|
1065
1065
|
background-color: #fff;
|
|
@@ -1078,7 +1078,7 @@
|
|
|
1078
1078
|
}
|
|
1079
1079
|
}
|
|
1080
1080
|
}
|
|
1081
|
-
`;class
|
|
1081
|
+
`;class Hg extends t.Component{}Hg.template="o-spreadsheet-TextValueProvider",Hg.props={values:Array,selectedIndex:Number,onValueSelected:Function};class $g{constructor(e){this.el=e}updateEl(e){this.el=e}selectRange(e,t){let i=window.getSelection();this.removeSelection();let o=document.createRange();if(e==t&&0===e)o.setStart(this.el,0),o.setEnd(this.el,0),i.addRange(o);else{const n=this.getText().length;(e<0||t>n)&&(console.warn(`wrong selection asked start ${e}, end ${t}, text content length ${n}`),e<0&&(e=0),t>n&&(t=n),e>n&&(e=n));let s=this.findChildAtCharacterIndex(e),r=this.findChildAtCharacterIndex(t);o.setStart(s.node,s.offset),i.addRange(o),i.extend(r.node,r.offset)}}findChildAtCharacterIndex(e){let t,i,o=Wn(this.el),n=e,s=!0;do{t=o.next(),t.done||t.value.hasChildNodes()||(t.value.textContent&&t.value.textContent.length<n?n-=t.value.textContent.length:t.value.textContent&&t.value.textContent.length>=n&&o.return(t.value),i=t.value),t.done||"P"!==t.value.nodeName||(s?s=!1:n--)}while(!t.done&&n);return t.value?{node:t.value,offset:n}:{node:i,offset:n}}setText(e){if(this.el.innerHTML="",0!==e.length)for(const t of e){const e=document.createElement("p");if(0===t.length||t.every((e=>!e.value&&!e.class)))e.appendChild(document.createElement("br")),this.el.appendChild(e);else{for(const i of t){if(!i.value&&!i.class)continue;const t=document.createElement("span");t.innerText=i.value,t.style.color=i.color||"",i.class&&t.classList.add(i.class),e.appendChild(t)}this.el.appendChild(e)}}}scrollSelectionIntoView(){var e;const t=null===(e=document.getSelection())||void 0===e?void 0:e.focusNode;if(!t||!this.el.contains(t))return;const i=t instanceof HTMLElement?t:t.parentElement;null==i||i.scrollIntoView({block:"nearest"})}removeSelection(){window.getSelection().removeAllRanges()}removeAll(){if(this.el)for(;this.el.firstChild;)this.el.removeChild(this.el.firstChild)}getCurrentSelection(){let{startElement:e,endElement:t,startSelectionOffset:i,endSelectionOffset:o}=this.getStartAndEndSelection();return{start:this.findSelectionIndex(e,i),end:this.findSelectionIndex(t,o)}}findSelectionIndex(e,t){let i=0,o=Wn(this.el),n=o.next(),s=!0;for(;!n.done&&n.value!==e;)n.value.hasChildNodes()||n.value.textContent&&(i+=n.value.textContent.length),("P"===n.value.nodeName||"DIV"===n.value.nodeName&&n.value!==this.el)&&(s?s=!1:i++),n=o.next();if(n.value!==e)return 0;if(n.value.hasChildNodes()){const e=[...n.value.childNodes].slice(0,t);i+=e.reduce(((t,i,o)=>{if(null!==i.textContent){let n=i.textContent.length;return"P"===i.nodeName&&o!==e.length-1&&n++,t+n}return t}),0)}else i+=t;return"P"!==e.nodeName||s||""!=e.textContent||i++,i}getStartAndEndSelection(){const e=document.getSelection();return{startElement:e.anchorNode||this.el,startSelectionOffset:e.anchorOffset,endElement:e.focusNode||this.el,endSelectionOffset:e.focusOffset}}getText(){let e="",t=Wn(this.el),i=t.next(),o=!0;for(;!i.done;)i.value.hasChildNodes()||(e+=i.value.textContent),("P"===i.value.nodeName||"DIV"===i.value.nodeName&&i.value!==this.el)&&(o?o=!1:e+=he),i=t.next();return e}}fo`
|
|
1082
1082
|
.o-formula-assistant {
|
|
1083
1083
|
.o-formula-assistant-head {
|
|
1084
1084
|
background-color: #f2f2f2;
|
|
@@ -1104,7 +1104,7 @@
|
|
|
1104
1104
|
color: gray;
|
|
1105
1105
|
}
|
|
1106
1106
|
}
|
|
1107
|
-
`;class
|
|
1107
|
+
`;class Wg extends t.Component{constructor(){super(...arguments),this.assistantState=t.useState({allowCellSelectionBehind:!1}),this.timeOutId=0}setup(){t.onWillUnmount((()=>{this.timeOutId&&clearTimeout(this.timeOutId)}))}getContext(){return this.props}onMouseMove(){this.assistantState.allowCellSelectionBehind=!0,this.timeOutId&&clearTimeout(this.timeOutId),this.timeOutId=setTimeout((()=>{this.assistantState.allowCellSelectionBehind=!1}),2e3)}}Wg.template="o-spreadsheet-FunctionDescriptionProvider",Wg.props={functionName:String,functionDescription:Object,argToFocus:Number};const Gg=tg.content,qg="selector-flag",Zg="#4a4e4d",jg="#3da4ab",Xg={OPERATOR:jg,NUMBER:"#02c39a",STRING:"#00a82d",FUNCTION:Zg,DEBUGGER:jg,LEFT_PAREN:Zg,RIGHT_PAREN:Zg,COMMA:Zg,MATCHING_PAREN:"#000000"};fo`
|
|
1108
1108
|
.o-composer-container {
|
|
1109
1109
|
.o-composer {
|
|
1110
1110
|
overflow-y: auto;
|
|
@@ -1129,7 +1129,7 @@
|
|
|
1129
1129
|
|
|
1130
1130
|
span {
|
|
1131
1131
|
white-space: pre-wrap;
|
|
1132
|
-
&.${
|
|
1132
|
+
&.${qg}:after {
|
|
1133
1133
|
content: "${"␣"}";
|
|
1134
1134
|
color: ${"#a9a9a9"};
|
|
1135
1135
|
}
|
|
@@ -1143,12 +1143,12 @@
|
|
|
1143
1143
|
pointer-events: none;
|
|
1144
1144
|
}
|
|
1145
1145
|
}
|
|
1146
|
-
`;class jg extends t.Component{constructor(){super(...arguments),this.composerRef=t.useRef("o_composer"),this.contentHelper=new Bg(this.composerRef.el),this.composerState=t.useState({positionStart:0,positionEnd:0}),this.autoCompleteState=t.useState({showProvider:!1,values:[],selectedIndex:0}),this.functionDescriptionState=t.useState({showDescription:!1,functionName:"",functionDescription:{},argToFocus:0}),this.isKeyStillDown=!1,this.compositionActive=!1,this.shouldProcessInputEvents=!1,this.tokens=[],this.keyMapping={ArrowUp:this.processArrowKeys,ArrowDown:this.processArrowKeys,ArrowLeft:this.processArrowKeys,ArrowRight:this.processArrowKeys,Enter:this.processEnterKey,Escape:this.processEscapeKey,F2:()=>console.warn("Not implemented"),F4:this.processF4Key,Tab:e=>this.processTabKey(e)}}get assistantStyle(){if(this.props.delimitation&&this.props.rect){const{x:e,y:t,height:i}=this.props.rect;let o={};return t>this.props.delimitation.height-(t+i)&&(o.top="-3px",o.transform="translate(0, -100%)"),e+300>this.props.delimitation.width&&(o.right="0px"),o.width="300px",Co(o)}return Co({width:"300px"})}setup(){t.onMounted((()=>{const e=this.composerRef.el;this.contentHelper.updateEl(e),this.processContent(),this.contentHelper.scrollSelectionIntoView()})),t.onWillUnmount((()=>{var e,t;null===(t=(e=this.props).onComposerUnmounted)||void 0===t||t.call(e)})),t.onPatched((()=>{this.isKeyStillDown||this.processContent()}))}processArrowKeys(e){if(this.env.model.getters.isSelectingForComposer())return this.functionDescriptionState.showDescription=!1,e.preventDefault(),e.stopPropagation(),void sg(e,this.env.model.selection);const t=this.env.model.getters.getCurrentContent();"cellFocus"!==this.props.focus||this.autoCompleteState.showProvider||t.startsWith("=")?(e.stopPropagation(),this.handleArrowKeysForAutocomplete(e)):this.env.model.dispatch("STOP_EDITION")}handleArrowKeysForAutocomplete(e){["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.showProvider&&(e.preventDefault(),"ArrowUp"===e.key?(this.autoCompleteState.selectedIndex--,this.autoCompleteState.selectedIndex<0&&(this.autoCompleteState.selectedIndex=this.autoCompleteState.values.length-1)):this.autoCompleteState.selectedIndex=(this.autoCompleteState.selectedIndex+1)%this.autoCompleteState.values.length),this.updateCursorIfNeeded()}processTabKey(e){var t;if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider){const e=null===(t=this.autoCompleteState.values[this.autoCompleteState.selectedIndex])||void 0===t?void 0:t.text;if(e)return void this.autoComplete(e)}else this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const i=e.shiftKey?"left":"right";this.env.model.dispatch("STOP_EDITION"),this.env.model.selection.moveAnchorCell(i,1)}processEnterKey(e){var t;if(e.preventDefault(),e.stopPropagation(),e.altKey||e.ctrlKey){const e=this.contentHelper.getCurrentSelection(),t=this.env.model.getters.getCurrentContent(),i=t.slice(0,e.start)+he+t.slice(e.end);return this.env.model.dispatch("SET_CURRENT_CONTENT",{content:i,selection:{start:e.start+1,end:e.start+1}}),this.processContent(),void this.contentHelper.scrollSelectionIntoView()}if(this.isKeyStillDown=!1,this.autoCompleteState.showProvider){const e=null===(t=this.autoCompleteState.values[this.autoCompleteState.selectedIndex])||void 0===t?void 0:t.text;if(e)return void this.autoComplete(e)}this.env.model.dispatch("STOP_EDITION");const i=e.shiftKey?"up":"down";this.env.model.selection.moveAnchorCell(i,1)}processEscapeKey(){this.env.model.dispatch("STOP_EDITION",{cancel:!0})}processF4Key(){this.env.model.dispatch("CYCLE_EDITION_REFERENCES"),this.processContent()}onCompositionStart(){this.compositionActive=!0}onCompositionEnd(){this.compositionActive=!1}onKeydown(e){let t=this.keyMapping[e.key];t?t.call(this,e):(e.stopPropagation(),this.updateCursorIfNeeded())}updateCursorIfNeeded(){if(!this.env.model.getters.isSelectingForComposer()){const{start:e,end:t}=this.contentHelper.getCurrentSelection();this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:e,end:t}),this.isKeyStillDown=!0}}onInput(){"inactive"!==this.props.focus&&this.shouldProcessInputEvents&&(this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),this.env.model.dispatch("SET_CURRENT_CONTENT",{content:this.contentHelper.getText(),selection:this.contentHelper.getCurrentSelection()}))}onKeyup(e){if(this.isKeyStillDown=!1,"inactive"===this.props.focus||["Control","Alt","Shift","Tab","Enter","F4"].includes(e.key))return;if(this.autoCompleteState.showProvider&&["ArrowUp","ArrowDown"].includes(e.key))return;if(this.env.model.getters.isSelectingForComposer()&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key))return;if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider=!1,e.ctrlKey&&" "===e.key)return this.showAutocomplete(""),void this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const{start:t,end:i}=this.env.model.getters.getComposerSelection(),{start:o,end:n}=this.contentHelper.getCurrentSelection();o===t&&n===i||this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",this.contentHelper.getCurrentSelection()),this.processTokenAtCursor(),this.processContent()}showAutocomplete(e){this.autoCompleteState.showProvider=!0;let t=Object.entries(Ju.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:t}])=>({text:e,description:t})));t=e?"true"===e.toLowerCase()||"false"===e.toLowerCase()?[]:Pi(e,t,(e=>e.text)):t.sort(((e,t)=>e.text.localeCompare(t.text))),this.autoCompleteState.values=t.slice(0,10),this.autoCompleteState.selectedIndex=0}onMousedown(e){e.button>0||this.contentHelper.removeSelection()}onClick(){if(this.env.model.getters.isReadonly())return;const e=this.contentHelper.getCurrentSelection();this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),"inactive"===this.props.focus&&this.props.onComposerContentFocused(e),this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",e),this.processTokenAtCursor()}onBlur(){this.isKeyStillDown=!1}processContent(){if(this.compositionActive)return;const e=(null==(t=this.composerRef.el)?void 0:t.scrollTop)||0;var t;this.contentHelper.removeAll(),this.shouldProcessInputEvents=!1,"inactive"!==this.props.focus&&(this.contentHelper.el.focus(),this.contentHelper.selectRange(0,0));const i=this.getContentLines();if(0!==i.length&&0!==i.length[0]){this.contentHelper.setText(i);const{start:t,end:o}=this.env.model.getters.getComposerSelection();"inactive"!==this.props.focus&&this.contentHelper.selectRange(t,o),function(e,t){e&&(e.scrollTop=t)}(this.composerRef.el,e)}this.shouldProcessInputEvents=!0}getContentLines(){let e=this.env.model.getters.getCurrentContent();const t=e.startsWith("=")&&this.env.model.getters.getCurrentTokens().length>0;return""===e?[]:t&&"inactive"!==this.props.focus?this.splitHtmlContentIntoLines(this.getColoredTokens()):this.splitHtmlContentIntoLines([{value:e}])}getColoredTokens(){const e=this.env.model.getters.getCurrentTokens(),t=this.env.model.getters.getTokenAtCursor(),i=[],{end:o,start:n}=this.env.model.getters.getComposerSelection();for(const s of e){switch(s.type){case"OPERATOR":case"NUMBER":case"FUNCTION":case"COMMA":case"STRING":i.push({value:s.value,color:Zg[s.type]||"#000"});break;case"REFERENCE":const{xc:e,sheetName:o}=Ht(s.value);i.push({value:s.value,color:this.rangeColor(e,o)||"#000"});break;case"SYMBOL":let n=s.value;["TRUE","FALSE"].includes(n.toUpperCase())?i.push({value:s.value,color:Zg.NUMBER}):i.push({value:s.value,color:"#000"});break;case"LEFT_PAREN":case"RIGHT_PAREN":t&&["LEFT_PAREN","RIGHT_PAREN"].includes(t.type)&&t.parenIndex&&t.parenIndex===s.parenIndex?i.push({value:s.value,color:Zg.MATCHING_PAREN}):i.push({value:s.value,color:Zg[s.type]||"#000"});break;default:i.push({value:s.value,color:"#000"})}this.env.model.getters.showSelectionIndicator()&&o===n&&o===s.end&&(i[i.length-1].class=Wg)}return i}splitHtmlContentIntoLines(e){const t=[];let i=[];for(const o of e)if(o.value.includes(he)){const e=o.value.split(he),n=e.pop();for(const n of e)i.push({color:o.color,value:n}),t.push(i),i=[];i.push({...o,value:n})}else i.push(o);i.length&&t.push(i);const o=[];for(const e of t)e.every(this.isContentEmpty)?o.push([e[0]]):o.push(e.filter((e=>!this.isContentEmpty(e))));return o}isContentEmpty(e){return!(e.value||e.class)}rangeColor(e,t){if("inactive"===this.props.focus)return;const i=this.env.model.getters.getHighlights(),o=t?this.env.model.getters.getSheetIdByName(t):this.env.model.getters.getEditionSheet(),n=i.find((t=>{if(t.sheetId!==o)return!1;let i=this.env.model.getters.getRangeFromSheetXC(o,e).zone;return i=1===ho(i)?this.env.model.getters.expandZone(o,i):i,Yi(i,t.zone)}));return n&&n.color?n.color:void 0}processTokenAtCursor(){let e=this.env.model.getters.getCurrentContent();if(this.autoCompleteState.showProvider=!1,this.functionDescriptionState.showDescription=!1,e.startsWith("=")){const e=this.env.model.getters.getTokenAtCursor();if(e){const{xc:t}=Ht(e.value);if("FUNCTION"===e.type||"SYMBOL"===e.type&&!Lt.test(t))this.showAutocomplete(e.value);else if(e.functionContext&&"UNKNOWN"!==e.type){const t=e.functionContext,i=t.parent.toUpperCase(),o=$g[i],n=t.argPosition;this.functionDescriptionState.functionName=i,this.functionDescriptionState.functionDescription=o,this.functionDescriptionState.argToFocus=o.getArgToFocus(n+1)-1,this.functionDescriptionState.showDescription=!0}}}}autoComplete(e){if(e){const t=this.env.model.getters.getTokenAtCursor();if(t){let i=t.end,o=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(i=t.start);const n=this.env.model.getters.getCurrentTokens();if(n.length){e+="(";const i=n.map((e=>e.start)).indexOf(t.start);if(i+1<n.length){"LEFT_PAREN"===n[i+1].type&&o++}}this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:i,end:o})}this.env.model.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}jg.template="o-spreadsheet-Composer",jg.components={TextValueProvider:zg,FunctionDescriptionProvider:Hg},jg.defaultProps={inputStyle:""},jg.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerContentFocused:Function,inputStyle:{type:String,optional:!0},rect:{type:Object,optional:!0},delimitation:{type:Object,optional:!0},onComposerUnmounted:{type:Function,optional:!0}};const Xg=3*.4*window.devicePixelRatio||1;fo`
|
|
1146
|
+
`;class Yg extends t.Component{constructor(){super(...arguments),this.composerRef=t.useRef("o_composer"),this.contentHelper=new $g(this.composerRef.el),this.composerState=t.useState({positionStart:0,positionEnd:0}),this.autoCompleteState=t.useState({showProvider:!1,values:[],selectedIndex:0}),this.functionDescriptionState=t.useState({showDescription:!1,functionName:"",functionDescription:{},argToFocus:0}),this.isKeyStillDown=!1,this.compositionActive=!1,this.shouldProcessInputEvents=!1,this.tokens=[],this.keyMapping={ArrowUp:this.processArrowKeys,ArrowDown:this.processArrowKeys,ArrowLeft:this.processArrowKeys,ArrowRight:this.processArrowKeys,Enter:this.processEnterKey,Escape:this.processEscapeKey,F2:()=>console.warn("Not implemented"),F4:this.processF4Key,Tab:e=>this.processTabKey(e)}}get assistantStyle(){if(this.props.delimitation&&this.props.rect){const{x:e,y:t,height:i}=this.props.rect;let o={};return t>this.props.delimitation.height-(t+i)&&(o.top="-3px",o.transform="translate(0, -100%)"),e+300>this.props.delimitation.width&&(o.right="0px"),o.width="300px",Co(o)}return Co({width:"300px"})}setup(){t.onMounted((()=>{const e=this.composerRef.el;this.contentHelper.updateEl(e),this.processContent(),this.contentHelper.scrollSelectionIntoView()})),t.onWillUnmount((()=>{var e,t;null===(t=(e=this.props).onComposerUnmounted)||void 0===t||t.call(e)})),t.onPatched((()=>{this.isKeyStillDown||this.processContent()}))}processArrowKeys(e){if(this.env.model.getters.isSelectingForComposer())return this.functionDescriptionState.showDescription=!1,e.preventDefault(),e.stopPropagation(),void ag(e,this.env.model.selection);const t=this.env.model.getters.getCurrentContent();"cellFocus"!==this.props.focus||this.autoCompleteState.showProvider||t.startsWith("=")?(e.stopPropagation(),this.handleArrowKeysForAutocomplete(e)):this.env.model.dispatch("STOP_EDITION")}handleArrowKeysForAutocomplete(e){["ArrowUp","ArrowDown"].includes(e.key)&&this.autoCompleteState.showProvider&&(e.preventDefault(),"ArrowUp"===e.key?(this.autoCompleteState.selectedIndex--,this.autoCompleteState.selectedIndex<0&&(this.autoCompleteState.selectedIndex=this.autoCompleteState.values.length-1)):this.autoCompleteState.selectedIndex=(this.autoCompleteState.selectedIndex+1)%this.autoCompleteState.values.length),this.updateCursorIfNeeded()}processTabKey(e){var t;if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider){const e=null===(t=this.autoCompleteState.values[this.autoCompleteState.selectedIndex])||void 0===t?void 0:t.text;if(e)return void this.autoComplete(e)}else this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const i=e.shiftKey?"left":"right";this.env.model.dispatch("STOP_EDITION"),this.env.model.selection.moveAnchorCell(i,1)}processEnterKey(e){var t;if(e.preventDefault(),e.stopPropagation(),e.altKey||e.ctrlKey){const e=this.contentHelper.getCurrentSelection(),t=this.env.model.getters.getCurrentContent(),i=t.slice(0,e.start)+he+t.slice(e.end);return this.env.model.dispatch("SET_CURRENT_CONTENT",{content:i,selection:{start:e.start+1,end:e.start+1}}),this.processContent(),void this.contentHelper.scrollSelectionIntoView()}if(this.isKeyStillDown=!1,this.autoCompleteState.showProvider){const e=null===(t=this.autoCompleteState.values[this.autoCompleteState.selectedIndex])||void 0===t?void 0:t.text;if(e)return void this.autoComplete(e)}this.env.model.dispatch("STOP_EDITION");const i=e.shiftKey?"up":"down";this.env.model.selection.moveAnchorCell(i,1)}processEscapeKey(){this.env.model.dispatch("STOP_EDITION",{cancel:!0})}processF4Key(){this.env.model.dispatch("CYCLE_EDITION_REFERENCES"),this.processContent()}onCompositionStart(){this.compositionActive=!0}onCompositionEnd(){this.compositionActive=!1}onKeydown(e){let t=this.keyMapping[e.key];t?t.call(this,e):(e.stopPropagation(),this.updateCursorIfNeeded())}updateCursorIfNeeded(){if(!this.env.model.getters.isSelectingForComposer()){const{start:e,end:t}=this.contentHelper.getCurrentSelection();this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:e,end:t}),this.isKeyStillDown=!0}}onInput(){"inactive"!==this.props.focus&&this.shouldProcessInputEvents&&(this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),this.env.model.dispatch("SET_CURRENT_CONTENT",{content:this.contentHelper.getText(),selection:this.contentHelper.getCurrentSelection()}))}onKeyup(e){if(this.isKeyStillDown=!1,"inactive"===this.props.focus||["Control","Alt","Shift","Tab","Enter","F4"].includes(e.key))return;if(this.autoCompleteState.showProvider&&["ArrowUp","ArrowDown"].includes(e.key))return;if(this.env.model.getters.isSelectingForComposer()&&["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"].includes(e.key))return;if(e.preventDefault(),e.stopPropagation(),this.autoCompleteState.showProvider=!1,e.ctrlKey&&" "===e.key)return this.showAutocomplete(""),void this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION");const{start:t,end:i}=this.env.model.getters.getComposerSelection(),{start:o,end:n}=this.contentHelper.getCurrentSelection();o===t&&n===i||this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",this.contentHelper.getCurrentSelection()),this.processTokenAtCursor(),this.processContent()}showAutocomplete(e){this.autoCompleteState.showProvider=!0;let t=Object.entries(tg.content).filter((([e,{hidden:t}])=>!t)).map((([e,{description:t}])=>({text:e,description:t})));t=e?"true"===e.toLowerCase()||"false"===e.toLowerCase()?[]:Pi(e,t,(e=>e.text)):t.sort(((e,t)=>e.text.localeCompare(t.text))),this.autoCompleteState.values=t.slice(0,10),this.autoCompleteState.selectedIndex=0}onMousedown(e){e.button>0||this.contentHelper.removeSelection()}onClick(){if(this.env.model.getters.isReadonly())return;const e=this.contentHelper.getCurrentSelection();this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION"),"inactive"===this.props.focus&&this.props.onComposerContentFocused(e),this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",e),this.processTokenAtCursor()}onBlur(){this.isKeyStillDown=!1}processContent(){if(this.compositionActive)return;const e=(null==(t=this.composerRef.el)?void 0:t.scrollTop)||0;var t;this.contentHelper.removeAll(),this.shouldProcessInputEvents=!1,"inactive"!==this.props.focus&&(this.contentHelper.el.focus(),this.contentHelper.selectRange(0,0));const i=this.getContentLines();if(0!==i.length&&0!==i.length[0]){this.contentHelper.setText(i);const{start:t,end:o}=this.env.model.getters.getComposerSelection();"inactive"!==this.props.focus&&this.contentHelper.selectRange(t,o),function(e,t){e&&(e.scrollTop=t)}(this.composerRef.el,e)}this.shouldProcessInputEvents=!0}getContentLines(){let e=this.env.model.getters.getCurrentContent();const t=e.startsWith("=")&&this.env.model.getters.getCurrentTokens().length>0;return""===e?[]:t&&"inactive"!==this.props.focus?this.splitHtmlContentIntoLines(this.getColoredTokens()):this.splitHtmlContentIntoLines([{value:e}])}getColoredTokens(){const e=this.env.model.getters.getCurrentTokens(),t=this.env.model.getters.getTokenAtCursor(),i=[],{end:o,start:n}=this.env.model.getters.getComposerSelection();for(const s of e){switch(s.type){case"OPERATOR":case"NUMBER":case"FUNCTION":case"COMMA":case"STRING":i.push({value:s.value,color:Xg[s.type]||"#000"});break;case"REFERENCE":const{xc:e,sheetName:o}=Ht(s.value);i.push({value:s.value,color:this.rangeColor(e,o)||"#000"});break;case"SYMBOL":let n=s.value;["TRUE","FALSE"].includes(n.toUpperCase())?i.push({value:s.value,color:Xg.NUMBER}):i.push({value:s.value,color:"#000"});break;case"LEFT_PAREN":case"RIGHT_PAREN":t&&["LEFT_PAREN","RIGHT_PAREN"].includes(t.type)&&t.parenIndex&&t.parenIndex===s.parenIndex?i.push({value:s.value,color:Xg.MATCHING_PAREN}):i.push({value:s.value,color:Xg[s.type]||"#000"});break;default:i.push({value:s.value,color:"#000"})}this.env.model.getters.showSelectionIndicator()&&o===n&&o===s.end&&(i[i.length-1].class=qg)}return i}splitHtmlContentIntoLines(e){const t=[];let i=[];for(const o of e)if(o.value.includes(he)){const e=o.value.split(he),n=e.pop();for(const n of e)i.push({color:o.color,value:n}),t.push(i),i=[];i.push({...o,value:n})}else i.push(o);i.length&&t.push(i);const o=[];for(const e of t)e.every(this.isContentEmpty)?o.push([e[0]]):o.push(e.filter((e=>!this.isContentEmpty(e))));return o}isContentEmpty(e){return!(e.value||e.class)}rangeColor(e,t){if("inactive"===this.props.focus)return;const i=this.env.model.getters.getHighlights(),o=t?this.env.model.getters.getSheetIdByName(t):this.env.model.getters.getEditionSheet(),n=i.find((t=>{if(t.sheetId!==o)return!1;let i=this.env.model.getters.getRangeFromSheetXC(o,e).zone;return i=1===ho(i)?this.env.model.getters.expandZone(o,i):i,Yi(i,t.zone)}));return n&&n.color?n.color:void 0}processTokenAtCursor(){let e=this.env.model.getters.getCurrentContent();if(this.autoCompleteState.showProvider=!1,this.functionDescriptionState.showDescription=!1,e.startsWith("=")){const e=this.env.model.getters.getTokenAtCursor();if(e){const{xc:t}=Ht(e.value);if("FUNCTION"===e.type||"SYMBOL"===e.type&&!Lt.test(t))this.showAutocomplete(e.value);else if(e.functionContext&&"UNKNOWN"!==e.type){const t=e.functionContext,i=t.parent.toUpperCase(),o=Gg[i],n=t.argPosition;this.functionDescriptionState.functionName=i,this.functionDescriptionState.functionDescription=o,this.functionDescriptionState.argToFocus=o.getArgToFocus(n+1)-1,this.functionDescriptionState.showDescription=!0}}}}autoComplete(e){if(e){const t=this.env.model.getters.getTokenAtCursor();if(t){let i=t.end,o=t.end;["SYMBOL","FUNCTION"].includes(t.type)&&(i=t.start);const n=this.env.model.getters.getCurrentTokens();if(n.length){e+="(";const i=n.map((e=>e.start)).indexOf(t.start);if(i+1<n.length){"LEFT_PAREN"===n[i+1].type&&o++}}this.env.model.dispatch("CHANGE_COMPOSER_CURSOR_SELECTION",{start:i,end:o})}this.env.model.dispatch("REPLACE_COMPOSER_CURSOR_SELECTION",{text:e})}this.processTokenAtCursor()}}Yg.template="o-spreadsheet-Composer",Yg.components={TextValueProvider:Hg,FunctionDescriptionProvider:Wg},Yg.defaultProps={inputStyle:""},Yg.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerContentFocused:Function,inputStyle:{type:String,optional:!0},rect:{type:Object,optional:!0},delimitation:{type:Object,optional:!0},onComposerUnmounted:{type:Function,optional:!0}};const Kg=3*.4*window.devicePixelRatio||1;fo`
|
|
1147
1147
|
div.o-grid-composer {
|
|
1148
1148
|
z-index: ${ce.GridComposer};
|
|
1149
1149
|
box-sizing: border-box;
|
|
1150
1150
|
position: absolute;
|
|
1151
|
-
border: ${
|
|
1151
|
+
border: ${Kg}px solid ${E};
|
|
1152
1152
|
|
|
1153
1153
|
display: flex;
|
|
1154
1154
|
align-items: center;
|
|
@@ -1164,7 +1164,7 @@
|
|
|
1164
1164
|
padding: 6px 7px;
|
|
1165
1165
|
border-radius: 4px;
|
|
1166
1166
|
}
|
|
1167
|
-
`;class
|
|
1167
|
+
`;class Qg extends t.Component{setup(){this.gridComposerRef=t.useRef("gridComposer"),this.composerState=t.useState({rect:void 0,delimitation:void 0});const{sheetId:e,col:i,row:o}=this.env.model.getters.getActivePosition();this.zone=this.env.model.getters.expandZone(e,lo({col:i,row:o})),this.rect=this.env.model.getters.getVisibleRect(this.zone),this.isCellReferenceVisible=!1,t.onMounted((()=>{const e=this.gridComposerRef.el;this.composerState.rect={x:this.rect.x,y:this.rect.y,width:e.clientWidth,height:e.clientHeight},this.composerState.delimitation={width:e.parentElement.clientWidth,height:e.parentElement.clientHeight}})),t.onWillUpdateProps((()=>{if(this.isCellReferenceVisible)return;const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZone();ct(this.env.model.getters.getVisibleRect(t),this.rect)&&e===this.env.model.getters.getCurrentEditedCell().sheetId||(this.isCellReferenceVisible=!0)}))}get shouldDisplayCellReference(){return this.isCellReferenceVisible}get cellReference(){const{col:e,row:t,sheetId:i}=this.env.model.getters.getCurrentEditedCell();return`${i!==this.env.model.getters.getActiveSheetId()?De(this.env.model.getters.getSheetName(i))+"!":""}${qt(e,t)}`}get cellReferenceStyle(){const{x:e,y:t}=this.rect;return Co({left:e-Kg+"px",top:t-28+"px"})}get containerStyle(){const e=this.env.model.getters.getCurrentContent().startsWith("="),t=this.env.model.getters.getActiveCell(),i=this.env.model.getters.getActivePosition(),o=this.env.model.getters.getCellComputedStyle(i),{x:n,y:s,width:r,height:a}=this.rect,l=!e&&o.fillColor||"#ffffff",c=!e&&o.textColor||"#000000",h=!e&&o.fontSize||10,d=!e&&o.bold?"bold":void 0,u=!e&&o.italic?"italic":"normal",g=e?"none":vo(o);let p="left";return e||(p=o.align||t.defaultAlign),Co({left:n-1+"px",top:`${s}px`,"min-width":`${r+1}px`,"min-height":`${a+1}px`,background:l,color:c,"font-size":`${Ve(h)}px`,"font-weight":d,"font-style":u,"text-decoration":g,"text-align":p})}get composerStyle(){const e=this.props.gridDims.height-this.rect.y;return Co({"max-width":`${this.props.gridDims.width-this.rect.x}px`,"max-height":`${e}px`})}}Qg.template="o-spreadsheet-GridComposer",Qg.components={Composer:Yg},Qg.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerUnmounted:Function,onComposerContentFocused:Function,gridDims:Object};const Jg=fo`
|
|
1168
1168
|
.o-filter-icon {
|
|
1169
1169
|
color: ${R};
|
|
1170
1170
|
position: absolute;
|
|
@@ -1188,7 +1188,7 @@
|
|
|
1188
1188
|
}
|
|
1189
1189
|
}
|
|
1190
1190
|
}
|
|
1191
|
-
`;class Qg extends t.Component{get style(){const{x:e,y:t}=this.props.position;return`top:${t}px;left:${e}px`}}Qg.style=Kg,Qg.template="o-spreadsheet-FilterIcon",Qg.props={position:Object,isActive:Boolean,onClick:Function};const Jg=fo``;class ep extends t.Component{getVisibleFilterHeaders(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getFilterHeaders(e).filter((e=>this.isPositionVisible(e.col,e.row)))}getFilterHeaderPosition(e){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getRowDimensionsInViewport(t,e.row),o=this.env.model.getters.getColDimensionsInViewport(t,e.col),n=Math.floor((i.size-H)/2);return{x:o.end-H+this.props.gridPosition.x-2-1,y:i.end-H+this.props.gridPosition.y-n}}isFilterActive(e){const t=this.env.model.getters.getActiveSheetId();return this.env.model.getters.isFilterActive({sheetId:t,...e})}toggleFilterMenu(e){const t=this.env.model.getters.getPersistentPopoverTypeAtPosition(e);if(t&&"FilterMenu"===t)return void this.env.model.dispatch("CLOSE_CELL_POPOVER");const{col:i,row:o}=e;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:i,row:o,popoverType:"FilterMenu"})}isPositionVisible(e,t){const i=this.env.model.getters.getVisibleRect({left:e,right:e,top:t,bottom:t});return!(0===i.width||0===i.height)}}ep.style=Jg,ep.template="o-spreadsheet-FilterIconsOverlay",ep.components={FilterIcon:Qg},ep.defaultProps={gridPosition:{x:0,y:0}},ep.props={gridPosition:{type:Object,optional:!0}};class tp extends t.Component{constructor(){super(...arguments),this.dnd=t.useState({figId:void 0,x:0,y:0,width:0,height:0})}setup(){t.onMounted((()=>{this.render()}))}getVisibleFigures(){const e=this.env.model.getters.getVisibleFigures();return this.dnd.figId&&!e.some((e=>e.id===this.dnd.figId))&&e.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(),this.dnd.figId)),e}get containers(){const e=this.getVisibleFigures(),t=[];for(const i of["topLeft","topRight","bottomLeft","bottomRight"]){const o=e.filter((e=>this.getFigureContainer(e)===i));o.length>0&&t.push({type:i,figures:o,style:this.getContainerStyle(i),inverseViewportStyle:this.getInverseViewportPositionStyle(i)})}return this.dnd.figId&&t.push({type:"dnd",figures:[this.getDndFigure()],style:this.getContainerStyle("dnd"),inverseViewportStyle:this.getInverseViewportPositionStyle("dnd")}),t}getContainerStyle(e){const{width:t,height:i}=this.env.model.getters.getMainViewportRect(),{x:o,y:n}=this.env.model.getters.getMainViewportCoordinates(),s=["bottomRight","topRight"].includes(e)?o:0,r=t-s,a=["bottomRight","bottomLeft"].includes(e)?n:0;return Co({left:`${s}px`,top:`${a}px`,width:`${r}px`,height:`${i-a}px`})}getInverseViewportPositionStyle(e){const{scrollX:t,scrollY:i}=this.env.model.getters.getActiveSheetScrollInfo(),{x:o,y:n}=this.env.model.getters.getMainViewportCoordinates();return Co({left:`${["bottomRight","topRight"].includes(e)?-(o+t):0}px`,top:`${["bottomRight","bottomLeft"].includes(e)?-(n+i):0}px`})}getFigureContainer(e){const{x:t,y:i}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.figId?"dnd":e.x<t&&e.y<i?"topLeft":e.x<t?"bottomLeft":e.y<i?"topRight":"bottomRight"}startDraggingFigure(e,t){if(t.button>0||this.env.model.getters.isReadonly())return;if(!this.env.model.dispatch("SELECT_FIGURE",{id:e.id}).isSuccessful)return;const i=this.env.model.getters.getActiveSheetId(),o=t.clientX,n=t.clientY,{x:s,y:r}=this.internalToScreenCoordinates(e);this.dnd.x=s,this.dnd.y=r,this.dnd.width=e.width,this.dnd.height=e.height;kg((t=>{const{x:i,y:a}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:l,scrollY:c}=this.env.model.getters.getActiveSheetScrollInfo(),h=i?0:-l,d=a?0:-c;this.dnd.figId=e.id;let u=t.clientX-o;this.dnd.x=Math.max(s+u,h);let g=t.clientY-n;this.dnd.y=Math.max(r+g,d)}),(t=>{if(!this.dnd.figId)return;let{x:o,y:n}=this.screenCoordinatesToInternal(this.dnd);this.dnd.figId=void 0,this.env.model.dispatch("UPDATE_FIGURE",{sheetId:i,id:e.id,x:o,y:n})}))}startResize(e,t,i,o){o.stopPropagation();const n=o.clientX,s=o.clientY,{x:r,y:a}=this.internalToScreenCoordinates(e);this.dnd.x=r,this.dnd.y=a,this.dnd.width=e.width,this.dnd.height=e.height;const l=vr.get(e.tag).keepRatio||!1,c=vr.get(e.tag).minFigSize||80;let h;h=l&&0!=t&&0!=i?o=>{this.dnd.figId=e.id;const l=Math.min(t*(n-o.clientX),e.width-c),h=Math.min(i*(s-o.clientY),e.height-c),d=Math.min(l/e.width,h/e.height);this.dnd.width=e.width*(1-d),this.dnd.height=e.height*(1-d),t<0&&(this.dnd.x=r+e.width*d),i<0&&(this.dnd.y=a+e.height*d),this.dnd.x<0&&(this.dnd.width+=this.dnd.x,this.dnd.x=0),this.dnd.y<0&&(this.dnd.height+=this.dnd.y,this.dnd.y=0)}:o=>{this.dnd.figId=e.id;const l=Math.max(t*(o.clientX-n),c-e.width),h=Math.max(i*(o.clientY-s),c-e.height);this.dnd.width=e.width+l,this.dnd.height=e.height+h,t<0&&(this.dnd.x=r-l),i<0&&(this.dnd.y=a-h),this.dnd.x<0&&(this.dnd.width+=this.dnd.x,this.dnd.x=0),this.dnd.y<0&&(this.dnd.height+=this.dnd.y,this.dnd.y=0)};kg(h,(o=>{if(!this.dnd.figId)return;this.dnd.figId=void 0;let{x:n,y:s}=this.screenCoordinatesToInternal(this.dnd);const r={x:n,y:s};t&&(r.width=this.dnd.width),i&&(r.height=this.dnd.height),this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:e.id,...r})}))}getDndFigure(){const e=this.getVisibleFigures().find((e=>e.id===this.dnd.figId));if(!e)throw new Error("Dnd figure not found");return{...e,x:this.dnd.x,y:this.dnd.y,width:this.dnd.width,height:this.dnd.height}}getFigureStyle(e){return e.id!==this.dnd.figId?"":Co({opacity:"0.9",cursor:"grabbing"})}internalToScreenCoordinates({x:e,y:t}){const{x:i,y:o}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=e<i?e:e-n,y:t=t<o?t:t-s}}screenCoordinatesToInternal({x:e,y:t}){const{x:i,y:o}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=i&&e<i?e:e+n,y:t=o&&t<o?t:t+s}}}function ip(e,i,o){let n={col:void 0,row:void 0};const{Date:s}=window;let r=0,a=0,l=0;function c(){return{col:e.model.getters.getColIndex(r),row:e.model.getters.getRowIndex(a)}}const{pause:h,resume:d}=function(e,i){let o;const{setInterval:n,clearInterval:s}=window;return t.useEffect((()=>(o=n(e,i),()=>s(o))),(()=>[i])),{pause:()=>{s(o),o=void 0},resume:()=>{void 0===o&&(o=n(e,i))}}}((function(){const{col:e,row:t}=c(),i=s.now()-l;i>300&&(e!==n.col||t!==n.row)&&p(void 0,void 0);if(i>300){if(e<0||t<0)return;p(e,t)}}),200);function u(e){i.el===e.target&&(r=e.offsetX,a=e.offsetY,l=s.now())}function g(){const{col:e,row:t}=c();e===n.col&&t===n.row||p(void 0,void 0)}function p(e,t){e===n.col&&t===n.row||(n.col=e,n.row=t,o({col:e,row:t}))}return t.onMounted((()=>{const e=i.el;e.addEventListener("mousemove",u),e.addEventListener("mouseleave",h),e.addEventListener("mouseenter",d),e.addEventListener("mousedown",g)})),t.onWillUnmount((()=>{const e=i.el;e.removeEventListener("mousemove",u),e.removeEventListener("mouseleave",h),e.removeEventListener("mouseenter",d),e.removeEventListener("mousedown",g)})),n}tp.template="o-spreadsheet-FiguresContainer",tp.components={FigureComponent:Dg},tp.props={onFigureDeleted:Function};class op extends t.Component{setup(){this.gridOverlay=t.useRef("gridOverlay"),ip(this.env,this.gridOverlay,this.props.onCellHovered);const e=new ResizeObserver((()=>{this.props.onGridResized({height:this.gridOverlayEl.clientHeight,width:this.gridOverlayEl.clientWidth})}));t.onMounted((()=>{e.observe(this.gridOverlayEl)})),t.onWillUnmount((()=>{e.disconnect()})),function(e,i,o){let n=null,s=null;function r(e){1===e.touches.length&&(n=e.touches[0].clientX,s=e.touches[0].clientY)}function a(){n=null,s=null}function l(e){if(1!==e.touches.length)return;o()&&(e.preventDefault(),e.stopPropagation());const t=e.touches[0].clientX,r=e.touches[0].clientY;i(n-t,s-r),n=t,s=r}t.onMounted((()=>{e.el.addEventListener("touchstart",r),e.el.addEventListener("touchend",a),e.el.addEventListener("touchmove",l)})),t.onWillUnmount((()=>{e.el.removeEventListener("touchstart",r),e.el.removeEventListener("touchend",a),e.el.removeEventListener("touchmove",l)}))}(this.gridOverlay,this.props.onGridMoved,(()=>{const{scrollY:e}=this.env.model.getters.getActiveSheetDOMScrollInfo();return e>0}))}get gridOverlayEl(){if(!this.gridOverlay.el)throw new Error("GridOverlay el is not defined.");return this.gridOverlay.el}onMouseDown(e){if(e.button>0)return;const[t,i]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,i,{shiftKey:e.shiftKey,ctrlKey:e.ctrlKey})}onDoubleClick(e){const[t,i]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,i)}onContextMenu(e){e.preventDefault();const[t,i]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,i,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}}op.template="o-spreadsheet-GridOverlay",op.components={FiguresContainer:tp},op.defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{}},op.props={onCellHovered:{type:Function,optional:!0},onCellDoubleClicked:{type:Function,optional:!0},onCellClicked:{type:Function,optional:!0},onCellRightClicked:{type:Function,optional:!0},onGridResized:{type:Function,optional:!0},onFigureDeleted:{type:Function,optional:!0},onGridMoved:Function,gridOverlayDimensions:String};class np extends t.Component{constructor(){super(...arguments),this.zIndex=ce.GridPopover}get cellPopover(){const e=this.env.model.getters.getCellPopover(this.props.hoveredCell);if(!e.isOpen)return{isOpen:!1};const t=e.anchorRect;return{...e,anchorRect:{...t,x:t.x+this.props.gridRect.x,y:t.y+this.props.gridRect.y}}}}np.template="o-spreadsheet-GridPopover",np.components={Popover:Xn},np.props={hoveredCell:Object,onClosePopover:Function,onMouseWheel:Function,gridRect:Object};class sp extends t.Component{constructor(){super(...arguments),this.PADDING=0,this.MAX_SIZE_MARGIN=0,this.MIN_ELEMENT_SIZE=0,this.lastSelectedElementIndex=null,this.state=t.useState({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0,position:"before"})}_computeHandleDisplay(e){const t=this._getEvOffset(e),i=this._getElementIndex(t);if(i<0)return;const o=this._getDimensionsInViewport(i);t-o.start<this.PADDING&&i!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=o.start,this.state.activeElement=this._getPreviousVisibleElement(i)):o.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=o.end,this.state.activeElement=i):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),i=this._getActiveElements(),o=this._getSelectedZoneStart(),n=this._getSelectedZoneEnd();i.has(o)&&o<=t&&t<=n?this.state.waitingForMove=!0:this.state.waitingForMove=!1}onMouseMove(e){this.state.isResizing||this.state.isMoving||this.state.isSelecting||(this._computeHandleDisplay(e),this._computeGrabDisplay(e))}onMouseLeave(){this.state.resizerIsActive=this.state.isResizing,this.state.waitingForMove=!1}onDblClick(e){this._fitElementSize(this.state.activeElement),this.state.isResizing=!1,this._computeHandleDisplay(e),this._computeGrabDisplay(e)}onMouseDown(e){this.state.isResizing=!0,this.state.delta=0;const t=this._getClientPosition(e),i=this.state.draggerLinePosition,o=this._getElementSize(this.state.activeElement),n=i-o+this.MIN_ELEMENT_SIZE,s=this._getMaxSize();kg((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=i+this.state.delta,this.state.draggerLinePosition<n&&(this.state.draggerLinePosition=n,this.state.delta=this.MIN_ELEMENT_SIZE-o),this.state.draggerLinePosition>s&&(this.state.draggerLinePosition=s,this.state.delta=s-i)}),(e=>{this.state.isResizing=!1,0!==this.state.delta&&this._updateSize()}))}select(e){if(e.button>0)return;const t=this._getElementIndex(this._getEvOffset(e));t<0||(!0!==this.state.waitingForMove?("editing"===this.env.model.getters.getEditionMode()&&this.env.model.selection.getBackToDefault(),this.startSelection(e,t)):this.env.model.getters.isGridSelectionActive()?this.startMovement(e):this._selectElement(t,!1))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),i=this._getDimensionsInViewport(this._getSelectedZoneEnd()),o=t.start;this.state.draggerLinePosition=o,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=o,this.state.draggerShadowThickness=i.end-t.start;Lg(this.env,((e,i)=>{let o="COL"===this._getType()?e:i;if(o>=0){const e=this._getDimensionsInViewport(o);o<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=o,this.state.position="before"):this._getSelectedZoneEnd()<o?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=o,this.state.position="after"):(this.state.draggerLinePosition=t.start,this.state.draggerShadowPosition=t.start,this.state.base=this._getSelectedZoneStart())}}),(()=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements(),this._computeGrabDisplay(e)}))}startSelection(e,t){this.state.isSelecting=!0,e.shiftKey?this._increaseSelection(t):this._selectElement(t,e.ctrlKey),this.lastSelectedElementIndex=t;Lg(this.env,((e,t)=>{let i="COL"===this._getType()?e:t;i!==this.lastSelectedElementIndex&&-1!==i&&(this._increaseSelection(i),this.lastSelectedElementIndex=i)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this.env.model.dispatch(e.ctrlKey?"PREPARE_SELECTION_INPUT_EXPANSION":"STOP_SELECTION_INPUT"),this._computeGrabDisplay(e)}))}onMouseUp(e){this.lastSelectedElementIndex=null}onContextMenu(e){e.preventDefault();const t=this._getElementIndex(this._getEvOffset(e));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);const i=this._getType();this.props.onOpenContextMenu(i,e.clientX,e.clientY)}}fo`
|
|
1191
|
+
`;class ep extends t.Component{get style(){const{x:e,y:t}=this.props.position;return`top:${t}px;left:${e}px`}}ep.style=Jg,ep.template="o-spreadsheet-FilterIcon",ep.props={position:Object,isActive:Boolean,onClick:Function};const tp=fo``;class ip extends t.Component{getVisibleFilterHeaders(){const e=this.env.model.getters.getActiveSheetId();return this.env.model.getters.getFilterHeaders(e).filter((e=>this.isPositionVisible(e.col,e.row)))}getFilterHeaderPosition(e){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getRowDimensionsInViewport(t,e.row),o=this.env.model.getters.getColDimensionsInViewport(t,e.col),n=Math.floor((i.size-H)/2);return{x:o.end-H+this.props.gridPosition.x-2-1,y:i.end-H+this.props.gridPosition.y-n}}isFilterActive(e){const t=this.env.model.getters.getActiveSheetId();return this.env.model.getters.isFilterActive({sheetId:t,...e})}toggleFilterMenu(e){const t=this.env.model.getters.getPersistentPopoverTypeAtPosition(e);if(t&&"FilterMenu"===t)return void this.env.model.dispatch("CLOSE_CELL_POPOVER");const{col:i,row:o}=e;this.env.model.dispatch("OPEN_CELL_POPOVER",{col:i,row:o,popoverType:"FilterMenu"})}isPositionVisible(e,t){const i=this.env.model.getters.getVisibleRect({left:e,right:e,top:t,bottom:t});return!(0===i.width||0===i.height)}}ip.style=tp,ip.template="o-spreadsheet-FilterIconsOverlay",ip.components={FilterIcon:ep},ip.defaultProps={gridPosition:{x:0,y:0}},ip.props={gridPosition:{type:Object,optional:!0}};class op extends t.Component{constructor(){super(...arguments),this.dnd=t.useState({figId:void 0,x:0,y:0,width:0,height:0})}setup(){t.onMounted((()=>{this.render()}))}getVisibleFigures(){const e=this.env.model.getters.getVisibleFigures();return this.dnd.figId&&!e.some((e=>e.id===this.dnd.figId))&&e.push(this.env.model.getters.getFigure(this.env.model.getters.getActiveSheetId(),this.dnd.figId)),e}get containers(){const e=this.getVisibleFigures(),t=[];for(const i of["topLeft","topRight","bottomLeft","bottomRight"]){const o=e.filter((e=>this.getFigureContainer(e)===i));o.length>0&&t.push({type:i,figures:o,style:this.getContainerStyle(i),inverseViewportStyle:this.getInverseViewportPositionStyle(i)})}return this.dnd.figId&&t.push({type:"dnd",figures:[this.getDndFigure()],style:this.getContainerStyle("dnd"),inverseViewportStyle:this.getInverseViewportPositionStyle("dnd")}),t}getContainerStyle(e){const{width:t,height:i}=this.env.model.getters.getMainViewportRect(),{x:o,y:n}=this.env.model.getters.getMainViewportCoordinates(),s=["bottomRight","topRight"].includes(e)?o:0,r=t-s,a=["bottomRight","bottomLeft"].includes(e)?n:0;return Co({left:`${s}px`,top:`${a}px`,width:`${r}px`,height:`${i-a}px`})}getInverseViewportPositionStyle(e){const{scrollX:t,scrollY:i}=this.env.model.getters.getActiveSheetScrollInfo(),{x:o,y:n}=this.env.model.getters.getMainViewportCoordinates();return Co({left:`${["bottomRight","topRight"].includes(e)?-(o+t):0}px`,top:`${["bottomRight","bottomLeft"].includes(e)?-(n+i):0}px`})}getFigureContainer(e){const{x:t,y:i}=this.env.model.getters.getMainViewportCoordinates();return e.id===this.dnd.figId?"dnd":e.x<t&&e.y<i?"topLeft":e.x<t?"bottomLeft":e.y<i?"topRight":"bottomRight"}startDraggingFigure(e,t){if(t.button>0||this.env.model.getters.isReadonly())return;if(!this.env.model.dispatch("SELECT_FIGURE",{id:e.id}).isSuccessful)return;const i=this.env.model.getters.getActiveSheetId(),o=t.clientX,n=t.clientY,{x:s,y:r}=this.internalToScreenCoordinates(e);this.dnd.x=s,this.dnd.y=r,this.dnd.width=e.width,this.dnd.height=e.height;Pg((t=>{const{x:i,y:a}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:l,scrollY:c}=this.env.model.getters.getActiveSheetScrollInfo(),h=i?0:-l,d=a?0:-c;this.dnd.figId=e.id;let u=t.clientX-o;this.dnd.x=Math.max(s+u,h);let g=t.clientY-n;this.dnd.y=Math.max(r+g,d)}),(t=>{if(!this.dnd.figId)return;let{x:o,y:n}=this.screenCoordinatesToInternal(this.dnd);this.dnd.figId=void 0,this.env.model.dispatch("UPDATE_FIGURE",{sheetId:i,id:e.id,x:o,y:n})}))}startResize(e,t,i,o){o.stopPropagation();const n=o.clientX,s=o.clientY,{x:r,y:a}=this.internalToScreenCoordinates(e);this.dnd.x=r,this.dnd.y=a,this.dnd.width=e.width,this.dnd.height=e.height;const l=Sr.get(e.tag).keepRatio||!1,c=Sr.get(e.tag).minFigSize||80;let h;h=l&&0!=t&&0!=i?o=>{this.dnd.figId=e.id;const l=Math.min(t*(n-o.clientX),e.width-c),h=Math.min(i*(s-o.clientY),e.height-c),d=Math.min(l/e.width,h/e.height);this.dnd.width=e.width*(1-d),this.dnd.height=e.height*(1-d),t<0&&(this.dnd.x=r+e.width*d),i<0&&(this.dnd.y=a+e.height*d),this.dnd.x<0&&(this.dnd.width+=this.dnd.x,this.dnd.x=0),this.dnd.y<0&&(this.dnd.height+=this.dnd.y,this.dnd.y=0)}:o=>{this.dnd.figId=e.id;const l=Math.max(t*(o.clientX-n),c-e.width),h=Math.max(i*(o.clientY-s),c-e.height);this.dnd.width=e.width+l,this.dnd.height=e.height+h,t<0&&(this.dnd.x=r-l),i<0&&(this.dnd.y=a-h),this.dnd.x<0&&(this.dnd.width+=this.dnd.x,this.dnd.x=0),this.dnd.y<0&&(this.dnd.height+=this.dnd.y,this.dnd.y=0)};Pg(h,(o=>{if(!this.dnd.figId)return;this.dnd.figId=void 0;let{x:n,y:s}=this.screenCoordinatesToInternal(this.dnd);const r={x:n,y:s};t&&(r.width=this.dnd.width),i&&(r.height=this.dnd.height),this.env.model.dispatch("UPDATE_FIGURE",{sheetId:this.env.model.getters.getActiveSheetId(),id:e.id,...r})}))}getDndFigure(){const e=this.getVisibleFigures().find((e=>e.id===this.dnd.figId));if(!e)throw new Error("Dnd figure not found");return{...e,x:this.dnd.x,y:this.dnd.y,width:this.dnd.width,height:this.dnd.height}}getFigureStyle(e){return e.id!==this.dnd.figId?"":Co({opacity:"0.9",cursor:"grabbing"})}internalToScreenCoordinates({x:e,y:t}){const{x:i,y:o}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=e<i?e:e-n,y:t=t<o?t:t-s}}screenCoordinatesToInternal({x:e,y:t}){const{x:i,y:o}=this.env.model.getters.getMainViewportCoordinates(),{scrollX:n,scrollY:s}=this.env.model.getters.getActiveSheetScrollInfo();return{x:e=i&&e<i?e:e+n,y:t=o&&t<o?t:t+s}}}function np(e,i,o){let n={col:void 0,row:void 0};const{Date:s}=window;let r=0,a=0,l=0;function c(){return{col:e.model.getters.getColIndex(r),row:e.model.getters.getRowIndex(a)}}const{pause:h,resume:d}=function(e,i){let o;const{setInterval:n,clearInterval:s}=window;return t.useEffect((()=>(o=n(e,i),()=>s(o))),(()=>[i])),{pause:()=>{s(o),o=void 0},resume:()=>{void 0===o&&(o=n(e,i))}}}((function(){const{col:e,row:t}=c(),i=s.now()-l;i>300&&(e!==n.col||t!==n.row)&&p(void 0,void 0);if(i>300){if(e<0||t<0)return;p(e,t)}}),200);function u(e){i.el===e.target&&(r=e.offsetX,a=e.offsetY,l=s.now())}function g(){const{col:e,row:t}=c();e===n.col&&t===n.row||p(void 0,void 0)}function p(e,t){e===n.col&&t===n.row||(n.col=e,n.row=t,o({col:e,row:t}))}return t.onMounted((()=>{const e=i.el;e.addEventListener("mousemove",u),e.addEventListener("mouseleave",h),e.addEventListener("mouseenter",d),e.addEventListener("mousedown",g)})),t.onWillUnmount((()=>{const e=i.el;e.removeEventListener("mousemove",u),e.removeEventListener("mouseleave",h),e.removeEventListener("mouseenter",d),e.removeEventListener("mousedown",g)})),n}op.template="o-spreadsheet-FiguresContainer",op.components={FigureComponent:Lg},op.props={onFigureDeleted:Function};class sp extends t.Component{setup(){this.gridOverlay=t.useRef("gridOverlay"),np(this.env,this.gridOverlay,this.props.onCellHovered);const e=new ResizeObserver((()=>{this.props.onGridResized({height:this.gridOverlayEl.clientHeight,width:this.gridOverlayEl.clientWidth})}));t.onMounted((()=>{e.observe(this.gridOverlayEl)})),t.onWillUnmount((()=>{e.disconnect()})),function(e,i,o){let n=null,s=null;function r(e){1===e.touches.length&&(n=e.touches[0].clientX,s=e.touches[0].clientY)}function a(){n=null,s=null}function l(e){if(1!==e.touches.length)return;o()&&(e.preventDefault(),e.stopPropagation());const t=e.touches[0].clientX,r=e.touches[0].clientY;i(n-t,s-r),n=t,s=r}t.onMounted((()=>{e.el.addEventListener("touchstart",r),e.el.addEventListener("touchend",a),e.el.addEventListener("touchmove",l)})),t.onWillUnmount((()=>{e.el.removeEventListener("touchstart",r),e.el.removeEventListener("touchend",a),e.el.removeEventListener("touchmove",l)}))}(this.gridOverlay,this.props.onGridMoved,(()=>{const{scrollY:e}=this.env.model.getters.getActiveSheetDOMScrollInfo();return e>0}))}get gridOverlayEl(){if(!this.gridOverlay.el)throw new Error("GridOverlay el is not defined.");return this.gridOverlay.el}onMouseDown(e){if(e.button>0)return;const[t,i]=this.getCartesianCoordinates(e);this.props.onCellClicked(t,i,{expandZone:e.shiftKey,addZone:qn(e)})}onDoubleClick(e){const[t,i]=this.getCartesianCoordinates(e);this.props.onCellDoubleClicked(t,i)}onContextMenu(e){e.preventDefault();const[t,i]=this.getCartesianCoordinates(e);this.props.onCellRightClicked(t,i,{x:e.clientX,y:e.clientY})}getCartesianCoordinates(e){return[this.env.model.getters.getColIndex(e.offsetX),this.env.model.getters.getRowIndex(e.offsetY)]}}sp.template="o-spreadsheet-GridOverlay",sp.components={FiguresContainer:op},sp.defaultProps={onCellHovered:()=>{},onCellDoubleClicked:()=>{},onCellClicked:()=>{},onCellRightClicked:()=>{},onGridResized:()=>{},onFigureDeleted:()=>{}},sp.props={onCellHovered:{type:Function,optional:!0},onCellDoubleClicked:{type:Function,optional:!0},onCellClicked:{type:Function,optional:!0},onCellRightClicked:{type:Function,optional:!0},onGridResized:{type:Function,optional:!0},onFigureDeleted:{type:Function,optional:!0},onGridMoved:Function,gridOverlayDimensions:String};class rp extends t.Component{constructor(){super(...arguments),this.zIndex=ce.GridPopover}get cellPopover(){const e=this.env.model.getters.getCellPopover(this.props.hoveredCell);if(!e.isOpen)return{isOpen:!1};const t=e.anchorRect;return{...e,anchorRect:{...t,x:t.x+this.props.gridRect.x,y:t.y+this.props.gridRect.y}}}}rp.template="o-spreadsheet-GridPopover",rp.components={Popover:Kn},rp.props={hoveredCell:Object,onClosePopover:Function,onMouseWheel:Function,gridRect:Object};class ap extends t.Component{constructor(){super(...arguments),this.PADDING=0,this.MAX_SIZE_MARGIN=0,this.MIN_ELEMENT_SIZE=0,this.lastSelectedElementIndex=null,this.state=t.useState({resizerIsActive:!1,isResizing:!1,isMoving:!1,isSelecting:!1,waitingForMove:!1,activeElement:0,draggerLinePosition:0,draggerShadowPosition:0,draggerShadowThickness:0,delta:0,base:0,position:"before"})}_computeHandleDisplay(e){const t=this._getEvOffset(e),i=this._getElementIndex(t);if(i<0)return;const o=this._getDimensionsInViewport(i);t-o.start<this.PADDING&&i!==this._getViewportOffset()?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=o.start,this.state.activeElement=this._getPreviousVisibleElement(i)):o.end-t<this.PADDING?(this.state.resizerIsActive=!0,this.state.draggerLinePosition=o.end,this.state.activeElement=i):this.state.resizerIsActive=!1}_computeGrabDisplay(e){const t=this._getElementIndex(this._getEvOffset(e)),i=this._getActiveElements(),o=this._getSelectedZoneStart(),n=this._getSelectedZoneEnd();i.has(o)&&o<=t&&t<=n?this.state.waitingForMove=!0:this.state.waitingForMove=!1}onMouseMove(e){this.state.isResizing||this.state.isMoving||this.state.isSelecting||(this._computeHandleDisplay(e),this._computeGrabDisplay(e))}onMouseLeave(){this.state.resizerIsActive=this.state.isResizing,this.state.waitingForMove=!1}onDblClick(e){this._fitElementSize(this.state.activeElement),this.state.isResizing=!1,this._computeHandleDisplay(e),this._computeGrabDisplay(e)}onMouseDown(e){this.state.isResizing=!0,this.state.delta=0;const t=this._getClientPosition(e),i=this.state.draggerLinePosition,o=this._getElementSize(this.state.activeElement),n=i-o+this.MIN_ELEMENT_SIZE,s=this._getMaxSize();Pg((e=>{this.state.delta=this._getClientPosition(e)-t,this.state.draggerLinePosition=i+this.state.delta,this.state.draggerLinePosition<n&&(this.state.draggerLinePosition=n,this.state.delta=this.MIN_ELEMENT_SIZE-o),this.state.draggerLinePosition>s&&(this.state.draggerLinePosition=s,this.state.delta=s-i)}),(e=>{this.state.isResizing=!1,0!==this.state.delta&&this._updateSize()}))}select(e){if(e.button>0)return;const t=this._getElementIndex(this._getEvOffset(e));t<0||(!0!==this.state.waitingForMove?("editing"===this.env.model.getters.getEditionMode()&&this.env.model.selection.getBackToDefault(),this.startSelection(e,t)):this.env.model.getters.isGridSelectionActive()?this.startMovement(e):this._selectElement(t,!1))}startMovement(e){this.state.waitingForMove=!1,this.state.isMoving=!0;const t=this._getDimensionsInViewport(this._getSelectedZoneStart()),i=this._getDimensionsInViewport(this._getSelectedZoneEnd()),o=t.start;this.state.draggerLinePosition=o,this.state.base=this._getSelectedZoneStart(),this.state.draggerShadowPosition=o,this.state.draggerShadowThickness=i.end-t.start;Ug(this.env,((e,i)=>{let o="COL"===this._getType()?e:i;if(o>=0){const e=this._getDimensionsInViewport(o);o<=this._getSelectedZoneStart()?(this.state.draggerLinePosition=e.start,this.state.draggerShadowPosition=e.start,this.state.base=o,this.state.position="before"):this._getSelectedZoneEnd()<o?(this.state.draggerLinePosition=e.end,this.state.draggerShadowPosition=e.end-this.state.draggerShadowThickness,this.state.base=o,this.state.position="after"):(this.state.draggerLinePosition=t.start,this.state.draggerShadowPosition=t.start,this.state.base=this._getSelectedZoneStart())}}),(()=>{this.state.isMoving=!1,this.state.base!==this._getSelectedZoneStart()&&this._moveElements(),this._computeGrabDisplay(e)}))}startSelection(e,t){this.state.isSelecting=!0,e.shiftKey?this._increaseSelection(t):this._selectElement(t,qn(e)),this.lastSelectedElementIndex=t;Ug(this.env,((e,t)=>{let i="COL"===this._getType()?e:t;i!==this.lastSelectedElementIndex&&-1!==i&&(this._increaseSelection(i),this.lastSelectedElementIndex=i)}),(()=>{this.state.isSelecting=!1,this.lastSelectedElementIndex=null,this.env.model.dispatch(qn(e)?"PREPARE_SELECTION_INPUT_EXPANSION":"STOP_SELECTION_INPUT"),this._computeGrabDisplay(e)}))}onMouseUp(e){this.lastSelectedElementIndex=null}onContextMenu(e){e.preventDefault();const t=this._getElementIndex(this._getEvOffset(e));if(t<0)return;this._getActiveElements().has(t)||this._selectElement(t,!1);const i=this._getType();this.props.onOpenContextMenu(i,e.clientX,e.clientY)}}fo`
|
|
1192
1192
|
.o-col-resizer {
|
|
1193
1193
|
position: absolute;
|
|
1194
1194
|
top: 0;
|
|
@@ -1247,7 +1247,7 @@
|
|
|
1247
1247
|
top: calc(${P}px / 2 - ${L}px / 2);
|
|
1248
1248
|
}
|
|
1249
1249
|
}
|
|
1250
|
-
`,
|
|
1250
|
+
`,ap.props={onOpenContextMenu:Function};class lp extends ap{setup(){super.setup(),this.colResizerRef=t.useRef("colResizer"),this.PADDING=15,this.MAX_SIZE_MARGIN=90,this.MIN_ELEMENT_SIZE=5}_getEvOffset(e){return e.offsetX}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().left}_getClientPosition(e){return e.clientX}_getElementIndex(e){return this.env.model.getters.getColIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().left}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().right}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollCol(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getColDimensionsInViewport(this.env.model.getters.getActiveSheetId(),e)}_getElementSize(e){return this.env.model.getters.getColSize(this.env.model.getters.getActiveSheetId(),e)}_getMaxSize(){return this.colResizerRef.el.clientWidth}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),i=this.env.model.getters.getActiveCols();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"COL",sheetId:this.env.model.getters.getActiveSheetId(),elements:i.has(e)?[...i]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();for(let o=t;o<=i;o++)e.push(o);const o=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"COL",base:this.state.base,elements:e,position:this.state.position});!o.isSuccessful&&o.reasons.includes(2)&&this.env.raiseError(Ls)}_selectElement(e,t){this.env.model.selection.selectColumn(e,t?"newAnchor":"overrideSelection")}_increaseSelection(e){this.env.model.selection.selectColumn(e,"updateAnchor")}_fitElementSize(e){const t=this.env.model.getters.getActiveCols();this.env.model.dispatch("AUTORESIZE_COLUMNS",{sheetId:this.env.model.getters.getActiveSheetId(),cols:t.has(e)?[...t]:[e]})}_getType(){return"COL"}_getActiveElements(){return this.env.model.getters.getActiveCols()}_getPreviousVisibleElement(e){const t=this.env.model.getters.getActiveSheetId();let i;for(i=e-1;i>=0&&this.env.model.getters.isColHidden(t,i);i--);return i}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),elements:e,dimension:"COL"})}unhideStyleValue(e){return this._getDimensionsInViewport(e).start}}lp.template="o-spreadsheet-ColResizer",fo`
|
|
1251
1251
|
.o-row-resizer {
|
|
1252
1252
|
position: absolute;
|
|
1253
1253
|
top: ${N}px;
|
|
@@ -1308,7 +1308,7 @@
|
|
|
1308
1308
|
background-color: lightgrey;
|
|
1309
1309
|
}
|
|
1310
1310
|
}
|
|
1311
|
-
`,
|
|
1311
|
+
`,lp.props={onOpenContextMenu:Function};class cp extends ap{setup(){super.setup(),this.rowResizerRef=t.useRef("rowResizer"),this.PADDING=5,this.MAX_SIZE_MARGIN=60,this.MIN_ELEMENT_SIZE=10}_getEvOffset(e){return e.offsetY}_getViewportOffset(){return this.env.model.getters.getActiveMainViewport().top}_getClientPosition(e){return e.clientY}_getElementIndex(e){return this.env.model.getters.getRowIndex(e)}_getSelectedZoneStart(){return this.env.model.getters.getSelectedZone().top}_getSelectedZoneEnd(){return this.env.model.getters.getSelectedZone().bottom}_getEdgeScroll(e){return this.env.model.getters.getEdgeScrollRow(e,e,e)}_getDimensionsInViewport(e){return this.env.model.getters.getRowDimensionsInViewport(this.env.model.getters.getActiveSheetId(),e)}_getElementSize(e){return this.env.model.getters.getRowSize(this.env.model.getters.getActiveSheetId(),e)}_getMaxSize(){return this.rowResizerRef.el.clientHeight}_updateSize(){const e=this.state.activeElement,t=this.state.delta+this._getElementSize(e),i=this.env.model.getters.getActiveRows();this.env.model.dispatch("RESIZE_COLUMNS_ROWS",{dimension:"ROW",sheetId:this.env.model.getters.getActiveSheetId(),elements:i.has(e)?[...i]:[e],size:t})}_moveElements(){const e=[],t=this._getSelectedZoneStart(),i=this._getSelectedZoneEnd();for(let o=t;o<=i;o++)e.push(o);const o=this.env.model.dispatch("MOVE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",base:this.state.base,elements:e,position:this.state.position});!o.isSuccessful&&o.reasons.includes(2)&&this.env.raiseError(Ls)}_selectElement(e,t){this.env.model.selection.selectRow(e,t?"newAnchor":"overrideSelection")}_increaseSelection(e){this.env.model.selection.selectRow(e,"updateAnchor")}_fitElementSize(e){const t=this.env.model.getters.getActiveRows();this.env.model.dispatch("AUTORESIZE_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),rows:t.has(e)?[...t]:[e]})}_getType(){return"ROW"}_getActiveElements(){return this.env.model.getters.getActiveRows()}_getPreviousVisibleElement(e){const t=this.env.model.getters.getActiveSheetId();let i;for(i=e-1;i>=0&&this.env.model.getters.isRowHidden(t,i);i--);return i}unhide(e){this.env.model.dispatch("UNHIDE_COLUMNS_ROWS",{sheetId:this.env.model.getters.getActiveSheetId(),dimension:"ROW",elements:e})}unhideStyleValue(e){return this._getDimensionsInViewport(e).start}}cp.template="o-spreadsheet-RowResizer",fo`
|
|
1312
1312
|
.o-overlay {
|
|
1313
1313
|
.all {
|
|
1314
1314
|
position: absolute;
|
|
@@ -1319,7 +1319,7 @@
|
|
|
1319
1319
|
height: ${N}px;
|
|
1320
1320
|
}
|
|
1321
1321
|
}
|
|
1322
|
-
`,
|
|
1322
|
+
`,cp.props={onOpenContextMenu:Function};class hp extends t.Component{selectAll(){this.env.model.selection.selectAll()}}function dp(e,i,o){const n=t.useRef(e);t.useEffect((function(){const e=n.el,t=window.devicePixelRatio||1,s=e.getContext("2d",{alpha:!1}),r={ctx:s,dpr:t,thinLineWidth:.4*t},{width:a,height:l}=o();e.style.width=`${a}px`,e.style.height=`${l}px`,e.width=a*t,e.height=l*t,e.setAttribute("style",`width:${a}px;height:${l}px;`),s.translate(-m,-m),s.scale(t,t),i.drawGrid(r)}))}function up(e){function t(e,t){return e*(0===t?1:D)}return i=>{const o=t(i.shiftKey&&!Gn()?i.deltaY:i.deltaX,i.deltaMode),n=t(i.shiftKey&&!Gn()?i.deltaX:i.deltaY,i.deltaMode);e(o,n)}}hp.template="o-spreadsheet-HeadersOverlay",hp.components={ColResizer:lp,RowResizer:cp},hp.props={onOpenContextMenu:Function},fo`
|
|
1323
1323
|
.o-border {
|
|
1324
1324
|
position: absolute;
|
|
1325
1325
|
&:hover {
|
|
@@ -1329,7 +1329,7 @@
|
|
|
1329
1329
|
.o-moving {
|
|
1330
1330
|
cursor: grabbing;
|
|
1331
1331
|
}
|
|
1332
|
-
`;class
|
|
1332
|
+
`;class gp extends t.Component{get style(){const e=["n","w","e"].includes(this.props.orientation),t=["n","w","s"].includes(this.props.orientation),i=["n","s"].includes(this.props.orientation),o=["w","e"].includes(this.props.orientation),n=this.props.zone,s=this.env.model.getters.getVisibleRect(n),r=s.x,a=s.x+s.width-4,l=s.y,c=s.y+s.height-4;return Co({left:`${t?r:a}px`,top:`${e?l:c}px`,width:`${i?a-r:4}px`,height:`${o?c-l:4}px`})}onMouseDown(e){this.props.onMoveHighlight(e.clientX,e.clientY)}}gp.template="o-spreadsheet-Border",gp.props={zone:Object,orientation:String,isMoving:Boolean,onMoveHighlight:Function},fo`
|
|
1333
1333
|
.o-corner {
|
|
1334
1334
|
position: absolute;
|
|
1335
1335
|
height: 6px;
|
|
@@ -1351,11 +1351,11 @@
|
|
|
1351
1351
|
.o-resizing {
|
|
1352
1352
|
cursor: grabbing;
|
|
1353
1353
|
}
|
|
1354
|
-
`;class
|
|
1354
|
+
`;class pp extends t.Component{constructor(){super(...arguments),this.isTop="n"===this.props.orientation[0],this.isLeft="w"===this.props.orientation[1]}get style(){const e=this.props.zone,t=this.isLeft?e.left:e.right,i=this.isTop?e.top:e.bottom,o=this.env.model.getters.getVisibleRect({left:t,right:t,top:i,bottom:i});if(o.width*o.height==0)return"display:none";return Co({left:(this.isLeft?o.x:o.x+o.width)-4+"px",top:(this.isTop?o.y:o.y+o.height)-4+"px","background-color":this.props.color})}onMouseDown(e){this.props.onResizeHighlight(this.isLeft,this.isTop)}}pp.template="o-spreadsheet-Corner",pp.props={zone:Object,color:String,orientation:String,isResizing:Boolean,onResizeHighlight:Function},fo`
|
|
1355
1355
|
.o-highlight {
|
|
1356
1356
|
z-index: ${ce.Highlight};
|
|
1357
1357
|
}
|
|
1358
|
-
`;class
|
|
1358
|
+
`;class mp extends t.Component{constructor(){super(...arguments),this.highlightState=t.useState({shiftingMode:"none"})}onResizeHighlight(e,t){const i=this.env.model.getters.getActiveSheet();this.highlightState.shiftingMode="isResizing";const o=this.props.zone,n=e?o.right:o.left,s=t?o.bottom:o.top;let r=e?o.left:o.right,a=t?o.top:o.bottom,l=o;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(i.id,l)});Ug(this.env,((e,t)=>{if(r!==e||a!==t){const o=this.env.model.getters.getActiveSheetId();r=ke(-1===e?r:e,0,this.env.model.getters.getNumberCols(o)-1),a=ke(-1===t?a:t,0,this.env.model.getters.getNumberRows(o)-1);let c={left:Math.min(n,r),top:Math.min(s,a),right:Math.max(n,r),bottom:Math.max(s,a)};c=this.env.model.getters.expandZone(o,c),Yi(c,l)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(i.id,c)}),l=c)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}onMoveHighlight(e,t){this.highlightState.shiftingMode="isMoving";const i=this.props.zone,o=Hn(),n=this.env.model.getters.getActiveSheetId(),s=this.env.model.getters.getColIndex(e-o.left),r=this.env.model.getters.getRowIndex(t-o.top),a=-i.left,l=this.env.model.getters.getNumberCols(n)-i.right-1,c=-i.top,h=this.env.model.getters.getNumberRows(n)-i.bottom-1;let d=i;this.env.model.dispatch("START_CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(n,d)});let u=s,g=r;Ug(this.env,((e,t)=>{if(u!==e||g!==t){u=-1===e?u:e,g=-1===t?g:t;const o=ke(u-s,a,l),p=ke(g-r,c,h);let m={left:i.left+o,top:i.top+p,right:i.right+o,bottom:i.bottom+p};m=this.env.model.getters.expandZone(n,m),Yi(m,d)||(this.env.model.dispatch("CHANGE_HIGHLIGHT",{range:this.env.model.getters.getRangeDataFromZone(n,m)}),d=m)}}),(()=>{this.highlightState.shiftingMode="none",this.env.model.dispatch("STOP_COMPOSER_RANGE_SELECTION")}))}}mp.template="o-spreadsheet-Highlight",mp.components={Corner:pp,Border:gp},mp.props={zone:Object,color:String};class fp{constructor(e,t){this.el=e,this.direction=t}get scroll(){return"horizontal"===this.direction?this.el.scrollLeft:this.el.scrollTop}set scroll(e){"horizontal"===this.direction?this.el.scrollLeft=e:this.el.scrollTop=e}}fo`
|
|
1359
1359
|
.o-scrollbar {
|
|
1360
1360
|
position: absolute;
|
|
1361
1361
|
overflow: auto;
|
|
@@ -1371,7 +1371,7 @@
|
|
|
1371
1371
|
border-left: 1px solid #e2e3e3;
|
|
1372
1372
|
}
|
|
1373
1373
|
}
|
|
1374
|
-
`;class
|
|
1374
|
+
`;class vp extends t.Component{setup(){this.scrollbarRef=t.useRef("scrollbar"),this.scrollbar=new fp(this.scrollbarRef.el,this.props.direction),t.onMounted((()=>{this.scrollbar.el=this.scrollbarRef.el})),t.useEffect((()=>{this.scrollbar.scroll!==this.props.offset&&(this.scrollbar.scroll=this.props.offset)}),(()=>[this.scrollbar.scroll,this.props.offset]))}get sizeCss(){return Co({width:`${this.props.width}px`,height:`${this.props.height}px`})}get positionCss(){return Co(this.props.position)}onScroll(e){this.props.offset!==this.scrollbar.scroll&&this.props.onScroll(this.scrollbar.scroll)}}vp.template=t.xml`
|
|
1375
1375
|
<div
|
|
1376
1376
|
t-attf-class="o-scrollbar {{props.direction}}"
|
|
1377
1377
|
t-on-scroll="onScroll"
|
|
@@ -1379,7 +1379,7 @@
|
|
|
1379
1379
|
t-att-style="positionCss">
|
|
1380
1380
|
<div t-att-style="sizeCss"/>
|
|
1381
1381
|
</div>
|
|
1382
|
-
`,
|
|
1382
|
+
`,vp.defaultProps={width:1,height:1},vp.props={width:{type:Number,optional:!0},height:{type:Number,optional:!0},direction:String,position:Object,offset:Number,onScroll:Function};class bp extends t.Component{get offset(){return this.env.model.getters.getActiveSheetDOMScrollInfo().scrollX}get width(){return this.env.model.getters.getMainViewportRect().width}get isDisplayed(){const{xRatio:e}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());return e<1}get position(){const{x:e}=this.env.model.getters.getMainViewportRect();return{left:`${this.props.leftOffset+e}px`,bottom:"0px",height:"15px",right:"0px"}}onScroll(e){const{scrollY:t}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:e,offsetY:t})}}bp.components={ScrollBar:vp},bp.template=t.xml`
|
|
1383
1383
|
<ScrollBar
|
|
1384
1384
|
t-if="isDisplayed"
|
|
1385
1385
|
width="width"
|
|
@@ -1387,7 +1387,7 @@
|
|
|
1387
1387
|
offset="offset"
|
|
1388
1388
|
direction="'horizontal'"
|
|
1389
1389
|
onScroll.bind="onScroll"
|
|
1390
|
-
/>`,
|
|
1390
|
+
/>`,bp.defaultProps={leftOffset:0},bp.props={leftOffset:{type:Number,optional:!0}};class Sp extends t.Component{get offset(){return this.env.model.getters.getActiveSheetDOMScrollInfo().scrollY}get height(){return this.env.model.getters.getMainViewportRect().height}get isDisplayed(){const{yRatio:e}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());return e<1}get position(){const{y:e}=this.env.model.getters.getMainViewportRect();return{top:`${this.props.topOffset+e}px`,right:"0px",width:"15px",bottom:"0px"}}onScroll(e){const{scrollX:t}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:t,offsetY:e})}}Sp.components={ScrollBar:vp},Sp.template=t.xml`
|
|
1391
1391
|
<ScrollBar
|
|
1392
1392
|
t-if="isDisplayed"
|
|
1393
1393
|
height="height"
|
|
@@ -1395,13 +1395,13 @@
|
|
|
1395
1395
|
offset="offset"
|
|
1396
1396
|
direction="'vertical'"
|
|
1397
1397
|
onScroll.bind="onScroll"
|
|
1398
|
-
/>`,vp.defaultProps={topOffset:0},vp.props={topOffset:{type:Number,optional:!0}};const bp={ROW:ua,COL:da,CELL:ha};class Sp extends t.Component{constructor(){super(...arguments),this.HEADER_HEIGHT=N,this.HEADER_WIDTH=_,this.keyDownMapping={ENTER:()=>{this.env.model.getters.getActiveCell().type===ln.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},TAB:()=>this.env.model.selection.moveAnchorCell("right",1),"SHIFT+TAB":()=>this.env.model.selection.moveAnchorCell("left",1),F2:()=>{this.env.model.getters.getActiveCell().type===ln.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},DELETE:()=>{this.env.model.dispatch("DELETE_CONTENT",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},BACKSPACE:()=>{this.env.model.dispatch("DELETE_CONTENT",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},ESCAPE:()=>{this.env.model.getters.hasOpenedPopover()?this.closeOpenedPopover():this.menuState.isOpen?this.closeMenu():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"),"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}}),"ALT+=":()=>{var e;const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getSelectedZone(),{anchor:o}=this.env.model.getters.getSelection(),n=this.env.model.getters.getAutomaticSums(t,i,o.cell);if(this.env.model.getters.isSingleCellOrMerge(t,i)||this.env.model.getters.isEmpty(t,i)&&n.length<=1){const i=(null===(e=n[0])||void 0===e?void 0:e.zone)?this.env.model.getters.zoneToXC(t,n[0].zone):"",o=`=SUM(${i})`;this.props.onGridComposerCellFocused(o,{start:5,end:5+i.length})}else this.env.model.dispatch("SUM_SELECTION")},"CTRL+HOME":()=>{const e=this.env.model.getters.getActiveSheetId(),{col:t,row:i}=this.env.model.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0});this.env.model.selection.selectCell(t,i)},"CTRL+END":()=>{const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.findVisibleHeader(e,"COL",this.env.model.getters.getNumberCols(e)-1,0),i=this.env.model.getters.findVisibleHeader(e,"ROW",this.env.model.getters.getNumberRows(e)-1,0);this.env.model.selection.selectCell(t,i)},"SHIFT+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),left:0,right:this.env.model.getters.getNumberCols(e)-1},i=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:i,zone:t})},"CTRL+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),top:0,bottom:this.env.model.getters.getNumberRows(e)-1},i=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:i,zone:t})},"CTRL+SHIFT+ ":()=>{this.env.model.selection.selectAll()},"SHIFT+PAGEDOWN":()=>{this.env.model.dispatch("ACTIVATE_NEXT_SHEET")},"SHIFT+PAGEUP":()=>{this.env.model.dispatch("ACTIVATE_PREVIOUS_SHEET")},PAGEDOWN:()=>this.env.model.dispatch("SHIFT_VIEWPORT_DOWN"),PAGEUP:()=>this.env.model.dispatch("SHIFT_VIEWPORT_UP"),"CTRL+K":()=>sa(this.env)}}setup(){this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.gridRef=t.useRef("grid"),this.hiddenInput=t.useRef("hiddenInput"),this.canvasPosition=qn(this.gridRef),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useChildSubEnv({getPopoverContainerRect:()=>this.getGridRect()}),t.useExternalListener(document.body,"cut",this.copy.bind(this,!0)),t.useExternalListener(document.body,"copy",this.copy.bind(this,!1)),t.useExternalListener(document.body,"paste",this.paste),t.onMounted((()=>this.focus())),this.props.exposeFocus((()=>this.focus())),cp("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimensionWithHeaders())),t.useEffect((()=>this.focus()),(()=>[this.env.model.getters.getActiveSheetId()])),this.onMouseWheel=hp(((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.col=void 0,this.hoveredCell.row=void 0}))}onCellHovered({col:e,row:t}){this.hoveredCell.col=e,this.hoveredCell.row=t}get gridOverlayDimensions(){return Co({top:"26px",left:"48px",height:"calc(100% - 41px)",width:"calc(100% - 63px)"})}onClosePopover(){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.focus()}focus(){var e;this.env.model.getters.getSelectedFigureId()||"inactive"!==this.env.model.getters.getEditionMode()||null===(e=this.hiddenInput.el)||void 0===e||e.focus()}get gridEl(){if(!this.gridRef.el)throw new Error("Grid el is not defined.");return this.gridRef.el}getAutofillPosition(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect(e);return{left:t.x+t.width-4,top:t.y+t.height-4}}get isAutofillVisible(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect({left:e.right,right:e.right,top:e.bottom,bottom:e.bottom});return!(0===t.width||0===t.height)}onGridResized({height:e,width:t}){this.env.model.dispatch("RESIZE_SHEETVIEW",{width:t,height:e,gridOffsetX:_,gridOffsetY:N})}moveCanvas(e,t){const{scrollX:i,scrollY:o}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:i+e,offsetY:o+t})}getClientPositionKey(e){var t,i,o;return`${e.id}-${null===(t=e.position)||void 0===t?void 0:t.sheetId}-${null===(i=e.position)||void 0===i?void 0:i.col}-${null===(o=e.position)||void 0===o?void 0:o.row}`}isCellHovered(e,t){return this.hoveredCell.col===e&&this.hoveredCell.row===t}getGridRect(){return{...this.canvasPosition,...this.env.model.getters.getSheetViewDimensionWithHeaders()}}onCellClicked(e,t,{ctrlKey:i,shiftKey:o}){i&&this.env.model.dispatch("PREPARE_SELECTION_INPUT_EXPANSION"),this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),"editing"===this.env.model.getters.getEditionMode()&&this.env.model.dispatch("STOP_EDITION"),o?this.env.model.selection.setAnchorCorner(e,t):i?this.env.model.selection.addCellToSelection(e,t):this.env.model.selection.selectCell(e,t);let n=e,s=t;Lg(this.env,((e,t,i)=>{i.preventDefault(),(e!==n&&-1!=e||t!==s&&-1!=t)&&(n=-1===e?n:e,s=-1===t?s:t,this.env.model.selection.setAnchorCorner(n,s))}),(()=>{this.env.model.dispatch("STOP_SELECTION_INPUT"),this.env.model.getters.isPaintingFormat()&&this.env.model.dispatch("PASTE",{target:this.env.model.getters.getSelectedZones()})}))}onCellDoubleClicked(e,t){const i=this.env.model.getters.getActiveSheetId();({col:e,row:t}=this.env.model.getters.getMainCellPosition({sheetId:i,col:e,row:t}));this.env.model.getters.getEvaluatedCell({sheetId:i,col:e,row:t}).type===ln.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()}closeOpenedPopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}processArrows(e){e.preventDefault(),e.stopPropagation(),this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),sg(e,this.env.model.selection),this.env.model.getters.isPaintingFormat()&&this.env.model.dispatch("PASTE",{target:this.env.model.getters.getSelectedZones()})}onKeydown(e){if(e.key.startsWith("Arrow"))return void this.processArrows(e);let t="";e.ctrlKey&&(t+="CTRL+"),e.metaKey&&(t+="CTRL+"),e.altKey&&(t+="ALT+"),e.shiftKey&&(t+="SHIFT+"),t+=e.key.toUpperCase();let i=this.keyDownMapping[t];return i?(e.preventDefault(),e.stopPropagation(),void i()):void 0}onInput(e){(e.isComposing||"insertFromPaste"!==e.inputType)&&e.data&&(e.preventDefault(),e.stopPropagation(),this.props.onGridComposerCellFocused(e.data))}onInputContextMenu(e){e.preventDefault();const t=this.env.model.getters.getSelectedZone(),{left:i,top:o}=t;let n="CELL";this.env.model.dispatch("STOP_EDITION"),this.env.model.getters.getActiveCols().has(i)?n="COL":this.env.model.getters.getActiveRows().has(o)&&(n="ROW");const{x:s,y:r,width:a,height:l}=this.env.model.getters.getVisibleRect(t);this.toggleContextMenu(n,s+a,r+l)}onCellRightClicked(e,t,{x:i,y:o}){const n=this.env.model.getters.getSelectedZones();let s="CELL";Qi(e,t,n[n.length-1])?this.env.model.getters.getActiveCols().has(e)?s="COL":this.env.model.getters.getActiveRows().has(t)&&(s="ROW"):(this.env.model.selection.getBackToDefault(),this.env.model.selection.selectCell(e,t)),this.toggleContextMenu(s,i,o)}toggleContextMenu(e,t,i){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.menuState.isOpen=!0,this.menuState.position={x:t,y:i},this.menuState.menuItems=bp[e].getMenuItems()}copy(e,t){if(!this.gridEl.contains(document.activeElement))return;const i=t.clipboardData;if(!i)return void this.displayWarningCopyPasteNotSupported();if("inactive"!==this.env.model.getters.getEditionMode())return;e?Tr(this.env):this.env.model.dispatch("COPY");const o=this.env.model.getters.getClipboardContent();for(const e in o)i.setData(e,o[e]);t.preventDefault()}paste(e){if(!this.gridEl.contains(document.activeElement))return;const t=e.clipboardData;if(t){if(t.types.indexOf(cn.PlainText)>-1){const e=t.getData(cn.PlainText),i=this.env.model.getters.getSelectedZones();this.env.model.getters.getClipboardTextContent()===e?_r(this.env,i):Fr(this.env,i,e)}}else this.displayWarningCopyPasteNotSupported()}displayWarningCopyPasteNotSupported(){this.env.raiseError(s("Copy/Paste is not supported in this browser."))}closeMenu(){this.menuState.isOpen=!1,this.focus()}}Sp.template="o-spreadsheet-Grid",Sp.components={GridComposer:Yg,GridOverlay:op,GridPopover:np,HeadersOverlay:lp,Menu:Jn,Autofill:Pg,ClientTag:Vg,Highlight:gp,Popover:Xn,VerticalScrollBar:vp,HorizontalScrollBar:fp,FilterIconsOverlay:ep},Sp.props={sidePanelIsOpen:Boolean,exposeFocus:Function,focusComposer:String,onComposerContentFocused:Function,onGridComposerCellFocused:Function};class Cp{constructor(e){this.xmlString=e}toString(){return this.xmlString}}const Ep=["areaChart","area3DChart","lineChart","line3DChart","stockChart","radarChart","scatterChart","pieChart","pie3DChart","doughnutChart","barChart","bar3DChart","ofPieChart","surfaceChart","surface3DChart","bubbleChart"],wp="000000",yp={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},xp={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"},Ip="http://schemas.openxmlformats.org/drawingml/2006/main",Rp="http://schemas.openxmlformats.org/drawingml/2006/chart",Tp={workbook:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",sheet:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+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"},Ap={document:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",sheet:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",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"},Mp="http://schemas.openxmlformats.org/officeDocument/2006/relationships",Op=.75,Np=.1317,_p=8.43,Fp=12.75,Dp=30,kp=100,Lp=164,Pp={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}]},Up=["ACOT","ACOTH","AGGREGATE","ARABIC","BASE","BETA.DIST","BETA.INV","BINOM.DIST","BINOM.DIST.RANGE","BINOM.INV","BITAND","BITLSHIFT","BITOR","BITRSHIFT","BITXOR","CEILING.MATH","CEILING.PRECISE","CHISQ.DIST","CHISQ.DIST.RT","CHISQ.INV","CHISQ.INV.RT","CHISQ.TEST","COMBINA","CONCAT","CONFIDENCE.NORM","CONFIDENCE.T","COT","COTH","COVARIANCE.P","COVARIANCE.S","CSC","CSCH","DAYS","DECIMAL","ERF.PRECISE","ERFC.PRECISE","EXPON.DIST","F.DIST","F.DIST.RT","F.INV","F.INV.RT","F.TEST","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","HYPGEOM.DIST","IFNA","IFS","IMCOSH","IMCOT","IMCSC","IMCSCH","IMSEC","IMSECH","IMSINH","IMTAN","ISFORMULA","ISOWEEKNUM","LOGNORM.DIST","LOGNORM.INV","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","QUARTILE.EXC","QUARTILE.INC","QUERYSTRING","RANK.AVG","RANK.EQ","RRI","SEC","SECH","SHEET","SHEETS","SKEW.P","STDEV.P","STDEV.S","SWITCH","T.DIST","T.DIST.2T","T.DIST.RT","T.INV","T.INV.2T","T.TEST","TEXTJOIN","UNICHAR","UNICODE","VAR.P","VAR.S","WEBSERVICE","WEIBULL.DIST","XOR","Z.TEST"],Vp="[Content_Types].xml";var zp;!function(e){e.DiagonalBorderNotSupported="Diagonal Borders",e.BorderStyleNotSupported="Border style",e.FillStyleNotSupported="Fill Style",e.FontNotSupported="Font",e.HorizontalAlignmentNotSupported="Horizontal Alignment",e.VerticalAlignmentNotSupported="Vertical Alignments",e.MultipleRulesCfNotSupported="Multiple rules conditional formats",e.CfTypeNotSupported="Conditional format type",e.CfFormatBorderNotSupported="Borders in conditional formats",e.CfFormatAlignmentNotSupported="Alignment in conditional formats",e.CfFormatNumFmtNotSupported="Num formats in conditional formats",e.CfIconSetEmptyIconNotSupported="IconSets with empty icons",e.BadlyFormattedHyperlink="Badly formatted hyperlink",e.NumFmtIdNotSupported="Number format"}(zp||(zp={}));class Bp{constructor(){this._parsingWarnings=new Set,this._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,i){let o=`${e} ${t?'"'+t+'" is':"are"} not yet supported. `;i&&(o+=`Only ${i.join(", ")} are currently supported.`),this._conversionWarnings.has(o)||this._conversionWarnings.add(o)}}const Hp=["thin"],$p=["general","left","center","right"],Wp=["Arial"],Gp=["solid"],qp=["expression","cellIs","colorScale","iconSet","containsText","notContainsText","beginsWith","endsWith","containsBlanks","notContainsBlanks"],Zp={b:"boolean",d:"date",e:"error",inlineStr:"inlineStr",n:"number",s:"sharedString",str:"str"},jp={dashDot:"thin",dashDotDot:"thin",dashed:"thin",dotted:"thin",double:"thin",hair:"thin",medium:"thin",mediumDashDot:"thin",mediumDashDotDot:"thin",mediumDashed:"thin",none:void 0,slantDashDot:"thin",thick:"thin",thin:"thin"},Xp={general:void 0,left:"left",center:"center",right:"right",fill:"left",justify:"left",centerContinuous:"center",distributed:"center"};const Yp={aboveAverage:void 0,expression:void 0,cellIs:void 0,colorScale:void 0,dataBar:void 0,iconSet:void 0,top10:void 0,uniqueValues:void 0,duplicateValues:void 0,containsText:"ContainsText",notContainsText:"NotContains",beginsWith:"BeginsWith",endsWith:"EndsWith",containsBlanks:"IsEmpty",notContainsBlanks:"IsNotEmpty",containsErrors:void 0,notContainsErrors:void 0,timePeriod:void 0},Kp={num:"number",percent:"percentage",max:"value",min:"value",percentile:"percentile",formula:"formula"},Qp={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"},Jp={b:"bottom",t:"top",l:"left",r:"right",tr:"right"},em={areaChart:void 0,area3DChart:void 0,lineChart:"line",line3DChart:void 0,stockChart:void 0,radarChart:void 0,scatterChart:void 0,pieChart:"pie",pie3DChart:void 0,doughnutChart:"pie",barChart:"bar",bar3DChart:void 0,ofPieChart:void 0,surfaceChart:void 0,surface3DChart:void 0,bubbleChart:void 0},tm={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"},im={0:"",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:void 0},om={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},nm={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"},sm={"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"};function rm(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=wp;else{if(!e.indexed)return;t=nm[e.indexed]}var i;return t=6===(i=t).length?"#"+i+"FF":"#"+i.slice(2)+i.slice(0,2),e.tint&&(t=function(e,t){const i=Tt(e),o=Mt(i);t<0&&(o.l=o.l*(1+t));t>0&&(o.l=o.l*(1-t)+(100-100*(1-t)));return Rt(At(o))}(t,e.tint)),t=t.toUpperCase(),9===t.length&&t.endsWith("FF")&&(t=t.slice(0,7)),t}function am(e,t){const i=e.split("/"),o=t.split("/");let n="",s=0;for(let e=0;e<i.length-1;e++)i[e]===o[e]?s++:n+="../";return n+=o.slice(s).join("/"),n}function lm(e,t=0){const i={};for(let o=0;o<e.length;o++)e[o]&&(i[o+t]=e[o]);return i}function cm(e){const t=[];for(let i of Object.keys(e).map(Number))t[i]=e[i];return t}function hm(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,((e,t)=>String.fromCharCode(parseInt(t,16))))}const dm=/^(yy|yyyy|m{1,5}|d{1,4}|h{1,2}|s{1,2}|am\/pm|a\/m|\s|-|\/|\.|:)+$/i;function um(e,t,i){var o,n,s;if(0===e)return;let r=im[e]||(null===(o=t.find((t=>t.id===e)))||void 0===o?void 0:o.format);if(r)try{let e=r.replace(/(.*?);.*/,"$1");e=e.replace(/\[(.*)-[A-Z0-9]{3}\]/g,"[$1]"),e=e.replace(/\[\$\]/g,"");const t=(null===(n=e.match(/"/g))||void 0===n?void 0:n.length)||0;if(t/2+((null===(s=e.match(/\[/g))||void 0===s?void 0:s.length)||0)>1)throw new Error("Multiple escaped blocks in format");if(e=e.replace(/"(.*)"/g,"[$$$1]"),e=e.replace(/_.{1}/g,""),e=e.replace(/\*.{1}/g,""),e=e.replace(/\\ /g," "),e=e.replace(/\\./g,(e=>e[1])),function(e){return null!==e.match(dm)}(e)&&(e=function(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}(e)),function(e){try{return mi(0,e),!0}catch(e){return!1}}(e))return e}catch(e){}i.generateNotSupportedWarning(zp.NumFmtIdNotSupported,r||`nmFmtId ${e}`)}function gm(e,t){const i=e.borders.map((e=>{!function(e,t){e.diagonal&&t.generateNotSupportedWarning(zp.DiagonalBorderNotSupported)}(e,t);const i={top:pm(e.top,t),bottom:pm(e.bottom,t),left:pm(e.left,t),right:pm(e.right,t)};return Object.keys(i).forEach((e=>void 0===i[e]&&delete i[e])),i}));return lm(i,1)}function pm(e,t){if(!e)return;!function(e,t){Hp.includes(e.style)||t.generateNotSupportedWarning(zp.BorderStyleNotSupported,e.style,Hp)}(e,t);const i=jp[e.style];return i?[i,rm(e.color)]:void 0}function mm(e,t){return lm(e.styles.map((i=>fm({fontStyle:e.fonts[i.fontId],fillStyle:e.fills[i.fillId],alignment:i.alignment},t))),1)}function fm(e,t){var i,o,n,s,r,a,l,c,h,d,u,g;return function(e,t,i){e&&e.name&&!Wp.includes(e.name)&&i.generateNotSupportedWarning(zp.FontNotSupported,e.name,Wp);t&&t.patternType&&!Gp.includes(t.patternType)&&i.generateNotSupportedWarning(zp.FillStyleNotSupported,t.patternType,Gp)}(null==e?void 0:e.fontStyle,null==e?void 0:e.fillStyle,t),function(e,t){e&&!$p.includes(e)&&t.generateNotSupportedWarning(zp.HorizontalAlignmentNotSupported,e,$p)}(null===(i=null==e?void 0:e.alignment)||void 0===i?void 0:i.horizontal,t),function(e,t){e&&t.generateNotSupportedWarning(zp.VerticalAlignmentNotSupported)}(null===(o=null==e?void 0:e.alignment)||void 0===o?void 0:o.vertical,t),{bold:null===(n=e.fontStyle)||void 0===n?void 0:n.bold,italic:null===(s=e.fontStyle)||void 0===s?void 0:s.italic,strikethrough:null===(r=e.fontStyle)||void 0===r?void 0:r.strike,underline:null===(a=e.fontStyle)||void 0===a?void 0:a.underline,align:(null===(l=e.alignment)||void 0===l?void 0:l.horizontal)?Xp[e.alignment.horizontal]:void 0,fillColor:"solid"===(null===(c=e.fillStyle)||void 0===c?void 0:c.patternType)?rm(null===(h=e.fillStyle)||void 0===h?void 0:h.fgColor):rm(null===(d=e.fillStyle)||void 0===d?void 0:d.bgColor),textColor:rm(null===(u=e.fontStyle)||void 0===u?void 0:u.color),fontSize:null===(g=e.fontStyle)||void 0===g?void 0:g.size}}function vm(e,t){const i=[];for(let o of e.styles){const n=um(o.numFmtId,e.numFmts,t);n&&(i[o.numFmtId]=n)}return lm(i,1)}function bm(e,t,i){const o=[];let n=1;for(let r of e){if(0===r.cfRules.length)continue;wm(r,t,i);const e=r.cfRules[0];let a;const l=[];if(void 0!==e.dxfId||"colorScale"===e.type||"iconSet"===e.type){switch(e.type){case"aboveAverage":case"containsErrors":case"notContainsErrors":case"dataBar":case"duplicateValues":case"expression":case"top10":case"uniqueValues":case"timePeriod":continue;case"colorScale":const t=Sm(n++,r);t&&o.push(t);continue;case"iconSet":const c=Cm(n++,r,i);c&&o.push(c);continue;case"containsText":case"notContainsText":case"beginsWith":case"endsWith":if(!e.text)continue;a=Yp[e.type],l.push(e.text);break;case"containsBlanks":case"notContainsBlanks":a=Yp[e.type];break;case"cellIs":if(!e.operator||!e.formula||0===e.formula.length)continue;a=(s=e.operator).slice(0,1).toUpperCase()+s.slice(1),l.push(e.formula[0]),2===e.formula.length&&l.push(e.formula[1])}a&&void 0!==e.dxfId&&o.push({id:(n++).toString(),ranges:r.sqref,stopIfTrue:e.stopIfTrue,rule:{type:"CellIsRule",operator:a,values:l,style:fm({fontStyle:t[e.dxfId].font,fillStyle:t[e.dxfId].fill},i)}})}}var s;return o}function Sm(e,t){const i=t.cfRules[0].colorScale;if(!i||i.cfvos.length!==i.colors.length||i.cfvos.length<2||i.cfvos.length>3)return;const o=[];for(let e=0;e<i.cfvos.length;e++)o.push({color:(n=rm(i.colors[e])||"#FFFFFF",9===n.length&&(n=n.slice(0,7)),parseInt(n.replace("#",""),16)),type:Kp[i.cfvos[e].type],value:i.cfvos[e].value});var n;const s=o[0],r=2===o.length?o[1]:o[2],a=3===o.length?o[1]:void 0;return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"ColorScaleRule",minimum:s,midpoint:a,maximum:r}}}function Cm(e,t,i){const o=t.cfRules[0].iconSet;if(!o)return;let n=o.cfvos,s=o.cfIcons;if(n.length<3||s&&s.length<3)return;n.length>3&&(n=[n[0],n[Math.floor(n.length/2)],n[n.length-1]]),s&&s.length>3&&(s=[s[0],s[Math.floor(s.length/2)],s[s.length-1]]);const r=[];for(let e=1;e<=2;e++){const t=Kp[n[e].type];if("value"===t)return;r.push({value:n[e].value||"",operator:n[e].gte?"ge":"gt",type:t})}let a={lower:s?Em(s[0].iconSet,s[0].iconId):Em(o.iconSet,0),middle:s?Em(s[1].iconSet,s[1].iconId):Em(o.iconSet,1),upper:s?Em(s[2].iconSet,s[2].iconId):Em(o.iconSet,2)};o.reverse&&(a={upper:a.lower,middle:a.middle,lower:a.upper});for(let e of Object.keys(a))if(!a[e])switch(i.generateNotSupportedWarning(zp.CfIconSetEmptyIconNotSupported),e){case"upper":a[e]=Tg.dots.good;break;case"middle":a[e]=Tg.dots.neutral;break;case"lower":a[e]=Tg.dots.bad}return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"IconSetRule",icons:a,upperInflectionPoint:r[1],lowerInflectionPoint:r[0]}}}function Em(e,t){const i=Qp[e];return i?0===t?Tg[i].bad:1===t?Tg[i].neutral:Tg[i].good:""}function wm(e,t,i){if(e.cfRules.length>1&&i.generateNotSupportedWarning(zp.MultipleRulesCfNotSupported),qp.includes(e.cfRules[0].type)||i.generateNotSupportedWarning(zp.CfTypeNotSupported,e.cfRules[0].type),e.cfRules[0].dxfId){const o=t[e.cfRules[0].dxfId];o.border&&i.generateNotSupportedWarning(zp.CfFormatBorderNotSupported),o.alignment&&i.generateNotSupportedWarning(zp.CfFormatAlignmentNotSupported),o.numFmt&&i.generateNotSupportedWarning(zp.CfFormatNumFmtNotSupported)}}class ym{constructor(e=new Im){this.scope=e,this.code=""}append(...e){this.code+=e.map((e=>e.toString())).join("\n")+"\n"}return(e){return new xm(this.scope,this.code,e)}toString(){return Rm(this.code)}}class xm{constructor(e,t,i){this.scope=e,this.returnExpression=i,this.code=Rm(t)}toString(){return this.code}wrapInClosure(){const e=this.scope.nextVariableName(),t=new ym(this.scope);return t.append(`const ${e} = () => {`),t.append(this.code),t.append(`return ${this.returnExpression};`),t.append("}"),t.return(e)}assignResultToVariable(){if(this.scope.isAlreadyDeclared(this.returnExpression))return this;const e=this.scope.nextVariableName(),t=new ym(this.scope);return t.append(this.code),t.append(`const ${e} = ${this.returnExpression};`),t.return(e)}}class Im{constructor(){this.nextId=1,this.declaredVariables=new Set}nextVariableName(){const e="_"+this.nextId++;return this.declaredVariables.add(e),e}isAlreadyDeclared(e){return this.declaredVariables.has(e)}}function Rm(e){let t="",i=0;const o=e.split("\n").map((e=>e.trim())).filter((e=>""!==e));for(const e of o)e.startsWith("}")&&i--,t+="\t".repeat(i)+e+"\n",e.endsWith("{")&&i++;return t.trim()}const Tm=Ju.content,Am=["%"],Mm="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(Am);function Om(e){const t=(e=ft(e)).split(""),i=[];for(;t.length;){let e=zm(t)||Fm(t)||km(t)||Pm(t)||Nm(t)||Bm(t)||Lm(t)||Vm(t);e||(e={type:"UNKNOWN",value:t.shift()}),i.push(e)}return i}function Nm(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const _m={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function Fm(e){if(e[0]in _m){const t=e.shift();return{type:_m[t],value:t}}return null}function Dm(e,t){for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function km(e){for(let t of Mm)if(Dm(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function Lm(e){const t=st(e).match(Kt);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function Pm(e){if('"'===e[0]){const t=e.shift();let i=t;for(;e[0]&&(e[0]!==t||"\\"===i[i.length-1]);)i+=e.shift();return'"'===e[0]&&(i+=e.shift()),{type:"STRING",value:i}}return null}const Um=/\w|\.|!|\$/;function Vm(e){let t="";if("'"===e[0]){let i=e.shift();for(t+=i;e[0];)if(i=e.shift(),t+=i,"'"===i){if(!e[0]||"'"!==e[0])break;i=e.shift(),t+=i}if("'"!==i)return{type:"UNKNOWN",value:t}}for(;e[0]&&e[0].match(Um);)t+=e.shift();if(t.length){const e=t;if(e.toUpperCase()in Tm)return{type:"FUNCTION",value:e};return e.match(Lt)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}function zm(e){let t=0;for(;e[0]===he;)t++,e.shift();if(t)return{type:"SPACE",value:he.repeat(t)};for(;" "===e[0];)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function Bm(e){return Dm(e,K)?(e.splice(0,K.length),{type:"INVALID_REFERENCE",value:K}):null}const Hm=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,$m=["-","+"],Wm=["%"],Gm=["*","+","&"],qm={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10};function Zm(e){var t,i,o;const n=e.shift();if(!n)throw new h(le);switch(n.type){case"DEBUGGER":const r=Ym(e,1e3);return r.debug=!0,r;case"NUMBER":return{type:"NUMBER",value:si(n.value)};case"STRING":return{type:"STRING",value:Oe(n.value)};case"FUNCTION":const a=function(e){var t;Xm(e,"LEFT_PAREN",s("Missing opening parenthesis"));const i=e[0];if("RIGHT_PAREN"===(null==i?void 0:i.type))return Xm(e,"RIGHT_PAREN"),[];const o=[];o.push(jm(e));for(;"RIGHT_PAREN"!==(null===(t=e[0])||void 0===t?void 0:t.type);)Xm(e,"COMMA",s("Wrong function call")),o.push(jm(e));return Xm(e,"RIGHT_PAREN"),o}(e);return{type:"FUNCALL",value:n.value,args:a};case"INVALID_REFERENCE":throw new u;case"REFERENCE":if(":"===(null===(t=e[0])||void 0===t?void 0:t.value)&&"REFERENCE"===(null===(i=e[1])||void 0===i?void 0:i.type)){e.shift();const t=e.shift();return{type:"REFERENCE",value:`${n.value}:${null==t?void 0:t.value}`}}return{type:"REFERENCE",value:n.value};case"SYMBOL":if(["TRUE","FALSE"].includes(n.value.toUpperCase()))return{type:"BOOLEAN",value:"TRUE"===n.value.toUpperCase()};if(n.value&&Hm.test(n.value)&&"LEFT_PAREN"===(null===(o=e[0])||void 0===o?void 0:o.type))throw new p(n.value);throw new h(s("Invalid formula"));case"LEFT_PAREN":const l=Ym(e);return Xm(e,"RIGHT_PAREN",s("Missing closing parenthesis")),l;case"OPERATOR":const c=n.value;if($m.includes(c))return{type:"UNARY_OPERATION",value:c,operand:Ym(e,qm[c])};throw new h(s("Unexpected token: %s",n.value));default:throw new h(s("Unexpected token: %s",n.value))}}function jm(e){const t=e[0];return"COMMA"===(null==t?void 0:t.type)||"RIGHT_PAREN"===(null==t?void 0:t.type)?{type:"EMPTY",value:""}:Ym(e)}function Xm(e,t,i=le){const o=e.shift();if(!o||o.type!==t)throw new h(i)}function Ym(e,t=0){var i;if(0===e.length)throw new h(le);let o=Zm(e);for(;"OPERATOR"===(null===(i=e[0])||void 0===i?void 0:i.type)&&qm[e[0].value]>t;){const t=e.shift().value;if(Wm.includes(t))o={type:"UNARY_OPERATION",value:t,operand:o,postfix:!0};else{o={type:"BIN_OPERATION",value:t,left:o,right:Ym(e,qm[t])}}}return o}function Km(e){return Qm(Om(e))}function Qm(e){"="===(e=e.filter((e=>"SPACE"!==e.type)))[0].value&&e.splice(0,1);const t=Ym(e);if(e.length)throw new h(le);return t}function Jm(e,t,i){switch(t===e.type&&(e=i(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>Jm(e,t,i)))};case"UNARY_OPERATION":return{...e,operand:Jm(e.operand,t,i)};case"BIN_OPERATION":return{...e,right:Jm(e.right,t,i),left:Jm(e.left,t,i)};default:return e}}function ef(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>ef(e)));return`${e.value}(${t.join(",")})`;case"NUMBER":return e.value.toString();case"REFERENCE":default:return e.value;case"STRING":return`"${e.value}"`;case"BOOLEAN":return e.value?"TRUE":"FALSE";case"UNARY_OPERATION":return e.postfix?tf(e)+e.value:e.value+of(e);case"BIN_OPERATION":return tf(e)+e.value+of(e)}}function tf(e){const t=e.value,i="left"in e?e.left:e.operand,o=i.value;return"BIN_OPERATION"===i.type&&qm[o]<qm[t]?`(${ef(i)})`:ef(i)}function of(e){const t=e.value,i="right"in e?e.right:e.operand,o=qm[i.value],n=qm[t];let s=!1;return"BIN_OPERATION"!==i.type?s=!1:o<n?s=!0:o!==n||Gm.includes(t)||(s=!0),s?`(${ef(i)})`:ef(i)}var nf;!function(e){e[e.LeftRef=0]="LeftRef",e[e.RightRef=1]="RightRef",e[e.Separator=2]="Separator",e[e.FullColumnSeparator=3]="FullColumnSeparator",e[e.FullRowSeparator=4]="FullRowSeparator",e[e.RightColumnRef=5]="RightColumnRef",e[e.RightRowRef=6]="RightRowRef",e[e.Found=7]="Found"}(nf||(nf={}));const sf=(e,t=(()=>!0))=>[{goTo:e,guard:t}],rf=(e,t=(()=>!0))=>({goTo:e,guard:t}),af={[nf.LeftRef]:{REFERENCE:sf(nf.Separator),NUMBER:sf(nf.FullRowSeparator),SYMBOL:[rf(nf.FullColumnSeparator,(e=>Pt(e.value))),rf(nf.FullRowSeparator,(e=>Ut(e.value)))]},[nf.FullColumnSeparator]:{SPACE:sf(nf.FullColumnSeparator),OPERATOR:sf(nf.RightColumnRef,(e=>":"===e.value))},[nf.FullRowSeparator]:{SPACE:sf(nf.FullRowSeparator),OPERATOR:sf(nf.RightRowRef,(e=>":"===e.value))},[nf.Separator]:{SPACE:sf(nf.Separator),OPERATOR:sf(nf.RightRef,(e=>":"===e.value))},[nf.RightRef]:{SPACE:sf(nf.RightRef),NUMBER:sf(nf.Found),REFERENCE:sf(nf.Found,(e=>Bt(e.value))),SYMBOL:sf(nf.Found,(e=>Vt(e.value)||zt(e.value)))},[nf.RightColumnRef]:{SPACE:sf(nf.RightColumnRef),SYMBOL:sf(nf.Found,(e=>Vt(e.value))),REFERENCE:sf(nf.Found,(e=>Bt(e.value)))},[nf.RightRowRef]:{SPACE:sf(nf.RightRowRef),NUMBER:sf(nf.Found),REFERENCE:sf(nf.Found,(e=>Bt(e.value))),SYMBOL:sf(nf.Found,(e=>zt(e.value)))},[nf.Found]:{}};function lf(e){var t;let i=0,o=af[nf.LeftRef];const n=[];for(;void 0!==o;){const s=e[i++];if(!s)return null;const r=null===(t=o[s.type])||void 0===t?void 0:t.find((e=>e.guard(s))),a=r?r.goTo:void 0;switch(a){case void 0:return null;case nf.Found:return n.push(s),e.splice(0,i),{type:"REFERENCE",value:st(n.map((e=>e.value)))};default:o=af[a],n.push(s)}}return null}function cf(e){const t=Om(e),i=[];for(;t.length;)i.push(lf(t)||t.shift());return i}const hf=Ju.content,df={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},uf={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"},gf={};function pf(e){const t=cf(e),{dependencies:i,constantValues:o}=function(e){const t={numbers:[],strings:[]},i=[];for(const o of e)switch(o.type){case"INVALID_REFERENCE":case"REFERENCE":i.push(o.value);break;case"STRING":const e=Oe(o.value);t.strings.includes(e)||t.strings.push(e);break;case"NUMBER":{const e=si(o.value);t.numbers.includes(e)||t.numbers.push(e);break}}return{dependencies:i,constantValues:t}}(t),n=function(e,t,i){return st(e.map((e=>{switch(e.type){case"STRING":const o=Oe(e.value);return`|S${i.strings.indexOf(o)}|`;case"NUMBER":return`|N${i.numbers.indexOf(si(e.value))}|`;case"REFERENCE":case"INVALID_REFERENCE":return`|${t.indexOf(e.value)}|`;case"SPACE":return"";default:return e.value}})))}(t,i,o);if(!gf[n]){const r=Qm([...t]),a=new Im;if("BIN_OPERATION"===r.type&&":"===r.value)throw new h(s("Invalid formula"));if("EMPTY"===r.type)throw new h(s("Invalid formula"));const l=g(r),c=new ym;c.append(`// ${n}`),c.append(l),c.append(`return ${l.returnExpression};`);let d=new Function("deps","ref","range","ctx",c.toString());function u(e){const t=hf[e.value.toUpperCase()],i=e.args,o=i.length;if(o<t.minArgRequired)throw new h(s("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",e.value.toUpperCase(),t.minArgRequired.toString(),o.toString()));if(o>t.maxArgPossible)throw new h(s("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",e.value.toUpperCase(),t.maxArgPossible.toString(),o.toString()));const n=t.nbrArgRepeating;if(n>1){const i=t.args.length-n;if((o-i)%n!=0)throw new h(s("Invalid number of arguments for the %s function. Expected all arguments after position %s to be supplied by groups of %s arguments",e.value.toUpperCase(),i.toString(),n.toString()))}let r=[];for(let n=0;n<o;n++){const o=t.getArgToFocus(n+1)-1;if(0<=o&&o<t.args.length){const a=i[n],l=t.args[o],c=l.type||[],d=c.includes("META"),u=l.lazy,p=c.some((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e)),m=c.every((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e));if(m&&"REFERENCE"!==a.type)throw new h(s("Function %s expects the parameter %s to be reference to a cell or range, not a %s.",e.value.toUpperCase(),(n+1).toString(),a.type.toLowerCase()));const f=g(a,d,p,{functionName:e.value.toUpperCase(),paramIndex:n+1});r.push(u?f.wrapInClosure():f)}}return r}function g(e,t=!1,n=!1,r={}){const l=new ym(a);if("REFERENCE"!==e.type&&("BIN_OPERATION"!==e.type||":"!==e.value)&&t)throw new h(s("Argument must be a reference to a cell or range."));switch(e.debug&&l.append("debugger;"),e.type){case"BOOLEAN":return l.return(`{ value: ${e.value} }`);case"NUMBER":return l.return(`{ value: this.constantValues.numbers[${o.numbers.indexOf(e.value)}] }`);case"STRING":return l.return(`{ value: this.constantValues.strings[${o.strings.indexOf(e.value)}] }`);case"REFERENCE":const s=i.indexOf(e.value);return n?l.return(`range(deps[${s}])`):l.return(`ref(deps[${s}], ${t?"true":"false"}, "${r.functionName||df["="]}", ${r.paramIndex})`);case"FUNCALL":const a=u(e).map((e=>e.assignResultToVariable()));l.append(...a);const c=e.value.toUpperCase();return l.append(`ctx.__lastFnCalled = '${c}';`),l.return(`ctx['${c}'](${a.map((e=>e.returnExpression))})`);case"UNARY_OPERATION":{const t=uf[e.value],i=g(e.operand,!1,!1,{functionName:t}).assignResultToVariable();return l.append(i),l.append(`ctx.__lastFnCalled = '${t}';`),l.return(`ctx['${t}'](${i.returnExpression})`)}case"BIN_OPERATION":{const t=df[e.value],i=g(e.left,!1,!1,{functionName:t}).assignResultToVariable(),o=g(e.right,!1,!1,{functionName:t}).assignResultToVariable();return l.append(i),l.append(o),l.append(`ctx.__lastFnCalled = '${t}';`),l.return(`ctx['${t}'](${i.returnExpression}, ${o.returnExpression})`)}case"EMPTY":return l.return("undefined")}}gf[n]={execute:d}}return{execute:gf[n].execute,dependencies:i,constantValues:o,tokens:t}}function mf(e){return function(e){let t=[],i="";return e.map(((e,o)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(i=""),e.type){case"FUNCTION":i=e.value;break;case"LEFT_PAREN":t.push({parent:i,argPosition:0}),i="";break;case"RIGHT_PAREN":t.pop();break;case"COMMA":t.length&&t[t.length-1].argPosition++}if(t.length){const i=t[t.length-1];i.parent&&(e.functionContext=Object.assign({},i))}return e}))}(function(e){let t=1;const i=[];return e.map((e=>("LEFT_PAREN"===e.type?(i.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=i.pop()),e)))}(function(e){let t=0;return e.map((e=>{const i=e.value.toString().length,o=Object.assign({},e,{start:t,end:t+i,length:i});return t=o.end,o}))}(cf(e))))}function ff(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function vf(e){return Math.round(Op*e*100)/100}function bf(e){return Math.round(Np*e*100)/100}function Sf(e){if(e)return{style:e[0],color:{rgb:e[1]}}}function Cf(e,t){let i={};e.style&&(i=t.styles[e.style]);const o=function(e,t){if(e.format)return t.formats[e.format];if(e.isFormula){const t=Om(e.content||""),i=Ju.content;if(!t.filter((e=>"FUNCTION"===e.type)).every((e=>i[e.value.toUpperCase()].isExported)))return e.computedFormat}return}(e,t),n={};if(e.border){const i=t.borders[e.border];n.left=Sf(i.left),n.right=Sf(i.right),n.bottom=Sf(i.bottom),n.top=Sf(i.top)}const s={font:{size:(null==i?void 0:i.fontSize)||q,color:{rgb:(null==i?void 0:i.textColor)?i.textColor:"000000"},family:2,name:"Arial"},fill:(null==i?void 0:i.fillColor)?{fgColor:{rgb:i.fillColor}}:{reservedAttribute:"none"},numFmt:o?{format:o,id:0}:void 0,border:n||{},alignment:{vertical:"center",horizontal:i.align}};return s.font.strike=!!(null==i?void 0:i.strikethrough)||void 0,s.font.underline=!!(null==i?void 0:i.underline)||void 0,s.font.bold=!!(null==i?void 0:i.bold)||void 0,s.font.italic=!!(null==i?void 0:i.italic)||void 0,s}function Ef(e,t){const{id:i}=yf(t.font,e.fonts),{id:o}=yf(t.fill,e.fills),{id:n}=yf(t.border,e.borders),s=function(e,t){if(!e)return 0;let i=om[e.format];if(!i){const{id:o}=yf(e,t);i=o+Lp}return i}(t.numFmt,e.numFmts),r={fontId:i,fillId:o,borderId:n,numFmtId:s,alignment:{vertical:t.alignment.vertical,horizontal:t.alignment.horizontal}},{id:a}=yf(r,e.styles);return a}function wf(e,t,i){let o,n=e.find((e=>e.path===t));return n?(o=`rId${(n.rels.length+1).toString()}`,n.rels.push({...i,id:o})):(o="rId1",e.push({path:t,rels:[{...i,id:o}]})),o}function yf(e,t){for(let[i,o]of Object.entries(t))if(JSON.stringify(o)===JSON.stringify(e))return{id:parseInt(i,10),list:t};let i=t.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)));return-1===i&&(t.push(e),i=t.length-1),{id:i,list:t}}const xf=[];function If(e){const t=xf.findIndex((t=>t===e));return-1===t?(xf.push(e),xf.length):t+1}const Rf=[];function Tf(e){const t=Rf.findIndex((t=>t===e));return-1===t?(Rf.push(e),Rf.length):t+1}function Af(e){return Math.round(914400*e/96)}function Mf(e,t,i){let o,n,s=e;if(({xc:s,sheetName:o}=Ht(e)),o){const e=i.sheets.findIndex((e=>e.name===o));if(e<0)throw new Error("Unable to find a sheet with the name "+o);n=e}else n=Number(t);const r=zi(s);return void 0===r.right&&(r.right=i.sheets[n].colNumber),void 0===r.bottom&&(r.bottom=i.sheets[n].rowNumber),(r.right-r.left+1)*(r.bottom-r.top+1)}function Of(e){return Math.round(96*e/914400)}function Nf(e,t){var i;let o=0;for(let n=0;n<e;n++){const e=t.cols.find((e=>n>=e.min&&n<=e.max));(null==e?void 0:e.width)?o+=e.width:(null===(i=t.sheetFormat)||void 0===i?void 0:i.defaultColWidth)?o+=t.sheetFormat.defaultColWidth:o+=_p}return o/Np}function _f(e,t){var i;let o=0;for(let n=0;n<e;n++){const e=t.rows[n];(null==e?void 0:e.height)?o+=e.height:(null===(i=t.sheetFormat)||void 0===i?void 0:i.defaultRowHeight)?o+=t.sheetFormat.defaultRowHeight:o+=Fp}return o/Op}function Ff(e){let t=1;return e.figures.map((i=>function(e,t,i){const o=Nf(e.anchors[0].col,i)+Of(e.anchors[0].colOffset),n=Nf(e.anchors[1].col,i)+Of(e.anchors[1].colOffset),s=_f(e.anchors[0].row,i)+Of(e.anchors[0].rowOffset),r=_f(e.anchors[1].row,i)+Of(e.anchors[1].rowOffset),a=n-o,l=r-s,c=Df(e.data);return c?{id:t,x:o,y:s,width:a,height:l,tag:"chart",data:Df(e.data)}:void 0}(i,(t++).toString(),e))).filter(it)}function Df(e){var t;const i=null===(t=e.dataSets[0].label)||void 0===t?void 0:t.replace(/\$/g,"");let o=e.dataSets.map((e=>e.range.replace(/\$/g,"")));return"pie"===e.type&&o.reverse(),{dataSets:o,dataSetsHaveTitle:!1,labelRange:i,title:e.title||"",type:e.type,background:rm({rgb:e.backgroundColor})||"#FFFFFF",verticalAxisPosition:e.verticalAxisPosition,legendPosition:e.legendPosition,stacked:e.stacked||!1,aggregated:!1,cumulative:e.cumulative||!1,labelsAsText:!1}}const kf=new RegExp(/'?\[([0-9]*)\](.*)'?!(\$?[a-zA-Z]*\$?[0-9]*)/g),Lf=new RegExp(/SUBTOTAL\(([0-9]*),/g),Pf=new RegExp(Ot.source,"ig");function Uf(e,t){const i=function(e){const t={};for(let i of e.rows)for(let e of i.cells)e.formula&&void 0!==e.formula.sharedIndex&&e.formula.content&&(t[e.formula.sharedIndex]={refCellXc:e.xc,formula:e.formula.content});return t}(e);for(let o of e.rows.map((e=>e.cells)).flat())(null==o?void 0:o.formula)&&(o.formula.content=void 0===o.formula.sharedIndex||o.formula.content?"="+o.formula.content:"="+zf(o.xc,i[o.formula.sharedIndex]),o.formula.content=Vf(o.formula.content,t))}function Vf(e,t){return e=(e=(e=(e=e.replace("_xlfn.","")).replace(/#REF!/g,"#REF")).replace(Lf,((e,t)=>{const i=tm[t];return i?i+"(":e}))).replace(kf,((e,i,o,n)=>{var s;i=Number(i)-1,n=n.replace(/\$/g,"");const r=t.externalBooks[i].sheetNames.findIndex((e=>e===o));if(-1===r)return e;const a=null===(s=t.externalBooks[i].datasets.find((e=>e.sheetId===r)))||void 0===s?void 0:s.data;if(!a)return e;const l=a&&a[n];return(Number(l)?l:`"${l}"`)||e}))}function zf(e,t){const i=Gt(t.refCellXc);let o,n=t.formula.slice();do{if(o=Pf.exec(n),o){const t=Gt(o[0].replace("$","")),s=Gt(e),r={colFixed:o[0].startsWith("$"),rowFixed:o[0].includes("$",1)},a={col:s.col-i.col,row:s.row-i.row},l={col:r.colFixed?t.col:t.col+a.col,row:r.rowFixed?t.row:t.row+a.row};n=n.slice(0,o.index)+qt(l.col,l.row,r)+n.slice(o.index+o[0].length)}}while(o);return n}function Bf(e,t){return e.sheets.map((i=>{Uf(i,e);const o=function(e){const t=[0,0];for(let i of e.rows)t[0]=Math.max(t[0],...i.cells.map((e=>Gt(e.xc).col))),t[1]=Math.max(t[1],i.index);return t[0]=Math.max(t[0],Dp),t[1]=Math.max(t[1],kp),t}(i),n=i.sheetViews[0];return{id:i.sheetName,areGridLinesVisible:!n||n.showGridLines,name:i.sheetName,colNumber:o[0],rowNumber:o[1],cells:Wf(i,e,o,t),merges:i.merges,cols:Hf(i,o[0]),rows:$f(i,o[1]),conditionalFormats:bm(i.cfs,e.dxfs,t),figures:Ff(i),isVisible:i.isVisible,panes:n?{xSplit:n.pane.xSplit,ySplit:n.pane.ySplit}:{xSplit:0,ySplit:0},filterTables:[]}}))}function Hf(e,t){var i;const o={};for(let s=1;s<t+1;s++){const t=e.cols.find((e=>e.min<=s&&s<=e.max));let r;r=t&&t.width?t.width:(null===(i=e.sheetFormat)||void 0===i?void 0:i.defaultColWidth)?e.sheetFormat.defaultColWidth:_p,o[s-1]={size:(n=r,n?Math.round(n/Np*100)/100:n),isHidden:null==t?void 0:t.hidden}}var n;return o}function $f(e,t){var i;const o={};for(let s=1;s<t+1;s++){const t=e.rows.find((e=>e.index===s));let r;r=t&&t.height?t.height:(null===(i=e.sheetFormat)||void 0===i?void 0:i.defaultRowHeight)?e.sheetFormat.defaultRowHeight:Fp,o[s-1]={size:(n=r,n?Math.round(n/Op*100)/100:n),isHidden:null==t?void 0:t.hidden}}var n;return o}function Wf(e,t,i,o){const n={},s=t.sharedStrings.map((e=>e.replace(/\n/g,"")));const r=e.hyperlinks.reduce(((e,t)=>(e[t.xc]=t,e)),{});for(let i of e.rows)for(let e of i.cells)n[e.xc]={content:Gf(e,r,s,o),style:e.styleIndex?e.styleIndex+1:void 0,border:e.styleIndex?t.styles[e.styleIndex].borderId+1:void 0,format:e.styleIndex?t.styles[e.styleIndex].numFmtId+1:void 0};for(let o of e.rows.filter((e=>e.styleIndex)))for(let e=1;e<=i[0];e++){const i=qt(e-1,o.index-1);let s=n[i];s||(s={},n[i]=s),s.style=s.style?s.style:o.styleIndex+1,s.border=s.border?s.border:t.styles[o.styleIndex].borderId+1,s.format=s.format?s.format:t.styles[o.styleIndex].numFmtId+1}for(let o of e.cols.filter((e=>e.styleIndex)))for(let e=o.min;e<=Math.min(o.max,i[0]);e++)for(let s=1;s<=i[1];s++){const i=qt(e-1,s-1);let r=n[i];r||(r={},n[i]=r),r.style=r.style?r.style:o.styleIndex+1,r.border=r.border?r.border:t.styles[o.styleIndex].borderId+1,r.format=r.format?r.format:t.styles[o.styleIndex].numFmtId+1}return n}function Gf(e,t,i,o){let n;switch(e.type){case"sharedString":n=i[parseInt(e.value,10)];break;case"boolean":n=Number(e.value)?"TRUE":"FALSE";break;case"date":case"error":case"inlineStr":case"number":case"str":n=e.value}return n&&t[e.xc]&&(n=function(e,t,i){const o=e.display||t;e.relTarget||e.location||i.generateNotSupportedWarning(zp.BadlyFormattedHyperlink);const n=e.relTarget?e.relTarget:et(Ht(e.location).sheetName);return Ye(o,n)}(t[e.xc],n,o)),e.formula&&(n=e.formula.content),n}const qf={fillColor:"#000000",textColor:"#ffffff",bold:!0},Zf={bold:!0},jf=["thin","#000000FF"];function Xf(e,t){for(const i of t.sheets)for(const t of i.tables){const o=e.sheets.find((e=>e.name===i.sheetName));o&&t.autoFilter&&(o.filterTables||(o.filterTables=[]),o.filterTables.push({range:t.ref}))}!function(e,t){var i,o,n,s;const r=cm(e.styles),a=cm(e.borders);for(let l of t.sheets)for(let t of l.tables){const c=e.sheets.find((e=>e.name===l.sheetName));if(!c)continue;const h=Bi(t.ref);for(let e=0;e<t.headerRowCount;e++)Yf(qf,{...h,bottom:h.top+e},c.cells,r);for(let e=0;e<t.totalsRowCount;e++)Yf(Zf,{...h,top:h.bottom-e},c.cells,r);(null===(i=t.style)||void 0===i?void 0:i.showFirstColumn)&&Yf(Zf,{...h,right:h.left},c.cells,r),(null===(o=t.style)||void 0===o?void 0:o.showLastColumn)&&Yf(Zf,{...h,left:h.right},c.cells,r);for(let e=h.left;e<=h.right;e++)for(let i=h.top;i<=h.bottom;i++){const o=qt(e,i),r=c.cells[o],l={left:e===h.left||(null===(n=t.style)||void 0===n?void 0:n.showColumnStripes)?jf:void 0,right:e===h.right?jf:void 0,top:i===h.top||(null===(s=t.style)||void 0===s?void 0:s.showRowStripes)||i>h.bottom-t.totalsRowCount?jf:void 0,bottom:i===h.bottom?jf:void 0},d=(null==r?void 0:r.border)?{...a[r.border],...l}:l;let u=a.findIndex((e=>ct(e,d)));-1===u&&(u=a.length,a.push(d)),r?r.border=u:c.cells[o]={border:u}}}e.styles=lm(r),e.borders=lm(a)}(e,t),function(e,t){for(let i of e){const e=t.find((e=>e.sheetName===i.name)).tables;for(let t of e){const e=t.name+"[";for(let o of no(Bi(t.ref))){const n=qt(o.col,o.row),s=i.cells[n];if(s&&s.content&&s.content.startsWith("=")){let i;for(;-1!==(i=s.content.indexOf(e));){let o=s.content.slice(i+e.length),r=o.indexOf("]");o.startsWith("[")&&(r=o.indexOf("]",r+1),r=o.indexOf("]",r+1)),o=o.slice(0,r);const a=Kf(o,t,n);s.content=s.content.slice(0,i)+a+s.content.slice(e.length+i+r+1)}}}}}}(e.sheets,t.sheets)}function Yf(e,t,i,o){for(let n=t.left;n<=t.right;n++)for(let s=t.top;s<=t.bottom;s++){const t=qt(n,s),r=i[t],a=(null==r?void 0:r.style)?{...o[r.style],...e}:e;let l=o.findIndex((e=>ct(e,a)));-1===l&&(l=o.length,o.push(a)),r?r.style=l:i[t]={style:l}}}function Kf(e,t,i){const o=e.split(","),n=Bi(t.ref),s={...n};let r=!0;if(1===o.length){const e=t.cols.findIndex((e=>e.name===o[0]));s.left=s.right=e+n.left,t.headerRowCount&&(s.top+=t.headerRowCount),t.totalsRowCount&&(s.bottom-=1)}else{switch(o[0].slice(1,o[0].length-1)){case"#All":s.top=t.headerRowCount?n.top+t.headerRowCount:n.top,s.bottom=n.bottom;break;case"#Data":s.top=t.headerRowCount?n.top+t.headerRowCount:n.top,s.bottom=t.totalsRowCount?n.bottom+1:n.bottom;break;case"#This Row":s.top=s.bottom=Gt(i).row;break;case"#Headers":s.top=s.bottom=n.top,t.headerRowCount||(r=!1);break;case"#Totals":s.top=s.bottom=n.bottom,t.totalsRowCount||(r=!1)}const e=o[1].slice(1,o[1].length-1),a=t.cols.findIndex((t=>t.name===e));s.left=s.right=a+n.left}return r?s.top!==s.bottom?$i(s):qt(s.left,s.top):K}function Qf(e,t,i){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:i}}function Jf(e){return String(e).replace(/\&/g,"&").replace(/\</g,"<").replace(/\>/g,">").replace(/\"/g,""").replace(/\'/g,"'").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function ev(e){return new Cp(e.map((([e,t])=>`${e}="${Jf(t)}"`)).join(" "))}function tv(e,t="text/xml"){const i=(new DOMParser).parseFromString(e.toString(),t),o=i.querySelector("parsererror");if(o){const t=o.innerHTML,i=parseInt(t.split(":")[0],10),n=e.toString().trim().split("\n"),s=n.slice(Math.max(i-3,0),Math.min(i+2,n.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${s}`)}return i}function iv(e,t){return nv`
|
|
1398
|
+
/>`,Sp.defaultProps={topOffset:0},Sp.props={topOffset:{type:Number,optional:!0}};const Cp={ROW:pa,COL:ga,CELL:ua};class Ep extends t.Component{constructor(){super(...arguments),this.HEADER_HEIGHT=N,this.HEADER_WIDTH=_,this.keyDownMapping={ENTER:()=>{this.env.model.getters.getActiveCell().type===ln.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},TAB:()=>this.env.model.selection.moveAnchorCell("right",1),"SHIFT+TAB":()=>this.env.model.selection.moveAnchorCell("left",1),F2:()=>{this.env.model.getters.getActiveCell().type===ln.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()},DELETE:()=>{this.env.model.dispatch("DELETE_CONTENT",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},BACKSPACE:()=>{this.env.model.dispatch("DELETE_CONTENT",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})},ESCAPE:()=>{this.env.model.getters.hasOpenedPopover()?this.closeOpenedPopover():this.menuState.isOpen?this.closeMenu():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"),"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}}),"ALT+=":()=>{var e;const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getSelectedZone(),{anchor:o}=this.env.model.getters.getSelection(),n=this.env.model.getters.getAutomaticSums(t,i,o.cell);if(this.env.model.getters.isSingleCellOrMerge(t,i)||this.env.model.getters.isEmpty(t,i)&&n.length<=1){const i=(null===(e=n[0])||void 0===e?void 0:e.zone)?this.env.model.getters.zoneToXC(t,n[0].zone):"",o=`=SUM(${i})`;this.props.onGridComposerCellFocused(o,{start:5,end:5+i.length})}else this.env.model.dispatch("SUM_SELECTION")},"CTRL+HOME":()=>{const e=this.env.model.getters.getActiveSheetId(),{col:t,row:i}=this.env.model.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0});this.env.model.selection.selectCell(t,i)},"CTRL+END":()=>{const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.findVisibleHeader(e,"COL",this.env.model.getters.getNumberCols(e)-1,0),i=this.env.model.getters.findVisibleHeader(e,"ROW",this.env.model.getters.getNumberRows(e)-1,0);this.env.model.selection.selectCell(t,i)},"SHIFT+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),left:0,right:this.env.model.getters.getNumberCols(e)-1},i=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:i,zone:t})},"CTRL+ ":()=>{const e=this.env.model.getters.getActiveSheetId(),t={...this.env.model.getters.getSelectedZone(),top:0,bottom:this.env.model.getters.getNumberRows(e)-1},i=this.env.model.getters.getActivePosition();this.env.model.selection.selectZone({cell:i,zone:t})},"CTRL+SHIFT+ ":()=>{this.env.model.selection.selectAll()},"SHIFT+PAGEDOWN":()=>{this.env.model.dispatch("ACTIVATE_NEXT_SHEET")},"SHIFT+PAGEUP":()=>{this.env.model.dispatch("ACTIVATE_PREVIOUS_SHEET")},PAGEDOWN:()=>this.env.model.dispatch("SHIFT_VIEWPORT_DOWN"),PAGEUP:()=>this.env.model.dispatch("SHIFT_VIEWPORT_UP"),"CTRL+K":()=>aa(this.env)}}setup(){this.menuState=t.useState({isOpen:!1,position:null,menuItems:[]}),this.gridRef=t.useRef("grid"),this.hiddenInput=t.useRef("hiddenInput"),this.canvasPosition=jn(this.gridRef),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useChildSubEnv({getPopoverContainerRect:()=>this.getGridRect()}),t.useExternalListener(document.body,"cut",this.copy.bind(this,!0)),t.useExternalListener(document.body,"copy",this.copy.bind(this,!1)),t.useExternalListener(document.body,"paste",this.paste),t.onMounted((()=>this.focus())),this.props.exposeFocus((()=>this.focus())),dp("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimensionWithHeaders())),t.useEffect((()=>this.focus()),(()=>[this.env.model.getters.getActiveSheetId()])),this.onMouseWheel=up(((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.col=void 0,this.hoveredCell.row=void 0}))}onCellHovered({col:e,row:t}){this.hoveredCell.col=e,this.hoveredCell.row=t}get gridOverlayDimensions(){return Co({top:"26px",left:"48px",height:"calc(100% - 41px)",width:"calc(100% - 63px)"})}onClosePopover(){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.focus()}focus(){var e;this.env.model.getters.getSelectedFigureId()||"inactive"!==this.env.model.getters.getEditionMode()||null===(e=this.hiddenInput.el)||void 0===e||e.focus()}get gridEl(){if(!this.gridRef.el)throw new Error("Grid el is not defined.");return this.gridRef.el}getAutofillPosition(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect(e);return{left:t.x+t.width-4,top:t.y+t.height-4}}get isAutofillVisible(){const e=this.env.model.getters.getSelectedZone(),t=this.env.model.getters.getVisibleRect({left:e.right,right:e.right,top:e.bottom,bottom:e.bottom});return!(0===t.width||0===t.height)}onGridResized({height:e,width:t}){this.env.model.dispatch("RESIZE_SHEETVIEW",{width:t,height:e,gridOffsetX:_,gridOffsetY:N})}moveCanvas(e,t){const{scrollX:i,scrollY:o}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:i+e,offsetY:o+t})}getClientPositionKey(e){var t,i,o;return`${e.id}-${null===(t=e.position)||void 0===t?void 0:t.sheetId}-${null===(i=e.position)||void 0===i?void 0:i.col}-${null===(o=e.position)||void 0===o?void 0:o.row}`}isCellHovered(e,t){return this.hoveredCell.col===e&&this.hoveredCell.row===t}getGridRect(){return{...this.canvasPosition,...this.env.model.getters.getSheetViewDimensionWithHeaders()}}onCellClicked(e,t,{addZone:i,expandZone:o}){i&&this.env.model.dispatch("PREPARE_SELECTION_INPUT_EXPANSION"),this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),"editing"===this.env.model.getters.getEditionMode()&&this.env.model.dispatch("STOP_EDITION"),o?this.env.model.selection.setAnchorCorner(e,t):i?this.env.model.selection.addCellToSelection(e,t):this.env.model.selection.selectCell(e,t);let n=e,s=t;Ug(this.env,((e,t,i)=>{i.preventDefault(),(e!==n&&-1!=e||t!==s&&-1!=t)&&(n=-1===e?n:e,s=-1===t?s:t,this.env.model.selection.setAnchorCorner(n,s))}),(()=>{this.env.model.dispatch("STOP_SELECTION_INPUT"),this.env.model.getters.isPaintingFormat()&&this.env.model.dispatch("PASTE",{target:this.env.model.getters.getSelectedZones()})}))}onCellDoubleClicked(e,t){const i=this.env.model.getters.getActiveSheetId();({col:e,row:t}=this.env.model.getters.getMainCellPosition({sheetId:i,col:e,row:t}));this.env.model.getters.getEvaluatedCell({sheetId:i,col:e,row:t}).type===ln.empty?this.props.onGridComposerCellFocused():this.props.onComposerContentFocused()}closeOpenedPopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}processArrows(e){e.preventDefault(),e.stopPropagation(),this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),ag(e,this.env.model.selection),this.env.model.getters.isPaintingFormat()&&this.env.model.dispatch("PASTE",{target:this.env.model.getters.getSelectedZones()})}onKeydown(e){if(e.key.startsWith("Arrow"))return void this.processArrows(e);let t="";qn(e)&&(t+="CTRL+"),e.altKey&&(t+="ALT+"),e.shiftKey&&(t+="SHIFT+"),t+=e.key.toUpperCase();let i=this.keyDownMapping[t];return i?(e.preventDefault(),e.stopPropagation(),void i()):void 0}onInput(e){(e.isComposing||"insertFromPaste"!==e.inputType)&&e.data&&(e.preventDefault(),e.stopPropagation(),this.props.onGridComposerCellFocused(e.data))}onInputContextMenu(e){e.preventDefault();const t=this.env.model.getters.getSelectedZone(),{left:i,top:o}=t;let n="CELL";this.env.model.dispatch("STOP_EDITION"),this.env.model.getters.getActiveCols().has(i)?n="COL":this.env.model.getters.getActiveRows().has(o)&&(n="ROW");const{x:s,y:r,width:a,height:l}=this.env.model.getters.getVisibleRect(t);this.toggleContextMenu(n,s+a,r+l)}onCellRightClicked(e,t,{x:i,y:o}){const n=this.env.model.getters.getSelectedZones();let s="CELL";Qi(e,t,n[n.length-1])?this.env.model.getters.getActiveCols().has(e)?s="COL":this.env.model.getters.getActiveRows().has(t)&&(s="ROW"):(this.env.model.selection.getBackToDefault(),this.env.model.selection.selectCell(e,t)),this.toggleContextMenu(s,i,o)}toggleContextMenu(e,t,i){this.env.model.getters.hasOpenedPopover()&&this.closeOpenedPopover(),this.menuState.isOpen=!0,this.menuState.position={x:t,y:i},this.menuState.menuItems=Cp[e].getMenuItems()}copy(e,t){if(!this.gridEl.contains(document.activeElement))return;const i=t.clipboardData;if(!i)return void this.displayWarningCopyPasteNotSupported();if("inactive"!==this.env.model.getters.getEditionMode())return;e?Mr(this.env):this.env.model.dispatch("COPY");const o=this.env.model.getters.getClipboardContent();for(const e in o)i.setData(e,o[e]);t.preventDefault()}paste(e){if(!this.gridEl.contains(document.activeElement))return;const t=e.clipboardData;if(t){if(t.types.indexOf(cn.PlainText)>-1){const e=t.getData(cn.PlainText),i=this.env.model.getters.getSelectedZones();this.env.model.getters.getClipboardTextContent()===e?Dr(this.env,i):kr(this.env,i,e)}}else this.displayWarningCopyPasteNotSupported()}displayWarningCopyPasteNotSupported(){this.env.raiseError(s("Copy/Paste is not supported in this browser."))}closeMenu(){this.menuState.isOpen=!1,this.focus()}}Ep.template="o-spreadsheet-Grid",Ep.components={GridComposer:Qg,GridOverlay:sp,GridPopover:rp,HeadersOverlay:hp,Menu:ts,Autofill:Vg,ClientTag:Bg,Highlight:mp,Popover:Kn,VerticalScrollBar:Sp,HorizontalScrollBar:bp,FilterIconsOverlay:ip},Ep.props={sidePanelIsOpen:Boolean,exposeFocus:Function,focusComposer:String,onComposerContentFocused:Function,onGridComposerCellFocused:Function};class wp{constructor(e){this.xmlString=e}toString(){return this.xmlString}}const yp=["areaChart","area3DChart","lineChart","line3DChart","stockChart","radarChart","scatterChart","pieChart","pie3DChart","doughnutChart","barChart","bar3DChart","ofPieChart","surfaceChart","surface3DChart","bubbleChart"],xp="000000",Ip={arrow:"3Arrows",smiley:"3Symbols",dot:"3TrafficLights1"},Rp={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"},Tp="http://schemas.openxmlformats.org/drawingml/2006/main",Ap="http://schemas.openxmlformats.org/drawingml/2006/chart",Mp={workbook:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml",sheet:"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+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"},Op={document:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",sheet:"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",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"},Np="http://schemas.openxmlformats.org/officeDocument/2006/relationships",_p=.75,Fp=.1317,Dp=8.43,kp=12.75,Lp=30,Pp=100,Up=164,Vp={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}]},zp=["ACOT","ACOTH","AGGREGATE","ARABIC","BASE","BETA.DIST","BETA.INV","BINOM.DIST","BINOM.DIST.RANGE","BINOM.INV","BITAND","BITLSHIFT","BITOR","BITRSHIFT","BITXOR","CEILING.MATH","CEILING.PRECISE","CHISQ.DIST","CHISQ.DIST.RT","CHISQ.INV","CHISQ.INV.RT","CHISQ.TEST","COMBINA","CONCAT","CONFIDENCE.NORM","CONFIDENCE.T","COT","COTH","COVARIANCE.P","COVARIANCE.S","CSC","CSCH","DAYS","DECIMAL","ERF.PRECISE","ERFC.PRECISE","EXPON.DIST","F.DIST","F.DIST.RT","F.INV","F.INV.RT","F.TEST","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","HYPGEOM.DIST","IFNA","IFS","IMCOSH","IMCOT","IMCSC","IMCSCH","IMSEC","IMSECH","IMSINH","IMTAN","ISFORMULA","ISOWEEKNUM","LOGNORM.DIST","LOGNORM.INV","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","QUARTILE.EXC","QUARTILE.INC","QUERYSTRING","RANK.AVG","RANK.EQ","RRI","SEC","SECH","SHEET","SHEETS","SKEW.P","STDEV.P","STDEV.S","SWITCH","T.DIST","T.DIST.2T","T.DIST.RT","T.INV","T.INV.2T","T.TEST","TEXTJOIN","UNICHAR","UNICODE","VAR.P","VAR.S","WEBSERVICE","WEIBULL.DIST","XOR","Z.TEST"],Bp="[Content_Types].xml";var Hp;!function(e){e.DiagonalBorderNotSupported="Diagonal Borders",e.BorderStyleNotSupported="Border style",e.FillStyleNotSupported="Fill Style",e.FontNotSupported="Font",e.HorizontalAlignmentNotSupported="Horizontal Alignment",e.VerticalAlignmentNotSupported="Vertical Alignments",e.MultipleRulesCfNotSupported="Multiple rules conditional formats",e.CfTypeNotSupported="Conditional format type",e.CfFormatBorderNotSupported="Borders in conditional formats",e.CfFormatAlignmentNotSupported="Alignment in conditional formats",e.CfFormatNumFmtNotSupported="Num formats in conditional formats",e.CfIconSetEmptyIconNotSupported="IconSets with empty icons",e.BadlyFormattedHyperlink="Badly formatted hyperlink",e.NumFmtIdNotSupported="Number format"}(Hp||(Hp={}));class $p{constructor(){this._parsingWarnings=new Set,this._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,i){let o=`${e} ${t?'"'+t+'" is':"are"} not yet supported. `;i&&(o+=`Only ${i.join(", ")} are currently supported.`),this._conversionWarnings.has(o)||this._conversionWarnings.add(o)}}const Wp=["thin"],Gp=["general","left","center","right"],qp=["Arial"],Zp=["solid"],jp=["expression","cellIs","colorScale","iconSet","containsText","notContainsText","beginsWith","endsWith","containsBlanks","notContainsBlanks"],Xp={b:"boolean",d:"date",e:"error",inlineStr:"inlineStr",n:"number",s:"sharedString",str:"str"},Yp={dashDot:"thin",dashDotDot:"thin",dashed:"thin",dotted:"thin",double:"thin",hair:"thin",medium:"thin",mediumDashDot:"thin",mediumDashDotDot:"thin",mediumDashed:"thin",none:void 0,slantDashDot:"thin",thick:"thin",thin:"thin"},Kp={general:void 0,left:"left",center:"center",right:"right",fill:"left",justify:"left",centerContinuous:"center",distributed:"center"};const Qp={aboveAverage:void 0,expression:void 0,cellIs:void 0,colorScale:void 0,dataBar:void 0,iconSet:void 0,top10:void 0,uniqueValues:void 0,duplicateValues:void 0,containsText:"ContainsText",notContainsText:"NotContains",beginsWith:"BeginsWith",endsWith:"EndsWith",containsBlanks:"IsEmpty",notContainsBlanks:"IsNotEmpty",containsErrors:void 0,notContainsErrors:void 0,timePeriod:void 0},Jp={num:"number",percent:"percentage",max:"value",min:"value",percentile:"percentile",formula:"formula"},em={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"},tm={b:"bottom",t:"top",l:"left",r:"right",tr:"right"},im={areaChart:void 0,area3DChart:void 0,lineChart:"line",line3DChart:void 0,stockChart:void 0,radarChart:void 0,scatterChart:void 0,pieChart:"pie",pie3DChart:void 0,doughnutChart:"pie",barChart:"bar",bar3DChart:void 0,ofPieChart:void 0,surfaceChart:void 0,surface3DChart:void 0,bubbleChart:void 0},om={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"},nm={0:"",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:void 0},sm={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},rm={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"},am={"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"};function lm(e){if(!e)return;let t;if(e.rgb)t=e.rgb;else if(e.auto)t=xp;else{if(!e.indexed)return;t=rm[e.indexed]}var i;return t=6===(i=t).length?"#"+i+"FF":"#"+i.slice(2)+i.slice(0,2),e.tint&&(t=function(e,t){const i=Tt(e),o=Mt(i);t<0&&(o.l=o.l*(1+t));t>0&&(o.l=o.l*(1-t)+(100-100*(1-t)));return Rt(At(o))}(t,e.tint)),t=t.toUpperCase(),9===t.length&&t.endsWith("FF")&&(t=t.slice(0,7)),t}function cm(e,t){const i=e.split("/"),o=t.split("/");let n="",s=0;for(let e=0;e<i.length-1;e++)i[e]===o[e]?s++:n+="../";return n+=o.slice(s).join("/"),n}function hm(e,t=0){const i={};for(let o=0;o<e.length;o++)e[o]&&(i[o+t]=e[o]);return i}function dm(e){const t=[];for(let i of Object.keys(e).map(Number))t[i]=e[i];return t}function um(e){return e.replace(/_x([0-9a-zA-Z]{4})_/g,((e,t)=>String.fromCharCode(parseInt(t,16))))}const gm=/^(yy|yyyy|m{1,5}|d{1,4}|h{1,2}|s{1,2}|am\/pm|a\/m|\s|-|\/|\.|:)+$/i;function pm(e,t,i){var o,n,s;if(0===e)return;let r=nm[e]||(null===(o=t.find((t=>t.id===e)))||void 0===o?void 0:o.format);if(r)try{let e=r.replace(/(.*?);.*/,"$1");e=e.replace(/\[(.*)-[A-Z0-9]{3}\]/g,"[$1]"),e=e.replace(/\[\$\]/g,"");const t=(null===(n=e.match(/"/g))||void 0===n?void 0:n.length)||0;if(t/2+((null===(s=e.match(/\[/g))||void 0===s?void 0:s.length)||0)>1)throw new Error("Multiple escaped blocks in format");if(e=e.replace(/"(.*)"/g,"[$$$1]"),e=e.replace(/_.{1}/g,""),e=e.replace(/\*.{1}/g,""),e=e.replace(/\\ /g," "),e=e.replace(/\\./g,(e=>e[1])),function(e){return null!==e.match(gm)}(e)&&(e=function(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}(e)),function(e){try{return mi(0,e),!0}catch(e){return!1}}(e))return e}catch(e){}i.generateNotSupportedWarning(Hp.NumFmtIdNotSupported,r||`nmFmtId ${e}`)}function mm(e,t){const i=e.borders.map((e=>{!function(e,t){e.diagonal&&t.generateNotSupportedWarning(Hp.DiagonalBorderNotSupported)}(e,t);const i={top:fm(e.top,t),bottom:fm(e.bottom,t),left:fm(e.left,t),right:fm(e.right,t)};return Object.keys(i).forEach((e=>void 0===i[e]&&delete i[e])),i}));return hm(i,1)}function fm(e,t){if(!e)return;!function(e,t){Wp.includes(e.style)||t.generateNotSupportedWarning(Hp.BorderStyleNotSupported,e.style,Wp)}(e,t);const i=Yp[e.style];return i?[i,lm(e.color)]:void 0}function vm(e,t){return hm(e.styles.map((i=>bm({fontStyle:e.fonts[i.fontId],fillStyle:e.fills[i.fillId],alignment:i.alignment},t))),1)}function bm(e,t){var i,o,n,s,r,a,l,c,h,d,u,g;return function(e,t,i){e&&e.name&&!qp.includes(e.name)&&i.generateNotSupportedWarning(Hp.FontNotSupported,e.name,qp);t&&t.patternType&&!Zp.includes(t.patternType)&&i.generateNotSupportedWarning(Hp.FillStyleNotSupported,t.patternType,Zp)}(null==e?void 0:e.fontStyle,null==e?void 0:e.fillStyle,t),function(e,t){e&&!Gp.includes(e)&&t.generateNotSupportedWarning(Hp.HorizontalAlignmentNotSupported,e,Gp)}(null===(i=null==e?void 0:e.alignment)||void 0===i?void 0:i.horizontal,t),function(e,t){e&&t.generateNotSupportedWarning(Hp.VerticalAlignmentNotSupported)}(null===(o=null==e?void 0:e.alignment)||void 0===o?void 0:o.vertical,t),{bold:null===(n=e.fontStyle)||void 0===n?void 0:n.bold,italic:null===(s=e.fontStyle)||void 0===s?void 0:s.italic,strikethrough:null===(r=e.fontStyle)||void 0===r?void 0:r.strike,underline:null===(a=e.fontStyle)||void 0===a?void 0:a.underline,align:(null===(l=e.alignment)||void 0===l?void 0:l.horizontal)?Kp[e.alignment.horizontal]:void 0,fillColor:"solid"===(null===(c=e.fillStyle)||void 0===c?void 0:c.patternType)?lm(null===(h=e.fillStyle)||void 0===h?void 0:h.fgColor):lm(null===(d=e.fillStyle)||void 0===d?void 0:d.bgColor),textColor:lm(null===(u=e.fontStyle)||void 0===u?void 0:u.color),fontSize:null===(g=e.fontStyle)||void 0===g?void 0:g.size}}function Sm(e,t){const i=[];for(let o of e.styles){const n=pm(o.numFmtId,e.numFmts,t);n&&(i[o.numFmtId]=n)}return hm(i,1)}function Cm(e,t,i){const o=[];let n=1;for(let r of e){if(0===r.cfRules.length)continue;xm(r,t,i);const e=r.cfRules[0];let a;const l=[];if(void 0!==e.dxfId||"colorScale"===e.type||"iconSet"===e.type){switch(e.type){case"aboveAverage":case"containsErrors":case"notContainsErrors":case"dataBar":case"duplicateValues":case"expression":case"top10":case"uniqueValues":case"timePeriod":continue;case"colorScale":const t=Em(n++,r);t&&o.push(t);continue;case"iconSet":const c=wm(n++,r,i);c&&o.push(c);continue;case"containsText":case"notContainsText":case"beginsWith":case"endsWith":if(!e.text)continue;a=Qp[e.type],l.push(e.text);break;case"containsBlanks":case"notContainsBlanks":a=Qp[e.type];break;case"cellIs":if(!e.operator||!e.formula||0===e.formula.length)continue;a=(s=e.operator).slice(0,1).toUpperCase()+s.slice(1),l.push(e.formula[0]),2===e.formula.length&&l.push(e.formula[1])}a&&void 0!==e.dxfId&&o.push({id:(n++).toString(),ranges:r.sqref,stopIfTrue:e.stopIfTrue,rule:{type:"CellIsRule",operator:a,values:l,style:bm({fontStyle:t[e.dxfId].font,fillStyle:t[e.dxfId].fill},i)}})}}var s;return o}function Em(e,t){const i=t.cfRules[0].colorScale;if(!i||i.cfvos.length!==i.colors.length||i.cfvos.length<2||i.cfvos.length>3)return;const o=[];for(let e=0;e<i.cfvos.length;e++)o.push({color:(n=lm(i.colors[e])||"#FFFFFF",9===n.length&&(n=n.slice(0,7)),parseInt(n.replace("#",""),16)),type:Jp[i.cfvos[e].type],value:i.cfvos[e].value});var n;const s=o[0],r=2===o.length?o[1]:o[2],a=3===o.length?o[1]:void 0;return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"ColorScaleRule",minimum:s,midpoint:a,maximum:r}}}function wm(e,t,i){const o=t.cfRules[0].iconSet;if(!o)return;let n=o.cfvos,s=o.cfIcons;if(n.length<3||s&&s.length<3)return;n.length>3&&(n=[n[0],n[Math.floor(n.length/2)],n[n.length-1]]),s&&s.length>3&&(s=[s[0],s[Math.floor(s.length/2)],s[s.length-1]]);const r=[];for(let e=1;e<=2;e++){const t=Jp[n[e].type];if("value"===t)return;r.push({value:n[e].value||"",operator:n[e].gte?"ge":"gt",type:t})}let a={lower:s?ym(s[0].iconSet,s[0].iconId):ym(o.iconSet,0),middle:s?ym(s[1].iconSet,s[1].iconId):ym(o.iconSet,1),upper:s?ym(s[2].iconSet,s[2].iconId):ym(o.iconSet,2)};o.reverse&&(a={upper:a.lower,middle:a.middle,lower:a.upper});for(let e of Object.keys(a))if(!a[e])switch(i.generateNotSupportedWarning(Hp.CfIconSetEmptyIconNotSupported),e){case"upper":a[e]=Mg.dots.good;break;case"middle":a[e]=Mg.dots.neutral;break;case"lower":a[e]=Mg.dots.bad}return{id:e.toString(),stopIfTrue:t.cfRules[0].stopIfTrue,ranges:t.sqref,rule:{type:"IconSetRule",icons:a,upperInflectionPoint:r[1],lowerInflectionPoint:r[0]}}}function ym(e,t){const i=em[e];return i?0===t?Mg[i].bad:1===t?Mg[i].neutral:Mg[i].good:""}function xm(e,t,i){if(e.cfRules.length>1&&i.generateNotSupportedWarning(Hp.MultipleRulesCfNotSupported),jp.includes(e.cfRules[0].type)||i.generateNotSupportedWarning(Hp.CfTypeNotSupported,e.cfRules[0].type),e.cfRules[0].dxfId){const o=t[e.cfRules[0].dxfId];o.border&&i.generateNotSupportedWarning(Hp.CfFormatBorderNotSupported),o.alignment&&i.generateNotSupportedWarning(Hp.CfFormatAlignmentNotSupported),o.numFmt&&i.generateNotSupportedWarning(Hp.CfFormatNumFmtNotSupported)}}class Im{constructor(e=new Tm){this.scope=e,this.code=""}append(...e){this.code+=e.map((e=>e.toString())).join("\n")+"\n"}return(e){return new Rm(this.scope,this.code,e)}toString(){return Am(this.code)}}class Rm{constructor(e,t,i){this.scope=e,this.returnExpression=i,this.code=Am(t)}toString(){return this.code}wrapInClosure(){const e=this.scope.nextVariableName(),t=new Im(this.scope);return t.append(`const ${e} = () => {`),t.append(this.code),t.append(`return ${this.returnExpression};`),t.append("}"),t.return(e)}assignResultToVariable(){if(this.scope.isAlreadyDeclared(this.returnExpression))return this;const e=this.scope.nextVariableName(),t=new Im(this.scope);return t.append(this.code),t.append(`const ${e} = ${this.returnExpression};`),t.return(e)}}class Tm{constructor(){this.nextId=1,this.declaredVariables=new Set}nextVariableName(){const e="_"+this.nextId++;return this.declaredVariables.add(e),e}isAlreadyDeclared(e){return this.declaredVariables.has(e)}}function Am(e){let t="",i=0;const o=e.split("\n").map((e=>e.trim())).filter((e=>""!==e));for(const e of o)e.startsWith("}")&&i--,t+="\t".repeat(i)+e+"\n",e.endsWith("{")&&i++;return t.trim()}const Mm=tg.content,Om=["%"],Nm="+,-,*,/,:,=,<>,>=,>,<=,<,^,&".split(",").concat(Om);function _m(e){const t=(e=ft(e)).split(""),i=[];for(;t.length;){let e=Hm(t)||km(t)||Pm(t)||Vm(t)||Fm(t)||$m(t)||Um(t)||Bm(t);e||(e={type:"UNKNOWN",value:t.shift()}),i.push(e)}return i}function Fm(e){return"?"===e[0]?(e.shift(),{type:"DEBUGGER",value:"?"}):null}const Dm={",":"COMMA","(":"LEFT_PAREN",")":"RIGHT_PAREN"};function km(e){if(e[0]in Dm){const t=e.shift();return{type:Dm[t],value:t}}return null}function Lm(e,t){for(let i=0;i<t.length;i++)if(t[i]!==e[i])return!1;return!0}function Pm(e){for(let t of Nm)if(Lm(e,t))return e.splice(0,t.length),{type:"OPERATOR",value:t};return null}function Um(e){const t=st(e).match(Kt);return t?(e.splice(0,t[0].length),{type:"NUMBER",value:t[0]}):null}function Vm(e){if('"'===e[0]){const t=e.shift();let i=t;for(;e[0]&&(e[0]!==t||"\\"===i[i.length-1]);)i+=e.shift();return'"'===e[0]&&(i+=e.shift()),{type:"STRING",value:i}}return null}const zm=/\w|\.|!|\$/;function Bm(e){let t="";if("'"===e[0]){let i=e.shift();for(t+=i;e[0];)if(i=e.shift(),t+=i,"'"===i){if(!e[0]||"'"!==e[0])break;i=e.shift(),t+=i}if("'"!==i)return{type:"UNKNOWN",value:t}}for(;e[0]&&e[0].match(zm);)t+=e.shift();if(t.length){const e=t;if(e.toUpperCase()in Mm)return{type:"FUNCTION",value:e};return e.match(Lt)?{type:"REFERENCE",value:e}:{type:"SYMBOL",value:e}}return null}function Hm(e){let t=0;for(;e[0]===he;)t++,e.shift();if(t)return{type:"SPACE",value:he.repeat(t)};for(;" "===e[0];)t++,e.shift();return t?{type:"SPACE",value:" ".repeat(t)}:null}function $m(e){return Lm(e,K)?(e.splice(0,K.length),{type:"INVALID_REFERENCE",value:K}):null}const Wm=/[a-zA-Z0-9\_]+(\.[a-zA-Z0-9\_]+)*/,Gm=["-","+"],qm=["%"],Zm=["*","+","&"],jm={"^":30,"%":30,"*":20,"/":20,"+":15,"-":15,"&":13,">":10,"<>":10,">=":10,"<":10,"<=":10,"=":10};function Xm(e){var t,i,o;const n=e.shift();if(!n)throw new h(le);switch(n.type){case"DEBUGGER":const r=Qm(e,1e3);return r.debug=!0,r;case"NUMBER":return{type:"NUMBER",value:si(n.value)};case"STRING":return{type:"STRING",value:Oe(n.value)};case"FUNCTION":const a=function(e){var t;Km(e,"LEFT_PAREN",s("Missing opening parenthesis"));const i=e[0];if("RIGHT_PAREN"===(null==i?void 0:i.type))return Km(e,"RIGHT_PAREN"),[];const o=[];o.push(Ym(e));for(;"RIGHT_PAREN"!==(null===(t=e[0])||void 0===t?void 0:t.type);)Km(e,"COMMA",s("Wrong function call")),o.push(Ym(e));return Km(e,"RIGHT_PAREN"),o}(e);return{type:"FUNCALL",value:n.value,args:a};case"INVALID_REFERENCE":throw new u;case"REFERENCE":if(":"===(null===(t=e[0])||void 0===t?void 0:t.value)&&"REFERENCE"===(null===(i=e[1])||void 0===i?void 0:i.type)){e.shift();const t=e.shift();return{type:"REFERENCE",value:`${n.value}:${null==t?void 0:t.value}`}}return{type:"REFERENCE",value:n.value};case"SYMBOL":if(["TRUE","FALSE"].includes(n.value.toUpperCase()))return{type:"BOOLEAN",value:"TRUE"===n.value.toUpperCase()};if(n.value&&Wm.test(n.value)&&"LEFT_PAREN"===(null===(o=e[0])||void 0===o?void 0:o.type))throw new p(n.value);throw new h(s("Invalid formula"));case"LEFT_PAREN":const l=Qm(e);return Km(e,"RIGHT_PAREN",s("Missing closing parenthesis")),l;case"OPERATOR":const c=n.value;if(Gm.includes(c))return{type:"UNARY_OPERATION",value:c,operand:Qm(e,jm[c])};throw new h(s("Unexpected token: %s",n.value));default:throw new h(s("Unexpected token: %s",n.value))}}function Ym(e){const t=e[0];return"COMMA"===(null==t?void 0:t.type)||"RIGHT_PAREN"===(null==t?void 0:t.type)?{type:"EMPTY",value:""}:Qm(e)}function Km(e,t,i=le){const o=e.shift();if(!o||o.type!==t)throw new h(i)}function Qm(e,t=0){var i;if(0===e.length)throw new h(le);let o=Xm(e);for(;"OPERATOR"===(null===(i=e[0])||void 0===i?void 0:i.type)&&jm[e[0].value]>t;){const t=e.shift().value;if(qm.includes(t))o={type:"UNARY_OPERATION",value:t,operand:o,postfix:!0};else{o={type:"BIN_OPERATION",value:t,left:o,right:Qm(e,jm[t])}}}return o}function Jm(e){return ef(_m(e))}function ef(e){"="===(e=e.filter((e=>"SPACE"!==e.type)))[0].value&&e.splice(0,1);const t=Qm(e);if(e.length)throw new h(le);return t}function tf(e,t,i){switch(t===e.type&&(e=i(e)),e.type){case"FUNCALL":return{...e,args:e.args.map((e=>tf(e,t,i)))};case"UNARY_OPERATION":return{...e,operand:tf(e.operand,t,i)};case"BIN_OPERATION":return{...e,right:tf(e.right,t,i),left:tf(e.left,t,i)};default:return e}}function of(e){switch(e.type){case"FUNCALL":const t=e.args.map((e=>of(e)));return`${e.value}(${t.join(",")})`;case"NUMBER":return e.value.toString();case"REFERENCE":default:return e.value;case"STRING":return`"${e.value}"`;case"BOOLEAN":return e.value?"TRUE":"FALSE";case"UNARY_OPERATION":return e.postfix?nf(e)+e.value:e.value+sf(e);case"BIN_OPERATION":return nf(e)+e.value+sf(e)}}function nf(e){const t=e.value,i="left"in e?e.left:e.operand,o=i.value;return"BIN_OPERATION"===i.type&&jm[o]<jm[t]?`(${of(i)})`:of(i)}function sf(e){const t=e.value,i="right"in e?e.right:e.operand,o=jm[i.value],n=jm[t];let s=!1;return"BIN_OPERATION"!==i.type?s=!1:o<n?s=!0:o!==n||Zm.includes(t)||(s=!0),s?`(${of(i)})`:of(i)}var rf;!function(e){e[e.LeftRef=0]="LeftRef",e[e.RightRef=1]="RightRef",e[e.Separator=2]="Separator",e[e.FullColumnSeparator=3]="FullColumnSeparator",e[e.FullRowSeparator=4]="FullRowSeparator",e[e.RightColumnRef=5]="RightColumnRef",e[e.RightRowRef=6]="RightRowRef",e[e.Found=7]="Found"}(rf||(rf={}));const af=(e,t=(()=>!0))=>[{goTo:e,guard:t}],lf=(e,t=(()=>!0))=>({goTo:e,guard:t}),cf={[rf.LeftRef]:{REFERENCE:af(rf.Separator),NUMBER:af(rf.FullRowSeparator),SYMBOL:[lf(rf.FullColumnSeparator,(e=>Pt(e.value))),lf(rf.FullRowSeparator,(e=>Ut(e.value)))]},[rf.FullColumnSeparator]:{SPACE:af(rf.FullColumnSeparator),OPERATOR:af(rf.RightColumnRef,(e=>":"===e.value))},[rf.FullRowSeparator]:{SPACE:af(rf.FullRowSeparator),OPERATOR:af(rf.RightRowRef,(e=>":"===e.value))},[rf.Separator]:{SPACE:af(rf.Separator),OPERATOR:af(rf.RightRef,(e=>":"===e.value))},[rf.RightRef]:{SPACE:af(rf.RightRef),NUMBER:af(rf.Found),REFERENCE:af(rf.Found,(e=>Bt(e.value))),SYMBOL:af(rf.Found,(e=>Vt(e.value)||zt(e.value)))},[rf.RightColumnRef]:{SPACE:af(rf.RightColumnRef),SYMBOL:af(rf.Found,(e=>Vt(e.value))),REFERENCE:af(rf.Found,(e=>Bt(e.value)))},[rf.RightRowRef]:{SPACE:af(rf.RightRowRef),NUMBER:af(rf.Found),REFERENCE:af(rf.Found,(e=>Bt(e.value))),SYMBOL:af(rf.Found,(e=>zt(e.value)))},[rf.Found]:{}};function hf(e){var t;let i=0,o=cf[rf.LeftRef];const n=[];for(;void 0!==o;){const s=e[i++];if(!s)return null;const r=null===(t=o[s.type])||void 0===t?void 0:t.find((e=>e.guard(s))),a=r?r.goTo:void 0;switch(a){case void 0:return null;case rf.Found:return n.push(s),e.splice(0,i),{type:"REFERENCE",value:st(n.map((e=>e.value)))};default:o=cf[a],n.push(s)}}return null}function df(e){const t=_m(e),i=[];for(;t.length;)i.push(hf(t)||t.shift());return i}const uf=tg.content,gf={"=":"EQ","+":"ADD","-":"MINUS","*":"MULTIPLY","/":"DIVIDE",">=":"GTE","<>":"NE",">":"GT","<=":"LTE","<":"LT","^":"POWER","&":"CONCATENATE"},pf={"-":"UMINUS","+":"UPLUS","%":"UNARY.PERCENT"},mf={};function ff(e){const t=df(e),{dependencies:i,constantValues:o}=function(e){const t={numbers:[],strings:[]},i=[];for(const o of e)switch(o.type){case"INVALID_REFERENCE":case"REFERENCE":i.push(o.value);break;case"STRING":const e=Oe(o.value);t.strings.includes(e)||t.strings.push(e);break;case"NUMBER":{const e=si(o.value);t.numbers.includes(e)||t.numbers.push(e);break}}return{dependencies:i,constantValues:t}}(t),n=function(e,t,i){return st(e.map((e=>{switch(e.type){case"STRING":const o=Oe(e.value);return`|S${i.strings.indexOf(o)}|`;case"NUMBER":return`|N${i.numbers.indexOf(si(e.value))}|`;case"REFERENCE":case"INVALID_REFERENCE":return`|${t.indexOf(e.value)}|`;case"SPACE":return"";default:return e.value}})))}(t,i,o);if(!mf[n]){const r=ef([...t]),a=new Tm;if("BIN_OPERATION"===r.type&&":"===r.value)throw new h(s("Invalid formula"));if("EMPTY"===r.type)throw new h(s("Invalid formula"));const l=g(r),c=new Im;c.append(`// ${n}`),c.append(l),c.append(`return ${l.returnExpression};`);let d=new Function("deps","ref","range","ctx",c.toString());function u(e){const t=uf[e.value.toUpperCase()],i=e.args,o=i.length;if(o<t.minArgRequired)throw new h(s("Invalid number of arguments for the %s function. Expected %s minimum, but got %s instead.",e.value.toUpperCase(),t.minArgRequired.toString(),o.toString()));if(o>t.maxArgPossible)throw new h(s("Invalid number of arguments for the %s function. Expected %s maximum, but got %s instead.",e.value.toUpperCase(),t.maxArgPossible.toString(),o.toString()));const n=t.nbrArgRepeating;if(n>1){const i=t.args.length-n;if((o-i)%n!=0)throw new h(s("Invalid number of arguments for the %s function. Expected all arguments after position %s to be supplied by groups of %s arguments",e.value.toUpperCase(),i.toString(),n.toString()))}let r=[];for(let n=0;n<o;n++){const o=t.getArgToFocus(n+1)-1;if(0<=o&&o<t.args.length){const a=i[n],l=t.args[o],c=l.type||[],d=c.includes("META"),u=l.lazy,p=c.some((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e)),m=c.every((e=>"RANGE"===e||"RANGE<BOOLEAN>"===e||"RANGE<DATE>"===e||"RANGE<NUMBER>"===e||"RANGE<STRING>"===e));if(m&&"REFERENCE"!==a.type)throw new h(s("Function %s expects the parameter %s to be reference to a cell or range, not a %s.",e.value.toUpperCase(),(n+1).toString(),a.type.toLowerCase()));const f=g(a,d,p,{functionName:e.value.toUpperCase(),paramIndex:n+1});r.push(u?f.wrapInClosure():f)}}return r}function g(e,t=!1,n=!1,r={}){const l=new Im(a);if("REFERENCE"!==e.type&&("BIN_OPERATION"!==e.type||":"!==e.value)&&t)throw new h(s("Argument must be a reference to a cell or range."));switch(e.debug&&l.append("debugger;"),e.type){case"BOOLEAN":return l.return(`{ value: ${e.value} }`);case"NUMBER":return l.return(`{ value: this.constantValues.numbers[${o.numbers.indexOf(e.value)}] }`);case"STRING":return l.return(`{ value: this.constantValues.strings[${o.strings.indexOf(e.value)}] }`);case"REFERENCE":const s=i.indexOf(e.value);return n?l.return(`range(deps[${s}])`):l.return(`ref(deps[${s}], ${t?"true":"false"}, "${r.functionName||gf["="]}", ${r.paramIndex})`);case"FUNCALL":const a=u(e).map((e=>e.assignResultToVariable()));l.append(...a);const c=e.value.toUpperCase();return l.append(`ctx.__lastFnCalled = '${c}';`),l.return(`ctx['${c}'](${a.map((e=>e.returnExpression))})`);case"UNARY_OPERATION":{const t=pf[e.value],i=g(e.operand,!1,!1,{functionName:t}).assignResultToVariable();return l.append(i),l.append(`ctx.__lastFnCalled = '${t}';`),l.return(`ctx['${t}'](${i.returnExpression})`)}case"BIN_OPERATION":{const t=gf[e.value],i=g(e.left,!1,!1,{functionName:t}).assignResultToVariable(),o=g(e.right,!1,!1,{functionName:t}).assignResultToVariable();return l.append(i),l.append(o),l.append(`ctx.__lastFnCalled = '${t}';`),l.return(`ctx['${t}'](${i.returnExpression}, ${o.returnExpression})`)}case"EMPTY":return l.return("undefined")}}mf[n]={execute:d}}return{execute:mf[n].execute,dependencies:i,constantValues:o,tokens:t}}function vf(e){return function(e){let t=[],i="";return e.map(((e,o)=>{switch(["SPACE","LEFT_PAREN"].includes(e.type)||(i=""),e.type){case"FUNCTION":i=e.value;break;case"LEFT_PAREN":t.push({parent:i,argPosition:0}),i="";break;case"RIGHT_PAREN":t.pop();break;case"COMMA":t.length&&t[t.length-1].argPosition++}if(t.length){const i=t[t.length-1];i.parent&&(e.functionContext=Object.assign({},i))}return e}))}(function(e){let t=1;const i=[];return e.map((e=>("LEFT_PAREN"===e.type?(i.push(t),e.parenIndex=t,t++):"RIGHT_PAREN"===e.type&&(e.parenIndex=i.pop()),e)))}(function(e){let t=0;return e.map((e=>{const i=e.value.toString().length,o=Object.assign({},e,{start:t,end:t+i,length:i});return t=o.end,o}))}(df(e))))}function bf(e){switch(e){case"IsNotEmpty":case"NotContains":return"notContainsBlanks";case"IsEmpty":return"containsBlanks";default:return e.charAt(0).toLowerCase()+e.slice(1)}}function Sf(e){return Math.round(_p*e*100)/100}function Cf(e){return Math.round(Fp*e*100)/100}function Ef(e){if(e)return{style:e[0],color:{rgb:e[1]}}}function wf(e,t){let i={};e.style&&(i=t.styles[e.style]);const o=function(e,t){if(e.format)return t.formats[e.format];if(e.isFormula){const t=_m(e.content||""),i=tg.content;if(!t.filter((e=>"FUNCTION"===e.type)).every((e=>i[e.value.toUpperCase()].isExported)))return e.computedFormat}return}(e,t),n={};if(e.border){const i=t.borders[e.border];n.left=Ef(i.left),n.right=Ef(i.right),n.bottom=Ef(i.bottom),n.top=Ef(i.top)}const s={font:{size:(null==i?void 0:i.fontSize)||q,color:{rgb:(null==i?void 0:i.textColor)?i.textColor:"000000"},family:2,name:"Arial"},fill:(null==i?void 0:i.fillColor)?{fgColor:{rgb:i.fillColor}}:{reservedAttribute:"none"},numFmt:o?{format:o,id:0}:void 0,border:n||{},alignment:{vertical:"center",horizontal:i.align}};return s.font.strike=!!(null==i?void 0:i.strikethrough)||void 0,s.font.underline=!!(null==i?void 0:i.underline)||void 0,s.font.bold=!!(null==i?void 0:i.bold)||void 0,s.font.italic=!!(null==i?void 0:i.italic)||void 0,s}function yf(e,t){const{id:i}=If(t.font,e.fonts),{id:o}=If(t.fill,e.fills),{id:n}=If(t.border,e.borders),s=function(e,t){if(!e)return 0;let i=sm[e.format];if(!i){const{id:o}=If(e,t);i=o+Up}return i}(t.numFmt,e.numFmts),r={fontId:i,fillId:o,borderId:n,numFmtId:s,alignment:{vertical:t.alignment.vertical,horizontal:t.alignment.horizontal}},{id:a}=If(r,e.styles);return a}function xf(e,t,i){let o,n=e.find((e=>e.path===t));return n?(o=`rId${(n.rels.length+1).toString()}`,n.rels.push({...i,id:o})):(o="rId1",e.push({path:t,rels:[{...i,id:o}]})),o}function If(e,t){for(let[i,o]of Object.entries(t))if(JSON.stringify(o)===JSON.stringify(e))return{id:parseInt(i,10),list:t};let i=t.findIndex((t=>JSON.stringify(t)===JSON.stringify(e)));return-1===i&&(t.push(e),i=t.length-1),{id:i,list:t}}const Rf=[];function Tf(e){const t=Rf.findIndex((t=>t===e));return-1===t?(Rf.push(e),Rf.length):t+1}const Af=[];function Mf(e){const t=Af.findIndex((t=>t===e));return-1===t?(Af.push(e),Af.length):t+1}function Of(e){return Math.round(914400*e/96)}function Nf(e,t,i){let o,n,s=e;if(({xc:s,sheetName:o}=Ht(e)),o){const e=i.sheets.findIndex((e=>e.name===o));if(e<0)throw new Error("Unable to find a sheet with the name "+o);n=e}else n=Number(t);const r=zi(s);return void 0===r.right&&(r.right=i.sheets[n].colNumber),void 0===r.bottom&&(r.bottom=i.sheets[n].rowNumber),(r.right-r.left+1)*(r.bottom-r.top+1)}function _f(e){return Math.round(96*e/914400)}function Ff(e,t){var i;let o=0;for(let n=0;n<e;n++){const e=t.cols.find((e=>n>=e.min&&n<=e.max));(null==e?void 0:e.width)?o+=e.width:(null===(i=t.sheetFormat)||void 0===i?void 0:i.defaultColWidth)?o+=t.sheetFormat.defaultColWidth:o+=Dp}return o/Fp}function Df(e,t){var i;let o=0;for(let n=0;n<e;n++){const e=t.rows[n];(null==e?void 0:e.height)?o+=e.height:(null===(i=t.sheetFormat)||void 0===i?void 0:i.defaultRowHeight)?o+=t.sheetFormat.defaultRowHeight:o+=kp}return o/_p}function kf(e){let t=1;return e.figures.map((i=>function(e,t,i){const o=Ff(e.anchors[0].col,i)+_f(e.anchors[0].colOffset),n=Ff(e.anchors[1].col,i)+_f(e.anchors[1].colOffset),s=Df(e.anchors[0].row,i)+_f(e.anchors[0].rowOffset),r=Df(e.anchors[1].row,i)+_f(e.anchors[1].rowOffset),a=n-o,l=r-s,c=Lf(e.data);return c?{id:t,x:o,y:s,width:a,height:l,tag:"chart",data:Lf(e.data)}:void 0}(i,(t++).toString(),e))).filter(it)}function Lf(e){var t;const i=null===(t=e.dataSets[0].label)||void 0===t?void 0:t.replace(/\$/g,"");let o=e.dataSets.map((e=>e.range.replace(/\$/g,"")));return"pie"===e.type&&o.reverse(),{dataSets:o,dataSetsHaveTitle:!1,labelRange:i,title:e.title||"",type:e.type,background:lm({rgb:e.backgroundColor})||"#FFFFFF",verticalAxisPosition:e.verticalAxisPosition,legendPosition:e.legendPosition,stacked:e.stacked||!1,aggregated:!1,cumulative:e.cumulative||!1,labelsAsText:!1}}const Pf=new RegExp(/'?\[([0-9]*)\](.*)'?!(\$?[a-zA-Z]*\$?[0-9]*)/g),Uf=new RegExp(/SUBTOTAL\(([0-9]*),/g),Vf=new RegExp(Ot.source,"ig");function zf(e,t){const i=function(e){const t={};for(let i of e.rows)for(let e of i.cells)e.formula&&void 0!==e.formula.sharedIndex&&e.formula.content&&(t[e.formula.sharedIndex]={refCellXc:e.xc,formula:e.formula.content});return t}(e);for(let o of e.rows.map((e=>e.cells)).flat())(null==o?void 0:o.formula)&&(o.formula.content=void 0===o.formula.sharedIndex||o.formula.content?"="+o.formula.content:"="+Hf(o.xc,i[o.formula.sharedIndex]),o.formula.content=Bf(o.formula.content,t))}function Bf(e,t){return e=(e=(e=(e=e.replace("_xlfn.","")).replace(/#REF!/g,"#REF")).replace(Uf,((e,t)=>{const i=om[t];return i?i+"(":e}))).replace(Pf,((e,i,o,n)=>{var s;i=Number(i)-1,n=n.replace(/\$/g,"");const r=t.externalBooks[i].sheetNames.findIndex((e=>e===o));if(-1===r)return e;const a=null===(s=t.externalBooks[i].datasets.find((e=>e.sheetId===r)))||void 0===s?void 0:s.data;if(!a)return e;const l=a&&a[n];return(Number(l)?l:`"${l}"`)||e}))}function Hf(e,t){const i=Gt(t.refCellXc);let o,n=t.formula.slice();do{if(o=Vf.exec(n),o){const t=Gt(o[0].replace("$","")),s=Gt(e),r={colFixed:o[0].startsWith("$"),rowFixed:o[0].includes("$",1)},a={col:s.col-i.col,row:s.row-i.row},l={col:r.colFixed?t.col:t.col+a.col,row:r.rowFixed?t.row:t.row+a.row};n=n.slice(0,o.index)+qt(l.col,l.row,r)+n.slice(o.index+o[0].length)}}while(o);return n}function $f(e,t){return e.sheets.map((i=>{zf(i,e);const o=function(e){const t=[0,0];for(let i of e.rows)t[0]=Math.max(t[0],...i.cells.map((e=>Gt(e.xc).col))),t[1]=Math.max(t[1],i.index);return t[0]=Math.max(t[0],Lp),t[1]=Math.max(t[1],Pp),t}(i),n=i.sheetViews[0];return{id:i.sheetName,areGridLinesVisible:!n||n.showGridLines,name:i.sheetName,colNumber:o[0],rowNumber:o[1],cells:qf(i,e,o,t),merges:i.merges,cols:Wf(i,o[0]),rows:Gf(i,o[1]),conditionalFormats:Cm(i.cfs,e.dxfs,t),figures:kf(i),isVisible:i.isVisible,panes:n?{xSplit:n.pane.xSplit,ySplit:n.pane.ySplit}:{xSplit:0,ySplit:0},filterTables:[]}}))}function Wf(e,t){var i;const o={};for(let s=1;s<t+1;s++){const t=e.cols.find((e=>e.min<=s&&s<=e.max));let r;r=t&&t.width?t.width:(null===(i=e.sheetFormat)||void 0===i?void 0:i.defaultColWidth)?e.sheetFormat.defaultColWidth:Dp,o[s-1]={size:(n=r,n?Math.round(n/Fp*100)/100:n),isHidden:null==t?void 0:t.hidden}}var n;return o}function Gf(e,t){var i;const o={};for(let s=1;s<t+1;s++){const t=e.rows.find((e=>e.index===s));let r;r=t&&t.height?t.height:(null===(i=e.sheetFormat)||void 0===i?void 0:i.defaultRowHeight)?e.sheetFormat.defaultRowHeight:kp,o[s-1]={size:(n=r,n?Math.round(n/_p*100)/100:n),isHidden:null==t?void 0:t.hidden}}var n;return o}function qf(e,t,i,o){const n={},s=t.sharedStrings.map((e=>e.replace(/\n/g,"")));const r=e.hyperlinks.reduce(((e,t)=>(e[t.xc]=t,e)),{});for(let i of e.rows)for(let e of i.cells)n[e.xc]={content:Zf(e,r,s,o),style:e.styleIndex?e.styleIndex+1:void 0,border:e.styleIndex?t.styles[e.styleIndex].borderId+1:void 0,format:e.styleIndex?t.styles[e.styleIndex].numFmtId+1:void 0};for(let o of e.rows.filter((e=>e.styleIndex)))for(let e=1;e<=i[0];e++){const i=qt(e-1,o.index-1);let s=n[i];s||(s={},n[i]=s),s.style=s.style?s.style:o.styleIndex+1,s.border=s.border?s.border:t.styles[o.styleIndex].borderId+1,s.format=s.format?s.format:t.styles[o.styleIndex].numFmtId+1}for(let o of e.cols.filter((e=>e.styleIndex)))for(let e=o.min;e<=Math.min(o.max,i[0]);e++)for(let s=1;s<=i[1];s++){const i=qt(e-1,s-1);let r=n[i];r||(r={},n[i]=r),r.style=r.style?r.style:o.styleIndex+1,r.border=r.border?r.border:t.styles[o.styleIndex].borderId+1,r.format=r.format?r.format:t.styles[o.styleIndex].numFmtId+1}return n}function Zf(e,t,i,o){let n;switch(e.type){case"sharedString":n=i[parseInt(e.value,10)];break;case"boolean":n=Number(e.value)?"TRUE":"FALSE";break;case"date":case"error":case"inlineStr":case"number":case"str":n=e.value}return n&&t[e.xc]&&(n=function(e,t,i){const o=e.display||t;e.relTarget||e.location||i.generateNotSupportedWarning(Hp.BadlyFormattedHyperlink);const n=e.relTarget?e.relTarget:et(Ht(e.location).sheetName);return Ye(o,n)}(t[e.xc],n,o)),e.formula&&(n=e.formula.content),n}const jf={fillColor:"#000000",textColor:"#ffffff",bold:!0},Xf={bold:!0},Yf=["thin","#000000FF"];function Kf(e,t){for(const i of t.sheets)for(const t of i.tables){const o=e.sheets.find((e=>e.name===i.sheetName));o&&t.autoFilter&&(o.filterTables||(o.filterTables=[]),o.filterTables.push({range:t.ref}))}!function(e,t){var i,o,n,s;const r=dm(e.styles),a=dm(e.borders);for(let l of t.sheets)for(let t of l.tables){const c=e.sheets.find((e=>e.name===l.sheetName));if(!c)continue;const h=Bi(t.ref);for(let e=0;e<t.headerRowCount;e++)Qf(jf,{...h,bottom:h.top+e},c.cells,r);for(let e=0;e<t.totalsRowCount;e++)Qf(Xf,{...h,top:h.bottom-e},c.cells,r);(null===(i=t.style)||void 0===i?void 0:i.showFirstColumn)&&Qf(Xf,{...h,right:h.left},c.cells,r),(null===(o=t.style)||void 0===o?void 0:o.showLastColumn)&&Qf(Xf,{...h,left:h.right},c.cells,r);for(let e=h.left;e<=h.right;e++)for(let i=h.top;i<=h.bottom;i++){const o=qt(e,i),r=c.cells[o],l={left:e===h.left||(null===(n=t.style)||void 0===n?void 0:n.showColumnStripes)?Yf:void 0,right:e===h.right?Yf:void 0,top:i===h.top||(null===(s=t.style)||void 0===s?void 0:s.showRowStripes)||i>h.bottom-t.totalsRowCount?Yf:void 0,bottom:i===h.bottom?Yf:void 0},d=(null==r?void 0:r.border)?{...a[r.border],...l}:l;let u=a.findIndex((e=>ct(e,d)));-1===u&&(u=a.length,a.push(d)),r?r.border=u:c.cells[o]={border:u}}}e.styles=hm(r),e.borders=hm(a)}(e,t),function(e,t){for(let i of e){const e=t.find((e=>e.sheetName===i.name)).tables;for(let t of e){const e=t.name+"[";for(let o of no(Bi(t.ref))){const n=qt(o.col,o.row),s=i.cells[n];if(s&&s.content&&s.content.startsWith("=")){let i;for(;-1!==(i=s.content.indexOf(e));){let o=s.content.slice(i+e.length),r=o.indexOf("]");o.startsWith("[")&&(r=o.indexOf("]",r+1),r=o.indexOf("]",r+1)),o=o.slice(0,r);const a=Jf(o,t,n);s.content=s.content.slice(0,i)+a+s.content.slice(e.length+i+r+1)}}}}}}(e.sheets,t.sheets)}function Qf(e,t,i,o){for(let n=t.left;n<=t.right;n++)for(let s=t.top;s<=t.bottom;s++){const t=qt(n,s),r=i[t],a=(null==r?void 0:r.style)?{...o[r.style],...e}:e;let l=o.findIndex((e=>ct(e,a)));-1===l&&(l=o.length,o.push(a)),r?r.style=l:i[t]={style:l}}}function Jf(e,t,i){const o=e.split(","),n=Bi(t.ref),s={...n};let r=!0;if(1===o.length){const e=t.cols.findIndex((e=>e.name===o[0]));s.left=s.right=e+n.left,t.headerRowCount&&(s.top+=t.headerRowCount),t.totalsRowCount&&(s.bottom-=1)}else{switch(o[0].slice(1,o[0].length-1)){case"#All":s.top=t.headerRowCount?n.top+t.headerRowCount:n.top,s.bottom=n.bottom;break;case"#Data":s.top=t.headerRowCount?n.top+t.headerRowCount:n.top,s.bottom=t.totalsRowCount?n.bottom+1:n.bottom;break;case"#This Row":s.top=s.bottom=Gt(i).row;break;case"#Headers":s.top=s.bottom=n.top,t.headerRowCount||(r=!1);break;case"#Totals":s.top=s.bottom=n.bottom,t.totalsRowCount||(r=!1)}const e=o[1].slice(1,o[1].length-1),a=t.cols.findIndex((t=>t.name===e));s.left=s.right=a+n.left}return r?s.top!==s.bottom?$i(s):qt(s.left,s.top):K}function ev(e,t,i){return{content:(new XMLSerializer).serializeToString(e),path:t,contentType:i}}function tv(e){return String(e).replace(/\&/g,"&").replace(/\</g,"<").replace(/\>/g,">").replace(/\"/g,""").replace(/\'/g,"'").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function iv(e){return new wp(e.map((([e,t])=>`${e}="${tv(t)}"`)).join(" "))}function ov(e,t="text/xml"){const i=(new DOMParser).parseFromString(e.toString(),t),o=i.querySelector("parsererror");if(o){const t=o.innerHTML,i=parseInt(t.split(":")[0],10),n=e.toString().trim().split("\n"),s=n.slice(Math.max(i-3,0),Math.min(i+2,n.length)).join("\n");throw new Error(`XML string could not be parsed: ${t}\n${s}`)}return i}function nv(e,t){return rv`
|
|
1399
1399
|
<Override ContentType="${t}" PartName="${e}" />
|
|
1400
|
-
`}function ov(e){return new Cp(e.join("\n"))}function nv(e,...t){let i=[e[0]];for(let o=0;o<t.length;o++){const n=t[o]instanceof Cp?t[o]:Jf(t[o]);i.push(n+e[o+1])}return new Cp(st(i))}function sv(e){return e.replace(/[a-z0-9]+:(?=[a-z0-9]+)/gi,"")}function rv(e){return e.replace(/([a-z0-9]+):(?=[a-z0-9]+)/gi,"$1\\:")}class av{constructor(e){this.value=e}asString(){return hm(String(this.value))}asBool(){return Boolean(Number(this.value))}asNum(){return Number(this.value)}}class lv{constructor(e,t,i){this.currentFile=void 0,this.rootFile=e,this.currentFile=e.file.fileName,this.xlsxFileStructure=t,this.warningManager=i,this.areNamespaceIgnored=null!==(new DOMParser).parseFromString("<t:test xmlns:t='a'/>","text/xml").querySelector("test"),this.relationships={},e.rels&&this.extractRelationships(e.rels).map((e=>{this.relationships[e.id]=e}))}extractRelationships(e){return this.mapOnElements({parent:e.xml,query:"Relationship"},(e=>({id:this.extractAttr(e,"Id",{required:!0}).asString(),target:this.extractAttr(e,"Target",{required:!0}).asString(),type:this.extractAttr(e,"Type",{required:!0}).asString()})))}getListOfFiles(){return Object.values(this.xlsxFileStructure).flat().filter(it)}mapOnElements(e,t){var i;const o=[],n=this.currentFile;let s;if(e.children){const t=null===(i=this.querySelector(e.parent,e.query))||void 0===i?void 0:i.children;s=t||[]}else s=this.querySelectorAll(e.parent,e.query);if(s)for(let e of s)try{o.push(t(e))}catch(t){this.catchErrorOnElement(t,e)}return this.currentFile=n,o}catchErrorOnElement(e,t){const i=t?`Error when parsing an element <${t.tagName}> of file ${this.currentFile}, skip this element. \n${e.stack}`:`Error when parsing file ${this.currentFile}.`;this.warningManager.addParsingWarning([i,e.message].join("\n"))}extractAttr(e,t,i){const o=e.attributes[t];o||this.handleMissingValue(e,`attribute "${t}"`,i);const n=(null==o?void 0:o.value)?o.value:null==i?void 0:i.default;return void 0===n?void 0:new av(n)}extractTextContent(e,t){var i;if(void 0!==(null==t?void 0:t.default)&&"string"!=typeof t.default)throw new Error("extractTextContent default value should be a string");const o="preserve"===(null===(i=null==e?void 0:e.attributes["xml:space"])||void 0===i?void 0:i.value);let n=null==e?void 0:e.textContent;return e&&null!==n||this.handleMissingValue(e,"text content",t),n&&(n=o?n:n.trim()),n?hm(n):null==t?void 0:t.default}extractChildAttr(e,t,i,o){var n;let s;s="number"==typeof t?e.children[t]:this.querySelector(e,t),s||this.handleMissingValue(e,"number"==typeof t?`child at index ${t}`:`child <${t}>`,o);const r=s?null===(n=this.extractAttr(s,i,o))||void 0===n?void 0:n.asString():null==o?void 0:o.default;return void 0!==r?new av(r):void 0}extractChildTextContent(e,t,i){if(void 0!==(null==i?void 0:i.default)&&"string"!=typeof i.default)throw new Error("extractTextContent default value should be a string");let o=this.querySelector(e,t);return o||this.handleMissingValue(e,`child <${t}>`,i),o?this.extractTextContent(o,i):null==i?void 0:i.default}handleMissingValue(e,t,i){if(null==i?void 0:i.required){if(!(null==i?void 0:i.default))throw new Error(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, and no default value was set`);this.warningManager.addParsingWarning(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, replacing it by the default value ${i.default}`)}}extractColor(e,t,i){var o,n,s,r,a;if(!e)return i?{rgb:i}:void 0;const l=null===(o=this.extractAttr(e,"theme"))||void 0===o?void 0:o.asString();let c;if(void 0!==l){if(!t||!t.clrScheme)throw new Error("Color referencing a theme but no theme was provided");c=this.getThemeColor(l,t.clrScheme)}else c=null===(n=this.extractAttr(e,"rgb"))||void 0===n?void 0:n.asString();return{rgb:c,auto:null===(s=this.extractAttr(e,"auto"))||void 0===s?void 0:s.asBool(),indexed:null===(r=this.extractAttr(e,"indexed"))||void 0===r?void 0:r.asNum(),tint:null===(a=this.extractAttr(e,"tint"))||void 0===a?void 0:a.asNum()}}getTargetXmlFile(e){if(!e)throw new Error("Undefined target file");let t=e.target;t=t.replace("../",""),t=t.replace("./","");const i=this.getListOfFiles().find((e=>e.file.fileName.endsWith(t)));if(!i||!i.file)throw new Error("Cannot find target file");return i}querySelector(e,t){return t=this.areNamespaceIgnored?sv(t):rv(t),e.querySelector(t)}querySelectorAll(e,t){return t=this.areNamespaceIgnored?sv(t):rv(t),e.querySelectorAll(t)}getThemeColor(e,t){switch(e){case"0":return"FFFFFF";case"1":return"000000";case"2":return t[3].value;case"3":return t[2].value;default:return t[e].value}}}class cv extends lv{getTheme(){return{clrScheme:this.mapOnElements({query:"a:clrScheme",parent:this.rootFile.file.xml,children:!0},(e=>({name:e.tagName,value:this.extractChildAttr(e,0,"val",{required:!0,default:wp}).asString(),lastClr:this.extractChildAttr(e,0,"lastClr",{default:wp}).asString()})))}}getSharedStrings(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"si"},(e=>"t"===e.children[0].tagName?this.extractTextContent(e)||"":this.mapOnElements({parent:e,query:"t"},(e=>this.extractTextContent(e)||"")).join("")))}}class hv extends lv{constructor(e,t,i,o){super(e,t,i),this.theme=o}extractConditionalFormattings(){const e=this.mapOnElements({parent:this.rootFile.file.xml,query:"worksheet > conditionalFormatting"},(e=>{var t;return{sqref:this.extractAttr(e,"sqref",{required:!0}).asString().split(" "),pivot:null===(t=this.extractAttr(e,"pivot"))||void 0===t?void 0:t.asBool(),cfRules:this.extractCFRules(e,this.theme)}}));return e.push(...this.mapOnElements({parent:this.rootFile.file.xml,query:"extLst x14:conditionalFormatting"},(e=>{var t;return{sqref:this.extractChildTextContent(e,"xm:sqref",{required:!0}).split(" "),pivot:null===(t=this.extractAttr(e,"xm:pivot"))||void 0===t?void 0:t.asBool(),cfRules:this.extractCFRules(e,this.theme)}}))),e}extractCFRules(e,t){return this.mapOnElements({parent:e,query:"cfRule, x14:cfRule"},(e=>{var i,o,n,s,r,a,l,c,h,d,u;const g=this.extractAttr(e,"type",{required:!0}).asString();if("dataBar"===g)throw new Error("Databars conditional formats are not supported.");return{type:g,priority:this.extractAttr(e,"priority",{required:!0}).asNum(),colorScale:this.extractCfColorScale(e,t),formula:this.extractCfFormula(e),iconSet:this.extractCfIconSet(e),dxfId:null===(i=this.extractAttr(e,"dxfId"))||void 0===i?void 0:i.asNum(),stopIfTrue:null===(o=this.extractAttr(e,"stopIfTrue"))||void 0===o?void 0:o.asBool(),aboveAverage:null===(n=this.extractAttr(e,"aboveAverage"))||void 0===n?void 0:n.asBool(),percent:null===(s=this.extractAttr(e,"percent"))||void 0===s?void 0:s.asBool(),bottom:null===(r=this.extractAttr(e,"bottom"))||void 0===r?void 0:r.asBool(),operator:null===(a=this.extractAttr(e,"operator"))||void 0===a?void 0:a.asString(),text:null===(l=this.extractAttr(e,"text"))||void 0===l?void 0:l.asString(),timePeriod:null===(c=this.extractAttr(e,"timePeriod"))||void 0===c?void 0:c.asString(),rank:null===(h=this.extractAttr(e,"rank"))||void 0===h?void 0:h.asNum(),stdDev:null===(d=this.extractAttr(e,"stdDev"))||void 0===d?void 0:d.asNum(),equalAverage:null===(u=this.extractAttr(e,"equalAverage"))||void 0===u?void 0:u.asBool()}}))}extractCfFormula(e){return this.mapOnElements({parent:e,query:"formula"},(e=>this.extractTextContent(e,{required:!0})))}extractCfColorScale(e,t){const i=this.querySelector(e,"colorScale");if(i)return{colors:this.mapOnElements({parent:i,query:"color"},(e=>this.extractColor(e,t,"ffffff"))),cfvos:this.extractCFVos(i)}}extractCfIconSet(e){var t,i;const o=this.querySelector(e,"iconSet, x14:iconSet");if(o)return{iconSet:this.extractAttr(o,"iconSet",{default:"3TrafficLights1"}).asString(),showValue:this.extractAttr(o,"showValue",{default:!0}).asBool(),percent:this.extractAttr(o,"percent",{default:!0}).asBool(),reverse:null===(t=this.extractAttr(o,"reverse"))||void 0===t?void 0:t.asBool(),custom:null===(i=this.extractAttr(o,"custom"))||void 0===i?void 0:i.asBool(),cfvos:this.extractCFVos(o),cfIcons:this.extractCfIcons(o)}}extractCfIcons(e){const t=this.mapOnElements({parent:e,query:"cfIcon, x14:cfIcon"},(e=>({iconSet:this.extractAttr(e,"iconSet",{required:!0}).asString(),iconId:this.extractAttr(e,"iconId",{required:!0}).asNum()})));return 0===t.length?void 0:t}extractCFVos(e){return this.mapOnElements({parent:e,query:"cfvo, x14:cfvo"},(e=>{var t,i;return{type:this.extractAttr(e,"type",{required:!0}).asString(),gte:null===(t=this.extractAttr(e,"gte",{default:!0}))||void 0===t?void 0:t.asBool(),value:e.attributes.val?null===(i=this.extractAttr(e,"val"))||void 0===i?void 0:i.asString():this.extractChildTextContent(e,"f, xm:f")}}))}}class dv extends lv{extractChart(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"c:chartSpace"},(e=>{const t=this.getChartType(e);if(!em[t])throw new Error(`Unsupported chart type ${t}`);const i=this.mapOnElements({parent:e,query:"c:title a:t"},(e=>e.textContent||"")).join(""),o=this.extractChildAttr(e,"c:grouping","val",{default:"clustered"}).asString();return{title:i,type:em[t],dataSets:this.extractChartDatasets(this.querySelector(e,`c:${t}`)),backgroundColor:this.extractChildAttr(e,"c:chartSpace > c:spPr a:srgbClr","val",{default:"ffffff"}).asString(),verticalAxisPosition:"r"===this.extractChildAttr(e,"c:valAx > c:axPos","val",{default:"l"}).asString()?"right":"left",legendPosition:Jp[this.extractChildAttr(e,"c:legendPos","val",{default:"b"}).asString()],stacked:"stacked"===o,fontColor:"000000"}}))[0]}extractChartDatasets(e){return this.mapOnElements({parent:e,query:"c:ser"},(e=>({label:this.extractChildTextContent(e,"c:cat c:f"),range:this.extractChildTextContent(e,"c:val c:f",{required:!0})})))}getChartType(e){const t=this.querySelector(e,"c:plotArea");if(!t)throw new Error("Missing plot area in the chart definition.");for(let e of t.children){const t=sv(e.tagName);if(Ep.some((e=>e===t)))return t}throw new Error("Unknown chart type")}}class uv extends lv{extractFigures(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"xdr:wsDr",children:!0},(e=>{if("twoCellAnchor"!==sv(e.tagName))throw new Error("Only twoCellAnchor are supported for xlsx drawings.");const t=this.querySelector(e,"c:chart");if(!t)throw new Error("Only chart figures are currently supported.");return{anchors:[this.extractFigureAnchor("xdr:from",e),this.extractFigureAnchor("xdr:to",e)],data:this.extractChart(t)}}))}extractFigureAnchor(e,t){const i=this.querySelector(t,e);if(!i)throw new Error(`Missing anchor element ${e}`);return{col:Number(this.extractChildTextContent(i,"xdr:col",{required:!0})),colOffset:Number(this.extractChildTextContent(i,"xdr:colOff",{required:!0})),row:Number(this.extractChildTextContent(i,"xdr:row",{required:!0})),rowOffset:Number(this.extractChildTextContent(i,"xdr:rowOff",{required:!0}))}}extractChart(e){const t=this.extractAttr(e,"r:id",{required:!0}).asString(),i=this.getTargetXmlFile(this.relationships[t]),o=new dv(i,this.xlsxFileStructure,this.warningManager).extractChart();if(!o)throw new Error("Unable to extract chart definition");return o}}class gv extends lv{getPivotTable(){return this.mapOnElements({query:":root",parent:this.rootFile.file.xml},(e=>({displayName:this.extractAttr(e,"name",{required:!0}).asString(),id:this.extractAttr(e,"name",{required:!0}).asString(),ref:this.extractChildAttr(e,"location","ref",{required:!0}).asString(),headerRowCount:this.extractChildAttr(e,"location","firstDataRow",{default:0}).asNum(),totalsRowCount:1,cols:[],style:{showFirstColumn:!0,showRowStripes:!0}})))[0]}}class pv extends lv{getTable(){return this.mapOnElements({query:"table",parent:this.rootFile.file.xml},(e=>{var t;return{displayName:this.extractAttr(e,"displayName",{required:!0}).asString(),name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),id:this.extractAttr(e,"id",{required:!0}).asString(),ref:this.extractAttr(e,"ref",{required:!0}).asString(),headerRowCount:this.extractAttr(e,"headerRowCount",{default:1}).asNum(),totalsRowCount:this.extractAttr(e,"totalsRowCount",{default:0}).asNum(),cols:this.extractTableCols(e),style:this.extractTableStyleInfo(e),autoFilter:this.extractTableAutoFilter(e)}}))[0]}extractTableCols(e){return this.mapOnElements({query:"tableColumn",parent:e},(e=>({id:this.extractAttr(e,"id",{required:!0}).asString(),name:this.extractAttr(e,"name",{required:!0}).asString(),colFormula:this.extractChildTextContent(e,"calculatedColumnFormula")})))}extractTableStyleInfo(e){return this.mapOnElements({query:"tableStyleInfo",parent:e},(e=>{var t,i,o,n,s;return{name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),showFirstColumn:null===(i=this.extractAttr(e,"showFirstColumn"))||void 0===i?void 0:i.asBool(),showLastColumn:null===(o=this.extractAttr(e,"showLastColumn"))||void 0===o?void 0:o.asBool(),showRowStripes:null===(n=this.extractAttr(e,"showRowStripes"))||void 0===n?void 0:n.asBool(),showColumnStripes:null===(s=this.extractAttr(e,"showColumnStripes"))||void 0===s?void 0:s.asBool()}}))[0]}extractTableAutoFilter(e){return this.mapOnElements({query:"autoFilter",parent:e},(e=>({columns:this.extractFilterColumns(e),zone:this.extractAttr(e,"ref",{required:!0}).asString()})))[0]}extractFilterColumns(e){return this.mapOnElements({query:"tableColumn",parent:e},(t=>({colId:this.extractAttr(e,"colId",{required:!0}).asNum(),hiddenButton:this.extractAttr(e,"hiddenButton",{default:!1}).asBool(),filters:this.extractSimpleFilter(t)})))}extractSimpleFilter(e){return this.mapOnElements({query:"filter",parent:e},(e=>({val:this.extractAttr(e,"val",{required:!0}).asString()})))}}class mv extends lv{constructor(e,t,i,o){super(e,t,i),this.theme=o}getSheet(){return this.mapOnElements({query:"worksheet",parent:this.rootFile.file.xml},(e=>{const t=this.getSheetWorkbookInfo();return{sheetName:this.extractSheetName(),sheetViews:this.extractSheetViews(e),sheetFormat:this.extractSheetFormat(e),cols:this.extractCols(e),rows:this.extractRows(e),sharedFormulas:this.extractSharedFormulas(e),merges:this.extractMerges(e),cfs:this.extractConditionalFormats(),figures:this.extractFigures(e),hyperlinks:this.extractHyperLinks(e),tables:[...this.extractTables(e),...this.extractPivotTables()],isVisible:"visible"===t.state}}))[0]}extractSheetViews(e){return this.mapOnElements({parent:e,query:"sheetView"},(e=>{const t=this.querySelector(e,"pane");return{tabSelected:this.extractAttr(e,"tabSelected",{default:!1}).asBool(),showFormulas:this.extractAttr(e,"showFormulas",{default:!1}).asBool(),showGridLines:this.extractAttr(e,"showGridLines",{default:!0}).asBool(),showRowColHeaders:this.extractAttr(e,"showRowColHeaders",{default:!0}).asBool(),pane:{xSplit:t?this.extractAttr(t,"xSplit",{default:0}).asNum():0,ySplit:t?this.extractAttr(t,"ySplit",{default:0}).asNum():0}}}))}extractSheetName(){const e=am(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id;for(let e of this.querySelectorAll(this.xlsxFileStructure.workbook.file.xml,"sheet"))if(e.attributes["r:id"].value===t)return e.attributes.name.value;throw new Error("Missing sheet name")}getSheetWorkbookInfo(){const e=am(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id,i=this.mapOnElements({parent:this.xlsxFileStructure.workbook.file.xml,query:"sheet"},(e=>({relationshipId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetId:this.extractAttr(e,"sheetId",{required:!0}).asString(),sheetName:this.extractAttr(e,"name",{required:!0}).asString(),state:this.extractAttr(e,"state",{default:"visible"}).asString()}))).find((e=>e.relationshipId===t));if(!i)throw new Error("Cannot find corresponding workbook sheet");return i}extractConditionalFormats(){return new hv(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractConditionalFormattings()}extractFigures(e){return this.mapOnElements({parent:e,query:"drawing"},(e=>{var t;const i=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),o=this.getTargetXmlFile(this.relationships[i]);return new uv(o,this.xlsxFileStructure,this.warningManager).extractFigures()}))[0]||[]}extractTables(e){return this.mapOnElements({query:"tablePart",parent:e},(e=>{var t;const i=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),o=this.getTargetXmlFile(this.relationships[i]);return new pv(o,this.xlsxFileStructure,this.warningManager).getTable()}))}extractPivotTables(){try{return Object.values(this.relationships).filter((e=>e.type.endsWith("pivotTable"))).map((e=>{const t=this.getTargetXmlFile(e);return new gv(t,this.xlsxFileStructure,this.warningManager).getPivotTable()}))}catch(e){return this.catchErrorOnElement(e),[]}}extractMerges(e){return this.mapOnElements({parent:e,query:"mergeCell"},(e=>this.extractAttr(e,"ref",{required:!0}).asString()))}extractSheetFormat(e){const t=this.querySelector(e,"sheetFormatPr");if(t)return{defaultColWidth:this.extractAttr(t,"defaultColWidth",{default:_p.toString()}).asNum(),defaultRowHeight:this.extractAttr(t,"defaultRowHeight",{default:Fp.toString()}).asNum()}}extractCols(e){return this.mapOnElements({parent:e,query:"cols col"},(e=>{var t,i,o,n,s,r,a;return{width:null===(t=this.extractAttr(e,"width"))||void 0===t?void 0:t.asNum(),customWidth:null===(i=this.extractAttr(e,"customWidth"))||void 0===i?void 0:i.asBool(),bestFit:null===(o=this.extractAttr(e,"bestFit"))||void 0===o?void 0:o.asBool(),hidden:null===(n=this.extractAttr(e,"hidden"))||void 0===n?void 0:n.asBool(),min:null===(s=this.extractAttr(e,"min",{required:!0}))||void 0===s?void 0:s.asNum(),max:null===(r=this.extractAttr(e,"max",{required:!0}))||void 0===r?void 0:r.asNum(),styleIndex:null===(a=this.extractAttr(e,"style"))||void 0===a?void 0:a.asNum()}}))}extractRows(e){return this.mapOnElements({parent:e,query:"sheetData row"},(e=>{var t,i,o,n,s;return{index:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asNum(),cells:this.extractCells(e),height:null===(i=this.extractAttr(e,"ht"))||void 0===i?void 0:i.asNum(),customHeight:null===(o=this.extractAttr(e,"customHeight"))||void 0===o?void 0:o.asBool(),hidden:null===(n=this.extractAttr(e,"hidden"))||void 0===n?void 0:n.asBool(),styleIndex:null===(s=this.extractAttr(e,"s"))||void 0===s?void 0:s.asNum()}}))}extractCells(e){return this.mapOnElements({parent:e,query:"c"},(e=>{var t,i,o;return{xc:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asString(),styleIndex:null===(i=this.extractAttr(e,"s"))||void 0===i?void 0:i.asNum(),type:Zp[null===(o=this.extractAttr(e,"t",{default:"n"}))||void 0===o?void 0:o.asString()],value:this.extractChildTextContent(e,"v"),formula:this.extractCellFormula(e)}}))}extractCellFormula(e){var t,i;const o=this.querySelector(e,"f");if(o)return{content:this.extractTextContent(o),sharedIndex:null===(t=this.extractAttr(o,"si"))||void 0===t?void 0:t.asNum(),ref:null===(i=this.extractAttr(o,"ref"))||void 0===i?void 0:i.asString()}}extractHyperLinks(e){return this.mapOnElements({parent:e,query:"hyperlink"},(e=>{var t,i,o,n;const s=null===(t=this.extractAttr(e,"r:id"))||void 0===t?void 0:t.asString();return{xc:null===(i=this.extractAttr(e,"ref",{required:!0}))||void 0===i?void 0:i.asString(),location:null===(o=this.extractAttr(e,"location"))||void 0===o?void 0:o.asString(),display:null===(n=this.extractAttr(e,"display"))||void 0===n?void 0:n.asString(),relTarget:s?this.relationships[s].target:void 0}}))}extractSharedFormulas(e){const t=this.querySelectorAll(e,"f[si][ref]"),i={};for(let e of t){const t=this.extractAttr(e,"si",{required:!0}).asNum(),o=this.extractTextContent(e,{required:!0});i[t]=o}const o=[];for(let e=0;e<Object.keys(i).length;e++)i[e]?o.push(i[e]):(this.warningManager.addParsingWarning(`Missing shared formula ${e}, replacing it by empty formula`),o.push(""));return o}}class fv extends lv{constructor(e,t,i){super(e.styles,e,t),this.theme=i}getNumFormats(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"numFmt"},(e=>this.extractNumFormats(e)))}extractNumFormats(e){return{id:this.extractAttr(e,"numFmtId",{required:!0}).asNum(),format:this.extractAttr(e,"formatCode",{required:!0,default:""}).asString()}}getFonts(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"font"},(e=>this.extractFont(e)))}extractFont(e){var t,i,o,n;const s=this.extractChildAttr(e,"name","val",{default:"Arial"}).asString(),r=this.extractChildAttr(e,"sz","val",{default:q.toString()}).asNum(),a=this.extractColor(this.querySelector(e,"color"),this.theme),l=this.querySelector(e,"i")||void 0,c=l&&"0"!==(null===(t=l.attributes.val)||void 0===t?void 0:t.value),h=this.querySelector(e,"b")||void 0,d=h&&"0"!==(null===(i=h.attributes.val)||void 0===i?void 0:i.value),u=this.querySelector(e,"strike")||void 0,g=u&&"0"!==(null===(o=u.attributes.val)||void 0===o?void 0:o.value),p=this.querySelector(e,"u")||void 0;return{name:s,size:r,color:a,italic:c,bold:d,underline:p&&"none"!==(null===(n=p.attributes.val)||void 0===n?void 0:n.value),strike:g}}getFills(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"fill"},(e=>this.extractFill(e)))}extractFill(e){var t;const i=e.children[0];return"patternFill"===i.tagName?{patternType:null===(t=i.attributes.patternType)||void 0===t?void 0:t.value,bgColor:this.extractColor(this.querySelector(i,"bgColor"),this.theme),fgColor:this.extractColor(this.querySelector(i,"fgColor"),this.theme)}:{patternType:"solid",fgColor:this.extractColor(this.querySelectorAll(i,"color")[1],this.theme)}}getBorders(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"border"},(e=>this.extractBorder(e)))}extractBorder(e){var t,i;const o={left:this.extractSingleBorder(e,"left",this.theme),right:this.extractSingleBorder(e,"right",this.theme),top:this.extractSingleBorder(e,"top",this.theme),bottom:this.extractSingleBorder(e,"bottom",this.theme),diagonal:this.extractSingleBorder(e,"diagonal",this.theme)};return o.diagonal&&(o.diagonalUp=null===(t=this.extractAttr(e,"diagonalUp"))||void 0===t?void 0:t.asBool(),o.diagonalDown=null===(i=this.extractAttr(e,"diagonalDown"))||void 0===i?void 0:i.asBool()),o}extractSingleBorder(e,t,i){const o=this.querySelector(e,t);if(o&&o.attributes.style)return{style:this.extractAttr(o,"style",{required:!0,default:"thin"}).asString(),color:this.extractColor(o.children[0],i,"000000")}}extractAlignment(e){var t,i,o,n,s,r,a;return{horizontal:this.extractAttr(e,"horizontal",{default:"general"}).asString(),vertical:this.extractAttr(e,"vertical",{default:"center"}).asString(),textRotation:null===(t=this.extractAttr(e,"textRotation"))||void 0===t?void 0:t.asNum(),wrapText:null===(i=this.extractAttr(e,"wrapText"))||void 0===i?void 0:i.asBool(),indent:null===(o=this.extractAttr(e,"indent"))||void 0===o?void 0:o.asNum(),relativeIndent:null===(n=this.extractAttr(e,"relativeIndent"))||void 0===n?void 0:n.asNum(),justifyLastLine:null===(s=this.extractAttr(e,"justifyLastLine"))||void 0===s?void 0:s.asBool(),shrinkToFit:null===(r=this.extractAttr(e,"shrinkToFit"))||void 0===r?void 0:r.asBool(),readingOrder:null===(a=this.extractAttr(e,"readingOrder"))||void 0===a?void 0:a.asNum()}}getDxfs(){return this.mapOnElements({query:"dxf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"font"),i=this.querySelector(e,"fill"),o=this.querySelector(e,"border"),n=this.querySelector(e,"numFmt"),s=this.querySelector(e,"alignment");return{font:t?this.extractFont(t):void 0,fill:i?this.extractFill(i):void 0,numFmt:n?this.extractNumFormats(n):void 0,alignment:s?this.extractAlignment(s):void 0,border:o?this.extractBorder(o):void 0}}))}getStyles(){return this.mapOnElements({query:"cellXfs xf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"alignment");return{fontId:this.extractAttr(e,"fontId",{required:!0,default:0}).asNum(),fillId:this.extractAttr(e,"fillId",{required:!0,default:0}).asNum(),borderId:this.extractAttr(e,"borderId",{required:!0,default:0}).asNum(),numFmtId:this.extractAttr(e,"numFmtId",{required:!0,default:0}).asNum(),alignment:t?this.extractAlignment(t):void 0}}))}}class vv extends lv{getExternalBook(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"externalBook"},(e=>({rId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetNames:this.mapOnElements({parent:e,query:"sheetName"},(e=>this.extractAttr(e,"val",{required:!0}).asString())),datasets:this.extractExternalSheetData(e)})))[0]}extractExternalSheetData(e){return this.mapOnElements({parent:e,query:"sheetData"},(e=>{const t=this.mapOnElements({parent:e,query:"cell"},(e=>({xc:this.extractAttr(e,"r",{required:!0}).asString(),value:this.extractChildTextContent(e,"v",{required:!0})}))),i={};for(let e of t)i[e.xc]=e.value;return{sheetId:this.extractAttr(e,"sheetId",{required:!0}).asNum(),data:i}}))}}function bv(e,t){const i=function(e,t){const i=t[Vp],o=i.querySelectorAll(`Override[ContentType="${e}"]`),n=[];for(let e of o){const t=null==e?void 0:e.attributes.PartName.value;n.push(t.substring(1))}return n}(e,t);return function(e,t){const i=[];for(let o of e){const e=Sv(o,t);i.push({file:{fileName:o,xml:t[o]},rels:e?{fileName:e,xml:t[e]}:void 0})}return i}(i,t)}function Sv(e,t){if(e===Vp)return"_rels/.rels";let i="";const o=e.split("/");for(let e=0;e<o.length-1;e++)i+=o[e]+"/";return i+="_rels/",i+=o[o.length-1]+".rels",t[i]||(i=void 0),i}class Cv{constructor(e){this.warningManager=new Bp,this.xmls={};for(let t of Object.keys(e))(t.endsWith(".xml")||t.endsWith(".rels"))&&(this.xmls[t]=tv(new Cp(e[t])))}convertXlsx(){const e=this.getXlsxData();return this.convertImportedData(e)}getXlsxData(){const e=this.buildXlsxFileStructure(),t=e.theme?new cv(e.theme,e,this.warningManager).getTheme():void 0,i=e.sharedStrings?new cv(e.sharedStrings,e,this.warningManager).getSharedStrings():[],o=e.sheets.sort(((e,t)=>e.file.fileName.localeCompare(t.file.fileName,void 0,{numeric:!0}))).map((i=>new mv(i,e,this.warningManager,t).getSheet())),n=e.externalLinks.map((t=>new vv(t,e,this.warningManager).getExternalBook())),s=new fv(e,this.warningManager,t);return{fonts:s.getFonts(),fills:s.getFills(),borders:s.getBorders(),dxfs:s.getDxfs(),numFmts:s.getNumFormats(),styles:s.getStyles(),sheets:o,sharedStrings:i,externalBooks:n}}buildXlsxFileStructure(){const e={sheets:bv(Tp.sheet,this.xmls),workbook:bv(Tp.workbook,this.xmls)[0],styles:bv(Tp.styles,this.xmls)[0],sharedStrings:bv(Tp.sharedStrings,this.xmls)[0],theme:bv(Tp.themes,this.xmls)[0],charts:bv(Tp.chart,this.xmls),figures:bv(Tp.drawing,this.xmls),tables:bv(Tp.table,this.xmls),pivots:bv(Tp.pivot,this.xmls),externalLinks:bv(Tp.externalLink,this.xmls)};if(!e.workbook.rels)throw Error(s("Cannot find workbook relations file"));return e}convertImportedData(e){const t={version:12,sheets:Bf(e,this.warningManager),styles:mm(e,this.warningManager),formats:vm(e,this.warningManager),borders:gm(e,this.warningManager),entities:{},revisionId:Q};return Xf(t,e),Object.keys(e.styles).map((t=>{e.styles[t]=dt(e.styles[t])})),t}}function Ev(e){const t=cf(e);let i=[];return{text:"".concat(...t.map((e=>{if("REFERENCE"===e.type&&Ot.test(e.value)){const t=e.value.trim();return i.includes(t)||i.push(t),`${ae}${i.indexOf(t)}${ae}`}return e.value}))),dependencies:i}}const wv=12,yv="Sheet1";function xv(e,t){if(!e)return Mv();if(e["[Content_Types].xml"]){const i=new Cv(e);if(e=i.convertXlsx(),t)for(let e of i.warningManager.warnings.sort())console.warn(e)}return"version"in(e=_e(e))&&e.version<wv&&(e=function(e){for(let t=Iv.findIndex((t=>t.from===e.version));t<Iv.length;t++)e=Iv[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,i=new Vi;for(const o of e.sheets||[])for(const e of o.figures||[])t.has(e.id)&&(e.id+=i.uuidv4()),t.add(e.id);return e.uniqueFigureIds=!0,e}(e),e=function(e){e=Object.assign(Mv(),e,{version:wv}),e.sheets=e.sheets?e.sheets.map(((e,t)=>Object.assign(Av(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===e.sheets.length&&e.sheets.push(Av(yv,"Sheet1"));return e}(e),e}(e),e}const Iv=[{description:"add the `activeSheet` field on data",from:1,to:2,applyMigration:e=>(e.sheets&&e.sheets[0]&&(e.activeSheet=e.sheets[0].name),e)},{description:"add an id field in each sheet",from:2,to:3,applyMigration(e){if(e.sheets&&e.sheets.length)for(let t of e.sheets)t.id=t.id||t.name;return e}},{description:"activeSheet is now an id, not the name of a sheet",from:3,to:4,applyMigration(e){if(e.sheets&&e.activeSheet){const t=e.sheets.find((t=>t.name===e.activeSheet));e.activeSheet=t.id}return e}},{description:"add figures object in each sheets",from:4,to:5,applyMigration(e){for(let t of e.sheets||[])t.figures=t.figures||[];return e}},{description:"normalize the content of the cell if it is a formula to avoid parsing all the formula that vary only by the cells they use",from:5,to:6,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const i=t.cells[e];i.content&&i.content.startsWith("=")&&(i.formula=Ev(i.content))}return e}},{description:"transform chart data structure",from:6,to:7,applyMigration(e){for(let t of e.sheets||[])for(let e in t.figures||[]){const{dataSets:i,...o}=t.figures[e].data,n=[];for(let e of i)if(e.labelCell){const t=Bi(e.dataRange),i=e.labelCell+":"+qt(t.right,t.bottom);n.push(i)}else n.push(e.dataRange);o.dataSetsHaveTitle=Boolean(i[0].labelCell),o.dataSets=n,t.figures[e].data=o}return e}},{description:"remove single quotes in sheet names",from:7,to:8,applyMigration(e){var t;const i=[],o=new RegExp(re,"g");for(let n of e.sheets||[]){if(!n.name)continue;const e=n.name,s=e.replace(o,"_");let r=1,a=s;for(;i.includes(a);)a=`${s}${r}`,r++;n.name=a,i.push(a);const l=t=>{if(void 0===t)return t;let i=t.replace(e,a),o=t;for(;o!==i;)o=i,i=o.replace(e,a);return o};for(let e in n.cells){const t=n.cells[e];t.formula&&(t.formula.dependencies=t.formula.dependencies.map(l))}for(let e of n.figures||[])if("chart"===e.type){const t=e.data.dataSets.map(l),i=l(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:i}}for(let e of n.conditionalFormats||[]){e.ranges=e.ranges.map(l);for(const i of["minimum","maximum","midpoint","upperInflectionPoint","lowerInflectionPoint"])"formula"===(null===(t=e.rule[i])||void 0===t?void 0:t.type)&&(e.rule[i].value=l(e.rule[i].value))}}return e}},{description:"transform chart data structure with design attributes",from:8,to:9,applyMigration(e){for(const t of e.sheets||[])for(const e of t.figures||[])e.data.background=w,e.data.verticalAxisPosition="left",e.data.legendPosition="top",e.data.stacked=!1;return e}},{description:"de-normalize formula to reduce exported json size (~30%)",from:9,to:10,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const i=t.cells[e];if(i.formula){let{text:e,dependencies:t}=i.formula;for(let[i,o]of Object.entries(t)){const t=`\\${ae}${i}\\${ae}`;e=e.replace(new RegExp(t,"g"),o)}i.content=e,delete i.formula}}return e}},{description:"normalize the formats of the cells",from:10,to:11,applyMigration(e){const t={};for(let i of e.sheets||[])for(let e in i.cells||[]){const o=i.cells[e];o.format&&(o.format=nt(o.format,t))}return e.formats=t,e}},{description:"Add isVisible to sheets",from:11,to:12,applyMigration(e){for(let t of e.sheets||[])t.isVisible=!0;return e}}];function Rv(e,t){return t=function(e,t){if(0!==Object.keys(e).length)return t;const i=[],o=[],n=e=>{if("CREATE_SHEET"===e.type)i.push(e.sheetId);else if("sheetId"in e&&!i.includes(e.sheetId))return{...e,sheetId:yv};return e};for(const e of t)"REMOTE_REVISION"===e.type?o.push({...e,commands:e.commands.map(n)}):o.push(e);return o}(e,t),t=Tv(t,"SORT_CELLS"),t=function(e,t){var i;const o=[],n={};for(const t of e.sheets||[])null===(i=t.figures)||void 0===i||i.forEach((e=>{"chart"===e.tag&&(n[e.id]=e.data)}));for(const e of t)if("REMOTE_REVISION"===e.type){const t=[];for(const i of e.commands){let e=i;switch(i.type){case"CREATE_CHART":n[i.id]=i.definition;break;case"UPDATE_CHART":if(!n[i.id]){console.log(`Fix chart definition: chart with id ${i.id} not found.`);continue}const t={...n[i.id],...i.definition};e={...i,definition:t},n[i.id]=t}t.push(e)}o.push({...e,commands:t})}else o.push(e);return o}(e,t=Tv(t,"SET_DECIMAL")),t}function Tv(e,t){const i=[];for(const o of e)"REMOTE_REVISION"===o.type?i.push({...o,commands:o.commands.filter((e=>e.type!==t))}):i.push(o);return i}function Av(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[],filterTables:[],isVisible:!0}}function Mv(e="Sheet1"){return{version:wv,sheets:[Av(yv,e)],entities:{},styles:{},formats:{},borders:{},revisionId:Q,uniqueFigureIds:!0}}function Ov(e,t){return{...Av(e,t),charts:[],images:[]}}class Nv{constructor(e,t){this.history=Object.assign(Object.create(e),{update:e.addChange.bind(e,this),selectCell:()=>{}}),this.dispatch=t}exportForExcel(e){}allowDispatch(e){return 0}beforeHandle(e){}handle(e){}finalize(){}batchValidations(...e){return t=>e.map((e=>e.call(this,t))).flat()}chainValidations(...e){return t=>{for(const i of e){let e=i.call(this,t);Array.isArray(e)||(e=[e]);const o=e.filter((e=>0!==e));if(o.length)return o}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}Nv.getters=[];class _v extends Nv{constructor({getters:e,stateObserver:t,range:i,dispatch:o,uuidGenerator:n}){super(t,o),this.range=i,i.addRangeProvider(this.adaptRanges.bind(this)),this.getters=e,this.uuidGenerator=n}import(e){}export(e){}adaptRanges(e,t){}garbageCollectExternalResources(){}}class Fv extends _v{constructor(){super(...arguments),this.borders={}}allowDispatch(e){return"SET_BORDER"===e.type?this.checkBordersUnchanged(e):0}handle(e){switch(e.type){case"ADD_MERGE":for(const t of e.target)this.addBordersToMerge(e.sheetId,t);break;case"DUPLICATE_SHEET":const t=this.borders[e.sheetId];if(t){const i=t.slice().map((e=>null==e?void 0:e.slice().map((e=>({...e})))));this.history.update("borders",e.sheetIdTo,i)}break;case"DELETE_SHEET":const i={...this.borders};delete i[e.sheetId],this.history.update("borders",i);break;case"SET_BORDER":this.setBorder(e.sheetId,e.col,e.row,e.border);break;case"SET_FORMATTING":if(e.border){const t=e.target.map((t=>this.getters.expandZone(e.sheetId,t)));this.setBorders(e.sheetId,t,e.border)}break;case"CLEAR_FORMATTING":this.clearBorders(e.sheetId,e.target);break;case"REMOVE_COLUMNS_ROWS":for(let t of e.elements)"COL"===e.dimension?this.shiftBordersHorizontally(e.sheetId,t+1,-1):this.shiftBordersVertically(e.sheetId,t+1,-1);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumns(e):this.handleAddRows(e)}}handleAddColumns(e){let t,i;"before"===e.position?(this.shiftBordersHorizontally(e.sheetId,e.base,e.quantity,{moveFirstLeftBorder:!0}),t=e.base-1,i=e.base+e.quantity):(this.shiftBordersHorizontally(e.sheetId,e.base+1,e.quantity,{moveFirstLeftBorder:!1}),t=e.base,i=e.base+e.quantity+1),this.ensureColumnBorderContinuity(e.sheetId,t,i)}handleAddRows(e){let t,i;"before"===e.position?(this.shiftBordersVertically(e.sheetId,e.base,e.quantity,{moveFirstTopBorder:!0}),t=e.base-1,i=e.base+e.quantity):(this.shiftBordersVertically(e.sheetId,e.base+1,e.quantity,{moveFirstTopBorder:!1}),t=e.base,i=e.base+e.quantity+1),this.ensureRowBorderContinuity(e.sheetId,t,i)}getCellBorder({sheetId:e,col:t,row:i}){var o,n,s,r,a,l,c,h,d,u,g,p;const m={top:null===(s=null===(n=null===(o=this.borders[e])||void 0===o?void 0:o[t])||void 0===n?void 0:n[i])||void 0===s?void 0:s.horizontal,bottom:null===(l=null===(a=null===(r=this.borders[e])||void 0===r?void 0:r[t])||void 0===a?void 0:a[i+1])||void 0===l?void 0:l.horizontal,left:null===(d=null===(h=null===(c=this.borders[e])||void 0===c?void 0:c[t])||void 0===h?void 0:h[i])||void 0===d?void 0:d.vertical,right:null===(p=null===(g=null===(u=this.borders[e])||void 0===u?void 0:u[t+1])||void 0===g?void 0:g[i])||void 0===p?void 0:p.vertical};return m.bottom||m.left||m.right||m.top?m:null}ensureColumnBorderContinuity(e,t,i){const o=He(t+1,i);for(let n=0;n<this.getters.getNumberRows(e);n++){const s=this.getCellBorder({sheetId:e,col:t,row:n}),r=this.getCellBorder({sheetId:e,col:i,row:n});if(s&&r){const t=this.getCommonSides(s,r);for(let i of o)this.addBorder(e,i,n,t)}}}ensureRowBorderContinuity(e,t,i){const o=He(t+1,i);for(let n=0;n<this.getters.getNumberCols(e);n++){const s=this.getCellBorder({sheetId:e,col:n,row:t}),r=this.getCellBorder({sheetId:e,col:n,row:i});if(s&&r){const t=this.getCommonSides(s,r);for(let i of o)this.addBorder(e,n,i,t)}}}getCommonSides(e,t){const i={};for(let o of["top","bottom","left","right"])e[o]&&e[o]===t[o]&&(i[o]=e[o]);return i}getColumnsWithBorders(e){const t=this.borders[e];return t?Object.keys(t).map((e=>parseInt(e,10))):[]}getRowsRange(e){return this.borders[e]?He(0,this.getters.getNumberRows(e)+1):[]}shiftBordersHorizontally(e,t,i,{moveFirstLeftBorder:o}={}){this.borders[e]&&(i<0&&this.moveBordersOfColumn(e,t,i,"vertical",{destructive:!1}),this.getColumnsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>i<0?e-t:t-e)).forEach((n=>{(n===t&&o||n!==t)&&this.moveBordersOfColumn(e,n,i,"vertical"),this.moveBordersOfColumn(e,n,i,"horizontal")})))}shiftBordersVertically(e,t,i,{moveFirstTopBorder:o}={}){this.borders[e]&&(i<0&&this.moveBordersOfRow(e,t,i,"horizontal",{destructive:!1}),this.getRowsRange(e).filter((e=>e>=t)).sort(((e,t)=>i<0?e-t:t-e)).forEach((n=>{(n===t&&o||n!==t)&&this.moveBordersOfRow(e,n,i,"horizontal"),this.moveBordersOfRow(e,n,i,"vertical")})))}moveBordersOfRow(e,t,i,o,{destructive:n}={destructive:!0}){const s=this.borders[e];s&&this.getColumnsWithBorders(e).forEach((r=>{var a,l,c,h;const d=null===(l=null===(a=s[r])||void 0===a?void 0:a[t+i])||void 0===l?void 0:l[o],u=null===(h=null===(c=s[r])||void 0===c?void 0:c[t])||void 0===h?void 0:h[o];this.history.update("borders",e,r,t+i,o,n?u:u||d),this.history.update("borders",e,r,t,o,void 0)}))}moveBordersOfColumn(e,t,i,o,{destructive:n}={destructive:!0}){const s=this.borders[e];s&&this.getRowsRange(e).forEach((r=>{var a,l,c,h;const d=null===(l=null===(a=s[t+i])||void 0===a?void 0:a[r])||void 0===l?void 0:l[o],u=null===(h=null===(c=s[t])||void 0===c?void 0:c[r])||void 0===h?void 0:h[o];this.history.update("borders",e,t+i,r,o,n?u:u||d),this.history.update("borders",e,t,r,o,void 0)}))}setBorder(e,t,i,o,n=!0){var s,r,a,l,c,h,d,u,g,p,m,f,v,b,S,C;!n&&(null===(l=null===(a=null===(r=null===(s=this.borders)||void 0===s?void 0:s[e])||void 0===r?void 0:r[t])||void 0===a?void 0:a[i])||void 0===l?void 0:l.vertical)||this.history.update("borders",e,t,i,"vertical",null==o?void 0:o.left),!n&&(null===(u=null===(d=null===(h=null===(c=this.borders)||void 0===c?void 0:c[e])||void 0===h?void 0:h[t])||void 0===d?void 0:d[i])||void 0===u?void 0:u.horizontal)||this.history.update("borders",e,t,i,"horizontal",null==o?void 0:o.top),!n&&(null===(f=null===(m=null===(p=null===(g=this.borders)||void 0===g?void 0:g[e])||void 0===p?void 0:p[t+1])||void 0===m?void 0:m[i])||void 0===f?void 0:f.vertical)||this.history.update("borders",e,t+1,i,"vertical",null==o?void 0:o.right),!n&&(null===(C=null===(S=null===(b=null===(v=this.borders)||void 0===v?void 0:v[e])||void 0===b?void 0:b[t])||void 0===S?void 0:S[i+1])||void 0===C?void 0:C.horizontal)||this.history.update("borders",e,t,i+1,"horizontal",null==o?void 0:o.bottom)}clearBorders(e,t){for(let i of t){for(let t=i.top;t<=i.bottom;t++){this.history.update("borders",e,i.right+1,t,"vertical",void 0);for(let o=i.left;o<=i.right;o++)this.history.update("borders",e,o,t,void 0)}for(let t=i.left;t<=i.right;t++)this.history.update("borders",e,t,i.bottom+1,"horizontal",void 0)}}addBorder(e,t,i,o){this.setBorder(e,t,i,{...this.getCellBorder({sheetId:e,col:t,row:i}),...o})}setBorders(e,t,i){if("clear"===i)return this.clearBorders(e,t);for(let o of t){if("h"===i||"hv"===i||"all"===i)for(let t=o.top+1;t<=o.bottom;t++)for(let i=o.left;i<=o.right;i++)this.addBorder(e,i,t,{top:j});if("v"===i||"hv"===i||"all"===i)for(let t=o.top;t<=o.bottom;t++)for(let i=o.left+1;i<=o.right;i++)this.addBorder(e,i,t,{left:j});if("left"===i||"all"===i||"external"===i)for(let t=o.top;t<=o.bottom;t++)this.addBorder(e,o.left,t,{left:j});if("right"===i||"all"===i||"external"===i)for(let t=o.top;t<=o.bottom;t++)this.addBorder(e,o.right+1,t,{left:j});if("top"===i||"all"===i||"external"===i)for(let t=o.left;t<=o.right;t++)this.addBorder(e,t,o.top,{top:j});if("bottom"===i||"all"===i||"external"===i)for(let t=o.left;t<=o.right;t++)this.addBorder(e,t,o.bottom+1,{top:j})}}addBordersToMerge(e,t){const{left:i,right:o,top:n,bottom:s}=t,r=this.getCellBorder({sheetId:e,col:i,row:n}),a=this.getCellBorder({sheetId:e,col:o,row:s});this.clearBorders(e,[t]),(null==r?void 0:r.top)&&this.setBorders(e,[{...t,bottom:n}],"top"),(null==r?void 0:r.left)&&this.setBorders(e,[{...t,right:i}],"left"),((null==a?void 0:a.bottom)||(null==r?void 0:r.bottom))&&this.setBorders(e,[{...t,top:s}],"bottom"),((null==a?void 0:a.right)||(null==r?void 0:r.right))&&this.setBorders(e,[{...t,left:o}],"right")}checkBordersUnchanged(e){var t,i,o,n;const s=this.getCellBorder(e),r=!((null===(t=e.border)||void 0===t?void 0:t.bottom)||(null===(i=e.border)||void 0===i?void 0:i.left)||(null===(o=e.border)||void 0===o?void 0:o.right)||(null===(n=e.border)||void 0===n?void 0:n.top));return!s&&r||ct(s,e.border)?88:0}import(e){if(e.borders)for(let t of e.sheets)for(let[i,o]of Object.entries(t.cells))if(null==o?void 0:o.border){const n=e.borders[o.border],{col:s,row:r}=Gt(i);this.setBorder(t.id,s,r,n,!1)}for(let t of e.sheets)if(t.merges)for(let e of t.merges)this.addBordersToMerge(t.id,Bi(e))}export(e){let t=0;const i={};function o(e){for(let[t,o]of Object.entries(i))if(ct(o,e))return parseInt(t,10);return i[++t]=e,t}for(let t of e.sheets)for(let e=0;e<t.colNumber;e++)for(let i=0;i<t.rowNumber;i++){const n=this.getCellBorder({sheetId:t.id,col:e,row:i});if(n){const s=qt(e,i),r=t.cells[s],a=o(n);r?r.border=a:t.cells[s]={border:a}}}e.borders=i}exportForExcel(e){this.export(e)}}Fv.getters=["getCellBorder"];class Dv extends _v{constructor(){super(...arguments),this.nextId=1,this.cells={}}adaptRanges(e,t){for(const i of Object.keys(this.cells))for(const o of Object.values(this.cells[i]||{}))if(o.isFormula)for(const n of o.dependencies)if(!t||n.sheetId===t){const t=e(n);"NONE"!==t.changeType&&this.history.update("cells",i,o.id,"dependencies",o.dependencies.indexOf(n),t.range)}}allowDispatch(e){switch(e.type){case"UPDATE_CELL":return this.checkCellOutOfSheet(e);case"CLEAR_CELL":return this.checkValidations(e,this.chainValidations(this.checkCellOutOfSheet,this.checkUselessClearCell));default:return 0}}handle(e){switch(e.type){case"SET_FORMATTING":"style"in e&&this.setStyle(e.sheetId,e.target,e.style),"format"in e&&void 0!==e.format&&this.setFormatter(e.sheetId,e.target,e.format);break;case"CLEAR_FORMATTING":this.clearFormatting(e.sheetId,e.target);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumnsRows(e,this.copyColumnStyle.bind(this)):this.handleAddColumnsRows(e,this.copyRowStyle.bind(this));break;case"UPDATE_CELL":this.updateCell(e.sheetId,e.col,e.row,e);break;case"CLEAR_CELL":this.dispatch("UPDATE_CELL",{sheetId:e.sheetId,col:e.col,row:e.row,content:"",style:null,format:""})}}setFormatter(e,t,i){for(let o of t)for(let t=o.top;t<=o.bottom;t++)for(let n=o.left;n<=o.right;n++)this.dispatch("UPDATE_CELL",{sheetId:e,col:n,row:t,format:i})}clearFormatting(e,t){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let o=i.top;o<=i.bottom;o++)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,style:null,format:""})}handleAddColumnsRows(e,t){let i,o;"before"===e.position?(i=He(e.base,e.base+e.quantity),o=e.base+e.quantity):(i=He(e.base+1,e.base+e.quantity+1),o=e.base),t(e.sheetId,o,i)}import(e){for(let t of e.sheets)for(let i in t.cells){const o=t.cells[i],{col:n,row:s}=Gt(i);if((null==o?void 0:o.content)||(null==o?void 0:o.format)||(null==o?void 0:o.style)){const i=this.importCell(t.id,o,e.styles,e.formats);this.history.update("cells",t.id,i.id,i),this.dispatch("UPDATE_CELL_POSITION",{cellId:i.id,col:n,row:s,sheetId:t.id})}}}export(e){const t={},i={};for(let o of e.sheets){const e={},n=Object.keys(this.cells[o.id]||{}).map((e=>this.getters.getCellPosition(e))).sort(((e,t)=>e.col===t.col?e.row-t.row:e.col-t.col));for(const o of n){const n=this.getters.getCell(o);e[qt(o.col,o.row)]={style:n.style?nt(n.style,t):void 0,format:n.format?nt(n.format,i):void 0,content:n.content||void 0}}o.cells=e}e.styles=t,e.formats=i}importCell(e,t,i,o){const n=t.style&&i[t.style]||void 0,s=t.format&&o[t.format]||void 0,r=this.getNextUid();return this.createCell(r,(null==t?void 0:t.content)||"",s,n,e)}exportForExcel(e){this.export(e)}getCells(e){return this.cells[e]||{}}getCellById(e){const t=this.getters.getCellPosition(e);return this.cells[t.sheetId][e]}buildFormulaContent(e,t,i){const o=i||t.dependencies;let n=0;return st(t.compiledFormula.tokens.map((t=>{if("REFERENCE"===t.type){const t=o[n++];return this.getters.getRangeString(t,e)}return t.value})))}getFormulaCellContent(e,t){return this.buildFormulaContent(e,t)}getCellStyle(e){var t;return(null===(t=this.getters.getCell(e))||void 0===t?void 0:t.style)||{}}zoneToXC(e,t,i=[{colFixed:!1,rowFixed:!1}]){const o=qt((t=this.getters.expandZone(e,t)).left,t.top,i[0]),n=qt(t.right,t.bottom,i.length>1?i[1]:i[0]),s=this.getters.getMainCellPosition({sheetId:e,col:t.left,row:t.top}),r=this.getters.getMainCellPosition({sheetId:e,col:t.right,row:t.bottom}),a=s.col===r.col&&s.row===r.row;return o==n||a?o:o+":"+n}setStyle(e,t,i){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let n=o.top;n<=o.bottom;n++){const o=this.getters.getCell({sheetId:e,col:t,row:n});this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:n,style:i?{...null==o?void 0:o.style,...i}:void 0})}}copyColumnStyle(e,t,i){for(let o=0;o<this.getters.getNumberRows(e);o++){const n=this.getFormat(e,t,o);if(n.style||n.format)for(let t of i)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,...n})}}copyRowStyle(e,t,i){for(let o=0;o<this.getters.getNumberCols(e);o++){const n=this.getFormat(e,o,t);if(n.style||n.format)for(let t of i)this.dispatch("UPDATE_CELL",{sheetId:e,col:o,row:t,...n})}}getFormat(e,t,i){const o={},n=this.getters.getMainCellPosition({sheetId:e,col:t,row:i}),s=this.getters.getCell(n);return s&&(s.style&&(o.style=s.style),s.format&&(o.format=s.format)),o}getNextUid(){const e=this.nextId.toString();return this.history.update("nextId",this.nextId+1),e}updateCell(e,t,i,o){const n=this.getters.getCell({sheetId:e,col:t,row:i}),s="content"in o||"formula"in o,r=s?ft(null==o?void 0:o.content):(null==n?void 0:n.content)||"";let a;a=void 0!==o.style?o.style||void 0:n?n.style:void 0;let l=("format"in o?o.format:n&&n.format)||Ri(r);if((s&&!r&&!o.formula||!s&&(!n||""===n.content))&&!a&&!l)return void(n&&(this.history.update("cells",e,n.id,void 0),this.dispatch("UPDATE_CELL_POSITION",{cellId:void 0,col:t,row:i,sheetId:e})));const c=(null==n?void 0:n.id)||this.getNextUid(),h=this.createCell(c,r,l,a,e);this.history.update("cells",e,h.id,h),this.dispatch("UPDATE_CELL_POSITION",{cellId:h.id,col:t,row:i,sheetId:e})}createCell(e,t,i,o,n){if(!t.startsWith("="))return this.createLiteralCell(e,t,i,o);try{return this.createFormulaCell(e,t,i,o,n)}catch(n){return this.createErrorFormula(e,t,i,o,n)}}createLiteralCell(e,t,i,o){return{id:e,content:t,style:o,format:i,isFormula:!1}}createFormulaCell(e,t,i,o,n){const s=pf(t);return s.dependencies.length?this.createFormulaCellWithDependencies(e,s,i,o,n):{id:e,content:t,style:o,format:i,isFormula:!0,compiledFormula:s,dependencies:[]}}createFormulaCellWithDependencies(e,t,i,o,n){const s=t.dependencies.map((e=>this.getters.getRangeFromSheetXC(n,e))),r=this.buildFormulaContent.bind(this);return{id:e,get content(){return r(n,{dependencies:this.dependencies,compiledFormula:this.compiledFormula})},style:o,format:i,isFormula:!0,compiledFormula:t,dependencies:s}}createErrorFormula(e,t,i,o,n){return{id:e,content:t,style:o,format:i,isFormula:!0,compiledFormula:{dependencies:[],tokens:Om(t),execute:function(){throw n}},dependencies:[]}}checkCellOutOfSheet(e){const{sheetId:t,col:i,row:o}=e;if(!this.getters.tryGetSheet(t))return 27;return Qi(i,o,this.getters.getSheetZone(t))?0:18}checkUselessClearCell(e){const t=this.getters.getCell(e);return t&&(t.content||t.style||t.format)?0:88}}Dv.getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];class kv extends _v{constructor(){super(...arguments),this.charts={},this.createChart=function(e){const t=dr.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(i,o,n){const s=t.find((e=>e.match(o.type)));if(!s)throw new Error(`No builder for this chart: ${o.type}`);return s.createChart(o,n,e)}}(this.getters),this.validateChartDefinition=e=>function(e,t){const i=dr.getAll().find((e=>e.match(t.type)));if(!i)throw new Error("Unknown chart type.");return i.validateChartDefinition(e,t)}(this,e.definition)}adaptRanges(e){for(const[t,i]of Object.entries(this.charts))this.history.update("charts",t,null==i?void 0:i.updateRanges(e))}allowDispatch(e){switch(e.type){case"CREATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartDuplicate));case"UPDATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartExists));default:return 0}}handle(e){var t;switch(e.type){case"CREATE_CHART":this.addFigure(e.id,e.sheetId,e.position,e.size),this.addChart(e.id,e.definition);break;case"UPDATE_CHART":this.addChart(e.id,e.definition);break;case"DUPLICATE_SHEET":{const i=this.getters.getFigures(e.sheetId);for(const o of i)if("chart"===o.tag){const i=o.id.split(ee).pop(),n=`${e.sheetIdTo}${ee}${i}`,s=null===(t=this.charts[o.id])||void 0===t?void 0:t.copyForSheetId(e.sheetIdTo);s&&this.dispatch("CREATE_CHART",{id:n,position:{x:o.x,y:o.y},size:{width:o.width,height:o.height},definition:s.getDefinition(),sheetId:e.sheetIdTo})}break}case"DELETE_FIGURE":this.history.update("charts",e.id,void 0);break;case"DELETE_SHEET":for(let t of this.getChartIds(e.sheetId))this.history.update("charts",t,void 0)}}getContextCreationChart(e){var t;return null===(t=this.charts[e])||void 0===t?void 0:t.getContextCreation()}getChart(e){return this.charts[e]}getChartType(e){var t;const i=null===(t=this.charts[e])||void 0===t?void 0:t.type;if(!i)throw new Error("Chart not defined.");return i}isChartDefined(e){return e in this.charts&&void 0!==this.charts}getChartIds(e){return Object.entries(this.charts).filter((([,t])=>(null==t?void 0:t.sheetId)===e)).map((([e])=>e))}getChartDefinition(e){var t;const i=null===(t=this.charts[e])||void 0===t?void 0:t.getDefinition();if(!i)throw new Error(`There is no chart with the given figureId: ${e}`);return i}import(e){for(let t of e.sheets)if(t.figures)for(let e of t.figures)"chart"===e.tag&&(this.charts[e.id]=this.createChart(e.id,e.data,t.id))}export(e){var t;if(e.sheets)for(let i of e.sheets){const e=this.getters.getFigures(i.id),o=[];for(let i of e){const e=i;if(e&&"chart"===e.tag){const i=null===(t=this.charts[e.id])||void 0===t?void 0:t.getDefinition();i&&(e.data=i,o.push(e))}else o.push(e)}i.figures=o}}exportForExcel(e){var t;for(let i of e.sheets){const e=this.getters.getFigures(i.id),o=[];for(let i of e)if(i&&"chart"===i.tag){const e=null===(t=this.charts[i.id])||void 0===t?void 0:t.getDefinitionForExcel();e&&o.push({...i,data:e})}i.charts=o}}addFigure(e,t,i={x:0,y:0},o={width:536,height:335}){if(this.getters.getFigure(t,e))return;const n={id:e,x:i.x,y:i.y,width:o.width,height:o.height,tag:"chart"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:n})}addChart(e,t){const i=this.getters.getFigureSheetId(e);i&&this.history.update("charts",e,this.createChart(e,t,i))}checkChartDuplicate(e){return this.getters.getFigureSheetId(e.id)?84:0}checkChartExists(e){return this.getters.getFigureSheetId(e.id)?0:85}}function Lv(e){return""===e?NaN:Number(e)}kv.getters=["isChartDefined","getChartDefinition","getChartType","getChartIds","getChart","getContextCreationChart"];class Pv extends _v{constructor(){super(...arguments),this.cfRules={}}loopThroughRangesOfSheet(e,t){for(const i of this.cfRules[e])for(const o of i.ranges){const n=t(o);switch(n.changeType){case"REMOVE":let t=i.ranges.slice();t.splice(i.ranges.indexOf(o),1),t.length>=1?this.history.update("cfRules",e,this.cfRules[e].indexOf(i),"ranges",t):this.removeConditionalFormatting(i.id,e);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("cfRules",e,this.cfRules[e].indexOf(i),"ranges",i.ranges.indexOf(o),n.range)}}}adaptRanges(e,t){if(t)this.loopThroughRangesOfSheet(t,e);else for(const t of Object.keys(this.cfRules))this.loopThroughRangesOfSheet(t,e)}allowDispatch(e){switch(e.type){case"ADD_CONDITIONAL_FORMAT":return this.checkValidations(e,this.checkCFRule,this.checkEmptyRange);case"MOVE_CONDITIONAL_FORMAT":return this.checkValidReordering(e.cfId,e.direction,e.sheetId)}return 0}handle(e){switch(e.type){case"CREATE_SHEET":this.cfRules[e.sheetId]=[];break;case"DUPLICATE_SHEET":this.history.update("cfRules",e.sheetIdTo,[]);for(const t of this.getConditionalFormats(e.sheetId))this.addConditionalFormatting(t,e.sheetIdTo);break;case"DELETE_SHEET":const t=Object.assign({},this.cfRules);delete t[e.sheetId],this.history.update("cfRules",t);break;case"ADD_CONDITIONAL_FORMAT":const i={...e.cf,ranges:e.ranges.map((t=>this.getters.getRangeString(this.getters.getRangeFromRangeData(t),e.sheetId)))};this.addConditionalFormatting(i,e.sheetId);break;case"REMOVE_CONDITIONAL_FORMAT":this.removeConditionalFormatting(e.id,e.sheetId);break;case"MOVE_CONDITIONAL_FORMAT":this.reorderConditionalFormatting(e.cfId,e.direction,e.sheetId)}}import(e){for(let t of e.sheets)this.cfRules[t.id]=t.conditionalFormats.map((e=>this.mapToConditionalFormatInternal(t.id,e)))}export(e){if(e.sheets)for(let t of e.sheets)this.cfRules[t.id]&&(t.conditionalFormats=this.cfRules[t.id].map((e=>this.mapToConditionalFormat(t.id,e))))}exportForExcel(e){this.export(e)}getConditionalFormats(e){var t;return(null===(t=this.cfRules[e])||void 0===t?void 0:t.map((t=>this.mapToConditionalFormat(e,t))))||[]}getRulesSelection(e,t){const i=new Set;return t.forEach((t=>{this.getRulesByZone(e,t).forEach((e=>{i.add(e)}))})),Array.from(i)}getRulesByZone(e,t){const i=new Set;for(let o=t.top;o<=t.bottom;o++)for(let n=t.left;n<=t.right;n++){this.getRulesByCell(e,n,o).forEach((e=>{i.add(e.id)}))}return i}getRulesByCell(e,t,i){const o=[];for(let n of this.cfRules[e])for(let e of n.ranges)Qi(t,i,e.zone)&&o.push(n);return new Set(o.map((t=>this.mapToConditionalFormat(e,t))))}mapToConditionalFormat(e,t){return{...t,ranges:t.ranges.map((t=>this.getters.getRangeString(t,e)))}}mapToConditionalFormatInternal(e,t){const i={...t,ranges:t.ranges.map((t=>this.getters.getRangeFromSheetXC(e,t)))};return i}addConditionalFormatting(e,t){const i=this.cfRules[t].slice(),o=i.findIndex((t=>t.id===e.id)),n=this.mapToConditionalFormatInternal(t,e);o>-1?i.splice(o,1,n):i.push(n),this.history.update("cfRules",t,i)}checkValidReordering(e,t,i){if(!this.cfRules[i])return 27;const o=this.cfRules[i].findIndex((t=>t.id===e));if(-1===o)return 71;const n="up"===t?o-1:o+1;return n<0||n>=this.cfRules[i].length?71:0}checkEmptyRange(e){return e.ranges.length?0:24}checkCFRule(e){const t=e.cf.rule;switch(t.type){case"CellIsRule":return this.checkValidations(t,this.checkOperatorArgsNumber(2,["Between","NotBetween"]),this.checkOperatorArgsNumber(1,["BeginsWith","ContainsText","EndsWith","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","NotContains"]),this.checkOperatorArgsNumber(0,["IsEmpty","IsNotEmpty"]));case"ColorScaleRule":return this.checkValidations(t,this.chainValidations(this.checkThresholds(this.checkFormulaCompilation)),this.chainValidations(this.checkThresholds(this.checkNaN),this.batchValidations(this.checkMinBiggerThanMax,this.checkMinBiggerThanMid,this.checkMidBiggerThanMax)));case"IconSetRule":return this.checkValidations(t,this.chainValidations(this.checkInflectionPoints(this.checkNaN),this.checkLowerBiggerThanUpper),this.chainValidations(this.checkInflectionPoints(this.checkFormulaCompilation)))}return 0}checkOperatorArgsNumber(e,t){if(e>2)throw new Error("Checking more than 2 arguments is currently not supported. Add the appropriate CommandResult if you want to.");return i=>{if(t.includes(i.operator)){const t=[],o=e=>void 0===e||""===e;return e>=1&&o(i.values[0])&&t.push(51),e>=2&&o(i.values[1])&&t.push(52),t.length?t:0}return 0}}checkNaN(e,t){if(["number","percentage","percentile"].includes(e.type)&&(""===e.value||isNaN(e.value)))switch(t){case"min":return 53;case"max":return 55;case"mid":return 54;case"upperInflectionPoint":return 56;case"lowerInflectionPoint":return 57}return 0}checkFormulaCompilation(e,t){if("formula"!==e.type)return 0;try{pf(e.value||"")}catch(e){switch(t){case"min":return 58;case"max":return 60;case"mid":return 59;case"upperInflectionPoint":return 61;case"lowerInflectionPoint":return 62}}return 0}checkThresholds(e){return this.batchValidations((t=>e(t.minimum,"min")),(t=>e(t.maximum,"max")),(t=>t.midpoint?e(t.midpoint,"mid"):0))}checkInflectionPoints(e){return this.batchValidations((t=>e(t.lowerInflectionPoint,"lowerInflectionPoint")),(t=>e(t.upperInflectionPoint,"upperInflectionPoint")))}checkLowerBiggerThanUpper(e){const t=e.lowerInflectionPoint.value,i=e.upperInflectionPoint.value;return["number","percentage","percentile"].includes(e.lowerInflectionPoint.type)&&e.lowerInflectionPoint.type===e.upperInflectionPoint.type&&Number(t)>Number(i)?48:0}checkMinBiggerThanMax(e){const t=e.minimum.value,i=e.maximum.value;return["number","percentage","percentile"].includes(e.minimum.type)&&e.minimum.type===e.maximum.type&&Lv(t)>=Lv(i)?47:0}checkMidBiggerThanMax(e){var t;const i=null===(t=e.midpoint)||void 0===t?void 0:t.value,o=e.maximum.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.midpoint.type===e.maximum.type&&Lv(i)>=Lv(o)?49:0}checkMinBiggerThanMid(e){var t;const i=e.minimum.value,o=null===(t=e.midpoint)||void 0===t?void 0:t.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.minimum.type===e.midpoint.type&&Lv(i)>=Lv(o)?50:0}removeConditionalFormatting(e,t){const i=this.cfRules[t].findIndex((t=>t.id===e));if(-1!==i){const e=this.cfRules[t].slice();e.splice(i,1),this.history.update("cfRules",t,e)}}reorderConditionalFormatting(e,t,i){const o=this.cfRules[i].findIndex((t=>t.id===e)),n="up"===t?o-1:o+1;if(!(n<0||n>=this.cfRules[i].length)&&-1!==o&&-1!==n){const e=[...this.cfRules[i]],t=e[o];e[o]=e[n],e[n]=t,this.history.update("cfRules",i,e)}}}Pv.getters=["getConditionalFormats","getRulesSelection","getRulesByCell"];class Uv extends _v{constructor(){super(...arguments),this.figures={}}allowDispatch(e){switch(e.type){case"CREATE_FIGURE":return this.checkFigureDuplicate(e.figure.id);case"UPDATE_FIGURE":case"DELETE_FIGURE":return this.checkFigureExists(e.sheetId,e.id);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":this.figures[e.sheetId]={};break;case"DELETE_SHEET":this.deleteSheet(e.sheetId);break;case"CREATE_FIGURE":this.addFigure(e.figure,e.sheetId);break;case"UPDATE_FIGURE":const{type:t,sheetId:i,...o}=e,n=o;this.updateFigure(i,n);break;case"DELETE_FIGURE":this.removeFigure(e.id,e.sheetId)}}updateFigure(e,t){if("id"in t)for(const[i,o]of Object.entries(t))switch(i){case"x":case"y":void 0!==o&&this.history.update("figures",e,t.id,i,Math.max(o,0));break;case"width":case"height":void 0!==o&&this.history.update("figures",e,t.id,i,o)}}addFigure(e,t){this.history.update("figures",t,e.id,e)}deleteSheet(e){this.history.update("figures",e,void 0)}removeFigure(e,t){this.history.update("figures",t,e,void 0)}checkFigureExists(e,t){var i;return void 0===(null===(i=this.figures[e])||void 0===i?void 0:i[t])?70:0}checkFigureDuplicate(e){return Object.values(this.figures).find((t=>null==t?void 0:t[e]))?82:0}getFigures(e){return Object.values(this.figures[e]||{}).filter(it)}getFigure(e,t){var i;return null===(i=this.figures[e])||void 0===i?void 0:i[t]}getFigureSheetId(e){return Object.keys(this.figures).find((t=>{var i;return void 0!==(null===(i=this.figures[t])||void 0===i?void 0:i[e])}))}import(e){for(let t of e.sheets){const e={};t.figures.forEach((t=>{e[t.id]=t})),this.figures[t.id]=e}}export(e){for(const t of e.sheets)for(const e of this.getFigures(t.id)){const i=void 0;t.figures.push({...e,data:i})}}exportForExcel(e){this.export(e)}}Uv.getters=["getFigures","getFigure","getFigureSheetId"];class Vv{constructor(e){this.filters=[],this.zone=e;const t=new Vi;this.id=t.uuidv4();for(const i of He(e.left,e.right+1)){const e={...this.zone,left:i,right:i};this.filters.push(new zv(t.uuidv4(),e))}}get contentZone(){if(this.zone.bottom!==this.zone.top)return{...this.zone,top:this.zone.top+1}}getFilterId(e){var t;return null===(t=this.filters.find((t=>t.col===e)))||void 0===t?void 0:t.id}clone(){return new Vv(this.zone)}}class zv{constructor(e,t){if(t.left!==t.right)throw new Error("Can only define a filter on a single column");this.id=e,this.zoneWithHeaders=t}get col(){return this.zoneWithHeaders.left}get filteredZone(){const e=this.zoneWithHeaders;if(e.bottom!==e.top)return{...e,top:e.top+1}}}class Bv extends _v{constructor(){super(...arguments),this.tables={}}allowDispatch(e){switch(e.type){case"CREATE_FILTER_TABLE":if(!uo(...e.target))return 81;const t=ji(...e.target),i=()=>this.getFilterTables(e.sheetId).some((e=>Ki(e.zone,t)))?78:0,o=()=>{const i=this.getters.getMergesInZone(e.sheetId,t);for(let e of i)if(Ki(t,e))return 80;return 0};return this.checkValidations(e,i,o);case"ADD_MERGE":for(let t of e.target)for(let i of this.getFilterTables(e.sheetId))if(Ki(i.zone,t))return 80}return 0}handle(e){switch(e.type){case"CREATE_SHEET":this.history.update("tables",e.sheetId,{});break;case"DELETE_SHEET":const t={...this.tables};delete t[e.sheetId],this.history.update("tables",t);break;case"DUPLICATE_SHEET":const i={};for(const t of Object.values(this.tables[e.sheetId]||{}))if(t){const e=_e(t);i[e.id]=e}this.history.update("tables",e.sheetIdTo,i);break;case"ADD_COLUMNS_ROWS":this.onAddColumnsRows(e);break;case"REMOVE_COLUMNS_ROWS":this.onDeleteColumnsRows(e);break;case"CREATE_FILTER_TABLE":{const t=ji(...e.target),i=this.createFilterTable(t);this.history.update("tables",e.sheetId,i.id,i);break}case"REMOVE_FILTER_TABLE":{const t={};for(const i of this.getFilterTables(e.sheetId))e.target.every((e=>!Xi(e,i.zone)))&&(t[i.id]=i);this.history.update("tables",e.sheetId,t);break}case"UPDATE_CELL":{const t=e.sheetId;for(let i of this.getFilterTables(t))this.canUpdateCellCmdExtendTable(e,i)&&this.extendTableDown(t,i);break}}}getFilters(e){return this.getFilterTables(e).map((e=>e.filters)).flat()}getFilterTables(e){return this.tables[e]?Object.values(this.tables[e]).filter(it):[]}getFilter(e){var t;return null===(t=this.getFilterTable(e))||void 0===t?void 0:t.filters.find((t=>t.col===e.col))}getFilterId(e){var t;return null===(t=this.getFilter(e))||void 0===t?void 0:t.id}getFilterTable({sheetId:e,col:t,row:i}){return this.getFilterTables(e).find((e=>Qi(t,i,e.zone)))}getFilterTablesInZone(e,t){return this.getFilterTables(e).filter((e=>Ji(e.zone,t)))}doesZonesContainFilter(e,t){for(const i of t)for(const t of this.getFilterTables(e))if(Xi(i,t.zone))return!0;return!1}onAddColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const i=Wi(t.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),o=[];for(const i of t.filters){const t=Wi(i.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);o.push(new zv(i.id,t))}if(o.length<io(i).numberOfCols){for(let e=i.left;e<=i.right;e++)o.find((t=>t.col===e))||o.push(new zv(this.uuidGenerator.uuidv4(),{...i,left:e,right:e}));o.sort(((e,t)=>e.col-t.col))}this.history.update("tables",e.sheetId,t.id,"zone",i),this.history.update("tables",e.sheetId,t.id,"filters",o)}}onDeleteColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){if("ROW"===e.dimension&&e.elements.includes(t.zone.top)){const i={...this.tables[e.sheetId]};delete i[t.id],this.history.update("tables",e.sheetId,i);continue}const i=Zi(t.zone,"COL"===e.dimension?"left":"top",e.elements);if(i){if($i(i)!==$i(t.zone)){const o=[];for(const i of t.filters){const t=Zi(i.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.elements);t&&o.push(new zv(i.id,t))}this.history.update("tables",e.sheetId,t.id,"zone",i),this.history.update("tables",e.sheetId,t.id,"filters",o)}}else{const i={...this.tables[e.sheetId]};delete i[t.id],this.history.update("tables",e.sheetId,i)}}}createFilterTable(e){return new Vv(e)}extendTableDown(e,t){const i={...t.zone,bottom:t.zone.bottom+1};this.history.update("tables",e,t.id,"zone",i);for(let i=0;i<t.filters.length;i++){const o=t.filters[i],n={...o.zoneWithHeaders,bottom:o.zoneWithHeaders.bottom+1};this.history.update("tables",e,t.id,"filters",i,"zoneWithHeaders",n)}}canUpdateCellCmdExtendTable({content:e,sheetId:t,col:i,row:o},n){var s;if(!e)return;const r=n.zone;if(!(r.bottom+1===o&&i>=r.left&&i<=r.right))return!1;for(const e of He(r.left,r.right+1)){const i={sheetId:t,col:e,row:o};if(null===(s=this.getters.getCell(i))||void 0===s?void 0:s.content)return!1;if(this.getters.getFilter(i))return!1;if(this.getters.isInMerge(i))return!1}return!0}import(e){for(const t of e.sheets)for(const e of t.filterTables||[]){const i=this.createFilterTable(Bi(e.range));this.history.update("tables",t.id,i.id,i)}}export(e){for(const t of e.sheets)for(const e of this.getFilterTables(t.id))t.filterTables.push({range:$i(e.zone)})}exportForExcel(e){this.export(e)}}Bv.getters=["doesZonesContainFilter","getFilter","getFilters","getFilterTable","getFilterTables","getFilterTablesInZone","getFilterId"];class Hv extends _v{constructor(){super(...arguments),this.sizes={}}handle(e){var t,i;switch(e.type){case"CREATE_SHEET":{const t=this.computeSheetSizes(e.sheetId),i={COL:t.COL.map((e=>({manualSize:void 0,computedSize:rt(e)}))),ROW:t.ROW.map((e=>({manualSize:void 0,computedSize:rt(e)})))};this.history.update("sizes",e.sheetId,i);break}case"DUPLICATE_SHEET":for(const t of this.sizes[e.sheetId].ROW)t.computedSize();for(const t of this.sizes[e.sheetId].COL)t.computedSize();this.history.update("sizes",e.sheetIdTo,_e(this.sizes[e.sheetId]));break;case"DELETE_SHEET":const o={...this.sizes};delete o[e.sheetId],this.history.update("sizes",o);break;case"REMOVE_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];for(let i of[...e.elements].sort(((e,t)=>t-e)))t.splice(i,1);const i=Math.min(...e.elements);t=t.map(((t,o)=>"ROW"===e.dimension&&o>=i?{manualSize:t.manualSize,computedSize:rt((()=>this.getRowTallestCellSize(e.sheetId,o)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];const i=lt(e.position,e.base),o=t[e.base],n=He(0,e.quantity).map((()=>({manualSize:o.manualSize,computedSize:rt(o.computedSize())})));t.splice(i,0,...n),t=t.map(((t,i)=>"ROW"===e.dimension&&i>e.base+e.quantity?{manualSize:t.manualSize,computedSize:rt((()=>this.getRowTallestCellSize(e.sheetId,i)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"RESIZE_COLUMNS_ROWS":for(let t of e.elements)if("ROW"===e.dimension){const i=this.getRowTallestCellSize(e.sheetId,t);this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:rt(i)})}else this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:rt(e.size||F)});break;case"UPDATE_CELL":const n=null===(i=null===(t=this.sizes[e.sheetId])||void 0===t?void 0:t.ROW)||void 0===i?void 0:i[e.row];if(n&&!n.manualSize){const{sheetId:t,row:i}=e;this.history.update("sizes",t,"ROW",i,"computedSize",rt((()=>this.getRowTallestCellSize(t,i))))}break;case"ADD_MERGE":case"REMOVE_MERGE":for(let t of e.target)for(let i of He(t.top,t.bottom+1)){const t=this.getRowTallestCellSize(e.sheetId,i);t!==this.getRowSize(e.sheetId,i)&&this.history.update("sizes",e.sheetId,"ROW",i,"computedSize",rt(t))}}}getColSize(e,t){return this.getHeaderSize(e,"COL",t)}getRowSize(e,t){return this.getHeaderSize(e,"ROW",t)}getHeaderSize(e,t,i){var o,n,s,r;return Math.round((null===(n=null===(o=this.sizes[e])||void 0===o?void 0:o[t][i])||void 0===n?void 0:n.manualSize)||(null===(r=null===(s=this.sizes[e])||void 0===s?void 0:s[t][i])||void 0===r?void 0:r.computedSize())||this.getDefaultHeaderSize(t))}computeSheetSizes(e){var t,i;const o={COL:[],ROW:[]};for(let t of He(0,this.getters.getNumberCols(e)))o.COL.push(this.getHeaderSize(e,"COL",t));for(let n of He(0,this.getters.getNumberRows(e))){let s=null===(i=null===(t=this.sizes[e])||void 0===t?void 0:t.ROW)||void 0===i?void 0:i[n].manualSize;if(!s){s=this.getRowTallestCellSize(e,n)}o.ROW.push(s)}return o}getDefaultHeaderSize(e){return"COL"===e?F:D}getCellHeight(e){const t=this.getters.getMerge(e);if(t&&t.bottom!==t.top)return D;return function(e){return e&&e.content?Le(Be(e.style),e.isFormula?1:e.content.split(he).length)+2*z:D}(this.getters.getCell(e))}getRowTallestCellSize(e,t){const i=this.getters.getRowCells(e,t);let o=0;for(let e=0;e<i.length;e++){const t=this.getters.getCellById(i[e]);if(!t)continue;const n=this.getters.getCellPosition(t.id),s=this.getCellHeight(n);s>o&&s>D&&(o=s)}return o<=D?D:o}import(e){for(let t of e.sheets){const e={COL:[],ROW:[]};for(let[i,o]of Object.entries(t.rows))o.size&&(e.ROW[i]=o.size);for(let[i,o]of Object.entries(t.cols))o.size&&(e.COL[i]=o.size);const i=this.computeSheetSizes(t.id);this.sizes[t.id]={COL:i.COL.map(((t,i)=>({manualSize:e.COL[i],computedSize:rt(t)}))),ROW:i.ROW.map(((t,i)=>({manualSize:e.ROW[i],computedSize:rt(t)})))}}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){var i,o;for(let n of e.sheets){void 0===n.rows&&(n.rows={});for(let e of He(0,this.getters.getNumberRows(n.id)))(t||(null===(i=this.sizes[n.id].ROW[e])||void 0===i?void 0:i.manualSize))&&(n.rows[e]={...n.rows[e],size:this.getRowSize(n.id,e)});void 0===n.cols&&(n.cols={});for(let e of He(0,this.getters.getNumberCols(n.id)))(t||(null===(o=this.sizes[n.id].COL[e])||void 0===o?void 0:o.manualSize))&&(n.cols[e]={...n.cols[e],size:this.getColSize(n.id,e)})}}}Hv.getters=["getRowSize","getColSize"];class $v extends _v{constructor(){super(...arguments),this.hiddenHeaders={}}allowDispatch(e){switch(e.type){case"HIDE_COLUMNS_ROWS":{if(!this.getters.tryGetSheet(e.sheetId))return 27;const t="COL"===e.dimension?this.getHiddenColsGroups(e.sheetId):this.getHiddenRowsGroups(e.sheetId),i="COL"===e.dimension?this.getters.getNumberCols(e.sheetId):this.getters.getNumberRows(e.sheetId);return new Set((t||[]).flat().concat(e.elements)).size>=i?66:Math.min(...e.elements)<0||Math.max(...e.elements)>i?86:0}case"REMOVE_COLUMNS_ROWS":return this.getters.tryGetSheet(e.sheetId)?this.checkElementsIncludeAllVisibleHeaders(e.sheetId,e.dimension,e.elements)?8:0:27}return 0}handle(e){switch(e.type){case"CREATE_SHEET":const t={COL:Array(this.getters.getNumberCols(e.sheetId)).fill(!1),ROW:Array(this.getters.getNumberRows(e.sheetId)).fill(!1)};this.history.update("hiddenHeaders",e.sheetId,t);break;case"DUPLICATE_SHEET":this.history.update("hiddenHeaders",e.sheetIdTo,_e(this.hiddenHeaders[e.sheetId]));break;case"DELETE_SHEET":this.history.update("hiddenHeaders",e.sheetId,void 0);break;case"REMOVE_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]];for(let i of[...e.elements].sort(((e,t)=>t-e)))t.splice(i,1);this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]],i=lt(e.position,e.base);t.splice(i,0,...Array(e.quantity).fill(!1)),this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"HIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!0);break;case"UNHIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!1)}}checkElementsIncludeAllVisibleHeaders(e,t,i){return ht(i,this.getAllVisibleHeaders(e,t))}isRowHiddenByUser(e,t){return this.hiddenHeaders[e].ROW[t]}isColHiddenByUser(e,t){return this.hiddenHeaders[e].COL[t]}getHiddenColsGroups(e){const t=[[]],i=this.hiddenHeaders[e].COL;for(let e=0;e<i.length;e++){i[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}getHiddenRowsGroups(e){const t=[[]],i=this.hiddenHeaders[e].ROW;for(let e=0;e<i.length;e++){i[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}getAllVisibleHeaders(e,t){return He(0,this.hiddenHeaders[e][t].length).filter((i=>!this.hiddenHeaders[e][t][i]))}import(e){var t,i;for(let o of e.sheets){this.hiddenHeaders[o.id]={COL:[],ROW:[]};for(let e=0;e<o.rowNumber;e++)this.hiddenHeaders[o.id].ROW[e]=Boolean(null===(t=o.rows[e])||void 0===t?void 0:t.isHidden);for(let e=0;e<o.colNumber;e++)this.hiddenHeaders[o.id].COL[e]=Boolean(null===(i=o.cols[e])||void 0===i?void 0:i.isHidden)}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let i of e.sheets){void 0===i.rows&&(i.rows={});for(let e=0;e<this.getters.getNumberRows(i.id);e++)(t||this.hiddenHeaders[i.id].ROW[e])&&(void 0===i.rows[e]&&(i.rows[e]={}),i.rows[e].isHidden=this.hiddenHeaders[i.id].ROW[e]);void 0===i.cols&&(i.cols={});for(let e=0;e<this.getters.getNumberCols(i.id);e++)(t||this.hiddenHeaders[i.id].COL[e])&&(void 0===i.cols[e]&&(i.cols[e]={}),i.cols[e].isHidden=this.hiddenHeaders[i.id].COL[e])}}}$v.getters=["checkElementsIncludeAllVisibleHeaders","getHiddenColsGroups","getHiddenRowsGroups","isRowHiddenByUser","isColHiddenByUser"];class Wv extends _v{constructor(e){super(e),this.images={},this.syncedImages=new Set,this.fileStore=e.external.fileStore}allowDispatch(e){return"CREATE_IMAGE"===e.type&&this.getters.getFigure(e.sheetId,e.figureId)?28:0}handle(e){switch(e.type){case"CREATE_IMAGE":this.addFigure(e.figureId,e.sheetId,e.position,e.size),this.history.update("images",e.sheetId,e.figureId,e.definition),this.syncedImages.add(e.definition.path);break;case"DUPLICATE_SHEET":{const t=this.getters.getFigures(e.sheetId);for(const i of t)if("image"===i.tag){const t=i.id.split(ee).pop(),o=`${e.sheetIdTo}${ee}${t}`,n=this.getImage(i.id);if(n){const t={width:i.width,height:i.height};this.dispatch("CREATE_IMAGE",{sheetId:e.sheetIdTo,figureId:o,position:{x:i.x,y:i.y},size:t,definition:_e(n)})}}break}case"DELETE_FIGURE":this.history.update("images",e.sheetId,e.id,void 0);break;case"DELETE_SHEET":this.history.update("images",e.sheetId,void 0)}}garbageCollectExternalResources(){var e;const t=new Set(this.getAllImages().map((e=>e.path)));for(const i of this.syncedImages)t.has(i)||null===(e=this.fileStore)||void 0===e||e.delete(i)}getImage(e){for(const t of Object.values(this.images))if(t&&t[e])return t[e];throw new Error(`There is no image with the given figureId: ${e}`)}getImagePath(e){return this.getImage(e).path}getImageSize(e){return this.getImage(e).size}addFigure(e,t,i,o){const n={id:e,x:i.x,y:i.y,width:o.width,height:o.height,tag:"image"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:n})}import(e){for(const t of e.sheets){const e=(t.figures||[]).filter((e=>"image"===e.tag));for(const i of e)this.history.update("images",t.id,i.id,i.data),this.syncedImages.add(i.data.path)}}export(e){var t;for(const i of e.sheets){const e=i.figures.filter((e=>"image"===e.tag));for(const o of e)o.data=null===(t=this.images[i.id])||void 0===t?void 0:t[o.id]}}exportForExcel(e){for(const t of e.sheets){const e=this.getters.getFigures(t.id),i=[];for(const t of e)if("image"===(null==t?void 0:t.tag)){const e=this.getImage(t.id);e&&i.push({...t,data:_e(e)})}t.images=i}}getAllImages(){const e=[];for(const t in this.images)e.push(...Object.values(this.images[t]||{}).filter(it));return e}}Wv.getters=["getImage","getImagePath","getImageSize"];class Gv extends _v{constructor(){super(...arguments),this.nextId=1,this.merges={},this.mergeCellMap={}}allowDispatch(e){const t="force"in e&&!!e.force;switch(e.type){case"ADD_MERGE":return t?this.checkValidations(e,this.checkFrozenPanes):this.checkValidations(e,this.checkDestructiveMerge,this.checkOverlap,this.checkFrozenPanes);case"UPDATE_CELL":return this.checkMergedContentUpdate(e);case"REMOVE_MERGE":return this.checkMergeExists(e);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":case"DELETE_SHEET":this.history.update("merges",e.sheetId,{}),this.history.update("mergeCellMap",e.sheetId,{});break;case"DUPLICATE_SHEET":const t=this.merges[e.sheetId];if(!t)break;for(const i of Object.values(t).filter(it))this.addMerge(e.sheetIdTo,i.zone);break;case"ADD_MERGE":for(const t of e.target)this.addMerge(e.sheetId,t);break;case"REMOVE_MERGE":for(const t of e.target)this.removeMerge(e.sheetId,t)}}adaptRanges(e,t){const i=t?[t]:Object.keys(this.merges);for(const t of i)this.applyRangeChangeOnSheet(t,e)}getMerges(e){return Object.keys(this.merges[e]||{}).map((t=>this.getMergeById(e,parseInt(t,10)))).filter(it)}getMerge({sheetId:e,col:t,row:i}){var o;const n=this.mergeCellMap[e],s=n?t in n&&(null===(o=n[t])||void 0===o?void 0:o[i]):void 0;return s?this.getMergeById(e,s):void 0}getMergesInZone(e,t){var i;const o=this.mergeCellMap[e];if(!o)return[];const n=new Set;for(const{col:e,row:s}of no(t)){const t=null===(i=o[e])||void 0===i?void 0:i[s];t&&n.add(t)}return Array.from(n).map((t=>this.getMergeById(e,t))).filter(it)}doesIntersectMerge(e,t){return no(t).some((({col:t,row:i})=>void 0!==this.getMerge({sheetId:e,col:t,row:i})))}doesColumnsHaveCommonMerges(e,t,i){const o=this.getters.getSheet(e);for(let n=0;n<this.getters.getNumberRows(e);n++)if(this.isInSameMerge(o.id,t,n,i,n))return!0;return!1}doesRowsHaveCommonMerges(e,t,i){const o=this.getters.getSheet(e);for(let n=0;n<=this.getters.getNumberCols(e);n++)if(this.isInSameMerge(o.id,n,t,n,i))return!0;return!1}expandZone(e,t){let{left:i,right:o,top:n,bottom:s}=t,r={left:i,right:o,top:n,bottom:s};for(let t in this.merges[e]){const i=this.getMergeById(e,parseInt(t));i&&Ki(i,r)&&(r=ji(i,r))}return Yi(r,t)?r:this.expandZone(e,r)}isInSameMerge(e,t,i,o,n){const s=this.getMerge({sheetId:e,col:t,row:i}),r=this.getMerge({sheetId:e,col:o,row:n});return!(!s||!r)&&Yi(s,r)}isInMerge({sheetId:e,col:t,row:i}){var o;const n=this.mergeCellMap[e];return!!n&&(t in n&&Boolean(null===(o=n[t])||void 0===o?void 0:o[i]))}getMainCellPosition(e){if(!this.isInMerge(e))return e;const t=this.getMerge(e).topLeft;return{sheetId:e.sheetId,col:t.col,row:t.row}}getBottomLeftCell(e){if(!this.isInMerge(e))return e;const{bottom:t,left:i}=this.getMerge(e);return{sheetId:e.sheetId,col:i,row:t}}isMergeHidden(e,t){const i=this.getters.getHiddenColsGroups(e),o=this.getters.getHiddenRowsGroups(e);for(let e of i)if(t.left>=e[0]&&t.right<=e[e.length-1])return!0;for(let e of o)if(t.top>=e[0]&&t.bottom<=e[e.length-1])return!0;return!1}isSingleCellOrMerge(e,t){const i=this.getMerge({sheetId:e,col:t.left,row:t.top});if(i)return Yi(t,i);const{numberOfCols:o,numberOfRows:n}=io(t);return 1===o&&1===n}isMergeDestructive(e,t){let{left:i,right:o,top:n,bottom:s}=t;o=ke(o,0,this.getters.getNumberCols(e)-1),s=ke(s,0,this.getters.getNumberRows(e)-1);for(let t=n;t<=s;t++)for(let s=i;s<=o;s++)if(s!==i||t!==n){const i=this.getters.getCell({sheetId:e,col:s,row:t});if(i&&""!==i.content)return!0}return!1}getMergeById(e,t){var i;const o=null===(i=this.merges[e])||void 0===i?void 0:i[t];return void 0!==o?Zv(t,o):void 0}checkDestructiveMerge({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;return t.some((t=>this.isMergeDestructive(e,t)))?3:0}checkOverlap({target:e}){for(const t of e)for(const i of e)if(t!==i&&Ki(t,i))return 65;return 0}checkFrozenPanes({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;const{xSplit:i,ySplit:o}=this.getters.getPaneDivisions(e);for(const e of t)if(e.left<i&&e.right>=i||e.top<o&&e.bottom>=o)return 75;return 0}checkMergedContentUpdate(e){const{col:t,row:i,content:o}=e;if(void 0===o)return 0;const{col:n,row:s}=this.getMainCellPosition(e);return n===t&&s===i?0:4}checkMergeExists(e){const{sheetId:t,target:i}=e;for(const e of i){const{left:i,top:o}=e,n=this.getMerge({sheetId:t,col:i,row:o});if(void 0===n||!Yi(e,n))return 5}return 0}addMerge(e,t){let{left:i,right:o,top:n,bottom:s}=t;o=ke(o,0,this.getters.getNumberCols(e)-1),s=ke(s,0,this.getters.getNumberRows(e)-1);if(qt(i,n)===qt(o,s))return;const r=this.getters.getCell({sheetId:e,col:i,row:n});let a=this.nextId++;this.history.update("merges",e,a,this.getters.getRangeFromSheetXC(e,$i({left:i,top:n,right:o,bottom:s})));let l=new Set;for(let t=n;t<=s;t++)for(let s=i;s<=o;s++){s===i&&t===n||this.dispatch("UPDATE_CELL",{sheetId:e,col:s,row:t,style:r?r.style:null,content:""});const o=this.getMerge({sheetId:e,col:s,row:t});o&&l.add(o.id),this.history.update("mergeCellMap",e,s,t,a)}for(let t of l){const{top:i,bottom:o,left:n,right:s}=this.getMergeById(e,t);for(let t=i;t<=o;t++)for(let i=n;i<=s;i++){const o={sheetId:e,col:i,row:t},n=this.getMerge(o);n&&n.id===a||(this.history.update("mergeCellMap",e,i,t,void 0),this.dispatch("CLEAR_CELL",o))}this.history.update("merges",e,t,void 0)}}removeMerge(e,t){const{left:i,top:o,bottom:n,right:s}=t,r=this.getMerge({sheetId:e,col:i,row:o});if(void 0!==r&&Yi(t,r)){this.history.update("merges",e,r.id,void 0);for(let t=o;t<=n;t++)for(let o=i;o<=s;o++)this.history.update("mergeCellMap",e,o,t,void 0)}}applyRangeChangeOnSheet(e,t){const i=Object.entries(this.merges[e]||{});for(const[o,n]of i)if(n){const i=n.zone,s=t(n);switch(s.changeType){case"NONE":break;case"REMOVE":this.removeMerge(e,i);break;default:const{numberOfCols:t,numberOfRows:n}=io(s.range.zone);1===t&&1===n?this.removeMerge(e,i):this.history.update("merges",e,parseInt(o,10),s.range)}}this.history.update("mergeCellMap",e,{});for(const t of this.getMerges(e))for(const{col:i,row:o}of no(t))this.history.update("mergeCellMap",e,i,o,t.id)}import(e){const t=e.sheets||[];for(let e of t)this.history.update("merges",e.id,{}),this.history.update("mergeCellMap",e.id,{}),e.merges&&this.importMerges(e.id,e.merges)}importMerges(e,t){for(let i of t)this.addMerge(e,Bi(i))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...qv(e))}}exportForExcel(e){this.export(e)}}function qv(e){return Object.entries(e).map((([e,t])=>t?Zv(parseInt(e,10),t):void 0)).filter(it).map((e=>qt(e.left,e.top)+":"+qt(e.right,e.bottom)))}function Zv(e,t){return{...t.zone,topLeft:{col:t.zone.left,row:t.zone.top},id:e}}Gv.getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCellPosition","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","getMergesInZone","isSingleCellOrMerge"];class jv{constructor(e){this.providers=[],this.getters=e}allowDispatch(e){return"MOVE_RANGES"===e.type?1===e.target.length?0:26:0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",i="COL"===e.dimension?"right":"bottom",o="COL"===e.dimension?"columns":"rows";const n=[...e.elements];n.sort(((e,t)=>t-e));const s=$e(n);this.executeOnAllRanges((n=>{if(n.sheetId!==e.sheetId)return{changeType:"NONE"};let r=n,a="NONE";for(let e of s){const s=Math.min(...e),l=Math.max(...e);if(n.zone[t]<=s&&s<=n.zone[i]){const e=Math.min(n.zone[i],l)-s+1;a="RESIZE",r=this.createAdaptedRange(r,o,a,-e)}else if(n.zone[t]>=s&&n.zone[i]<=l)a="REMOVE",r=n.clone({...this.getInvalidRange()});else if(n.zone[t]<=l&&n.zone[i]>=l){const e=l-n.zone[t]+1;a="RESIZE",r=this.createAdaptedRange(r,o,a,-e),r=this.createAdaptedRange(r,o,"MOVE",-(n.zone[t]-s))}else s<n.zone[t]&&(a="MOVE",r=this.createAdaptedRange(r,o,a,-(l-s+1)))}return"NONE"!==a?{changeType:a,range:r}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",i="COL"===e.dimension?"right":"bottom",o="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((n=>{if(n.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(n.zone[t]<=e.base&&e.base<n.zone[i])return{changeType:"RESIZE",range:this.createAdaptedRange(n,o,"RESIZE",e.quantity)};if(e.base<n.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(n,o,"MOVE",e.quantity)}}else{if(n.zone[t]<e.base&&e.base<=n.zone[i])return{changeType:"RESIZE",range:this.createAdaptedRange(n,o,"RESIZE",e.quantity)};if(e.base<=n.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(n,o,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId!==e.sheetId)return{changeType:"NONE"};const i=this.getters.getSheetName(e.sheetId);return{changeType:"REMOVE",range:t=t.clone({...this.getInvalidRange(),invalidSheetName:i})}}),e.sheetId);break;case"RENAME_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId===e.sheetId)return{changeType:"CHANGE",range:t};if(e.name&&t.invalidSheetName===e.name){const i=void 0,o=e.sheetId;return{changeType:"CHANGE",range:t.clone({sheetId:o,invalidSheetName:i})}}return{changeType:"NONE"}}));break;case"MOVE_RANGES":{const t=e.target[0];this.executeOnAllRanges((i=>{if(i.sheetId!==e.sheetId||!Ji(i.zone,t))return{changeType:"NONE"};const o=e.targetSheetId,n=e.col-t.left,s=e.row-t.top,r=this.createAdaptedRange(i,"both","MOVE",[n,s]),a=e.sheetId!==o||r.prefixSheet;return{changeType:"MOVE",range:r.clone({sheetId:o,prefixSheet:a})}}));break}}}finalize(){}verifyRangeRemoved(e){return t=>{const i=e(t);return"NONE"===i.changeType||Hi(i.range.zone)?i:{range:i.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,i,o){const n=so(e.unboundedZone,t,i,o);return e.clone({zone:n})}executeOnAllRanges(e,t){const i=this.verifyRangeRemoved(e);for(const e of this.providers)e(i,t)}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,i,o){const n=e.map((e=>Di.fromRange(e,this.getters)));return n.map((e=>{if(!Hi(e.zone))return e;const n=e.prefixSheet?e.sheetId:o,s={...e.unboundedZone,left:e.isFullRow&&!e.unboundedZone.hasHeader?e.unboundedZone.left:e.unboundedZone.left+(e.parts[0].colFixed?0:t),right:e.isFullRow?e.unboundedZone.right:e.unboundedZone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:e.isFullCol&&!e.unboundedZone.hasHeader?e.unboundedZone.top:e.unboundedZone.top+(e.parts[0].rowFixed?0:i),bottom:e.isFullCol?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:i)};return e.clone({sheetId:n,zone:s}).orderZone()}))}getRangeFromSheetXC(e,t){if(!Lt.test(t))return new Di({sheetId:"",zone:{left:-1,top:-1,right:-1,bottom:-1},parts:[],invalidXc:t,prefixSheet:!1},this.getters.getSheetSize);let i,o=t,n=!1;t.includes("!")&&(({xc:o,sheetName:i}=Ht(t)),i&&(n=!0));const s=zi(o),r=Di.getRangeParts(o,s),a=i&&!this.getters.getSheetIdByName(i)?i:void 0,l=this.getters.getSheetIdByName(i)||e;return new Di({prefixSheet:n,zone:s,sheetId:l,invalidSheetName:a,parts:r},this.getters.getSheetSize).orderZone()}getSelectionRangeString(e,t){const i=Di.fromRange(e,this.getters),o=this.getters.expandZone(i.sheetId,i.zone),n=i.clone({zone:{...o,bottom:i.isFullCol?void 0:o.bottom,right:i.isFullRow?void 0:o.right}});return this.getRangeString(n,t)}getRangeString(e,t){if(!e)return K;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return K;if(e.zone.left<0||e.zone.top<0)return K;const i=Di.fromRange(e,this.getters);let o=i.sheetId!==t||i.invalidSheetName||i.prefixSheet,n="";if(o&&(n=i.invalidSheetName?i.invalidSheetName:De(this.getters.getSheetName(i.sheetId))),o&&!n)return K;let s=this.getRangePartString(i,0);return i.parts&&2===i.parts.length&&(i.zone.top!==i.zone.bottom||i.zone.left!==i.zone.right||i.parts[0].rowFixed||i.parts[0].colFixed||i.parts[1].rowFixed||i.parts[1].colFixed)&&(s+=":",s+=this.getRangePartString(i,1)),`${o?n+"!":""}${s}`}getRangeDataFromXc(e,t){return this.getters.getRangeFromSheetXC(e,t).rangeData}getRangeDataFromZone(e,t){return{_sheetId:e,_zone:t}}getRangeFromRangeData(e){const t={prefixSheet:!1,zone:e._zone,sheetId:e._sheetId,invalidSheetName:void 0,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}]};return new Di(t,this.getters.getSheetSize)}getRangePartString(e,t){const i=e.parts&&e.parts[t].colFixed?"$":"",o=$t(0===t?e.zone.left:e.zone.right),n=e.parts&&e.parts[t].rowFixed?"$":"",s=String(0===t?e.zone.top+1:e.zone.bottom+1);let r="";return r=e.isFullCol?0===t&&e.unboundedZone.hasHeader?i+o+n+s:i+o:e.isFullRow?0===t&&e.unboundedZone.hasHeader?i+o+n+s:n+s:i+o+n+s,r}getInvalidRange(){return{parts:[],prefixSheet:!1,zone:{left:-1,top:-1,right:-1,bottom:-1},sheetId:"",invalidXc:K}}}jv.getters=["getRangeString","getSelectionRangeString","getRangeFromSheetXC","createAdaptedRanges","getRangeDataFromXc","getRangeDataFromZone","getRangeFromRangeData"];class Xv extends _v{constructor(){super(...arguments),this.sheetIdsMapName={},this.orderedSheetIds=[],this.sheets={},this.cellPosition={}}allowDispatch(e){const t=this.chainValidations(this.checkSheetExists,this.checkZones)(e);if(0!==t)return t;switch(e.type){case"HIDE_SHEET":return 1===this.getVisibleSheetIds().length?9:0;case"CREATE_SHEET":return this.checkValidations(e,this.checkSheetName,this.checkSheetPosition);case"MOVE_SHEET":try{const t=this.orderedSheetIds.findIndex((t=>t===e.sheetId));return this.findIndexOfTargetSheet(t,e.delta),0}catch(e){return 14}case"RENAME_SHEET":return this.isRenameAllowed(e);case"DELETE_SHEET":return this.orderedSheetIds.length>1?0:9;case"ADD_COLUMNS_ROWS":const t="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return e.base<0||e.base>=t?86:e.quantity<=0?87:0;case"REMOVE_COLUMNS_ROWS":{const t="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return Math.min(...e.elements)<0||Math.max(...e.elements)>t?86:this.checkElementsIncludeAllNonFrozenHeaders(e.sheetId,e.dimension,e.elements)?8:0}case"FREEZE_ROWS":return this.checkValidations(e,this.checkRowFreezeQuantity,this.checkRowFreezeOverlapMerge);case"FREEZE_COLUMNS":return this.checkValidations(e,this.checkColFreezeQuantity,this.checkColFreezeOverlapMerge);default:return 0}}handle(e){switch(e.type){case"SET_GRID_LINES_VISIBILITY":this.setGridLinesVisibility(e.sheetId,e.areGridLinesVisible);break;case"DELETE_CONTENT":this.clearZones(e.sheetId,e.target);break;case"CREATE_SHEET":const t=this.createSheet(e.sheetId,e.name||this.getNextSheetName(),e.cols||26,e.rows||100,e.position);this.history.update("sheetIdsMapName",t.name,t.id);break;case"MOVE_SHEET":this.moveSheet(e.sheetId,e.delta);break;case"RENAME_SHEET":this.renameSheet(this.sheets[e.sheetId],e.name);break;case"HIDE_SHEET":this.hideSheet(e.sheetId);break;case"SHOW_SHEET":this.showSheet(e.sheetId);break;case"DUPLICATE_SHEET":this.duplicateSheet(e.sheetId,e.sheetIdTo);break;case"DELETE_SHEET":this.deleteSheet(this.sheets[e.sheetId]);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.removeColumns(this.sheets[e.sheetId],[...e.elements]):this.removeRows(this.sheets[e.sheetId],[...e.elements]);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.addColumns(this.sheets[e.sheetId],e.base,e.position,e.quantity):this.addRows(this.sheets[e.sheetId],e.base,e.position,e.quantity);break;case"UPDATE_CELL_POSITION":this.updateCellPosition(e);break;case"FREEZE_COLUMNS":this.setPaneDivisions(e.sheetId,e.quantity,"COL");break;case"FREEZE_ROWS":this.setPaneDivisions(e.sheetId,e.quantity,"ROW");break;case"UNFREEZE_ROWS":this.setPaneDivisions(e.sheetId,0,"ROW");break;case"UNFREEZE_COLUMNS":this.setPaneDivisions(e.sheetId,0,"COL");break;case"UNFREEZE_COLUMNS_ROWS":this.setPaneDivisions(e.sheetId,0,"COL"),this.setPaneDivisions(e.sheetId,0,"ROW")}}import(e){var t,i;for(let t of e.sheets)this.sheetIdsMapName[t.name]=t.id;for(let o of e.sheets){const e=o.name||n("Sheet")+(Object.keys(this.sheets).length+1),{colNumber:s,rowNumber:r}=this.getImportedSheetSize(o),a={id:o.id,name:e,numberOfCols:s,rows:Ui(r),areGridLinesVisible:void 0===o.areGridLinesVisible||o.areGridLinesVisible,isVisible:o.isVisible,panes:{xSplit:(null===(t=o.panes)||void 0===t?void 0:t.xSplit)||0,ySplit:(null===(i=o.panes)||void 0===i?void 0:i.ySplit)||0}};this.orderedSheetIds.push(a.id),this.sheets[a.id]=a}}exportSheets(e){e.sheets=this.orderedSheetIds.filter(it).map((e=>{const t=this.sheets[e],i={id:t.id,name:t.name,colNumber:t.numberOfCols,rowNumber:this.getters.getNumberRows(t.id),rows:{},cols:{},merges:[],cells:{},conditionalFormats:[],figures:[],filterTables:[],areGridLinesVisible:void 0===t.areGridLinesVisible||t.areGridLinesVisible,isVisible:t.isVisible};return(t.panes.xSplit||t.panes.ySplit)&&(i.panes=t.panes),i}))}export(e){this.exportSheets(e)}exportForExcel(e){this.exportSheets(e)}getGridLinesVisibility(e){return this.getSheet(e).areGridLinesVisible}tryGetSheet(e){return this.sheets[e]}getSheet(e){const t=this.sheets[e];if(!t)throw new Error(`Sheet ${e} not found.`);return t}isSheetVisible(e){return this.getSheet(e).isVisible}getSheetName(e){return this.getSheet(e).name}tryGetSheetName(e){var t;return null===(t=this.tryGetSheet(e))||void 0===t?void 0:t.name}getSheetIdByName(e){if(e){const t=Fe(e);for(const e in this.sheetIdsMapName)if(e.toUpperCase()===t.toUpperCase())return this.sheetIdsMapName[e]}}getSheetIds(){return this.orderedSheetIds}getVisibleSheetIds(){return this.orderedSheetIds.filter(this.isSheetVisible.bind(this))}getEvaluationSheets(){return this.sheets}doesHeaderExist(e,t,i){return"COL"===t?i>=0&&i<this.getNumberCols(e):i>=0&&i<this.getNumberRows(e)}getRow(e,t){const i=this.getSheet(e).rows[t];if(!i)throw new Error(`Row ${i} not found.`);return i}getCell({sheetId:e,col:t,row:i}){var o;const n=this.tryGetSheet(e),s=null===(o=null==n?void 0:n.rows[i])||void 0===o?void 0:o.cells[t];if(void 0!==s)return this.getters.getCellById(s)}getColsZone(e,t,i){return{top:0,bottom:this.getNumberRows(e)-1,left:t,right:i}}getRowCells(e,t){var i;return Object.values(null===(i=this.getSheet(e).rows[t])||void 0===i?void 0:i.cells).filter(it)}getRowsZone(e,t,i){return{top:t,bottom:i,left:0,right:this.getSheet(e).numberOfCols-1}}getCellPosition(e){const t=this.cellPosition[e];if(!t)throw new Error(`asking for a cell position that doesn't exist, cell id: ${e}`);return t}getNumberCols(e){return this.getSheet(e).numberOfCols}getNumberRows(e){return this.getSheet(e).rows.length}getNumberHeaders(e,t){return"COL"===t?this.getNumberCols(e):this.getNumberRows(e)}getNextSheetName(e="Sheet"){let t=1;const i=this.orderedSheetIds.map(this.getSheetName.bind(this));let o=`${e}${t}`;for(;i.includes(o);)o=`${e}${t}`,t++;return o}getSheetSize(e){return{numberOfRows:this.getNumberRows(e),numberOfCols:this.getNumberCols(e)}}getSheetZone(e){return{top:0,left:0,bottom:this.getNumberRows(e)-1,right:this.getNumberCols(e)-1}}getPaneDivisions(e){return this.getSheet(e).panes}setPaneDivisions(e,t,i){const o={...this.getPaneDivisions(e)};"COL"===i?o.xSplit=t:"ROW"===i&&(o.ySplit=t),this.history.update("sheets",e,"panes",o)}checkElementsIncludeAllNonFrozenHeaders(e,t,i){const o=this.getters.getPaneDivisions(e),n="ROW"===t?o.ySplit:o.xSplit,s=this.getters.getNumberHeaders(e,t);if(!n)return!1;return ht(i,He(n,s))}isEmpty(e,t){return no(t).map((({col:t,row:i})=>this.getCell({sheetId:e,col:t,row:i}))).every((e=>!e||""===e.content))}updateCellPosition(e){const{sheetId:t,cellId:i,col:o,row:n}=e;i?this.setNewPosition(i,t,o,n):this.clearPosition(t,o,n)}setNewPosition(e,t,i,o){const n=this.cellPosition[e];n&&this.clearPosition(t,n.col,n.row),this.history.update("cellPosition",e,{row:o,col:i,sheetId:t}),this.history.update("sheets",t,"rows",o,"cells",i,e)}clearPosition(e,t,i){var o;const n=null===(o=this.sheets[e])||void 0===o?void 0:o.rows[i].cells[t];n&&(this.history.update("cellPosition",n,void 0),this.history.update("sheets",e,"rows",i,"cells",t,void 0))}setGridLinesVisibility(e,t){this.history.update("sheets",e,"areGridLinesVisible",t)}clearZones(e,t){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let o=i.top;o<=i.bottom;o++){this.sheets[e].rows[o].cells[t]&&this.dispatch("UPDATE_CELL",{sheetId:e,content:"",col:t,row:o})}}createSheet(e,t,i,o,n){const s={id:e,name:t,numberOfCols:i,rows:Ui(o),areGridLinesVisible:!0,isVisible:!0,panes:{xSplit:0,ySplit:0}},r=this.orderedSheetIds.slice();r.splice(n,0,s.id);const a=this.sheets;return this.history.update("orderedSheetIds",r),this.history.update("sheets",Object.assign({},a,{[s.id]:s})),s}moveSheet(e,t){const i=this.orderedSheetIds.slice(),o=i.findIndex((t=>t===e)),n=i.splice(o,1);let s=this.findIndexOfTargetSheet(o,t);i.splice(s,0,n[0]),this.history.update("orderedSheetIds",i)}findIndexOfTargetSheet(e,t){for(;0!=t&&0<=e&&e<=this.orderedSheetIds.length;)t>0?(e++,this.isSheetVisible(this.orderedSheetIds[e])&&t--):t<0&&(e--,this.isSheetVisible(this.orderedSheetIds[e])&&t++);if(0===t)return e;throw new Error(s("There is not enough visible sheets"))}checkSheetName(e){const{orderedSheetIds:t,sheets:i}=this,o=e.name&&e.name.trim().toLowerCase();return t.find((e=>{var t;return(null===(t=i[e])||void 0===t?void 0:t.name.toLowerCase())===o}))?11:re.test(o)?13:0}checkSheetPosition(e){const{orderedSheetIds:t}=this;return e.position>t.length||e.position<0?15:0}checkRowFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberRows(e.sheetId)?0:74}checkColFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberCols(e.sheetId)?0:74}checkRowFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let i of t)if(i.top<e.quantity&&e.quantity<=i.bottom)return 65;return 0}checkColFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let i of t)if(i.left<e.quantity&&e.quantity<=i.right)return 65;return 0}isRenameAllowed(e){return e.name&&e.name.trim().toLowerCase()?this.checkSheetName(e):10}renameSheet(e,t){const i=e.name;this.history.update("sheets",e.id,"name",t.trim());const o=Object.assign({},this.sheetIdsMapName);o[t]=e.id,delete o[i],this.history.update("sheetIdsMapName",o)}hideSheet(e){this.history.update("sheets",e,"isVisible",!1)}showSheet(e){this.history.update("sheets",e,"isVisible",!0)}duplicateSheet(e,t){const i=this.getSheet(e),o=this.getDuplicateSheetName(i.name),n=_e(i);n.id=t,n.name=o;for(let e=0;e<=n.numberOfCols;e++)for(let t=0;t<=n.rows.length;t++)n.rows[t]&&(n.rows[t].cells[e]=void 0);const s=this.orderedSheetIds.slice(),r=s.indexOf(e);s.splice(r+1,0,n.id),this.history.update("orderedSheetIds",s),this.history.update("sheets",Object.assign({},this.sheets,{[n.id]:n}));for(const t of Object.values(this.getters.getCells(e))){const{col:e,row:i}=this.getCellPosition(t.id);this.dispatch("UPDATE_CELL",{sheetId:n.id,col:e,row:i,content:t.content,format:t.format,style:t.style})}const a=Object.assign({},this.sheetIdsMapName);a[n.name]=n.id,this.history.update("sheetIdsMapName",a)}getDuplicateSheetName(e){let t=1;const i=this.orderedSheetIds.map(this.getSheetName.bind(this)),o=s("Copy of %s",e);let n=o.toString();for(;i.includes(n);)n=`${o} (${t})`,t++;return n}deleteSheet(e){const t=e.name,i=Object.assign({},this.sheets);delete i[e.id],this.history.update("sheets",i);const o=this.orderedSheetIds.slice(),n=o.indexOf(e.id);o.splice(n,1),this.history.update("orderedSheetIds",o);const s=Object.assign({},this.sheetIdsMapName);delete s[t],this.history.update("sheetIdsMapName",s)}removeColumns(e,t){t.sort(((e,t)=>t-e));for(let i of t)this.moveCellOnColumnsDeletion(e,i);const i=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",i-t.length);const o=t.filter((t=>t<e.panes.xSplit)).length;o&&this.setPaneDivisions(e.id,e.panes.xSplit-o,"COL")}removeRows(e,t){t.sort(((e,t)=>t-e));for(let i of $e(t)){const t=i[i.length-1],o=i[0];this.moveCellOnRowsDeletion(e,t,o),this.updateRowsStructureOnDeletion(e,t,o)}const i=t.filter((t=>t<e.panes.ySplit)).length;i&&this.setPaneDivisions(e.id,e.panes.ySplit-i,"ROW")}addColumns(e,t,i,o){const n="before"===i?t:t+1;this.moveCellsOnAddition(e,n,o,"columns");const s=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",s+o),n<e.panes.xSplit&&this.setPaneDivisions(e.id,e.panes.xSplit+o,"COL")}addRows(e,t,i,o){const n="before"===i?t:t+1;this.addEmptyRows(e,o),this.moveCellsOnAddition(e,n,o,"rows"),n<e.panes.ySplit&&this.setPaneDivisions(e.id,e.panes.ySplit+o,"ROW")}moveCellOnColumnsDeletion(e,t){for(let i=0;i<e.rows.length;i++){const o=e.rows[i];for(let n in o.cells){const s=Number(n),r=o.cells[n];r&&(s===t&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:s,row:i}),s>t&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:r,col:s-1,row:i}))}}}moveCellsOnAddition(e,t,i,o){const n=[];for(let s=0;s<e.rows.length;s++){const r=e.rows[s];if("rows"!==o||s>=t)for(let a in r.cells){const l=Number(a),c=r.cells[a];c&&("rows"===o||l>=t)&&n.push({type:"UPDATE_CELL_POSITION",sheetId:e.id,cellId:c,col:l+("columns"===o?i:0),row:s+("rows"===o?i:0)})}}for(let e of n.reverse())this.dispatch(e.type,e)}moveCellOnRowsDeletion(e,t,i){const o=i-t+1;for(let n=0;n<e.rows.length;n++){const s=e.rows[n];if(n>=t&&n<=i)for(let t in s.cells){const i=Number(t);s.cells[t]&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:i,row:n})}if(n>i)for(let t in s.cells){const i=Number(t),r=s.cells[t];r&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:r,col:i,row:n-o})}}}updateRowsStructureOnDeletion(e,t,i){const o=[],n=e.rows.map((e=>e.cells)).reverse();for(let s in e.rows){const e=Number(s);e>=t&&e<=i||o.push({cells:n.pop()})}this.history.update("sheets",e.id,"rows",o)}addEmptyRows(e,t){const i=e.rows.slice();for(let e=0;e<t;e++)i.push({cells:{}});this.history.update("sheets",e.id,"rows",i)}getImportedSheetSize(e){const t=Object.keys(e.cells).map(Gt);let i=e.rowNumber,o=e.colNumber;for(let{col:e,row:n}of t)i=Math.max(i,n+1),o=Math.max(o,e+1);return{rowNumber:i,colNumber:o}}checkSheetExists(e){return"CREATE_SHEET"!==e.type&&"sheetId"in e&&void 0===this.sheets[e.sheetId]?27:"CREATE_SHEET"===e.type&&void 0!==this.sheets[e.sheetId]?12:0}checkZones(e){const t=[];if("zone"in e&&t.push(e.zone),"target"in e&&Array.isArray(e.target)&&t.push(...e.target),"ranges"in e&&Array.isArray(e.ranges)&&t.push(...e.ranges.map((e=>this.getters.getRangeFromRangeData(e).zone))),!t.every(Hi))return 25;if(t.length&&"sheetId"in e){const i=this.getSheetZone(e.sheetId);return t.every((e=>Ji(e,i)))?0:18}return 0}}Xv.getters=["getSheetName","tryGetSheetName","getSheet","tryGetSheet","getSheetIdByName","getSheetIds","getVisibleSheetIds","isSheetVisible","getEvaluationSheets","doesHeaderExist","getCell","getCellPosition","getColsZone","getRowCells","getRowsZone","getNumberCols","getNumberRows","getNumberHeaders","getGridLinesVisibility","getNextSheetName","isEmpty","getSheetSize","getSheetZone","getPaneDivisions","checkElementsIncludeAllNonFrozenHeaders"];class Yv extends Nv{constructor({getters:e,stateObserver:t,dispatch:i,uiActions:o,selection:n}){super(t,i),this.getters=e,this.ui=o,this.selection=n}drawGrid(e,t){}}Yv.layers=[];class Kv extends Yv{constructor(){super(...arguments),this.customColors=new Set,this.shouldUpdateColors=!1}handle(e){switch(e.type){case"UPDATE_CELL":case"UPDATE_CHART":case"CREATE_CHART":case"ADD_CONDITIONAL_FORMAT":this.shouldUpdateColors=!0}}finalize(){if(this.shouldUpdateColors){this.shouldUpdateColors=!1;for(const e of this.getCustomColors())this.tryToAddColor(e)}}getCustomColors(){let e=[];for(const t of this.getters.getSheetIds()){const i=Object.values(this.getters.getCells(t));e=e.concat(this.getColorsFromCells(i),this.getFormattingColors(t),this.getChartColors(t))}return function(e){const t=[{leadColor:xt(255,0,0),colors:[]},{leadColor:xt(255,128,0),colors:[]},{leadColor:xt(128,128,0),colors:[]},{leadColor:xt(128,255,0),colors:[]},{leadColor:xt(0,255,0),colors:[]},{leadColor:xt(0,255,128),colors:[]},{leadColor:xt(0,255,255),colors:[]},{leadColor:xt(0,127,255),colors:[]},{leadColor:xt(0,0,255),colors:[]},{leadColor:xt(127,0,255),colors:[]},{leadColor:xt(128,0,128),colors:[]},{leadColor:xt(255,0,128),colors:[]}];for(const i of e.map(Tt)){let e=500,o=0;t.forEach(((t,n)=>{const s=(r=i,a=t.leadColor,Math.sqrt(Math.pow(r.r-a.r,2)+Math.pow(r.g-a.g,2)+Math.pow(r.b-a.b,2)));var r,a;e>s&&(e=s,o=n)})),t[o].colors.push(i)}return t.map((e=>e.colors.sort(((e,t)=>Mt(e).s-Mt(t).s)))).flat().map(Rt)}([...new Set([...new Set([...e,...this.customColors])].filter(wt).map(Et))]).filter((e=>!O.includes(e)))}getColorsFromCells(e){var t,i;const o=new Set;for(const n of e)(null===(t=n.style)||void 0===t?void 0:t.textColor)&&o.add(n.style.textColor),(null===(i=n.style)||void 0===i?void 0:i.fillColor)&&o.add(n.style.fillColor);return[...o]}getFormattingColors(e){const t=this.getters.getConditionalFormats(e),i=[];for(const e of t){const t=e.rule;"CellIsRule"===t.type?(i.push(t.style.textColor),i.push(t.style.fillColor)):"ColorScaleRule"===t.type&&(i.push(Ct(t.minimum.color)),i.push(t.midpoint?Ct(t.midpoint.color):void 0),i.push(Ct(t.maximum.color)))}return i.filter(it)}getChartColors(e){const t=this.getters.getChartIds(e).map((e=>this.getters.getChart(e)));let i=new Set;for(let e of t){if(void 0===e)continue;const t=e.getDefinition().background;switch(void 0!==t&&i.add(t),e.type){case"gauge":const t=e.sectionRule.colors;i.add(t.lowerColor),i.add(t.middleColor),i.add(t.upperColor);break;case"scorecard":const o=e;i.add(o.baselineColorDown),i.add(o.baselineColorUp)}}return[...i]}tryToAddColor(e){const t=Et(e);e&&!O.includes(t)&&this.customColors.add(t)}}Kv.getters=["getCustomColors"];const Qv=Ju.mapping;class Jv extends Yv{constructor(e){super(e),this.isUpToDate=!1,this.evaluatedCells={},this.evalContext=e.custom,this.lazyEvaluation=e.lazyEvaluation}handle(e){switch(hn.has(e.type)&&(this.isUpToDate=!1),e.type){case"UPDATE_CELL":("content"in e||"format"in e)&&(this.isUpToDate=!1);break;case"EVALUATE_CELLS":this.evaluate()}}finalize(){this.isUpToDate||(this.evaluate(),this.isUpToDate=!0)}evaluateFormula(e,t=this.getters.getActiveSheetId()){const i=pf(e),o=this.getCompilationParameters((e=>this.getEvaluatedCell(this.getters.getCellPosition(e.id)))),n=[];for(let e of i.dependencies)n.push(this.getters.getRangeFromSheetXC(t,e));return i.execute(n,...o).value}getRangeFormattedValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.formattedValue))}getRangeValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.value))}getRangeFormats(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.format))}getEvaluatedCell({sheetId:e,col:t,row:i}){var o,n,s;return void 0===this.getters.getCell({sheetId:e,col:t,row:i})?En(""):(null===(s=null===(n=null===(o=this.evaluatedCells[e])||void 0===o?void 0:o[t])||void 0===n?void 0:n[i])||void 0===s?void 0:s.call(n))||En("")}getEvaluatedCells(e){const t=this.getters.getCells(e)||{},i={};for(let e of Object.keys(t)){const t=this.getters.getCellPosition(e);i[e]=this.getEvaluatedCell(t)}return i}getColEvaluatedCells(e,t){var i;return Object.values((null===(i=this.evaluatedCells[e])||void 0===i?void 0:i[t])||[]).filter(it).map((e=>e()))}getEvaluatedCellsInZone(e,t){return no(t).map((({col:t,row:i})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:i})))}setEvaluatedCell(e,t){const{col:i,row:o,sheetId:n}=this.getters.getCellPosition(e);this.evaluatedCells[n]||(this.evaluatedCells[n]={}),this.evaluatedCells[n][i]||(this.evaluatedCells[n][i]={}),this.evaluatedCells[n][i][o]=t,this.lazyEvaluation||this.evaluatedCells[n][i][o]()}*getAllCells(){for(const e of this.getters.getSheetIds()){const t=this.getters.getCells(e);for(const e in t)yield t[e]}}evaluate(){this.evaluatedCells={};const e=new Set,t=e=>{var t,n;const s=e.id,{col:r,row:a,sheetId:l}=this.getters.getCellPosition(s),c=null===(n=null===(t=this.evaluatedCells[l])||void 0===t?void 0:t[r])||void 0===n?void 0:n[a];return c||rt((()=>{try{switch(e.isFormula){case!0:return o(e);case!1:return Sn(e.content,e.format)}}catch(t){return i(t,e)}}))},i=(e,t)=>{e instanceof Error||(e=new Error(e));const i=(null==e?void 0:e.errorType)||a.GenericError,o=n[2].__lastFnCalled||"",s=new c(i,e.message.replace("[[FUNCTION_NAME]]",o),void 0!==e.logLevel?e.logLevel:l.error);return In(t.content,s)},o=t=>{const i=t.id;if(e.has(i))throw new d;n[2].__originCellXC=()=>{const e=n[2].getters.getCellPosition(i);return qt(e.col,e.row)},e.add(i);const o=t.compiledFormula.execute(t.dependencies,...n);if(e.delete(i),Array.isArray(o.value))throw new Error(s("This formula depends on invalid values"));return En(o.value,t.format||o.format)},n=this.getCompilationParameters((e=>t(e)()));for(const e of this.getAllCells())this.setEvaluatedCell(e.id,t(e))}getCompilationParameters(e){const t=Object.assign(Object.create(Qv),this.evalContext,{getters:this.getters}),i=this.getters;const o=t=>{const i=e(t);if(i.type===ln.error)throw i.error;return i},n={};return[function(e,t,n,r){if(t)return{value:$i(e.zone)};if(!Hi(e.zone))throw new u;if(e.zone.bottom!==e.zone.top||e.zone.left!==e.zone.right)throw new Error(r?s("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.",n.toString(),r.toString()):s("Function %s expects its parameters to be single values or single cell references, not ranges.",n.toString()));if(e.invalidSheetName)throw new Error(s("Invalid sheet name: %s",e.invalidSheetName));return function(e){let t;if(!i.tryGetSheet(e.sheetId))throw new Error(s("Invalid sheet name"));return t=i.getCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}),t&&""!==t.content?o(t):{value:null,format:null==t?void 0:t.format}}(e)},function(e){const s=e.sheetId;if(!Hi(e.zone))throw new u;const r=i.getSheetZone(s),a=Xi(e.zone,r);if(!a)return[[]];const{top:l,left:c,bottom:h,right:d}=a,g=`${s}-${l}-${c}-${h}-${d}`;if(g in n)return n[g];const p=new Array(d-c+1);for(let i=c;i<=d;i++){const n=new Array(h-l+1);for(let s=l;s<=h;s++){const r=t.getters.getCell({sheetId:e.sheetId,col:i,row:s});n[s-l]=r?o(r):void 0}p[i-c]=n}return n[g]=p,p},t]}exportForExcel(e){for(let t of e.sheets)for(const e in t.cells){const i={sheetId:t.id,...Gt(e)},o=this.getters.getCell(i);if(o){const n=t.cells[e],s=this.getEvaluatedCell(i);n.value=s.value,n.isFormula=o.isFormula&&!this.isBadExpression(o.content),o.format!==s.format&&(n.computedFormat=s.format)}}}isBadExpression(e){try{return pf(e),!1}catch(e){return!0}}}Jv.getters=["evaluateFormula","getRangeFormattedValues","getRangeValues","getRangeFormats","getEvaluatedCell","getEvaluatedCells","getColEvaluatedCells","getEvaluatedCellsInZone"];class eb extends Yv{constructor(){super(...arguments),this.charts={},this.createRuntimeChart=function(e){const t=dr.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(i){const o=t.find((e=>e.match(i.type)));if(!o)throw new Error("No runtime builder for this chart.");return o.getChartRuntime(i,e)}}(this.getters)}handle(e){if(hn.has(e.type)||dn.has(e.type)||"EVALUATE_CELLS"===e.type||"UPDATE_CELL"===e.type)for(const e in this.charts)this.charts[e]=void 0;switch(e.type){case"UPDATE_CHART":case"CREATE_CHART":case"DELETE_FIGURE":this.charts[e.id]=void 0;break;case"DELETE_SHEET":for(let e in this.charts)this.getters.isChartDefined(e)||(this.charts[e]=void 0)}}getChartRuntime(e){if(!this.charts[e]){const t=this.getters.getChart(e);if(!t)throw new Error(`No chart for the given id: ${e}`);this.charts[e]=this.createRuntimeChart(t)}return this.charts[e]}getStyleOfSingleCellChart(e,t){if(e)return{background:e,fontColor:ys(e)};if(!t)return{background:w,fontColor:ys(w)};const i=t.zone.left,o=t.zone.top,n=t.sheetId,s=this.getters.getCellComputedStyle({sheetId:n,col:i,row:o}),r=s.fillColor||w;return{background:r,fontColor:s.textColor||ys(r)}}}eb.getters=["getChartRuntime","getStyleOfSingleCellChart"];class tb extends Yv{constructor(){super(...arguments),this.isStale=!0,this.computedStyles={},this.computedIcons={},this.uuidGenerator=new Vi,this.rulePredicate={CellIsRule:(e,t)=>{if(e.type===ln.error)return!1;const i=t.values.map(Cn);switch(t.operator){case"IsEmpty":return""===e.value.toString().trim();case"IsNotEmpty":return""!==e.value.toString().trim();case"BeginsWith":return""!==i[0]&&e.value.toString().startsWith(i[0].toString());case"EndsWith":return""!==i[0]&&e.value.toString().endsWith(i[0].toString());case"Between":return e.value>=i[0]&&e.value<=i[1];case"NotBetween":return!(e.value>=i[0]&&e.value<=i[1]);case"ContainsText":return e.value.toString().indexOf(i[0].toString())>-1;case"NotContains":return!e.value||-1==e.value.toString().indexOf(i[0].toString());case"GreaterThan":return e.value>i[0];case"GreaterThanOrEqual":return e.value>=i[0];case"LessThan":return e.value<i[0];case"LessThanOrEqual":return e.value<=i[0];case"NotEqual":return""!==i[0]&&e.value!==i[0];case"Equal":return""===i[0]||e.value===i[0];default:console.warn(s("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}handle(e){switch((dn.has(e.type)||"UPDATE_CELL"===e.type&&"content"in e)&&(this.isStale=!0),e.type){case"ACTIVATE_SHEET":const t=e.sheetIdTo;this.computedStyles[t]=this.computedStyles[t]||{},this.computedIcons[t]=this.computedIcons[t]||{},this.isStale=!0;break;case"AUTOFILL_CELL":const i=this.getters.getActiveSheetId(),o=this.getters.getRulesByCell(i,e.originCol,e.originRow);for(const t of o)this.adaptRules(i,t,[qt(e.col,e.row)],[]);break;case"PASTE_CONDITIONAL_FORMAT":this.pasteCf(e.origin,e.target,e.operation)}}finalize(){this.isStale&&(this.computeStyles(),this.isStale=!1)}getCellComputedStyle(e){var t;const{sheetId:i,col:o,row:n}=e,s=this.getters.getCell(e),r=this.computedStyles[i],a=r&&(null===(t=r[o])||void 0===t?void 0:t[n]),l={...null==s?void 0:s.style,...a};return this.getters.getEvaluatedCell(e).link&&!l.textColor&&(l.textColor=I),this.getters.isFilterHeader(e)&&(l.bold=!0),l}getConditionalIcon({col:e,row:t}){var i;const o=this.getters.getActiveSheetId(),n=this.computedIcons[o];return n&&(null===(i=n[e])||void 0===i?void 0:i[t])}computeStyles(){var e;const t=this.getters.getActiveSheetId();this.computedStyles[t]={},this.computedIcons[t]={};const i=this.computedStyles[t];for(let o of this.getters.getConditionalFormats(t).reverse())try{switch(o.rule.type){case"ColorScaleRule":for(let e of o.ranges)this.applyColorScale(e,o.rule);break;case"IconSetRule":for(let e of o.ranges)this.applyIcon(e,o.rule);break;default:for(let n of o.ranges){const s=this.getters.getRangeFromSheetXC(t,n).zone;for(let n=s.top;n<=s.bottom;n++)for(let r=s.left;r<=s.right;r++){const s=this.rulePredicate[o.rule.type];let a=this.getters.getEvaluatedCell({sheetId:t,col:r,row:n});s&&s(a,o.rule)&&(i[r]||(i[r]=[]),i[r][n]=Object.assign((null===(e=i[r])||void 0===e?void 0:e[n])||{},o.rule.style))}}}}catch(e){}}parsePoint(e,t,i){const o=this.getters.getActiveSheetId(),n=this.getters.getEvaluatedCellsInZone(o,this.getters.getRangeFromSheetXC(o,e).zone).filter((e=>e.type===ln.number)).map((e=>e.value));switch(t.type){case"value":return"max"===i?Math.max(...n):Math.min(...n);case"number":return Number(t.value);case"percentage":const e=Math.min(...n);return e+(Math.max(...n)-e)*Number(t.value)/100;case"percentile":return ri(n,Number(t.value)/100,!0);case"formula":const o=t.value&&this.getters.evaluateFormula(t.value);return o instanceof Promise?null:o;default:return null}}applyIcon(e,t){const i=this.parsePoint(e,t.lowerInflectionPoint),o=this.parsePoint(e,t.upperInflectionPoint);if(null===i||null===o||i>o)return;const n=this.getters.getActiveSheetId(),s=this.getters.getRangeFromSheetXC(n,e).zone,r=this.computedIcons[n],a=[t.icons.upper,t.icons.middle,t.icons.lower];for(let e=s.top;e<=s.bottom;e++)for(let l=s.left;l<=s.right;l++){const s=this.getters.getEvaluatedCell({sheetId:n,col:l,row:e});if(s.type!==ln.number)continue;const c=this.computeIcon(s.value,o,t.upperInflectionPoint.operator,i,t.lowerInflectionPoint.operator,a);r[l]||(r[l]=[]),r[l][e]=c}}computeIcon(e,t,i,o,n,s){return"ge"===i&&e>=t||"gt"===i&&e>t?s[0]:"ge"===n&&e>=o||"gt"===n&&e>o?s[1]:s[2]}applyColorScale(e,t){var i;const o=this.parsePoint(e,t.minimum,"min"),n=t.midpoint?this.parsePoint(e,t.midpoint):null,s=this.parsePoint(e,t.maximum,"max");if(null===o||null===s||o>=s||n&&(o>=n||n>=s))return;const r=this.getters.getActiveSheetId(),a=this.getters.getRangeFromSheetXC(r,e).zone,l=this.computedStyles[r],c=[];t.midpoint&&n?(c.push({minValue:o,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(o,n,t.minimum.color,t.midpoint.color)}),c.push({minValue:n,minColor:t.midpoint.color,colorDiffUnit:this.computeColorDiffUnits(n,s,t.midpoint.color,t.maximum.color)})):c.push({minValue:o,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(o,s,t.minimum.color,t.maximum.color)});for(let e=a.top;e<=a.bottom;e++)for(let t=a.left;t<=a.right;t++){const a=this.getters.getEvaluatedCell({sheetId:r,col:t,row:e});if(a.type===ln.number){const r=ke(a.value,o,s);let h;h=2===c.length&&n?r<=n?this.colorCell(r,c[0].minValue,c[0].minColor,c[0].colorDiffUnit):this.colorCell(r,c[1].minValue,c[1].minColor,c[1].colorDiffUnit):this.colorCell(r,c[0].minValue,c[0].minColor,c[0].colorDiffUnit),l[t]||(l[t]=[]),l[t][e]=(null===(i=l[t])||void 0===i?void 0:i[e])||{},l[t][e].fillColor=Ct(h)}}}computeColorDiffUnits(e,t,i,o){const n=t-e;return[((i>>16)%256-(o>>16)%256)/n,((i>>8)%256-(o>>8)%256)/n,(i%256-o%256)/n]}colorCell(e,t,i,o){const[n,s,r]=o;return Math.round((i>>16)%256-n*(e-t))<<16|Math.round((i>>8)%256-s*(e-t))<<8|Math.round(i%256-r*(e-t))}adaptRules(e,t,i,o){if(0===i.length&&0===o.length)return;const n=this.getters.getConditionalFormats(e),s=n.findIndex((e=>e.id===t.id));let r=[];s>-1&&(r=n[s].ranges),r=r.concat(i);const a=eo(r,o);0!==a.length?this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},ranges:a.map((t=>this.getters.getRangeDataFromXc(e,t))),sheetId:e}):this.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:t.id,sheetId:e})}pasteCf(e,t,i){const o=qt(t.col,t.row);for(let n of this.getters.getConditionalFormats(e.sheetId))for(let s of n.ranges)if(Qi(e.col,e.row,this.getters.getRangeFromSheetXC(e.sheetId,s).zone)){const s=n,r=[];if("CUT"===i&&r.push(qt(e.col,e.row)),e.sheetId===t.sheetId)this.adaptRules(e.sheetId,s,[o],r);else{this.adaptRules(e.sheetId,s,[],r);const i=this.getCFToCopyTo(t.sheetId,s);this.adaptRules(t.sheetId,i,[o],[])}}}getCFToCopyTo(e,t){const i=this.getters.getConditionalFormats(e).find((e=>e.stopIfTrue===t.stopIfTrue&&ct(e.rule,t.rule)));return i||{...t,id:this.uuidGenerator.uuidv4(),ranges:[]}}}tb.getters=["getConditionalIcon","getCellComputedStyle"];class ib extends Yv{constructor(){super(...arguments),this.filterValues={},this.hiddenRows=new Set,this.isEvaluationDirty=!1}allowDispatch(e){if("UPDATE_FILTER"===e.type)if(!this.getters.getFilterId(e))return 79;return 0}handle(e){switch(e.type){case"UNDO":case"REDO":case"UPDATE_CELL":case"EVALUATE_CELLS":case"ACTIVATE_SHEET":case"REMOVE_FILTER_TABLE":case"ADD_COLUMNS_ROWS":case"REMOVE_COLUMNS_ROWS":this.isEvaluationDirty=!0;break;case"START":for(const e of this.getters.getSheetIds()){this.filterValues[e]={};for(const t of this.getters.getFilters(e))this.filterValues[e][t.id]=[]}break;case"CREATE_SHEET":this.filterValues[e.sheetId]={};break;case"HIDE_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":this.updateHiddenRows();break;case"UPDATE_FILTER":this.updateFilter(e),this.updateHiddenRows();break;case"DUPLICATE_SHEET":const t={};for(const i of this.getters.getFilters(e.sheetIdTo)){const o=i.zoneWithHeaders;t[i.id]=this.getFilterValues({sheetId:e.sheetId,col:o.left,row:o.top})}this.filterValues[e.sheetIdTo]=t}}finalize(){this.isEvaluationDirty&&(this.updateHiddenRows(),this.isEvaluationDirty=!1)}isRowFiltered(e,t){return e===this.getters.getActiveSheetId()&&this.hiddenRows.has(t)}getCellBorderWithFilterBorder(e){const{sheetId:t,col:i,row:o}=e;let n;for(let e of this.getters.getFilterTables(t)){const s=e.zone;if(Qi(i,o,s)){const e=this.intersectZoneWithViewport(t,s);n={top:o===e.top?X:void 0,bottom:o===e.bottom?X:void 0,left:i===e.left?X:void 0,right:i===e.right?X:void 0}}}const s=this.getters.getCellBorder(e),r={...n,...dt(s||{})};return ot(r)?null:r}getFilterHeaders(e){const t=[];for(let i of this.getters.getFilterTables(e)){const o=i.zone;if(!o)continue;const n=o.top;for(let i=o.left;i<=o.right;i++)this.getters.isColHidden(e,i)||this.getters.isRowHidden(e,n)||t.push({col:i,row:n})}return t}getFilterValues(e){const t=this.getters.getFilterId(e),i=e.sheetId;return t&&this.filterValues[i]&&this.filterValues[i][t]||[]}isFilterHeader({sheetId:e,col:t,row:i}){return this.getFilterHeaders(e).some((e=>e.col===t&&e.row===i))}isFilterActive(e){var t,i;const o=this.getters.getFilterId(e),n=e.sheetId;return Boolean(o&&(null===(i=null===(t=this.filterValues[n])||void 0===t?void 0:t[o])||void 0===i?void 0:i.length))}intersectZoneWithViewport(e,t){return{left:this.getters.findVisibleHeader(e,"COL",t.left,t.right),right:this.getters.findVisibleHeader(e,"COL",t.right,t.left),top:this.getters.findVisibleHeader(e,"ROW",t.top,t.bottom),bottom:this.getters.findVisibleHeader(e,"ROW",t.bottom,t.top)}}updateFilter({col:e,row:t,values:i,sheetId:o}){const n=this.getters.getFilterId({sheetId:o,col:e,row:t});n&&(this.filterValues[o]||(this.filterValues[o]={}),this.filterValues[o][n]=i)}updateHiddenRows(){var e,t;const i=this.getters.getActiveSheetId(),o=this.getters.getFilters(i).sort(((e,t)=>e.zoneWithHeaders.top-t.zoneWithHeaders.top)),n=new Set;for(let s of o){if(this.getters.isRowHiddenByUser(i,s.zoneWithHeaders.top))continue;if(n.has(s.zoneWithHeaders.top))continue;const o=null===(t=null===(e=this.filterValues[i])||void 0===e?void 0:e[s.id])||void 0===t?void 0:t.map(ut);if(o&&s.filteredZone)for(let e=s.filteredZone.top;e<=s.filteredZone.bottom;e++){const t=this.getCellValueAsString(i,s.col,e);o.includes(t)&&n.add(e)}}this.hiddenRows=n}getCellValueAsString(e,t,i){return this.getters.getEvaluatedCell({sheetId:e,col:t,row:i}).formattedValue.toLowerCase()}exportForExcel(e){for(const t of e.sheets){const e=t.id;for(const i of t.filterTables){const o=Bi(i.range),n=[],s=[];for(const i of He(0,io(o).numberOfCols)){const r={sheetId:t.id,col:o.left+i,row:o.top},a=this.getFilterValues(r),l=this.getters.getFilter(r);if(!l)continue;const c=l.filteredZone?no(l.filteredZone).map((t=>this.getters.getEvaluatedCell({sheetId:e,...t}).formattedValue)):[];if(a.length){const e=c.filter((e=>e)).filter((e=>!a.includes(e)));n.push({colId:i,displayedValues:[...new Set(e)],displayBlanks:!a.includes("")&&c.some((e=>!e))})}const h={col:l.col,row:l.zoneWithHeaders.top,sheetId:e},d=this.getters.getEvaluatedCell(h).formattedValue,u=this.getUniqueColNameForExcel(i,d,s);s.push(u),t.cells[qt(h.col,h.row)]={...t.cells[qt(h.col,h.row)],content:u,value:u,isFormula:!1}}i.filters=n}}}getUniqueColNameForExcel(e,t,i){t||(t=`Column${e}`);let o=t,n=2;for(;i.includes(o);)o=t+String(n),n++;return o}}ib.getters=["getCellBorderWithFilterBorder","getFilterHeaders","getFilterValues","isFilterHeader","isRowFiltered","isFilterActive"];class ob{constructor(e,t,i,o,n,s){this.getters=e,this.sheetId=t,this.boundaries=i,this.viewportWidth=o.width,this.viewportHeight=o.height,this.offsetScrollbarX=s.x,this.offsetScrollbarY=s.y,this.canScrollVertically=n.canScrollVertically,this.canScrollHorizontally=n.canScrollHorizontally,this.offsetCorrectionX=this.getters.getColDimensions(this.sheetId,this.boundaries.left).start,this.offsetCorrectionY=this.getters.getRowDimensions(this.sheetId,this.boundaries.top).start,this.adjustViewportOffsetX(),this.adjustViewportOffsetY()}getMaxSize(){const 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:i,size:o}=this.getters.getColDimensions(this.sheetId,e),{end:n,size:s}=this.getters.getRowDimensions(this.sheetId,t),r=this.searchHeaderIndex("COL",i-this.viewportWidth,0),a=this.getters.getColSize(this.sheetId,r),l=this.searchHeaderIndex("ROW",n-this.viewportHeight,0),c=this.getters.getRowSize(this.sheetId,l);let h=i-this.offsetCorrectionX;this.canScrollHorizontally&&(h+=Math.max(F,Math.min(a,this.viewportWidth-o)),h=Math.max(h,this.viewportWidth));let d=n-this.offsetCorrectionY;return this.canScrollVertically&&(d+=Math.max(D+5,Math.min(c,this.viewportHeight-s)),d=Math.max(d,this.viewportHeight)),{width:h,height:d}}getColIndex(e,t=!1){return e<this.offsetCorrectionX||e>this.offsetCorrectionX+this.viewportWidth?-1:this.searchHeaderIndex("COL",e-this.offsetCorrectionX,this.left,t)}getRowIndex(e,t=!1){return e<this.offsetCorrectionY||e>this.offsetCorrectionY+this.viewportHeight?-1:this.searchHeaderIndex("ROW",e-this.offsetCorrectionY,this.top,t)}adjustPosition(e){const t=this.sheetId;e||(e=this.getters.getSheetPosition(t));const i=this.getters.getMainCellPosition({sheetId:t,...e}),{col:o,row:n}=this.getters.getNextVisibleCellPosition(i);Qi(o,this.boundaries.top,this.boundaries)&&this.adjustPositionX(o),Qi(this.boundaries.left,n,this.boundaries)&&this.adjustPositionY(n)}adjustPositionX(e){const t=this.sheetId,{end:i}=this.getters.getColDimensions(t,e),o=this.getters.getNumberCols(t);if(this.offsetX+this.offsetCorrectionX+this.viewportWidth<i){let i=e;for(;this.getters.isColHidden(t,i)&&e<o;)i++;const n=this.getters.getColDimensions(t,i).end,s=this.searchHeaderIndex("COL",n-this.viewportWidth-this.offsetCorrectionX,this.boundaries.left,!0);this.offsetX=this.getters.getColDimensions(t,s).end-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}else if(this.left>e){let i=e;for(;this.getters.isColHidden(t,i)&&e>0;)i--;this.offsetX=this.getters.getColDimensions(t,i).start-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}}adjustPositionY(e){const t=this.sheetId,{end:i}=this.getters.getRowDimensions(t,e),o=this.getters.getNumberRows(t);if(this.offsetY+this.viewportHeight+this.offsetCorrectionY<i){let i=e;for(;this.getters.isRowHidden(t,i)&&e<o;)i++;const n=this.getters.getRowDimensions(t,i).end,s=this.searchHeaderIndex("ROW",n-this.viewportHeight-this.offsetCorrectionY,this.boundaries.top,!0);this.offsetY=this.getters.getRowDimensions(t,s).end-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY()}else if(this.top>e){let i=e;for(;this.getters.isRowHidden(t,i)&&e>0;)i--;this.offsetY=this.getters.getRowDimensions(t,i).start-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY()}}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}getRect(e){const t=Xi(e,this.zone);if(t){return{x:this.getters.getColRowOffset("COL",this.zone.left,t.left)+this.offsetCorrectionX,y:this.getters.getColRowOffset("ROW",this.zone.top,t.top)+this.offsetCorrectionY,width:Math.min(this.getters.getColRowOffset("COL",t.left,t.right+1),this.viewportWidth),height:Math.min(this.getters.getColRowOffset("ROW",t.top,t.bottom+1),this.viewportHeight)}}}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,i=0,o=!1){let n=0;const s=this.sheetId,r=this.getters.getNumberHeaders(s,e);for(let a=i;a<=r-1;a++){const i=o||"COL"!==e?a<this.top&&a>this.bottom:a<this.left&&a>this.right;if(!this.getters.isHeaderHidden(s,e,a)&&!i&&(n+="COL"===e?this.getters.getColSize(s,a):this.getters.getRowSize(s,a),n>t))return a}return-1}get zone(){return{left:this.left,right:this.right,top:this.top,bottom:this.bottom}}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetScrollbarX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetScrollbarY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){const{width:e}=this.getMaxSize();this.viewportWidth+this.offsetScrollbarX>e&&(this.offsetScrollbarX=Math.max(0,e-this.viewportWidth))}this.left=this.getColIndex(this.offsetScrollbarX,!0),this.right=this.getColIndex(this.offsetScrollbarX+this.viewportWidth,!0),-1===this.right&&(this.right=this.boundaries.right),this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){const{height:e}=this.getMaxSize();this.viewportHeight+this.offsetScrollbarY>e&&(this.offsetScrollbarY=Math.max(0,e-this.viewportHeight))}this.top=this.getRowIndex(this.offsetScrollbarY,!0),this.bottom=this.getRowIndex(this.offsetScrollbarY+this.viewportWidth,!0),-1===this.bottom&&(this.bottom=this.boundaries.bottom),this.adjustViewportZoneY()}adjustViewportZoneX(){const e=this.sheetId;this.left=this.searchHeaderIndex("COL",this.offsetScrollbarX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex("COL",this.viewportWidth,this.left)),-1===this.left&&(this.left=this.boundaries.left),-1===this.right&&(this.right=this.getters.getNumberCols(e)-1),this.offsetX=this.getters.getColDimensions(e,this.left).start-this.getters.getColDimensions(e,this.boundaries.left).start}adjustViewportZoneY(){const e=this.sheetId;this.top=this.searchHeaderIndex("ROW",this.offsetScrollbarY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex("ROW",this.viewportHeight,this.top)),-1===this.top&&(this.top=this.boundaries.top),-1===this.bottom&&(this.bottom=this.getters.getNumberRows(e)-1),this.offsetY=this.getters.getRowDimensions(e,this.top).start-this.getters.getRowDimensions(e,this.boundaries.top).start}}class nb extends Yv{constructor(){super(...arguments),this.viewports={},this.sheetViewWidth=1e3,this.sheetViewHeight=1e3,this.gridOffsetX=0,this.gridOffsetY=0,this.sheetsWithDirtyViewports=new Set}allowDispatch(e){switch(e.type){case"SET_VIEWPORT_OFFSET":return this.checkScrollingDirection(e);case"RESIZE_SHEETVIEW":return this.chainValidations(this.checkValuesAreDifferent,this.checkPositiveDimension)(e);default:return 0}}handleEvent(e){switch(e.type){case"HeadersSelected":case"AlterZone":break;case"ZonesSelected":let{col:t,row:i}=ro(e.previousAnchor.zone,e.anchor.zone);if("updateAnchor"===e.mode){const o=e.previousAnchor.zone,n=e.anchor.zone,{top:s,bottom:r,left:a,right:l}=this.getters.getActiveMainViewport();o.left===n.left&&o.right===n.right&&(t=a>t||t>l?a:t),o.top===n.top&&o.bottom===n.bottom&&(i=s>i||i>r?s:i)}const o=this.getters.getActiveSheetId();t=Math.min(t,this.getters.getNumberCols(o)-1),i=Math.min(i,this.getters.getNumberRows(o)-1),this.refreshViewport(this.getters.getActiveSheetId(),{col:t,row:i})}}handle(e){var t;switch(this.cleanViewports(),e.type){case"START":this.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.resetViewports(this.getters.getActiveSheetId());break;case"UNDO":case"REDO":this.resetSheetViews();break;case"RESIZE_SHEETVIEW":this.resizeSheetView(e.height,e.width,e.gridOffsetX,e.gridOffsetY);break;case"SET_VIEWPORT_OFFSET":this.setSheetViewOffset(e.offsetX,e.offsetY);break;case"SHIFT_VIEWPORT_DOWN":const{top:i}=this.getActiveMainViewport(),o=this.getters.getActiveSheetId(),n=this.clipOffsetY(this.getters.getRowDimensions(o,i).start+this.sheetViewHeight);this.shiftVertically(n);break;case"SHIFT_VIEWPORT_UP":{const{top:e}=this.getActiveMainViewport(),t=this.getters.getActiveSheetId(),i=this.clipOffsetY(this.getters.getRowDimensions(t,e).end-this.sheetViewHeight);this.shiftVertically(i);break}case"REMOVE_COLUMNS_ROWS":case"RESIZE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"UPDATE_FILTER":this.resetViewports(e.sheetId);break;case"UPDATE_CELL":("content"in e||"format"in e||void 0!==(null===(t=e.style)||void 0===t?void 0:t.fontSize))&&this.sheetsWithDirtyViewports.add(e.sheetId);break;case"ACTIVATE_SHEET":this.setViewports(),this.refreshViewport(e.sheetIdTo);break;case"UNFREEZE_ROWS":case"UNFREEZE_COLUMNS":case"FREEZE_COLUMNS":case"FREEZE_ROWS":case"UNFREEZE_COLUMNS_ROWS":this.resetViewports(this.getters.getActiveSheetId());break;case"DELETE_SHEET":this.sheetsWithDirtyViewports.delete(e.sheetId);break;case"START_EDITION":const{col:s,row:r}=this.getters.getActivePosition();this.refreshViewport(this.getters.getActiveSheetId(),{col:s,row:r})}}finalize(){for(const e of this.sheetsWithDirtyViewports)this.resetViewports(e);this.sheetsWithDirtyViewports=new Set,this.setViewports()}setViewports(){var e;const t=this.getters.getSheetIds();for(const i of t)(null===(e=this.viewports[i])||void 0===e?void 0:e.bottomRight)||this.resetViewports(i)}getColIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getColIndex(e))))}getRowIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getRowIndex(e))))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getActiveMainViewport(){const e=this.getters.getActiveSheetId();return this.getMainViewport(e)}getActiveSheetScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getActiveSheetDOMScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetScrollbarX,scrollY:t.offsetScrollbarY}}getSheetViewVisibleCols(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>He(e.left,e.right+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"COL",t)))}getSheetViewVisibleRows(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>He(e.top,e.bottom+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"ROW",t)))}getMainViewportRect(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e),{xSplit:i,ySplit:o}=this.getters.getPaneDivisions(e);let{width:n,height:s}=t.getMaxSize();return{x:this.getters.getColDimensions(e,i).start,y:this.getters.getRowDimensions(e,o).start,width:n,height:s}}getMaximumSheetOffset(){const e=this.getters.getActiveSheetId(),{width:t,height:i}=this.getMainViewportRect(),o=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-o.viewportWidth+1),maxOffsetY:Math.max(0,i-o.viewportHeight+1)}}getColRowOffsetInViewport(e,t,i){const o=this.getters.getActiveSheetId(),n=this.getters.getSheetViewVisibleCols(),s=this.getters.getSheetViewVisibleRows();if(i<t)return-this.getColRowOffsetInViewport(e,i,t);let r=0;const a="COL"===e?n:s;for(let n=t;n<i;n++)a.includes(n)&&(r+="COL"===e?this.getters.getColSize(o,n):this.getters.getRowSize(o,n));return r}isVisibleInViewport({sheetId:e,col:t,row:i}){return this.getSubViewports(e).some((e=>e.isVisible(t,i)))}getEdgeScrollCol(e,t,i){let o=!1,n=0,s=0;const{xSplit:r}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:a}=this.getSheetViewDimension(),{x:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollX;return e>a?(o=!0,s=Yt(e-a),n=1):e<l&&i>=l&&c>0?(o=!0,s=Yt(l-e),n=-1):r&&t<l&&e>l&&(o=!0,s=Yt(e),n="reset"),{canEdgeScroll:o,direction:n,delay:s}}getEdgeScrollRow(e,t,i){let o=!1,n=0,s=0;const{ySplit:r}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:a}=this.getSheetViewDimension(),{y:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollY;return e>a?(o=!0,s=Yt(e-a),n=1):e<l&&i>=l&&c>0?(o=!0,s=Yt(l-e),n=-1):r&&t<l&&e>l&&(o=!0,s=Yt(e),n="reset"),{canEdgeScroll:o,direction:n,delay:s}}getVisibleRect(e){const t=this.getters.getActiveSheetId(),i=this.getSubViewports(t).map((t=>t.getRect(e))).filter(it);if(0===i.length)return{x:0,y:0,width:0,height:0};const o=Math.min(...i.map((e=>e.x))),n=Math.min(...i.map((e=>e.y))),s=Math.max(...i.map((e=>e.x+e.width)))-o,r=Math.max(...i.map((e=>e.y+e.height)))-n;return{x:o+this.gridOffsetX,y:n+this.gridOffsetY,width:s,height:r}}getMainViewportCoordinates(){const e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,i).start}}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(it)}checkPositiveDimension(e){return e.width<0||e.height<0?68:0}checkValuesAreDifferent(e){const{height:t,width:i}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===i&&e.height===t?76:0}checkScrollingDirection({offsetX:e,offsetY:t}){const i=this.getMainInternalViewport(this.getters.getActiveSheetId());return!i.canScrollHorizontally&&e>0||!i.canScrollVertically&&t>0?69:0}getMainViewport(e){const 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(){const e=this.getters.getSheetIds();for(let t of Object.keys(this.viewports))e.includes(t)||delete this.viewports[t]}resetSheetViews(){for(let e of Object.keys(this.viewports)){const t=this.getters.getSheetPosition(e);this.resetViewports(e);const i=this.getSubViewports(e);Object.values(i).forEach((e=>{e.adjustPosition(t)}))}}resizeSheetView(e,t,i=0,o=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=i,this.gridOffsetY=o,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.resetViewports(e)}setSheetViewOffset(e,t){const i=this.getters.getActiveSheetId(),{maxOffsetX:o,maxOffsetY:n}=this.getMaximumSheetOffset();Object.values(this.getSubViewports(i)).forEach((i=>i.setViewportOffset(ke(e,0,o),ke(t,0,n))))}clipOffsetY(e){const{height:t}=this.getMainViewportRect(),i=t-this.sheetViewHeight;return e=Math.min(e,i),e=Math.max(e,0)}getViewportOffset(e){var t,i;return{x:(null===(t=this.viewports[e])||void 0===t?void 0:t.bottomRight.offsetScrollbarX)||0,y:(null===(i=this.viewports[e])||void 0===i?void 0:i.bottomRight.offsetScrollbarY)||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;const{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e),o=this.getters.getNumberCols(e),n=this.getters.getNumberRows(e),s=this.getters.getColRowOffset("COL",0,t,e),r=this.getters.getColRowOffset("ROW",0,i,e),{xRatio:a,yRatio:l}=this.getFrozenSheetViewRatio(e),c=a<1,h=l<1,d=this.getViewportOffset(e),u={topLeft:i&&t&&new ob(this.getters,e,{left:0,right:t-1,top:0,bottom:i-1},{width:s,height:r},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:i&&new ob(this.getters,e,{left:t,right:o-1,top:0,bottom:i-1},{width:this.sheetViewWidth-s,height:r},{canScrollHorizontally:c,canScrollVertically:!1},{x:c?d.x:0,y:0})||void 0,bottomLeft:t&&new ob(this.getters,e,{left:0,right:t-1,top:i,bottom:n-1},{width:s,height:this.sheetViewHeight-r},{canScrollHorizontally:!1,canScrollVertically:h},{x:0,y:h?d.y:0})||void 0,bottomRight:new ob(this.getters,e,{left:t,right:o-1,top:i,bottom:n-1},{width:this.sheetViewWidth-s,height:this.sheetViewHeight-r},{canScrollHorizontally:c,canScrollVertically:h},{x:c?d.x:0,y:h?d.y:0})};this.viewports[e]=u}refreshViewport(e,t){Object.values(this.getSubViewports(e)).forEach((e=>{e.adjustViewportZone(),e.adjustPosition(t)}))}shiftVertically(e){const{top:t}=this.getActiveMainViewport(),{scrollX:i}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(i,e);const{anchor:o}=this.getters.getSelection(),n=this.getActiveMainViewport().top-t;this.selection.selectCell(o.cell.col,o.cell.row+n)}getVisibleFigures(){const e=this.getters.getActiveSheetId(),t=[],i=this.getters.getFigures(e),{scrollX:o,scrollY:n}=this.getActiveSheetScrollInfo(),{x:s,y:r}=this.getters.getMainViewportCoordinates(),{width:a,height:l}=this.getters.getSheetViewDimensionWithHeaders();for(const e of i)e.x>=s&&(e.x+e.width<=s+o||e.x>=a+o+s)||e.y>=r&&(e.y+e.height<=r+n||e.y>=l+n+r)||t.push(e);return t}getFrozenSheetViewRatio(e){const{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e),o=this.getters.getColDimensions(e,t).start,n=this.getters.getRowDimensions(e,i).start;return{xRatio:o/(this.sheetViewWidth+this.gridOffsetX),yRatio:n/(this.sheetViewHeight+this.gridOffsetY)}}}nb.getters=["getColIndex","getRowIndex","getActiveMainViewport","getSheetViewDimension","getSheetViewDimensionWithHeaders","getMainViewportRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow","getVisibleFigures","getVisibleRect","getColRowOffsetInViewport","getMainViewportCoordinates","getActiveSheetScrollInfo","getActiveSheetDOMScrollInfo","getSheetViewVisibleCols","getSheetViewVisibleRows","getFrozenSheetViewRatio"];class sb{constructor(e,t,i){this.index=0,this.cells=e,this.getters=t,this.direction=i}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:i,tooltip:o}=Tn.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:i,tooltip:o,origin:{col:e.data.col,row:e.data.row}}}}class rb extends Yv{constructor(){super(...arguments),this.lastCellSelected={}}allowDispatch(e){switch(e.type){case"AUTOFILL_SELECT":const t=this.getters.getActiveSheetId();return this.lastCellSelected.col=-1===e.col?this.lastCellSelected.col:ke(e.col,0,this.getters.getNumberCols(t)),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:ke(e.row,0,this.getters.getNumberRows(t)),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:45;case"AUTOFILL_AUTO":const i=this.getters.getSelectedZone();return i.top===i.bottom?0:1}return 0}handle(e){switch(e.type){case"AUTOFILL":this.autofill(!0);break;case"AUTOFILL_SELECT":this.select(e.col,e.row);break;case"AUTOFILL_AUTO":this.autofillAuto();break;case"AUTOFILL_CELL":this.autoFillMerge(e.originCol,e.originRow,e.col,e.row);const t=this.getters.getActiveSheetId();this.dispatch("UPDATE_CELL",{sheetId:t,col:e.col,row:e.row,style:e.style||null,content:e.content||"",format:e.format||""}),this.dispatch("SET_BORDER",{sheetId:t,col:e.col,row:e.row,border:e.border})}}getAutofillTooltip(){return this.tooltip}autofill(e){if(!this.autofillZone||!this.steps||void 0===this.direction)return void(this.tooltip=void 0);const t=this.getters.getSelectedZone(),i=this.autofillZone;switch(this.direction){case"down":for(let o=t.left;o<=t.right;o++){const n=[];for(let e=t.top;e<=t.bottom;e++)n.push(qt(o,e));const s=this.createGenerator(n);for(let t=i.top;t<=i.bottom;t++)this.computeNewCell(s,o,t,e)}break;case"up":for(let o=t.left;o<=t.right;o++){const n=[];for(let e=t.bottom;e>=t.top;e--)n.push(qt(o,e));const s=this.createGenerator(n);for(let t=i.bottom;t>=i.top;t--)this.computeNewCell(s,o,t,e)}break;case"left":for(let o=t.top;o<=t.bottom;o++){const n=[];for(let e=t.right;e>=t.left;e--)n.push(qt(e,o));const s=this.createGenerator(n);for(let t=i.right;t>=i.left;t--)this.computeNewCell(s,t,o,e)}break;case"right":for(let o=t.top;o<=t.bottom;o++){const n=[];for(let e=t.left;e<=t.right;e++)n.push(qt(e,o));const s=this.createGenerator(n);for(let t=i.left;t<=i.right;t++)this.computeNewCell(s,t,o,e)}}e&&(this.autofillZone=void 0,this.selection.resizeAnchorZone(this.direction,this.steps),this.lastCellSelected={},this.direction=void 0,this.steps=0,this.tooltip=void 0)}select(e,t){const i=this.getters.getSelectedZone();if(Qi(e,t,i))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case"up":this.saveZone(t,i.top-1,i.left,i.right),this.steps=i.top-t;break;case"down":this.saveZone(i.bottom+1,t,i.left,i.right),this.steps=t-i.bottom;break;case"left":this.saveZone(i.top,i.bottom,e,i.left-1),this.steps=i.left-e;break;case"right":this.saveZone(i.top,i.bottom,i.right+1,e),this.steps=e-i.right}this.autofill(!1)}}autofillAuto(){var e,t;const i=this.getters.getSelectedZone(),o=this.getters.getActiveSheetId();let n=i.left,s=i.bottom;if(n>0){let t={sheetId:o,col:n-1,row:s};for(;this.getters.getEvaluatedCell(t).type!==ln.empty||(null===(e=this.getters.getCell(t))||void 0===e?void 0:e.content);)s+=1,t={sheetId:o,col:n-1,row:s}}if(s===i.bottom&&(n=i.right,n<=this.getters.getNumberCols(o))){let e={sheetId:o,col:n+1,row:s};for(;this.getters.getEvaluatedCell(e).type!==ln.empty||(null===(t=this.getters.getCell(e))||void 0===t?void 0:t.content);)s+=1,e={sheetId:o,col:n+1,row:s}}s!==i.bottom&&(this.select(i.left,s-1),this.autofill(!0))}computeNewCell(e,t,i,o){const{cellData:n,tooltip:s,origin:r}=e.next(),{content:a,style:l,border:c,format:h}=n;this.tooltip=s,o&&this.dispatch("AUTOFILL_CELL",{originCol:r.col,originRow:r.row,col:t,row:i,content:a,style:l,border:c,format:h})}getRule(e,t){const i=An.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((i=>i.condition(e,t)));return i&&i.generateRule(e,t)}createGenerator(e){const t=[],i=[],o=this.getters.getActiveSheetId();for(let t of e){const{col:e,row:n}=Gt(t),s=this.getters.getCell({sheetId:o,col:e,row:n});i.push({col:e,row:n,cell:s,sheetId:o})}const n=i.map((e=>e.cell));for(let e of i){let i={type:"COPY_MODIFIER"};if(e&&e.cell){i=this.getRule(e.cell,n)||i}const o=this.getters.getCellBorder(e)||void 0;t.push({data:{...e,border:o},rule:i})}return new sb(t,this.getters,this.direction)}saveZone(e,t,i,o){this.autofillZone={top:e,bottom:t,left:i,right:o}}getDirection(e,t){const i=this.getters.getSelectedZone(),o={up:{number:i.top-t,value:"up"},down:{number:t-i.bottom,value:"down"},left:{number:i.left-e,value:"left"},right:{number:e-i.right,value:"right"}};if(1===Object.values(o).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(o).find((e=>e.number>0?1:0)).value;const n=o.up.number>0?"up":"down",s=o.left.number>0?"left":"right";return Math.abs(o[n].number)>=Math.abs(o[s].number)?o[n].value:o[s].value}autoFillMerge(e,t,i,o){const n=this.getters.getActiveSheetId(),s={sheetId:n,col:i,row:o},r={sheetId:n,col:e,row:t};if(this.getters.isInMerge(s)&&!this.getters.isInMerge(r)){const e=this.getters.getMerge(s);e&&this.dispatch("REMOVE_MERGE",{sheetId:n,target:[e]})}const a=this.getters.getMerge(r);(null==a?void 0:a.topLeft.col)===e&&(null==a?void 0:a.topLeft.row)===t&&this.dispatch("ADD_MERGE",{sheetId:n,target:[{top:o,bottom:o+a.bottom-a.top,left:i,right:i+a.right-a.left}]})}drawGrid(e){if(!this.autofillZone)return;const{ctx:t,thinLineWidth:i}=e,{x:o,y:n,width:s,height:r}=this.getters.getVisibleRect(this.autofillZone);s>0&&r>0&&(t.strokeStyle="black",t.lineWidth=i,t.setLineDash([3]),t.strokeRect(o,n,s,r),t.setLineDash([]))}}rb.layers=[5],rb.getters=["getAutofillTooltip"];class ab extends Yv{handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:i}=this.getters.getSelection();for(const o of t){const t=this.getAutomaticSums(e,o,i.cell);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,i){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,i):this.sumData(e,t)}sumData(e,t){const i=this.dimensionsToSum(e,t),o=this.sumDimensions(e,t,i).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return i.has("ROW")&&i.has("COL")&&o.push(this.sumTotal(t)),o}sumAdjacentData(e,t,i){const{col:o,row:n}=Qi(i.col,i.row,t)?i:{col:t.left,row:t.top},s=this.findAdjacentData(e,o,n);return s?this.getters.isSingleCellOrMerge(e,t)||oo(ji(s,t))?[{position:{col:o,row:n},zone:s}]:this.sumDimensions(e,ji(s,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,i){const o=this.getters.getSheet(e),n=this.getters.getMainCellPosition({sheetId:e,col:t,row:i}),s=this.findSuitableZoneToSum(o,n.col,n.row);if(s)return this.getters.expandZone(e,s)}findSuitableZoneToSum(e,t,i){const o=this.getters.getEvaluatedCell({sheetId:e.id,col:t,row:i-1}),n=this.getters.getEvaluatedCell({sheetId:e.id,col:t-1,row:i});if(this.isNumber(n)&&!this.isNumber(o))return this.findHorizontalZone(e,t,i);const s=this.findVerticalZone(e,t,i);if(this.isZoneValid(s))return s;const r=this.findHorizontalZone(e,t,i);return this.isZoneValid(r)?r:void 0}findVerticalZone(e,t,i){const o={top:0,bottom:i-1,left:t,right:t},n=this.reduceZoneStart(e,o,o.bottom);return{...o,top:n}}findHorizontalZone(e,t,i){const o={top:i,bottom:i,left:0,right:t-1},n=this.reduceZoneStart(e,o,o.right);return{...o,left:n}}reduceZoneStart(e,t,i){const o=this.getters.getEvaluatedCellsInZone(e.id,t),n=He(i,-1,-1),s=n.filter((e=>o[e]&&!o[e].isAutoSummable)),r=Math.max(...s),a=$e(n.filter((e=>this.isNumber(o[e]))))[0]||[];return Math.max(...a)<r?1/0:Math.min(...a)}shouldFindData(e,t){return this.getters.isEmpty(e,t)||this.getters.isSingleCellOrMerge(e,t)}isNumber(e){var t;return e.type===ln.number&&!(null===(t=e.format)||void 0===t?void 0:t.match(Y))}isZoneValid(e){return e.bottom>=e.top&&e.right>=e.left}lastColIsEmpty(e,t){return this.getters.isEmpty(e,{...t,left:t.right})}lastRowIsEmpty(e,t){return this.getters.isEmpty(e,{...t,top:t.bottom})}dimensionsToSum(e,t){const i=new Set;return oo(t)?(i.add(1===io(t).numberOfCols?"COL":"ROW"),i):(this.lastColIsEmpty(e,t)&&i.add("ROW"),this.lastRowIsEmpty(e,t)&&i.add("COL"),0===i.size&&i.add("COL"),i)}sumDimensions(e,t,i){return[...i.has("COL")?this.sumColumns(t,e):[],...i.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:i}=e;return{position:{col:i,row:t},zone:{...e,top:t,right:i-1}}}sumColumns(e,t){const i=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,i.bottom-1)},no(i).map((t=>({position:t,zone:{...e,right:t.col,left:t.col}})))}sumRows(e,t){const i=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,i.right-1)},no(i).map((t=>({position:t,zone:{...e,top:t.row,bottom:t.row}})))}dispatchCellUpdates(e,t){for(const i of t){const{col:t,row:o}=i.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,content:`=SUM(${this.getters.zoneToXC(e,i.zone)})`})}}nextEmptyRow(e,t){let i=t.bottom+1;const{left:o,right:n}=t;for(;!this.getters.isEmpty(e,{bottom:i,top:i,left:o,right:n});)i++;return{...t,top:i,bottom:i}}nextEmptyCol(e,t){let i=t.right+1;const{top:o,bottom:n}=t;for(;!this.getters.isEmpty(e,{left:i,right:i,top:o,bottom:n});)i++;return{...t,left:i,right:i}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}ab.getters=["getAutomaticSums"];class lb extends Yv{allowDispatch(e){if("OPEN_CELL_POPOVER"===e.type){try{cs.get(e.popoverType)}catch(e){return 72}return 0}return 0}handle(e){switch(e.type){case"ACTIVATE_SHEET":case"CLOSE_CELL_POPOVER":this.persistentPopover=void 0;break;case"OPEN_CELL_POPOVER":this.persistentPopover={col:e.col,row:e.row,sheetId:this.getters.getActiveSheetId(),type:e.popoverType}}}getCellPopover({col:e,row:t}){var i,o;const n=this.getters.getActiveSheetId();if(this.persistentPopover&&this.getters.isVisibleInViewport(this.persistentPopover)){const e=this.getters.getMainCellPosition(this.persistentPopover),t=null===(o=(i=cs.get(this.persistentPopover.type)).onOpen)||void 0===o?void 0:o.call(i,e,this.getters);return(null==t?void 0:t.isOpen)?{...t,anchorRect:this.computePopoverAnchorRect(this.persistentPopover)}:{isOpen:!1}}if(void 0===e||void 0===t||!this.getters.isVisibleInViewport({sheetId:n,col:e,row:t}))return{isOpen:!1};const s=this.getters.getMainCellPosition({sheetId:n,col:e,row:t}),r=cs.getAll().map((e=>{var t;return null===(t=e.onHover)||void 0===t?void 0:t.call(e,s,this.getters)})).find((e=>null==e?void 0:e.isOpen));return(null==r?void 0:r.isOpen)?{...r,anchorRect:this.computePopoverAnchorRect(s)}:{isOpen:!1}}hasOpenedPopover(){return void 0!==this.persistentPopover}getPersistentPopoverTypeAtPosition({col:e,row:t}){if(this.persistentPopover&&this.persistentPopover.col===e&&this.persistentPopover.row===t)return this.persistentPopover.type}computePopoverAnchorRect({col:e,row:t}){const i=this.getters.getActiveSheetId(),o=this.getters.getMerge({sheetId:i,col:e,row:t});return o?this.getters.getVisibleRect(o):this.getters.getVisibleRect(lo({col:e,row:t}))}}lb.getters=["getCellPopover","getPersistentPopoverTypeAtPosition","hasOpenedPopover"];var cb;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}(cb||(cb={}));class hb extends Yv{constructor(){super(...arguments),this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.toSearch="",this.isSearchDirty=!1}handle(e){switch(e.type){case"UPDATE_SEARCH":this.updateSearch(e.toSearch,e.searchOptions);break;case"CLEAR_SEARCH":this.clearSearch();break;case"SELECT_SEARCH_PREVIOUS_MATCH":this.selectNextCell(cb.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell(cb.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith);break;case"UNDO":case"REDO":case"REMOVE_FILTER_TABLE":case"UPDATE_FILTER":case"REMOVE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"EVALUATE_CELLS":case"UPDATE_CELL":this.isSearchDirty=!0;break;case"ACTIVATE_SHEET":this.refreshSearch()}}finalize(){this.isSearchDirty&&(this.refreshSearch(),this.isSearchDirty=!1)}getSearchMatches(){return this.searchMatches}getCurrentSelectedMatchIndex(){return this.selectedMatchIndex}updateSearch(e,t){this.searchOptions=t,e!==this.toSearch&&(this.selectedMatchIndex=null),this.toSearch=e,this.updateRegex(),this.refreshSearch()}refreshSearch(){const e=this.findMatches();this.searchMatches=e,this.selectNextCell(cb.current)}updateRegex(){let e=Ne(this.toSearch);const t=this.searchOptions.matchCase?"":"i";this.searchOptions.exactMatch&&(e=`^${e}$`),this.currentSearchRegex=RegExp(e,t)}findMatches(){const e=this.getters.getActiveSheetId(),t=this.getters.getCells(e),i=[];if(this.toSearch)for(const o of Object.values(t)){const{col:t,row:n}=this.getters.getCellPosition(o.id),s=this.getters.isColHidden(e,t),r=this.getters.isRowHidden(e,n);if(!s&&!r&&(o&&this.currentSearchRegex&&this.currentSearchRegex.test(this.getSearchableString({sheetId:e,col:t,row:n})))){const e={col:t,row:n,selected:!1};i.push(e)}}return i.sort(this.sortByRowThenColumn)}sortByRowThenColumn(e,t){return e.row===t.row?e.col-t.col:e.row>t.row?1:-1}selectNextCell(e){const t=this.searchMatches;if(!t.length)return void(this.selectedMatchIndex=null);let i;i=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,i=(i%t.length+t.length)%t.length,this.selectedMatchIndex=i,this.selection.selectCell(t[i].col,t[i].row);for(let e=0;e<this.searchMatches.length;e++)this.searchMatches[e].selected=e===this.selectedMatchIndex}clearSearch(){this.toSearch="",this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1}}replaceMatch(e,t){if(!this.currentSearchRegex)return;const i=this.getters.getActiveSheetId(),o=this.getters.getCell({sheetId:i,...e}),{col:n,row:s}=e;if((null==o?void 0:o.isFormula)&&!this.searchOptions.searchFormulas)return;const r=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),a=this.getSearchableString({sheetId:i,col:n,row:s}).replace(r,t);this.dispatch("UPDATE_CELL",{sheetId:i,col:n,row:s,content:a})}replace(e){if(null===this.selectedMatchIndex)return;const t=this.searchMatches[this.selectedMatchIndex];this.replaceMatch(t,e),this.selectNextCell(cb.next)}replaceAll(e){const t=this.searchMatches.length;for(let i=0;i<t;i++)this.replaceMatch(this.searchMatches[i],e)}getSearchableString(e){const t=this.getters.getCell(e);return this.searchOptions.searchFormulas&&(null==t?void 0:t.isFormula)?t.content:this.getters.getEvaluatedCell(e).formattedValue}drawGrid(e){const{ctx:t}=e,i=this.getters.getActiveSheetId();for(const e of this.searchMatches){const o=this.getters.getMerge({sheetId:i,col:e.col,row:e.row}),n=o?o.left:e.col,s=o?o.right:e.col,r=o?o.top:e.row,a=o?o.bottom:e.row,{x:l,y:c,width:h,height:d}=this.getters.getVisibleRect({top:r,left:n,right:s,bottom:a});h>0&&d>0&&(t.fillStyle="#8B008B33",t.fillRect(l,c,h,d),e.selected&&(t.strokeStyle="#8B008B",t.strokeRect(l,c,h,d)))}}}hb.layers=[3],hb.getters=["getSearchMatches","getCurrentSelectedMatchIndex"];class db extends Yv{isRowHidden(e,t){return this.getters.isRowHiddenByUser(e,t)||this.getters.isRowFiltered(e,t)}isColHidden(e,t){return this.getters.isColHiddenByUser(e,t)}isHeaderHidden(e,t,i){return"COL"===t?this.isColHidden(e,i):this.isRowHidden(e,i)}getNextVisibleCellPosition({sheetId:e,col:t,row:i}){return{sheetId:e,col:this.findVisibleHeader(e,"COL",t,this.getters.getNumberCols(e)-1),row:this.findVisibleHeader(e,"ROW",i,this.getters.getNumberRows(e)-1)}}findVisibleHeader(e,t,i,o){if(i<=o)for(let n=i;n<=o;n++)if(this.getters.doesHeaderExist(e,t,n)&&!this.isHeaderHidden(e,t,n))return n;if(i>o)for(let n=i;n>=o;n--)if(this.getters.doesHeaderExist(e,t,n)&&!this.isHeaderHidden(e,t,n))return n}findLastVisibleColRowIndex(e,t,{last:i,first:o}){return He(i,o,-1).find((i=>!this.isHeaderHidden(e,t,i)))||o}findFirstVisibleColRowIndex(e,t){const i=this.getters.getNumberHeaders(e,t);for(let o=0;o<i;o++){if("COL"===t&&!this.isColHidden(e,o))return o;if("ROW"===t&&!this.isRowHidden(e,o))return o}}exportForExcel(e){for(const t of e.sheets)for(const[e,i]of Object.entries(t.rows)){const o=this.isRowHidden(t.id,Number(e));i.isHidden=o}}}db.getters=["getNextVisibleCellPosition","findVisibleHeader","findLastVisibleColRowIndex","findFirstVisibleColRowIndex","isRowHidden","isColHidden","isHeaderHidden"];class ub extends Yv{getHighlights(){return this.prepareHighlights(this.getters.getComposerHighlights().concat(this.getters.getSelectionInputHighlights()))}prepareHighlights(e){return e.filter((e=>e.zone.top>=0&&e.zone.left>=0&&e.zone.bottom<this.getters.getNumberRows(e.sheetId)&&e.zone.right<this.getters.getNumberCols(e.sheetId))).map((e=>{const{numberOfRows:t,numberOfCols:i}=io(e.zone),o=t*i==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:o}}))}drawGrid(e){const{ctx:t,thinLineWidth:i}=e,o=this.getters.getActiveSheetId(),n=3*i;t.lineWidth=n;const s=this.getHighlights();for(let e of s.filter(((e,t)=>s.findIndex((t=>Yi(t.zone,e.zone)&&t.sheetId===o))===t))){const{x:i,y:o,width:s,height:r}=this.getters.getVisibleRect(e.zone);s>0&&r>0&&(t.strokeStyle=e.color,t.strokeRect(i+n/2,o+n/2,s-n,r-n),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(i+n,o+n,s-2*n,r-2*n))}}}ub.layers=[1],ub.getters=["getHighlights"];class gb extends Yv{constructor(){super(...arguments),this.boxes=[]}getColDimensionsInViewport(e,t){const i=Math.min(...this.getters.getSheetViewVisibleCols()),o=this.getters.getColRowOffsetInViewport("COL",i,t),n=this.getters.getColSize(e,t);return{start:o,size:n,end:o+(this.getters.isColHidden(e,t)?0:n)}}getRowDimensionsInViewport(e,t){const i=Math.min(...this.getters.getSheetViewVisibleRows()),o=this.getters.getColRowOffsetInViewport("ROW",i,t),n=this.getters.getRowSize(e,t);return{start:o,size:n,end:o+(this.getters.isRowHidden(e,t)?0:n)}}getHeaderOffset(e,t,i){let o=this.getters.getColRowOffsetInViewport(e,t,i);return this.getters.isDashboard()||(o+="ROW"===e?N:_),o}drawGrid(e,t){switch(t){case 0:this.boxes=this.getGridBoxes(),this.drawBackground(e),this.drawOverflowingCellBackground(e),this.drawCellBackground(e),this.drawBorders(e),this.drawTexts(e),this.drawIcon(e),this.drawFrozenPanes(e);break;case 7:this.getters.isDashboard()||(this.drawHeaders(e),this.drawFrozenPanesHeaders(e))}}drawBackground(e){const{ctx:t,thinLineWidth:i}=e,{width:o,height:n}=this.getters.getSheetViewDimensionWithHeaders();t.fillStyle="#ffffff",t.fillRect(0,0,o+m,n+m);const s=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId()),r=s?.1*i:0;if(s)for(const e of this.boxes)t.strokeStyle="#E2E3E3",t.lineWidth=i,t.strokeRect(e.x+r,e.y+r,e.width-2*r,e.height-2*r)}drawCellBackground(e){const{ctx:t}=e;for(const e of this.boxes){let i=e.style;i.fillColor&&"#ffffff"!==i.fillColor&&(t.fillStyle=i.fillColor||"#ffffff",t.fillRect(e.x,e.y,e.width,e.height)),e.error&&(t.fillStyle="red",t.beginPath(),t.moveTo(e.x+e.width-5,e.y),t.lineTo(e.x+e.width,e.y),t.lineTo(e.x+e.width,e.y+5),t.fill())}}drawOverflowingCellBackground(e){var t,i;const{ctx:o,thinLineWidth:n}=e;for(const e of this.boxes)if(e.content&&e.isOverflow){const s=e.content.align||"left";let r,a;const l=e.y+n/2,c=e.height-n,h=Math.min((null===(t=e.clipRect)||void 0===t?void 0:t.width)||1/0,e.content.width);"left"===s?(r=e.x+n/2,a=h-2*n):"right"===s?(r=e.x+e.width-n/2,a=2*n-h):(r=((null===(i=e.clipRect)||void 0===i?void 0:i.x)||e.x+e.width/2-e.content.width/2)+n/2,a=h-2*n),o.fillStyle="#ffffff",o.fillRect(r,l,a,c)}}drawBorders(e){const{ctx:t,thinLineWidth:i}=e;for(let e of this.boxes){const t=e.border;if(t){const{x:i,y:n,width:s,height:r}=e;t.left&&o(t.left,i,n,i,n+r),t.top&&o(t.top,i,n,i+s,n),t.right&&o(t.right,i+s,n,i+s,n+r),t.bottom&&o(t.bottom,i,n+r,i+s,n+r)}}function o([e,o],n,s,r,a){t.strokeStyle=o,t.lineWidth=("thin"===e?2:3)*i,t.beginPath(),t.moveTo(n,s),t.lineTo(r,a),t.stroke()}}drawTexts(e){const{ctx:t,thinLineWidth:i}=e;let o;t.textBaseline="top";for(let e of this.boxes)if(e.content){const n=e.style||{},s=e.content.align||"left",r=ze(n);r!==o&&(o=r,t.font=r),t.fillStyle=n.textColor||"#000";let a=e.x;if(a+="left"===s?V+(e.image?e.image.size+U:0):"right"===s?e.width-V-(e.isFilterHeader?20:0):e.width/2,t.textAlign=s,e.clipRect){t.save(),t.beginPath();const{x:i,y:o,width:n,height:s}=e.clipRect;t.rect(i,o,n,s),t.clip()}const l=Be(n),c=e.content.textLines.length;let h=this.computeTextYCoordinate(e,l,c);for(let o of e.content.textLines){if(t.fillText(o,Math.round(a),Math.round(h)),n.strikethrough||n.underline){const e=Pe(t,o,n);let r=a;"right"===s?r-=e:"center"===s&&(r-=e/2),n.strikethrough&&t.fillRect(r,h+l/2,e,2.6*i),n.underline&&t.fillRect(r,h+l+1,e,1.3*i)}h+=V+l}e.clipRect&&t.restore()}}drawIcon(e){const{ctx:t}=e;for(const e of this.boxes)if(e.image){const i=e.image.image;if(e.image.clipIcon){t.save(),t.beginPath();const{x:i,y:o,width:n,height:s}=e.image.clipIcon;t.rect(i,o,n,s),t.clip()}const o=e.image.size,n=this.computeTextYCoordinate(e,o);t.drawImage(i,e.x+U,n,o,o),e.image.clipIcon&&t.restore()}}computeTextYCoordinate(e,t,i=1){const o=e.y+1,n=Le(t,i),s=e.height>n+2*V,r=e.verticalAlign||"middle";if(s){if("middle"===r)return o+(e.height-n)/2;if("bottom"===r)return o+e.height-n-V}return o+V}drawHeaders(e){const{ctx:t,thinLineWidth:i}=e,o=this.getters.getSheetViewVisibleCols(),n=o[0],s=o[o.length-1],r=this.getters.getSheetViewVisibleRows(),a=r[0],l=r[r.length-1],{width:c,height:h}=this.getters.getSheetViewDimensionWithHeaders(),d=this.getters.getSelectedZones(),u=function(e){const t=new Set;for(let i of e)for(let e of He(i.left,i.right+1))t.add(e);return t}(d),g=function(e){const t=new Set;for(let i of e)for(let e of He(i.top,i.bottom+1))t.add(e);return t}(d),p=this.getters.getActiveSheetId(),m=this.getters.getNumberCols(p),f=this.getters.getNumberRows(p),E=this.getters.getActiveCols(),w=this.getters.getActiveRows();t.font=`400 11px ${Z}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=i,t.strokeStyle="#333";for(let e=n;e<=s;e++){const i={left:e,right:e,top:0,bottom:f-1},{x:o,width:n}=this.getters.getVisibleRect(i),s=this.getters.doesZonesContainFilter(p,[i]),r=E.has(e),a=u.has(e);t.fillStyle=r?s?R:S:a?s?A:b:s?T:v,t.fillRect(o,0,n,N)}for(let e=a;e<=l;e++){const i={top:e,bottom:e,left:0,right:m-1},{y:o,height:n}=this.getters.getVisibleRect(i),s=this.getters.doesZonesContainFilter(p,[i]),r=w.has(e),a=g.has(e);t.fillStyle=r?s?R:S:a?s?A:b:s?T:v,t.fillRect(0,o,_,n)}t.beginPath(),t.moveTo(_,0),t.lineTo(_,h),t.moveTo(0,N),t.lineTo(c,N),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(const e of o){const i=this.getters.getColSize(p,e),o=$t(e);t.fillStyle=E.has(e)?"#fff":C;let s=this.getHeaderOffset("COL",n,e);t.fillText(o,s+i/2,13),t.moveTo(s+i,0),t.lineTo(s+i,N)}for(const e of r){const i=this.getters.getRowSize(p,e);t.fillStyle=w.has(e)?"#fff":C;let o=this.getHeaderOffset("ROW",a,e);t.fillText(String(e+1),24,o+i/2),t.moveTo(0,o+i),t.lineTo(_,o+i)}t.stroke()}drawFrozenPanesHeaders(e){const{ctx:t,thinLineWidth:i}=e,{x:o,y:n}=this.getters.getMainViewportCoordinates(),s=this.getters.isDashboard()?0:_,r=this.getters.isDashboard()?0:N;t.lineWidth=6*i,t.strokeStyle="#BCBCBC",t.beginPath(),o&&(t.moveTo(s+o,0),t.lineTo(s+o,r)),n&&(t.moveTo(0,r+n),t.lineTo(s,r+n)),t.stroke()}drawFrozenPanes(e){const{ctx:t,thinLineWidth:i}=e,{x:o,y:n}=this.getters.getMainViewportCoordinates(),s=this.getters.getSheetViewVisibleCols(),r=s[0],a=s[s.length-1],l=this.getters.getSheetViewVisibleRows(),c={left:r,right:a,top:l[0],bottom:l[l.length-1]},h=this.getters.getVisibleRect(c),d=this.getters.isDashboard()?0:_,u=this.getters.isDashboard()?0:N;t.lineWidth=6*i,t.strokeStyle="#DADFE8",t.beginPath(),o&&(t.moveTo(d+o,u),t.lineTo(d+o,h.height+u)),n&&(t.moveTo(d,u+n),t.lineTo(h.width+d,u+n)),t.stroke()}findNextEmptyCol(e,t,i){const o=this.getters.getActiveSheetId();let n=e;for(;n<t;){const e={sheetId:o,col:n+1,row:i},t=this.getters.getEvaluatedCell(e),s=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==ln.empty||this.getters.isInMerge(e)||(null==s?void 0:s.left))return n;n++}return n}findPreviousEmptyCol(e,t,i){const o=this.getters.getActiveSheetId();let n=e;for(;n>t;){const e={sheetId:o,col:n-1,row:i},t=this.getters.getEvaluatedCell(e),s=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==ln.empty||this.getters.isInMerge(e)||(null==s?void 0:s.right))return n;n--}return n}computeCellAlignment(e,t){const i=this.getters.getCell(e);if((null==i?void 0:i.isFormula)&&this.getters.shouldShowFormulas())return"left";const{align:o}=this.getters.getCellStyle(e),n=this.getters.getEvaluatedCell(e);return t&&n.type===ln.number?"center"!==o?"left":o:o||n.defaultAlign}createZoneBox(e,t,i){const{left:o,right:n}=i,s=t.left,r=t.top,a={sheetId:e,col:s,row:r},c=this.getters.getEvaluatedCell(a),h=this.getters.shouldShowFormulas(),{x:d,y:u,width:g,height:p}=this.getters.getVisibleRect(t),{verticalAlign:m}=this.getters.getCellStyle(a),f={x:d,y:u,width:g,height:p,border:this.getters.getCellBorderWithFilterBorder(a)||void 0,style:this.getters.getCellComputedStyle(a),verticalAlign:m};if(c.type===ln.empty)return f;const v=this.getters.getConditionalIcon(a),b=Be(f.style),S=v?U+b:0;v&&(f.image={type:"icon",size:b,clipIcon:{x:f.x,y:f.y,width:Math.min(S,g),height:p},image:Rg[v].img}),f.isFilterHeader=this.getters.isFilterHeader(a);const C=f.isFilterHeader?19:0,E=this.getters.getCellComputedStyle(a),w=E.wrapping||"overflow",y="wrap"!==w||h?void 0:g-2*V,x=this.getters.getCellMultiLineText(a,y),I=Math.max(...x.map((e=>this.getters.getTextWidth(e,E)+V))),R=S+I+C,T=this.computeCellAlignment(a,R>g);f.content={textLines:x,width:"overflow"===w?I:g,align:T},c.type===ln.error&&c.error.logLevel>l.silent&&(f.error=c.error.message);const A=R>g||b>p;if(v||f.isFilterHeader)f.clipRect={x:f.x+S,y:f.y,width:Math.max(0,g-S-C),height:p};else if(A&&"overflow"===w){let e,i;switch(this.getters.isInMerge(a)?(e=this.getters.getMerge(a).right,i=s):(e=this.findNextEmptyCol(s,n,r),i=this.findPreviousEmptyCol(s,o,r),f.isOverflow=!0),T){case"left":{const i=lo({col:e,row:r}),{x:o,y:n,width:s,height:a}=this.getters.getVisibleRect(ji(t,i));(s<R||b>a||x.length>1)&&(f.clipRect={x:o,y:n,width:s,height:a});break}case"right":{const e=lo({col:i,row:r}),{x:o,y:n,width:s,height:a}=this.getters.getVisibleRect(ji(t,e));(s<R||b>a||x.length>1)&&(f.clipRect={x:o,y:n,width:s,height:a});break}case"center":{const o={...t,left:i,right:e},{x:n,y:s,height:r,width:a}=this.getters.getVisibleRect(o),l=R/2,c=f.x+f.width/2;if(n+a<c+l||n>c-l||b>r||x.length>1){const e=n>c-l?n:c-l,t=n+a-e;f.clipRect={x:e,y:s,width:t,height:r}}break}}}else("clip"===w||"wrap"===w||x.length>1)&&(f.clipRect={x:f.x,y:f.y,width:g,height:p});return f}getGridBoxes(){const e=[],t=this.getters.getSheetViewVisibleCols(),i=t[0],o=t[t.length-1],n=this.getters.getSheetViewVisibleRows(),s={left:i,right:o,top:n[0],bottom:n[n.length-1]},r=this.getters.getActiveSheetId();for(const i of n)for(const o of t){const t={sheetId:r,col:o,row:i};this.getters.isInMerge(t)||e.push(this.createZoneBox(r,lo(t),s))}for(const t of this.getters.getMerges(r))if(!this.getters.isMergeHidden(r,t)&&Ki(t,s)){const i=this.createZoneBox(r,t,s),o=this.getters.getCellBorder({sheetId:r,col:t.right,row:t.bottom});i.border={...i.border,bottom:o?o.bottom:void 0,right:o?o.right:void 0},i.isMerge=!0,e.push(i)}return e}}gb.layers=[0,7],gb.getters=["getColDimensionsInViewport","getRowDimensionsInViewport"];class pb extends Yv{constructor(e,t,i){if(i&&t.length>1)throw new Error("Input with a single range cannot be instantiated with several range references.");super(e),this.inputHasSingleRange=i,this.ranges=[],this.focusedRangeIndex=null,this.willAddNewRange=!1,this.insertNewRange(0,t),this.activeSheet=this.getters.getActiveSheetId(),0===this.ranges.length&&(this.insertNewRange(this.ranges.length,[""]),this.focusLast())}allowDispatch(e){switch(e.type){case"ADD_EMPTY_RANGE":if(this.inputHasSingleRange&&1===this.ranges.length)return 30;break;case"CHANGE_RANGE":if(this.inputHasSingleRange&&e.value.split(",").length>1)return 30}return 0}handleEvent(e){const t=$i(e.anchor.zone),i=this.activeSheet,o=this.getters.getActiveSheetId(),n=this.getters.getSheetName(o);this.add([o===i?t:`${De(n)}!${t}`])}handle(e){switch(e.type){case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"FOCUS_RANGE":this.focus(this.getIndex(e.rangeId));break;case"CHANGE_RANGE":{const t=this.getIndex(e.rangeId);if(null!==t&&this.focusedRangeIndex!==t&&this.focus(t),null!==t){const i=e.value.replace(/^,+/,"").split(",").map((e=>e.trim()));this.setRange(t,i)}break}case"ADD_EMPTY_RANGE":this.insertNewRange(this.ranges.length,[""]),this.focusLast();break;case"REMOVE_RANGE":const t=this.getIndex(e.rangeId);null!==t&&this.removeRange(t);break;case"STOP_SELECTION_INPUT":this.willAddNewRange=!1;break;case"PREPARE_SELECTION_INPUT_EXPANSION":{const e=this.focusedRangeIndex;null===e||this.inputHasSingleRange||(this.willAddNewRange=""!==this.ranges[e].xc.trim());break}case"ACTIVATE_SHEET":if(e.sheetIdFrom!==e.sheetIdTo){const{col:t,row:i}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0}),o=this.getters.expandZone(e.sheetIdTo,lo({col:t,row:i}));this.selection.resetAnchor(this,{cell:{col:t,row:i},zone:o})}}}getSelectionInputValue(){return this.cleanInputs(this.ranges.map((e=>e.xc?e.xc:"")))}getSelectionInputHighlights(){return this.ranges.map((e=>this.inputToHighlights(e))).flat()}focus(e){this.focusedRangeIndex=e}focusLast(){this.focus(this.ranges.length-1)}unfocus(){this.focusedRangeIndex=null}add(e){null!==this.focusedRangeIndex&&0!==e.length&&(this.willAddNewRange?(this.insertNewRange(this.ranges.length,e),this.focusLast(),this.willAddNewRange=!1):this.setRange(this.focusedRangeIndex,e))}setContent(e,t){this.ranges[e]={...this.ranges[e],xc:t}}insertNewRange(e,t){const i=Math.max(0,...this.ranges.map((e=>Number(e.id))));this.ranges.splice(e,0,...t.map(((e,t)=>({xc:e,id:i+t+1,color:St[(i+t)%St.length]}))))}setRange(e,t){const[,...i]=t;this.setContent(e,t[0]),this.insertNewRange(e+1,i),i.length&&this.focus(e+i.length)}removeRange(e){this.ranges.splice(e,1),null!==this.focusedRangeIndex&&this.focusLast()}inputToHighlights({xc:e,color:t}){const i=this.cleanInputs([e]).filter((e=>this.getters.isRangeValid(e))).filter((e=>this.shouldBeHighlighted(this.activeSheet,e)));return i.map((e=>{const{sheetName:i}=Ht(e);return{zone:this.getters.getRangeFromSheetXC(this.activeSheet,e).zone,sheetId:i&&this.getters.getSheetIdByName(i)||this.activeSheet,color:t}}))}cleanInputs(e){return e.map((e=>e.split(","))).flat().map((e=>e.trim())).filter((e=>""!==e))}shouldBeHighlighted(e,t){const{sheetName:i}=Ht(t),o=this.getters.getSheetIdByName(i),n=this.getters.getActiveSheet().id;return this.getters.isRangeValid(t)&&(o===n||void 0===o&&n===e)}getIndex(e){const t=this.ranges.findIndex((t=>t.id===e));return t>=0?t:null}}pb.layers=[1],pb.getters=[];class mb extends Yv{get currentInput(){return this.focusedInputId?this.inputs[this.focusedInputId]:null}constructor(e){super(e),this.config=e,this.inputs={},this.focusedInputId=null}allowDispatch(e){var t,i;if("FOCUS_RANGE"===e.type){const o=null===(t=this.currentInput)||void 0===t?void 0:t.getIndex(e.rangeId);if(this.focusedInputId===e.id&&(null===(i=this.currentInput)||void 0===i?void 0:i.focusedRangeIndex)===o)return 29}return this.currentInput?this.currentInput.allowDispatch(e):0}handle(e){var t;switch(e.type){case"ENABLE_NEW_SELECTION_INPUT":this.initInput(e.id,e.initialRanges||[],e.hasSingleRange);break;case"DISABLE_SELECTION_INPUT":this.focusedInputId===e.id&&this.unfocus(),delete this.inputs[e.id];break;case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"ADD_EMPTY_RANGE":case"REMOVE_RANGE":if(e.id!==this.focusedInputId){const t=this.inputs[e.id];this.selection.capture(t,{cell:{col:0,row:0},zone:lo({col:0,row:0})},{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e.id}break;case"FOCUS_RANGE":case"CHANGE_RANGE":if(e.id!==this.focusedInputId){const t=this.inputs[e.id],i=t.ranges.find((t=>t.id===e.rangeId)),o=this.getters.getActiveSheetId(),n=this.getters.getRangeFromSheetXC(o,(null==i?void 0:i.xc)||"A1").zone;this.selection.capture(t,{cell:{col:n.left,row:n.top},zone:n},{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e.id}}null===(t=this.currentInput)||void 0===t||t.handle(e)}getSelectionInput(e){return this.inputs[e]?this.inputs[e].ranges.map(((t,i)=>Object.assign({},t,{color:this.focusedInputId===e&&null!==this.inputs[e].focusedRangeIndex&&this.isRangeValid(t.xc)?t.color:null,isFocused:this.focusedInputId===e&&this.inputs[e].focusedRangeIndex===i}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:i}=Ht(e);return null!==t.match(Lt)&&(!i||void 0!==this.getters.getSheetIdByName(i))}getSelectionInputValue(e){return this.inputs[e].getSelectionInputValue()}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].getSelectionInputHighlights():[]}initInput(e,t,i=!1){if(this.inputs[e]=new pb(this.config,t,i),0===t.length){const t=this.inputs[e],i={zone:lo({col:0,row:0}),cell:{col:0,row:0}};this.selection.capture(t,i,{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e}}unfocus(){this.selection.release(this.currentInput),this.focusedInputId=null}}mb.layers=[1],mb.getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];class fb{constructor(){this.subscriptions={}}on(e,t,i){if(!i)throw new Error("Missing callback");this.subscriptions[e]||(this.subscriptions[e]=[]),this.subscriptions[e].push({owner:t,callback:i})}trigger(e,t){const i=this.subscriptions[e]||[];for(let e=0,o=i.length;e<o;e++){const o=i[e];o.callback.call(o.owner,t)}}off(e,t){const i=this.subscriptions[e];i&&(this.subscriptions[e]=i.filter((e=>e.owner!==t)))}clear(){this.subscriptions={}}}function vb(e,t){return{...e,definition:yr(e.definition,t)}}function bb(e,t){if(e.sheetId!==t.sheetId)return e;if(("FREEZE_COLUMNS"===e.type?"COL":"ROW")!==t.dimension)return e;let i=e.quantity;if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));for(let t of e)i>t&&i--}if("ADD_COLUMNS_ROWS"===t.type){i=i>("before"===t.position?t.base-1:t.base)?i+t.quantity:i}return i>0?{...e,quantity:i}:void 0}og.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],vb),og.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],vb),og.addTransformation("DELETE_SHEET",["MOVE_RANGES"],(function(e,t){const i=t.sheetId;if(e.targetSheetId===i||e.sheetId===i)return;return e})),og.addTransformation("DELETE_FIGURE",["UPDATE_FIGURE","UPDATE_CHART"],(function(e,t){if(e.id===t.id)return;return e})),og.addTransformation("CREATE_SHEET",["CREATE_SHEET"],(function(e,t){var i;if(e.name===t.name)return{...e,name:(null===(i=e.name)||void 0===i?void 0:i.match(/\d+/))?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),og.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE","CREATE_FILTER_TABLE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const i=[];for(const o of e.target)for(const e of t.target)Ki(o,e)||i.push({...o});if(i.length)return{...e,target:i};return})),og.addTransformation("ADD_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],bb),og.addTransformation("REMOVE_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],bb),og.addTransformation("CREATE_FILTER_TABLE",["CREATE_FILTER_TABLE","ADD_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;for(const i of e.target)for(const e of t.target)if(Ki(e,i))return;return e}));const Sb=[{match:function(e){return"sheetId"in e},fn:wb},{match:function(e){return"target"in e&&"sheetId"in e},fn:function(e,t){const i=wb(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;const o=[];for(const i of e.target){const e=us(i,t);e&&o.push(e)}if(!o.length)return"IGNORE_COMMAND";return{...e,target:o}}},{match:function(e){return"col"in e&&"row"in e&&"sheetId"in e},fn:function(e,t){const i=wb(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const i="COL"===t.dimension?"col":"row";let o=e[i];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(o))return"IGNORE_COMMAND";for(let t of e)o>=t&&o--}"ADD_COLUMNS_ROWS"===t.type&&(o>t.base||o===t.base&&"before"===t.position)&&(o+=t.quantity);return{...e,[i]:o}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const i of t.target){if(!(e.col===i.left&&e.row===i.top)&&Qi(e.col,e.row,i))return"IGNORE_COMMAND"}return e}(e,t);return"SKIP_TRANSFORMATION"}},{match:function(e){return"dimension"in e&&"sheetId"in e},fn:function(e,t){const i=wb(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const i="ADD_COLUMNS_ROWS"===e.type,o=i?"base":"elements";let n=i?[e[o]]:e[o];if("REMOVE_COLUMNS_ROWS"===t.type&&(n=n.map((e=>{if(t.elements.includes(e))return;const i=t.elements.sort(((e,t)=>t-e));for(let t of i)e>t&&e--;return e})).filter(it)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;n=n.map((i=>i>e?i+t.quantity:i))}if(n.length){let t=n;return i&&(t=n[0]),{...e,[o]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}},{match:function(e){return"ranges"in e},fn:function(e,t){const i=[],o="DELETE_SHEET"===t.type&&t.sheetId;for(const n of e.ranges)if(n._sheetId!==t.sheetId)i.push({...n,_zone:n._zone});else{const e=us(n._zone,t);e&&o!==n._sheetId&&i.push({...n,_zone:e})}if(!i.length)return"IGNORE_COMMAND";return{...e,ranges:i}}}];function Cb(e,t){const i=og.getTransformation(e.type,t.type);return i?i(e,t):function(e,t){for(const{match:i,fn:o}of Sb)if(i(e)){const i=o(e,t);if("SKIP_TRANSFORMATION"===i)continue;if("IGNORE_COMMAND"===i)return;e=i}return e}(e,t)}function Eb(e,t){let i=[...e];for(const e of t)i=i.map((t=>Cb(t,e))).filter(it);return i}function wb(e,t){const i="DELETE_SHEET"===t.type&&t.sheetId;return e.sheetId===i?"IGNORE_COMMAND":"CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId?e:"SKIP_TRANSFORMATION"}class yb{constructor(e,t,i,o){this._commands=[],this._changes=[],this.id=e,this.clientId=t,this._commands=[...i],this._changes=o?[...o]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class xb extends Error{}class Ib extends fb{constructor(e,t,i=Q){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=i,this.clients={},this.clientId="local",this.pendingMessages=[],this.waitingAck=!1,this.waitingUndoRedoAck=!1,this.isReplayingInitialRevisions=!1,this.processedRevisions=new Set,this.uuidGenerator=new Vi,this.debouncedMove=function(e,t,i){let o;return function(){const n=this,s=arguments,r=i&&!o;clearTimeout(o),o=setTimeout((function(){o=null,i||e.apply(n,s)}),t),r&&e.apply(n,s)}}(this._move.bind(this),200)}canApplyOptimisticUpdate(){return!this.waitingUndoRedoAck}save(e,t){if(!e.length||!t.length||!this.canApplyOptimisticUpdate())return;const i=new yb(this.uuidGenerator.uuidv4(),this.clientId,e,t);this.revisions.append(i.id,i),this.trigger("new-local-state-update",{id:i.id}),this.sendUpdateMessage({type:"REMOTE_REVISION",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:i.id,clientId:i.clientId,commands:i.commands})}undo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_UNDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),undoneRevisionId:e})}redo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_REDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),redoneRevisionId:e})}move(e){this.debouncedMove(e)}join(e){e?(this.clients[e.id]=e,this.clientId=e.id):(this.clients.local={id:"local",name:"local"},this.clientId="local"),this.transportService.onNewMessage(this.clientId,this.onMessageReceived.bind(this))}loadInitialMessages(e){this.isReplayingInitialRevisions=!0;for(const t of e)this.onMessageReceived(t);this.isReplayingInitialRevisions=!1}leave(){delete this.clients[this.clientId],this.transportService.leave(this.clientId),this.transportService.sendMessage({type:"CLIENT_LEFT",clientId:this.clientId,version:1})}snapshot(e){const t=this.uuidGenerator.uuidv4();this.transportService.sendMessage({type:"SNAPSHOT",nextRevisionId:t,serverRevisionId:this.serverRevisionId,data:{...e,revisionId:t},version:1})}getClient(){const e=this.clients[this.clientId];if(!e)throw new xb("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(it))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}_move(e){var t;if(!this.clients[this.clientId])return;const i=null===(t=this.clients[this.clientId])||void 0===t?void 0:t.position;if((null==i?void 0:i.col)===e.col&&i.row===e.row&&i.sheetId===e.sheetId)return;const o=i?"CLIENT_MOVED":"CLIENT_JOINED",n=this.getClient();this.clients[this.clientId]={...n,position:e},this.transportService.sendMessage({type:o,version:1,client:{...n,position:e}})}onMessageReceived(e){if(!this.isAlreadyProcessed(e))if(this.isWrongServerRevisionId(e))this.trigger("unexpected-revision-id");else{switch(e.type){case"CLIENT_MOVED":this.onClientMoved(e);break;case"CLIENT_JOINED":this.onClientJoined(e);break;case"CLIENT_LEFT":this.onClientLeft(e);break;case"REVISION_REDONE":this.revisions.redo(e.redoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-redone",{revisionId:e.redoneRevisionId,commands:this.revisions.get(e.redoneRevisionId).commands});break;case"REVISION_UNDONE":this.revisions.undo(e.undoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-undone",{revisionId:e.undoneRevisionId,commands:this.revisions.get(e.undoneRevisionId).commands});break;case"REMOTE_REVISION":const{clientId:t,commands:i}=e,o=new yb(e.nextRevisionId,t,i);if(o.clientId!==this.clientId){this.revisions.insert(o.id,o,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:Eb(i,t)})}break;case"SNAPSHOT_CREATED":{const t=new yb(e.nextRevisionId,"server",[]);this.revisions.insert(t.id,t,e.serverRevisionId),this.dropPendingHistoryMessages(),this.trigger("snapshot");break}}this.acknowledge(e),this.trigger("collaborative-event-received")}}onClientMoved(e){e.client.id!==this.clientId&&(this.clients[e.client.id]=e.client)}onClientJoined(e){if(e.client.id!==this.clientId){this.clients[e.client.id]=e.client;const t=this.clients[this.clientId];if(t){const{position:e}=t;e&&this.transportService.sendMessage({type:"CLIENT_MOVED",version:1,client:{...t,position:e}})}}}onClientLeft(e){e.clientId!==this.clientId&&delete this.clients[e.clientId]}sendUpdateMessage(e){this.pendingMessages.push(e),this.waitingAck||(this.waitingAck=!0,this.sendPendingMessage())}sendPendingMessage(){let e=this.pendingMessages[0];if(e){if("REMOTE_REVISION"===e.type){const t=this.revisions.get(e.nextRevisionId);if(0===t.commands.length){this.revisions.drop(t.id);const e=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.nextRevisionId));return this.trigger("pending-revisions-dropped",{revisionIds:e}),this.waitingAck=!1,this.waitingUndoRedoAck=!1,void(this.pendingMessages=[])}e={...e,clientId:t.clientId,commands:t.commands}}if(this.isReplayingInitialRevisions)throw new Error(`Trying to send a new revision while replaying initial revision. This can lead to endless dispatches every time the spreadsheet is open.\n ${JSON.stringify(e)}`);this.transportService.sendMessage({...e,serverRevisionId:this.serverRevisionId})}}acknowledge(e){switch("REVISION_UNDONE"!==e.type&&"REVISION_REDONE"!==e.type||(this.waitingUndoRedoAck=!1),e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":this.waitingAck=!1,this.pendingMessages=this.pendingMessages.filter((t=>t.nextRevisionId!==e.nextRevisionId)),this.serverRevisionId=e.nextRevisionId,this.processedRevisions.add(e.nextRevisionId),this.sendPendingMessage()}}isAlreadyProcessed(e){if("CLIENT_MOVED"===e.type&&e.client.id===this.clientId)return!0;switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":return this.processedRevisions.has(e.nextRevisionId);default:return!1}}isWrongServerRevisionId(e){switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":return e.serverRevisionId!==this.serverRevisionId;default:return!1}}dropPendingHistoryMessages(){this.waitingUndoRedoAck=!1,this.pendingMessages=this.pendingMessages.filter((({type:e})=>"REVISION_REDONE"!==e&&"REVISION_UNDONE"!==e))}}const Rb=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];class Tb extends Yv{constructor(){super(...arguments),this.availableColors=new Set(Rb),this.colors={}}isPositionValid(e){return e.row<this.getters.getNumberRows(e.sheetId)&&e.col<this.getters.getNumberCols(e.sheetId)}chooseNewColor(){0===this.availableColors.size&&(this.availableColors=new Set(Rb));const e=(t=[...this.availableColors.values()])[Math.floor(Math.random()*t.length)];var t;return this.availableColors.delete(e),e}getClientsToDisplay(){try{this.getters.getClient()}catch(e){if(e instanceof xb)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const i of this.getters.getConnectedClients())if(i.id!==this.getters.getClient().id&&i.position&&i.position.sheetId===e&&this.isPositionValid(i.position)){const e=i.position;this.colors[i.id]||(this.colors[i.id]=this.chooseNewColor());const o=this.colors[i.id];t.push({...i,position:e,color:o})}return t}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:i}=e,o=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:n,col:s}=e.position,r=this.getters.expandZone(o,{top:n,bottom:n,left:s,right:s}),{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(r);if(c<=0||h<=0)continue;const d=e.color,u=`${d}10`;t.fillStyle=u,t.lineWidth=4*i,t.strokeStyle=d,t.globalCompositeOperation="multiply",t.fillRect(a,l,c,h),t.globalCompositeOperation="source-over",t.strokeRect(a,l,c,h),t.font=`bold ${q+1}px ${Z}`}}}Tb.getters=["getClientsToDisplay"],Tb.layers=[6];class Ab extends Yv{allowDispatch(e){if("SORT_CELLS"===e.type){if(!Qi(e.col,e.row,e.zone))throw new Error(s("The anchor must be part of the provided zone"));return this.checkValidations(e,this.checkMerge,this.checkMergeSizes)}return 0}handle(e){if("SORT_CELLS"===e.type)this.sortZone(e.sheetId,e,e.zone,e.sortDirection,e.sortOptions||{})}checkMerge({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;return no(t).some((({col:t,row:i})=>!this.getters.isInMerge({sheetId:e,col:t,row:i})))?63:0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const i=this.getters.getMerges(e).filter((e=>Ki(e,t))),o=io(i[0]);let[n,s]=[o.numberOfCols,o.numberOfRows];return i.every((e=>{let[t,i]=[e.right-e.left+1,e.bottom-e.top+1];return t===n&&i===s}))?0:63}expand(e,t){const{left:i,right:o,top:n,bottom:s}=this.getters.expandZone(e,t);return{left:Math.max(0,i),right:Math.min(this.getters.getNumberCols(e)-1,o),top:Math.max(0,n),bottom:Math.min(this.getters.getNumberRows(e)-1,s)}}checkExpandedValues(e,t){const i=this.expand(e,t);let o;if(this.getters.doesIntersectMerge(e,i)){const{left:t,right:n,top:s,bottom:r}=i;for(let i=t;i<=n;i++)for(let t=s;t<=r;t++){const{col:n,row:s}=this.getters.getMainCellPosition({sheetId:e,col:i,row:t});if(o=this.getters.getEvaluatedCell({sheetId:e,col:n,row:s}),o.formattedValue)return!0}}else for(let t of this.getters.getEvaluatedCellsInZone(e,i))if(t.formattedValue)return!0;return!1}getContiguousZone(e,t){let i,{top:o,bottom:n,left:s,right:r}=t,a=!1;for(;!a;)a=!0,o>0&&(i=this.checkExpandedValues(e,{left:s-1,right:r+1,top:o-1,bottom:o-1}),i&&(a=!1,o--)),s>0&&(i=this.checkExpandedValues(e,{left:s-1,right:s-1,top:o-1,bottom:n+1}),i&&(a=!1,s--)),r<this.getters.getNumberCols(e)-1&&(i=this.checkExpandedValues(e,{left:r+1,right:r+1,top:o-1,bottom:n+1}),i&&(a=!1,r++)),n<this.getters.getNumberRows(e)-1&&(i=this.checkExpandedValues(e,{left:s-1,right:r+1,top:n+1,bottom:n+1}),i&&(a=!1,n++));return{left:s,right:r,top:o,bottom:n}}hasHeader(e,t){if(1===t[0].length)return!1;let i=t.map((t=>t.map((({col:t,row:i})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:i}).type))));return i[0][0]===ln.empty&&(i=i.slice(1)),!i.some((e=>e[0]===ln.empty))&&!!i.some((e=>e[1]!==ln.empty&&e[0]!==e[1]))}sortZone(e,t,i,o,n){const[s,r]=this.mainCellsSteps(e,i);let a=this.getters.getMainCellPosition({sheetId:e,col:t.col,row:t.row}).col,l=Object.assign({},i),c=this.mainCells(e,i);!n.sortHeaders&&this.hasHeader(e,c)&&(l.top+=r),c=this.mainCells(e,l);const h=function(e,t,i){const o=e.map(((e,t)=>({index:t,type:e.type,value:e.value})));let n=o.filter((e=>e.type===ln.empty)),s=o.filter((e=>e.type!==ln.empty));i&&(s.push(...n.map((e=>({...e,type:ln.number,value:0})))),n=[]);const r="descending"===t?-1:1;return s.sort(((e,t)=>{let i=Ir.indexOf(e.type)-Ir.indexOf(t.type);return 0===i&&(i=e.type===ln.text||e.type===ln.error?e.value.localeCompare(t.value):e.value-t.value),r*i})).concat(n)}(c[a-l.left].map((e=>this.getters.getEvaluatedCell(e))),o,Boolean(n.emptyCellAsZero)),d=h.map((e=>e.index)),[u,g]=[c.length,c[0].length],p=[];for(let e=0;e<u;e++)for(let t=0;t<g;t++){let{col:i,row:o,sheetId:n}=c[e][d[t]];const a=this.getters.getCell({sheetId:n,col:i,row:o});let h=l.left+e*s,u=l.top+t*r,g={sheetId:n,col:h,row:u,content:""};if(a){let e=a.content;if(a.isFormula){const t=u-this.getters.getCellPosition(a.id).row,i=this.getters.createAdaptedRanges(a.dependencies,0,t,n);e=this.getters.buildFormulaContent(n,a,i)}g.style=a.style,g.content=e,g.format=a.format}p.push(g)}p.forEach((e=>this.dispatch("UPDATE_CELL",e)))}mainCellsSteps(e,t){const i=this.getters.getMerge({sheetId:e,col:t.left,row:t.top});return[i?i.right-i.left+1:1,i?i.bottom-i.top+1:1]}mainCells(e,t){const[i,o]=this.mainCellsSteps(e,t),n=[],s=He(t.left,t.right+1,i),r=He(t.top,t.bottom+1,o);for(const t of s){const i=[];n.push(i);for(const o of r)i.push({sheetId:e,col:t,row:o})}return n}}Ab.getters=["getContiguousZone"];class Mb extends Yv{constructor(){super(...arguments),this.showFormulas=!1}handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}Mb.getters=["shouldShowFormulas"];class Ob extends Yv{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}allowDispatch(e){switch(e.type){case"AUTORESIZE_ROWS":case"AUTORESIZE_COLUMNS":try{this.getters.getSheet(e.sheetId);break}catch(e){return 27}}return 0}handle(e){switch(e.type){case"AUTORESIZE_COLUMNS":for(let t of e.cols){const i=this.getColMaxWidth(e.sheetId,t);0!==i&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:i,sheetId:e.sheetId})}break;case"AUTORESIZE_ROWS":for(let t of e.rows)this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"ROW",size:null,sheetId:e.sheetId})}}getCellWidth(e){const t=this.getCellText(e),i=this.getters.getCellComputedStyle(e),o=t.split(he);let n=Math.max(...o.map((e=>this.getTextWidth(e,i))));this.getters.getConditionalIcon(e)&&(n+=function(e){return Be(e)+2*U}(this.getters.getCellStyle(e)));if(this.getters.isFilterHeader(e)&&(n+=20),n>0&&(n+=2*B,"wrap"===this.getters.getCellStyle(e).wrapping)){const t=this.getters.getColSize(this.getters.getActiveSheetId(),e.col);return Math.min(t,n)}return n}getTextWidth(e,t){return Pe(this.ctx,e,t)}getCellText(e,t=!1){const i=this.getters.getCell(e);return t&&(null==i?void 0:i.isFormula)?i.content:this.getters.getEvaluatedCell(e).formattedValue}getCellMultiLineText(e,t){const i=this.getters.getCellStyle(e),o=this.getters.getCellText(e,this.getters.shouldShowFormulas()),n=[];for(const e of o.split("\n")){const o=e.split(" ");if(!t){n.push(e);continue}let s="",r=t;for(let e of o){const o=this.splitWordToSpecificWidth(this.ctx,e,t,i),a=o.pop(),l=Pe(this.ctx,a,i);if(o.length)""!==s&&(n.push(s),s="",r=t),o.forEach((e=>{n.push(e)})),s=a,r=t-l;else{const e=""===s?a:" "+a,o=Pe(this.ctx,e,i);o<=r?(s+=e,r-=o):(n.push(s),s=a,r=t-l)}}""!==s&&n.push(s)}return n}getColDimensions(e,t){const i=this.getColRowOffset("COL",0,t,e),o=this.getters.getColSize(e,t);return{start:i,size:o,end:i+(this.getters.isColHidden(e,t)?0:o)}}getRowDimensions(e,t){const i=this.getColRowOffset("ROW",0,t,e),o=this.getters.getRowSize(e,t);return{start:i,size:o,end:i+(this.getters.isRowHidden(e,t)?0:o)}}getColRowOffset(e,t,i,o=this.getters.getActiveSheetId()){if(i<t)return-this.getColRowOffset(e,i,t);let n=0;for(let s=t;s<i;s++)this.getters.isHeaderHidden(o,e,s)||(n+="COL"===e?this.getters.getColSize(o,s):this.getters.getRowSize(o,s));return n}getColMaxWidth(e,t){const i=no(this.getters.getColsZone(e,t,t)).map((t=>this.getCellWidth({sheetId:e,...t})));return Math.max(0,...i)}splitWordToSpecificWidth(e,t,i,o){if(Pe(e,t,o)<=i)return[t];const n=[];let s="";for(let r of t){Pe(e,s+r,o)>i?(n.push(s),s=r):s+=r}return n.push(s),n}}Ob.getters=["getCellWidth","getTextWidth","getCellText","getCellMultiLineText","getColDimensions","getRowDimensions","getColRowOffset"];class Nb{constructor(e,t,i,o){this.getters=t,this.dispatch=i,this.selection=o,this.operation=e,this.sheetId=t.getActiveSheetId()}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0}addMissingDimensions(e,t,i,o){const n=this.getters.getActiveSheetId(),s=t+o-this.getters.getNumberRows(n);s>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"ROW",base:this.getters.getNumberRows(n)-1,sheetId:n,quantity:s,position:"after"});const r=e+i-this.getters.getNumberCols(n);r>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:this.getters.getNumberCols(n)-1,sheetId:n,quantity:r,position:"after"})}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class _b extends Nb{constructor(e,t,i,o,n){if(super(t,i,o,n),!e.length)return this.cells=[[]],this.zones=[],void(this.copiedTables=[]);const s=new Set(e.map((e=>e.left))),r=new Set(e.map((e=>e.right))),a=new Set(e.map((e=>e.top))),l=new Set(e.map((e=>e.bottom))),c=1===a.size&&1===l.size||1===s.size&&1===r.size?function(e){return e.reduce(((e,t)=>{const i=e.length;for(let o=0;o<i;o++)if(Ki(e[o],t))return e[o]=ji(e[o],t),e;return e[i]=t,e}),[])}(e):[e[e.length-1]],h=c.map((e=>no(e))).flat(),d=[...new Set(h.map((e=>e.col)))].sort(((e,t)=>e-t)),u=[...new Set(h.map((e=>e.row)))].sort(((e,t)=>e-t)),g=[],p=i.getActiveSheetId();for(let e of u){let t=[];for(let o of d){const n={col:o,row:e,sheetId:p};t.push({cell:i.getCell(n),style:i.getCellComputedStyle(n),evaluatedCell:i.getEvaluatedCell(n),border:i.getCellBorder(n)||void 0,position:n})}g.push(t)}const m=[];for(const t of e)for(const e of this.getters.getFilterTablesInZone(p,t)){const t=[];for(const i of He(e.zone.left,e.zone.right+1))t.push(this.getters.getFilterValues({sheetId:p,col:i,row:e.zone.top}));m.push({filtersValues:t,zone:e.zone})}this.cells=g,this.zones=c,this.copiedTables=m}isCutAllowed(e){return 1!==e.length?19:0}isPasteAllowed(e,t){const i=this.getters.getActiveSheetId();if("CUT"===this.operation&&void 0!==(null==t?void 0:t.pasteOption))return 21;if(e.length>1&&(this.cells.length>1||this.cells[0].length>1))return 20;const o=this.cells.length,n=this.cells[0].length;for(let t of this.getPasteZones(e))if(this.getters.doesIntersectMerge(i,t)&&(e.length>1||!this.getters.isSingleCellOrMerge(i,e[0])||o*n!=1))return 2;const{xSplit:s,ySplit:r}=this.getters.getPaneDivisions(i);for(const t of this.getPasteZones(e))if(t.left<s&&t.right>=s||t.top<r&&t.bottom>=r)return 75;return 0}paste(e,t){"COPY"===this.operation?this.pasteFromCopy(e,t):this.pasteFromCut(e,t);const i=this.cells.length,o=this.cells[0].length,n="CUT"===this.operation;(null==t?void 0:t.selectTarget)&&this.selectPastedZone(o,i,n,e)}pasteFromCopy(e,t){if(1===e.length){const i=this.cells.length,o=this.cells[0].length,n=this.pastedZones(e,o,i);for(const e of n)this.pasteZone(e.left,e.top,t)}else for(const i of e)for(let e=i.left;e<=i.right;e++)for(let o=i.top;o<=i.bottom;o++)this.pasteZone(e,o,t);void 0===(null==t?void 0:t.pasteOption)&&this.pasteCopiedTables(e)}pasteFromCut(e,t){this.clearClippedZones();const i=e[0];this.pasteZone(i.left,i.top,t),this.dispatch("MOVE_RANGES",{target:this.zones,sheetId:this.sheetId,targetSheetId:this.getters.getActiveSheetId(),col:i.left,row:i.top});for(const e of this.copiedTables)this.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.sheetId,target:[e.zone]});this.pasteCopiedTables(e)}pastedZones(e,t,i){const o=e[0],n=Math.max(1,Math.floor((o.right+1-o.left)/t)),s=Math.max(1,Math.floor((o.bottom+1-o.top)/i)),r=[];for(let e=0;e<n;e++)for(let n=0;n<s;n++){const s=o.top+n*i,a=o.left+e*t;r.push({left:a,top:s,bottom:s+i-1,right:a+t-1})}return r}getPasteZones(e){const t=this.cells;if(!t.length||!t[0].length)return e;const i=[],o=t.length,n=t[0].length,s=e[e.length-1],r=s.left,a=s.top,l=Math.max(1,Math.floor((s.right+1-r)/n)),c=Math.max(1,Math.floor((s.bottom+1-a)/o));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)i.push({left:r,top:a,right:r-1+e*n,bottom:a-1+t*o});return i}selectPastedZone(e,t,i,o){const n=o[0],s=n.left,r=n.top;if(t>1||e>1||i){const n=this.pastedZones(o,e,t),a=i?n[0]:ji(...n);this.selection.selectZone({cell:{col:s,row:r},zone:a})}}clearClippedZones(){for(const e of this.cells)for(const t of e)t.cell&&this.dispatch("CLEAR_CELL",t.position);this.dispatch("CLEAR_FORMATTING",{sheetId:this.sheetId,target:this.zones})}pasteZone(e,t,i){const o=this.cells.length,n=this.cells[0].length,s="onlyValue"!==(null==i?void 0:i.pasteOption)&&(null==i?void 0:i.shouldPasteCF),r=this.getters.getActiveSheetId();this.addMissingDimensions(n,o,e,t);for(let a=0;a<o;a++){const o=this.cells[a];for(let l=0;l<n;l++){const n=o[l],c={col:e+l,row:t+a,sheetId:r};"CUT"!==this.operation&&this.pasteMergeIfExist(n.position,c),this.pasteCell(n,c,this.operation,i),s&&this.dispatch("PASTE_CONDITIONAL_FORMAT",{origin:n.position,target:c,operation:this.operation})}}}pasteCell(e,t,i,o){const{sheetId:n,col:s,row:r}=t,a=this.getters.getEvaluatedCell(t);if("onlyValue"!==(null==o?void 0:o.pasteOption)){const i=this.getters.getCellBorder(t),o=e.border,a={top:(null==i?void 0:i.top)||(null==o?void 0:o.top),bottom:(null==i?void 0:i.bottom)||(null==o?void 0:o.bottom),left:(null==i?void 0:i.left)||(null==o?void 0:o.left),right:(null==i?void 0:i.right)||(null==o?void 0:o.right)};this.dispatch("SET_BORDER",{sheetId:n,col:s,row:r,border:a})}if(e.cell){if("onlyFormat"===(null==o?void 0:o.pasteOption))return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.evaluatedCell.format});if("onlyValue"===(null==o?void 0:o.pasteOption)){const i=mi(e.evaluatedCell.value);return void this.dispatch("UPDATE_CELL",{...t,content:i})}let a=e.cell.content;if(e.cell.isFormula&&"COPY"===i){const t=s-e.position.col,o=r-e.position.row;a=this.getUpdatedContent(n,e.cell,t,o,i)}this.dispatch("UPDATE_CELL",{...t,content:a,style:e.cell.style||null,format:e.cell.format})}else a&&("onlyValue"===(null==o?void 0:o.pasteOption)?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===(null==o?void 0:o.pasteOption)?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,i,o,n){const s=this.getters.createAdaptedRanges(t.dependencies,i,o,e);return this.getters.buildFormulaContent(e,t,s)}pasteMergeIfExist(e,t){let{sheetId:i,col:o,row:n}=e;const{col:s,row:r}=this.getters.getMainCellPosition(e);if(s===o&&r===n){const s=this.getters.getMerge(e);if(!s)return;({sheetId:i,col:o,row:n}=t),this.dispatch("ADD_MERGE",{sheetId:i,force:!0,target:[{left:o,top:n,right:o+s.right-s.left,bottom:n+s.bottom-s.top}]})}}pasteCopiedTables(e){const t=this.getters.getActiveSheetId(),i=e[0],o=this.zones[0],n=[i.left-o.left,i.top-o.top];for(const e of this.copiedTables){const i=so(e.zone,"both","MOVE",n);this.dispatch("CREATE_FILTER_TABLE",{sheetId:t,target:[i]});for(const o of He(0,e.filtersValues.length))this.dispatch("UPDATE_FILTER",{sheetId:t,col:i.left+o,row:i.top,values:e.filtersValues[o]})}}getClipboardContent(){return{[cn.PlainText]:this.getPlainTextContent(),[cn.Html]:this.getHTMLContent()}}getPlainTextContent(){return this.cells.map((e=>e.map((e=>e.cell?this.getters.getCellText(e.position,this.getters.shouldShowFormulas()):"")).join("\t"))).join("\n")||"\t"}getHTMLContent(){if(1==this.cells.length&&1==this.cells[0].length)return this.getters.getCellText(this.cells[0][0].position);let e='<table border="1" style="border-collapse:collapse">';for(const t of this.cells){e+="<tr>";for(const i of t){e+=`<td style="${Co(bo(i.style))}">`+Jf(this.getters.getCellText(i.position))+"</td>"}e+="</tr>"}return e+="</table>",e}isColRowDirtyingClipboard(e,t){if(!this.zones)return!1;for(let i of this.zones){if("COL"===t&&e<=i.right)return!0;if("ROW"===t&&e<=i.bottom)return!0}return!1}drawClipboard(e){const{ctx:t,thinLineWidth:i}=e;if(this.sheetId===this.getters.getActiveSheetId()&&this.zones&&this.zones.length){t.setLineDash([8,5]),t.strokeStyle=E,t.lineWidth=3.3*i;for(const e of this.zones){const{x:i,y:o,width:n,height:s}=this.getters.getVisibleRect(e);n>0&&s>0&&t.strokeRect(i,o,n,s)}}}}class Fb{constructor(e,t,i){this.operation=e,this.getters=t,this.dispatch=i,this.sheetId=t.getActiveSheetId();const o=t.getSelectedFigureId();if(!o)throw new Error("No figure selected");const n=t.getFigure(this.sheetId,o);if(!n)throw new Error(`No figure for the given id: ${o}`);switch(this.copiedFigure={...n},n.tag){case"chart":this.copiedFigureContent=new Db(i,t,this.sheetId,o);break;case"image":this.copiedFigureContent=new kb(i,t,this.sheetId,o);break;default:throw new Error(`Unknow tag '${n.tag}' for the given figure id: ${o}`)}}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0===e.length?73:void 0!==(null==t?void 0:t.pasteOption)?22:0}paste(e){const t=this.getters.getActiveSheetId(),i={x:this.getters.getColDimensions(t,e[0].left).start,y:this.getters.getRowDimensions(t,e[0].top).start},o={height:this.copiedFigure.height,width:this.copiedFigure.width},n=(new Vi).uuidv4();this.copiedFigureContent.paste(t,n,i,o),"CUT"===this.operation&&this.dispatch("DELETE_FIGURE",{sheetId:this.copiedFigureContent.sheetId,id:this.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:n})}getClipboardContent(){return{[cn.PlainText]:"\t"}}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class Db{constructor(e,t,i,o){this.dispatch=e,this.sheetId=i;const n=t.getChart(o);if(!n)throw new Error(`No chart for the given id: ${o}`);this.copiedChart=n.copyInSheetId(i)}paste(e,t,i,o){const n=this.copiedChart.copyInSheetId(e);this.dispatch("CREATE_CHART",{id:t,sheetId:e,position:i,size:o,definition:n.getDefinition()})}}class kb{constructor(e,t,i,o){this.dispatch=e,this.sheetId=i;const n=t.getImage(o);this.copiedImage=_e(n)}paste(e,t,i,o){const n=_e(this.copiedImage);this.dispatch("CREATE_IMAGE",{figureId:t,sheetId:e,position:i,size:o,definition:n})}}class Lb extends Nb{constructor(e,t,i,o){super("COPY",t,i,o),this.values=e.replace(/\r/g,"").split("\n").map((e=>e.split("\t")))}isPasteAllowed(e,t){const i=this.getters.getActiveSheetId(),o=this.getPasteZone(e);return this.getters.doesIntersectMerge(i,o)?2:0}paste(e){const t=this.values,i=this.getPasteZone(e),{left:o,top:n}=i,{numberOfCols:s,numberOfRows:r}=io(i),a=this.getters.getActiveSheetId();this.addMissingDimensions(s,r,o,n);for(let e=0;e<t.length;e++)for(let i=0;i<t[e].length;i++)this.dispatch("UPDATE_CELL",{row:n+e,col:o+i,content:t[e][i],sheetId:a});const l={left:o,top:n,right:o+s-1,bottom:n+r-1};this.selection.selectZone({cell:{col:o,row:n},zone:l})}getClipboardContent(){return{[cn.PlainText]:this.values.map((e=>e.join("\t"))).join("\n")}}getPasteZone(e){const t=this.values.length,i=Math.max(...this.values.map((e=>e.length))),{left:o,top:n}=e[0];return{top:n,left:o,bottom:n+t-1,right:o+i-1}}}class Pb extends Yv{constructor(){super(...arguments),this.status="invisible",this._isPaintingFormat=!1}allowDispatch(e){switch(e.type){case"CUT":const t=this.getters.getSelectedZones();return this.getClipboardState(t,e.type).isCutAllowed(t);case"PASTE":if(!this.state)return 23;const i=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);return this.state.isPasteAllowed(e.target,{pasteOption:i});case"PASTE_FROM_OS_CLIPBOARD":return new Lb(e.text,this.getters,this.dispatch,this.selection).isPasteAllowed(e.target);case"INSERT_CELL":{const{cut:t,paste:i}=this.getInsertCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(i)}case"DELETE_CELL":{const{cut:t,paste:i}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(i)}}return 0}handle(e){var t,i;switch(e.type){case"COPY":case"CUT":const o=this.getters.getSelectedZones();this.state=this.getClipboardState(o,e.type),this.status="visible";break;case"PASTE":if(!this.state)break;const n=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);this._isPaintingFormat=!1,this.state.paste(e.target,{pasteOption:n,shouldPasteCF:!0,selectTarget:!0}),"CUT"===this.state.operation&&(this.state=void 0),this.status="invisible";break;case"CLEAN_CLIPBOARD_HIGHLIGHT":this.status="invisible";break;case"DELETE_CELL":{const{cut:t,paste:i}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!Hi(t[0])){for(const{col:t,row:i}of no(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:i,sheetId:this.getters.getActiveSheetId()});break}this.getClipboardStateForCopyCells(t,"CUT").paste(i);break}case"INSERT_CELL":{const{cut:t,paste:i}=this.getInsertCellsTargets(e.zone,e.shiftDimension);this.getClipboardStateForCopyCells(t,"CUT").paste(i);break}case"ADD_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(t=this.state)||void 0===t?void 0:t.operation))return;this.state.isColRowDirtyingClipboard("before"===e.position?e.base:e.base+1,e.dimension)&&(this.state=void 0);break;case"REMOVE_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(i=this.state)||void 0===i?void 0:i.operation))return;for(let t of e.elements){if(this.state.isColRowDirtyingClipboard(t,e.dimension)){this.state=void 0;break}}this.status="invisible";break;case"PASTE_FROM_OS_CLIPBOARD":new Lb(e.text,this.getters,this.dispatch,this.selection).paste(e.target),this.status="invisible";break;case"ACTIVATE_PAINT_FORMAT":{const e=this.getters.getSelectedZones();this.state=this.getClipboardStateForCopyCells(e,"COPY"),this._isPaintingFormat=!0,this.status="visible";break}default:pn(e)&&(this.status="invisible")}}getClipboardContent(){var e;return(null===(e=this.state)||void 0===e?void 0:e.getClipboardContent())||{[cn.PlainText]:"\t"}}getClipboardTextContent(){var e;return(null===(e=this.state)||void 0===e?void 0:e.getClipboardContent()[cn.PlainText])||"\t"}isCutOperation(){return!!this.state&&"CUT"===this.state.operation}isPaintingFormat(){return this._isPaintingFormat}getDeleteCellsTargets(e,t){const i=this.getters.getActiveSheetId();let o;return o="COL"===t?{...e,left:e.right+1,right:this.getters.getNumberCols(i)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(i)-1},{cut:[o],paste:[e]}}getInsertCellsTargets(e,t){const i=this.getters.getActiveSheetId();let o,n;return"COL"===t?(o={...e,right:this.getters.getNumberCols(i)-1},n={...e,left:e.right+1,right:e.right+1}):(o={...e,bottom:this.getters.getNumberRows(i)-1},n={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(i)-1}),{cut:[o],paste:[n]}}getClipboardStateForCopyCells(e,t){return new _b(e,t,this.getters,this.dispatch,this.selection)}getClipboardState(e,t){return this.getters.getSelectedFigureId()?new Fb(t,this.getters,this.dispatch):new _b(e,t,this.getters,this.dispatch,this.selection)}drawGrid(e){"visible"===this.status&&this.state&&this.state.drawClipboard(e)}}function Ub(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:i}=Ht(e.value),[o,n]=t.split(":"),s=i?`${De(i)}!`:"",r=Vb(o),a=n?`:${Vb(n)}`:"";return{...e,value:s+r+a}}function Vb(e){switch(function(e){if(function(e){return e.startsWith("$")&&e.length>1&&e.slice(1).includes("$")}(e))return"colrow";if(function(e){return e.startsWith("$")}(e))return"col";if(function(e){return e.includes("$",1)}(e))return"row";return"none"}(e)){case"none":e=zb(e,"colrow");break;case"colrow":e=zb(e,"row");break;case"row":e=zb(e,"col");break;case"col":e=zb(e,"none")}return e}function zb(e,t){let i;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return i=e.search(/[0-9]/),e.slice(0,i)+"$"+e.slice(i);case"colrow":return i=e.search(/[0-9]/),-1===i||0===i?"$"+e:"$"+(e=e.slice(0,i)+"$"+e.slice(i));case"none":return e}}Pb.layers=[2],Pb.getters=["getClipboardContent","getClipboardTextContent","isCutOperation","isPaintingFormat"];const Bb=s("The cell you are trying to edit has been deleted.");class Hb extends Yv{constructor(){super(...arguments),this.col=0,this.row=0,this.mode="inactive",this.sheetId="",this.currentContent="",this.currentTokens=[],this.selectionStart=0,this.selectionEnd=0,this.selectionInitialStart=0,this.initialContent="",this.previousRef="",this.previousRange=void 0,this.colorIndexByRange={}}allowDispatch(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":return this.validateSelection(this.currentContent.length,e.start,e.end);case"SET_CURRENT_CONTENT":return e.selection?this.validateSelection(e.content.length,e.selection.start,e.selection.end):0;case"START_EDITION":if(e.selection){const t=e.text||this.getComposerContent(this.getters.getActivePosition());return this.validateSelection(t.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handleEvent(e){if("selecting"===this.mode)if("newAnchor"===e.mode)this.insertSelectedRange(e.anchor.zone);else this.replaceSelectedRanges(e.anchor.zone)}handle(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":this.selectionStart=e.start,this.selectionEnd=e.end;break;case"STOP_COMPOSER_RANGE_SELECTION":this.isSelectingForComposer()&&(this.mode="editing");break;case"START_EDITION":"inactive"!==this.mode&&e.text?this.setContent(e.text,e.selection):this.startEdition(e.text,e.selection),this.updateRangeColor();break;case"STOP_EDITION":e.cancel?(this.cancelEditionAndActivateSheet(),this.resetContent()):this.stopEdition(),this.colorIndexByRange={};break;case"SET_CURRENT_CONTENT":this.setContent(e.content,e.selection,!0),this.updateRangeColor();break;case"REPLACE_COMPOSER_CURSOR_SELECTION":this.replaceSelection(e.text);break;case"SELECT_FIGURE":this.cancelEditionAndActivateSheet(),this.resetContent();break;case"ADD_COLUMNS_ROWS":this.onAddElements(e);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case"START_CHANGE_HIGHLIGHT":this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=this.getters.getRangeFromRangeData(e.range),i=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:i,sheetName:o}=Ht(e.value),n=o||this.getters.getSheetName(this.sheetId),s=this.getters.getActiveSheetId();if(this.getters.getSheetName(s)!==n)return!1;const r=this.getters.getRangeFromSheetXC(s,i);return Yi(this.getters.expandZone(s,r.zone),t.zone)}));this.previousRef=i.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=i.start;break;case"CHANGE_HIGHLIGHT":const o=this.getters.getRangeFromRangeData(e.range),n=this.getRangeReference(o,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(n),this.previousRef=n,this.selectionStart=this.currentContent.length,this.selectionEnd=this.currentContent.length;break;case"ACTIVATE_SHEET":if(this.currentContent.startsWith("=")||(this.cancelEdition(),this.resetContent()),e.sheetIdFrom!==e.sheetIdTo){const t=this.getters.getActivePosition(),{col:i,row:o}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:t.col,row:t.row}),n=this.getters.expandZone(e.sheetIdTo,lo({col:i,row:o}));this.selection.resetAnchor(this,{cell:{col:i,row:o},zone:n})}break;case"DELETE_SHEET":case"UNDO":case"REDO":!!this.getters.tryGetSheet(this.sheetId)||"inactive"===this.mode||(this.sheetId=this.getters.getActiveSheetId(),this.cancelEditionAndActivateSheet(),this.resetContent(),this.ui.notifyUI({type:"ERROR",text:Bb}));break;case"CYCLE_EDITION_REFERENCES":this.cycleReferences()}}getEditionMode(){return this.mode}getCurrentContent(){return"inactive"===this.mode?this.getComposerContent(this.getters.getActivePosition()):this.currentContent}getEditionSheet(){return this.sheetId}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}getCurrentEditedCell(){return{sheetId:this.sheetId,col:this.col,row:this.row}}isSelectingForComposer(){return"selecting"===this.mode}showSelectionIndicator(){return this.isSelectingForComposer()&&this.canStartComposerRangeSelection()}getCurrentTokens(){return this.currentTokens}getTokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((i=>i.start<=e&&i.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const i=e.map(Ub).map((e=>e.value)).join(""),o=this.currentContent,n=e[0].start,s=e[e.length-1].end,r=o.slice(0,n)+i+o.slice(s),a=r.length-o.length,l={start:t[0].start,end:t[t.length-1].end+a};1===t.length&&this.selectionStart===this.selectionEnd&&(l.start=l.end),this.dispatch("SET_CURRENT_CONTENT",{content:r,selection:l})}validateSelection(e,t,i){return t>=0&&t<=e&&i>=0&&i<=e?0:46}onColumnsRemoved(e){if(e.elements.includes(this.col)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:Bb});const{top:t,left:i}=qi({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=i,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:Bb});const{top:t,left:i}=qi({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=i,this.row=t}onAddElements(e){const{top:t,left:i}=Gi({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=i,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=lo({col:this.col,row:this.row});this.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.mode="selecting",this.selectionInitialStart=this.selectionStart}startEdition(e,t){var i;const o=this.getters.getActiveCell();e&&(null===(i=o.format)||void 0===i?void 0:i.includes("%"))&&oi(e)&&(t=t||{start:e.length,end:e.length},e=`${e}%`);const{col:n,row:s,sheetId:r}=this.getters.getActivePosition();this.col=n,this.sheetId=r,this.row=s,this.initialContent=this.getComposerContent({sheetId:r,col:n,row:s}),this.mode="editing",this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const a=lo({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:a},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if("inactive"!==this.mode){this.cancelEditionAndActivateSheet();const e=this.col,t=this.row;let i=this.currentContent;if(!(this.initialContent!==i))return;if(i){const o=this.getters.getActiveSheetId(),n=this.getters.getEvaluatedCell({sheetId:o,col:this.col,row:this.row});if(i.startsWith("=")){const e=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length,t=this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length,o=e-t;o>0&&(i+=st(new Array(o).fill(")")))}else n.link&&(i=Ye(i,n.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:e,row:t,content:i})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:e,row:t});this.setContent("")}}cancelEditionAndActivateSheet(){if("inactive"===this.mode)return;this.cancelEdition();this.getters.getActiveSheetId()!==this.sheetId&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}getComposerContent(e){const t=this.getters.getCell(e);if(null==t?void 0:t.isFormula)return t.content;const{format:i,value:o,type:n,formattedValue:s}=this.getters.getEvaluatedCell(e);switch(n){case ln.text:case ln.empty:return o;case ln.boolean:return s;case ln.error:return(null==t?void 0:t.content)||"";case ln.number:return i&&Ei(i)?s:this.numberComposerContent(o,i)}}numberComposerContent(e,t){return(null==t?void 0:t.includes("%"))?100*e+"%":function(e){const{integerDigits:t,decimalDigits:i}=bi(e,20);return i?`${t}.${i}`:t}(e)}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,i){const o=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(o||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?mf(e):[],this.currentTokens.length>100&&i&&this.ui.notifyUI({type:"ERROR",text:s("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells")})),this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(e){const t=Math.min(this.selectionStart,this.selectionEnd),i=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(i,t),this.selectionInitialStart=t):(this.insertText(","+i,t),this.selectionInitialStart=t+1)}replaceSelectedRanges(e){const t=this.getZoneReference(e);this.replaceText(t,this.selectionInitialStart,this.selectionEnd)}getZoneReference(e,t=[{colFixed:!1,rowFixed:!1}]){const i=this.getters.getActiveSheetId();let o=this.getters.zoneToXC(i,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){o=`${De(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${o}`}return o}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){let i=[...t];1===t.length&&ho(e.zone)>1?i.push({...t[0]}):2===t.length&&1===ho(e.zone)&&i.pop();const o=e.clone({parts:i});return this.getters.getSelectionRangeString(o,this.getters.getEditionSheet())}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),i=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,i)}replaceText(e,t,i){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(i,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const i=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),o=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:i,selection:{start:o,end:o}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getEditionSheet(),t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),i={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(i[e]=this.colorIndexByRange[e]);const o=new Set(Object.values(i));let n=0;const s=()=>{for(;o.has(n);)n++;return o.add(n),n};for(const e of t){const t=e in i?i[e]:s();i[e]=t}this.colorIndexByRange=i}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getEditionSheet(),t=e=>{const t=this.colorIndexByRange[e];return St[t%St.length]};return this.getReferencedRanges().map((i=>{const o=this.getters.getRangeString(i,e);return{zone:i.zone,color:t(o),sheetId:i.sheetId}}))}getReferencedRanges(){const e=this.getters.getEditionSheet();return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value)))}canStartComposerRangeSelection(){if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let i=t,o=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(o.type)||Am.includes(o.value);){if("SPACE"!==o.type||i<1)return!1;i--,o=this.currentTokens[i]}for(i=t+1,o=this.currentTokens[i];o&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(o.type);){if("SPACE"!==o.type)return!1;i++,o=this.currentTokens[i]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((i=>i.start<=e&&i.end>=e||i.start>=e&&i.start<t))}}Hb.getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights","getCurrentEditedCell"];const $b=[{name:s("Sum"),types:[ln.number],compute:e=>ml.compute([e])},{name:s("Avg"),types:[ln.number],compute:e=>Rl.compute([e])},{name:s("Min"),types:[ln.number],compute:e=>$l.compute([e])},{name:s("Max"),types:[ln.number],compute:e=>Vl.compute([e])},{name:s("Count"),types:[ln.number,ln.text,ln.boolean,ln.error],compute:e=>Dl.compute([e])},{name:s("Count Numbers"),types:[ln.number,ln.text,ln.boolean,ln.error],compute:e=>Fl.compute([e])}];class Wb extends Yv{constructor(e){super(e),this.gridSelection={anchor:{cell:{col:0,row:0},zone:{top:0,left:0,bottom:0,right:0}},zones:[{top:0,left:0,bottom:0,right:0}]},this.selectedFigureId=null,this.sheetsData={},this.activeSheet=null,this.moveClient=e.moveClient}allowDispatch(e){switch(e.type){case"ACTIVATE_SHEET":try{this.getters.getSheet(e.sheetIdTo);break}catch(e){return 27}case"MOVE_COLUMNS_ROWS":return this.isMoveElementAllowed(e)}return 0}handleEvent(e){const t=e.anchor;let i=[];switch(e.mode){case"overrideSelection":i=[t.zone];break;case"updateAnchor":i=[...this.gridSelection.zones];const o=i.findIndex((t=>Yi(t,e.previousAnchor.zone)));o>=0&&(i[o]=t.zone);break;case"newAnchor":i=[...this.gridSelection.zones,t.zone]}this.setSelectionMixin(e.anchor,i),this.selection.resetDefaultAnchor(this,_e(this.gridSelection.anchor));const{col:o,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:o,row:n}),this.selectedFigureId=null}handle(e){switch(e.type){case"START_EDITION":case"ACTIVATE_SHEET":this.selectedFigureId=null;break;case"DELETE_FIGURE":this.selectedFigureId===e.id&&(this.selectedFigureId=null);break;case"DELETE_SHEET":this.selectedFigureId&&this.getters.getFigure(e.sheetId,this.selectedFigureId)&&(this.selectedFigureId=null)}switch(e.type){case"START":const t=this.getters.getVisibleSheetIds()[0];this.dispatch("ACTIVATE_SHEET",{sheetIdTo:t,sheetIdFrom:t});const{col:i,row:o}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(i,o),this.selection.registerAsDefault(this,this.gridSelection.anchor,{handleEvent:this.handleEvent.bind(this)}),this.moveClient({sheetId:t,col:0,row:0});break;case"ACTIVATE_SHEET":if(this.getters.isSheetVisible(e.sheetIdTo)||this.dispatch("SHOW_SHEET",{sheetId:e.sheetIdTo}),this.setActiveSheet(e.sheetIdTo),this.sheetsData[e.sheetIdFrom]={gridSelection:_e(this.gridSelection)},e.sheetIdTo in this.sheetsData)Object.assign(this,this.sheetsData[e.sheetIdTo]),this.selection.resetDefaultAnchor(this,_e(this.gridSelection.anchor));else{const{col:t,row:i}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0});this.selectCell(t,i)}break;case"REMOVE_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);const{col:i,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:i,row:o})}break}case"ADD_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);const{col:i,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:i,row:o})}break}case"MOVE_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case"SELECT_FIGURE":this.selectedFigureId=e.id;break;case"ACTIVATE_NEXT_SHEET":this.activateNextSheet("right");break;case"ACTIVATE_PREVIOUS_SHEET":this.activateNextSheet("left");break;case"HIDE_SHEET":e.sheetId===this.getActiveSheetId()&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e.sheetId,sheetIdTo:this.getters.getVisibleSheetIds()[0]});break;case"UNDO":case"REDO":case"DELETE_SHEET":const n=Object.keys(this.sheetsData).filter((e=>!this.getters.tryGetSheet(e)));for(const e of n)delete this.sheetsData[e];for(const e in this.sheetsData){const t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:_e(t)}}if(!this.getters.tryGetSheet(this.getters.getActiveSheetId())){const e=this.getters.getVisibleSheetIds();if(this.activeSheet=this.getters.getSheet(e[0]),this.activeSheet.id in this.sheetsData){const{anchor:e}=this.clipSelection(this.activeSheet.id,this.sheetsData[this.activeSheet.id].gridSelection);this.selectCell(e.cell.col,e.cell.row)}else this.selectCell(0,0);const{col:t,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:i})}const s=this.getters.getActiveSheetId();this.gridSelection.zones=this.gridSelection.zones.map((e=>this.getters.expandZone(s,e))),this.gridSelection.anchor.zone=this.getters.expandZone(s,this.gridSelection.anchor.zone),this.setSelectionMixin(this.gridSelection.anchor,this.gridSelection.zones)}this.selection.resetDefaultAnchor(this,_e(this.gridSelection.anchor))}isGridSelectionActive(){return this.selection.isListening(this)}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}getActiveCell(){return this.getters.getEvaluatedCell(this.getActivePosition())}getActiveCols(){const e=new Set;for(let t of this.gridSelection.zones)if(0===t.top&&t.bottom===this.getters.getNumberRows(this.getters.getActiveSheetId())-1)for(let i=t.left;i<=t.right;i++)e.add(i);return e}getActiveRows(){const e=new Set,t=this.getters.getActiveSheetId();for(let i of this.gridSelection.zones)if(0===i.left&&i.right===this.getters.getNumberCols(t)-1)for(let t=i.top;t<=i.bottom;t++)e.add(t);return e}getCurrentStyle(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();return this.getters.getCellStyle({sheetId:t,col:e.left,row:e.top})}getSelectedZones(){return _e(this.gridSelection.zones)}getSelectedZone(){return _e(this.gridSelection.anchor.zone)}getSelection(){return _e(this.gridSelection)}getSelectedFigureId(){return this.selectedFigureId}getActivePosition(){return this.getters.getMainCellPosition({sheetId:this.getActiveSheetId(),col:this.gridSelection.anchor.cell.col,row:this.gridSelection.anchor.cell.row})}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getActivePosition();{const t=this.sheetsData[e];return t?{sheetId:e,col:t.gridSelection.anchor.cell.col,row:t.gridSelection.anchor.cell.row}:this.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0})}}getStatisticFnResults(){const e=this.getters.getActiveSheetId(),t=new Set;for(const i of this.gridSelection.zones)for(const{col:o,row:n}of no(i)){if(this.getters.isRowHidden(e,n)||this.getters.isColHidden(e,o))continue;const i=this.getters.getEvaluatedCell({sheetId:e,col:o,row:n});i.type!==ln.empty&&t.add(i)}let i=new Set,o=[];for(let e of t)i.add(e.type),o.push(e.value);let n={};for(let e of $b){let t;e.types.some((e=>i.has(e)))&&(t=e.compute(o)),n[e.name]=t}return n}getAggregate(){let e=0,t=0;const i=this.getters.getActiveSheetId(),o=this.gridSelection.zones.map(no).flat();for(const{col:n,row:s}of o){const o=this.getters.getEvaluatedCell({sheetId:i,col:n,row:s});o.type===ln.number&&(t++,e+=o.value)}return t<2?null:mi(e)}isSelected(e){return!!this.getters.getSelectedZones().find((t=>Yi(t,e)))}getElementsFromSelection(e){if("COL"===e&&0===this.getters.getActiveCols().size)return[];if("ROW"===e&&0===this.getters.getActiveRows().size)return[];const t=this.getters.getSelectedZones();let i=[];const o="COL"===e?"left":"top",n="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[n]-e[o]+1},((t,i)=>e[o]+i));i=i.concat(t)}return[...new Set(i)].sort()}setSelectionMixin(e,t){const{anchor:i,zones:o}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=i,this.gridSelection.zones=function(e){return e.reverse().filter(((e,t,i)=>t===i.findIndex((t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)))).reverse()}(o)}selectCell(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.expandZone(i,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:o,cell:{col:e,row:t}},[o])}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}activateNextSheet(e){const t=this.getters.getSheetIds(),i=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[i]})}onColumnsRemoved(e){const{cell:t,zone:i}=this.gridSelection.anchor,o=qi(i,"left",[...e.elements]);let n={left:t.col,right:t.col,top:t.row,bottom:t.row};n=qi(n,"left",[...e.elements]);const s={cell:{col:n.left,row:n.top},zone:o};this.setSelectionMixin(s,[o])}onRowsRemoved(e){const{cell:t,zone:i}=this.gridSelection.anchor,o=qi(i,"top",[...e.elements]);let n={left:t.col,right:t.col,top:t.row,bottom:t.row};n=qi(n,"top",[...e.elements]);const s={cell:{col:n.left,row:n.top},zone:o};this.setSelectionMixin(s,[o])}onAddElements(e){const t=Gi(this.gridSelection.anchor.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),i={cell:{col:t.left,row:t.top},zone:t};this.setSelectionMixin(i,[t])}onMoveElements(e){const t=e.elements.length;this.dispatch("ADD_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,base:e.base,quantity:t,position:e.position});const i="COL"===e.dimension,o=e.elements[0],n=e.elements[t-1],s=e.base<o,r=s&&i?t:0,a=s&&!i?t:0,l=[{left:i?o+r:0,right:i?n+r:this.getters.getNumberCols(e.sheetId)-1,top:i?0:o+a,bottom:i?this.getters.getNumberRows(e.sheetId)-1:n+a}],c=new _b(l,"CUT",this.getters,this.dispatch,this.selection),h=s?e.base:e.base+1,d=[{left:i?h:0,right:i?h+t-1:this.getters.getNumberCols(e.sheetId)-1,top:i?0:h,bottom:i?this.getters.getNumberRows(e.sheetId)-1:h+t-1}];c.paste(d,{selectTarget:!0});const u=s?e.elements.map((e=>e+t)):e.elements;let g=e.base;for(const t of u){const i="COL"===e.dimension?this.getters.getColSize(e.sheetId,t):this.getters.getRowSize(e.sheetId,t);this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,size:i,elements:[g]}),g+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:u})}isMoveElementAllowed(e){const t="COL"===e.dimension,i=e.elements[0],o=e.elements[e.elements.length-1],n=e.sheetId,s=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;if(s(n,i-1,i)||s(n,o,o+1)||s(n,e.base-1,e.base))return 2;const r=[e.base,...e.elements],a=t?this.getters.getNumberCols(n):this.getters.getNumberRows(n);return r.some((e=>e<0||e>=a))?86:0}clipSelection(e,t){const i=this.getters.getNumberCols(e)-1,o=this.getters.getNumberRows(e)-1;return{zones:t.zones.map((e=>({left:ke(e.left,0,i),right:ke(e.right,0,i),top:ke(e.top,0,o),bottom:ke(e.bottom,0,o)}))),anchor:{cell:{col:ke(t.anchor.cell.col,0,i),row:ke(t.anchor.cell.row,0,o)},zone:{left:ke(t.anchor.zone.left,0,i),right:ke(t.anchor.zone.right,0,i),top:ke(t.anchor.zone.top,0,o),bottom:ke(t.anchor.zone.bottom,0,o)}}}}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:i}=e,o=this.getSelectedZones();t.fillStyle="#f3f7fe";const n=1===o.length&&o[0].left===o[0].right&&o[0].top===o[0].bottom;t.fillStyle=n?"#f3f7fe":"#e9f0ff",t.strokeStyle=E,t.lineWidth=1.5*i;for(const e of o){const{x:i,y:o,width:n,height:s}=this.getters.getVisibleRect(e);t.globalCompositeOperation="multiply",t.fillRect(i,o,n,s),t.globalCompositeOperation="source-over",t.strokeRect(i,o,n,s)}t.globalCompositeOperation="source-over";const s=this.getActivePosition();let r;t.strokeStyle=E,t.lineWidth=3*i,r=this.getters.isInMerge(s)?this.getters.getMerge(s):lo(s);const{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(r);c>0&&h>0&&t.strokeRect(a,l,c,h)}}Wb.layers=[6],Wb.getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getStatisticFnResults","getAggregate","getSelectedFigureId","getSelection","getActivePosition","getSheetPosition","isSelected","getElementsFromSelection","isGridSelectionActive"];const Gb=(new Io).add("sheet",Xv).add("header visibility",$v).add("filters",Bv).add("cell",Dv).add("merge",Gv).add("headerSize",Hv).add("borders",Fv).add("conditional formatting",Pv).add("figures",Uv).add("chart",kv).add("image",Wv),qb=(new Io).add("ui_sheet",Ob).add("header_visibility_ui",db).add("ui_options",Mb).add("selectionInputManager",mb).add("highlight",ub).add("grid renderer",gb).add("autofill",rb).add("find_and_replace",hb).add("sort",Ab).add("automatic_sum",ab).add("format",class extends Yv{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,i){for(const o of t)for(const t of no(o)){const o=this.getCellNumberFormat({sheetId:e,...t});if(void 0!==o){const n=Ai(o,i);this.dispatch("SET_FORMATTING",{sheetId:e,target:[lo(t)],format:n})}}}getCellNumberFormat(e){var t;for(const i of[e]){const e=this.getters.getEvaluatedCell(i);if(e.type===ln.number&&!(null===(t=e.format)||void 0===t?void 0:t.match(Y)))return e.format||Ii(e.value)}}}).add("cell_popovers",lb).add("selection_multiuser",Tb),Zb=(new Io).add("selection",Wb).add("clipboard",Pb).add("edition",Hb),jb=(new Io).add("evaluation",Jv).add("evaluation_filter",ib).add("evaluation_chart",eb).add("evaluation_cf",tb).add("viewport",nb).add("custom_colors",Kv),Xb=new Io;Xb.add("link",{condition:(e,t)=>!!t.model.getters.getEvaluatedCell(e).link,action:(e,t)=>_o(t.model.getters.getEvaluatedCell(e).link,t),sequence:5});class Yb{constructor(e){this.fileStore=e}async requestImage(){const e=await this.getImageFromUser(),t=await this.fileStore.upload(e);return{path:t,size:await this.getImageSize(t),mimetype:e.type}}getImageFromUser(){return new Promise(((e,t)=>{const i=document.createElement("input");i.setAttribute("type","file"),i.setAttribute("accept","image/*"),i.addEventListener("change",(async()=>{null===i.files||1!=i.files.length?t():e(i.files[0])})),i.click()}))}getImageSize(e){return new Promise(((t,i)=>{const o=new Image;o.src=e,o.addEventListener("load",(()=>{const e={width:o.width,height:o.height};t(e)})),o.addEventListener("error",i)}))}}const Kb=[{transform:"scale(0)"},{transform:"scale(0.8)",offset:.33},{opacity:"0",transform:"scale(1)",offset:1}];fo`
|
|
1400
|
+
`}function sv(e){return new wp(e.join("\n"))}function rv(e,...t){let i=[e[0]];for(let o=0;o<t.length;o++){const n=t[o]instanceof wp?t[o]:tv(t[o]);i.push(n+e[o+1])}return new wp(st(i))}function av(e){return e.replace(/[a-z0-9]+:(?=[a-z0-9]+)/gi,"")}function lv(e){return e.replace(/([a-z0-9]+):(?=[a-z0-9]+)/gi,"$1\\:")}class cv{constructor(e){this.value=e}asString(){return um(String(this.value))}asBool(){return Boolean(Number(this.value))}asNum(){return Number(this.value)}}class hv{constructor(e,t,i){this.currentFile=void 0,this.rootFile=e,this.currentFile=e.file.fileName,this.xlsxFileStructure=t,this.warningManager=i,this.areNamespaceIgnored=null!==(new DOMParser).parseFromString("<t:test xmlns:t='a'/>","text/xml").querySelector("test"),this.relationships={},e.rels&&this.extractRelationships(e.rels).map((e=>{this.relationships[e.id]=e}))}extractRelationships(e){return this.mapOnElements({parent:e.xml,query:"Relationship"},(e=>({id:this.extractAttr(e,"Id",{required:!0}).asString(),target:this.extractAttr(e,"Target",{required:!0}).asString(),type:this.extractAttr(e,"Type",{required:!0}).asString()})))}getListOfFiles(){return Object.values(this.xlsxFileStructure).flat().filter(it)}mapOnElements(e,t){var i;const o=[],n=this.currentFile;let s;if(e.children){const t=null===(i=this.querySelector(e.parent,e.query))||void 0===i?void 0:i.children;s=t||[]}else s=this.querySelectorAll(e.parent,e.query);if(s)for(let e of s)try{o.push(t(e))}catch(t){this.catchErrorOnElement(t,e)}return this.currentFile=n,o}catchErrorOnElement(e,t){const i=t?`Error when parsing an element <${t.tagName}> of file ${this.currentFile}, skip this element. \n${e.stack}`:`Error when parsing file ${this.currentFile}.`;this.warningManager.addParsingWarning([i,e.message].join("\n"))}extractAttr(e,t,i){const o=e.attributes[t];o||this.handleMissingValue(e,`attribute "${t}"`,i);const n=(null==o?void 0:o.value)?o.value:null==i?void 0:i.default;return void 0===n?void 0:new cv(n)}extractTextContent(e,t){var i;if(void 0!==(null==t?void 0:t.default)&&"string"!=typeof t.default)throw new Error("extractTextContent default value should be a string");const o="preserve"===(null===(i=null==e?void 0:e.attributes["xml:space"])||void 0===i?void 0:i.value);let n=null==e?void 0:e.textContent;return e&&null!==n||this.handleMissingValue(e,"text content",t),n&&(n=o?n:n.trim()),n?um(n):null==t?void 0:t.default}extractChildAttr(e,t,i,o){var n;let s;s="number"==typeof t?e.children[t]:this.querySelector(e,t),s||this.handleMissingValue(e,"number"==typeof t?`child at index ${t}`:`child <${t}>`,o);const r=s?null===(n=this.extractAttr(s,i,o))||void 0===n?void 0:n.asString():null==o?void 0:o.default;return void 0!==r?new cv(r):void 0}extractChildTextContent(e,t,i){if(void 0!==(null==i?void 0:i.default)&&"string"!=typeof i.default)throw new Error("extractTextContent default value should be a string");let o=this.querySelector(e,t);return o||this.handleMissingValue(e,`child <${t}>`,i),o?this.extractTextContent(o,i):null==i?void 0:i.default}handleMissingValue(e,t,i){if(null==i?void 0:i.required){if(!(null==i?void 0:i.default))throw new Error(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, and no default value was set`);this.warningManager.addParsingWarning(`Missing required ${t} in element <${e.tagName}> of ${this.currentFile}, replacing it by the default value ${i.default}`)}}extractColor(e,t,i){var o,n,s,r,a;if(!e)return i?{rgb:i}:void 0;const l=null===(o=this.extractAttr(e,"theme"))||void 0===o?void 0:o.asString();let c;if(void 0!==l){if(!t||!t.clrScheme)throw new Error("Color referencing a theme but no theme was provided");c=this.getThemeColor(l,t.clrScheme)}else c=null===(n=this.extractAttr(e,"rgb"))||void 0===n?void 0:n.asString();return{rgb:c,auto:null===(s=this.extractAttr(e,"auto"))||void 0===s?void 0:s.asBool(),indexed:null===(r=this.extractAttr(e,"indexed"))||void 0===r?void 0:r.asNum(),tint:null===(a=this.extractAttr(e,"tint"))||void 0===a?void 0:a.asNum()}}getTargetXmlFile(e){if(!e)throw new Error("Undefined target file");let t=e.target;t=t.replace("../",""),t=t.replace("./","");const i=this.getListOfFiles().find((e=>e.file.fileName.endsWith(t)));if(!i||!i.file)throw new Error("Cannot find target file");return i}querySelector(e,t){return t=this.areNamespaceIgnored?av(t):lv(t),e.querySelector(t)}querySelectorAll(e,t){return t=this.areNamespaceIgnored?av(t):lv(t),e.querySelectorAll(t)}getThemeColor(e,t){switch(e){case"0":return"FFFFFF";case"1":return"000000";case"2":return t[3].value;case"3":return t[2].value;default:return t[e].value}}}class dv extends hv{getTheme(){return{clrScheme:this.mapOnElements({query:"a:clrScheme",parent:this.rootFile.file.xml,children:!0},(e=>({name:e.tagName,value:this.extractChildAttr(e,0,"val",{required:!0,default:xp}).asString(),lastClr:this.extractChildAttr(e,0,"lastClr",{default:xp}).asString()})))}}getSharedStrings(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"si"},(e=>"t"===e.children[0].tagName?this.extractTextContent(e)||"":this.mapOnElements({parent:e,query:"t"},(e=>this.extractTextContent(e)||"")).join("")))}}class uv extends hv{constructor(e,t,i,o){super(e,t,i),this.theme=o}extractConditionalFormattings(){const e=this.mapOnElements({parent:this.rootFile.file.xml,query:"worksheet > conditionalFormatting"},(e=>{var t;return{sqref:this.extractAttr(e,"sqref",{required:!0}).asString().split(" "),pivot:null===(t=this.extractAttr(e,"pivot"))||void 0===t?void 0:t.asBool(),cfRules:this.extractCFRules(e,this.theme)}}));return e.push(...this.mapOnElements({parent:this.rootFile.file.xml,query:"extLst x14:conditionalFormatting"},(e=>{var t;return{sqref:this.extractChildTextContent(e,"xm:sqref",{required:!0}).split(" "),pivot:null===(t=this.extractAttr(e,"xm:pivot"))||void 0===t?void 0:t.asBool(),cfRules:this.extractCFRules(e,this.theme)}}))),e}extractCFRules(e,t){return this.mapOnElements({parent:e,query:"cfRule, x14:cfRule"},(e=>{var i,o,n,s,r,a,l,c,h,d,u;const g=this.extractAttr(e,"type",{required:!0}).asString();if("dataBar"===g)throw new Error("Databars conditional formats are not supported.");return{type:g,priority:this.extractAttr(e,"priority",{required:!0}).asNum(),colorScale:this.extractCfColorScale(e,t),formula:this.extractCfFormula(e),iconSet:this.extractCfIconSet(e),dxfId:null===(i=this.extractAttr(e,"dxfId"))||void 0===i?void 0:i.asNum(),stopIfTrue:null===(o=this.extractAttr(e,"stopIfTrue"))||void 0===o?void 0:o.asBool(),aboveAverage:null===(n=this.extractAttr(e,"aboveAverage"))||void 0===n?void 0:n.asBool(),percent:null===(s=this.extractAttr(e,"percent"))||void 0===s?void 0:s.asBool(),bottom:null===(r=this.extractAttr(e,"bottom"))||void 0===r?void 0:r.asBool(),operator:null===(a=this.extractAttr(e,"operator"))||void 0===a?void 0:a.asString(),text:null===(l=this.extractAttr(e,"text"))||void 0===l?void 0:l.asString(),timePeriod:null===(c=this.extractAttr(e,"timePeriod"))||void 0===c?void 0:c.asString(),rank:null===(h=this.extractAttr(e,"rank"))||void 0===h?void 0:h.asNum(),stdDev:null===(d=this.extractAttr(e,"stdDev"))||void 0===d?void 0:d.asNum(),equalAverage:null===(u=this.extractAttr(e,"equalAverage"))||void 0===u?void 0:u.asBool()}}))}extractCfFormula(e){return this.mapOnElements({parent:e,query:"formula"},(e=>this.extractTextContent(e,{required:!0})))}extractCfColorScale(e,t){const i=this.querySelector(e,"colorScale");if(i)return{colors:this.mapOnElements({parent:i,query:"color"},(e=>this.extractColor(e,t,"ffffff"))),cfvos:this.extractCFVos(i)}}extractCfIconSet(e){var t,i;const o=this.querySelector(e,"iconSet, x14:iconSet");if(o)return{iconSet:this.extractAttr(o,"iconSet",{default:"3TrafficLights1"}).asString(),showValue:this.extractAttr(o,"showValue",{default:!0}).asBool(),percent:this.extractAttr(o,"percent",{default:!0}).asBool(),reverse:null===(t=this.extractAttr(o,"reverse"))||void 0===t?void 0:t.asBool(),custom:null===(i=this.extractAttr(o,"custom"))||void 0===i?void 0:i.asBool(),cfvos:this.extractCFVos(o),cfIcons:this.extractCfIcons(o)}}extractCfIcons(e){const t=this.mapOnElements({parent:e,query:"cfIcon, x14:cfIcon"},(e=>({iconSet:this.extractAttr(e,"iconSet",{required:!0}).asString(),iconId:this.extractAttr(e,"iconId",{required:!0}).asNum()})));return 0===t.length?void 0:t}extractCFVos(e){return this.mapOnElements({parent:e,query:"cfvo, x14:cfvo"},(e=>{var t,i;return{type:this.extractAttr(e,"type",{required:!0}).asString(),gte:null===(t=this.extractAttr(e,"gte",{default:!0}))||void 0===t?void 0:t.asBool(),value:e.attributes.val?null===(i=this.extractAttr(e,"val"))||void 0===i?void 0:i.asString():this.extractChildTextContent(e,"f, xm:f")}}))}}class gv extends hv{extractChart(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"c:chartSpace"},(e=>{const t=this.getChartType(e);if(!im[t])throw new Error(`Unsupported chart type ${t}`);const i=this.mapOnElements({parent:e,query:"c:title a:t"},(e=>e.textContent||"")).join(""),o=this.extractChildAttr(e,"c:grouping","val",{default:"clustered"}).asString();return{title:i,type:im[t],dataSets:this.extractChartDatasets(this.querySelector(e,`c:${t}`)),backgroundColor:this.extractChildAttr(e,"c:chartSpace > c:spPr a:srgbClr","val",{default:"ffffff"}).asString(),verticalAxisPosition:"r"===this.extractChildAttr(e,"c:valAx > c:axPos","val",{default:"l"}).asString()?"right":"left",legendPosition:tm[this.extractChildAttr(e,"c:legendPos","val",{default:"b"}).asString()],stacked:"stacked"===o,fontColor:"000000"}}))[0]}extractChartDatasets(e){return this.mapOnElements({parent:e,query:"c:ser"},(e=>({label:this.extractChildTextContent(e,"c:cat c:f"),range:this.extractChildTextContent(e,"c:val c:f",{required:!0})})))}getChartType(e){const t=this.querySelector(e,"c:plotArea");if(!t)throw new Error("Missing plot area in the chart definition.");for(let e of t.children){const t=av(e.tagName);if(yp.some((e=>e===t)))return t}throw new Error("Unknown chart type")}}class pv extends hv{extractFigures(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"xdr:wsDr",children:!0},(e=>{if("twoCellAnchor"!==av(e.tagName))throw new Error("Only twoCellAnchor are supported for xlsx drawings.");const t=this.querySelector(e,"c:chart");if(!t)throw new Error("Only chart figures are currently supported.");return{anchors:[this.extractFigureAnchor("xdr:from",e),this.extractFigureAnchor("xdr:to",e)],data:this.extractChart(t)}}))}extractFigureAnchor(e,t){const i=this.querySelector(t,e);if(!i)throw new Error(`Missing anchor element ${e}`);return{col:Number(this.extractChildTextContent(i,"xdr:col",{required:!0})),colOffset:Number(this.extractChildTextContent(i,"xdr:colOff",{required:!0})),row:Number(this.extractChildTextContent(i,"xdr:row",{required:!0})),rowOffset:Number(this.extractChildTextContent(i,"xdr:rowOff",{required:!0}))}}extractChart(e){const t=this.extractAttr(e,"r:id",{required:!0}).asString(),i=this.getTargetXmlFile(this.relationships[t]),o=new gv(i,this.xlsxFileStructure,this.warningManager).extractChart();if(!o)throw new Error("Unable to extract chart definition");return o}}class mv extends hv{getPivotTable(){return this.mapOnElements({query:":root",parent:this.rootFile.file.xml},(e=>({displayName:this.extractAttr(e,"name",{required:!0}).asString(),id:this.extractAttr(e,"name",{required:!0}).asString(),ref:this.extractChildAttr(e,"location","ref",{required:!0}).asString(),headerRowCount:this.extractChildAttr(e,"location","firstDataRow",{default:0}).asNum(),totalsRowCount:1,cols:[],style:{showFirstColumn:!0,showRowStripes:!0}})))[0]}}class fv extends hv{getTable(){return this.mapOnElements({query:"table",parent:this.rootFile.file.xml},(e=>{var t;return{displayName:this.extractAttr(e,"displayName",{required:!0}).asString(),name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),id:this.extractAttr(e,"id",{required:!0}).asString(),ref:this.extractAttr(e,"ref",{required:!0}).asString(),headerRowCount:this.extractAttr(e,"headerRowCount",{default:1}).asNum(),totalsRowCount:this.extractAttr(e,"totalsRowCount",{default:0}).asNum(),cols:this.extractTableCols(e),style:this.extractTableStyleInfo(e),autoFilter:this.extractTableAutoFilter(e)}}))[0]}extractTableCols(e){return this.mapOnElements({query:"tableColumn",parent:e},(e=>({id:this.extractAttr(e,"id",{required:!0}).asString(),name:this.extractAttr(e,"name",{required:!0}).asString(),colFormula:this.extractChildTextContent(e,"calculatedColumnFormula")})))}extractTableStyleInfo(e){return this.mapOnElements({query:"tableStyleInfo",parent:e},(e=>{var t,i,o,n,s;return{name:null===(t=this.extractAttr(e,"name"))||void 0===t?void 0:t.asString(),showFirstColumn:null===(i=this.extractAttr(e,"showFirstColumn"))||void 0===i?void 0:i.asBool(),showLastColumn:null===(o=this.extractAttr(e,"showLastColumn"))||void 0===o?void 0:o.asBool(),showRowStripes:null===(n=this.extractAttr(e,"showRowStripes"))||void 0===n?void 0:n.asBool(),showColumnStripes:null===(s=this.extractAttr(e,"showColumnStripes"))||void 0===s?void 0:s.asBool()}}))[0]}extractTableAutoFilter(e){return this.mapOnElements({query:"autoFilter",parent:e},(e=>({columns:this.extractFilterColumns(e),zone:this.extractAttr(e,"ref",{required:!0}).asString()})))[0]}extractFilterColumns(e){return this.mapOnElements({query:"tableColumn",parent:e},(t=>({colId:this.extractAttr(e,"colId",{required:!0}).asNum(),hiddenButton:this.extractAttr(e,"hiddenButton",{default:!1}).asBool(),filters:this.extractSimpleFilter(t)})))}extractSimpleFilter(e){return this.mapOnElements({query:"filter",parent:e},(e=>({val:this.extractAttr(e,"val",{required:!0}).asString()})))}}class vv extends hv{constructor(e,t,i,o){super(e,t,i),this.theme=o}getSheet(){return this.mapOnElements({query:"worksheet",parent:this.rootFile.file.xml},(e=>{const t=this.getSheetWorkbookInfo();return{sheetName:this.extractSheetName(),sheetViews:this.extractSheetViews(e),sheetFormat:this.extractSheetFormat(e),cols:this.extractCols(e),rows:this.extractRows(e),sharedFormulas:this.extractSharedFormulas(e),merges:this.extractMerges(e),cfs:this.extractConditionalFormats(),figures:this.extractFigures(e),hyperlinks:this.extractHyperLinks(e),tables:[...this.extractTables(e),...this.extractPivotTables()],isVisible:"visible"===t.state}}))[0]}extractSheetViews(e){return this.mapOnElements({parent:e,query:"sheetView"},(e=>{const t=this.querySelector(e,"pane");return{tabSelected:this.extractAttr(e,"tabSelected",{default:!1}).asBool(),showFormulas:this.extractAttr(e,"showFormulas",{default:!1}).asBool(),showGridLines:this.extractAttr(e,"showGridLines",{default:!0}).asBool(),showRowColHeaders:this.extractAttr(e,"showRowColHeaders",{default:!0}).asBool(),pane:{xSplit:t?this.extractAttr(t,"xSplit",{default:0}).asNum():0,ySplit:t?this.extractAttr(t,"ySplit",{default:0}).asNum():0}}}))}extractSheetName(){const e=cm(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id;for(let e of this.querySelectorAll(this.xlsxFileStructure.workbook.file.xml,"sheet"))if(e.attributes["r:id"].value===t)return e.attributes.name.value;throw new Error("Missing sheet name")}getSheetWorkbookInfo(){const e=cm(this.xlsxFileStructure.workbook.file.fileName,this.rootFile.file.fileName),t=this.extractRelationships(this.xlsxFileStructure.workbook.rels).find((t=>t.target===e)).id,i=this.mapOnElements({parent:this.xlsxFileStructure.workbook.file.xml,query:"sheet"},(e=>({relationshipId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetId:this.extractAttr(e,"sheetId",{required:!0}).asString(),sheetName:this.extractAttr(e,"name",{required:!0}).asString(),state:this.extractAttr(e,"state",{default:"visible"}).asString()}))).find((e=>e.relationshipId===t));if(!i)throw new Error("Cannot find corresponding workbook sheet");return i}extractConditionalFormats(){return new uv(this.rootFile,this.xlsxFileStructure,this.warningManager,this.theme).extractConditionalFormattings()}extractFigures(e){return this.mapOnElements({parent:e,query:"drawing"},(e=>{var t;const i=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),o=this.getTargetXmlFile(this.relationships[i]);return new pv(o,this.xlsxFileStructure,this.warningManager).extractFigures()}))[0]||[]}extractTables(e){return this.mapOnElements({query:"tablePart",parent:e},(e=>{var t;const i=null===(t=this.extractAttr(e,"r:id",{required:!0}))||void 0===t?void 0:t.asString(),o=this.getTargetXmlFile(this.relationships[i]);return new fv(o,this.xlsxFileStructure,this.warningManager).getTable()}))}extractPivotTables(){try{return Object.values(this.relationships).filter((e=>e.type.endsWith("pivotTable"))).map((e=>{const t=this.getTargetXmlFile(e);return new mv(t,this.xlsxFileStructure,this.warningManager).getPivotTable()}))}catch(e){return this.catchErrorOnElement(e),[]}}extractMerges(e){return this.mapOnElements({parent:e,query:"mergeCell"},(e=>this.extractAttr(e,"ref",{required:!0}).asString()))}extractSheetFormat(e){const t=this.querySelector(e,"sheetFormatPr");if(t)return{defaultColWidth:this.extractAttr(t,"defaultColWidth",{default:Dp.toString()}).asNum(),defaultRowHeight:this.extractAttr(t,"defaultRowHeight",{default:kp.toString()}).asNum()}}extractCols(e){return this.mapOnElements({parent:e,query:"cols col"},(e=>{var t,i,o,n,s,r,a;return{width:null===(t=this.extractAttr(e,"width"))||void 0===t?void 0:t.asNum(),customWidth:null===(i=this.extractAttr(e,"customWidth"))||void 0===i?void 0:i.asBool(),bestFit:null===(o=this.extractAttr(e,"bestFit"))||void 0===o?void 0:o.asBool(),hidden:null===(n=this.extractAttr(e,"hidden"))||void 0===n?void 0:n.asBool(),min:null===(s=this.extractAttr(e,"min",{required:!0}))||void 0===s?void 0:s.asNum(),max:null===(r=this.extractAttr(e,"max",{required:!0}))||void 0===r?void 0:r.asNum(),styleIndex:null===(a=this.extractAttr(e,"style"))||void 0===a?void 0:a.asNum()}}))}extractRows(e){return this.mapOnElements({parent:e,query:"sheetData row"},(e=>{var t,i,o,n,s;return{index:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asNum(),cells:this.extractCells(e),height:null===(i=this.extractAttr(e,"ht"))||void 0===i?void 0:i.asNum(),customHeight:null===(o=this.extractAttr(e,"customHeight"))||void 0===o?void 0:o.asBool(),hidden:null===(n=this.extractAttr(e,"hidden"))||void 0===n?void 0:n.asBool(),styleIndex:null===(s=this.extractAttr(e,"s"))||void 0===s?void 0:s.asNum()}}))}extractCells(e){return this.mapOnElements({parent:e,query:"c"},(e=>{var t,i,o;return{xc:null===(t=this.extractAttr(e,"r",{required:!0}))||void 0===t?void 0:t.asString(),styleIndex:null===(i=this.extractAttr(e,"s"))||void 0===i?void 0:i.asNum(),type:Xp[null===(o=this.extractAttr(e,"t",{default:"n"}))||void 0===o?void 0:o.asString()],value:this.extractChildTextContent(e,"v"),formula:this.extractCellFormula(e)}}))}extractCellFormula(e){var t,i;const o=this.querySelector(e,"f");if(o)return{content:this.extractTextContent(o),sharedIndex:null===(t=this.extractAttr(o,"si"))||void 0===t?void 0:t.asNum(),ref:null===(i=this.extractAttr(o,"ref"))||void 0===i?void 0:i.asString()}}extractHyperLinks(e){return this.mapOnElements({parent:e,query:"hyperlink"},(e=>{var t,i,o,n;const s=null===(t=this.extractAttr(e,"r:id"))||void 0===t?void 0:t.asString();return{xc:null===(i=this.extractAttr(e,"ref",{required:!0}))||void 0===i?void 0:i.asString(),location:null===(o=this.extractAttr(e,"location"))||void 0===o?void 0:o.asString(),display:null===(n=this.extractAttr(e,"display"))||void 0===n?void 0:n.asString(),relTarget:s?this.relationships[s].target:void 0}}))}extractSharedFormulas(e){const t=this.querySelectorAll(e,"f[si][ref]"),i={};for(let e of t){const t=this.extractAttr(e,"si",{required:!0}).asNum(),o=this.extractTextContent(e,{required:!0});i[t]=o}const o=[];for(let e=0;e<Object.keys(i).length;e++)i[e]?o.push(i[e]):(this.warningManager.addParsingWarning(`Missing shared formula ${e}, replacing it by empty formula`),o.push(""));return o}}class bv extends hv{constructor(e,t,i){super(e.styles,e,t),this.theme=i}getNumFormats(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"numFmt"},(e=>this.extractNumFormats(e)))}extractNumFormats(e){return{id:this.extractAttr(e,"numFmtId",{required:!0}).asNum(),format:this.extractAttr(e,"formatCode",{required:!0,default:""}).asString()}}getFonts(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"font"},(e=>this.extractFont(e)))}extractFont(e){var t,i,o,n;const s=this.extractChildAttr(e,"name","val",{default:"Arial"}).asString(),r=this.extractChildAttr(e,"sz","val",{default:q.toString()}).asNum(),a=this.extractColor(this.querySelector(e,"color"),this.theme),l=this.querySelector(e,"i")||void 0,c=l&&"0"!==(null===(t=l.attributes.val)||void 0===t?void 0:t.value),h=this.querySelector(e,"b")||void 0,d=h&&"0"!==(null===(i=h.attributes.val)||void 0===i?void 0:i.value),u=this.querySelector(e,"strike")||void 0,g=u&&"0"!==(null===(o=u.attributes.val)||void 0===o?void 0:o.value),p=this.querySelector(e,"u")||void 0;return{name:s,size:r,color:a,italic:c,bold:d,underline:p&&"none"!==(null===(n=p.attributes.val)||void 0===n?void 0:n.value),strike:g}}getFills(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"fill"},(e=>this.extractFill(e)))}extractFill(e){var t;const i=e.children[0];return"patternFill"===i.tagName?{patternType:null===(t=i.attributes.patternType)||void 0===t?void 0:t.value,bgColor:this.extractColor(this.querySelector(i,"bgColor"),this.theme),fgColor:this.extractColor(this.querySelector(i,"fgColor"),this.theme)}:{patternType:"solid",fgColor:this.extractColor(this.querySelectorAll(i,"color")[1],this.theme)}}getBorders(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"border"},(e=>this.extractBorder(e)))}extractBorder(e){var t,i;const o={left:this.extractSingleBorder(e,"left",this.theme),right:this.extractSingleBorder(e,"right",this.theme),top:this.extractSingleBorder(e,"top",this.theme),bottom:this.extractSingleBorder(e,"bottom",this.theme),diagonal:this.extractSingleBorder(e,"diagonal",this.theme)};return o.diagonal&&(o.diagonalUp=null===(t=this.extractAttr(e,"diagonalUp"))||void 0===t?void 0:t.asBool(),o.diagonalDown=null===(i=this.extractAttr(e,"diagonalDown"))||void 0===i?void 0:i.asBool()),o}extractSingleBorder(e,t,i){const o=this.querySelector(e,t);if(o&&o.attributes.style)return{style:this.extractAttr(o,"style",{required:!0,default:"thin"}).asString(),color:this.extractColor(o.children[0],i,"000000")}}extractAlignment(e){var t,i,o,n,s,r,a;return{horizontal:this.extractAttr(e,"horizontal",{default:"general"}).asString(),vertical:this.extractAttr(e,"vertical",{default:"center"}).asString(),textRotation:null===(t=this.extractAttr(e,"textRotation"))||void 0===t?void 0:t.asNum(),wrapText:null===(i=this.extractAttr(e,"wrapText"))||void 0===i?void 0:i.asBool(),indent:null===(o=this.extractAttr(e,"indent"))||void 0===o?void 0:o.asNum(),relativeIndent:null===(n=this.extractAttr(e,"relativeIndent"))||void 0===n?void 0:n.asNum(),justifyLastLine:null===(s=this.extractAttr(e,"justifyLastLine"))||void 0===s?void 0:s.asBool(),shrinkToFit:null===(r=this.extractAttr(e,"shrinkToFit"))||void 0===r?void 0:r.asBool(),readingOrder:null===(a=this.extractAttr(e,"readingOrder"))||void 0===a?void 0:a.asNum()}}getDxfs(){return this.mapOnElements({query:"dxf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"font"),i=this.querySelector(e,"fill"),o=this.querySelector(e,"border"),n=this.querySelector(e,"numFmt"),s=this.querySelector(e,"alignment");return{font:t?this.extractFont(t):void 0,fill:i?this.extractFill(i):void 0,numFmt:n?this.extractNumFormats(n):void 0,alignment:s?this.extractAlignment(s):void 0,border:o?this.extractBorder(o):void 0}}))}getStyles(){return this.mapOnElements({query:"cellXfs xf",parent:this.rootFile.file.xml},(e=>{const t=this.querySelector(e,"alignment");return{fontId:this.extractAttr(e,"fontId",{required:!0,default:0}).asNum(),fillId:this.extractAttr(e,"fillId",{required:!0,default:0}).asNum(),borderId:this.extractAttr(e,"borderId",{required:!0,default:0}).asNum(),numFmtId:this.extractAttr(e,"numFmtId",{required:!0,default:0}).asNum(),alignment:t?this.extractAlignment(t):void 0}}))}}class Sv extends hv{getExternalBook(){return this.mapOnElements({parent:this.rootFile.file.xml,query:"externalBook"},(e=>({rId:this.extractAttr(e,"r:id",{required:!0}).asString(),sheetNames:this.mapOnElements({parent:e,query:"sheetName"},(e=>this.extractAttr(e,"val",{required:!0}).asString())),datasets:this.extractExternalSheetData(e)})))[0]}extractExternalSheetData(e){return this.mapOnElements({parent:e,query:"sheetData"},(e=>{const t=this.mapOnElements({parent:e,query:"cell"},(e=>({xc:this.extractAttr(e,"r",{required:!0}).asString(),value:this.extractChildTextContent(e,"v",{required:!0})}))),i={};for(let e of t)i[e.xc]=e.value;return{sheetId:this.extractAttr(e,"sheetId",{required:!0}).asNum(),data:i}}))}}function Cv(e,t){const i=function(e,t){const i=t[Bp],o=i.querySelectorAll(`Override[ContentType="${e}"]`),n=[];for(let e of o){const t=null==e?void 0:e.attributes.PartName.value;n.push(t.substring(1))}return n}(e,t);return function(e,t){const i=[];for(let o of e){const e=Ev(o,t);i.push({file:{fileName:o,xml:t[o]},rels:e?{fileName:e,xml:t[e]}:void 0})}return i}(i,t)}function Ev(e,t){if(e===Bp)return"_rels/.rels";let i="";const o=e.split("/");for(let e=0;e<o.length-1;e++)i+=o[e]+"/";return i+="_rels/",i+=o[o.length-1]+".rels",t[i]||(i=void 0),i}class wv{constructor(e){this.warningManager=new $p,this.xmls={};for(let t of Object.keys(e))(t.endsWith(".xml")||t.endsWith(".rels"))&&(this.xmls[t]=ov(new wp(e[t])))}convertXlsx(){const e=this.getXlsxData();return this.convertImportedData(e)}getXlsxData(){const e=this.buildXlsxFileStructure(),t=e.theme?new dv(e.theme,e,this.warningManager).getTheme():void 0,i=e.sharedStrings?new dv(e.sharedStrings,e,this.warningManager).getSharedStrings():[],o=e.sheets.sort(((e,t)=>e.file.fileName.localeCompare(t.file.fileName,void 0,{numeric:!0}))).map((i=>new vv(i,e,this.warningManager,t).getSheet())),n=e.externalLinks.map((t=>new Sv(t,e,this.warningManager).getExternalBook())),s=new bv(e,this.warningManager,t);return{fonts:s.getFonts(),fills:s.getFills(),borders:s.getBorders(),dxfs:s.getDxfs(),numFmts:s.getNumFormats(),styles:s.getStyles(),sheets:o,sharedStrings:i,externalBooks:n}}buildXlsxFileStructure(){const e={sheets:Cv(Mp.sheet,this.xmls),workbook:Cv(Mp.workbook,this.xmls)[0],styles:Cv(Mp.styles,this.xmls)[0],sharedStrings:Cv(Mp.sharedStrings,this.xmls)[0],theme:Cv(Mp.themes,this.xmls)[0],charts:Cv(Mp.chart,this.xmls),figures:Cv(Mp.drawing,this.xmls),tables:Cv(Mp.table,this.xmls),pivots:Cv(Mp.pivot,this.xmls),externalLinks:Cv(Mp.externalLink,this.xmls)};if(!e.workbook.rels)throw Error(s("Cannot find workbook relations file"));return e}convertImportedData(e){const t={version:12,sheets:$f(e,this.warningManager),styles:vm(e,this.warningManager),formats:Sm(e,this.warningManager),borders:mm(e,this.warningManager),entities:{},revisionId:Q};return Kf(t,e),Object.keys(e.styles).map((t=>{e.styles[t]=dt(e.styles[t])})),t}}function yv(e){const t=df(e);let i=[];return{text:"".concat(...t.map((e=>{if("REFERENCE"===e.type&&Ot.test(e.value)){const t=e.value.trim();return i.includes(t)||i.push(t),`${ae}${i.indexOf(t)}${ae}`}return e.value}))),dependencies:i}}const xv=12,Iv="Sheet1";function Rv(e,t){if(!e)return Nv();if(e["[Content_Types].xml"]){const i=new wv(e);if(e=i.convertXlsx(),t)for(let e of i.warningManager.warnings.sort())console.warn(e)}return"version"in(e=_e(e))&&e.version<xv&&(e=function(e){for(let t=Tv.findIndex((t=>t.from===e.version));t<Tv.length;t++)e=Tv[t].applyMigration(e);return e}(e)),e=function(e){return e=function(e){if(e.uniqueFigureIds)return e;const t=new Set,i=new Vi;for(const o of e.sheets||[])for(const e of o.figures||[])t.has(e.id)&&(e.id+=i.uuidv4()),t.add(e.id);return e.uniqueFigureIds=!0,e}(e),e=function(e){e=Object.assign(Nv(),e,{version:xv}),e.sheets=e.sheets?e.sheets.map(((e,t)=>Object.assign(Ov(`Sheet${t+1}`,`Sheet${t+1}`),e))):[],0===e.sheets.length&&e.sheets.push(Ov(Iv,"Sheet1"));return e}(e),e}(e),e}const Tv=[{description:"add the `activeSheet` field on data",from:1,to:2,applyMigration:e=>(e.sheets&&e.sheets[0]&&(e.activeSheet=e.sheets[0].name),e)},{description:"add an id field in each sheet",from:2,to:3,applyMigration(e){if(e.sheets&&e.sheets.length)for(let t of e.sheets)t.id=t.id||t.name;return e}},{description:"activeSheet is now an id, not the name of a sheet",from:3,to:4,applyMigration(e){if(e.sheets&&e.activeSheet){const t=e.sheets.find((t=>t.name===e.activeSheet));e.activeSheet=t.id}return e}},{description:"add figures object in each sheets",from:4,to:5,applyMigration(e){for(let t of e.sheets||[])t.figures=t.figures||[];return e}},{description:"normalize the content of the cell if it is a formula to avoid parsing all the formula that vary only by the cells they use",from:5,to:6,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const i=t.cells[e];i.content&&i.content.startsWith("=")&&(i.formula=yv(i.content))}return e}},{description:"transform chart data structure",from:6,to:7,applyMigration(e){for(let t of e.sheets||[])for(let e in t.figures||[]){const{dataSets:i,...o}=t.figures[e].data,n=[];for(let e of i)if(e.labelCell){const t=Bi(e.dataRange),i=e.labelCell+":"+qt(t.right,t.bottom);n.push(i)}else n.push(e.dataRange);o.dataSetsHaveTitle=Boolean(i[0].labelCell),o.dataSets=n,t.figures[e].data=o}return e}},{description:"remove single quotes in sheet names",from:7,to:8,applyMigration(e){var t;const i=[],o=new RegExp(re,"g");for(let n of e.sheets||[]){if(!n.name)continue;const e=n.name,s=e.replace(o,"_");let r=1,a=s;for(;i.includes(a);)a=`${s}${r}`,r++;n.name=a,i.push(a);const l=t=>{if(void 0===t)return t;let i=t.replace(e,a),o=t;for(;o!==i;)o=i,i=o.replace(e,a);return o};for(let e in n.cells){const t=n.cells[e];t.formula&&(t.formula.dependencies=t.formula.dependencies.map(l))}for(let e of n.figures||[])if("chart"===e.type){const t=e.data.dataSets.map(l),i=l(e.data.labelRange);e.data={...e.data,dataSets:t,labelRange:i}}for(let e of n.conditionalFormats||[]){e.ranges=e.ranges.map(l);for(const i of["minimum","maximum","midpoint","upperInflectionPoint","lowerInflectionPoint"])"formula"===(null===(t=e.rule[i])||void 0===t?void 0:t.type)&&(e.rule[i].value=l(e.rule[i].value))}}return e}},{description:"transform chart data structure with design attributes",from:8,to:9,applyMigration(e){for(const t of e.sheets||[])for(const e of t.figures||[])e.data.background=w,e.data.verticalAxisPosition="left",e.data.legendPosition="top",e.data.stacked=!1;return e}},{description:"de-normalize formula to reduce exported json size (~30%)",from:9,to:10,applyMigration(e){for(let t of e.sheets||[])for(let e in t.cells||[]){const i=t.cells[e];if(i.formula){let{text:e,dependencies:t}=i.formula;for(let[i,o]of Object.entries(t)){const t=`\\${ae}${i}\\${ae}`;e=e.replace(new RegExp(t,"g"),o)}i.content=e,delete i.formula}}return e}},{description:"normalize the formats of the cells",from:10,to:11,applyMigration(e){const t={};for(let i of e.sheets||[])for(let e in i.cells||[]){const o=i.cells[e];o.format&&(o.format=nt(o.format,t))}return e.formats=t,e}},{description:"Add isVisible to sheets",from:11,to:12,applyMigration(e){for(let t of e.sheets||[])t.isVisible=!0;return e}}];function Av(e,t){return t=function(e,t){if(0!==Object.keys(e).length)return t;const i=[],o=[],n=e=>{if("CREATE_SHEET"===e.type)i.push(e.sheetId);else if("sheetId"in e&&!i.includes(e.sheetId))return{...e,sheetId:Iv};return e};for(const e of t)"REMOTE_REVISION"===e.type?o.push({...e,commands:e.commands.map(n)}):o.push(e);return o}(e,t),t=Mv(t,"SORT_CELLS"),t=function(e,t){var i;const o=[],n={};for(const t of e.sheets||[])null===(i=t.figures)||void 0===i||i.forEach((e=>{"chart"===e.tag&&(n[e.id]=e.data)}));for(const e of t)if("REMOTE_REVISION"===e.type){const t=[];for(const i of e.commands){let e=i;switch(i.type){case"CREATE_CHART":n[i.id]=i.definition;break;case"UPDATE_CHART":if(!n[i.id]){console.log(`Fix chart definition: chart with id ${i.id} not found.`);continue}const t={...n[i.id],...i.definition};e={...i,definition:t},n[i.id]=t}t.push(e)}o.push({...e,commands:t})}else o.push(e);return o}(e,t=Mv(t,"SET_DECIMAL")),t}function Mv(e,t){const i=[];for(const o of e)"REMOTE_REVISION"===o.type?i.push({...o,commands:o.commands.filter((e=>e.type!==t))}):i.push(o);return i}function Ov(e,t){return{id:e,name:t,colNumber:26,rowNumber:100,cells:{},cols:{},rows:{},merges:[],conditionalFormats:[],figures:[],filterTables:[],isVisible:!0}}function Nv(e="Sheet1"){return{version:xv,sheets:[Ov(Iv,e)],entities:{},styles:{},formats:{},borders:{},revisionId:Q,uniqueFigureIds:!0}}function _v(e,t){return{...Ov(e,t),charts:[],images:[]}}class Fv{constructor(e,t){this.history=Object.assign(Object.create(e),{update:e.addChange.bind(e,this),selectCell:()=>{}}),this.dispatch=t}exportForExcel(e){}allowDispatch(e){return 0}beforeHandle(e){}handle(e){}finalize(){}batchValidations(...e){return t=>e.map((e=>e.call(this,t))).flat()}chainValidations(...e){return t=>{for(const i of e){let e=i.call(this,t);Array.isArray(e)||(e=[e]);const o=e.filter((e=>0!==e));if(o.length)return o}return 0}}checkValidations(e,...t){return this.batchValidations(...t)(e)}}Fv.getters=[];class Dv extends Fv{constructor({getters:e,stateObserver:t,range:i,dispatch:o,uuidGenerator:n}){super(t,o),this.range=i,i.addRangeProvider(this.adaptRanges.bind(this)),this.getters=e,this.uuidGenerator=n}import(e){}export(e){}adaptRanges(e,t){}garbageCollectExternalResources(){}}class kv extends Dv{constructor(){super(...arguments),this.borders={}}allowDispatch(e){return"SET_BORDER"===e.type?this.checkBordersUnchanged(e):0}handle(e){switch(e.type){case"ADD_MERGE":for(const t of e.target)this.addBordersToMerge(e.sheetId,t);break;case"DUPLICATE_SHEET":const t=this.borders[e.sheetId];if(t){const i=t.slice().map((e=>null==e?void 0:e.slice().map((e=>({...e})))));this.history.update("borders",e.sheetIdTo,i)}break;case"DELETE_SHEET":const i={...this.borders};delete i[e.sheetId],this.history.update("borders",i);break;case"SET_BORDER":this.setBorder(e.sheetId,e.col,e.row,e.border);break;case"SET_FORMATTING":if(e.border){const t=e.target.map((t=>this.getters.expandZone(e.sheetId,t)));this.setBorders(e.sheetId,t,e.border)}break;case"CLEAR_FORMATTING":this.clearBorders(e.sheetId,e.target);break;case"REMOVE_COLUMNS_ROWS":for(let t of e.elements)"COL"===e.dimension?this.shiftBordersHorizontally(e.sheetId,t+1,-1):this.shiftBordersVertically(e.sheetId,t+1,-1);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumns(e):this.handleAddRows(e)}}handleAddColumns(e){let t,i;"before"===e.position?(this.shiftBordersHorizontally(e.sheetId,e.base,e.quantity,{moveFirstLeftBorder:!0}),t=e.base-1,i=e.base+e.quantity):(this.shiftBordersHorizontally(e.sheetId,e.base+1,e.quantity,{moveFirstLeftBorder:!1}),t=e.base,i=e.base+e.quantity+1),this.ensureColumnBorderContinuity(e.sheetId,t,i)}handleAddRows(e){let t,i;"before"===e.position?(this.shiftBordersVertically(e.sheetId,e.base,e.quantity,{moveFirstTopBorder:!0}),t=e.base-1,i=e.base+e.quantity):(this.shiftBordersVertically(e.sheetId,e.base+1,e.quantity,{moveFirstTopBorder:!1}),t=e.base,i=e.base+e.quantity+1),this.ensureRowBorderContinuity(e.sheetId,t,i)}getCellBorder({sheetId:e,col:t,row:i}){var o,n,s,r,a,l,c,h,d,u,g,p;const m={top:null===(s=null===(n=null===(o=this.borders[e])||void 0===o?void 0:o[t])||void 0===n?void 0:n[i])||void 0===s?void 0:s.horizontal,bottom:null===(l=null===(a=null===(r=this.borders[e])||void 0===r?void 0:r[t])||void 0===a?void 0:a[i+1])||void 0===l?void 0:l.horizontal,left:null===(d=null===(h=null===(c=this.borders[e])||void 0===c?void 0:c[t])||void 0===h?void 0:h[i])||void 0===d?void 0:d.vertical,right:null===(p=null===(g=null===(u=this.borders[e])||void 0===u?void 0:u[t+1])||void 0===g?void 0:g[i])||void 0===p?void 0:p.vertical};return m.bottom||m.left||m.right||m.top?m:null}ensureColumnBorderContinuity(e,t,i){const o=He(t+1,i);for(let n=0;n<this.getters.getNumberRows(e);n++){const s=this.getCellBorder({sheetId:e,col:t,row:n}),r=this.getCellBorder({sheetId:e,col:i,row:n});if(s&&r){const t=this.getCommonSides(s,r);for(let i of o)this.addBorder(e,i,n,t)}}}ensureRowBorderContinuity(e,t,i){const o=He(t+1,i);for(let n=0;n<this.getters.getNumberCols(e);n++){const s=this.getCellBorder({sheetId:e,col:n,row:t}),r=this.getCellBorder({sheetId:e,col:n,row:i});if(s&&r){const t=this.getCommonSides(s,r);for(let i of o)this.addBorder(e,n,i,t)}}}getCommonSides(e,t){const i={};for(let o of["top","bottom","left","right"])e[o]&&e[o]===t[o]&&(i[o]=e[o]);return i}getColumnsWithBorders(e){const t=this.borders[e];return t?Object.keys(t).map((e=>parseInt(e,10))):[]}getRowsRange(e){return this.borders[e]?He(0,this.getters.getNumberRows(e)+1):[]}shiftBordersHorizontally(e,t,i,{moveFirstLeftBorder:o}={}){this.borders[e]&&(i<0&&this.moveBordersOfColumn(e,t,i,"vertical",{destructive:!1}),this.getColumnsWithBorders(e).filter((e=>e>=t)).sort(((e,t)=>i<0?e-t:t-e)).forEach((n=>{(n===t&&o||n!==t)&&this.moveBordersOfColumn(e,n,i,"vertical"),this.moveBordersOfColumn(e,n,i,"horizontal")})))}shiftBordersVertically(e,t,i,{moveFirstTopBorder:o}={}){this.borders[e]&&(i<0&&this.moveBordersOfRow(e,t,i,"horizontal",{destructive:!1}),this.getRowsRange(e).filter((e=>e>=t)).sort(((e,t)=>i<0?e-t:t-e)).forEach((n=>{(n===t&&o||n!==t)&&this.moveBordersOfRow(e,n,i,"horizontal"),this.moveBordersOfRow(e,n,i,"vertical")})))}moveBordersOfRow(e,t,i,o,{destructive:n}={destructive:!0}){const s=this.borders[e];s&&this.getColumnsWithBorders(e).forEach((r=>{var a,l,c,h;const d=null===(l=null===(a=s[r])||void 0===a?void 0:a[t+i])||void 0===l?void 0:l[o],u=null===(h=null===(c=s[r])||void 0===c?void 0:c[t])||void 0===h?void 0:h[o];this.history.update("borders",e,r,t+i,o,n?u:u||d),this.history.update("borders",e,r,t,o,void 0)}))}moveBordersOfColumn(e,t,i,o,{destructive:n}={destructive:!0}){const s=this.borders[e];s&&this.getRowsRange(e).forEach((r=>{var a,l,c,h;const d=null===(l=null===(a=s[t+i])||void 0===a?void 0:a[r])||void 0===l?void 0:l[o],u=null===(h=null===(c=s[t])||void 0===c?void 0:c[r])||void 0===h?void 0:h[o];this.history.update("borders",e,t+i,r,o,n?u:u||d),this.history.update("borders",e,t,r,o,void 0)}))}setBorder(e,t,i,o,n=!0){var s,r,a,l,c,h,d,u,g,p,m,f,v,b,S,C;!n&&(null===(l=null===(a=null===(r=null===(s=this.borders)||void 0===s?void 0:s[e])||void 0===r?void 0:r[t])||void 0===a?void 0:a[i])||void 0===l?void 0:l.vertical)||this.history.update("borders",e,t,i,"vertical",null==o?void 0:o.left),!n&&(null===(u=null===(d=null===(h=null===(c=this.borders)||void 0===c?void 0:c[e])||void 0===h?void 0:h[t])||void 0===d?void 0:d[i])||void 0===u?void 0:u.horizontal)||this.history.update("borders",e,t,i,"horizontal",null==o?void 0:o.top),!n&&(null===(f=null===(m=null===(p=null===(g=this.borders)||void 0===g?void 0:g[e])||void 0===p?void 0:p[t+1])||void 0===m?void 0:m[i])||void 0===f?void 0:f.vertical)||this.history.update("borders",e,t+1,i,"vertical",null==o?void 0:o.right),!n&&(null===(C=null===(S=null===(b=null===(v=this.borders)||void 0===v?void 0:v[e])||void 0===b?void 0:b[t])||void 0===S?void 0:S[i+1])||void 0===C?void 0:C.horizontal)||this.history.update("borders",e,t,i+1,"horizontal",null==o?void 0:o.bottom)}clearBorders(e,t){for(let i of t){for(let t=i.top;t<=i.bottom;t++){this.history.update("borders",e,i.right+1,t,"vertical",void 0);for(let o=i.left;o<=i.right;o++)this.history.update("borders",e,o,t,void 0)}for(let t=i.left;t<=i.right;t++)this.history.update("borders",e,t,i.bottom+1,"horizontal",void 0)}}addBorder(e,t,i,o){this.setBorder(e,t,i,{...this.getCellBorder({sheetId:e,col:t,row:i}),...o})}setBorders(e,t,i){if("clear"===i)return this.clearBorders(e,t);for(let o of t){if("h"===i||"hv"===i||"all"===i)for(let t=o.top+1;t<=o.bottom;t++)for(let i=o.left;i<=o.right;i++)this.addBorder(e,i,t,{top:j});if("v"===i||"hv"===i||"all"===i)for(let t=o.top;t<=o.bottom;t++)for(let i=o.left+1;i<=o.right;i++)this.addBorder(e,i,t,{left:j});if("left"===i||"all"===i||"external"===i)for(let t=o.top;t<=o.bottom;t++)this.addBorder(e,o.left,t,{left:j});if("right"===i||"all"===i||"external"===i)for(let t=o.top;t<=o.bottom;t++)this.addBorder(e,o.right+1,t,{left:j});if("top"===i||"all"===i||"external"===i)for(let t=o.left;t<=o.right;t++)this.addBorder(e,t,o.top,{top:j});if("bottom"===i||"all"===i||"external"===i)for(let t=o.left;t<=o.right;t++)this.addBorder(e,t,o.bottom+1,{top:j})}}addBordersToMerge(e,t){const{left:i,right:o,top:n,bottom:s}=t,r=this.getCellBorder({sheetId:e,col:i,row:n}),a=this.getCellBorder({sheetId:e,col:o,row:s});this.clearBorders(e,[t]),(null==r?void 0:r.top)&&this.setBorders(e,[{...t,bottom:n}],"top"),(null==r?void 0:r.left)&&this.setBorders(e,[{...t,right:i}],"left"),((null==a?void 0:a.bottom)||(null==r?void 0:r.bottom))&&this.setBorders(e,[{...t,top:s}],"bottom"),((null==a?void 0:a.right)||(null==r?void 0:r.right))&&this.setBorders(e,[{...t,left:o}],"right")}checkBordersUnchanged(e){var t,i,o,n;const s=this.getCellBorder(e),r=!((null===(t=e.border)||void 0===t?void 0:t.bottom)||(null===(i=e.border)||void 0===i?void 0:i.left)||(null===(o=e.border)||void 0===o?void 0:o.right)||(null===(n=e.border)||void 0===n?void 0:n.top));return!s&&r||ct(s,e.border)?88:0}import(e){if(e.borders)for(let t of e.sheets)for(let[i,o]of Object.entries(t.cells))if(null==o?void 0:o.border){const n=e.borders[o.border],{col:s,row:r}=Gt(i);this.setBorder(t.id,s,r,n,!1)}for(let t of e.sheets)if(t.merges)for(let e of t.merges)this.addBordersToMerge(t.id,Bi(e))}export(e){let t=0;const i={};function o(e){for(let[t,o]of Object.entries(i))if(ct(o,e))return parseInt(t,10);return i[++t]=e,t}for(let t of e.sheets)for(let e=0;e<t.colNumber;e++)for(let i=0;i<t.rowNumber;i++){const n=this.getCellBorder({sheetId:t.id,col:e,row:i});if(n){const s=qt(e,i),r=t.cells[s],a=o(n);r?r.border=a:t.cells[s]={border:a}}}e.borders=i}exportForExcel(e){this.export(e)}}kv.getters=["getCellBorder"];class Lv extends Dv{constructor(){super(...arguments),this.nextId=1,this.cells={}}adaptRanges(e,t){for(const i of Object.keys(this.cells))for(const o of Object.values(this.cells[i]||{}))if(o.isFormula)for(const n of o.dependencies)if(!t||n.sheetId===t){const t=e(n);"NONE"!==t.changeType&&this.history.update("cells",i,o.id,"dependencies",o.dependencies.indexOf(n),t.range)}}allowDispatch(e){switch(e.type){case"UPDATE_CELL":return this.checkCellOutOfSheet(e);case"CLEAR_CELL":return this.checkValidations(e,this.chainValidations(this.checkCellOutOfSheet,this.checkUselessClearCell));default:return 0}}handle(e){switch(e.type){case"SET_FORMATTING":"style"in e&&this.setStyle(e.sheetId,e.target,e.style),"format"in e&&void 0!==e.format&&this.setFormatter(e.sheetId,e.target,e.format);break;case"CLEAR_FORMATTING":this.clearFormatting(e.sheetId,e.target);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.handleAddColumnsRows(e,this.copyColumnStyle.bind(this)):this.handleAddColumnsRows(e,this.copyRowStyle.bind(this));break;case"UPDATE_CELL":this.updateCell(e.sheetId,e.col,e.row,e);break;case"CLEAR_CELL":this.dispatch("UPDATE_CELL",{sheetId:e.sheetId,col:e.col,row:e.row,content:"",style:null,format:""})}}setFormatter(e,t,i){for(let o of t)for(let t=o.top;t<=o.bottom;t++)for(let n=o.left;n<=o.right;n++)this.dispatch("UPDATE_CELL",{sheetId:e,col:n,row:t,format:i})}clearFormatting(e,t){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let o=i.top;o<=i.bottom;o++)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,style:null,format:""})}handleAddColumnsRows(e,t){let i,o;"before"===e.position?(i=He(e.base,e.base+e.quantity),o=e.base+e.quantity):(i=He(e.base+1,e.base+e.quantity+1),o=e.base),t(e.sheetId,o,i)}import(e){for(let t of e.sheets)for(let i in t.cells){const o=t.cells[i],{col:n,row:s}=Gt(i);if((null==o?void 0:o.content)||(null==o?void 0:o.format)||(null==o?void 0:o.style)){const i=this.importCell(t.id,o,e.styles,e.formats);this.history.update("cells",t.id,i.id,i),this.dispatch("UPDATE_CELL_POSITION",{cellId:i.id,col:n,row:s,sheetId:t.id})}}}export(e){const t={},i={};for(let o of e.sheets){const e={},n=Object.keys(this.cells[o.id]||{}).map((e=>this.getters.getCellPosition(e))).sort(((e,t)=>e.col===t.col?e.row-t.row:e.col-t.col));for(const o of n){const n=this.getters.getCell(o);e[qt(o.col,o.row)]={style:n.style?nt(n.style,t):void 0,format:n.format?nt(n.format,i):void 0,content:n.content||void 0}}o.cells=e}e.styles=t,e.formats=i}importCell(e,t,i,o){const n=t.style&&i[t.style]||void 0,s=t.format&&o[t.format]||void 0,r=this.getNextUid();return this.createCell(r,(null==t?void 0:t.content)||"",s,n,e)}exportForExcel(e){this.export(e)}getCells(e){return this.cells[e]||{}}getCellById(e){const t=this.getters.getCellPosition(e);return this.cells[t.sheetId][e]}buildFormulaContent(e,t,i){const o=i||t.dependencies;let n=0;return st(t.compiledFormula.tokens.map((t=>{if("REFERENCE"===t.type){const t=o[n++];return this.getters.getRangeString(t,e)}return t.value})))}getFormulaCellContent(e,t){return this.buildFormulaContent(e,t)}getCellStyle(e){var t;return(null===(t=this.getters.getCell(e))||void 0===t?void 0:t.style)||{}}zoneToXC(e,t,i=[{colFixed:!1,rowFixed:!1}]){const o=qt((t=this.getters.expandZone(e,t)).left,t.top,i[0]),n=qt(t.right,t.bottom,i.length>1?i[1]:i[0]),s=this.getters.getMainCellPosition({sheetId:e,col:t.left,row:t.top}),r=this.getters.getMainCellPosition({sheetId:e,col:t.right,row:t.bottom}),a=s.col===r.col&&s.row===r.row;return o==n||a?o:o+":"+n}setStyle(e,t,i){for(let o of t)for(let t=o.left;t<=o.right;t++)for(let n=o.top;n<=o.bottom;n++){const o=this.getters.getCell({sheetId:e,col:t,row:n});this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:n,style:i?{...null==o?void 0:o.style,...i}:void 0})}}copyColumnStyle(e,t,i){for(let o=0;o<this.getters.getNumberRows(e);o++){const n=this.getFormat(e,t,o);if(n.style||n.format)for(let t of i)this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,...n})}}copyRowStyle(e,t,i){for(let o=0;o<this.getters.getNumberCols(e);o++){const n=this.getFormat(e,o,t);if(n.style||n.format)for(let t of i)this.dispatch("UPDATE_CELL",{sheetId:e,col:o,row:t,...n})}}getFormat(e,t,i){const o={},n=this.getters.getMainCellPosition({sheetId:e,col:t,row:i}),s=this.getters.getCell(n);return s&&(s.style&&(o.style=s.style),s.format&&(o.format=s.format)),o}getNextUid(){const e=this.nextId.toString();return this.history.update("nextId",this.nextId+1),e}updateCell(e,t,i,o){const n=this.getters.getCell({sheetId:e,col:t,row:i}),s="content"in o||"formula"in o,r=s?ft(null==o?void 0:o.content):(null==n?void 0:n.content)||"";let a;a=void 0!==o.style?o.style||void 0:n?n.style:void 0;let l=("format"in o?o.format:n&&n.format)||Ri(r);if((s&&!r&&!o.formula||!s&&(!n||""===n.content))&&!a&&!l)return void(n&&(this.history.update("cells",e,n.id,void 0),this.dispatch("UPDATE_CELL_POSITION",{cellId:void 0,col:t,row:i,sheetId:e})));const c=(null==n?void 0:n.id)||this.getNextUid(),h=this.createCell(c,r,l,a,e);this.history.update("cells",e,h.id,h),this.dispatch("UPDATE_CELL_POSITION",{cellId:h.id,col:t,row:i,sheetId:e})}createCell(e,t,i,o,n){if(!t.startsWith("="))return this.createLiteralCell(e,t,i,o);try{return this.createFormulaCell(e,t,i,o,n)}catch(n){return this.createErrorFormula(e,t,i,o,n)}}createLiteralCell(e,t,i,o){return{id:e,content:t,style:o,format:i,isFormula:!1}}createFormulaCell(e,t,i,o,n){const s=ff(t);return s.dependencies.length?this.createFormulaCellWithDependencies(e,s,i,o,n):{id:e,content:t,style:o,format:i,isFormula:!0,compiledFormula:s,dependencies:[]}}createFormulaCellWithDependencies(e,t,i,o,n){const s=t.dependencies.map((e=>this.getters.getRangeFromSheetXC(n,e))),r=this.buildFormulaContent.bind(this);return{id:e,get content(){return r(n,{dependencies:this.dependencies,compiledFormula:this.compiledFormula})},style:o,format:i,isFormula:!0,compiledFormula:t,dependencies:s}}createErrorFormula(e,t,i,o,n){return{id:e,content:t,style:o,format:i,isFormula:!0,compiledFormula:{dependencies:[],tokens:_m(t),execute:function(){throw n}},dependencies:[]}}checkCellOutOfSheet(e){const{sheetId:t,col:i,row:o}=e;if(!this.getters.tryGetSheet(t))return 27;return Qi(i,o,this.getters.getSheetZone(t))?0:18}checkUselessClearCell(e){const t=this.getters.getCell(e);return t&&(t.content||t.style||t.format)?0:88}}Lv.getters=["zoneToXC","getCells","getFormulaCellContent","getCellStyle","buildFormulaContent","getCellById"];class Pv extends Dv{constructor(){super(...arguments),this.charts={},this.createChart=function(e){const t=gr.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(i,o,n){const s=t.find((e=>e.match(o.type)));if(!s)throw new Error(`No builder for this chart: ${o.type}`);return s.createChart(o,n,e)}}(this.getters),this.validateChartDefinition=e=>function(e,t){const i=gr.getAll().find((e=>e.match(t.type)));if(!i)throw new Error("Unknown chart type.");return i.validateChartDefinition(e,t)}(this,e.definition)}adaptRanges(e){for(const[t,i]of Object.entries(this.charts))this.history.update("charts",t,null==i?void 0:i.updateRanges(e))}allowDispatch(e){switch(e.type){case"CREATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartDuplicate));case"UPDATE_CHART":return this.checkValidations(e,this.chainValidations(this.validateChartDefinition,this.checkChartExists));default:return 0}}handle(e){var t;switch(e.type){case"CREATE_CHART":this.addFigure(e.id,e.sheetId,e.position,e.size),this.addChart(e.id,e.definition);break;case"UPDATE_CHART":this.addChart(e.id,e.definition);break;case"DUPLICATE_SHEET":{const i=this.getters.getFigures(e.sheetId);for(const o of i)if("chart"===o.tag){const i=o.id.split(ee).pop(),n=`${e.sheetIdTo}${ee}${i}`,s=null===(t=this.charts[o.id])||void 0===t?void 0:t.copyForSheetId(e.sheetIdTo);s&&this.dispatch("CREATE_CHART",{id:n,position:{x:o.x,y:o.y},size:{width:o.width,height:o.height},definition:s.getDefinition(),sheetId:e.sheetIdTo})}break}case"DELETE_FIGURE":this.history.update("charts",e.id,void 0);break;case"DELETE_SHEET":for(let t of this.getChartIds(e.sheetId))this.history.update("charts",t,void 0)}}getContextCreationChart(e){var t;return null===(t=this.charts[e])||void 0===t?void 0:t.getContextCreation()}getChart(e){return this.charts[e]}getChartType(e){var t;const i=null===(t=this.charts[e])||void 0===t?void 0:t.type;if(!i)throw new Error("Chart not defined.");return i}isChartDefined(e){return e in this.charts&&void 0!==this.charts}getChartIds(e){return Object.entries(this.charts).filter((([,t])=>(null==t?void 0:t.sheetId)===e)).map((([e])=>e))}getChartDefinition(e){var t;const i=null===(t=this.charts[e])||void 0===t?void 0:t.getDefinition();if(!i)throw new Error(`There is no chart with the given figureId: ${e}`);return i}import(e){for(let t of e.sheets)if(t.figures)for(let e of t.figures)"chart"===e.tag&&(this.charts[e.id]=this.createChart(e.id,e.data,t.id))}export(e){var t;if(e.sheets)for(let i of e.sheets){const e=this.getters.getFigures(i.id),o=[];for(let i of e){const e=i;if(e&&"chart"===e.tag){const i=null===(t=this.charts[e.id])||void 0===t?void 0:t.getDefinition();i&&(e.data=i,o.push(e))}else o.push(e)}i.figures=o}}exportForExcel(e){var t;for(let i of e.sheets){const e=this.getters.getFigures(i.id),o=[];for(let i of e)if(i&&"chart"===i.tag){const e=null===(t=this.charts[i.id])||void 0===t?void 0:t.getDefinitionForExcel();e&&o.push({...i,data:e})}i.charts=o}}addFigure(e,t,i={x:0,y:0},o={width:536,height:335}){if(this.getters.getFigure(t,e))return;const n={id:e,x:i.x,y:i.y,width:o.width,height:o.height,tag:"chart"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:n})}addChart(e,t){const i=this.getters.getFigureSheetId(e);i&&this.history.update("charts",e,this.createChart(e,t,i))}checkChartDuplicate(e){return this.getters.getFigureSheetId(e.id)?84:0}checkChartExists(e){return this.getters.getFigureSheetId(e.id)?0:85}}function Uv(e){return""===e?NaN:Number(e)}Pv.getters=["isChartDefined","getChartDefinition","getChartType","getChartIds","getChart","getContextCreationChart"];class Vv extends Dv{constructor(){super(...arguments),this.cfRules={}}loopThroughRangesOfSheet(e,t){for(const i of this.cfRules[e])for(const o of i.ranges){const n=t(o);switch(n.changeType){case"REMOVE":let t=i.ranges.slice();t.splice(i.ranges.indexOf(o),1),t.length>=1?this.history.update("cfRules",e,this.cfRules[e].indexOf(i),"ranges",t):this.removeConditionalFormatting(i.id,e);break;case"RESIZE":case"MOVE":case"CHANGE":this.history.update("cfRules",e,this.cfRules[e].indexOf(i),"ranges",i.ranges.indexOf(o),n.range)}}}adaptRanges(e,t){if(t)this.loopThroughRangesOfSheet(t,e);else for(const t of Object.keys(this.cfRules))this.loopThroughRangesOfSheet(t,e)}allowDispatch(e){switch(e.type){case"ADD_CONDITIONAL_FORMAT":return this.checkValidations(e,this.checkCFRule,this.checkEmptyRange);case"MOVE_CONDITIONAL_FORMAT":return this.checkValidReordering(e.cfId,e.direction,e.sheetId)}return 0}handle(e){switch(e.type){case"CREATE_SHEET":this.cfRules[e.sheetId]=[];break;case"DUPLICATE_SHEET":this.history.update("cfRules",e.sheetIdTo,[]);for(const t of this.getConditionalFormats(e.sheetId))this.addConditionalFormatting(t,e.sheetIdTo);break;case"DELETE_SHEET":const t=Object.assign({},this.cfRules);delete t[e.sheetId],this.history.update("cfRules",t);break;case"ADD_CONDITIONAL_FORMAT":const i={...e.cf,ranges:e.ranges.map((t=>this.getters.getRangeString(this.getters.getRangeFromRangeData(t),e.sheetId)))};this.addConditionalFormatting(i,e.sheetId);break;case"REMOVE_CONDITIONAL_FORMAT":this.removeConditionalFormatting(e.id,e.sheetId);break;case"MOVE_CONDITIONAL_FORMAT":this.reorderConditionalFormatting(e.cfId,e.direction,e.sheetId)}}import(e){for(let t of e.sheets)this.cfRules[t.id]=t.conditionalFormats.map((e=>this.mapToConditionalFormatInternal(t.id,e)))}export(e){if(e.sheets)for(let t of e.sheets)this.cfRules[t.id]&&(t.conditionalFormats=this.cfRules[t.id].map((e=>this.mapToConditionalFormat(t.id,e))))}exportForExcel(e){this.export(e)}getConditionalFormats(e){var t;return(null===(t=this.cfRules[e])||void 0===t?void 0:t.map((t=>this.mapToConditionalFormat(e,t))))||[]}getRulesSelection(e,t){const i=new Set;return t.forEach((t=>{this.getRulesByZone(e,t).forEach((e=>{i.add(e)}))})),Array.from(i)}getRulesByZone(e,t){const i=new Set;for(let o=t.top;o<=t.bottom;o++)for(let n=t.left;n<=t.right;n++){this.getRulesByCell(e,n,o).forEach((e=>{i.add(e.id)}))}return i}getRulesByCell(e,t,i){const o=[];for(let n of this.cfRules[e])for(let e of n.ranges)Qi(t,i,e.zone)&&o.push(n);return new Set(o.map((t=>this.mapToConditionalFormat(e,t))))}mapToConditionalFormat(e,t){return{...t,ranges:t.ranges.map((t=>this.getters.getRangeString(t,e)))}}mapToConditionalFormatInternal(e,t){const i={...t,ranges:t.ranges.map((t=>this.getters.getRangeFromSheetXC(e,t)))};return i}addConditionalFormatting(e,t){const i=this.cfRules[t].slice(),o=i.findIndex((t=>t.id===e.id)),n=this.mapToConditionalFormatInternal(t,e);o>-1?i.splice(o,1,n):i.push(n),this.history.update("cfRules",t,i)}checkValidReordering(e,t,i){if(!this.cfRules[i])return 27;const o=this.cfRules[i].findIndex((t=>t.id===e));if(-1===o)return 71;const n="up"===t?o-1:o+1;return n<0||n>=this.cfRules[i].length?71:0}checkEmptyRange(e){return e.ranges.length?0:24}checkCFRule(e){const t=e.cf.rule;switch(t.type){case"CellIsRule":return this.checkValidations(t,this.checkOperatorArgsNumber(2,["Between","NotBetween"]),this.checkOperatorArgsNumber(1,["BeginsWith","ContainsText","EndsWith","GreaterThan","GreaterThanOrEqual","LessThan","LessThanOrEqual","NotContains"]),this.checkOperatorArgsNumber(0,["IsEmpty","IsNotEmpty"]));case"ColorScaleRule":return this.checkValidations(t,this.chainValidations(this.checkThresholds(this.checkFormulaCompilation)),this.chainValidations(this.checkThresholds(this.checkNaN),this.batchValidations(this.checkMinBiggerThanMax,this.checkMinBiggerThanMid,this.checkMidBiggerThanMax)));case"IconSetRule":return this.checkValidations(t,this.chainValidations(this.checkInflectionPoints(this.checkNaN),this.checkLowerBiggerThanUpper),this.chainValidations(this.checkInflectionPoints(this.checkFormulaCompilation)))}return 0}checkOperatorArgsNumber(e,t){if(e>2)throw new Error("Checking more than 2 arguments is currently not supported. Add the appropriate CommandResult if you want to.");return i=>{if(t.includes(i.operator)){const t=[],o=e=>void 0===e||""===e;return e>=1&&o(i.values[0])&&t.push(51),e>=2&&o(i.values[1])&&t.push(52),t.length?t:0}return 0}}checkNaN(e,t){if(["number","percentage","percentile"].includes(e.type)&&(""===e.value||isNaN(e.value)))switch(t){case"min":return 53;case"max":return 55;case"mid":return 54;case"upperInflectionPoint":return 56;case"lowerInflectionPoint":return 57}return 0}checkFormulaCompilation(e,t){if("formula"!==e.type)return 0;try{ff(e.value||"")}catch(e){switch(t){case"min":return 58;case"max":return 60;case"mid":return 59;case"upperInflectionPoint":return 61;case"lowerInflectionPoint":return 62}}return 0}checkThresholds(e){return this.batchValidations((t=>e(t.minimum,"min")),(t=>e(t.maximum,"max")),(t=>t.midpoint?e(t.midpoint,"mid"):0))}checkInflectionPoints(e){return this.batchValidations((t=>e(t.lowerInflectionPoint,"lowerInflectionPoint")),(t=>e(t.upperInflectionPoint,"upperInflectionPoint")))}checkLowerBiggerThanUpper(e){const t=e.lowerInflectionPoint.value,i=e.upperInflectionPoint.value;return["number","percentage","percentile"].includes(e.lowerInflectionPoint.type)&&e.lowerInflectionPoint.type===e.upperInflectionPoint.type&&Number(t)>Number(i)?48:0}checkMinBiggerThanMax(e){const t=e.minimum.value,i=e.maximum.value;return["number","percentage","percentile"].includes(e.minimum.type)&&e.minimum.type===e.maximum.type&&Uv(t)>=Uv(i)?47:0}checkMidBiggerThanMax(e){var t;const i=null===(t=e.midpoint)||void 0===t?void 0:t.value,o=e.maximum.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.midpoint.type===e.maximum.type&&Uv(i)>=Uv(o)?49:0}checkMinBiggerThanMid(e){var t;const i=e.minimum.value,o=null===(t=e.midpoint)||void 0===t?void 0:t.value;return e.midpoint&&["number","percentage","percentile"].includes(e.midpoint.type)&&e.minimum.type===e.midpoint.type&&Uv(i)>=Uv(o)?50:0}removeConditionalFormatting(e,t){const i=this.cfRules[t].findIndex((t=>t.id===e));if(-1!==i){const e=this.cfRules[t].slice();e.splice(i,1),this.history.update("cfRules",t,e)}}reorderConditionalFormatting(e,t,i){const o=this.cfRules[i].findIndex((t=>t.id===e)),n="up"===t?o-1:o+1;if(!(n<0||n>=this.cfRules[i].length)&&-1!==o&&-1!==n){const e=[...this.cfRules[i]],t=e[o];e[o]=e[n],e[n]=t,this.history.update("cfRules",i,e)}}}Vv.getters=["getConditionalFormats","getRulesSelection","getRulesByCell"];class zv extends Dv{constructor(){super(...arguments),this.figures={}}allowDispatch(e){switch(e.type){case"CREATE_FIGURE":return this.checkFigureDuplicate(e.figure.id);case"UPDATE_FIGURE":case"DELETE_FIGURE":return this.checkFigureExists(e.sheetId,e.id);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":this.figures[e.sheetId]={};break;case"DELETE_SHEET":this.deleteSheet(e.sheetId);break;case"CREATE_FIGURE":this.addFigure(e.figure,e.sheetId);break;case"UPDATE_FIGURE":const{type:t,sheetId:i,...o}=e,n=o;this.updateFigure(i,n);break;case"DELETE_FIGURE":this.removeFigure(e.id,e.sheetId)}}updateFigure(e,t){if("id"in t)for(const[i,o]of Object.entries(t))switch(i){case"x":case"y":void 0!==o&&this.history.update("figures",e,t.id,i,Math.max(o,0));break;case"width":case"height":void 0!==o&&this.history.update("figures",e,t.id,i,o)}}addFigure(e,t){this.history.update("figures",t,e.id,e)}deleteSheet(e){this.history.update("figures",e,void 0)}removeFigure(e,t){this.history.update("figures",t,e,void 0)}checkFigureExists(e,t){var i;return void 0===(null===(i=this.figures[e])||void 0===i?void 0:i[t])?70:0}checkFigureDuplicate(e){return Object.values(this.figures).find((t=>null==t?void 0:t[e]))?82:0}getFigures(e){return Object.values(this.figures[e]||{}).filter(it)}getFigure(e,t){var i;return null===(i=this.figures[e])||void 0===i?void 0:i[t]}getFigureSheetId(e){return Object.keys(this.figures).find((t=>{var i;return void 0!==(null===(i=this.figures[t])||void 0===i?void 0:i[e])}))}import(e){for(let t of e.sheets){const e={};t.figures.forEach((t=>{e[t.id]=t})),this.figures[t.id]=e}}export(e){for(const t of e.sheets)for(const e of this.getFigures(t.id)){const i=void 0;t.figures.push({...e,data:i})}}exportForExcel(e){this.export(e)}}zv.getters=["getFigures","getFigure","getFigureSheetId"];class Bv{constructor(e){this.filters=[],this.zone=e;const t=new Vi;this.id=t.uuidv4();for(const i of He(e.left,e.right+1)){const e={...this.zone,left:i,right:i};this.filters.push(new Hv(t.uuidv4(),e))}}get contentZone(){if(this.zone.bottom!==this.zone.top)return{...this.zone,top:this.zone.top+1}}getFilterId(e){var t;return null===(t=this.filters.find((t=>t.col===e)))||void 0===t?void 0:t.id}clone(){return new Bv(this.zone)}}class Hv{constructor(e,t){if(t.left!==t.right)throw new Error("Can only define a filter on a single column");this.id=e,this.zoneWithHeaders=t}get col(){return this.zoneWithHeaders.left}get filteredZone(){const e=this.zoneWithHeaders;if(e.bottom!==e.top)return{...e,top:e.top+1}}}class $v extends Dv{constructor(){super(...arguments),this.tables={}}allowDispatch(e){switch(e.type){case"CREATE_FILTER_TABLE":if(!uo(...e.target))return 81;const t=ji(...e.target),i=()=>this.getFilterTables(e.sheetId).some((e=>Ki(e.zone,t)))?78:0,o=()=>{const i=this.getters.getMergesInZone(e.sheetId,t);for(let e of i)if(Ki(t,e))return 80;return 0};return this.checkValidations(e,i,o);case"ADD_MERGE":for(let t of e.target)for(let i of this.getFilterTables(e.sheetId))if(Ki(i.zone,t))return 80}return 0}handle(e){switch(e.type){case"CREATE_SHEET":this.history.update("tables",e.sheetId,{});break;case"DELETE_SHEET":const t={...this.tables};delete t[e.sheetId],this.history.update("tables",t);break;case"DUPLICATE_SHEET":const i={};for(const t of Object.values(this.tables[e.sheetId]||{}))if(t){const e=_e(t);i[e.id]=e}this.history.update("tables",e.sheetIdTo,i);break;case"ADD_COLUMNS_ROWS":this.onAddColumnsRows(e);break;case"REMOVE_COLUMNS_ROWS":this.onDeleteColumnsRows(e);break;case"CREATE_FILTER_TABLE":{const t=ji(...e.target),i=this.createFilterTable(t);this.history.update("tables",e.sheetId,i.id,i);break}case"REMOVE_FILTER_TABLE":{const t={};for(const i of this.getFilterTables(e.sheetId))e.target.every((e=>!Xi(e,i.zone)))&&(t[i.id]=i);this.history.update("tables",e.sheetId,t);break}case"UPDATE_CELL":{const t=e.sheetId;for(let i of this.getFilterTables(t))this.canUpdateCellCmdExtendTable(e,i)&&this.extendTableDown(t,i);break}}}getFilters(e){return this.getFilterTables(e).map((e=>e.filters)).flat()}getFilterTables(e){return this.tables[e]?Object.values(this.tables[e]).filter(it):[]}getFilter(e){var t;return null===(t=this.getFilterTable(e))||void 0===t?void 0:t.filters.find((t=>t.col===e.col))}getFilterId(e){var t;return null===(t=this.getFilter(e))||void 0===t?void 0:t.id}getFilterTable({sheetId:e,col:t,row:i}){return this.getFilterTables(e).find((e=>Qi(t,i,e.zone)))}getFilterTablesInZone(e,t){return this.getFilterTables(e).filter((e=>Ji(e.zone,t)))}doesZonesContainFilter(e,t){for(const i of t)for(const t of this.getFilterTables(e))if(Xi(i,t.zone))return!0;return!1}onAddColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){const i=Wi(t.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),o=[];for(const i of t.filters){const t=Wi(i.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);o.push(new Hv(i.id,t))}if(o.length<io(i).numberOfCols){for(let e=i.left;e<=i.right;e++)o.find((t=>t.col===e))||o.push(new Hv(this.uuidGenerator.uuidv4(),{...i,left:e,right:e}));o.sort(((e,t)=>e.col-t.col))}this.history.update("tables",e.sheetId,t.id,"zone",i),this.history.update("tables",e.sheetId,t.id,"filters",o)}}onDeleteColumnsRows(e){for(const t of this.getFilterTables(e.sheetId)){if("ROW"===e.dimension&&e.elements.includes(t.zone.top)){const i={...this.tables[e.sheetId]};delete i[t.id],this.history.update("tables",e.sheetId,i);continue}const i=Zi(t.zone,"COL"===e.dimension?"left":"top",e.elements);if(i){if($i(i)!==$i(t.zone)){const o=[];for(const i of t.filters){const t=Zi(i.zoneWithHeaders,"COL"===e.dimension?"left":"top",e.elements);t&&o.push(new Hv(i.id,t))}this.history.update("tables",e.sheetId,t.id,"zone",i),this.history.update("tables",e.sheetId,t.id,"filters",o)}}else{const i={...this.tables[e.sheetId]};delete i[t.id],this.history.update("tables",e.sheetId,i)}}}createFilterTable(e){return new Bv(e)}extendTableDown(e,t){const i={...t.zone,bottom:t.zone.bottom+1};this.history.update("tables",e,t.id,"zone",i);for(let i=0;i<t.filters.length;i++){const o=t.filters[i],n={...o.zoneWithHeaders,bottom:o.zoneWithHeaders.bottom+1};this.history.update("tables",e,t.id,"filters",i,"zoneWithHeaders",n)}}canUpdateCellCmdExtendTable({content:e,sheetId:t,col:i,row:o},n){var s;if(!e)return;const r=n.zone;if(!(r.bottom+1===o&&i>=r.left&&i<=r.right))return!1;for(const e of He(r.left,r.right+1)){const i={sheetId:t,col:e,row:o};if(null===(s=this.getters.getCell(i))||void 0===s?void 0:s.content)return!1;if(this.getters.getFilter(i))return!1;if(this.getters.isInMerge(i))return!1}return!0}import(e){for(const t of e.sheets)for(const e of t.filterTables||[]){const i=this.createFilterTable(Bi(e.range));this.history.update("tables",t.id,i.id,i)}}export(e){for(const t of e.sheets)for(const e of this.getFilterTables(t.id))t.filterTables.push({range:$i(e.zone)})}exportForExcel(e){this.export(e)}}$v.getters=["doesZonesContainFilter","getFilter","getFilters","getFilterTable","getFilterTables","getFilterTablesInZone","getFilterId"];class Wv extends Dv{constructor(){super(...arguments),this.sizes={}}handle(e){var t,i;switch(e.type){case"CREATE_SHEET":{const t=this.computeSheetSizes(e.sheetId),i={COL:t.COL.map((e=>({manualSize:void 0,computedSize:rt(e)}))),ROW:t.ROW.map((e=>({manualSize:void 0,computedSize:rt(e)})))};this.history.update("sizes",e.sheetId,i);break}case"DUPLICATE_SHEET":for(const t of this.sizes[e.sheetId].ROW)t.computedSize();for(const t of this.sizes[e.sheetId].COL)t.computedSize();this.history.update("sizes",e.sheetIdTo,_e(this.sizes[e.sheetId]));break;case"DELETE_SHEET":const o={...this.sizes};delete o[e.sheetId],this.history.update("sizes",o);break;case"REMOVE_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];for(let i of[...e.elements].sort(((e,t)=>t-e)))t.splice(i,1);const i=Math.min(...e.elements);t=t.map(((t,o)=>"ROW"===e.dimension&&o>=i?{manualSize:t.manualSize,computedSize:rt((()=>this.getRowTallestCellSize(e.sheetId,o)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{let t=[...this.sizes[e.sheetId][e.dimension]];const i=lt(e.position,e.base),o=t[e.base],n=He(0,e.quantity).map((()=>({manualSize:o.manualSize,computedSize:rt(o.computedSize())})));t.splice(i,0,...n),t=t.map(((t,i)=>"ROW"===e.dimension&&i>e.base+e.quantity?{manualSize:t.manualSize,computedSize:rt((()=>this.getRowTallestCellSize(e.sheetId,i)))}:t)),this.history.update("sizes",e.sheetId,e.dimension,t);break}case"RESIZE_COLUMNS_ROWS":for(let t of e.elements)if("ROW"===e.dimension){const i=this.getRowTallestCellSize(e.sheetId,t);this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:rt(i)})}else this.history.update("sizes",e.sheetId,e.dimension,t,{manualSize:e.size||void 0,computedSize:rt(e.size||F)});break;case"UPDATE_CELL":const n=null===(i=null===(t=this.sizes[e.sheetId])||void 0===t?void 0:t.ROW)||void 0===i?void 0:i[e.row];if(n&&!n.manualSize){const{sheetId:t,row:i}=e;this.history.update("sizes",t,"ROW",i,"computedSize",rt((()=>this.getRowTallestCellSize(t,i))))}break;case"ADD_MERGE":case"REMOVE_MERGE":for(let t of e.target)for(let i of He(t.top,t.bottom+1)){const t=this.getRowTallestCellSize(e.sheetId,i);t!==this.getRowSize(e.sheetId,i)&&this.history.update("sizes",e.sheetId,"ROW",i,"computedSize",rt(t))}}}getColSize(e,t){return this.getHeaderSize(e,"COL",t)}getRowSize(e,t){return this.getHeaderSize(e,"ROW",t)}getHeaderSize(e,t,i){var o,n,s,r;return Math.round((null===(n=null===(o=this.sizes[e])||void 0===o?void 0:o[t][i])||void 0===n?void 0:n.manualSize)||(null===(r=null===(s=this.sizes[e])||void 0===s?void 0:s[t][i])||void 0===r?void 0:r.computedSize())||this.getDefaultHeaderSize(t))}computeSheetSizes(e){var t,i;const o={COL:[],ROW:[]};for(let t of He(0,this.getters.getNumberCols(e)))o.COL.push(this.getHeaderSize(e,"COL",t));for(let n of He(0,this.getters.getNumberRows(e))){let s=null===(i=null===(t=this.sizes[e])||void 0===t?void 0:t.ROW)||void 0===i?void 0:i[n].manualSize;if(!s){s=this.getRowTallestCellSize(e,n)}o.ROW.push(s)}return o}getDefaultHeaderSize(e){return"COL"===e?F:D}getCellHeight(e){const t=this.getters.getMerge(e);if(t&&t.bottom!==t.top)return D;return function(e){return e&&e.content?Le(Be(e.style),e.isFormula?1:e.content.split(he).length)+2*z:D}(this.getters.getCell(e))}getRowTallestCellSize(e,t){const i=this.getters.getRowCells(e,t);let o=0;for(let e=0;e<i.length;e++){const t=this.getters.getCellById(i[e]);if(!t)continue;const n=this.getters.getCellPosition(t.id),s=this.getCellHeight(n);s>o&&s>D&&(o=s)}return o<=D?D:o}import(e){for(let t of e.sheets){const e={COL:[],ROW:[]};for(let[i,o]of Object.entries(t.rows))o.size&&(e.ROW[i]=o.size);for(let[i,o]of Object.entries(t.cols))o.size&&(e.COL[i]=o.size);const i=this.computeSheetSizes(t.id);this.sizes[t.id]={COL:i.COL.map(((t,i)=>({manualSize:e.COL[i],computedSize:rt(t)}))),ROW:i.ROW.map(((t,i)=>({manualSize:e.ROW[i],computedSize:rt(t)})))}}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){var i,o;for(let n of e.sheets){void 0===n.rows&&(n.rows={});for(let e of He(0,this.getters.getNumberRows(n.id)))(t||(null===(i=this.sizes[n.id].ROW[e])||void 0===i?void 0:i.manualSize))&&(n.rows[e]={...n.rows[e],size:this.getRowSize(n.id,e)});void 0===n.cols&&(n.cols={});for(let e of He(0,this.getters.getNumberCols(n.id)))(t||(null===(o=this.sizes[n.id].COL[e])||void 0===o?void 0:o.manualSize))&&(n.cols[e]={...n.cols[e],size:this.getColSize(n.id,e)})}}}Wv.getters=["getRowSize","getColSize"];class Gv extends Dv{constructor(){super(...arguments),this.hiddenHeaders={}}allowDispatch(e){switch(e.type){case"HIDE_COLUMNS_ROWS":{if(!this.getters.tryGetSheet(e.sheetId))return 27;const t="COL"===e.dimension?this.getHiddenColsGroups(e.sheetId):this.getHiddenRowsGroups(e.sheetId),i="COL"===e.dimension?this.getters.getNumberCols(e.sheetId):this.getters.getNumberRows(e.sheetId);return new Set((t||[]).flat().concat(e.elements)).size>=i?66:Math.min(...e.elements)<0||Math.max(...e.elements)>i?86:0}case"REMOVE_COLUMNS_ROWS":return this.getters.tryGetSheet(e.sheetId)?this.checkElementsIncludeAllVisibleHeaders(e.sheetId,e.dimension,e.elements)?8:0:27}return 0}handle(e){switch(e.type){case"CREATE_SHEET":const t={COL:Array(this.getters.getNumberCols(e.sheetId)).fill(!1),ROW:Array(this.getters.getNumberRows(e.sheetId)).fill(!1)};this.history.update("hiddenHeaders",e.sheetId,t);break;case"DUPLICATE_SHEET":this.history.update("hiddenHeaders",e.sheetIdTo,_e(this.hiddenHeaders[e.sheetId]));break;case"DELETE_SHEET":this.history.update("hiddenHeaders",e.sheetId,void 0);break;case"REMOVE_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]];for(let i of[...e.elements].sort(((e,t)=>t-e)))t.splice(i,1);this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"ADD_COLUMNS_ROWS":{const t=[...this.hiddenHeaders[e.sheetId][e.dimension]],i=lt(e.position,e.base);t.splice(i,0,...Array(e.quantity).fill(!1)),this.history.update("hiddenHeaders",e.sheetId,e.dimension,t);break}case"HIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!0);break;case"UNHIDE_COLUMNS_ROWS":for(let t of e.elements)this.history.update("hiddenHeaders",e.sheetId,e.dimension,t,!1)}}checkElementsIncludeAllVisibleHeaders(e,t,i){return ht(i,this.getAllVisibleHeaders(e,t))}isRowHiddenByUser(e,t){return this.hiddenHeaders[e].ROW[t]}isColHiddenByUser(e,t){return this.hiddenHeaders[e].COL[t]}getHiddenColsGroups(e){const t=[[]],i=this.hiddenHeaders[e].COL;for(let e=0;e<i.length;e++){i[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}getHiddenRowsGroups(e){const t=[[]],i=this.hiddenHeaders[e].ROW;for(let e=0;e<i.length;e++){i[e]?t[t.length-1].push(e):0!==t[t.length-1].length&&t.push([])}return 0===t[t.length-1].length&&t.pop(),t}getAllVisibleHeaders(e,t){return He(0,this.hiddenHeaders[e][t].length).filter((i=>!this.hiddenHeaders[e][t][i]))}import(e){var t,i;for(let o of e.sheets){this.hiddenHeaders[o.id]={COL:[],ROW:[]};for(let e=0;e<o.rowNumber;e++)this.hiddenHeaders[o.id].ROW[e]=Boolean(null===(t=o.rows[e])||void 0===t?void 0:t.isHidden);for(let e=0;e<o.colNumber;e++)this.hiddenHeaders[o.id].COL[e]=Boolean(null===(i=o.cols[e])||void 0===i?void 0:i.isHidden)}}exportForExcel(e){this.exportData(e,!0)}export(e){this.exportData(e)}exportData(e,t=!1){for(let i of e.sheets){void 0===i.rows&&(i.rows={});for(let e=0;e<this.getters.getNumberRows(i.id);e++)(t||this.hiddenHeaders[i.id].ROW[e])&&(void 0===i.rows[e]&&(i.rows[e]={}),i.rows[e].isHidden=this.hiddenHeaders[i.id].ROW[e]);void 0===i.cols&&(i.cols={});for(let e=0;e<this.getters.getNumberCols(i.id);e++)(t||this.hiddenHeaders[i.id].COL[e])&&(void 0===i.cols[e]&&(i.cols[e]={}),i.cols[e].isHidden=this.hiddenHeaders[i.id].COL[e])}}}Gv.getters=["checkElementsIncludeAllVisibleHeaders","getHiddenColsGroups","getHiddenRowsGroups","isRowHiddenByUser","isColHiddenByUser"];class qv extends Dv{constructor(e){super(e),this.images={},this.syncedImages=new Set,this.fileStore=e.external.fileStore}allowDispatch(e){return"CREATE_IMAGE"===e.type&&this.getters.getFigure(e.sheetId,e.figureId)?28:0}handle(e){switch(e.type){case"CREATE_IMAGE":this.addFigure(e.figureId,e.sheetId,e.position,e.size),this.history.update("images",e.sheetId,e.figureId,e.definition),this.syncedImages.add(e.definition.path);break;case"DUPLICATE_SHEET":{const t=this.getters.getFigures(e.sheetId);for(const i of t)if("image"===i.tag){const t=i.id.split(ee).pop(),o=`${e.sheetIdTo}${ee}${t}`,n=this.getImage(i.id);if(n){const t={width:i.width,height:i.height};this.dispatch("CREATE_IMAGE",{sheetId:e.sheetIdTo,figureId:o,position:{x:i.x,y:i.y},size:t,definition:_e(n)})}}break}case"DELETE_FIGURE":this.history.update("images",e.sheetId,e.id,void 0);break;case"DELETE_SHEET":this.history.update("images",e.sheetId,void 0)}}garbageCollectExternalResources(){var e;const t=new Set(this.getAllImages().map((e=>e.path)));for(const i of this.syncedImages)t.has(i)||null===(e=this.fileStore)||void 0===e||e.delete(i)}getImage(e){for(const t of Object.values(this.images))if(t&&t[e])return t[e];throw new Error(`There is no image with the given figureId: ${e}`)}getImagePath(e){return this.getImage(e).path}getImageSize(e){return this.getImage(e).size}addFigure(e,t,i,o){const n={id:e,x:i.x,y:i.y,width:o.width,height:o.height,tag:"image"};this.dispatch("CREATE_FIGURE",{sheetId:t,figure:n})}import(e){for(const t of e.sheets){const e=(t.figures||[]).filter((e=>"image"===e.tag));for(const i of e)this.history.update("images",t.id,i.id,i.data),this.syncedImages.add(i.data.path)}}export(e){var t;for(const i of e.sheets){const e=i.figures.filter((e=>"image"===e.tag));for(const o of e)o.data=null===(t=this.images[i.id])||void 0===t?void 0:t[o.id]}}exportForExcel(e){for(const t of e.sheets){const e=this.getters.getFigures(t.id),i=[];for(const t of e)if("image"===(null==t?void 0:t.tag)){const e=this.getImage(t.id);e&&i.push({...t,data:_e(e)})}t.images=i}}getAllImages(){const e=[];for(const t in this.images)e.push(...Object.values(this.images[t]||{}).filter(it));return e}}qv.getters=["getImage","getImagePath","getImageSize"];class Zv extends Dv{constructor(){super(...arguments),this.nextId=1,this.merges={},this.mergeCellMap={}}allowDispatch(e){const t="force"in e&&!!e.force;switch(e.type){case"ADD_MERGE":return t?this.checkValidations(e,this.checkFrozenPanes):this.checkValidations(e,this.checkDestructiveMerge,this.checkOverlap,this.checkFrozenPanes);case"UPDATE_CELL":return this.checkMergedContentUpdate(e);case"REMOVE_MERGE":return this.checkMergeExists(e);default:return 0}}handle(e){switch(e.type){case"CREATE_SHEET":case"DELETE_SHEET":this.history.update("merges",e.sheetId,{}),this.history.update("mergeCellMap",e.sheetId,{});break;case"DUPLICATE_SHEET":const t=this.merges[e.sheetId];if(!t)break;for(const i of Object.values(t).filter(it))this.addMerge(e.sheetIdTo,i.zone);break;case"ADD_MERGE":for(const t of e.target)this.addMerge(e.sheetId,t);break;case"REMOVE_MERGE":for(const t of e.target)this.removeMerge(e.sheetId,t)}}adaptRanges(e,t){const i=t?[t]:Object.keys(this.merges);for(const t of i)this.applyRangeChangeOnSheet(t,e)}getMerges(e){return Object.keys(this.merges[e]||{}).map((t=>this.getMergeById(e,parseInt(t,10)))).filter(it)}getMerge({sheetId:e,col:t,row:i}){var o;const n=this.mergeCellMap[e],s=n?t in n&&(null===(o=n[t])||void 0===o?void 0:o[i]):void 0;return s?this.getMergeById(e,s):void 0}getMergesInZone(e,t){var i;const o=this.mergeCellMap[e];if(!o)return[];const n=new Set;for(const{col:e,row:s}of no(t)){const t=null===(i=o[e])||void 0===i?void 0:i[s];t&&n.add(t)}return Array.from(n).map((t=>this.getMergeById(e,t))).filter(it)}doesIntersectMerge(e,t){return no(t).some((({col:t,row:i})=>void 0!==this.getMerge({sheetId:e,col:t,row:i})))}doesColumnsHaveCommonMerges(e,t,i){const o=this.getters.getSheet(e);for(let n=0;n<this.getters.getNumberRows(e);n++)if(this.isInSameMerge(o.id,t,n,i,n))return!0;return!1}doesRowsHaveCommonMerges(e,t,i){const o=this.getters.getSheet(e);for(let n=0;n<=this.getters.getNumberCols(e);n++)if(this.isInSameMerge(o.id,n,t,n,i))return!0;return!1}expandZone(e,t){let{left:i,right:o,top:n,bottom:s}=t,r={left:i,right:o,top:n,bottom:s};for(let t in this.merges[e]){const i=this.getMergeById(e,parseInt(t));i&&Ki(i,r)&&(r=ji(i,r))}return Yi(r,t)?r:this.expandZone(e,r)}isInSameMerge(e,t,i,o,n){const s=this.getMerge({sheetId:e,col:t,row:i}),r=this.getMerge({sheetId:e,col:o,row:n});return!(!s||!r)&&Yi(s,r)}isInMerge({sheetId:e,col:t,row:i}){var o;const n=this.mergeCellMap[e];return!!n&&(t in n&&Boolean(null===(o=n[t])||void 0===o?void 0:o[i]))}getMainCellPosition(e){if(!this.isInMerge(e))return e;const t=this.getMerge(e).topLeft;return{sheetId:e.sheetId,col:t.col,row:t.row}}getBottomLeftCell(e){if(!this.isInMerge(e))return e;const{bottom:t,left:i}=this.getMerge(e);return{sheetId:e.sheetId,col:i,row:t}}isMergeHidden(e,t){const i=this.getters.getHiddenColsGroups(e),o=this.getters.getHiddenRowsGroups(e);for(let e of i)if(t.left>=e[0]&&t.right<=e[e.length-1])return!0;for(let e of o)if(t.top>=e[0]&&t.bottom<=e[e.length-1])return!0;return!1}isSingleCellOrMerge(e,t){const i=this.getMerge({sheetId:e,col:t.left,row:t.top});if(i)return Yi(t,i);const{numberOfCols:o,numberOfRows:n}=io(t);return 1===o&&1===n}isMergeDestructive(e,t){let{left:i,right:o,top:n,bottom:s}=t;o=ke(o,0,this.getters.getNumberCols(e)-1),s=ke(s,0,this.getters.getNumberRows(e)-1);for(let t=n;t<=s;t++)for(let s=i;s<=o;s++)if(s!==i||t!==n){const i=this.getters.getCell({sheetId:e,col:s,row:t});if(i&&""!==i.content)return!0}return!1}getMergeById(e,t){var i;const o=null===(i=this.merges[e])||void 0===i?void 0:i[t];return void 0!==o?Xv(t,o):void 0}checkDestructiveMerge({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;return t.some((t=>this.isMergeDestructive(e,t)))?3:0}checkOverlap({target:e}){for(const t of e)for(const i of e)if(t!==i&&Ki(t,i))return 65;return 0}checkFrozenPanes({sheetId:e,target:t}){if(!this.getters.tryGetSheet(e))return 0;const{xSplit:i,ySplit:o}=this.getters.getPaneDivisions(e);for(const e of t)if(e.left<i&&e.right>=i||e.top<o&&e.bottom>=o)return 75;return 0}checkMergedContentUpdate(e){const{col:t,row:i,content:o}=e;if(void 0===o)return 0;const{col:n,row:s}=this.getMainCellPosition(e);return n===t&&s===i?0:4}checkMergeExists(e){const{sheetId:t,target:i}=e;for(const e of i){const{left:i,top:o}=e,n=this.getMerge({sheetId:t,col:i,row:o});if(void 0===n||!Yi(e,n))return 5}return 0}addMerge(e,t){let{left:i,right:o,top:n,bottom:s}=t;o=ke(o,0,this.getters.getNumberCols(e)-1),s=ke(s,0,this.getters.getNumberRows(e)-1);if(qt(i,n)===qt(o,s))return;const r=this.getters.getCell({sheetId:e,col:i,row:n});let a=this.nextId++;this.history.update("merges",e,a,this.getters.getRangeFromSheetXC(e,$i({left:i,top:n,right:o,bottom:s})));let l=new Set;for(let t=n;t<=s;t++)for(let s=i;s<=o;s++){s===i&&t===n||this.dispatch("UPDATE_CELL",{sheetId:e,col:s,row:t,style:r?r.style:null,content:""});const o=this.getMerge({sheetId:e,col:s,row:t});o&&l.add(o.id),this.history.update("mergeCellMap",e,s,t,a)}for(let t of l){const{top:i,bottom:o,left:n,right:s}=this.getMergeById(e,t);for(let t=i;t<=o;t++)for(let i=n;i<=s;i++){const o={sheetId:e,col:i,row:t},n=this.getMerge(o);n&&n.id===a||(this.history.update("mergeCellMap",e,i,t,void 0),this.dispatch("CLEAR_CELL",o))}this.history.update("merges",e,t,void 0)}}removeMerge(e,t){const{left:i,top:o,bottom:n,right:s}=t,r=this.getMerge({sheetId:e,col:i,row:o});if(void 0!==r&&Yi(t,r)){this.history.update("merges",e,r.id,void 0);for(let t=o;t<=n;t++)for(let o=i;o<=s;o++)this.history.update("mergeCellMap",e,o,t,void 0)}}applyRangeChangeOnSheet(e,t){const i=Object.entries(this.merges[e]||{});for(const[o,n]of i)if(n){const i=n.zone,s=t(n);switch(s.changeType){case"NONE":break;case"REMOVE":this.removeMerge(e,i);break;default:const{numberOfCols:t,numberOfRows:n}=io(s.range.zone);1===t&&1===n?this.removeMerge(e,i):this.history.update("merges",e,parseInt(o,10),s.range)}}this.history.update("mergeCellMap",e,{});for(const t of this.getMerges(e))for(const{col:i,row:o}of no(t))this.history.update("mergeCellMap",e,i,o,t.id)}import(e){const t=e.sheets||[];for(let e of t)this.history.update("merges",e.id,{}),this.history.update("mergeCellMap",e.id,{}),e.merges&&this.importMerges(e.id,e.merges)}importMerges(e,t){for(let i of t)this.addMerge(e,Bi(i))}export(e){for(let t of e.sheets){const e=this.merges[t.id];e&&t.merges.push(...jv(e))}}exportForExcel(e){this.export(e)}}function jv(e){return Object.entries(e).map((([e,t])=>t?Xv(parseInt(e,10),t):void 0)).filter(it).map((e=>qt(e.left,e.top)+":"+qt(e.right,e.bottom)))}function Xv(e,t){return{...t.zone,topLeft:{col:t.zone.left,row:t.zone.top},id:e}}Zv.getters=["isInMerge","isInSameMerge","isMergeHidden","getMainCellPosition","getBottomLeftCell","expandZone","doesIntersectMerge","doesColumnsHaveCommonMerges","doesRowsHaveCommonMerges","getMerges","getMerge","getMergesInZone","isSingleCellOrMerge"];class Yv{constructor(e){this.providers=[],this.getters=e}allowDispatch(e){return"MOVE_RANGES"===e.type?1===e.target.length?0:26:0}beforeHandle(e){}handle(e){switch(e.type){case"REMOVE_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",i="COL"===e.dimension?"right":"bottom",o="COL"===e.dimension?"columns":"rows";const n=[...e.elements];n.sort(((e,t)=>t-e));const s=$e(n);this.executeOnAllRanges((n=>{if(n.sheetId!==e.sheetId)return{changeType:"NONE"};let r=n,a="NONE";for(let e of s){const s=Math.min(...e),l=Math.max(...e);if(n.zone[t]<=s&&s<=n.zone[i]){const e=Math.min(n.zone[i],l)-s+1;a="RESIZE",r=this.createAdaptedRange(r,o,a,-e)}else if(n.zone[t]>=s&&n.zone[i]<=l)a="REMOVE",r=n.clone({...this.getInvalidRange()});else if(n.zone[t]<=l&&n.zone[i]>=l){const e=l-n.zone[t]+1;a="RESIZE",r=this.createAdaptedRange(r,o,a,-e),r=this.createAdaptedRange(r,o,"MOVE",-(n.zone[t]-s))}else s<n.zone[t]&&(a="MOVE",r=this.createAdaptedRange(r,o,a,-(l-s+1)))}return"NONE"!==a?{changeType:a,range:r}:{changeType:"NONE"}}),e.sheetId);break}case"ADD_COLUMNS_ROWS":{let t="COL"===e.dimension?"left":"top",i="COL"===e.dimension?"right":"bottom",o="COL"===e.dimension?"columns":"rows";this.executeOnAllRanges((n=>{if(n.sheetId!==e.sheetId)return{changeType:"NONE"};if("after"===e.position){if(n.zone[t]<=e.base&&e.base<n.zone[i])return{changeType:"RESIZE",range:this.createAdaptedRange(n,o,"RESIZE",e.quantity)};if(e.base<n.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(n,o,"MOVE",e.quantity)}}else{if(n.zone[t]<e.base&&e.base<=n.zone[i])return{changeType:"RESIZE",range:this.createAdaptedRange(n,o,"RESIZE",e.quantity)};if(e.base<=n.zone[t])return{changeType:"MOVE",range:this.createAdaptedRange(n,o,"MOVE",e.quantity)}}return{changeType:"NONE"}}),e.sheetId);break}case"DELETE_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId!==e.sheetId)return{changeType:"NONE"};const i=this.getters.getSheetName(e.sheetId);return{changeType:"REMOVE",range:t=t.clone({...this.getInvalidRange(),invalidSheetName:i})}}),e.sheetId);break;case"RENAME_SHEET":this.executeOnAllRanges((t=>{if(t.sheetId===e.sheetId)return{changeType:"CHANGE",range:t};if(e.name&&t.invalidSheetName===e.name){const i=void 0,o=e.sheetId;return{changeType:"CHANGE",range:t.clone({sheetId:o,invalidSheetName:i})}}return{changeType:"NONE"}}));break;case"MOVE_RANGES":{const t=e.target[0];this.executeOnAllRanges((i=>{if(i.sheetId!==e.sheetId||!Ji(i.zone,t))return{changeType:"NONE"};const o=e.targetSheetId,n=e.col-t.left,s=e.row-t.top,r=this.createAdaptedRange(i,"both","MOVE",[n,s]),a=e.sheetId!==o||r.prefixSheet;return{changeType:"MOVE",range:r.clone({sheetId:o,prefixSheet:a})}}));break}}}finalize(){}verifyRangeRemoved(e){return t=>{const i=e(t);return"NONE"===i.changeType||Hi(i.range.zone)?i:{range:i.range,changeType:"REMOVE"}}}createAdaptedRange(e,t,i,o){const n=so(e.unboundedZone,t,i,o);return e.clone({zone:n})}executeOnAllRanges(e,t){const i=this.verifyRangeRemoved(e);for(const e of this.providers)e(i,t)}addRangeProvider(e){this.providers.push(e)}createAdaptedRanges(e,t,i,o){const n=e.map((e=>Di.fromRange(e,this.getters)));return n.map((e=>{if(!Hi(e.zone))return e;const n=e.prefixSheet?e.sheetId:o,s={...e.unboundedZone,left:e.isFullRow&&!e.unboundedZone.hasHeader?e.unboundedZone.left:e.unboundedZone.left+(e.parts[0].colFixed?0:t),right:e.isFullRow?e.unboundedZone.right:e.unboundedZone.right+((e.parts[1]||e.parts[0]).colFixed?0:t),top:e.isFullCol&&!e.unboundedZone.hasHeader?e.unboundedZone.top:e.unboundedZone.top+(e.parts[0].rowFixed?0:i),bottom:e.isFullCol?e.unboundedZone.bottom:e.unboundedZone.bottom+((e.parts[1]||e.parts[0]).rowFixed?0:i)};return e.clone({sheetId:n,zone:s}).orderZone()}))}getRangeFromSheetXC(e,t){if(!Lt.test(t))return new Di({sheetId:"",zone:{left:-1,top:-1,right:-1,bottom:-1},parts:[],invalidXc:t,prefixSheet:!1},this.getters.getSheetSize);let i,o=t,n=!1;t.includes("!")&&(({xc:o,sheetName:i}=Ht(t)),i&&(n=!0));const s=zi(o),r=Di.getRangeParts(o,s),a=i&&!this.getters.getSheetIdByName(i)?i:void 0,l=this.getters.getSheetIdByName(i)||e;return new Di({prefixSheet:n,zone:s,sheetId:l,invalidSheetName:a,parts:r},this.getters.getSheetSize).orderZone()}getSelectionRangeString(e,t){const i=Di.fromRange(e,this.getters),o=this.getters.expandZone(i.sheetId,i.zone),n=i.clone({zone:{...o,bottom:i.isFullCol?void 0:o.bottom,right:i.isFullRow?void 0:o.right}});return this.getRangeString(n,t)}getRangeString(e,t){if(!e)return K;if(e.invalidXc)return e.invalidXc;if(e.zone.bottom-e.zone.top<0||e.zone.right-e.zone.left<0)return K;if(e.zone.left<0||e.zone.top<0)return K;const i=Di.fromRange(e,this.getters);let o=i.sheetId!==t||i.invalidSheetName||i.prefixSheet,n="";if(o&&(n=i.invalidSheetName?i.invalidSheetName:De(this.getters.getSheetName(i.sheetId))),o&&!n)return K;let s=this.getRangePartString(i,0);return i.parts&&2===i.parts.length&&(i.zone.top!==i.zone.bottom||i.zone.left!==i.zone.right||i.parts[0].rowFixed||i.parts[0].colFixed||i.parts[1].rowFixed||i.parts[1].colFixed)&&(s+=":",s+=this.getRangePartString(i,1)),`${o?n+"!":""}${s}`}getRangeDataFromXc(e,t){return this.getters.getRangeFromSheetXC(e,t).rangeData}getRangeDataFromZone(e,t){return{_sheetId:e,_zone:t}}getRangeFromRangeData(e){const t={prefixSheet:!1,zone:e._zone,sheetId:e._sheetId,invalidSheetName:void 0,parts:[{colFixed:!1,rowFixed:!1},{colFixed:!1,rowFixed:!1}]};return new Di(t,this.getters.getSheetSize)}getRangePartString(e,t){const i=e.parts&&e.parts[t].colFixed?"$":"",o=$t(0===t?e.zone.left:e.zone.right),n=e.parts&&e.parts[t].rowFixed?"$":"",s=String(0===t?e.zone.top+1:e.zone.bottom+1);let r="";return r=e.isFullCol?0===t&&e.unboundedZone.hasHeader?i+o+n+s:i+o:e.isFullRow?0===t&&e.unboundedZone.hasHeader?i+o+n+s:n+s:i+o+n+s,r}getInvalidRange(){return{parts:[],prefixSheet:!1,zone:{left:-1,top:-1,right:-1,bottom:-1},sheetId:"",invalidXc:K}}}Yv.getters=["getRangeString","getSelectionRangeString","getRangeFromSheetXC","createAdaptedRanges","getRangeDataFromXc","getRangeDataFromZone","getRangeFromRangeData"];class Kv extends Dv{constructor(){super(...arguments),this.sheetIdsMapName={},this.orderedSheetIds=[],this.sheets={},this.cellPosition={}}allowDispatch(e){const t=this.chainValidations(this.checkSheetExists,this.checkZones)(e);if(0!==t)return t;switch(e.type){case"HIDE_SHEET":return 1===this.getVisibleSheetIds().length?9:0;case"CREATE_SHEET":return this.checkValidations(e,this.checkSheetName,this.checkSheetPosition);case"MOVE_SHEET":try{const t=this.orderedSheetIds.findIndex((t=>t===e.sheetId));return this.findIndexOfTargetSheet(t,e.delta),0}catch(e){return 14}case"RENAME_SHEET":return this.isRenameAllowed(e);case"DELETE_SHEET":return this.orderedSheetIds.length>1?0:9;case"ADD_COLUMNS_ROWS":const t="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return e.base<0||e.base>=t?86:e.quantity<=0?87:0;case"REMOVE_COLUMNS_ROWS":{const t="COL"===e.dimension?this.getNumberCols(e.sheetId):this.getNumberRows(e.sheetId);return Math.min(...e.elements)<0||Math.max(...e.elements)>t?86:this.checkElementsIncludeAllNonFrozenHeaders(e.sheetId,e.dimension,e.elements)?8:0}case"FREEZE_ROWS":return this.checkValidations(e,this.checkRowFreezeQuantity,this.checkRowFreezeOverlapMerge);case"FREEZE_COLUMNS":return this.checkValidations(e,this.checkColFreezeQuantity,this.checkColFreezeOverlapMerge);default:return 0}}handle(e){switch(e.type){case"SET_GRID_LINES_VISIBILITY":this.setGridLinesVisibility(e.sheetId,e.areGridLinesVisible);break;case"DELETE_CONTENT":this.clearZones(e.sheetId,e.target);break;case"CREATE_SHEET":const t=this.createSheet(e.sheetId,e.name||this.getNextSheetName(),e.cols||26,e.rows||100,e.position);this.history.update("sheetIdsMapName",t.name,t.id);break;case"MOVE_SHEET":this.moveSheet(e.sheetId,e.delta);break;case"RENAME_SHEET":this.renameSheet(this.sheets[e.sheetId],e.name);break;case"HIDE_SHEET":this.hideSheet(e.sheetId);break;case"SHOW_SHEET":this.showSheet(e.sheetId);break;case"DUPLICATE_SHEET":this.duplicateSheet(e.sheetId,e.sheetIdTo);break;case"DELETE_SHEET":this.deleteSheet(this.sheets[e.sheetId]);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.removeColumns(this.sheets[e.sheetId],[...e.elements]):this.removeRows(this.sheets[e.sheetId],[...e.elements]);break;case"ADD_COLUMNS_ROWS":"COL"===e.dimension?this.addColumns(this.sheets[e.sheetId],e.base,e.position,e.quantity):this.addRows(this.sheets[e.sheetId],e.base,e.position,e.quantity);break;case"UPDATE_CELL_POSITION":this.updateCellPosition(e);break;case"FREEZE_COLUMNS":this.setPaneDivisions(e.sheetId,e.quantity,"COL");break;case"FREEZE_ROWS":this.setPaneDivisions(e.sheetId,e.quantity,"ROW");break;case"UNFREEZE_ROWS":this.setPaneDivisions(e.sheetId,0,"ROW");break;case"UNFREEZE_COLUMNS":this.setPaneDivisions(e.sheetId,0,"COL");break;case"UNFREEZE_COLUMNS_ROWS":this.setPaneDivisions(e.sheetId,0,"COL"),this.setPaneDivisions(e.sheetId,0,"ROW")}}import(e){var t,i;for(let t of e.sheets)this.sheetIdsMapName[t.name]=t.id;for(let o of e.sheets){const e=o.name||n("Sheet")+(Object.keys(this.sheets).length+1),{colNumber:s,rowNumber:r}=this.getImportedSheetSize(o),a={id:o.id,name:e,numberOfCols:s,rows:Ui(r),areGridLinesVisible:void 0===o.areGridLinesVisible||o.areGridLinesVisible,isVisible:o.isVisible,panes:{xSplit:(null===(t=o.panes)||void 0===t?void 0:t.xSplit)||0,ySplit:(null===(i=o.panes)||void 0===i?void 0:i.ySplit)||0}};this.orderedSheetIds.push(a.id),this.sheets[a.id]=a}}exportSheets(e){e.sheets=this.orderedSheetIds.filter(it).map((e=>{const t=this.sheets[e],i={id:t.id,name:t.name,colNumber:t.numberOfCols,rowNumber:this.getters.getNumberRows(t.id),rows:{},cols:{},merges:[],cells:{},conditionalFormats:[],figures:[],filterTables:[],areGridLinesVisible:void 0===t.areGridLinesVisible||t.areGridLinesVisible,isVisible:t.isVisible};return(t.panes.xSplit||t.panes.ySplit)&&(i.panes=t.panes),i}))}export(e){this.exportSheets(e)}exportForExcel(e){this.exportSheets(e)}getGridLinesVisibility(e){return this.getSheet(e).areGridLinesVisible}tryGetSheet(e){return this.sheets[e]}getSheet(e){const t=this.sheets[e];if(!t)throw new Error(`Sheet ${e} not found.`);return t}isSheetVisible(e){return this.getSheet(e).isVisible}getSheetName(e){return this.getSheet(e).name}tryGetSheetName(e){var t;return null===(t=this.tryGetSheet(e))||void 0===t?void 0:t.name}getSheetIdByName(e){if(e){const t=Fe(e);for(const e in this.sheetIdsMapName)if(e.toUpperCase()===t.toUpperCase())return this.sheetIdsMapName[e]}}getSheetIds(){return this.orderedSheetIds}getVisibleSheetIds(){return this.orderedSheetIds.filter(this.isSheetVisible.bind(this))}getEvaluationSheets(){return this.sheets}doesHeaderExist(e,t,i){return"COL"===t?i>=0&&i<this.getNumberCols(e):i>=0&&i<this.getNumberRows(e)}getRow(e,t){const i=this.getSheet(e).rows[t];if(!i)throw new Error(`Row ${i} not found.`);return i}getCell({sheetId:e,col:t,row:i}){var o;const n=this.tryGetSheet(e),s=null===(o=null==n?void 0:n.rows[i])||void 0===o?void 0:o.cells[t];if(void 0!==s)return this.getters.getCellById(s)}getColsZone(e,t,i){return{top:0,bottom:this.getNumberRows(e)-1,left:t,right:i}}getRowCells(e,t){var i;return Object.values(null===(i=this.getSheet(e).rows[t])||void 0===i?void 0:i.cells).filter(it)}getRowsZone(e,t,i){return{top:t,bottom:i,left:0,right:this.getSheet(e).numberOfCols-1}}getCellPosition(e){const t=this.cellPosition[e];if(!t)throw new Error(`asking for a cell position that doesn't exist, cell id: ${e}`);return t}getNumberCols(e){return this.getSheet(e).numberOfCols}getNumberRows(e){return this.getSheet(e).rows.length}getNumberHeaders(e,t){return"COL"===t?this.getNumberCols(e):this.getNumberRows(e)}getNextSheetName(e="Sheet"){let t=1;const i=this.orderedSheetIds.map(this.getSheetName.bind(this));let o=`${e}${t}`;for(;i.includes(o);)o=`${e}${t}`,t++;return o}getSheetSize(e){return{numberOfRows:this.getNumberRows(e),numberOfCols:this.getNumberCols(e)}}getSheetZone(e){return{top:0,left:0,bottom:this.getNumberRows(e)-1,right:this.getNumberCols(e)-1}}getPaneDivisions(e){return this.getSheet(e).panes}setPaneDivisions(e,t,i){const o={...this.getPaneDivisions(e)};"COL"===i?o.xSplit=t:"ROW"===i&&(o.ySplit=t),this.history.update("sheets",e,"panes",o)}checkElementsIncludeAllNonFrozenHeaders(e,t,i){const o=this.getters.getPaneDivisions(e),n="ROW"===t?o.ySplit:o.xSplit,s=this.getters.getNumberHeaders(e,t);if(!n)return!1;return ht(i,He(n,s))}isEmpty(e,t){return no(t).map((({col:t,row:i})=>this.getCell({sheetId:e,col:t,row:i}))).every((e=>!e||""===e.content))}updateCellPosition(e){const{sheetId:t,cellId:i,col:o,row:n}=e;i?this.setNewPosition(i,t,o,n):this.clearPosition(t,o,n)}setNewPosition(e,t,i,o){const n=this.cellPosition[e];n&&this.clearPosition(t,n.col,n.row),this.history.update("cellPosition",e,{row:o,col:i,sheetId:t}),this.history.update("sheets",t,"rows",o,"cells",i,e)}clearPosition(e,t,i){var o;const n=null===(o=this.sheets[e])||void 0===o?void 0:o.rows[i].cells[t];n&&(this.history.update("cellPosition",n,void 0),this.history.update("sheets",e,"rows",i,"cells",t,void 0))}setGridLinesVisibility(e,t){this.history.update("sheets",e,"areGridLinesVisible",t)}clearZones(e,t){for(let i of t)for(let t=i.left;t<=i.right;t++)for(let o=i.top;o<=i.bottom;o++){this.sheets[e].rows[o].cells[t]&&this.dispatch("UPDATE_CELL",{sheetId:e,content:"",col:t,row:o})}}createSheet(e,t,i,o,n){const s={id:e,name:t,numberOfCols:i,rows:Ui(o),areGridLinesVisible:!0,isVisible:!0,panes:{xSplit:0,ySplit:0}},r=this.orderedSheetIds.slice();r.splice(n,0,s.id);const a=this.sheets;return this.history.update("orderedSheetIds",r),this.history.update("sheets",Object.assign({},a,{[s.id]:s})),s}moveSheet(e,t){const i=this.orderedSheetIds.slice(),o=i.findIndex((t=>t===e)),n=i.splice(o,1);let s=this.findIndexOfTargetSheet(o,t);i.splice(s,0,n[0]),this.history.update("orderedSheetIds",i)}findIndexOfTargetSheet(e,t){for(;0!=t&&0<=e&&e<=this.orderedSheetIds.length;)t>0?(e++,this.isSheetVisible(this.orderedSheetIds[e])&&t--):t<0&&(e--,this.isSheetVisible(this.orderedSheetIds[e])&&t++);if(0===t)return e;throw new Error(s("There is not enough visible sheets"))}checkSheetName(e){const{orderedSheetIds:t,sheets:i}=this,o=e.name&&e.name.trim().toLowerCase();return t.find((e=>{var t;return(null===(t=i[e])||void 0===t?void 0:t.name.toLowerCase())===o}))?11:re.test(o)?13:0}checkSheetPosition(e){const{orderedSheetIds:t}=this;return e.position>t.length||e.position<0?15:0}checkRowFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberRows(e.sheetId)?0:74}checkColFreezeQuantity(e){return e.quantity>=1&&e.quantity<this.getNumberCols(e.sheetId)?0:74}checkRowFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let i of t)if(i.top<e.quantity&&e.quantity<=i.bottom)return 65;return 0}checkColFreezeOverlapMerge(e){const t=this.getters.getMerges(e.sheetId);for(let i of t)if(i.left<e.quantity&&e.quantity<=i.right)return 65;return 0}isRenameAllowed(e){return e.name&&e.name.trim().toLowerCase()?this.checkSheetName(e):10}renameSheet(e,t){const i=e.name;this.history.update("sheets",e.id,"name",t.trim());const o=Object.assign({},this.sheetIdsMapName);o[t]=e.id,delete o[i],this.history.update("sheetIdsMapName",o)}hideSheet(e){this.history.update("sheets",e,"isVisible",!1)}showSheet(e){this.history.update("sheets",e,"isVisible",!0)}duplicateSheet(e,t){const i=this.getSheet(e),o=this.getDuplicateSheetName(i.name),n=_e(i);n.id=t,n.name=o;for(let e=0;e<=n.numberOfCols;e++)for(let t=0;t<=n.rows.length;t++)n.rows[t]&&(n.rows[t].cells[e]=void 0);const s=this.orderedSheetIds.slice(),r=s.indexOf(e);s.splice(r+1,0,n.id),this.history.update("orderedSheetIds",s),this.history.update("sheets",Object.assign({},this.sheets,{[n.id]:n}));for(const t of Object.values(this.getters.getCells(e))){const{col:e,row:i}=this.getCellPosition(t.id);this.dispatch("UPDATE_CELL",{sheetId:n.id,col:e,row:i,content:t.content,format:t.format,style:t.style})}const a=Object.assign({},this.sheetIdsMapName);a[n.name]=n.id,this.history.update("sheetIdsMapName",a)}getDuplicateSheetName(e){let t=1;const i=this.orderedSheetIds.map(this.getSheetName.bind(this)),o=s("Copy of %s",e);let n=o.toString();for(;i.includes(n);)n=`${o} (${t})`,t++;return n}deleteSheet(e){const t=e.name,i=Object.assign({},this.sheets);delete i[e.id],this.history.update("sheets",i);const o=this.orderedSheetIds.slice(),n=o.indexOf(e.id);o.splice(n,1),this.history.update("orderedSheetIds",o);const s=Object.assign({},this.sheetIdsMapName);delete s[t],this.history.update("sheetIdsMapName",s)}removeColumns(e,t){t.sort(((e,t)=>t-e));for(let i of t)this.moveCellOnColumnsDeletion(e,i);const i=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",i-t.length);const o=t.filter((t=>t<e.panes.xSplit)).length;o&&this.setPaneDivisions(e.id,e.panes.xSplit-o,"COL")}removeRows(e,t){t.sort(((e,t)=>t-e));for(let i of $e(t)){const t=i[i.length-1],o=i[0];this.moveCellOnRowsDeletion(e,t,o),this.updateRowsStructureOnDeletion(e,t,o)}const i=t.filter((t=>t<e.panes.ySplit)).length;i&&this.setPaneDivisions(e.id,e.panes.ySplit-i,"ROW")}addColumns(e,t,i,o){const n="before"===i?t:t+1;this.moveCellsOnAddition(e,n,o,"columns");const s=this.sheets[e.id].numberOfCols;this.history.update("sheets",e.id,"numberOfCols",s+o),n<e.panes.xSplit&&this.setPaneDivisions(e.id,e.panes.xSplit+o,"COL")}addRows(e,t,i,o){const n="before"===i?t:t+1;this.addEmptyRows(e,o),this.moveCellsOnAddition(e,n,o,"rows"),n<e.panes.ySplit&&this.setPaneDivisions(e.id,e.panes.ySplit+o,"ROW")}moveCellOnColumnsDeletion(e,t){for(let i=0;i<e.rows.length;i++){const o=e.rows[i];for(let n in o.cells){const s=Number(n),r=o.cells[n];r&&(s===t&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:s,row:i}),s>t&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:r,col:s-1,row:i}))}}}moveCellsOnAddition(e,t,i,o){const n=[];for(let s=0;s<e.rows.length;s++){const r=e.rows[s];if("rows"!==o||s>=t)for(let a in r.cells){const l=Number(a),c=r.cells[a];c&&("rows"===o||l>=t)&&n.push({type:"UPDATE_CELL_POSITION",sheetId:e.id,cellId:c,col:l+("columns"===o?i:0),row:s+("rows"===o?i:0)})}}for(let e of n.reverse())this.dispatch(e.type,e)}moveCellOnRowsDeletion(e,t,i){const o=i-t+1;for(let n=0;n<e.rows.length;n++){const s=e.rows[n];if(n>=t&&n<=i)for(let t in s.cells){const i=Number(t);s.cells[t]&&this.dispatch("CLEAR_CELL",{sheetId:e.id,col:i,row:n})}if(n>i)for(let t in s.cells){const i=Number(t),r=s.cells[t];r&&this.dispatch("UPDATE_CELL_POSITION",{sheetId:e.id,cellId:r,col:i,row:n-o})}}}updateRowsStructureOnDeletion(e,t,i){const o=[],n=e.rows.map((e=>e.cells)).reverse();for(let s in e.rows){const e=Number(s);e>=t&&e<=i||o.push({cells:n.pop()})}this.history.update("sheets",e.id,"rows",o)}addEmptyRows(e,t){const i=e.rows.slice();for(let e=0;e<t;e++)i.push({cells:{}});this.history.update("sheets",e.id,"rows",i)}getImportedSheetSize(e){const t=Object.keys(e.cells).map(Gt);let i=e.rowNumber,o=e.colNumber;for(let{col:e,row:n}of t)i=Math.max(i,n+1),o=Math.max(o,e+1);return{rowNumber:i,colNumber:o}}checkSheetExists(e){return"CREATE_SHEET"!==e.type&&"sheetId"in e&&void 0===this.sheets[e.sheetId]?27:"CREATE_SHEET"===e.type&&void 0!==this.sheets[e.sheetId]?12:0}checkZones(e){const t=[];if("zone"in e&&t.push(e.zone),"target"in e&&Array.isArray(e.target)&&t.push(...e.target),"ranges"in e&&Array.isArray(e.ranges)&&t.push(...e.ranges.map((e=>this.getters.getRangeFromRangeData(e).zone))),!t.every(Hi))return 25;if(t.length&&"sheetId"in e){const i=this.getSheetZone(e.sheetId);return t.every((e=>Ji(e,i)))?0:18}return 0}}Kv.getters=["getSheetName","tryGetSheetName","getSheet","tryGetSheet","getSheetIdByName","getSheetIds","getVisibleSheetIds","isSheetVisible","getEvaluationSheets","doesHeaderExist","getCell","getCellPosition","getColsZone","getRowCells","getRowsZone","getNumberCols","getNumberRows","getNumberHeaders","getGridLinesVisibility","getNextSheetName","isEmpty","getSheetSize","getSheetZone","getPaneDivisions","checkElementsIncludeAllNonFrozenHeaders"];class Qv extends Fv{constructor({getters:e,stateObserver:t,dispatch:i,uiActions:o,selection:n}){super(t,i),this.getters=e,this.ui=o,this.selection=n}drawGrid(e,t){}}Qv.layers=[];class Jv extends Qv{constructor(){super(...arguments),this.customColors=new Set,this.shouldUpdateColors=!1}handle(e){switch(e.type){case"UPDATE_CELL":case"UPDATE_CHART":case"CREATE_CHART":case"ADD_CONDITIONAL_FORMAT":this.shouldUpdateColors=!0}}finalize(){if(this.shouldUpdateColors){this.shouldUpdateColors=!1;for(const e of this.getCustomColors())this.tryToAddColor(e)}}getCustomColors(){let e=[];for(const t of this.getters.getSheetIds()){const i=Object.values(this.getters.getCells(t));e=e.concat(this.getColorsFromCells(i),this.getFormattingColors(t),this.getChartColors(t))}return function(e){const t=[{leadColor:xt(255,0,0),colors:[]},{leadColor:xt(255,128,0),colors:[]},{leadColor:xt(128,128,0),colors:[]},{leadColor:xt(128,255,0),colors:[]},{leadColor:xt(0,255,0),colors:[]},{leadColor:xt(0,255,128),colors:[]},{leadColor:xt(0,255,255),colors:[]},{leadColor:xt(0,127,255),colors:[]},{leadColor:xt(0,0,255),colors:[]},{leadColor:xt(127,0,255),colors:[]},{leadColor:xt(128,0,128),colors:[]},{leadColor:xt(255,0,128),colors:[]}];for(const i of e.map(Tt)){let e=500,o=0;t.forEach(((t,n)=>{const s=(r=i,a=t.leadColor,Math.sqrt(Math.pow(r.r-a.r,2)+Math.pow(r.g-a.g,2)+Math.pow(r.b-a.b,2)));var r,a;e>s&&(e=s,o=n)})),t[o].colors.push(i)}return t.map((e=>e.colors.sort(((e,t)=>Mt(e).s-Mt(t).s)))).flat().map(Rt)}([...new Set([...new Set([...e,...this.customColors])].filter(wt).map(Et))]).filter((e=>!O.includes(e)))}getColorsFromCells(e){var t,i;const o=new Set;for(const n of e)(null===(t=n.style)||void 0===t?void 0:t.textColor)&&o.add(n.style.textColor),(null===(i=n.style)||void 0===i?void 0:i.fillColor)&&o.add(n.style.fillColor);return[...o]}getFormattingColors(e){const t=this.getters.getConditionalFormats(e),i=[];for(const e of t){const t=e.rule;"CellIsRule"===t.type?(i.push(t.style.textColor),i.push(t.style.fillColor)):"ColorScaleRule"===t.type&&(i.push(Ct(t.minimum.color)),i.push(t.midpoint?Ct(t.midpoint.color):void 0),i.push(Ct(t.maximum.color)))}return i.filter(it)}getChartColors(e){const t=this.getters.getChartIds(e).map((e=>this.getters.getChart(e)));let i=new Set;for(let e of t){if(void 0===e)continue;const t=e.getDefinition().background;switch(void 0!==t&&i.add(t),e.type){case"gauge":const t=e.sectionRule.colors;i.add(t.lowerColor),i.add(t.middleColor),i.add(t.upperColor);break;case"scorecard":const o=e;i.add(o.baselineColorDown),i.add(o.baselineColorUp)}}return[...i]}tryToAddColor(e){const t=Et(e);e&&!O.includes(t)&&this.customColors.add(t)}}Jv.getters=["getCustomColors"];const eb=tg.mapping;class tb extends Qv{constructor(e){super(e),this.isUpToDate=!1,this.evaluatedCells={},this.evalContext=e.custom,this.lazyEvaluation=e.lazyEvaluation}handle(e){switch(hn.has(e.type)&&(this.isUpToDate=!1),e.type){case"UPDATE_CELL":("content"in e||"format"in e)&&(this.isUpToDate=!1);break;case"EVALUATE_CELLS":this.evaluate()}}finalize(){this.isUpToDate||(this.evaluate(),this.isUpToDate=!0)}evaluateFormula(e,t=this.getters.getActiveSheetId()){try{const i=ff(e),o=this.getCompilationParameters((e=>this.getEvaluatedCell(this.getters.getCellPosition(e.id)))),n=[];for(let e of i.dependencies)n.push(this.getters.getRangeFromSheetXC(t,e));return i.execute(n,...o).value}catch(e){return e instanceof c?e.errorType:a.GenericError}}getRangeFormattedValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.formattedValue))}getRangeValues(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.value))}getRangeFormats(e){const t=this.getters.tryGetSheet(e.sheetId);return void 0===t?[]:this.getters.getEvaluatedCellsInZone(t.id,e.zone).map((e=>e.format))}getEvaluatedCell({sheetId:e,col:t,row:i}){var o,n,s;return void 0===this.getters.getCell({sheetId:e,col:t,row:i})?En(""):(null===(s=null===(n=null===(o=this.evaluatedCells[e])||void 0===o?void 0:o[t])||void 0===n?void 0:n[i])||void 0===s?void 0:s.call(n))||En("")}getEvaluatedCells(e){const t=this.getters.getCells(e)||{},i={};for(let e of Object.keys(t)){const t=this.getters.getCellPosition(e);i[e]=this.getEvaluatedCell(t)}return i}getColEvaluatedCells(e,t){var i;return Object.values((null===(i=this.evaluatedCells[e])||void 0===i?void 0:i[t])||[]).filter(it).map((e=>e()))}getEvaluatedCellsInZone(e,t){return no(t).map((({col:t,row:i})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:i})))}setEvaluatedCell(e,t){const{col:i,row:o,sheetId:n}=this.getters.getCellPosition(e);this.evaluatedCells[n]||(this.evaluatedCells[n]={}),this.evaluatedCells[n][i]||(this.evaluatedCells[n][i]={}),this.evaluatedCells[n][i][o]=t,this.lazyEvaluation||this.evaluatedCells[n][i][o]()}*getAllCells(){for(const e of this.getters.getSheetIds()){const t=this.getters.getCells(e);for(const e in t)yield t[e]}}evaluate(){this.evaluatedCells={};const e=new Set,t=e=>{var t,n;const s=e.id,{col:r,row:a,sheetId:l}=this.getters.getCellPosition(s),c=null===(n=null===(t=this.evaluatedCells[l])||void 0===t?void 0:t[r])||void 0===n?void 0:n[a];return c||rt((()=>{try{switch(e.isFormula){case!0:return o(e);case!1:return Sn(e.content,e.format)}}catch(t){return i(t,e)}}))},i=(e,t)=>{e instanceof Error||(e=new Error(e));const i=(null==e?void 0:e.errorType)||a.GenericError,o=n[2].__lastFnCalled||"",s=new c(i,e.message.replace("[[FUNCTION_NAME]]",o),void 0!==e.logLevel?e.logLevel:l.error);return In(t.content,s)},o=t=>{const i=t.id;if(e.has(i))throw new d;n[2].__originCellXC=()=>{const e=n[2].getters.getCellPosition(i);return qt(e.col,e.row)},e.add(i);const o=t.compiledFormula.execute(t.dependencies,...n);if(e.delete(i),Array.isArray(o.value))throw new Error(s("This formula depends on invalid values"));return En(o.value,t.format||o.format)},n=this.getCompilationParameters((e=>t(e)()));for(const e of this.getAllCells())this.setEvaluatedCell(e.id,t(e))}getCompilationParameters(e){const t=Object.assign(Object.create(eb),this.evalContext,{getters:this.getters}),i=this.getters;const o=t=>{const i=e(t);if(i.type===ln.error)throw i.error;return i},n={};return[function(e,t,n,r){if(t)return{value:$i(e.zone)};if(!Hi(e.zone))throw new u;if(e.zone.bottom!==e.zone.top||e.zone.left!==e.zone.right)throw new Error(r?s("Function %s expects the parameter %s to be a single value or a single cell reference, not a range.",n.toString(),r.toString()):s("Function %s expects its parameters to be single values or single cell references, not ranges.",n.toString()));if(e.invalidSheetName)throw new Error(s("Invalid sheet name: %s",e.invalidSheetName));return function(e){let t;if(!i.tryGetSheet(e.sheetId))throw new Error(s("Invalid sheet name"));return t=i.getCell({sheetId:e.sheetId,col:e.zone.left,row:e.zone.top}),t&&""!==t.content?o(t):{value:null,format:null==t?void 0:t.format}}(e)},function(e){const s=e.sheetId;if(!Hi(e.zone))throw new u;const r=i.getSheetZone(s),a=Xi(e.zone,r);if(!a)return[[]];const{top:l,left:c,bottom:h,right:d}=a,g=`${s}-${l}-${c}-${h}-${d}`;if(g in n)return n[g];const p=new Array(d-c+1);for(let i=c;i<=d;i++){const n=new Array(h-l+1);for(let s=l;s<=h;s++){const r=t.getters.getCell({sheetId:e.sheetId,col:i,row:s});n[s-l]=r?o(r):void 0}p[i-c]=n}return n[g]=p,p},t]}exportForExcel(e){for(let t of e.sheets)for(const e in t.cells){const i={sheetId:t.id,...Gt(e)},o=this.getters.getCell(i);if(o){const n=t.cells[e],s=this.getEvaluatedCell(i);n.value=s.value,n.isFormula=o.isFormula&&!this.isBadExpression(o.content),o.format!==s.format&&(n.computedFormat=s.format)}}}isBadExpression(e){try{return ff(e),!1}catch(e){return!0}}}tb.getters=["evaluateFormula","getRangeFormattedValues","getRangeValues","getRangeFormats","getEvaluatedCell","getEvaluatedCells","getColEvaluatedCells","getEvaluatedCellsInZone"];class ib extends Qv{constructor(){super(...arguments),this.charts={},this.createRuntimeChart=function(e){const t=gr.getAll().sort(((e,t)=>e.sequence-t.sequence));return function(i){const o=t.find((e=>e.match(i.type)));if(!o)throw new Error("No runtime builder for this chart.");return o.getChartRuntime(i,e)}}(this.getters)}handle(e){if(hn.has(e.type)||dn.has(e.type)||"EVALUATE_CELLS"===e.type||"UPDATE_CELL"===e.type)for(const e in this.charts)this.charts[e]=void 0;switch(e.type){case"UPDATE_CHART":case"CREATE_CHART":case"DELETE_FIGURE":this.charts[e.id]=void 0;break;case"DELETE_SHEET":for(let e in this.charts)this.getters.isChartDefined(e)||(this.charts[e]=void 0)}}getChartRuntime(e){if(!this.charts[e]){const t=this.getters.getChart(e);if(!t)throw new Error(`No chart for the given id: ${e}`);this.charts[e]=this.createRuntimeChart(t)}return this.charts[e]}getStyleOfSingleCellChart(e,t){if(e)return{background:e,fontColor:Is(e)};if(!t)return{background:w,fontColor:Is(w)};const i=t.zone.left,o=t.zone.top,n=t.sheetId,s=this.getters.getCellComputedStyle({sheetId:n,col:i,row:o}),r=s.fillColor||w;return{background:r,fontColor:s.textColor||Is(r)}}}ib.getters=["getChartRuntime","getStyleOfSingleCellChart"];class ob extends Qv{constructor(){super(...arguments),this.isStale=!0,this.computedStyles={},this.computedIcons={},this.uuidGenerator=new Vi,this.rulePredicate={CellIsRule:(e,t)=>{if(e.type===ln.error)return!1;const i=t.values.map(Cn);switch(t.operator){case"IsEmpty":return""===e.value.toString().trim();case"IsNotEmpty":return""!==e.value.toString().trim();case"BeginsWith":return""!==i[0]&&e.value.toString().startsWith(i[0].toString());case"EndsWith":return""!==i[0]&&e.value.toString().endsWith(i[0].toString());case"Between":return e.value>=i[0]&&e.value<=i[1];case"NotBetween":return!(e.value>=i[0]&&e.value<=i[1]);case"ContainsText":return e.value.toString().indexOf(i[0].toString())>-1;case"NotContains":return!e.value||-1==e.value.toString().indexOf(i[0].toString());case"GreaterThan":return e.value>i[0];case"GreaterThanOrEqual":return e.value>=i[0];case"LessThan":return e.value<i[0];case"LessThanOrEqual":return e.value<=i[0];case"NotEqual":return""!==i[0]&&e.value!==i[0];case"Equal":return""===i[0]||e.value===i[0];default:console.warn(s("Not implemented operator %s for kind of conditional formatting: %s",t.operator,t.type))}return!1}}}handle(e){switch((dn.has(e.type)||"UPDATE_CELL"===e.type&&"content"in e)&&(this.isStale=!0),e.type){case"ACTIVATE_SHEET":const t=e.sheetIdTo;this.computedStyles[t]=this.computedStyles[t]||{},this.computedIcons[t]=this.computedIcons[t]||{},this.isStale=!0;break;case"AUTOFILL_CELL":const i=this.getters.getActiveSheetId(),o=this.getters.getRulesByCell(i,e.originCol,e.originRow);for(const t of o)this.adaptRules(i,t,[qt(e.col,e.row)],[]);break;case"PASTE_CONDITIONAL_FORMAT":this.pasteCf(e.origin,e.target,e.operation)}}finalize(){this.isStale&&(this.computeStyles(),this.isStale=!1)}getCellComputedStyle(e){var t;const{sheetId:i,col:o,row:n}=e,s=this.getters.getCell(e),r=this.computedStyles[i],a=r&&(null===(t=r[o])||void 0===t?void 0:t[n]),l={...null==s?void 0:s.style,...a};return this.getters.getEvaluatedCell(e).link&&!l.textColor&&(l.textColor=I),this.getters.isFilterHeader(e)&&(l.bold=!0),l}getConditionalIcon({col:e,row:t}){var i;const o=this.getters.getActiveSheetId(),n=this.computedIcons[o];return n&&(null===(i=n[e])||void 0===i?void 0:i[t])}computeStyles(){var e;const t=this.getters.getActiveSheetId();this.computedStyles[t]={},this.computedIcons[t]={};const i=this.computedStyles[t];for(let o of this.getters.getConditionalFormats(t).reverse())switch(o.rule.type){case"ColorScaleRule":for(let e of o.ranges)this.applyColorScale(e,o.rule);break;case"IconSetRule":for(let e of o.ranges)this.applyIcon(e,o.rule);break;default:for(let n of o.ranges){const s=this.getters.getRangeFromSheetXC(t,n).zone;for(let n=s.top;n<=s.bottom;n++)for(let r=s.left;r<=s.right;r++){const s=this.rulePredicate[o.rule.type];let a=this.getters.getEvaluatedCell({sheetId:t,col:r,row:n});s&&s(a,o.rule)&&(i[r]||(i[r]=[]),i[r][n]=Object.assign((null===(e=i[r])||void 0===e?void 0:e[n])||{},o.rule.style))}}}}parsePoint(e,t,i){const o=this.getters.getActiveSheetId(),n=this.getters.getEvaluatedCellsInZone(o,this.getters.getRangeFromSheetXC(o,e).zone).filter((e=>e.type===ln.number)).map((e=>e.value));switch(t.type){case"value":return"max"===i?Math.max(...n):Math.min(...n);case"number":return Number(t.value);case"percentage":const e=Math.min(...n);return e+(Math.max(...n)-e)*Number(t.value)/100;case"percentile":return ri(n,Number(t.value)/100,!0);case"formula":const o=t.value&&this.getters.evaluateFormula(t.value);return"number"==typeof o?o:null;default:return null}}applyIcon(e,t){const i=this.parsePoint(e,t.lowerInflectionPoint),o=this.parsePoint(e,t.upperInflectionPoint);if(null===i||null===o||i>o)return;const n=this.getters.getActiveSheetId(),s=this.getters.getRangeFromSheetXC(n,e).zone,r=this.computedIcons[n],a=[t.icons.upper,t.icons.middle,t.icons.lower];for(let e=s.top;e<=s.bottom;e++)for(let l=s.left;l<=s.right;l++){const s=this.getters.getEvaluatedCell({sheetId:n,col:l,row:e});if(s.type!==ln.number)continue;const c=this.computeIcon(s.value,o,t.upperInflectionPoint.operator,i,t.lowerInflectionPoint.operator,a);r[l]||(r[l]=[]),r[l][e]=c}}computeIcon(e,t,i,o,n,s){return"ge"===i&&e>=t||"gt"===i&&e>t?s[0]:"ge"===n&&e>=o||"gt"===n&&e>o?s[1]:s[2]}applyColorScale(e,t){var i;const o=this.parsePoint(e,t.minimum,"min"),n=t.midpoint?this.parsePoint(e,t.midpoint):null,s=this.parsePoint(e,t.maximum,"max");if(null===o||null===s||o>=s||n&&(o>=n||n>=s))return;const r=this.getters.getActiveSheetId(),a=this.getters.getRangeFromSheetXC(r,e).zone,l=this.computedStyles[r],c=[];t.midpoint&&n?(c.push({minValue:o,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(o,n,t.minimum.color,t.midpoint.color)}),c.push({minValue:n,minColor:t.midpoint.color,colorDiffUnit:this.computeColorDiffUnits(n,s,t.midpoint.color,t.maximum.color)})):c.push({minValue:o,minColor:t.minimum.color,colorDiffUnit:this.computeColorDiffUnits(o,s,t.minimum.color,t.maximum.color)});for(let e=a.top;e<=a.bottom;e++)for(let t=a.left;t<=a.right;t++){const a=this.getters.getEvaluatedCell({sheetId:r,col:t,row:e});if(a.type===ln.number){const r=ke(a.value,o,s);let h;h=2===c.length&&n?r<=n?this.colorCell(r,c[0].minValue,c[0].minColor,c[0].colorDiffUnit):this.colorCell(r,c[1].minValue,c[1].minColor,c[1].colorDiffUnit):this.colorCell(r,c[0].minValue,c[0].minColor,c[0].colorDiffUnit),l[t]||(l[t]=[]),l[t][e]=(null===(i=l[t])||void 0===i?void 0:i[e])||{},l[t][e].fillColor=Ct(h)}}}computeColorDiffUnits(e,t,i,o){const n=t-e;return[((i>>16)%256-(o>>16)%256)/n,((i>>8)%256-(o>>8)%256)/n,(i%256-o%256)/n]}colorCell(e,t,i,o){const[n,s,r]=o;return Math.round((i>>16)%256-n*(e-t))<<16|Math.round((i>>8)%256-s*(e-t))<<8|Math.round(i%256-r*(e-t))}adaptRules(e,t,i,o){if(0===i.length&&0===o.length)return;const n=this.getters.getConditionalFormats(e),s=n.findIndex((e=>e.id===t.id));let r=[];s>-1&&(r=n[s].ranges),r=r.concat(i);const a=eo(r,o);0!==a.length?this.dispatch("ADD_CONDITIONAL_FORMAT",{cf:{id:t.id,rule:t.rule,stopIfTrue:t.stopIfTrue},ranges:a.map((t=>this.getters.getRangeDataFromXc(e,t))),sheetId:e}):this.dispatch("REMOVE_CONDITIONAL_FORMAT",{id:t.id,sheetId:e})}pasteCf(e,t,i){const o=qt(t.col,t.row);for(let n of this.getters.getConditionalFormats(e.sheetId))for(let s of n.ranges)if(Qi(e.col,e.row,this.getters.getRangeFromSheetXC(e.sheetId,s).zone)){const s=n,r=[];if("CUT"===i&&r.push(qt(e.col,e.row)),e.sheetId===t.sheetId)this.adaptRules(e.sheetId,s,[o],r);else{this.adaptRules(e.sheetId,s,[],r);const i=this.getCFToCopyTo(t.sheetId,s);this.adaptRules(t.sheetId,i,[o],[])}}}getCFToCopyTo(e,t){const i=this.getters.getConditionalFormats(e).find((e=>e.stopIfTrue===t.stopIfTrue&&ct(e.rule,t.rule)));return i||{...t,id:this.uuidGenerator.uuidv4(),ranges:[]}}}ob.getters=["getConditionalIcon","getCellComputedStyle"];class nb extends Qv{constructor(){super(...arguments),this.filterValues={},this.hiddenRows=new Set,this.isEvaluationDirty=!1}allowDispatch(e){if("UPDATE_FILTER"===e.type)if(!this.getters.getFilterId(e))return 79;return 0}handle(e){switch(e.type){case"UNDO":case"REDO":case"UPDATE_CELL":case"EVALUATE_CELLS":case"ACTIVATE_SHEET":case"REMOVE_FILTER_TABLE":case"ADD_COLUMNS_ROWS":case"REMOVE_COLUMNS_ROWS":this.isEvaluationDirty=!0;break;case"START":for(const e of this.getters.getSheetIds()){this.filterValues[e]={};for(const t of this.getters.getFilters(e))this.filterValues[e][t.id]=[]}break;case"CREATE_SHEET":this.filterValues[e.sheetId]={};break;case"HIDE_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":this.updateHiddenRows();break;case"UPDATE_FILTER":this.updateFilter(e),this.updateHiddenRows();break;case"DUPLICATE_SHEET":const t={};for(const i of this.getters.getFilters(e.sheetIdTo)){const o=i.zoneWithHeaders;t[i.id]=this.getFilterValues({sheetId:e.sheetId,col:o.left,row:o.top})}this.filterValues[e.sheetIdTo]=t}}finalize(){this.isEvaluationDirty&&(this.updateHiddenRows(),this.isEvaluationDirty=!1)}isRowFiltered(e,t){return e===this.getters.getActiveSheetId()&&this.hiddenRows.has(t)}getCellBorderWithFilterBorder(e){const{sheetId:t,col:i,row:o}=e;let n;for(let e of this.getters.getFilterTables(t)){const s=e.zone;if(Qi(i,o,s)){const e=this.intersectZoneWithViewport(t,s);n={top:o===e.top?X:void 0,bottom:o===e.bottom?X:void 0,left:i===e.left?X:void 0,right:i===e.right?X:void 0}}}const s=this.getters.getCellBorder(e),r={...n,...dt(s||{})};return ot(r)?null:r}getFilterHeaders(e){const t=[];for(let i of this.getters.getFilterTables(e)){const o=i.zone;if(!o)continue;const n=o.top;for(let i=o.left;i<=o.right;i++)this.getters.isColHidden(e,i)||this.getters.isRowHidden(e,n)||t.push({col:i,row:n})}return t}getFilterValues(e){const t=this.getters.getFilterId(e),i=e.sheetId;return t&&this.filterValues[i]&&this.filterValues[i][t]||[]}isFilterHeader({sheetId:e,col:t,row:i}){return this.getFilterHeaders(e).some((e=>e.col===t&&e.row===i))}isFilterActive(e){var t,i;const o=this.getters.getFilterId(e),n=e.sheetId;return Boolean(o&&(null===(i=null===(t=this.filterValues[n])||void 0===t?void 0:t[o])||void 0===i?void 0:i.length))}intersectZoneWithViewport(e,t){return{left:this.getters.findVisibleHeader(e,"COL",t.left,t.right),right:this.getters.findVisibleHeader(e,"COL",t.right,t.left),top:this.getters.findVisibleHeader(e,"ROW",t.top,t.bottom),bottom:this.getters.findVisibleHeader(e,"ROW",t.bottom,t.top)}}updateFilter({col:e,row:t,values:i,sheetId:o}){const n=this.getters.getFilterId({sheetId:o,col:e,row:t});n&&(this.filterValues[o]||(this.filterValues[o]={}),this.filterValues[o][n]=i)}updateHiddenRows(){var e,t;const i=this.getters.getActiveSheetId(),o=this.getters.getFilters(i).sort(((e,t)=>e.zoneWithHeaders.top-t.zoneWithHeaders.top)),n=new Set;for(let s of o){if(this.getters.isRowHiddenByUser(i,s.zoneWithHeaders.top))continue;if(n.has(s.zoneWithHeaders.top))continue;const o=null===(t=null===(e=this.filterValues[i])||void 0===e?void 0:e[s.id])||void 0===t?void 0:t.map(ut);if(o&&s.filteredZone)for(let e=s.filteredZone.top;e<=s.filteredZone.bottom;e++){const t=this.getCellValueAsString(i,s.col,e);o.includes(t)&&n.add(e)}}this.hiddenRows=n}getCellValueAsString(e,t,i){return this.getters.getEvaluatedCell({sheetId:e,col:t,row:i}).formattedValue.toLowerCase()}exportForExcel(e){for(const t of e.sheets){const e=t.id;for(const i of t.filterTables){const o=Bi(i.range),n=[],s=[];for(const i of He(0,io(o).numberOfCols)){const r={sheetId:t.id,col:o.left+i,row:o.top},a=this.getFilterValues(r),l=this.getters.getFilter(r);if(!l)continue;const c=l.filteredZone?no(l.filteredZone).map((t=>this.getters.getEvaluatedCell({sheetId:e,...t}).formattedValue)):[];if(a.length){const e=c.filter((e=>e)).filter((e=>!a.includes(e)));n.push({colId:i,displayedValues:[...new Set(e)],displayBlanks:!a.includes("")&&c.some((e=>!e))})}const h={col:l.col,row:l.zoneWithHeaders.top,sheetId:e},d=this.getters.getEvaluatedCell(h).formattedValue,u=this.getUniqueColNameForExcel(i,d,s);s.push(u),t.cells[qt(h.col,h.row)]={...t.cells[qt(h.col,h.row)],content:u,value:u,isFormula:!1}}i.filters=n}}}getUniqueColNameForExcel(e,t,i){t||(t=`Column${e}`);let o=t,n=2;for(;i.includes(o);)o=t+String(n),n++;return o}}nb.getters=["getCellBorderWithFilterBorder","getFilterHeaders","getFilterValues","isFilterHeader","isRowFiltered","isFilterActive"];class sb{constructor(e,t,i,o,n,s){this.getters=e,this.sheetId=t,this.boundaries=i,this.viewportWidth=o.width,this.viewportHeight=o.height,this.offsetScrollbarX=s.x,this.offsetScrollbarY=s.y,this.canScrollVertically=n.canScrollVertically,this.canScrollHorizontally=n.canScrollHorizontally,this.offsetCorrectionX=this.getters.getColDimensions(this.sheetId,this.boundaries.left).start,this.offsetCorrectionY=this.getters.getRowDimensions(this.sheetId,this.boundaries.top).start,this.adjustViewportOffsetX(),this.adjustViewportOffsetY()}getMaxSize(){const 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:i,size:o}=this.getters.getColDimensions(this.sheetId,e),{end:n,size:s}=this.getters.getRowDimensions(this.sheetId,t),r=this.searchHeaderIndex("COL",i-this.viewportWidth,0),a=this.getters.getColSize(this.sheetId,r),l=this.searchHeaderIndex("ROW",n-this.viewportHeight,0),c=this.getters.getRowSize(this.sheetId,l);let h=i-this.offsetCorrectionX;this.canScrollHorizontally&&(h+=Math.max(F,Math.min(a,this.viewportWidth-o)),h=Math.max(h,this.viewportWidth));let d=n-this.offsetCorrectionY;return this.canScrollVertically&&(d+=Math.max(D+5,Math.min(c,this.viewportHeight-s)),d=Math.max(d,this.viewportHeight)),{width:h,height:d}}getColIndex(e,t=!1){return e<this.offsetCorrectionX||e>this.offsetCorrectionX+this.viewportWidth?-1:this.searchHeaderIndex("COL",e-this.offsetCorrectionX,this.left,t)}getRowIndex(e,t=!1){return e<this.offsetCorrectionY||e>this.offsetCorrectionY+this.viewportHeight?-1:this.searchHeaderIndex("ROW",e-this.offsetCorrectionY,this.top,t)}adjustPosition(e){const t=this.sheetId;e||(e=this.getters.getSheetPosition(t));const i=this.getters.getMainCellPosition({sheetId:t,...e}),{col:o,row:n}=this.getters.getNextVisibleCellPosition(i);Qi(o,this.boundaries.top,this.boundaries)&&this.adjustPositionX(o),Qi(this.boundaries.left,n,this.boundaries)&&this.adjustPositionY(n)}adjustPositionX(e){const t=this.sheetId,{end:i}=this.getters.getColDimensions(t,e),o=this.getters.getNumberCols(t);if(this.offsetX+this.offsetCorrectionX+this.viewportWidth<i){let i=e;for(;this.getters.isColHidden(t,i)&&e<o;)i++;const n=this.getters.getColDimensions(t,i).end,s=this.searchHeaderIndex("COL",n-this.viewportWidth-this.offsetCorrectionX,this.boundaries.left,!0);this.offsetX=this.getters.getColDimensions(t,s).end-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}else if(this.left>e){let i=e;for(;this.getters.isColHidden(t,i)&&e>0;)i--;this.offsetX=this.getters.getColDimensions(t,i).start-this.offsetCorrectionX,this.offsetScrollbarX=this.offsetX,this.adjustViewportZoneX()}}adjustPositionY(e){const t=this.sheetId,{end:i}=this.getters.getRowDimensions(t,e),o=this.getters.getNumberRows(t);if(this.offsetY+this.viewportHeight+this.offsetCorrectionY<i){let i=e;for(;this.getters.isRowHidden(t,i)&&e<o;)i++;const n=this.getters.getRowDimensions(t,i).end,s=this.searchHeaderIndex("ROW",n-this.viewportHeight-this.offsetCorrectionY,this.boundaries.top,!0);this.offsetY=this.getters.getRowDimensions(t,s).end-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY()}else if(this.top>e){let i=e;for(;this.getters.isRowHidden(t,i)&&e>0;)i--;this.offsetY=this.getters.getRowDimensions(t,i).start-this.offsetCorrectionY,this.offsetScrollbarY=this.offsetY,this.adjustViewportZoneY()}}setViewportOffset(e,t){this.setViewportOffsetX(e),this.setViewportOffsetY(t)}adjustViewportZone(){this.adjustViewportZoneX(),this.adjustViewportZoneY()}getRect(e){const t=Xi(e,this.zone);if(t){return{x:this.getters.getColRowOffset("COL",this.zone.left,t.left)+this.offsetCorrectionX,y:this.getters.getColRowOffset("ROW",this.zone.top,t.top)+this.offsetCorrectionY,width:Math.min(this.getters.getColRowOffset("COL",t.left,t.right+1),this.viewportWidth),height:Math.min(this.getters.getColRowOffset("ROW",t.top,t.bottom+1),this.viewportHeight)}}}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,i=0,o=!1){let n=0;const s=this.sheetId,r=this.getters.getNumberHeaders(s,e);for(let a=i;a<=r-1;a++){const i=o||"COL"!==e?a<this.top&&a>this.bottom:a<this.left&&a>this.right;if(!this.getters.isHeaderHidden(s,e,a)&&!i&&(n+="COL"===e?this.getters.getColSize(s,a):this.getters.getRowSize(s,a),n>t))return a}return-1}get zone(){return{left:this.left,right:this.right,top:this.top,bottom:this.bottom}}setViewportOffsetX(e){this.canScrollHorizontally&&(this.offsetScrollbarX=e,this.adjustViewportZoneX())}setViewportOffsetY(e){this.canScrollVertically&&(this.offsetScrollbarY=e,this.adjustViewportZoneY())}adjustViewportOffsetX(){if(this.canScrollHorizontally){const{width:e}=this.getMaxSize();this.viewportWidth+this.offsetScrollbarX>e&&(this.offsetScrollbarX=Math.max(0,e-this.viewportWidth))}this.left=this.getColIndex(this.offsetScrollbarX,!0),this.right=this.getColIndex(this.offsetScrollbarX+this.viewportWidth,!0),-1===this.right&&(this.right=this.boundaries.right),this.adjustViewportZoneX()}adjustViewportOffsetY(){if(this.canScrollVertically){const{height:e}=this.getMaxSize();this.viewportHeight+this.offsetScrollbarY>e&&(this.offsetScrollbarY=Math.max(0,e-this.viewportHeight))}this.top=this.getRowIndex(this.offsetScrollbarY,!0),this.bottom=this.getRowIndex(this.offsetScrollbarY+this.viewportWidth,!0),-1===this.bottom&&(this.bottom=this.boundaries.bottom),this.adjustViewportZoneY()}adjustViewportZoneX(){const e=this.sheetId;this.left=this.searchHeaderIndex("COL",this.offsetScrollbarX,this.boundaries.left),this.right=Math.min(this.boundaries.right,this.searchHeaderIndex("COL",this.viewportWidth,this.left)),-1===this.left&&(this.left=this.boundaries.left),-1===this.right&&(this.right=this.getters.getNumberCols(e)-1),this.offsetX=this.getters.getColDimensions(e,this.left).start-this.getters.getColDimensions(e,this.boundaries.left).start}adjustViewportZoneY(){const e=this.sheetId;this.top=this.searchHeaderIndex("ROW",this.offsetScrollbarY,this.boundaries.top),this.bottom=Math.min(this.boundaries.bottom,this.searchHeaderIndex("ROW",this.viewportHeight,this.top)),-1===this.top&&(this.top=this.boundaries.top),-1===this.bottom&&(this.bottom=this.getters.getNumberRows(e)-1),this.offsetY=this.getters.getRowDimensions(e,this.top).start-this.getters.getRowDimensions(e,this.boundaries.top).start}}class rb extends Qv{constructor(){super(...arguments),this.viewports={},this.sheetViewWidth=1e3,this.sheetViewHeight=1e3,this.gridOffsetX=0,this.gridOffsetY=0,this.sheetsWithDirtyViewports=new Set}allowDispatch(e){switch(e.type){case"SET_VIEWPORT_OFFSET":return this.checkScrollingDirection(e);case"RESIZE_SHEETVIEW":return this.chainValidations(this.checkValuesAreDifferent,this.checkPositiveDimension)(e);default:return 0}}handleEvent(e){switch(e.type){case"HeadersSelected":case"AlterZone":break;case"ZonesSelected":let{col:t,row:i}=ro(e.previousAnchor.zone,e.anchor.zone);if("updateAnchor"===e.mode){const o=e.previousAnchor.zone,n=e.anchor.zone,{top:s,bottom:r,left:a,right:l}=this.getters.getActiveMainViewport();o.left===n.left&&o.right===n.right&&(t=a>t||t>l?a:t),o.top===n.top&&o.bottom===n.bottom&&(i=s>i||i>r?s:i)}const o=this.getters.getActiveSheetId();t=Math.min(t,this.getters.getNumberCols(o)-1),i=Math.min(i,this.getters.getNumberRows(o)-1),this.refreshViewport(this.getters.getActiveSheetId(),{col:t,row:i})}}handle(e){var t;switch(this.cleanViewports(),e.type){case"START":this.selection.observe(this,{handleEvent:this.handleEvent.bind(this)}),this.resetViewports(this.getters.getActiveSheetId());break;case"UNDO":case"REDO":this.resetSheetViews();break;case"RESIZE_SHEETVIEW":this.resizeSheetView(e.height,e.width,e.gridOffsetX,e.gridOffsetY);break;case"SET_VIEWPORT_OFFSET":this.setSheetViewOffset(e.offsetX,e.offsetY);break;case"SHIFT_VIEWPORT_DOWN":const{top:i}=this.getActiveMainViewport(),o=this.getters.getActiveSheetId(),n=this.clipOffsetY(this.getters.getRowDimensions(o,i).start+this.sheetViewHeight);this.shiftVertically(n);break;case"SHIFT_VIEWPORT_UP":{const{top:e}=this.getActiveMainViewport(),t=this.getters.getActiveSheetId(),i=this.clipOffsetY(this.getters.getRowDimensions(t,e).end-this.sheetViewHeight);this.shiftVertically(i);break}case"REMOVE_COLUMNS_ROWS":case"RESIZE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"UPDATE_FILTER":this.resetViewports(e.sheetId);break;case"UPDATE_CELL":("content"in e||"format"in e||void 0!==(null===(t=e.style)||void 0===t?void 0:t.fontSize))&&this.sheetsWithDirtyViewports.add(e.sheetId);break;case"ACTIVATE_SHEET":this.setViewports(),this.refreshViewport(e.sheetIdTo);break;case"UNFREEZE_ROWS":case"UNFREEZE_COLUMNS":case"FREEZE_COLUMNS":case"FREEZE_ROWS":case"UNFREEZE_COLUMNS_ROWS":this.resetViewports(this.getters.getActiveSheetId());break;case"DELETE_SHEET":this.sheetsWithDirtyViewports.delete(e.sheetId);break;case"START_EDITION":const{col:s,row:r}=this.getters.getActivePosition();this.refreshViewport(this.getters.getActiveSheetId(),{col:s,row:r})}}finalize(){for(const e of this.sheetsWithDirtyViewports)this.resetViewports(e);this.sheetsWithDirtyViewports=new Set,this.setViewports()}setViewports(){var e;const t=this.getters.getSheetIds();for(const i of t)(null===(e=this.viewports[i])||void 0===e?void 0:e.bottomRight)||this.resetViewports(i)}getColIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getColIndex(e))))}getRowIndex(e){const t=this.getters.getActiveSheetId();return Math.max(...this.getSubViewports(t).map((t=>t.getRowIndex(e))))}getSheetViewDimensionWithHeaders(){return{width:this.sheetViewWidth+this.gridOffsetX,height:this.sheetViewHeight+this.gridOffsetY}}getSheetViewDimension(){return{width:this.sheetViewWidth,height:this.sheetViewHeight}}getActiveMainViewport(){const e=this.getters.getActiveSheetId();return this.getMainViewport(e)}getActiveSheetScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetX,scrollY:t.offsetY}}getActiveSheetDOMScrollInfo(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e);return{scrollX:t.offsetScrollbarX,scrollY:t.offsetScrollbarY}}getSheetViewVisibleCols(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>He(e.left,e.right+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"COL",t)))}getSheetViewVisibleRows(){const e=this.getters.getActiveSheetId(),t=this.getSubViewports(e);return[...new Set(t.map((e=>He(e.top,e.bottom+1))).flat())].filter((t=>!this.getters.isHeaderHidden(e,"ROW",t)))}getMainViewportRect(){const e=this.getters.getActiveSheetId(),t=this.getMainInternalViewport(e),{xSplit:i,ySplit:o}=this.getters.getPaneDivisions(e);let{width:n,height:s}=t.getMaxSize();return{x:this.getters.getColDimensions(e,i).start,y:this.getters.getRowDimensions(e,o).start,width:n,height:s}}getMaximumSheetOffset(){const e=this.getters.getActiveSheetId(),{width:t,height:i}=this.getMainViewportRect(),o=this.getMainInternalViewport(e);return{maxOffsetX:Math.max(0,t-o.viewportWidth+1),maxOffsetY:Math.max(0,i-o.viewportHeight+1)}}getColRowOffsetInViewport(e,t,i){const o=this.getters.getActiveSheetId(),n=this.getters.getSheetViewVisibleCols(),s=this.getters.getSheetViewVisibleRows();if(i<t)return-this.getColRowOffsetInViewport(e,i,t);let r=0;const a="COL"===e?n:s;for(let n=t;n<i;n++)a.includes(n)&&(r+="COL"===e?this.getters.getColSize(o,n):this.getters.getRowSize(o,n));return r}isVisibleInViewport({sheetId:e,col:t,row:i}){return this.getSubViewports(e).some((e=>e.isVisible(t,i)))}getEdgeScrollCol(e,t,i){let o=!1,n=0,s=0;const{xSplit:r}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{width:a}=this.getSheetViewDimension(),{x:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollX;return e>a?(o=!0,s=Yt(e-a),n=1):e<l&&i>=l&&c>0?(o=!0,s=Yt(l-e),n=-1):r&&t<l&&e>l&&(o=!0,s=Yt(e),n="reset"),{canEdgeScroll:o,direction:n,delay:s}}getEdgeScrollRow(e,t,i){let o=!1,n=0,s=0;const{ySplit:r}=this.getters.getPaneDivisions(this.getters.getActiveSheetId()),{height:a}=this.getSheetViewDimension(),{y:l}=this.getMainViewportCoordinates(),c=this.getActiveSheetScrollInfo().scrollY;return e>a?(o=!0,s=Yt(e-a),n=1):e<l&&i>=l&&c>0?(o=!0,s=Yt(l-e),n=-1):r&&t<l&&e>l&&(o=!0,s=Yt(e),n="reset"),{canEdgeScroll:o,direction:n,delay:s}}getVisibleRect(e){const t=this.getters.getActiveSheetId(),i=this.getSubViewports(t).map((t=>t.getRect(e))).filter(it);if(0===i.length)return{x:0,y:0,width:0,height:0};const o=Math.min(...i.map((e=>e.x))),n=Math.min(...i.map((e=>e.y))),s=Math.max(...i.map((e=>e.x+e.width)))-o,r=Math.max(...i.map((e=>e.y+e.height)))-n;return{x:o+this.gridOffsetX,y:n+this.gridOffsetY,width:s,height:r}}getMainViewportCoordinates(){const e=this.getters.getActiveSheetId(),{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e);return{x:this.getters.getColDimensions(e,t).start,y:this.getters.getRowDimensions(e,i).start}}ensureMainViewportExist(e){this.viewports[e]||this.resetViewports(e)}getSubViewports(e){return this.ensureMainViewportExist(e),Object.values(this.viewports[e]).filter(it)}checkPositiveDimension(e){return e.width<0||e.height<0?68:0}checkValuesAreDifferent(e){const{height:t,width:i}=this.getSheetViewDimension();return e.gridOffsetX===this.gridOffsetX&&e.gridOffsetY===this.gridOffsetY&&e.width===i&&e.height===t?76:0}checkScrollingDirection({offsetX:e,offsetY:t}){const i=this.getMainInternalViewport(this.getters.getActiveSheetId());return!i.canScrollHorizontally&&e>0||!i.canScrollVertically&&t>0?69:0}getMainViewport(e){const 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(){const e=this.getters.getSheetIds();for(let t of Object.keys(this.viewports))e.includes(t)||delete this.viewports[t]}resetSheetViews(){for(let e of Object.keys(this.viewports)){const t=this.getters.getSheetPosition(e);this.resetViewports(e);const i=this.getSubViewports(e);Object.values(i).forEach((e=>{e.adjustPosition(t)}))}}resizeSheetView(e,t,i=0,o=0){this.sheetViewHeight=e,this.sheetViewWidth=t,this.gridOffsetX=i,this.gridOffsetY=o,this.recomputeViewports()}recomputeViewports(){for(let e of Object.keys(this.viewports))this.resetViewports(e)}setSheetViewOffset(e,t){const i=this.getters.getActiveSheetId(),{maxOffsetX:o,maxOffsetY:n}=this.getMaximumSheetOffset();Object.values(this.getSubViewports(i)).forEach((i=>i.setViewportOffset(ke(e,0,o),ke(t,0,n))))}clipOffsetY(e){const{height:t}=this.getMainViewportRect(),i=t-this.sheetViewHeight;return e=Math.min(e,i),e=Math.max(e,0)}getViewportOffset(e){var t,i;return{x:(null===(t=this.viewports[e])||void 0===t?void 0:t.bottomRight.offsetScrollbarX)||0,y:(null===(i=this.viewports[e])||void 0===i?void 0:i.bottomRight.offsetScrollbarY)||0}}resetViewports(e){if(!this.getters.tryGetSheet(e))return;const{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e),o=this.getters.getNumberCols(e),n=this.getters.getNumberRows(e),s=this.getters.getColRowOffset("COL",0,t,e),r=this.getters.getColRowOffset("ROW",0,i,e),{xRatio:a,yRatio:l}=this.getFrozenSheetViewRatio(e),c=a<1,h=l<1,d=this.getViewportOffset(e),u={topLeft:i&&t&&new sb(this.getters,e,{left:0,right:t-1,top:0,bottom:i-1},{width:s,height:r},{canScrollHorizontally:!1,canScrollVertically:!1},{x:0,y:0})||void 0,topRight:i&&new sb(this.getters,e,{left:t,right:o-1,top:0,bottom:i-1},{width:this.sheetViewWidth-s,height:r},{canScrollHorizontally:c,canScrollVertically:!1},{x:c?d.x:0,y:0})||void 0,bottomLeft:t&&new sb(this.getters,e,{left:0,right:t-1,top:i,bottom:n-1},{width:s,height:this.sheetViewHeight-r},{canScrollHorizontally:!1,canScrollVertically:h},{x:0,y:h?d.y:0})||void 0,bottomRight:new sb(this.getters,e,{left:t,right:o-1,top:i,bottom:n-1},{width:this.sheetViewWidth-s,height:this.sheetViewHeight-r},{canScrollHorizontally:c,canScrollVertically:h},{x:c?d.x:0,y:h?d.y:0})};this.viewports[e]=u}refreshViewport(e,t){Object.values(this.getSubViewports(e)).forEach((e=>{e.adjustViewportZone(),e.adjustPosition(t)}))}shiftVertically(e){const{top:t}=this.getActiveMainViewport(),{scrollX:i}=this.getActiveSheetScrollInfo();this.setSheetViewOffset(i,e);const{anchor:o}=this.getters.getSelection(),n=this.getActiveMainViewport().top-t;this.selection.selectCell(o.cell.col,o.cell.row+n)}getVisibleFigures(){const e=this.getters.getActiveSheetId(),t=[],i=this.getters.getFigures(e),{scrollX:o,scrollY:n}=this.getActiveSheetScrollInfo(),{x:s,y:r}=this.getters.getMainViewportCoordinates(),{width:a,height:l}=this.getters.getSheetViewDimensionWithHeaders();for(const e of i)e.x>=s&&(e.x+e.width<=s+o||e.x>=a+o+s)||e.y>=r&&(e.y+e.height<=r+n||e.y>=l+n+r)||t.push(e);return t}getFrozenSheetViewRatio(e){const{xSplit:t,ySplit:i}=this.getters.getPaneDivisions(e),o=this.getters.getColDimensions(e,t).start,n=this.getters.getRowDimensions(e,i).start;return{xRatio:o/(this.sheetViewWidth+this.gridOffsetX),yRatio:n/(this.sheetViewHeight+this.gridOffsetY)}}}rb.getters=["getColIndex","getRowIndex","getActiveMainViewport","getSheetViewDimension","getSheetViewDimensionWithHeaders","getMainViewportRect","isVisibleInViewport","getEdgeScrollCol","getEdgeScrollRow","getVisibleFigures","getVisibleRect","getColRowOffsetInViewport","getMainViewportCoordinates","getActiveSheetScrollInfo","getActiveSheetDOMScrollInfo","getSheetViewVisibleCols","getSheetViewVisibleRows","getFrozenSheetViewRatio"];class ab{constructor(e,t,i){this.index=0,this.cells=e,this.getters=t,this.direction=i}next(){const e=this.cells[this.index++%this.cells.length],t=e.rule,{cellData:i,tooltip:o}=Tn.get(t.type).apply(t,e.data,this.getters,this.direction);return{cellData:i,tooltip:o,origin:{col:e.data.col,row:e.data.row}}}}class lb extends Qv{constructor(){super(...arguments),this.lastCellSelected={}}allowDispatch(e){switch(e.type){case"AUTOFILL_SELECT":const t=this.getters.getActiveSheetId();return this.lastCellSelected.col=-1===e.col?this.lastCellSelected.col:ke(e.col,0,this.getters.getNumberCols(t)),this.lastCellSelected.row=-1===e.row?this.lastCellSelected.row:ke(e.row,0,this.getters.getNumberRows(t)),void 0!==this.lastCellSelected.col&&void 0!==this.lastCellSelected.row?0:45;case"AUTOFILL_AUTO":const i=this.getters.getSelectedZone();return i.top===i.bottom?0:1}return 0}handle(e){switch(e.type){case"AUTOFILL":this.autofill(!0);break;case"AUTOFILL_SELECT":this.select(e.col,e.row);break;case"AUTOFILL_AUTO":this.autofillAuto();break;case"AUTOFILL_CELL":this.autoFillMerge(e.originCol,e.originRow,e.col,e.row);const t=this.getters.getActiveSheetId();this.dispatch("UPDATE_CELL",{sheetId:t,col:e.col,row:e.row,style:e.style||null,content:e.content||"",format:e.format||""}),this.dispatch("SET_BORDER",{sheetId:t,col:e.col,row:e.row,border:e.border})}}getAutofillTooltip(){return this.tooltip}autofill(e){if(!this.autofillZone||!this.steps||void 0===this.direction)return void(this.tooltip=void 0);const t=this.getters.getSelectedZone(),i=this.autofillZone;switch(this.direction){case"down":for(let o=t.left;o<=t.right;o++){const n=[];for(let e=t.top;e<=t.bottom;e++)n.push(qt(o,e));const s=this.createGenerator(n);for(let t=i.top;t<=i.bottom;t++)this.computeNewCell(s,o,t,e)}break;case"up":for(let o=t.left;o<=t.right;o++){const n=[];for(let e=t.bottom;e>=t.top;e--)n.push(qt(o,e));const s=this.createGenerator(n);for(let t=i.bottom;t>=i.top;t--)this.computeNewCell(s,o,t,e)}break;case"left":for(let o=t.top;o<=t.bottom;o++){const n=[];for(let e=t.right;e>=t.left;e--)n.push(qt(e,o));const s=this.createGenerator(n);for(let t=i.right;t>=i.left;t--)this.computeNewCell(s,t,o,e)}break;case"right":for(let o=t.top;o<=t.bottom;o++){const n=[];for(let e=t.left;e<=t.right;e++)n.push(qt(e,o));const s=this.createGenerator(n);for(let t=i.left;t<=i.right;t++)this.computeNewCell(s,t,o,e)}}e&&(this.autofillZone=void 0,this.selection.resizeAnchorZone(this.direction,this.steps),this.lastCellSelected={},this.direction=void 0,this.steps=0,this.tooltip=void 0)}select(e,t){const i=this.getters.getSelectedZone();if(Qi(e,t,i))this.autofillZone=void 0;else{switch(this.direction=this.getDirection(e,t),this.direction){case"up":this.saveZone(t,i.top-1,i.left,i.right),this.steps=i.top-t;break;case"down":this.saveZone(i.bottom+1,t,i.left,i.right),this.steps=t-i.bottom;break;case"left":this.saveZone(i.top,i.bottom,e,i.left-1),this.steps=i.left-e;break;case"right":this.saveZone(i.top,i.bottom,i.right+1,e),this.steps=e-i.right}this.autofill(!1)}}autofillAuto(){var e,t;const i=this.getters.getSelectedZone(),o=this.getters.getActiveSheetId();let n=i.left,s=i.bottom;if(n>0){let t={sheetId:o,col:n-1,row:s};for(;this.getters.getEvaluatedCell(t).type!==ln.empty||(null===(e=this.getters.getCell(t))||void 0===e?void 0:e.content);)s+=1,t={sheetId:o,col:n-1,row:s}}if(s===i.bottom&&(n=i.right,n<=this.getters.getNumberCols(o))){let e={sheetId:o,col:n+1,row:s};for(;this.getters.getEvaluatedCell(e).type!==ln.empty||(null===(t=this.getters.getCell(e))||void 0===t?void 0:t.content);)s+=1,e={sheetId:o,col:n+1,row:s}}s!==i.bottom&&(this.select(i.left,s-1),this.autofill(!0))}computeNewCell(e,t,i,o){const{cellData:n,tooltip:s,origin:r}=e.next(),{content:a,style:l,border:c,format:h}=n;this.tooltip=s,o&&this.dispatch("AUTOFILL_CELL",{originCol:r.col,originRow:r.row,col:t,row:i,content:a,style:l,border:c,format:h})}getRule(e,t){const i=An.getAll().sort(((e,t)=>e.sequence-t.sequence)).find((i=>i.condition(e,t)));return i&&i.generateRule(e,t)}createGenerator(e){const t=[],i=[],o=this.getters.getActiveSheetId();for(let t of e){const{col:e,row:n}=Gt(t),s=this.getters.getCell({sheetId:o,col:e,row:n});i.push({col:e,row:n,cell:s,sheetId:o})}const n=i.map((e=>e.cell));for(let e of i){let i={type:"COPY_MODIFIER"};if(e&&e.cell){i=this.getRule(e.cell,n)||i}const o=this.getters.getCellBorder(e)||void 0;t.push({data:{...e,border:o},rule:i})}return new ab(t,this.getters,this.direction)}saveZone(e,t,i,o){this.autofillZone={top:e,bottom:t,left:i,right:o}}getDirection(e,t){const i=this.getters.getSelectedZone(),o={up:{number:i.top-t,value:"up"},down:{number:t-i.bottom,value:"down"},left:{number:i.left-e,value:"left"},right:{number:e-i.right,value:"right"}};if(1===Object.values(o).map((e=>e.number>0?1:0)).reduce(((e,t)=>e+t)))return Object.values(o).find((e=>e.number>0?1:0)).value;const n=o.up.number>0?"up":"down",s=o.left.number>0?"left":"right";return Math.abs(o[n].number)>=Math.abs(o[s].number)?o[n].value:o[s].value}autoFillMerge(e,t,i,o){const n=this.getters.getActiveSheetId(),s={sheetId:n,col:i,row:o},r={sheetId:n,col:e,row:t};if(this.getters.isInMerge(s)&&!this.getters.isInMerge(r)){const e=this.getters.getMerge(s);e&&this.dispatch("REMOVE_MERGE",{sheetId:n,target:[e]})}const a=this.getters.getMerge(r);(null==a?void 0:a.topLeft.col)===e&&(null==a?void 0:a.topLeft.row)===t&&this.dispatch("ADD_MERGE",{sheetId:n,target:[{top:o,bottom:o+a.bottom-a.top,left:i,right:i+a.right-a.left}]})}drawGrid(e){if(!this.autofillZone)return;const{ctx:t,thinLineWidth:i}=e,{x:o,y:n,width:s,height:r}=this.getters.getVisibleRect(this.autofillZone);s>0&&r>0&&(t.strokeStyle="black",t.lineWidth=i,t.setLineDash([3]),t.strokeRect(o,n,s,r),t.setLineDash([]))}}lb.layers=[5],lb.getters=["getAutofillTooltip"];class cb extends Qv{handle(e){if("SUM_SELECTION"===e.type){const e=this.getters.getActiveSheetId(),{zones:t,anchor:i}=this.getters.getSelection();for(const o of t){const t=this.getAutomaticSums(e,o,i.cell);this.dispatchCellUpdates(e,t)}}}getAutomaticSums(e,t,i){return this.shouldFindData(e,t)?this.sumAdjacentData(e,t,i):this.sumData(e,t)}sumData(e,t){const i=this.dimensionsToSum(e,t),o=this.sumDimensions(e,t,i).filter((({zone:t})=>!this.getters.isEmpty(e,t)));return i.has("ROW")&&i.has("COL")&&o.push(this.sumTotal(t)),o}sumAdjacentData(e,t,i){const{col:o,row:n}=Qi(i.col,i.row,t)?i:{col:t.left,row:t.top},s=this.findAdjacentData(e,o,n);return s?this.getters.isSingleCellOrMerge(e,t)||oo(ji(s,t))?[{position:{col:o,row:n},zone:s}]:this.sumDimensions(e,ji(s,t),this.transpose(this.dimensionsToSum(e,t))):[]}findAdjacentData(e,t,i){const o=this.getters.getSheet(e),n=this.getters.getMainCellPosition({sheetId:e,col:t,row:i}),s=this.findSuitableZoneToSum(o,n.col,n.row);if(s)return this.getters.expandZone(e,s)}findSuitableZoneToSum(e,t,i){const o=this.getters.getEvaluatedCell({sheetId:e.id,col:t,row:i-1}),n=this.getters.getEvaluatedCell({sheetId:e.id,col:t-1,row:i});if(this.isNumber(n)&&!this.isNumber(o))return this.findHorizontalZone(e,t,i);const s=this.findVerticalZone(e,t,i);if(this.isZoneValid(s))return s;const r=this.findHorizontalZone(e,t,i);return this.isZoneValid(r)?r:void 0}findVerticalZone(e,t,i){const o={top:0,bottom:i-1,left:t,right:t},n=this.reduceZoneStart(e,o,o.bottom);return{...o,top:n}}findHorizontalZone(e,t,i){const o={top:i,bottom:i,left:0,right:t-1},n=this.reduceZoneStart(e,o,o.right);return{...o,left:n}}reduceZoneStart(e,t,i){const o=this.getters.getEvaluatedCellsInZone(e.id,t),n=He(i,-1,-1),s=n.filter((e=>o[e]&&!o[e].isAutoSummable)),r=Math.max(...s),a=$e(n.filter((e=>this.isNumber(o[e]))))[0]||[];return Math.max(...a)<r?1/0:Math.min(...a)}shouldFindData(e,t){return this.getters.isEmpty(e,t)||this.getters.isSingleCellOrMerge(e,t)}isNumber(e){var t;return e.type===ln.number&&!(null===(t=e.format)||void 0===t?void 0:t.match(Y))}isZoneValid(e){return e.bottom>=e.top&&e.right>=e.left}lastColIsEmpty(e,t){return this.getters.isEmpty(e,{...t,left:t.right})}lastRowIsEmpty(e,t){return this.getters.isEmpty(e,{...t,top:t.bottom})}dimensionsToSum(e,t){const i=new Set;return oo(t)?(i.add(1===io(t).numberOfCols?"COL":"ROW"),i):(this.lastColIsEmpty(e,t)&&i.add("ROW"),this.lastRowIsEmpty(e,t)&&i.add("COL"),0===i.size&&i.add("COL"),i)}sumDimensions(e,t,i){return[...i.has("COL")?this.sumColumns(t,e):[],...i.has("ROW")?this.sumRows(t,e):[]]}sumTotal(e){const{bottom:t,right:i}=e;return{position:{col:i,row:t},zone:{...e,top:t,right:i-1}}}sumColumns(e,t){const i=this.nextEmptyRow(t,{...e,bottom:e.bottom-1});return e={...e,bottom:Math.min(e.bottom,i.bottom-1)},no(i).map((t=>({position:t,zone:{...e,right:t.col,left:t.col}})))}sumRows(e,t){const i=this.nextEmptyCol(t,{...e,right:e.right-1});return e={...e,right:Math.min(e.right,i.right-1)},no(i).map((t=>({position:t,zone:{...e,top:t.row,bottom:t.row}})))}dispatchCellUpdates(e,t){for(const i of t){const{col:t,row:o}=i.position;this.dispatch("UPDATE_CELL",{sheetId:e,col:t,row:o,content:`=SUM(${this.getters.zoneToXC(e,i.zone)})`})}}nextEmptyRow(e,t){let i=t.bottom+1;const{left:o,right:n}=t;for(;!this.getters.isEmpty(e,{bottom:i,top:i,left:o,right:n});)i++;return{...t,top:i,bottom:i}}nextEmptyCol(e,t){let i=t.right+1;const{top:o,bottom:n}=t;for(;!this.getters.isEmpty(e,{left:i,right:i,top:o,bottom:n});)i++;return{...t,left:i,right:i}}transpose(e){return new Set([...e.values()].map((e=>"COL"===e?"ROW":"COL")))}}cb.getters=["getAutomaticSums"];class hb extends Qv{allowDispatch(e){if("OPEN_CELL_POPOVER"===e.type){try{ds.get(e.popoverType)}catch(e){return 72}return 0}return 0}handle(e){switch(e.type){case"ACTIVATE_SHEET":case"CLOSE_CELL_POPOVER":this.persistentPopover=void 0;break;case"OPEN_CELL_POPOVER":this.persistentPopover={col:e.col,row:e.row,sheetId:this.getters.getActiveSheetId(),type:e.popoverType}}}getCellPopover({col:e,row:t}){var i,o;const n=this.getters.getActiveSheetId();if(this.persistentPopover&&this.getters.isVisibleInViewport(this.persistentPopover)){const e=this.getters.getMainCellPosition(this.persistentPopover),t=null===(o=(i=ds.get(this.persistentPopover.type)).onOpen)||void 0===o?void 0:o.call(i,e,this.getters);return(null==t?void 0:t.isOpen)?{...t,anchorRect:this.computePopoverAnchorRect(this.persistentPopover)}:{isOpen:!1}}if(void 0===e||void 0===t||!this.getters.isVisibleInViewport({sheetId:n,col:e,row:t}))return{isOpen:!1};const s=this.getters.getMainCellPosition({sheetId:n,col:e,row:t}),r=ds.getAll().map((e=>{var t;return null===(t=e.onHover)||void 0===t?void 0:t.call(e,s,this.getters)})).find((e=>null==e?void 0:e.isOpen));return(null==r?void 0:r.isOpen)?{...r,anchorRect:this.computePopoverAnchorRect(s)}:{isOpen:!1}}hasOpenedPopover(){return void 0!==this.persistentPopover}getPersistentPopoverTypeAtPosition({col:e,row:t}){if(this.persistentPopover&&this.persistentPopover.col===e&&this.persistentPopover.row===t)return this.persistentPopover.type}computePopoverAnchorRect({col:e,row:t}){const i=this.getters.getActiveSheetId(),o=this.getters.getMerge({sheetId:i,col:e,row:t});return o?this.getters.getVisibleRect(o):this.getters.getVisibleRect(lo({col:e,row:t}))}}hb.getters=["getCellPopover","getPersistentPopoverTypeAtPosition","hasOpenedPopover"];var db;!function(e){e[e.previous=-1]="previous",e[e.current=0]="current",e[e.next=1]="next"}(db||(db={}));class ub extends Qv{constructor(){super(...arguments),this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1},this.toSearch="",this.isSearchDirty=!1}handle(e){switch(e.type){case"UPDATE_SEARCH":this.updateSearch(e.toSearch,e.searchOptions);break;case"CLEAR_SEARCH":this.clearSearch();break;case"SELECT_SEARCH_PREVIOUS_MATCH":this.selectNextCell(db.previous);break;case"SELECT_SEARCH_NEXT_MATCH":this.selectNextCell(db.next);break;case"REPLACE_SEARCH":this.replace(e.replaceWith);break;case"REPLACE_ALL_SEARCH":this.replaceAll(e.replaceWith);break;case"UNDO":case"REDO":case"REMOVE_FILTER_TABLE":case"UPDATE_FILTER":case"REMOVE_COLUMNS_ROWS":case"HIDE_COLUMNS_ROWS":case"UNHIDE_COLUMNS_ROWS":case"ADD_COLUMNS_ROWS":case"EVALUATE_CELLS":case"UPDATE_CELL":this.isSearchDirty=!0;break;case"ACTIVATE_SHEET":this.refreshSearch()}}finalize(){this.isSearchDirty&&(this.refreshSearch(),this.isSearchDirty=!1)}getSearchMatches(){return this.searchMatches}getCurrentSelectedMatchIndex(){return this.selectedMatchIndex}updateSearch(e,t){this.searchOptions=t,e!==this.toSearch&&(this.selectedMatchIndex=null),this.toSearch=e,this.updateRegex(),this.refreshSearch()}refreshSearch(){const e=this.findMatches();this.searchMatches=e,this.selectNextCell(db.current)}updateRegex(){let e=Ne(this.toSearch);const t=this.searchOptions.matchCase?"":"i";this.searchOptions.exactMatch&&(e=`^${e}$`),this.currentSearchRegex=RegExp(e,t)}findMatches(){const e=this.getters.getActiveSheetId(),t=this.getters.getCells(e),i=[];if(this.toSearch)for(const o of Object.values(t)){const{col:t,row:n}=this.getters.getCellPosition(o.id),s=this.getters.isColHidden(e,t),r=this.getters.isRowHidden(e,n);if(!s&&!r&&(o&&this.currentSearchRegex&&this.currentSearchRegex.test(this.getSearchableString({sheetId:e,col:t,row:n})))){const e={col:t,row:n,selected:!1};i.push(e)}}return i.sort(this.sortByRowThenColumn)}sortByRowThenColumn(e,t){return e.row===t.row?e.col-t.col:e.row>t.row?1:-1}selectNextCell(e){const t=this.searchMatches;if(!t.length)return void(this.selectedMatchIndex=null);let i;i=null===this.selectedMatchIndex?0:this.selectedMatchIndex+e,i=(i%t.length+t.length)%t.length,this.selectedMatchIndex=i,this.selection.selectCell(t[i].col,t[i].row);for(let e=0;e<this.searchMatches.length;e++)this.searchMatches[e].selected=e===this.selectedMatchIndex}clearSearch(){this.toSearch="",this.searchMatches=[],this.selectedMatchIndex=null,this.currentSearchRegex=null,this.searchOptions={matchCase:!1,exactMatch:!1,searchFormulas:!1}}replaceMatch(e,t){if(!this.currentSearchRegex)return;const i=this.getters.getActiveSheetId(),o=this.getters.getCell({sheetId:i,...e}),{col:n,row:s}=e;if((null==o?void 0:o.isFormula)&&!this.searchOptions.searchFormulas)return;const r=new RegExp(this.currentSearchRegex.source,this.currentSearchRegex.flags+"g"),a=this.getSearchableString({sheetId:i,col:n,row:s}).replace(r,t);this.dispatch("UPDATE_CELL",{sheetId:i,col:n,row:s,content:a})}replace(e){if(null===this.selectedMatchIndex)return;const t=this.searchMatches[this.selectedMatchIndex];this.replaceMatch(t,e),this.selectNextCell(db.next)}replaceAll(e){const t=this.searchMatches.length;for(let i=0;i<t;i++)this.replaceMatch(this.searchMatches[i],e)}getSearchableString(e){const t=this.getters.getCell(e);return this.searchOptions.searchFormulas&&(null==t?void 0:t.isFormula)?t.content:this.getters.getEvaluatedCell(e).formattedValue}drawGrid(e){const{ctx:t}=e,i=this.getters.getActiveSheetId();for(const e of this.searchMatches){const o=this.getters.getMerge({sheetId:i,col:e.col,row:e.row}),n=o?o.left:e.col,s=o?o.right:e.col,r=o?o.top:e.row,a=o?o.bottom:e.row,{x:l,y:c,width:h,height:d}=this.getters.getVisibleRect({top:r,left:n,right:s,bottom:a});h>0&&d>0&&(t.fillStyle="#8B008B33",t.fillRect(l,c,h,d),e.selected&&(t.strokeStyle="#8B008B",t.strokeRect(l,c,h,d)))}}}ub.layers=[3],ub.getters=["getSearchMatches","getCurrentSelectedMatchIndex"];class gb extends Qv{isRowHidden(e,t){return this.getters.isRowHiddenByUser(e,t)||this.getters.isRowFiltered(e,t)}isColHidden(e,t){return this.getters.isColHiddenByUser(e,t)}isHeaderHidden(e,t,i){return"COL"===t?this.isColHidden(e,i):this.isRowHidden(e,i)}getNextVisibleCellPosition({sheetId:e,col:t,row:i}){return{sheetId:e,col:this.findVisibleHeader(e,"COL",t,this.getters.getNumberCols(e)-1),row:this.findVisibleHeader(e,"ROW",i,this.getters.getNumberRows(e)-1)}}findVisibleHeader(e,t,i,o){if(i<=o)for(let n=i;n<=o;n++)if(this.getters.doesHeaderExist(e,t,n)&&!this.isHeaderHidden(e,t,n))return n;if(i>o)for(let n=i;n>=o;n--)if(this.getters.doesHeaderExist(e,t,n)&&!this.isHeaderHidden(e,t,n))return n}findLastVisibleColRowIndex(e,t,{last:i,first:o}){return He(i,o,-1).find((i=>!this.isHeaderHidden(e,t,i)))||o}findFirstVisibleColRowIndex(e,t){const i=this.getters.getNumberHeaders(e,t);for(let o=0;o<i;o++){if("COL"===t&&!this.isColHidden(e,o))return o;if("ROW"===t&&!this.isRowHidden(e,o))return o}}exportForExcel(e){for(const t of e.sheets)for(const[e,i]of Object.entries(t.rows)){const o=this.isRowHidden(t.id,Number(e));i.isHidden=o}}}gb.getters=["getNextVisibleCellPosition","findVisibleHeader","findLastVisibleColRowIndex","findFirstVisibleColRowIndex","isRowHidden","isColHidden","isHeaderHidden"];class pb extends Qv{getHighlights(){return this.prepareHighlights(this.getters.getComposerHighlights().concat(this.getters.getSelectionInputHighlights()))}prepareHighlights(e){return e.filter((e=>e.zone.top>=0&&e.zone.left>=0&&e.zone.bottom<this.getters.getNumberRows(e.sheetId)&&e.zone.right<this.getters.getNumberCols(e.sheetId))).map((e=>{const{numberOfRows:t,numberOfCols:i}=io(e.zone),o=t*i==1?this.getters.expandZone(e.sheetId,e.zone):e.zone;return{...e,zone:o}}))}drawGrid(e){const{ctx:t,thinLineWidth:i}=e,o=this.getters.getActiveSheetId(),n=3*i;t.lineWidth=n;const s=this.getHighlights();for(let e of s.filter(((e,t)=>s.findIndex((t=>Yi(t.zone,e.zone)&&t.sheetId===o))===t))){const{x:i,y:o,width:s,height:r}=this.getters.getVisibleRect(e.zone);s>0&&r>0&&(t.strokeStyle=e.color,t.strokeRect(i+n/2,o+n/2,s-n,r-n),t.globalCompositeOperation="source-over",t.fillStyle=e.color+"20",t.fillRect(i+n,o+n,s-2*n,r-2*n))}}}pb.layers=[1],pb.getters=["getHighlights"];class mb extends Qv{constructor(){super(...arguments),this.boxes=[]}getColDimensionsInViewport(e,t){const i=Math.min(...this.getters.getSheetViewVisibleCols()),o=this.getters.getColRowOffsetInViewport("COL",i,t),n=this.getters.getColSize(e,t);return{start:o,size:n,end:o+(this.getters.isColHidden(e,t)?0:n)}}getRowDimensionsInViewport(e,t){const i=Math.min(...this.getters.getSheetViewVisibleRows()),o=this.getters.getColRowOffsetInViewport("ROW",i,t),n=this.getters.getRowSize(e,t);return{start:o,size:n,end:o+(this.getters.isRowHidden(e,t)?0:n)}}getHeaderOffset(e,t,i){let o=this.getters.getColRowOffsetInViewport(e,t,i);return this.getters.isDashboard()||(o+="ROW"===e?N:_),o}drawGrid(e,t){switch(t){case 0:this.boxes=this.getGridBoxes(),this.drawBackground(e),this.drawOverflowingCellBackground(e),this.drawCellBackground(e),this.drawBorders(e),this.drawTexts(e),this.drawIcon(e),this.drawFrozenPanes(e);break;case 7:this.getters.isDashboard()||(this.drawHeaders(e),this.drawFrozenPanesHeaders(e))}}drawBackground(e){const{ctx:t,thinLineWidth:i}=e,{width:o,height:n}=this.getters.getSheetViewDimensionWithHeaders();t.fillStyle="#ffffff",t.fillRect(0,0,o+m,n+m);const s=!this.getters.isDashboard()&&this.getters.getGridLinesVisibility(this.getters.getActiveSheetId()),r=s?.1*i:0;if(s)for(const e of this.boxes)t.strokeStyle="#E2E3E3",t.lineWidth=i,t.strokeRect(e.x+r,e.y+r,e.width-2*r,e.height-2*r)}drawCellBackground(e){const{ctx:t}=e;for(const e of this.boxes){let i=e.style;i.fillColor&&"#ffffff"!==i.fillColor&&(t.fillStyle=i.fillColor||"#ffffff",t.fillRect(e.x,e.y,e.width,e.height)),e.error&&(t.fillStyle="red",t.beginPath(),t.moveTo(e.x+e.width-5,e.y),t.lineTo(e.x+e.width,e.y),t.lineTo(e.x+e.width,e.y+5),t.fill())}}drawOverflowingCellBackground(e){var t,i;const{ctx:o,thinLineWidth:n}=e;for(const e of this.boxes)if(e.content&&e.isOverflow){const s=e.content.align||"left";let r,a;const l=e.y+n/2,c=e.height-n,h=Math.min((null===(t=e.clipRect)||void 0===t?void 0:t.width)||1/0,e.content.width);"left"===s?(r=e.x+n/2,a=h-2*n):"right"===s?(r=e.x+e.width-n/2,a=2*n-h):(r=((null===(i=e.clipRect)||void 0===i?void 0:i.x)||e.x+e.width/2-e.content.width/2)+n/2,a=h-2*n),o.fillStyle="#ffffff",o.fillRect(r,l,a,c)}}drawBorders(e){const{ctx:t,thinLineWidth:i}=e;for(let e of this.boxes){const t=e.border;if(t){const{x:i,y:n,width:s,height:r}=e;t.left&&o(t.left,i,n,i,n+r),t.top&&o(t.top,i,n,i+s,n),t.right&&o(t.right,i+s,n,i+s,n+r),t.bottom&&o(t.bottom,i,n+r,i+s,n+r)}}function o([e,o],n,s,r,a){t.strokeStyle=o,t.lineWidth=("thin"===e?2:3)*i,t.beginPath(),t.moveTo(n,s),t.lineTo(r,a),t.stroke()}}drawTexts(e){const{ctx:t,thinLineWidth:i}=e;let o;t.textBaseline="top";for(let e of this.boxes)if(e.content){const n=e.style||{},s=e.content.align||"left",r=ze(n);r!==o&&(o=r,t.font=r),t.fillStyle=n.textColor||"#000";let a=e.x;if(a+="left"===s?V+(e.image?e.image.size+U:0):"right"===s?e.width-V-(e.isFilterHeader?20:0):e.width/2,t.textAlign=s,e.clipRect){t.save(),t.beginPath();const{x:i,y:o,width:n,height:s}=e.clipRect;t.rect(i,o,n,s),t.clip()}const l=Be(n),c=e.content.textLines.length;let h=this.computeTextYCoordinate(e,l,c);for(let o of e.content.textLines){if(t.fillText(o,Math.round(a),Math.round(h)),n.strikethrough||n.underline){const e=Pe(t,o,n);let r=a;"right"===s?r-=e:"center"===s&&(r-=e/2),n.strikethrough&&t.fillRect(r,h+l/2,e,2.6*i),n.underline&&t.fillRect(r,h+l+1,e,1.3*i)}h+=V+l}e.clipRect&&t.restore()}}drawIcon(e){const{ctx:t}=e;for(const e of this.boxes)if(e.image){const i=e.image.image;if(e.image.clipIcon){t.save(),t.beginPath();const{x:i,y:o,width:n,height:s}=e.image.clipIcon;t.rect(i,o,n,s),t.clip()}const o=e.image.size,n=this.computeTextYCoordinate(e,o);t.drawImage(i,e.x+U,n,o,o),e.image.clipIcon&&t.restore()}}computeTextYCoordinate(e,t,i=1){const o=e.y+1,n=Le(t,i),s=e.height>n+2*V,r=e.verticalAlign||"middle";if(s){if("middle"===r)return o+(e.height-n)/2;if("bottom"===r)return o+e.height-n-V}return o+V}drawHeaders(e){const{ctx:t,thinLineWidth:i}=e,o=this.getters.getSheetViewVisibleCols(),n=o[0],s=o[o.length-1],r=this.getters.getSheetViewVisibleRows(),a=r[0],l=r[r.length-1],{width:c,height:h}=this.getters.getSheetViewDimensionWithHeaders(),d=this.getters.getSelectedZones(),u=function(e){const t=new Set;for(let i of e)for(let e of He(i.left,i.right+1))t.add(e);return t}(d),g=function(e){const t=new Set;for(let i of e)for(let e of He(i.top,i.bottom+1))t.add(e);return t}(d),p=this.getters.getActiveSheetId(),m=this.getters.getNumberCols(p),f=this.getters.getNumberRows(p),E=this.getters.getActiveCols(),w=this.getters.getActiveRows();t.font=`400 11px ${Z}`,t.textAlign="center",t.textBaseline="middle",t.lineWidth=i,t.strokeStyle="#333";for(let e=n;e<=s;e++){const i={left:e,right:e,top:0,bottom:f-1},{x:o,width:n}=this.getters.getVisibleRect(i),s=this.getters.doesZonesContainFilter(p,[i]),r=E.has(e),a=u.has(e);t.fillStyle=r?s?R:S:a?s?A:b:s?T:v,t.fillRect(o,0,n,N)}for(let e=a;e<=l;e++){const i={top:e,bottom:e,left:0,right:m-1},{y:o,height:n}=this.getters.getVisibleRect(i),s=this.getters.doesZonesContainFilter(p,[i]),r=w.has(e),a=g.has(e);t.fillStyle=r?s?R:S:a?s?A:b:s?T:v,t.fillRect(0,o,_,n)}t.beginPath(),t.moveTo(_,0),t.lineTo(_,h),t.moveTo(0,N),t.lineTo(c,N),t.strokeStyle="#C0C0C0",t.stroke(),t.beginPath();for(const e of o){const i=this.getters.getColSize(p,e),o=$t(e);t.fillStyle=E.has(e)?"#fff":C;let s=this.getHeaderOffset("COL",n,e);t.fillText(o,s+i/2,13),t.moveTo(s+i,0),t.lineTo(s+i,N)}for(const e of r){const i=this.getters.getRowSize(p,e);t.fillStyle=w.has(e)?"#fff":C;let o=this.getHeaderOffset("ROW",a,e);t.fillText(String(e+1),24,o+i/2),t.moveTo(0,o+i),t.lineTo(_,o+i)}t.stroke()}drawFrozenPanesHeaders(e){const{ctx:t,thinLineWidth:i}=e,{x:o,y:n}=this.getters.getMainViewportCoordinates(),s=this.getters.isDashboard()?0:_,r=this.getters.isDashboard()?0:N;t.lineWidth=6*i,t.strokeStyle="#BCBCBC",t.beginPath(),o&&(t.moveTo(s+o,0),t.lineTo(s+o,r)),n&&(t.moveTo(0,r+n),t.lineTo(s,r+n)),t.stroke()}drawFrozenPanes(e){const{ctx:t,thinLineWidth:i}=e,{x:o,y:n}=this.getters.getMainViewportCoordinates(),s=this.getters.getSheetViewVisibleCols(),r=s[0],a=s[s.length-1],l=this.getters.getSheetViewVisibleRows(),c={left:r,right:a,top:l[0],bottom:l[l.length-1]},h=this.getters.getVisibleRect(c),d=this.getters.isDashboard()?0:_,u=this.getters.isDashboard()?0:N;t.lineWidth=6*i,t.strokeStyle="#DADFE8",t.beginPath(),o&&(t.moveTo(d+o,u),t.lineTo(d+o,h.height+u)),n&&(t.moveTo(d,u+n),t.lineTo(h.width+d,u+n)),t.stroke()}findNextEmptyCol(e,t,i){const o=this.getters.getActiveSheetId();let n=e;for(;n<t;){const e={sheetId:o,col:n+1,row:i},t=this.getters.getEvaluatedCell(e),s=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==ln.empty||this.getters.isInMerge(e)||(null==s?void 0:s.left))return n;n++}return n}findPreviousEmptyCol(e,t,i){const o=this.getters.getActiveSheetId();let n=e;for(;n>t;){const e={sheetId:o,col:n-1,row:i},t=this.getters.getEvaluatedCell(e),s=this.getters.getCellBorderWithFilterBorder(e);if(t.type!==ln.empty||this.getters.isInMerge(e)||(null==s?void 0:s.right))return n;n--}return n}computeCellAlignment(e,t){const i=this.getters.getCell(e);if((null==i?void 0:i.isFormula)&&this.getters.shouldShowFormulas())return"left";const{align:o}=this.getters.getCellStyle(e),n=this.getters.getEvaluatedCell(e);return t&&n.type===ln.number?"center"!==o?"left":o:o||n.defaultAlign}createZoneBox(e,t,i){const{left:o,right:n}=i,s=t.left,r=t.top,a={sheetId:e,col:s,row:r},c=this.getters.getEvaluatedCell(a),h=this.getters.shouldShowFormulas(),{x:d,y:u,width:g,height:p}=this.getters.getVisibleRect(t),{verticalAlign:m}=this.getters.getCellStyle(a),f={x:d,y:u,width:g,height:p,border:this.getters.getCellBorderWithFilterBorder(a)||void 0,style:this.getters.getCellComputedStyle(a),verticalAlign:m};if(c.type===ln.empty)return f;const v=this.getters.getConditionalIcon(a),b=Be(f.style),S=v?U+b:0;v&&(f.image={type:"icon",size:b,clipIcon:{x:f.x,y:f.y,width:Math.min(S,g),height:p},image:Ag[v].img}),f.isFilterHeader=this.getters.isFilterHeader(a);const C=f.isFilterHeader?19:0,E=this.getters.getCellComputedStyle(a),w=E.wrapping||"overflow",y="wrap"!==w||h?void 0:g-2*V,x=this.getters.getCellMultiLineText(a,y),I=Math.max(...x.map((e=>this.getters.getTextWidth(e,E)+V))),R=S+I+C,T=this.computeCellAlignment(a,R>g);f.content={textLines:x,width:"overflow"===w?I:g,align:T},c.type===ln.error&&c.error.logLevel>l.silent&&(f.error=c.error.message);const A=R>g||b>p;if(v||f.isFilterHeader)f.clipRect={x:f.x+S,y:f.y,width:Math.max(0,g-S-C),height:p};else if(A&&"overflow"===w){let e,i;switch(this.getters.isInMerge(a)?(e=this.getters.getMerge(a).right,i=s):(e=this.findNextEmptyCol(s,n,r),i=this.findPreviousEmptyCol(s,o,r),f.isOverflow=!0),T){case"left":{const i=lo({col:e,row:r}),{x:o,y:n,width:s,height:a}=this.getters.getVisibleRect(ji(t,i));(s<R||b>a||x.length>1)&&(f.clipRect={x:o,y:n,width:s,height:a});break}case"right":{const e=lo({col:i,row:r}),{x:o,y:n,width:s,height:a}=this.getters.getVisibleRect(ji(t,e));(s<R||b>a||x.length>1)&&(f.clipRect={x:o,y:n,width:s,height:a});break}case"center":{const o={...t,left:i,right:e},{x:n,y:s,height:r,width:a}=this.getters.getVisibleRect(o),l=R/2,c=f.x+f.width/2;if(n+a<c+l||n>c-l||b>r||x.length>1){const e=n>c-l?n:c-l,t=n+a-e;f.clipRect={x:e,y:s,width:t,height:r}}break}}}else("clip"===w||"wrap"===w||x.length>1)&&(f.clipRect={x:f.x,y:f.y,width:g,height:p});return f}getGridBoxes(){const e=[],t=this.getters.getSheetViewVisibleCols(),i=t[0],o=t[t.length-1],n=this.getters.getSheetViewVisibleRows(),s={left:i,right:o,top:n[0],bottom:n[n.length-1]},r=this.getters.getActiveSheetId();for(const i of n)for(const o of t){const t={sheetId:r,col:o,row:i};this.getters.isInMerge(t)||e.push(this.createZoneBox(r,lo(t),s))}for(const t of this.getters.getMerges(r))if(!this.getters.isMergeHidden(r,t)&&Ki(t,s)){const i=this.createZoneBox(r,t,s),o=this.getters.getCellBorder({sheetId:r,col:t.right,row:t.bottom});i.border={...i.border,bottom:o?o.bottom:void 0,right:o?o.right:void 0},i.isMerge=!0,e.push(i)}return e}}mb.layers=[0,7],mb.getters=["getColDimensionsInViewport","getRowDimensionsInViewport"];class fb extends Qv{constructor(e,t,i){if(i&&t.length>1)throw new Error("Input with a single range cannot be instantiated with several range references.");super(e),this.inputHasSingleRange=i,this.ranges=[],this.focusedRangeIndex=null,this.willAddNewRange=!1,this.insertNewRange(0,t),this.activeSheet=this.getters.getActiveSheetId(),0===this.ranges.length&&(this.insertNewRange(this.ranges.length,[""]),this.focusLast())}allowDispatch(e){switch(e.type){case"ADD_EMPTY_RANGE":if(this.inputHasSingleRange&&1===this.ranges.length)return 30;break;case"CHANGE_RANGE":if(this.inputHasSingleRange&&e.value.split(",").length>1)return 30}return 0}handleEvent(e){const t=$i(e.anchor.zone),i=this.activeSheet,o=this.getters.getActiveSheetId(),n=this.getters.getSheetName(o);this.add([o===i?t:`${De(n)}!${t}`])}handle(e){switch(e.type){case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"FOCUS_RANGE":this.focus(this.getIndex(e.rangeId));break;case"CHANGE_RANGE":{const t=this.getIndex(e.rangeId);if(null!==t&&this.focusedRangeIndex!==t&&this.focus(t),null!==t){const i=e.value.replace(/^,+/,"").split(",").map((e=>e.trim()));this.setRange(t,i)}break}case"ADD_EMPTY_RANGE":this.insertNewRange(this.ranges.length,[""]),this.focusLast();break;case"REMOVE_RANGE":const t=this.getIndex(e.rangeId);null!==t&&this.removeRange(t);break;case"STOP_SELECTION_INPUT":this.willAddNewRange=!1;break;case"PREPARE_SELECTION_INPUT_EXPANSION":{const e=this.focusedRangeIndex;null===e||this.inputHasSingleRange||(this.willAddNewRange=""!==this.ranges[e].xc.trim());break}case"ACTIVATE_SHEET":if(e.sheetIdFrom!==e.sheetIdTo){const{col:t,row:i}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0}),o=this.getters.expandZone(e.sheetIdTo,lo({col:t,row:i}));this.selection.resetAnchor(this,{cell:{col:t,row:i},zone:o})}}}getSelectionInputValue(){return this.cleanInputs(this.ranges.map((e=>e.xc?e.xc:"")))}getSelectionInputHighlights(){return this.ranges.map((e=>this.inputToHighlights(e))).flat()}focus(e){this.focusedRangeIndex=e}focusLast(){this.focus(this.ranges.length-1)}unfocus(){this.focusedRangeIndex=null}add(e){null!==this.focusedRangeIndex&&0!==e.length&&(this.willAddNewRange?(this.insertNewRange(this.ranges.length,e),this.focusLast(),this.willAddNewRange=!1):this.setRange(this.focusedRangeIndex,e))}setContent(e,t){this.ranges[e]={...this.ranges[e],xc:t}}insertNewRange(e,t){const i=Math.max(0,...this.ranges.map((e=>Number(e.id))));this.ranges.splice(e,0,...t.map(((e,t)=>({xc:e,id:i+t+1,color:St[(i+t)%St.length]}))))}setRange(e,t){const[,...i]=t;this.setContent(e,t[0]),this.insertNewRange(e+1,i),i.length&&this.focus(e+i.length)}removeRange(e){this.ranges.splice(e,1),null!==this.focusedRangeIndex&&this.focusLast()}inputToHighlights({xc:e,color:t}){const i=this.cleanInputs([e]).filter((e=>this.getters.isRangeValid(e))).filter((e=>this.shouldBeHighlighted(this.activeSheet,e)));return i.map((e=>{const{sheetName:i}=Ht(e);return{zone:this.getters.getRangeFromSheetXC(this.activeSheet,e).zone,sheetId:i&&this.getters.getSheetIdByName(i)||this.activeSheet,color:t}}))}cleanInputs(e){return e.map((e=>e.split(","))).flat().map((e=>e.trim())).filter((e=>""!==e))}shouldBeHighlighted(e,t){const{sheetName:i}=Ht(t),o=this.getters.getSheetIdByName(i),n=this.getters.getActiveSheet().id;return this.getters.isRangeValid(t)&&(o===n||void 0===o&&n===e)}getIndex(e){const t=this.ranges.findIndex((t=>t.id===e));return t>=0?t:null}}fb.layers=[1],fb.getters=[];class vb extends Qv{get currentInput(){return this.focusedInputId?this.inputs[this.focusedInputId]:null}constructor(e){super(e),this.config=e,this.inputs={},this.focusedInputId=null}allowDispatch(e){var t,i;if("FOCUS_RANGE"===e.type){const o=null===(t=this.currentInput)||void 0===t?void 0:t.getIndex(e.rangeId);if(this.focusedInputId===e.id&&(null===(i=this.currentInput)||void 0===i?void 0:i.focusedRangeIndex)===o)return 29}return this.currentInput?this.currentInput.allowDispatch(e):0}handle(e){var t;switch(e.type){case"ENABLE_NEW_SELECTION_INPUT":this.initInput(e.id,e.initialRanges||[],e.hasSingleRange);break;case"DISABLE_SELECTION_INPUT":this.focusedInputId===e.id&&this.unfocus(),delete this.inputs[e.id];break;case"UNFOCUS_SELECTION_INPUT":this.unfocus();break;case"ADD_EMPTY_RANGE":case"REMOVE_RANGE":if(e.id!==this.focusedInputId){const t=this.inputs[e.id];this.selection.capture(t,{cell:{col:0,row:0},zone:lo({col:0,row:0})},{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e.id}break;case"FOCUS_RANGE":case"CHANGE_RANGE":if(e.id!==this.focusedInputId){const t=this.inputs[e.id],i=t.ranges.find((t=>t.id===e.rangeId)),o=this.getters.getActiveSheetId(),n=this.getters.getRangeFromSheetXC(o,(null==i?void 0:i.xc)||"A1").zone;this.selection.capture(t,{cell:{col:n.left,row:n.top},zone:n},{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e.id}}null===(t=this.currentInput)||void 0===t||t.handle(e)}getSelectionInput(e){return this.inputs[e]?this.inputs[e].ranges.map(((t,i)=>Object.assign({},t,{color:this.focusedInputId===e&&null!==this.inputs[e].focusedRangeIndex&&this.isRangeValid(t.xc)?t.color:null,isFocused:this.focusedInputId===e&&this.inputs[e].focusedRangeIndex===i}))):[]}isRangeValid(e){if(!e)return!1;const{xc:t,sheetName:i}=Ht(e);return null!==t.match(Lt)&&(!i||void 0!==this.getters.getSheetIdByName(i))}getSelectionInputValue(e){return this.inputs[e].getSelectionInputValue()}getSelectionInputHighlights(){return this.focusedInputId?this.inputs[this.focusedInputId].getSelectionInputHighlights():[]}initInput(e,t,i=!1){if(this.inputs[e]=new fb(this.config,t,i),0===t.length){const t=this.inputs[e],i={zone:lo({col:0,row:0}),cell:{col:0,row:0}};this.selection.capture(t,i,{handleEvent:t.handleEvent.bind(t)}),this.focusedInputId=e}}unfocus(){this.selection.release(this.currentInput),this.focusedInputId=null}}vb.layers=[1],vb.getters=["getSelectionInput","getSelectionInputValue","isRangeValid","getSelectionInputHighlights"];class bb{constructor(){this.subscriptions={}}on(e,t,i){if(!i)throw new Error("Missing callback");this.subscriptions[e]||(this.subscriptions[e]=[]),this.subscriptions[e].push({owner:t,callback:i})}trigger(e,t){const i=this.subscriptions[e]||[];for(let e=0,o=i.length;e<o;e++){const o=i[e];o.callback.call(o.owner,t)}}off(e,t){const i=this.subscriptions[e];i&&(this.subscriptions[e]=i.filter((e=>e.owner!==t)))}clear(){this.subscriptions={}}}function Sb(e,t){return{...e,definition:Ir(e.definition,t)}}function Cb(e,t){if(e.sheetId!==t.sheetId)return e;if(("FREEZE_COLUMNS"===e.type?"COL":"ROW")!==t.dimension)return e;let i=e.quantity;if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));for(let t of e)i>t&&i--}if("ADD_COLUMNS_ROWS"===t.type){i=i>("before"===t.position?t.base-1:t.base)?i+t.quantity:i}return i>0?{...e,quantity:i}:void 0}sg.addTransformation("ADD_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],Sb),sg.addTransformation("REMOVE_COLUMNS_ROWS",["CREATE_CHART","UPDATE_CHART"],Sb),sg.addTransformation("DELETE_SHEET",["MOVE_RANGES"],(function(e,t){const i=t.sheetId;if(e.targetSheetId===i||e.sheetId===i)return;return e})),sg.addTransformation("DELETE_FIGURE",["UPDATE_FIGURE","UPDATE_CHART"],(function(e,t){if(e.id===t.id)return;return e})),sg.addTransformation("CREATE_SHEET",["CREATE_SHEET"],(function(e,t){var i;if(e.name===t.name)return{...e,name:(null===(i=e.name)||void 0===i?void 0:i.match(/\d+/))?e.name.replace(/\d+/,(e=>(parseInt(e)+1).toString())):`${e.name}~`,position:e.position+1};return e})),sg.addTransformation("ADD_MERGE",["ADD_MERGE","REMOVE_MERGE","CREATE_FILTER_TABLE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;const i=[];for(const o of e.target)for(const e of t.target)Ki(o,e)||i.push({...o});if(i.length)return{...e,target:i};return})),sg.addTransformation("ADD_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],Cb),sg.addTransformation("REMOVE_COLUMNS_ROWS",["FREEZE_COLUMNS","FREEZE_ROWS"],Cb),sg.addTransformation("CREATE_FILTER_TABLE",["CREATE_FILTER_TABLE","ADD_MERGE"],(function(e,t){if(e.sheetId!==t.sheetId)return e;for(const i of e.target)for(const e of t.target)if(Ki(e,i))return;return e}));const Eb=[{match:function(e){return"sheetId"in e},fn:xb},{match:function(e){return"target"in e&&"sheetId"in e},fn:function(e,t){const i=xb(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;const o=[];for(const i of e.target){const e=ps(i,t);e&&o.push(e)}if(!o.length)return"IGNORE_COMMAND";return{...e,target:o}}},{match:function(e){return"col"in e&&"row"in e&&"sheetId"in e},fn:function(e,t){const i=xb(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type)return function(e,t){const i="COL"===t.dimension?"col":"row";let o=e[i];if("REMOVE_COLUMNS_ROWS"===t.type){const e=[...t.elements].sort(((e,t)=>t-e));if(e.includes(o))return"IGNORE_COMMAND";for(let t of e)o>=t&&o--}"ADD_COLUMNS_ROWS"===t.type&&(o>t.base||o===t.base&&"before"===t.position)&&(o+=t.quantity);return{...e,[i]:o}}(e,t);if("ADD_MERGE"===t.type)return function(e,t){for(const i of t.target){if(!(e.col===i.left&&e.row===i.top)&&Qi(e.col,e.row,i))return"IGNORE_COMMAND"}return e}(e,t);return"SKIP_TRANSFORMATION"}},{match:function(e){return"dimension"in e&&"sheetId"in e},fn:function(e,t){const i=xb(e,t);if("SKIP_TRANSFORMATION"!==i)return"IGNORE_COMMAND"===i?"IGNORE_COMMAND":e;if("ADD_COLUMNS_ROWS"===t.type||"REMOVE_COLUMNS_ROWS"===t.type){if(t.dimension!==e.dimension)return e;const i="ADD_COLUMNS_ROWS"===e.type,o=i?"base":"elements";let n=i?[e[o]]:e[o];if("REMOVE_COLUMNS_ROWS"===t.type&&(n=n.map((e=>{if(t.elements.includes(e))return;const i=t.elements.sort(((e,t)=>t-e));for(let t of i)e>t&&e--;return e})).filter(it)),"ADD_COLUMNS_ROWS"===t.type){const e="before"===t.position?t.base-1:t.base;n=n.map((i=>i>e?i+t.quantity:i))}if(n.length){let t=n;return i&&(t=n[0]),{...e,[o]:t}}return"IGNORE_COMMAND"}return"SKIP_TRANSFORMATION"}},{match:function(e){return"ranges"in e},fn:function(e,t){const i=[],o="DELETE_SHEET"===t.type&&t.sheetId;for(const n of e.ranges)if(n._sheetId!==t.sheetId)i.push({...n,_zone:n._zone});else{const e=ps(n._zone,t);e&&o!==n._sheetId&&i.push({...n,_zone:e})}if(!i.length)return"IGNORE_COMMAND";return{...e,ranges:i}}}];function wb(e,t){const i=sg.getTransformation(e.type,t.type);return i?i(e,t):function(e,t){for(const{match:i,fn:o}of Eb)if(i(e)){const i=o(e,t);if("SKIP_TRANSFORMATION"===i)continue;if("IGNORE_COMMAND"===i)return;e=i}return e}(e,t)}function yb(e,t){let i=[...e];for(const e of t)i=i.map((t=>wb(t,e))).filter(it);return i}function xb(e,t){const i="DELETE_SHEET"===t.type&&t.sheetId;return e.sheetId===i?"IGNORE_COMMAND":"CREATE_SHEET"===e.type||"CREATE_SHEET"===t.type||e.sheetId!==t.sheetId?e:"SKIP_TRANSFORMATION"}class Ib{constructor(e,t,i,o){this._commands=[],this._changes=[],this.id=e,this.clientId=t,this._commands=[...i],this._changes=o?[...o]:[]}setChanges(e){this._changes=e}get commands(){return this._commands}get changes(){return this._changes}}class Rb extends Error{}class Tb extends bb{constructor(e,t,i=Q){super(),this.revisions=e,this.transportService=t,this.serverRevisionId=i,this.clients={},this.clientId="local",this.pendingMessages=[],this.waitingAck=!1,this.waitingUndoRedoAck=!1,this.isReplayingInitialRevisions=!1,this.processedRevisions=new Set,this.uuidGenerator=new Vi,this.debouncedMove=function(e,t,i){let o;return function(){const n=this,s=arguments,r=i&&!o;clearTimeout(o),o=setTimeout((function(){o=null,i||e.apply(n,s)}),t),r&&e.apply(n,s)}}(this._move.bind(this),200)}canApplyOptimisticUpdate(){return!this.waitingUndoRedoAck}save(e,t){if(!e.length||!t.length||!this.canApplyOptimisticUpdate())return;const i=new Ib(this.uuidGenerator.uuidv4(),this.clientId,e,t);this.revisions.append(i.id,i),this.trigger("new-local-state-update",{id:i.id}),this.sendUpdateMessage({type:"REMOTE_REVISION",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:i.id,clientId:i.clientId,commands:i.commands})}undo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_UNDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),undoneRevisionId:e})}redo(e){this.waitingUndoRedoAck=!0,this.sendUpdateMessage({type:"REVISION_REDONE",version:1,serverRevisionId:this.serverRevisionId,nextRevisionId:this.uuidGenerator.uuidv4(),redoneRevisionId:e})}move(e){this.debouncedMove(e)}join(e){e?(this.clients[e.id]=e,this.clientId=e.id):(this.clients.local={id:"local",name:"local"},this.clientId="local"),this.transportService.onNewMessage(this.clientId,this.onMessageReceived.bind(this))}loadInitialMessages(e){this.isReplayingInitialRevisions=!0;for(const t of e)this.onMessageReceived(t);this.isReplayingInitialRevisions=!1}leave(){delete this.clients[this.clientId],this.transportService.leave(this.clientId),this.transportService.sendMessage({type:"CLIENT_LEFT",clientId:this.clientId,version:1})}snapshot(e){const t=this.uuidGenerator.uuidv4();this.transportService.sendMessage({type:"SNAPSHOT",nextRevisionId:t,serverRevisionId:this.serverRevisionId,data:{...e,revisionId:t},version:1})}getClient(){const e=this.clients[this.clientId];if(!e)throw new Rb("The client left the session");return e}getConnectedClients(){return new Set(Object.values(this.clients).filter(it))}getRevisionId(){return this.serverRevisionId}isFullySynchronized(){return 0===this.pendingMessages.length}_move(e){var t;if(!this.clients[this.clientId])return;const i=null===(t=this.clients[this.clientId])||void 0===t?void 0:t.position;if((null==i?void 0:i.col)===e.col&&i.row===e.row&&i.sheetId===e.sheetId)return;const o=i?"CLIENT_MOVED":"CLIENT_JOINED",n=this.getClient();this.clients[this.clientId]={...n,position:e},this.transportService.sendMessage({type:o,version:1,client:{...n,position:e}})}onMessageReceived(e){if(!this.isAlreadyProcessed(e))if(this.isWrongServerRevisionId(e))this.trigger("unexpected-revision-id");else{switch(e.type){case"CLIENT_MOVED":this.onClientMoved(e);break;case"CLIENT_JOINED":this.onClientJoined(e);break;case"CLIENT_LEFT":this.onClientLeft(e);break;case"REVISION_REDONE":this.revisions.redo(e.redoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-redone",{revisionId:e.redoneRevisionId,commands:this.revisions.get(e.redoneRevisionId).commands});break;case"REVISION_UNDONE":this.revisions.undo(e.undoneRevisionId,e.nextRevisionId,e.serverRevisionId),this.trigger("revision-undone",{revisionId:e.undoneRevisionId,commands:this.revisions.get(e.undoneRevisionId).commands});break;case"REMOTE_REVISION":const{clientId:t,commands:i}=e,o=new Ib(e.nextRevisionId,t,i);if(o.clientId!==this.clientId){this.revisions.insert(o.id,o,e.serverRevisionId);const t=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.commands)).flat();this.trigger("remote-revision-received",{commands:yb(i,t)})}break;case"SNAPSHOT_CREATED":{const t=new Ib(e.nextRevisionId,"server",[]);this.revisions.insert(t.id,t,e.serverRevisionId),this.dropPendingHistoryMessages(),this.trigger("snapshot");break}}this.acknowledge(e),this.trigger("collaborative-event-received")}}onClientMoved(e){e.client.id!==this.clientId&&(this.clients[e.client.id]=e.client)}onClientJoined(e){if(e.client.id!==this.clientId){this.clients[e.client.id]=e.client;const t=this.clients[this.clientId];if(t){const{position:e}=t;e&&this.transportService.sendMessage({type:"CLIENT_MOVED",version:1,client:{...t,position:e}})}}}onClientLeft(e){e.clientId!==this.clientId&&delete this.clients[e.clientId]}sendUpdateMessage(e){this.pendingMessages.push(e),this.waitingAck||(this.waitingAck=!0,this.sendPendingMessage())}sendPendingMessage(){let e=this.pendingMessages[0];if(e){if("REMOTE_REVISION"===e.type){const t=this.revisions.get(e.nextRevisionId);if(0===t.commands.length){this.revisions.drop(t.id);const e=this.pendingMessages.filter((e=>"REMOTE_REVISION"===e.type)).map((e=>e.nextRevisionId));return this.trigger("pending-revisions-dropped",{revisionIds:e}),this.waitingAck=!1,this.waitingUndoRedoAck=!1,void(this.pendingMessages=[])}e={...e,clientId:t.clientId,commands:t.commands}}if(this.isReplayingInitialRevisions)throw new Error(`Trying to send a new revision while replaying initial revision. This can lead to endless dispatches every time the spreadsheet is open.\n ${JSON.stringify(e)}`);this.transportService.sendMessage({...e,serverRevisionId:this.serverRevisionId})}}acknowledge(e){switch("REVISION_UNDONE"!==e.type&&"REVISION_REDONE"!==e.type||(this.waitingUndoRedoAck=!1),e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":this.waitingAck=!1,this.pendingMessages=this.pendingMessages.filter((t=>t.nextRevisionId!==e.nextRevisionId)),this.serverRevisionId=e.nextRevisionId,this.processedRevisions.add(e.nextRevisionId),this.sendPendingMessage()}}isAlreadyProcessed(e){if("CLIENT_MOVED"===e.type&&e.client.id===this.clientId)return!0;switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":return this.processedRevisions.has(e.nextRevisionId);default:return!1}}isWrongServerRevisionId(e){switch(e.type){case"REMOTE_REVISION":case"REVISION_REDONE":case"REVISION_UNDONE":case"SNAPSHOT_CREATED":return e.serverRevisionId!==this.serverRevisionId;default:return!1}}dropPendingHistoryMessages(){this.waitingUndoRedoAck=!1,this.pendingMessages=this.pendingMessages.filter((({type:e})=>"REVISION_REDONE"!==e&&"REVISION_UNDONE"!==e))}}const Ab=["#ff851b","#0074d9","#7fdbff","#b10dc9","#39cccc","#f012be","#3d9970","#111111","#ff4136","#aaaaaa","#85144b","#001f3f"];class Mb extends Qv{constructor(){super(...arguments),this.availableColors=new Set(Ab),this.colors={}}isPositionValid(e){return e.row<this.getters.getNumberRows(e.sheetId)&&e.col<this.getters.getNumberCols(e.sheetId)}chooseNewColor(){0===this.availableColors.size&&(this.availableColors=new Set(Ab));const e=(t=[...this.availableColors.values()])[Math.floor(Math.random()*t.length)];var t;return this.availableColors.delete(e),e}getClientsToDisplay(){try{this.getters.getClient()}catch(e){if(e instanceof Rb)return[];throw e}const e=this.getters.getActiveSheetId(),t=[];for(const i of this.getters.getConnectedClients())if(i.id!==this.getters.getClient().id&&i.position&&i.position.sheetId===e&&this.isPositionValid(i.position)){const e=i.position;this.colors[i.id]||(this.colors[i.id]=this.chooseNewColor());const o=this.colors[i.id];t.push({...i,position:e,color:o})}return t}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:i}=e,o=this.getters.getActiveSheetId();for(const e of this.getClientsToDisplay()){const{row:n,col:s}=e.position,r=this.getters.expandZone(o,{top:n,bottom:n,left:s,right:s}),{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(r);if(c<=0||h<=0)continue;const d=e.color,u=`${d}10`;t.fillStyle=u,t.lineWidth=4*i,t.strokeStyle=d,t.globalCompositeOperation="multiply",t.fillRect(a,l,c,h),t.globalCompositeOperation="source-over",t.strokeRect(a,l,c,h),t.font=`bold ${q+1}px ${Z}`}}}Mb.getters=["getClientsToDisplay"],Mb.layers=[6];class Ob extends Qv{allowDispatch(e){if("SORT_CELLS"===e.type){if(!Qi(e.col,e.row,e.zone))throw new Error(s("The anchor must be part of the provided zone"));return this.checkValidations(e,this.checkMerge,this.checkMergeSizes)}return 0}handle(e){if("SORT_CELLS"===e.type)this.sortZone(e.sheetId,e,e.zone,e.sortDirection,e.sortOptions||{})}checkMerge({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;return no(t).some((({col:t,row:i})=>!this.getters.isInMerge({sheetId:e,col:t,row:i})))?63:0}checkMergeSizes({sheetId:e,zone:t}){if(!this.getters.doesIntersectMerge(e,t))return 0;const i=this.getters.getMerges(e).filter((e=>Ki(e,t))),o=io(i[0]);let[n,s]=[o.numberOfCols,o.numberOfRows];return i.every((e=>{let[t,i]=[e.right-e.left+1,e.bottom-e.top+1];return t===n&&i===s}))?0:63}expand(e,t){const{left:i,right:o,top:n,bottom:s}=this.getters.expandZone(e,t);return{left:Math.max(0,i),right:Math.min(this.getters.getNumberCols(e)-1,o),top:Math.max(0,n),bottom:Math.min(this.getters.getNumberRows(e)-1,s)}}checkExpandedValues(e,t){const i=this.expand(e,t);let o;if(this.getters.doesIntersectMerge(e,i)){const{left:t,right:n,top:s,bottom:r}=i;for(let i=t;i<=n;i++)for(let t=s;t<=r;t++){const{col:n,row:s}=this.getters.getMainCellPosition({sheetId:e,col:i,row:t});if(o=this.getters.getEvaluatedCell({sheetId:e,col:n,row:s}),o.formattedValue)return!0}}else for(let t of this.getters.getEvaluatedCellsInZone(e,i))if(t.formattedValue)return!0;return!1}getContiguousZone(e,t){let i,{top:o,bottom:n,left:s,right:r}=t,a=!1;for(;!a;)a=!0,o>0&&(i=this.checkExpandedValues(e,{left:s-1,right:r+1,top:o-1,bottom:o-1}),i&&(a=!1,o--)),s>0&&(i=this.checkExpandedValues(e,{left:s-1,right:s-1,top:o-1,bottom:n+1}),i&&(a=!1,s--)),r<this.getters.getNumberCols(e)-1&&(i=this.checkExpandedValues(e,{left:r+1,right:r+1,top:o-1,bottom:n+1}),i&&(a=!1,r++)),n<this.getters.getNumberRows(e)-1&&(i=this.checkExpandedValues(e,{left:s-1,right:r+1,top:n+1,bottom:n+1}),i&&(a=!1,n++));return{left:s,right:r,top:o,bottom:n}}hasHeader(e,t){if(1===t[0].length)return!1;let i=t.map((t=>t.map((({col:t,row:i})=>this.getters.getEvaluatedCell({sheetId:e,col:t,row:i}).type))));return i[0][0]===ln.empty&&(i=i.slice(1)),!i.some((e=>e[0]===ln.empty))&&!!i.some((e=>e[1]!==ln.empty&&e[0]!==e[1]))}sortZone(e,t,i,o,n){const[s,r]=this.mainCellsSteps(e,i);let a=this.getters.getMainCellPosition({sheetId:e,col:t.col,row:t.row}).col,l=Object.assign({},i),c=this.mainCells(e,i);!n.sortHeaders&&this.hasHeader(e,c)&&(l.top+=r),c=this.mainCells(e,l);const h=function(e,t,i){const o=e.map(((e,t)=>({index:t,type:e.type,value:e.value})));let n=o.filter((e=>e.type===ln.empty)),s=o.filter((e=>e.type!==ln.empty));i&&(s.push(...n.map((e=>({...e,type:ln.number,value:0})))),n=[]);const r="descending"===t?-1:1;return s.sort(((e,t)=>{let i=Tr.indexOf(e.type)-Tr.indexOf(t.type);return 0===i&&(i=e.type===ln.text||e.type===ln.error?e.value.localeCompare(t.value):e.value-t.value),r*i})).concat(n)}(c[a-l.left].map((e=>this.getters.getEvaluatedCell(e))),o,Boolean(n.emptyCellAsZero)),d=h.map((e=>e.index)),[u,g]=[c.length,c[0].length],p=[];for(let e=0;e<u;e++)for(let t=0;t<g;t++){let{col:i,row:o,sheetId:n}=c[e][d[t]];const a=this.getters.getCell({sheetId:n,col:i,row:o});let h=l.left+e*s,u=l.top+t*r,g={sheetId:n,col:h,row:u,content:""};if(a){let e=a.content;if(a.isFormula){const t=u-this.getters.getCellPosition(a.id).row,i=this.getters.createAdaptedRanges(a.dependencies,0,t,n);e=this.getters.buildFormulaContent(n,a,i)}g.style=a.style,g.content=e,g.format=a.format}p.push(g)}p.forEach((e=>this.dispatch("UPDATE_CELL",e)))}mainCellsSteps(e,t){const i=this.getters.getMerge({sheetId:e,col:t.left,row:t.top});return[i?i.right-i.left+1:1,i?i.bottom-i.top+1:1]}mainCells(e,t){const[i,o]=this.mainCellsSteps(e,t),n=[],s=He(t.left,t.right+1,i),r=He(t.top,t.bottom+1,o);for(const t of s){const i=[];n.push(i);for(const o of r)i.push({sheetId:e,col:t,row:o})}return n}}Ob.getters=["getContiguousZone"];class Nb extends Qv{constructor(){super(...arguments),this.showFormulas=!1}handle(e){if("SET_FORMULA_VISIBILITY"===e.type)this.showFormulas=e.show}shouldShowFormulas(){return this.showFormulas}}Nb.getters=["shouldShowFormulas"];class _b extends Qv{constructor(){super(...arguments),this.ctx=document.createElement("canvas").getContext("2d")}allowDispatch(e){switch(e.type){case"AUTORESIZE_ROWS":case"AUTORESIZE_COLUMNS":try{this.getters.getSheet(e.sheetId);break}catch(e){return 27}}return 0}handle(e){switch(e.type){case"AUTORESIZE_COLUMNS":for(let t of e.cols){const i=this.getColMaxWidth(e.sheetId,t);0!==i&&this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"COL",size:i,sheetId:e.sheetId})}break;case"AUTORESIZE_ROWS":for(let t of e.rows)this.dispatch("RESIZE_COLUMNS_ROWS",{elements:[t],dimension:"ROW",size:null,sheetId:e.sheetId})}}getCellWidth(e){const t=this.getCellText(e),i=this.getters.getCellComputedStyle(e),o=t.split(he);let n=Math.max(...o.map((e=>this.getTextWidth(e,i))));this.getters.getConditionalIcon(e)&&(n+=function(e){return Be(e)+2*U}(this.getters.getCellStyle(e)));if(this.getters.isFilterHeader(e)&&(n+=20),n>0&&(n+=2*B,"wrap"===this.getters.getCellStyle(e).wrapping)){const t=this.getters.getColSize(this.getters.getActiveSheetId(),e.col);return Math.min(t,n)}return n}getTextWidth(e,t){return Pe(this.ctx,e,t)}getCellText(e,t=!1){const i=this.getters.getCell(e);return t&&(null==i?void 0:i.isFormula)?i.content:this.getters.getEvaluatedCell(e).formattedValue}getCellMultiLineText(e,t){const i=this.getters.getCellStyle(e),o=this.getters.getCellText(e,this.getters.shouldShowFormulas()),n=[];for(const e of o.split("\n")){const o=e.split(" ");if(!t){n.push(e);continue}let s="",r=t;for(let e of o){const o=this.splitWordToSpecificWidth(this.ctx,e,t,i),a=o.pop(),l=Pe(this.ctx,a,i);if(o.length)""!==s&&(n.push(s),s="",r=t),o.forEach((e=>{n.push(e)})),s=a,r=t-l;else{const e=""===s?a:" "+a,o=Pe(this.ctx,e,i);o<=r?(s+=e,r-=o):(n.push(s),s=a,r=t-l)}}""!==s&&n.push(s)}return n}getColDimensions(e,t){const i=this.getColRowOffset("COL",0,t,e),o=this.getters.getColSize(e,t);return{start:i,size:o,end:i+(this.getters.isColHidden(e,t)?0:o)}}getRowDimensions(e,t){const i=this.getColRowOffset("ROW",0,t,e),o=this.getters.getRowSize(e,t);return{start:i,size:o,end:i+(this.getters.isRowHidden(e,t)?0:o)}}getColRowOffset(e,t,i,o=this.getters.getActiveSheetId()){if(i<t)return-this.getColRowOffset(e,i,t);let n=0;for(let s=t;s<i;s++)this.getters.isHeaderHidden(o,e,s)||(n+="COL"===e?this.getters.getColSize(o,s):this.getters.getRowSize(o,s));return n}getColMaxWidth(e,t){const i=no(this.getters.getColsZone(e,t,t)).map((t=>this.getCellWidth({sheetId:e,...t})));return Math.max(0,...i)}splitWordToSpecificWidth(e,t,i,o){if(Pe(e,t,o)<=i)return[t];const n=[];let s="";for(let r of t){Pe(e,s+r,o)>i?(n.push(s),s=r):s+=r}return n.push(s),n}}_b.getters=["getCellWidth","getTextWidth","getCellText","getCellMultiLineText","getColDimensions","getRowDimensions","getColRowOffset"];class Fb{constructor(e,t,i,o){this.getters=t,this.dispatch=i,this.selection=o,this.operation=e,this.sheetId=t.getActiveSheetId()}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0}addMissingDimensions(e,t,i,o){const n=this.getters.getActiveSheetId(),s=t+o-this.getters.getNumberRows(n);s>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"ROW",base:this.getters.getNumberRows(n)-1,sheetId:n,quantity:s,position:"after"});const r=e+i-this.getters.getNumberCols(n);r>0&&this.dispatch("ADD_COLUMNS_ROWS",{dimension:"COL",base:this.getters.getNumberCols(n)-1,sheetId:n,quantity:r,position:"after"})}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class Db extends Fb{constructor(e,t,i,o,n){if(super(t,i,o,n),!e.length)return this.cells=[[]],this.zones=[],void(this.copiedTables=[]);const s=new Set(e.map((e=>e.left))),r=new Set(e.map((e=>e.right))),a=new Set(e.map((e=>e.top))),l=new Set(e.map((e=>e.bottom))),c=1===a.size&&1===l.size||1===s.size&&1===r.size?function(e){return e.reduce(((e,t)=>{const i=e.length;for(let o=0;o<i;o++)if(Ki(e[o],t))return e[o]=ji(e[o],t),e;return e[i]=t,e}),[])}(e):[e[e.length-1]],h=c.map((e=>no(e))).flat(),d=[...new Set(h.map((e=>e.col)))].sort(((e,t)=>e-t)),u=[...new Set(h.map((e=>e.row)))].sort(((e,t)=>e-t)),g=[],p=i.getActiveSheetId();for(let e of u){let t=[];for(let o of d){const n={col:o,row:e,sheetId:p};t.push({cell:i.getCell(n),style:i.getCellComputedStyle(n),evaluatedCell:i.getEvaluatedCell(n),border:i.getCellBorder(n)||void 0,position:n})}g.push(t)}const m=[];for(const t of e)for(const e of this.getters.getFilterTablesInZone(p,t)){const t=[];for(const i of He(e.zone.left,e.zone.right+1))t.push(this.getters.getFilterValues({sheetId:p,col:i,row:e.zone.top}));m.push({filtersValues:t,zone:e.zone})}this.cells=g,this.zones=c,this.copiedTables=m}isCutAllowed(e){return 1!==e.length?19:0}isPasteAllowed(e,t){const i=this.getters.getActiveSheetId();if("CUT"===this.operation&&void 0!==(null==t?void 0:t.pasteOption))return 21;if(e.length>1&&(this.cells.length>1||this.cells[0].length>1))return 20;const o=this.cells.length,n=this.cells[0].length;for(let t of this.getPasteZones(e))if(this.getters.doesIntersectMerge(i,t)&&(e.length>1||!this.getters.isSingleCellOrMerge(i,e[0])||o*n!=1))return 2;const{xSplit:s,ySplit:r}=this.getters.getPaneDivisions(i);for(const t of this.getPasteZones(e))if(t.left<s&&t.right>=s||t.top<r&&t.bottom>=r)return 75;return 0}paste(e,t){"COPY"===this.operation?this.pasteFromCopy(e,t):this.pasteFromCut(e,t);const i=this.cells.length,o=this.cells[0].length,n="CUT"===this.operation;(null==t?void 0:t.selectTarget)&&this.selectPastedZone(o,i,n,e)}pasteFromCopy(e,t){if(1===e.length){const i=this.cells.length,o=this.cells[0].length,n=this.pastedZones(e,o,i);for(const e of n)this.pasteZone(e.left,e.top,t)}else for(const i of e)for(let e=i.left;e<=i.right;e++)for(let o=i.top;o<=i.bottom;o++)this.pasteZone(e,o,t);void 0===(null==t?void 0:t.pasteOption)&&this.pasteCopiedTables(e)}pasteFromCut(e,t){this.clearClippedZones();const i=e[0];this.pasteZone(i.left,i.top,t),this.dispatch("MOVE_RANGES",{target:this.zones,sheetId:this.sheetId,targetSheetId:this.getters.getActiveSheetId(),col:i.left,row:i.top});for(const e of this.copiedTables)this.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.sheetId,target:[e.zone]});this.pasteCopiedTables(e)}pastedZones(e,t,i){const o=e[0],n=Math.max(1,Math.floor((o.right+1-o.left)/t)),s=Math.max(1,Math.floor((o.bottom+1-o.top)/i)),r=[];for(let e=0;e<n;e++)for(let n=0;n<s;n++){const s=o.top+n*i,a=o.left+e*t;r.push({left:a,top:s,bottom:s+i-1,right:a+t-1})}return r}getPasteZones(e){const t=this.cells;if(!t.length||!t[0].length)return e;const i=[],o=t.length,n=t[0].length,s=e[e.length-1],r=s.left,a=s.top,l=Math.max(1,Math.floor((s.right+1-r)/n)),c=Math.max(1,Math.floor((s.bottom+1-a)/o));for(let e=1;e<=l;e++)for(let t=1;t<=c;t++)i.push({left:r,top:a,right:r-1+e*n,bottom:a-1+t*o});return i}selectPastedZone(e,t,i,o){const n=o[0],s=n.left,r=n.top;if(t>1||e>1||i){const n=this.pastedZones(o,e,t),a=i?n[0]:ji(...n);this.selection.selectZone({cell:{col:s,row:r},zone:a})}}clearClippedZones(){for(const e of this.cells)for(const t of e)t.cell&&this.dispatch("CLEAR_CELL",t.position);this.dispatch("CLEAR_FORMATTING",{sheetId:this.sheetId,target:this.zones})}pasteZone(e,t,i){const o=this.cells.length,n=this.cells[0].length,s="onlyValue"!==(null==i?void 0:i.pasteOption)&&(null==i?void 0:i.shouldPasteCF),r=this.getters.getActiveSheetId();this.addMissingDimensions(n,o,e,t);for(let a=0;a<o;a++){const o=this.cells[a];for(let l=0;l<n;l++){const n=o[l],c={col:e+l,row:t+a,sheetId:r};"CUT"!==this.operation&&this.pasteMergeIfExist(n.position,c),this.pasteCell(n,c,this.operation,i),s&&this.dispatch("PASTE_CONDITIONAL_FORMAT",{origin:n.position,target:c,operation:this.operation})}}}pasteCell(e,t,i,o){const{sheetId:n,col:s,row:r}=t,a=this.getters.getEvaluatedCell(t);if("onlyValue"!==(null==o?void 0:o.pasteOption)){const i=this.getters.getCellBorder(t),o=e.border,a={top:(null==i?void 0:i.top)||(null==o?void 0:o.top),bottom:(null==i?void 0:i.bottom)||(null==o?void 0:o.bottom),left:(null==i?void 0:i.left)||(null==o?void 0:o.left),right:(null==i?void 0:i.right)||(null==o?void 0:o.right)};this.dispatch("SET_BORDER",{sheetId:n,col:s,row:r,border:a})}if(e.cell){if("onlyFormat"===(null==o?void 0:o.pasteOption))return void this.dispatch("UPDATE_CELL",{...t,style:e.cell.style,format:e.evaluatedCell.format});if("onlyValue"===(null==o?void 0:o.pasteOption)){const i=mi(e.evaluatedCell.value);return void this.dispatch("UPDATE_CELL",{...t,content:i})}let a=e.cell.content;if(e.cell.isFormula&&"COPY"===i){const t=s-e.position.col,o=r-e.position.row;a=this.getUpdatedContent(n,e.cell,t,o,i)}this.dispatch("UPDATE_CELL",{...t,content:a,style:e.cell.style||null,format:e.cell.format})}else a&&("onlyValue"===(null==o?void 0:o.pasteOption)?this.dispatch("UPDATE_CELL",{...t,content:""}):"onlyFormat"===(null==o?void 0:o.pasteOption)?this.dispatch("UPDATE_CELL",{...t,style:null,format:""}):this.dispatch("CLEAR_CELL",t))}getUpdatedContent(e,t,i,o,n){const s=this.getters.createAdaptedRanges(t.dependencies,i,o,e);return this.getters.buildFormulaContent(e,t,s)}pasteMergeIfExist(e,t){let{sheetId:i,col:o,row:n}=e;const{col:s,row:r}=this.getters.getMainCellPosition(e);if(s===o&&r===n){const s=this.getters.getMerge(e);if(!s)return;({sheetId:i,col:o,row:n}=t),this.dispatch("ADD_MERGE",{sheetId:i,force:!0,target:[{left:o,top:n,right:o+s.right-s.left,bottom:n+s.bottom-s.top}]})}}pasteCopiedTables(e){const t=this.getters.getActiveSheetId(),i=e[0],o=this.zones[0],n=[i.left-o.left,i.top-o.top];for(const e of this.copiedTables){const i=so(e.zone,"both","MOVE",n);this.dispatch("CREATE_FILTER_TABLE",{sheetId:t,target:[i]});for(const o of He(0,e.filtersValues.length))this.dispatch("UPDATE_FILTER",{sheetId:t,col:i.left+o,row:i.top,values:e.filtersValues[o]})}}getClipboardContent(){return{[cn.PlainText]:this.getPlainTextContent(),[cn.Html]:this.getHTMLContent()}}getPlainTextContent(){return this.cells.map((e=>e.map((e=>e.cell?this.getters.getCellText(e.position,this.getters.shouldShowFormulas()):"")).join("\t"))).join("\n")||"\t"}getHTMLContent(){if(1==this.cells.length&&1==this.cells[0].length)return this.getters.getCellText(this.cells[0][0].position);let e='<table border="1" style="border-collapse:collapse">';for(const t of this.cells){e+="<tr>";for(const i of t){e+=`<td style="${Co(bo(i.style))}">`+tv(this.getters.getCellText(i.position))+"</td>"}e+="</tr>"}return e+="</table>",e}isColRowDirtyingClipboard(e,t){if(!this.zones)return!1;for(let i of this.zones){if("COL"===t&&e<=i.right)return!0;if("ROW"===t&&e<=i.bottom)return!0}return!1}drawClipboard(e){const{ctx:t,thinLineWidth:i}=e;if(this.sheetId===this.getters.getActiveSheetId()&&this.zones&&this.zones.length){t.setLineDash([8,5]),t.strokeStyle=E,t.lineWidth=3.3*i;for(const e of this.zones){const{x:i,y:o,width:n,height:s}=this.getters.getVisibleRect(e);n>0&&s>0&&t.strokeRect(i,o,n,s)}}}}class kb{constructor(e,t,i){this.operation=e,this.getters=t,this.dispatch=i,this.sheetId=t.getActiveSheetId();const o=t.getSelectedFigureId();if(!o)throw new Error("No figure selected");const n=t.getFigure(this.sheetId,o);if(!n)throw new Error(`No figure for the given id: ${o}`);switch(this.copiedFigure={...n},n.tag){case"chart":this.copiedFigureContent=new Lb(i,t,this.sheetId,o);break;case"image":this.copiedFigureContent=new Pb(i,t,this.sheetId,o);break;default:throw new Error(`Unknow tag '${n.tag}' for the given figure id: ${o}`)}}isCutAllowed(e){return 0}isPasteAllowed(e,t){return 0===e.length?73:void 0!==(null==t?void 0:t.pasteOption)?22:0}paste(e){const t=this.getters.getActiveSheetId(),i={x:this.getters.getColDimensions(t,e[0].left).start,y:this.getters.getRowDimensions(t,e[0].top).start},o={height:this.copiedFigure.height,width:this.copiedFigure.width},n=(new Vi).uuidv4();this.copiedFigureContent.paste(t,n,i,o),"CUT"===this.operation&&this.dispatch("DELETE_FIGURE",{sheetId:this.copiedFigureContent.sheetId,id:this.copiedFigure.id}),this.dispatch("SELECT_FIGURE",{id:n})}getClipboardContent(){return{[cn.PlainText]:"\t"}}isColRowDirtyingClipboard(e,t){return!1}drawClipboard(e){}}class Lb{constructor(e,t,i,o){this.dispatch=e,this.sheetId=i;const n=t.getChart(o);if(!n)throw new Error(`No chart for the given id: ${o}`);this.copiedChart=n.copyInSheetId(i)}paste(e,t,i,o){const n=this.copiedChart.copyInSheetId(e);this.dispatch("CREATE_CHART",{id:t,sheetId:e,position:i,size:o,definition:n.getDefinition()})}}class Pb{constructor(e,t,i,o){this.dispatch=e,this.sheetId=i;const n=t.getImage(o);this.copiedImage=_e(n)}paste(e,t,i,o){const n=_e(this.copiedImage);this.dispatch("CREATE_IMAGE",{figureId:t,sheetId:e,position:i,size:o,definition:n})}}class Ub extends Fb{constructor(e,t,i,o){super("COPY",t,i,o),this.values=e.replace(/\r/g,"").split("\n").map((e=>e.split("\t")))}isPasteAllowed(e,t){const i=this.getters.getActiveSheetId(),o=this.getPasteZone(e);return this.getters.doesIntersectMerge(i,o)?2:0}paste(e){const t=this.values,i=this.getPasteZone(e),{left:o,top:n}=i,{numberOfCols:s,numberOfRows:r}=io(i),a=this.getters.getActiveSheetId();this.addMissingDimensions(s,r,o,n);for(let e=0;e<t.length;e++)for(let i=0;i<t[e].length;i++)this.dispatch("UPDATE_CELL",{row:n+e,col:o+i,content:t[e][i],sheetId:a});const l={left:o,top:n,right:o+s-1,bottom:n+r-1};this.selection.selectZone({cell:{col:o,row:n},zone:l})}getClipboardContent(){return{[cn.PlainText]:this.values.map((e=>e.join("\t"))).join("\n")}}getPasteZone(e){const t=this.values.length,i=Math.max(...this.values.map((e=>e.length))),{left:o,top:n}=e[0];return{top:n,left:o,bottom:n+t-1,right:o+i-1}}}class Vb extends Qv{constructor(){super(...arguments),this.status="invisible",this._isPaintingFormat=!1}allowDispatch(e){switch(e.type){case"CUT":const t=this.getters.getSelectedZones();return this.getClipboardState(t,e.type).isCutAllowed(t);case"PASTE":if(!this.state)return 23;const i=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);return this.state.isPasteAllowed(e.target,{pasteOption:i});case"PASTE_FROM_OS_CLIPBOARD":return new Ub(e.text,this.getters,this.dispatch,this.selection).isPasteAllowed(e.target);case"INSERT_CELL":{const{cut:t,paste:i}=this.getInsertCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(i)}case"DELETE_CELL":{const{cut:t,paste:i}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);return this.getClipboardStateForCopyCells(t,"CUT").isPasteAllowed(i)}}return 0}handle(e){var t,i;switch(e.type){case"COPY":case"CUT":const o=this.getters.getSelectedZones();this.state=this.getClipboardState(o,e.type),this.status="visible";break;case"PASTE":if(!this.state)break;const n=e.pasteOption||(this._isPaintingFormat?"onlyFormat":void 0);this._isPaintingFormat=!1,this.state.paste(e.target,{pasteOption:n,shouldPasteCF:!0,selectTarget:!0}),"CUT"===this.state.operation&&(this.state=void 0),this.status="invisible";break;case"CLEAN_CLIPBOARD_HIGHLIGHT":this.status="invisible";break;case"DELETE_CELL":{const{cut:t,paste:i}=this.getDeleteCellsTargets(e.zone,e.shiftDimension);if(!Hi(t[0])){for(const{col:t,row:i}of no(e.zone))this.dispatch("CLEAR_CELL",{col:t,row:i,sheetId:this.getters.getActiveSheetId()});break}this.getClipboardStateForCopyCells(t,"CUT").paste(i);break}case"INSERT_CELL":{const{cut:t,paste:i}=this.getInsertCellsTargets(e.zone,e.shiftDimension);this.getClipboardStateForCopyCells(t,"CUT").paste(i);break}case"ADD_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(t=this.state)||void 0===t?void 0:t.operation))return;this.state.isColRowDirtyingClipboard("before"===e.position?e.base:e.base+1,e.dimension)&&(this.state=void 0);break;case"REMOVE_COLUMNS_ROWS":if(this.status="invisible","CUT"!==(null===(i=this.state)||void 0===i?void 0:i.operation))return;for(let t of e.elements){if(this.state.isColRowDirtyingClipboard(t,e.dimension)){this.state=void 0;break}}this.status="invisible";break;case"PASTE_FROM_OS_CLIPBOARD":new Ub(e.text,this.getters,this.dispatch,this.selection).paste(e.target),this.status="invisible";break;case"ACTIVATE_PAINT_FORMAT":{const e=this.getters.getSelectedZones();this.state=this.getClipboardStateForCopyCells(e,"COPY"),this._isPaintingFormat=!0,this.status="visible";break}default:pn(e)&&(this.status="invisible")}}getClipboardContent(){var e;return(null===(e=this.state)||void 0===e?void 0:e.getClipboardContent())||{[cn.PlainText]:"\t"}}getClipboardTextContent(){var e;return(null===(e=this.state)||void 0===e?void 0:e.getClipboardContent()[cn.PlainText])||"\t"}isCutOperation(){return!!this.state&&"CUT"===this.state.operation}isPaintingFormat(){return this._isPaintingFormat}getDeleteCellsTargets(e,t){const i=this.getters.getActiveSheetId();let o;return o="COL"===t?{...e,left:e.right+1,right:this.getters.getNumberCols(i)-1}:{...e,top:e.bottom+1,bottom:this.getters.getNumberRows(i)-1},{cut:[o],paste:[e]}}getInsertCellsTargets(e,t){const i=this.getters.getActiveSheetId();let o,n;return"COL"===t?(o={...e,right:this.getters.getNumberCols(i)-1},n={...e,left:e.right+1,right:e.right+1}):(o={...e,bottom:this.getters.getNumberRows(i)-1},n={...e,top:e.bottom+1,bottom:this.getters.getNumberRows(i)-1}),{cut:[o],paste:[n]}}getClipboardStateForCopyCells(e,t){return new Db(e,t,this.getters,this.dispatch,this.selection)}getClipboardState(e,t){return this.getters.getSelectedFigureId()?new kb(t,this.getters,this.dispatch):new Db(e,t,this.getters,this.dispatch,this.selection)}drawGrid(e){"visible"===this.status&&this.state&&this.state.drawClipboard(e)}}function zb(e){if("REFERENCE"!==e.type)return e;const{xc:t,sheetName:i}=Ht(e.value),[o,n]=t.split(":"),s=i?`${De(i)}!`:"",r=Bb(o),a=n?`:${Bb(n)}`:"";return{...e,value:s+r+a}}function Bb(e){switch(function(e){if(function(e){return e.startsWith("$")&&e.length>1&&e.slice(1).includes("$")}(e))return"colrow";if(function(e){return e.startsWith("$")}(e))return"col";if(function(e){return e.includes("$",1)}(e))return"row";return"none"}(e)){case"none":e=Hb(e,"colrow");break;case"colrow":e=Hb(e,"row");break;case"row":e=Hb(e,"col");break;case"col":e=Hb(e,"none")}return e}function Hb(e,t){let i;switch(e=e.replace(/\$/g,""),t){case"col":return"$"+e;case"row":return i=e.search(/[0-9]/),e.slice(0,i)+"$"+e.slice(i);case"colrow":return i=e.search(/[0-9]/),-1===i||0===i?"$"+e:"$"+(e=e.slice(0,i)+"$"+e.slice(i));case"none":return e}}Vb.layers=[2],Vb.getters=["getClipboardContent","getClipboardTextContent","isCutOperation","isPaintingFormat"];const $b=s("The cell you are trying to edit has been deleted.");class Wb extends Qv{constructor(){super(...arguments),this.col=0,this.row=0,this.mode="inactive",this.sheetId="",this.currentContent="",this.currentTokens=[],this.selectionStart=0,this.selectionEnd=0,this.selectionInitialStart=0,this.initialContent="",this.previousRef="",this.previousRange=void 0,this.colorIndexByRange={}}allowDispatch(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":return this.validateSelection(this.currentContent.length,e.start,e.end);case"SET_CURRENT_CONTENT":return e.selection?this.validateSelection(e.content.length,e.selection.start,e.selection.end):0;case"START_EDITION":if(e.selection){const t=e.text||this.getComposerContent(this.getters.getActivePosition());return this.validateSelection(t.length,e.selection.start,e.selection.end)}return 0;default:return 0}}handleEvent(e){if("selecting"===this.mode)if("newAnchor"===e.mode)this.insertSelectedRange(e.anchor.zone);else this.replaceSelectedRanges(e.anchor.zone)}handle(e){switch(e.type){case"CHANGE_COMPOSER_CURSOR_SELECTION":this.selectionStart=e.start,this.selectionEnd=e.end;break;case"STOP_COMPOSER_RANGE_SELECTION":this.isSelectingForComposer()&&(this.mode="editing");break;case"START_EDITION":"inactive"!==this.mode&&e.text?this.setContent(e.text,e.selection):this.startEdition(e.text,e.selection),this.updateRangeColor();break;case"STOP_EDITION":e.cancel?(this.cancelEditionAndActivateSheet(),this.resetContent()):this.stopEdition(),this.colorIndexByRange={};break;case"SET_CURRENT_CONTENT":this.setContent(e.content,e.selection,!0),this.updateRangeColor();break;case"REPLACE_COMPOSER_CURSOR_SELECTION":this.replaceSelection(e.text);break;case"SELECT_FIGURE":this.cancelEditionAndActivateSheet(),this.resetContent();break;case"ADD_COLUMNS_ROWS":this.onAddElements(e);break;case"REMOVE_COLUMNS_ROWS":"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);break;case"START_CHANGE_HIGHLIGHT":this.dispatch("STOP_COMPOSER_RANGE_SELECTION");const t=this.getters.getRangeFromRangeData(e.range),i=this.currentTokens.filter((e=>"REFERENCE"===e.type)).find((e=>{const{xc:i,sheetName:o}=Ht(e.value),n=o||this.getters.getSheetName(this.sheetId),s=this.getters.getActiveSheetId();if(this.getters.getSheetName(s)!==n)return!1;const r=this.getters.getRangeFromSheetXC(s,i);return Yi(this.getters.expandZone(s,r.zone),t.zone)}));this.previousRef=i.value,this.previousRange=this.getters.getRangeFromSheetXC(this.getters.getActiveSheetId(),this.previousRef),this.selectionInitialStart=i.start;break;case"CHANGE_HIGHLIGHT":const o=this.getters.getRangeFromRangeData(e.range),n=this.getRangeReference(o,this.previousRange.parts);this.selectionStart=this.selectionInitialStart,this.selectionEnd=this.selectionInitialStart+this.previousRef.length,this.replaceSelection(n),this.previousRef=n,this.selectionStart=this.currentContent.length,this.selectionEnd=this.currentContent.length;break;case"ACTIVATE_SHEET":if(this.currentContent.startsWith("=")||(this.cancelEdition(),this.resetContent()),e.sheetIdFrom!==e.sheetIdTo){const t=this.getters.getActivePosition(),{col:i,row:o}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:t.col,row:t.row}),n=this.getters.expandZone(e.sheetIdTo,lo({col:i,row:o}));this.selection.resetAnchor(this,{cell:{col:i,row:o},zone:n})}break;case"DELETE_SHEET":case"UNDO":case"REDO":!!this.getters.tryGetSheet(this.sheetId)||"inactive"===this.mode||(this.sheetId=this.getters.getActiveSheetId(),this.cancelEditionAndActivateSheet(),this.resetContent(),this.ui.notifyUI({type:"ERROR",text:$b}));break;case"CYCLE_EDITION_REFERENCES":this.cycleReferences()}}getEditionMode(){return this.mode}getCurrentContent(){return"inactive"===this.mode?this.getComposerContent(this.getters.getActivePosition()):this.currentContent}getEditionSheet(){return this.sheetId}getComposerSelection(){return{start:this.selectionStart,end:this.selectionEnd}}getCurrentEditedCell(){return{sheetId:this.sheetId,col:this.col,row:this.row}}isSelectingForComposer(){return"selecting"===this.mode}showSelectionIndicator(){return this.isSelectingForComposer()&&this.canStartComposerRangeSelection()}getCurrentTokens(){return this.currentTokens}getTokenAtCursor(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return e===t&&0===t?void 0:this.currentTokens.find((i=>i.start<=e&&i.end>=t))}cycleReferences(){const e=this.getTokensInSelection(),t=e.filter((e=>"REFERENCE"===e.type));if(0===t.length)return;const i=e.map(zb).map((e=>e.value)).join(""),o=this.currentContent,n=e[0].start,s=e[e.length-1].end,r=o.slice(0,n)+i+o.slice(s),a=r.length-o.length,l={start:t[0].start,end:t[t.length-1].end+a};1===t.length&&this.selectionStart===this.selectionEnd&&(l.start=l.end),this.dispatch("SET_CURRENT_CONTENT",{content:r,selection:l})}validateSelection(e,t,i){return t>=0&&t<=e&&i>=0&&i<=e?0:46}onColumnsRemoved(e){if(e.elements.includes(this.col)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:$b});const{top:t,left:i}=qi({left:this.col,right:this.col,top:this.row,bottom:this.row},"left",[...e.elements]);this.col=i,this.row=t}onRowsRemoved(e){if(e.elements.includes(this.row)&&"inactive"!==this.mode)return this.dispatch("STOP_EDITION",{cancel:!0}),void this.ui.notifyUI({type:"ERROR",text:$b});const{top:t,left:i}=qi({left:this.col,right:this.col,top:this.row,bottom:this.row},"top",[...e.elements]);this.col=i,this.row=t}onAddElements(e){const{top:t,left:i}=Gi({left:this.col,right:this.col,top:this.row,bottom:this.row},"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity);this.col=i,this.row=t}startComposerRangeSelection(){if(this.sheetId===this.getters.getActiveSheetId()){const e=lo({col:this.col,row:this.row});this.selection.resetAnchor(this,{cell:{col:this.col,row:this.row},zone:e})}this.mode="selecting",this.selectionInitialStart=this.selectionStart}startEdition(e,t){var i;const o=this.getters.getActiveCell();e&&(null===(i=o.format)||void 0===i?void 0:i.includes("%"))&&oi(e)&&(t=t||{start:e.length,end:e.length},e=`${e}%`);const{col:n,row:s,sheetId:r}=this.getters.getActivePosition();this.col=n,this.sheetId=r,this.row=s,this.initialContent=this.getComposerContent({sheetId:r,col:n,row:s}),this.mode="editing",this.setContent(e||this.initialContent,t),this.colorIndexByRange={};const a=lo({col:this.col,row:this.row});this.selection.capture(this,{cell:{col:this.col,row:this.row},zone:a},{handleEvent:this.handleEvent.bind(this),release:()=>{this.stopEdition()}})}stopEdition(){if("inactive"!==this.mode){this.cancelEditionAndActivateSheet();const e=this.col,t=this.row;let i=this.currentContent;if(!(this.initialContent!==i))return;if(i){const o=this.getters.getActiveSheetId(),n=this.getters.getEvaluatedCell({sheetId:o,col:this.col,row:this.row});if(i.startsWith("=")){const e=this.currentTokens.filter((e=>"LEFT_PAREN"===e.type)).length,t=this.currentTokens.filter((e=>"RIGHT_PAREN"===e.type)).length,o=e-t;o>0&&(i+=st(new Array(o).fill(")")))}else n.link&&(i=Ye(i,n.link.url));this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,col:e,row:t,content:i})}else this.dispatch("UPDATE_CELL",{sheetId:this.sheetId,content:"",col:e,row:t});this.setContent("")}}cancelEditionAndActivateSheet(){if("inactive"===this.mode)return;this.cancelEdition();this.getters.getActiveSheetId()!==this.sheetId&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getters.getActiveSheetId(),sheetIdTo:this.sheetId})}getComposerContent(e){const t=this.getters.getCell(e);if(null==t?void 0:t.isFormula)return t.content;const{format:i,value:o,type:n,formattedValue:s}=this.getters.getEvaluatedCell(e);switch(n){case ln.text:case ln.empty:return o;case ln.boolean:return s;case ln.error:return(null==t?void 0:t.content)||"";case ln.number:return i&&Ei(i)?s:this.numberComposerContent(o,i)}}numberComposerContent(e,t){return(null==t?void 0:t.includes("%"))?100*e+"%":function(e){const{integerDigits:t,decimalDigits:i}=bi(e,20);return i?`${t}.${i}`:t}(e)}cancelEdition(){"inactive"!==this.mode&&(this.mode="inactive",this.selection.release(this))}resetContent(){this.setContent(this.initialContent||"")}setContent(e,t,i){const o=this.currentContent!==e;this.currentContent=e,t?(this.selectionStart=t.start,this.selectionEnd=t.end):this.selectionStart=this.selectionEnd=e.length,(o||"inactive"!==this.mode)&&(this.currentTokens=e.startsWith("=")?vf(e):[],this.currentTokens.length>100&&i&&this.ui.notifyUI({type:"ERROR",text:s("This formula has over 100 parts. It can't be processed properly, consider splitting it into multiple cells")})),this.canStartComposerRangeSelection()&&this.startComposerRangeSelection()}insertSelectedRange(e){const t=Math.min(this.selectionStart,this.selectionEnd),i=this.getZoneReference(e);this.canStartComposerRangeSelection()?(this.insertText(i,t),this.selectionInitialStart=t):(this.insertText(","+i,t),this.selectionInitialStart=t+1)}replaceSelectedRanges(e){const t=this.getZoneReference(e);this.replaceText(t,this.selectionInitialStart,this.selectionEnd)}getZoneReference(e,t=[{colFixed:!1,rowFixed:!1}]){const i=this.getters.getActiveSheetId();let o=this.getters.zoneToXC(i,e,t);if(this.getters.getEditionSheet()!==this.getters.getActiveSheetId()){o=`${De(this.getters.getSheetName(this.getters.getActiveSheetId()))}!${o}`}return o}getRangeReference(e,t=[{colFixed:!1,rowFixed:!1}]){let i=[...t];1===t.length&&ho(e.zone)>1?i.push({...t[0]}):2===t.length&&1===ho(e.zone)&&i.pop();const o=e.clone({parts:i});return this.getters.getSelectionRangeString(o,this.getters.getEditionSheet())}replaceSelection(e){const t=Math.min(this.selectionStart,this.selectionEnd),i=Math.max(this.selectionStart,this.selectionEnd);this.replaceText(e,t,i)}replaceText(e,t,i){this.currentContent=this.currentContent.slice(0,t)+this.currentContent.slice(i,this.currentContent.length),this.insertText(e,t)}insertText(e,t){const i=this.currentContent.slice(0,t)+e+this.currentContent.slice(t),o=t+e.length;this.dispatch("SET_CURRENT_CONTENT",{content:i,selection:{start:o,end:o}})}updateRangeColor(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return;const e=this.getters.getEditionSheet(),t=this.getReferencedRanges().map((t=>this.getters.getRangeString(t,e))),i={};for(const e of t)void 0!==this.colorIndexByRange[e]&&(i[e]=this.colorIndexByRange[e]);const o=new Set(Object.values(i));let n=0;const s=()=>{for(;o.has(n);)n++;return o.add(n),n};for(const e of t){const t=e in i?i[e]:s();i[e]=t}this.colorIndexByRange=i}getComposerHighlights(){if(!this.currentContent.startsWith("=")||"inactive"===this.mode)return[];const e=this.getters.getEditionSheet(),t=e=>{const t=this.colorIndexByRange[e];return St[t%St.length]};return this.getReferencedRanges().map((i=>{const o=this.getters.getRangeString(i,e);return{zone:i.zone,color:t(o),sheetId:i.sheetId}}))}getReferencedRanges(){const e=this.getters.getEditionSheet();return this.currentTokens.filter((e=>"REFERENCE"===e.type)).map((t=>this.getters.getRangeFromSheetXC(e,t.value)))}canStartComposerRangeSelection(){if(this.currentContent.startsWith("=")){const e=this.getTokenAtCursor();if(!e)return!1;const t=this.currentTokens.map((e=>e.start)).indexOf(e.start);let i=t,o=e;for(;!["COMMA","LEFT_PAREN","OPERATOR"].includes(o.type)||Om.includes(o.value);){if("SPACE"!==o.type||i<1)return!1;i--,o=this.currentTokens[i]}for(i=t+1,o=this.currentTokens[i];o&&!["COMMA","RIGHT_PAREN","OPERATOR"].includes(o.type);){if("SPACE"!==o.type)return!1;i++,o=this.currentTokens[i]}return!0}return!1}getTokensInSelection(){const e=Math.min(this.selectionStart,this.selectionEnd),t=Math.max(this.selectionStart,this.selectionEnd);return this.currentTokens.filter((i=>i.start<=e&&i.end>=e||i.start>=e&&i.start<t))}}Wb.getters=["getEditionMode","isSelectingForComposer","showSelectionIndicator","getCurrentContent","getEditionSheet","getComposerSelection","getCurrentTokens","getTokenAtCursor","getComposerHighlights","getCurrentEditedCell"];const Gb=[{name:s("Sum"),types:[ln.number],compute:e=>vl.compute([e])},{name:s("Avg"),types:[ln.number],compute:e=>Al.compute([e])},{name:s("Min"),types:[ln.number],compute:e=>Gl.compute([e])},{name:s("Max"),types:[ln.number],compute:e=>Bl.compute([e])},{name:s("Count"),types:[ln.number,ln.text,ln.boolean,ln.error],compute:e=>Ll.compute([e])},{name:s("Count Numbers"),types:[ln.number,ln.text,ln.boolean,ln.error],compute:e=>kl.compute([e])}];class qb extends Qv{constructor(e){super(e),this.gridSelection={anchor:{cell:{col:0,row:0},zone:{top:0,left:0,bottom:0,right:0}},zones:[{top:0,left:0,bottom:0,right:0}]},this.selectedFigureId=null,this.sheetsData={},this.activeSheet=null,this.moveClient=e.moveClient}allowDispatch(e){switch(e.type){case"ACTIVATE_SHEET":try{this.getters.getSheet(e.sheetIdTo);break}catch(e){return 27}case"MOVE_COLUMNS_ROWS":return this.isMoveElementAllowed(e)}return 0}handleEvent(e){const t=e.anchor;let i=[];switch(e.mode){case"overrideSelection":i=[t.zone];break;case"updateAnchor":i=[...this.gridSelection.zones];const o=i.findIndex((t=>Yi(t,e.previousAnchor.zone)));o>=0&&(i[o]=t.zone);break;case"newAnchor":i=[...this.gridSelection.zones,t.zone]}this.setSelectionMixin(e.anchor,i),this.selection.resetDefaultAnchor(this,_e(this.gridSelection.anchor));const{col:o,row:n}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:o,row:n}),this.selectedFigureId=null}handle(e){switch(e.type){case"START_EDITION":case"ACTIVATE_SHEET":this.selectedFigureId=null;break;case"DELETE_FIGURE":this.selectedFigureId===e.id&&(this.selectedFigureId=null);break;case"DELETE_SHEET":this.selectedFigureId&&this.getters.getFigure(e.sheetId,this.selectedFigureId)&&(this.selectedFigureId=null)}switch(e.type){case"START":const t=this.getters.getVisibleSheetIds()[0];this.dispatch("ACTIVATE_SHEET",{sheetIdTo:t,sheetIdFrom:t});const{col:i,row:o}=this.getters.getNextVisibleCellPosition({sheetId:t,col:0,row:0});this.selectCell(i,o),this.selection.registerAsDefault(this,this.gridSelection.anchor,{handleEvent:this.handleEvent.bind(this)}),this.moveClient({sheetId:t,col:0,row:0});break;case"ACTIVATE_SHEET":if(this.getters.isSheetVisible(e.sheetIdTo)||this.dispatch("SHOW_SHEET",{sheetId:e.sheetIdTo}),this.setActiveSheet(e.sheetIdTo),this.sheetsData[e.sheetIdFrom]={gridSelection:_e(this.gridSelection)},e.sheetIdTo in this.sheetsData)Object.assign(this,this.sheetsData[e.sheetIdTo]),this.selection.resetDefaultAnchor(this,_e(this.gridSelection.anchor));else{const{col:t,row:i}=this.getters.getNextVisibleCellPosition({sheetId:e.sheetIdTo,col:0,row:0});this.selectCell(t,i)}break;case"REMOVE_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){"COL"===e.dimension?this.onColumnsRemoved(e):this.onRowsRemoved(e);const{col:i,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:i,row:o})}break}case"ADD_COLUMNS_ROWS":{const t=this.getters.getActiveSheetId();if(e.sheetId===t){this.onAddElements(e);const{col:i,row:o}=this.gridSelection.anchor.cell;this.moveClient({sheetId:t,col:i,row:o})}break}case"MOVE_COLUMNS_ROWS":e.sheetId===this.getActiveSheetId()&&this.onMoveElements(e);break;case"SELECT_FIGURE":this.selectedFigureId=e.id;break;case"ACTIVATE_NEXT_SHEET":this.activateNextSheet("right");break;case"ACTIVATE_PREVIOUS_SHEET":this.activateNextSheet("left");break;case"HIDE_SHEET":e.sheetId===this.getActiveSheetId()&&this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:e.sheetId,sheetIdTo:this.getters.getVisibleSheetIds()[0]});break;case"UNDO":case"REDO":case"DELETE_SHEET":const n=Object.keys(this.sheetsData).filter((e=>!this.getters.tryGetSheet(e)));for(const e of n)delete this.sheetsData[e];for(const e in this.sheetsData){const t=this.clipSelection(e,this.sheetsData[e].gridSelection);this.sheetsData[e]={gridSelection:_e(t)}}if(!this.getters.tryGetSheet(this.getters.getActiveSheetId())){const e=this.getters.getVisibleSheetIds();if(this.activeSheet=this.getters.getSheet(e[0]),this.activeSheet.id in this.sheetsData){const{anchor:e}=this.clipSelection(this.activeSheet.id,this.sheetsData[this.activeSheet.id].gridSelection);this.selectCell(e.cell.col,e.cell.row)}else this.selectCell(0,0);const{col:t,row:i}=this.gridSelection.anchor.cell;this.moveClient({sheetId:this.getters.getActiveSheetId(),col:t,row:i})}const s=this.getters.getActiveSheetId();this.gridSelection.zones=this.gridSelection.zones.map((e=>this.getters.expandZone(s,e))),this.gridSelection.anchor.zone=this.getters.expandZone(s,this.gridSelection.anchor.zone),this.setSelectionMixin(this.gridSelection.anchor,this.gridSelection.zones)}this.selection.resetDefaultAnchor(this,_e(this.gridSelection.anchor))}isGridSelectionActive(){return this.selection.isListening(this)}getActiveSheet(){return this.activeSheet}getActiveSheetId(){return this.activeSheet.id}getActiveCell(){return this.getters.getEvaluatedCell(this.getActivePosition())}getActiveCols(){const e=new Set;for(let t of this.gridSelection.zones)if(0===t.top&&t.bottom===this.getters.getNumberRows(this.getters.getActiveSheetId())-1)for(let i=t.left;i<=t.right;i++)e.add(i);return e}getActiveRows(){const e=new Set,t=this.getters.getActiveSheetId();for(let i of this.gridSelection.zones)if(0===i.left&&i.right===this.getters.getNumberCols(t)-1)for(let t=i.top;t<=i.bottom;t++)e.add(t);return e}getCurrentStyle(){const e=this.getters.getSelectedZone(),t=this.getters.getActiveSheetId();return this.getters.getCellStyle({sheetId:t,col:e.left,row:e.top})}getSelectedZones(){return _e(this.gridSelection.zones)}getSelectedZone(){return _e(this.gridSelection.anchor.zone)}getSelection(){return _e(this.gridSelection)}getSelectedFigureId(){return this.selectedFigureId}getActivePosition(){return this.getters.getMainCellPosition({sheetId:this.getActiveSheetId(),col:this.gridSelection.anchor.cell.col,row:this.gridSelection.anchor.cell.row})}getSheetPosition(e){if(e===this.getters.getActiveSheetId())return this.getActivePosition();{const t=this.sheetsData[e];return t?{sheetId:e,col:t.gridSelection.anchor.cell.col,row:t.gridSelection.anchor.cell.row}:this.getters.getNextVisibleCellPosition({sheetId:e,col:0,row:0})}}getStatisticFnResults(){const e=this.getters.getActiveSheetId(),t=new Set;for(const i of this.gridSelection.zones)for(const{col:o,row:n}of no(i)){if(this.getters.isRowHidden(e,n)||this.getters.isColHidden(e,o))continue;const i=this.getters.getEvaluatedCell({sheetId:e,col:o,row:n});i.type!==ln.empty&&t.add(i)}let i=new Set,o=[];for(let e of t)i.add(e.type),o.push(e.value);let n={};for(let e of Gb){let t;e.types.some((e=>i.has(e)))&&(t=e.compute(o)),n[e.name]=t}return n}getAggregate(){let e=0,t=0;const i=this.getters.getActiveSheetId(),o=this.gridSelection.zones.map(no).flat();for(const{col:n,row:s}of o){const o=this.getters.getEvaluatedCell({sheetId:i,col:n,row:s});o.type===ln.number&&(t++,e+=o.value)}return t<2?null:mi(e)}isSelected(e){return!!this.getters.getSelectedZones().find((t=>Yi(t,e)))}getElementsFromSelection(e){if("COL"===e&&0===this.getters.getActiveCols().size)return[];if("ROW"===e&&0===this.getters.getActiveRows().size)return[];const t=this.getters.getSelectedZones();let i=[];const o="COL"===e?"left":"top",n="COL"===e?"right":"bottom";for(const e of t){const t=Array.from({length:e[n]-e[o]+1},((t,i)=>e[o]+i));i=i.concat(t)}return[...new Set(i)].sort()}setSelectionMixin(e,t){const{anchor:i,zones:o}=this.clipSelection(this.getters.getActiveSheetId(),{anchor:e,zones:t});this.gridSelection.anchor=i,this.gridSelection.zones=function(e){return e.reverse().filter(((e,t,i)=>t===i.findIndex((t=>t.top===e.top&&t.bottom===e.bottom&&t.left===e.left&&t.right===e.right)))).reverse()}(o)}selectCell(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.expandZone(i,{left:e,right:e,top:t,bottom:t});this.setSelectionMixin({zone:o,cell:{col:e,row:t}},[o])}setActiveSheet(e){const t=this.getters.getSheet(e);this.activeSheet=t}activateNextSheet(e){const t=this.getters.getSheetIds(),i=(t.findIndex((e=>e===this.activeSheet.id))+("left"===e?t.length-1:1))%t.length;this.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.getActiveSheetId(),sheetIdTo:t[i]})}onColumnsRemoved(e){const{cell:t,zone:i}=this.gridSelection.anchor,o=qi(i,"left",[...e.elements]);let n={left:t.col,right:t.col,top:t.row,bottom:t.row};n=qi(n,"left",[...e.elements]);const s={cell:{col:n.left,row:n.top},zone:o};this.setSelectionMixin(s,[o])}onRowsRemoved(e){const{cell:t,zone:i}=this.gridSelection.anchor,o=qi(i,"top",[...e.elements]);let n={left:t.col,right:t.col,top:t.row,bottom:t.row};n=qi(n,"top",[...e.elements]);const s={cell:{col:n.left,row:n.top},zone:o};this.setSelectionMixin(s,[o])}onAddElements(e){const t=Gi(this.gridSelection.anchor.zone,"COL"===e.dimension?"left":"top",e.base,e.position,e.quantity),i={cell:{col:t.left,row:t.top},zone:t};this.setSelectionMixin(i,[t])}onMoveElements(e){const t=e.elements.length;this.dispatch("ADD_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,base:e.base,quantity:t,position:e.position});const i="COL"===e.dimension,o=e.elements[0],n=e.elements[t-1],s=e.base<o,r=s&&i?t:0,a=s&&!i?t:0,l=[{left:i?o+r:0,right:i?n+r:this.getters.getNumberCols(e.sheetId)-1,top:i?0:o+a,bottom:i?this.getters.getNumberRows(e.sheetId)-1:n+a}],c=new Db(l,"CUT",this.getters,this.dispatch,this.selection),h=s?e.base:e.base+1,d=[{left:i?h:0,right:i?h+t-1:this.getters.getNumberCols(e.sheetId)-1,top:i?0:h,bottom:i?this.getters.getNumberRows(e.sheetId)-1:h+t-1}];c.paste(d,{selectTarget:!0});const u=s?e.elements.map((e=>e+t)):e.elements;let g=e.base;for(const t of u){const i="COL"===e.dimension?this.getters.getColSize(e.sheetId,t):this.getters.getRowSize(e.sheetId,t);this.dispatch("RESIZE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,size:i,elements:[g]}),g+=1}this.dispatch("REMOVE_COLUMNS_ROWS",{dimension:e.dimension,sheetId:e.sheetId,elements:u})}isMoveElementAllowed(e){const t="COL"===e.dimension,i=e.elements[0],o=e.elements[e.elements.length-1],n=e.sheetId,s=t?this.getters.doesColumnsHaveCommonMerges:this.getters.doesRowsHaveCommonMerges;if(s(n,i-1,i)||s(n,o,o+1)||s(n,e.base-1,e.base))return 2;const r=[e.base,...e.elements],a=t?this.getters.getNumberCols(n):this.getters.getNumberRows(n);return r.some((e=>e<0||e>=a))?86:0}clipSelection(e,t){const i=this.getters.getNumberCols(e)-1,o=this.getters.getNumberRows(e)-1;return{zones:t.zones.map((e=>({left:ke(e.left,0,i),right:ke(e.right,0,i),top:ke(e.top,0,o),bottom:ke(e.bottom,0,o)}))),anchor:{cell:{col:ke(t.anchor.cell.col,0,i),row:ke(t.anchor.cell.row,0,o)},zone:{left:ke(t.anchor.zone.left,0,i),right:ke(t.anchor.zone.right,0,i),top:ke(t.anchor.zone.top,0,o),bottom:ke(t.anchor.zone.bottom,0,o)}}}}drawGrid(e){if(this.getters.isDashboard())return;const{ctx:t,thinLineWidth:i}=e,o=this.getSelectedZones();t.fillStyle="#f3f7fe";const n=1===o.length&&o[0].left===o[0].right&&o[0].top===o[0].bottom;t.fillStyle=n?"#f3f7fe":"#e9f0ff",t.strokeStyle=E,t.lineWidth=1.5*i;for(const e of o){const{x:i,y:o,width:n,height:s}=this.getters.getVisibleRect(e);t.globalCompositeOperation="multiply",t.fillRect(i,o,n,s),t.globalCompositeOperation="source-over",t.strokeRect(i,o,n,s)}t.globalCompositeOperation="source-over";const s=this.getActivePosition();let r;t.strokeStyle=E,t.lineWidth=3*i,r=this.getters.isInMerge(s)?this.getters.getMerge(s):lo(s);const{x:a,y:l,width:c,height:h}=this.getters.getVisibleRect(r);c>0&&h>0&&t.strokeRect(a,l,c,h)}}qb.layers=[6],qb.getters=["getActiveSheet","getActiveSheetId","getActiveCell","getActiveCols","getActiveRows","getCurrentStyle","getSelectedZones","getSelectedZone","getStatisticFnResults","getAggregate","getSelectedFigureId","getSelection","getActivePosition","getSheetPosition","isSelected","getElementsFromSelection","isGridSelectionActive"];const Zb=(new Io).add("sheet",Kv).add("header visibility",Gv).add("filters",$v).add("cell",Lv).add("merge",Zv).add("headerSize",Wv).add("borders",kv).add("conditional formatting",Vv).add("figures",zv).add("chart",Pv).add("image",qv),jb=(new Io).add("ui_sheet",_b).add("header_visibility_ui",gb).add("ui_options",Nb).add("selectionInputManager",vb).add("highlight",pb).add("grid renderer",mb).add("autofill",lb).add("find_and_replace",ub).add("sort",Ob).add("automatic_sum",cb).add("format",class extends Qv{handle(e){if("SET_DECIMAL"===e.type)this.setDecimal(e.sheetId,e.target,e.step)}setDecimal(e,t,i){for(const o of t)for(const t of no(o)){const o=this.getCellNumberFormat({sheetId:e,...t});if(void 0!==o){const n=Ai(o,i);this.dispatch("SET_FORMATTING",{sheetId:e,target:[lo(t)],format:n})}}}getCellNumberFormat(e){var t;for(const i of[e]){const e=this.getters.getEvaluatedCell(i);if(e.type===ln.number&&!(null===(t=e.format)||void 0===t?void 0:t.match(Y)))return e.format||Ii(e.value)}}}).add("cell_popovers",hb).add("selection_multiuser",Mb),Xb=(new Io).add("selection",qb).add("clipboard",Vb).add("edition",Wb),Yb=(new Io).add("evaluation",tb).add("evaluation_filter",nb).add("evaluation_chart",ib).add("evaluation_cf",ob).add("viewport",rb).add("custom_colors",Jv),Kb=new Io;Kb.add("link",{condition:(e,t)=>!!t.model.getters.getEvaluatedCell(e).link,action:(e,t)=>_o(t.model.getters.getEvaluatedCell(e).link,t),sequence:5});class Qb{constructor(e){this.fileStore=e}async requestImage(){const e=await this.getImageFromUser(),t=await this.fileStore.upload(e);return{path:t,size:await this.getImageSize(t),mimetype:e.type}}getImageFromUser(){return new Promise(((e,t)=>{const i=document.createElement("input");i.setAttribute("type","file"),i.setAttribute("accept","image/*"),i.addEventListener("change",(async()=>{null===i.files||1!=i.files.length?t():e(i.files[0])})),i.click()}))}getImageSize(e){return new Promise(((t,i)=>{const o=new Image;o.src=e,o.addEventListener("load",(()=>{const e={width:o.width,height:o.height};t(e)})),o.addEventListener("error",i)}))}}const Jb=[{transform:"scale(0)"},{transform:"scale(0.8)",offset:.33},{opacity:"0",transform:"scale(1)",offset:1}];fo`
|
|
1401
1401
|
.o-ripple {
|
|
1402
1402
|
z-index: 1;
|
|
1403
1403
|
}
|
|
1404
|
-
`;class
|
|
1404
|
+
`;class eS extends t.Component{constructor(){super(...arguments),this.rippleRef=t.useRef("ripple")}setup(){let e;t.onMounted((()=>{const t=this.rippleRef.el;t&&t.animate&&(e=t.animate(Jb,{duration:this.props.duration,easing:"ease-out"}),e.addEventListener("finish",this.props.onAnimationEnd))})),t.onWillUnmount((()=>{null==e||e.removeEventListener("finish",this.props.onAnimationEnd)}))}get rippleStyle(){const{x:e,y:t,width:i,height:o}=this.props;return Co({transform:"scale(0)",left:e,top:t,"margin-left":`${-i/2+(this.props.offsetX||0)}px`,"margin-top":`${-o/2+(this.props.offsetY||0)}px`,width:`${i}px`,height:`${o}px`,background:this.props.color,"border-radius":"100%",opacity:`${this.props.opacity}`})}}eS.template="o-spreadsheet-RippleEffect",eS.props={x:String,y:String,color:String,opacity:Number,duration:Number,width:Number,height:Number,offsetY:Number,offsetX:Number,allowOverflow:Boolean,onAnimationEnd:Function,style:String};class tS extends t.Component{constructor(){super(...arguments),this.childContainer=t.useRef("childContainer"),this.state=t.useState({ripples:[]}),this.currentId=1}onClick(e){if(!this.props.enabled)return;if(!this.childContainer.el)return;const t=this.getRippleChildRectInfo(),{x:i,y:o,width:n,height:s}=t,r=Math.max(n,s),a={x:e.clientX-i,y:e.clientY-o,width:this.props.width||2.85*r,height:this.props.height||2.85*r};this.state.ripples.push({rippleRect:a,id:this.currentId++})}getRippleStyle(){const e=this.childContainer.el;if(!e||1!==e.childElementCount||!e.firstElementChild)return"";const t=this.getRippleChildRectInfo();return Co({top:t.marginTop+"px",left:t.marginLeft+"px",width:t.width+"px",height:t.height+"px"})}getRippleChildRectInfo(){const e=this.childContainer.el;if(!e)throw new Error("No child container element found");if(1!==e.childElementCount||!e.firstElementChild){return{...$n(e),marginLeft:0,marginTop:0}}const t=e.firstElementChild,i=function(e){const 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}}(t);return{...$n(t),marginLeft:i.left,marginTop:i.top}}removeRipple(e){const t=this.state.ripples.findIndex((t=>t.id===e));-1!==t&&this.state.ripples.splice(t,1)}getRippleEffectProps(e){var t;const i=null===(t=this.state.ripples.find((t=>t.id===e)))||void 0===t?void 0:t.rippleRect;if(!i)throw new Error("Cannot find a ripple with the id "+e);return{color:this.props.color,opacity:this.props.opacity,duration:this.props.duration,x:this.props.ignoreClickPosition?"50%":i.x+"px",y:this.props.ignoreClickPosition?"50%":i.y+"px",width:i.width,height:i.height,offsetX:this.props.offsetX||0,offsetY:this.props.offsetY||0,allowOverflow:this.props.allowOverflow||!1,style:this.getRippleStyle(),onAnimationEnd:()=>this.removeRipple(e)}}}tS.template="o-spreadsheet-Ripple",tS.components={RippleEffect:eS},tS.defaultProps={color:"#aaaaaa",opacity:.4,duration:800,enabled:!0,onAnimationEnd:()=>{},class:""},tS.props={color:{type:String,optional:!0},opacity:{type:Number,optional:!0},duration:{type:Number,optional:!0},ignoreClickPosition:{type:Boolean,optional:!0},width:{type:Number,optional:!0},height:{type:Number,optional:!0},offsetY:{type:Number,optional:!0},offsetX:{type:Number,optional:!0},allowOverflow:{type:Boolean,optional:!0},enabled:{type:Boolean,optional:!0},onAnimationEnd:{type:Function,optional:!0},slots:Object,class:{type:String,optional:!0}},fo`
|
|
1405
1405
|
.o-sheet {
|
|
1406
1406
|
color: #666;
|
|
1407
1407
|
padding: 0 15px;
|
|
@@ -1442,7 +1442,7 @@
|
|
|
1442
1442
|
}
|
|
1443
1443
|
}
|
|
1444
1444
|
}
|
|
1445
|
-
`;class
|
|
1445
|
+
`;class iS extends t.Component{constructor(){super(...arguments),this.state=t.useState({isEditing:!1}),this.sheetDivRef=t.useRef("sheetDiv"),this.sheetNameRef=t.useRef("sheetNameSpan"),this.editionState="initializing"}setup(){t.onMounted((()=>{this.isSheetActive&&this.scrollToSheet()})),t.onPatched((()=>{this.sheetNameRef.el&&this.state.isEditing&&"initializing"===this.editionState&&(this.editionState="editing",this.focusInputAndSelectContent())}))}focusInputAndSelectContent(){var e;if(!this.state.isEditing||!this.sheetNameRef.el)return;this.sheetNameRef.el.focus();const t=window.getSelection();t&&this.sheetNameRef.el.firstChild&&t.setBaseAndExtent(this.sheetNameRef.el.firstChild,0,this.sheetNameRef.el.firstChild,(null===(e=this.sheetNameRef.el.textContent)||void 0===e?void 0:e.length)||0)}scrollToSheet(){var e,t;null===(t=null===(e=this.sheetDivRef.el)||void 0===e?void 0:e.scrollIntoView)||void 0===t||t.call(e)}onFocusOut(){this.state.isEditing&&"initializing"!==this.editionState&&this.stopEdition()}onMouseDown(e){this.activateSheet(),this.props.onMouseDown(e)}activateSheet(){this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:this.env.model.getters.getActiveSheetId(),sheetIdTo:this.props.sheetId}),this.scrollToSheet()}onDblClick(){this.startEdition()}onKeyDown(e){this.state.isEditing&&("Enter"===e.key&&(e.preventDefault(),this.stopEdition()),"Escape"===e.key&&this.cancelEdition())}onClickSheetName(e){this.state.isEditing&&e.stopPropagation()}startEdition(){this.state.isEditing=!0,this.editionState="initializing"}stopEdition(){var e;if(!this.state.isEditing)return;this.state.isEditing=!1,this.editionState="initializing",null===(e=this.sheetNameRef.el)||void 0===e||e.blur();const t=this.getInputContent()||"";!function(e,t,i,o){const n=e.model.getters.getSheetName(t);if(null===i||i===n)return;const r=e.model.dispatch("RENAME_SHEET",{sheetId:t,name:i});r.reasons.includes(10)?e.raiseError(s("The sheet name cannot be empty."),o):r.reasons.includes(11)?e.raiseError(s("A sheet with the name %s already exists. Please select another name.",i),o):r.reasons.includes(13)&&e.raiseError(s("Some used characters are not allowed in a sheet name (Forbidden characters are %s).",se.join(" ")),o)}(this.env,this.props.sheetId,t,(()=>this.startEdition()))}cancelEdition(){var e;this.state.isEditing=!1,this.editionState="initializing",null===(e=this.sheetNameRef.el)||void 0===e||e.blur(),this.setInputContent(this.sheetName)}onIconClick(e){this.isSheetActive||this.activateSheet(),this.props.openContextMenu(this.contextMenuRegistry,e)}onContextMenu(e){this.isSheetActive||this.activateSheet(),this.props.openContextMenu(this.contextMenuRegistry,e)}getInputContent(){var e;return null===(e=this.sheetNameRef.el)||void 0===e?void 0:e.textContent}setInputContent(e){this.sheetNameRef.el&&(this.sheetNameRef.el.textContent=e)}get contextMenuRegistry(){return function(e){const t=new as;return t.add("delete",{name:s("Delete"),sequence:10,isVisible:e=>e.model.getters.getSheetIds().length>1,action:e=>e.askConfirmation(s("Are you sure you want to delete this sheet ?"),(()=>{e.model.dispatch("DELETE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})}))}).add("duplicate",{name:s("Duplicate"),sequence:20,action:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.uuidGenerator.uuidv4();e.model.dispatch("DUPLICATE_SHEET",{sheetId:t,sheetIdTo:i}),e.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:i})}}).add("rename",{name:s("Rename"),sequence:30,action:()=>e.renameSheetCallback()}).add("move_right",{name:s("Move right"),sequence:40,isVisible:e=>{const t=e.model.getters.getActiveSheetId(),i=e.model.getters.getVisibleSheetIds();return i.indexOf(t)!==i.length-1},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),delta:1})}).add("move_left",{name:s("Move left"),sequence:50,isVisible:e=>{const t=e.model.getters.getActiveSheetId();return e.model.getters.getVisibleSheetIds()[0]!==t},action:e=>e.model.dispatch("MOVE_SHEET",{sheetId:e.model.getters.getActiveSheetId(),delta:-1})}).add("hide_sheet",{name:s("Hide sheet"),sequence:60,isVisible:e=>1!==e.model.getters.getVisibleSheetIds().length,action:e=>e.model.dispatch("HIDE_SHEET",{sheetId:e.model.getters.getActiveSheetId()})}),t}({renameSheetCallback:()=>{this.scrollToSheet(),this.startEdition()}})}get isSheetActive(){return this.env.model.getters.getActiveSheetId()===this.props.sheetId}get sheetName(){return this.env.model.getters.getSheetName(this.props.sheetId)}}iS.template="o-spreadsheet-BottomBarSheet",iS.components={Ripple:tS},iS.defaultProps={onMouseDown:()=>{},style:""},iS.props={sheetId:String,openContextMenu:Function,style:{type:String,optional:!0},onMouseDown:{type:Function,optional:!0}},fo`
|
|
1446
1446
|
.o-selection-statistic {
|
|
1447
1447
|
margin-right: 20px;
|
|
1448
1448
|
padding: 4px 4px 4px 8px;
|
|
@@ -1452,7 +1452,7 @@
|
|
|
1452
1452
|
background-color: rgba(0, 0, 0, 0.08) !important;
|
|
1453
1453
|
}
|
|
1454
1454
|
}
|
|
1455
|
-
`;class
|
|
1455
|
+
`;class oS extends t.Component{constructor(){super(...arguments),this.selectedStatisticFn="",this.statisticFnResults={}}setup(){this.statisticFnResults=this.env.model.getters.getStatisticFnResults(),t.onWillUpdateProps((()=>{const e=this.env.model.getters.getStatisticFnResults();ct(e,this.statisticFnResults)||this.props.closeContextMenu(),this.statisticFnResults=e}))}getSelectedStatistic(){if(!Object.values(this.statisticFnResults).every((e=>void 0===e)))return""===this.selectedStatisticFn&&(this.selectedStatisticFn=Object.keys(this.statisticFnResults)[0]),this.getComposedFnName(this.selectedStatisticFn,this.statisticFnResults[this.selectedStatisticFn])}listSelectionStatistics(e){const t=new as;let i=0;for(let[e,o]of Object.entries(this.statisticFnResults))t.add(e,{name:this.getComposedFnName(e,o),sequence:i,isReadonlyAllowed:!0,action:()=>{this.selectedStatisticFn=e}}),i++;const o=e.currentTarget,{top:n,left:s,width:r}=o.getBoundingClientRect();this.props.openContextMenu(s+r,n,t)}getComposedFnName(e,t){return e+": "+(void 0!==t?mi(t):"__")}}oS.template="o-spreadsheet-BottomBarStatisic",oS.components={Ripple:tS},oS.props={openContextMenu:Function,closeContextMenu:Function};class nS{constructor(e){this.edgeScrollOffset=0,this.items=e.items.map((e=>({...e,positionAtStart:e.position}))),this.draggedItemId=e.draggedItemId,this.containerEl=e.containerEl,this.onChange=e.onChange,this.onCancel=e.onCancel,this.onDragEnd=e.onDragEnd,this.initialMousePosition=e.mouseX,this.currentMousePosition=e.mouseX,this.minPosition=this.items[0].position,this.maxPosition=this.items[this.items.length-1].position+this.items[this.items.length-1].size,Pg(this.onMouseMove.bind(this),this.onMouseUp.bind(this))}onMouseMove(e){if(0!==e.button)return void this.onCancel();const t=e.clientX;t<this.containerRect.left||t>this.containerRect.right?this.startEdgeScroll(t<this.containerRect.left?-1:1):(this.stopEdgeScroll(),this.moveDraggedItemToPosition(t+this.edgeScrollOffset))}moveDraggedItemToPosition(e){this.currentMousePosition=e;const t=this.getHoveredItemIndex(e,this.items),i=this.items.findIndex((e=>e.id===this.draggedItemId)),o=this.items[i];if(this.deadZone&&this.isInZone(e,this.deadZone))return void this.onChange(this.getItemsPositions());if(this.isInZone(e,{start:o.position,end:o.position+o.size})&&(this.deadZone=void 0),i===t)return void this.onChange(this.getItemsPositions());const n=Math.min(i,t),s=Math.max(i,t),r=Math.sign(t-i);let a=0;for(let e=n;e<=s;e++)e!==i&&(this.items[e].position-=r*o.size,a+=this.items[e].size);o.position+=r*a,this.items.sort(((e,t)=>e.position-t.position)),this.deadZone=r>0?{start:e,end:o.position}:{start:o.position+o.size,end:e},this.onChange(this.getItemsPositions())}onMouseUp(e){0!==e.button&&this.onCancel();const t=this.items.findIndex((e=>e.id===this.draggedItemId));this.onDragEnd(this.draggedItemId,t),this.stopEdgeScroll()}startEdgeScroll(e){this.edgeScrollIntervalId||(this.edgeScrollIntervalId=window.setInterval((()=>{const t=3*e;let i=this.currentMousePosition+t;i<this.minPosition?i=this.minPosition:i>this.maxPosition&&(i=this.maxPosition),this.edgeScrollOffset+=i-this.currentMousePosition,this.moveDraggedItemToPosition(i),this.containerEl.scrollLeft+=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(){const e={};for(let t of this.items){if(t.id!==this.draggedItemId){e[t.id]=t.position-t.positionAtStart;continue}let i=this.currentMousePosition-this.initialMousePosition;i=Math.max(this.minPosition-t.positionAtStart,i),i=Math.min(this.maxPosition-t.positionAtStart-t.size,i),e[t.id]=i}return e}get containerRect(){return this.containerEl.getBoundingClientRect()}isInZone(e,t){return e>=t.start&&e<=t.end}destroy(){this.stopEdgeScroll()}}fo`
|
|
1456
1456
|
.o-spreadsheet-bottom-bar {
|
|
1457
1457
|
background-color: ${f};
|
|
1458
1458
|
padding-left: ${_}px;
|
|
@@ -1501,12 +1501,12 @@
|
|
|
1501
1501
|
}
|
|
1502
1502
|
}
|
|
1503
1503
|
}
|
|
1504
|
-
`;class
|
|
1504
|
+
`;class sS extends t.Component{constructor(){super(...arguments),this.bottomBarRef=t.useRef("bottomBar"),this.sheetListRef=t.useRef("sheetList"),this.targetScroll=void 0,this.state=t.useState({isSheetListScrollableLeft:!1,isSheetListScrollableRight:!1}),this.menuMaxHeight=250,this.menuState=t.useState({isOpen:!1,menuId:void 0,position:null,menuItems:[]}),this.sheetState=t.useState({sheetList:this.getVisibleSheets(),isDnd:!1,sheetDndPositions:void 0})}setup(){t.onWillUpdateProps((()=>{this.updateScrollState();const e=this.getVisibleSheets();this.sheetState.isDnd&&!ct(this.sheetState.sheetList,e)&&this.stopDragging(),this.sheetState.sheetList=e})),t.onWillUnmount((()=>{var e;null===(e=this.dndHelper)||void 0===e||e.destroy()}))}isDragged(e){var t;return this.sheetState.isDnd&&(null===(t=this.dndHelper)||void 0===t?void 0:t.draggedItemId)===e}clickAddSheet(e){const t=this.env.model.getters.getActiveSheetId(),i=this.env.model.getters.getSheetIds().findIndex((e=>e===t))+1,o=this.env.model.uuidGenerator.uuidv4(),n=this.env.model.getters.getNextSheetName(this.env._t("Sheet"));this.env.model.dispatch("CREATE_SHEET",{sheetId:o,position:i,name:n}),this.env.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:t,sheetIdTo:o})}getVisibleSheets(){return this.env.model.getters.getVisibleSheetIds().map((e=>{const t=this.env.model.getters.getSheet(e);return{id:t.id,name:t.name}}))}getSheets(){return this.sheetState.sheetList}clickListSheets(e){const t=new as,i=this.env.model.getters.getActiveSheetId();let o=0;for(const e of this.env.model.getters.getSheetIds()){const n=this.env.model.getters.getSheet(e);t.add(e,{name:n.name,sequence:o,isReadonlyAllowed:!0,textColor:n.isVisible?void 0:"grey",action:t=>{t.model.dispatch("ACTIVATE_SHEET",{sheetIdFrom:i,sheetIdTo:e})}}),o++}const n=e.currentTarget,{left:s}=n.getBoundingClientRect(),r=this.bottomBarRef.el.getBoundingClientRect().top;this.openContextMenu(s,r,"listSheets",t)}openContextMenu(e,t,i,o){this.menuState.isOpen=!0,this.menuState.menuId=i,this.menuState.menuItems=o.getMenuItems(),this.menuState.position={x:e,y:t}}onSheetContextMenu(e,t,i){const o=i.currentTarget,{top:n,left:s}=o.getBoundingClientRect();i.closedMenuId!==e?this.openContextMenu(s,n,e,t):this.closeMenu()}closeMenu(){this.menuState.isOpen=!1,this.menuState.menuId=void 0,this.menuState.menuItems=[],this.menuState.position=null}closeContextMenuWithId(e){this.menuState.menuId===e&&this.closeMenu()}onWheel(e){this.targetScroll=void 0;e.currentTarget.scrollLeft+=.5*e.deltaY}onScroll(){this.updateScrollState(),this.targetScroll===this.sheetListCurrentScroll&&(this.targetScroll=void 0)}onArrowLeft(e){if(!this.state.isSheetListScrollableLeft)return;this.targetScroll||(this.targetScroll=this.sheetListCurrentScroll);const t=this.targetScroll-this.sheetListWidth;this.scrollSheetListTo(Math.max(0,t))}onArrowRight(e){if(!this.state.isSheetListScrollableRight)return;this.targetScroll||(this.targetScroll=this.sheetListCurrentScroll);const t=this.targetScroll+this.sheetListWidth;this.scrollSheetListTo(Math.min(this.sheetListMaxScroll,t))}updateScrollState(){this.state.isSheetListScrollableLeft=this.sheetListCurrentScroll>0,this.state.isSheetListScrollableRight=this.sheetListCurrentScroll<this.sheetListMaxScroll}scrollSheetListTo(e){this.sheetListRef.el&&(this.targetScroll=e,this.sheetListRef.el.scrollTo({top:0,left:e,behavior:"smooth"}))}onSheetMouseDown(e,t){if(0!==t.button)return;this.closeMenu();const i=t.clientX;document.body.style.cursor="move";const o=this.getVisibleSheets(),n=this.getSheetItemRects(),s=o.map(((e,t)=>({id:e.id,size:n[t].width,position:n[t].x})));this.dndHelper=new nS({draggedItemId:e,mouseX:i,items:s,containerEl:this.sheetListRef.el,onChange:e=>{this.sheetState.isDnd=!0,this.sheetState.sheetDndPositions=e},onCancel:()=>this.stopDragging(),onDragEnd:(e,t)=>this.onDragEnd(e,t)})}onDragEnd(e,t){const i=t-this.sheetState.sheetList.findIndex((t=>t.id===e));e&&0!==i&&this.env.model.dispatch("MOVE_SHEET",{sheetId:e,delta:i}),this.stopDragging()}getSheetStyle(e){var t;const i={};return this.sheetState.isDnd&&(i.position="relative",i.left=((null===(t=this.sheetState.sheetDndPositions)||void 0===t?void 0:t[e])||0)+"px",i.transition="left 0.5s",i.cursor="move"),this.isDragged(e)&&(i.transition="left 0s",i["z-index"]="1000"),Co(i)}stopDragging(){document.body.style.cursor="",this.sheetState.sheetList=this.getVisibleSheets(),this.sheetState.isDnd=!1,this.sheetState.sheetDndPositions=void 0,this.dndHelper=void 0}getSheetItemRects(){return Array.from(this.bottomBarRef.el.querySelectorAll(".o-sheet")).map((e=>e.getBoundingClientRect())).map((e=>({x:e.x,width:e.width-1,y:e.y,height:e.height})))}getSheetClasses(e){let t="";return this.isDragged(e)&&(t+="dragged "),this.sheetState.isDnd&&(t+="dragging "),t}get sheetListCurrentScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollLeft:0}get sheetListWidth(){return this.sheetListRef.el?this.sheetListRef.el.clientWidth:0}get sheetListMaxScroll(){return this.sheetListRef.el?this.sheetListRef.el.scrollWidth-this.sheetListRef.el.clientWidth:0}}sS.template="o-spreadsheet-BottomBar",sS.components={Menu:ts,Ripple:tS,BottomBarSheet:iS,BottomBarStatistic:oS},sS.props={onClick:Function},fo`
|
|
1505
1505
|
.o-dashboard-clickable-cell {
|
|
1506
1506
|
position: absolute;
|
|
1507
1507
|
cursor: pointer;
|
|
1508
1508
|
}
|
|
1509
|
-
`;let
|
|
1509
|
+
`;let rS=1;class aS extends t.Component{setup(){const e=t.useRef("grid");this.canvasPosition=jn(e),this.hoveredCell=t.useState({col:void 0,row:void 0}),t.useChildSubEnv({getPopoverContainerRect:()=>this.getGridRect()}),dp("canvas",this.env.model,(()=>this.env.model.getters.getSheetViewDimension())),this.onMouseWheel=up(((e,t)=>{this.moveCanvas(e,t),this.hoveredCell.col=void 0,this.hoveredCell.row=void 0}))}onCellHovered({col:e,row:t}){this.hoveredCell.col=e,this.hoveredCell.row=t}get gridContainer(){const e=this.env.model.getters.getActiveSheetId(),{right:t}=this.env.model.getters.getSheetZone(e),{end:i}=this.env.model.getters.getColDimensions(e,t);return Co({"max-width":`${i}px`})}get gridOverlayDimensions(){return Co({height:"100%",width:"100%"})}getCellClickableStyle(e){return Co({top:`${e.y}px`,left:`${e.x}px`,width:`${e.width}px`,height:`${e.height}px`})}getClickableCells(){const e=[],t=this.env.model.getters.getActiveSheetId();for(const i of this.env.model.getters.getSheetViewVisibleCols())for(const o of this.env.model.getters.getSheetViewVisibleRows()){const n={sheetId:t,col:i,row:o},s=this.getClickableAction(n);if(!s)continue;let r;r=this.env.model.getters.isInMerge(n)?this.env.model.getters.getMerge(n):lo({col:i,row:o});const a=this.env.model.getters.getVisibleRect(r);e.push({coordinates:a,position:{col:i,row:o},action:s,tKey:`${rS}-${i}-${o}`})}return rS++,e}getClickableAction(e){for(const t of Kb.getAll().sort(((e,t)=>e.sequence-t.sequence)))if(t.condition(e,this.env))return t.action;return!1}selectClickableCell(e){const{position:t,action:i}=e;i({...t,sheetId:this.env.model.getters.getActiveSheetId()},this.env)}onClosePopover(){this.env.model.dispatch("CLOSE_CELL_POPOVER")}onGridResized({height:e,width:t}){this.env.model.dispatch("RESIZE_SHEETVIEW",{width:t,height:e,gridOffsetX:0,gridOffsetY:0})}moveCanvas(e,t){const{scrollX:i,scrollY:o}=this.env.model.getters.getActiveSheetDOMScrollInfo();this.env.model.dispatch("SET_VIEWPORT_OFFSET",{offsetX:i+e,offsetY:o+t})}getGridRect(){return{...this.canvasPosition,...this.env.model.getters.getSheetViewDimensionWithHeaders()}}}aS.template="o-spreadsheet-SpreadsheetDashboard",aS.components={GridOverlay:sp,GridPopover:rp,Popover:Kn,VerticalScrollBar:Sp,HorizontalScrollBar:bp,FilterIconsOverlay:ip},aS.props={},fo`
|
|
1510
1510
|
.o-sidePanel {
|
|
1511
1511
|
display: flex;
|
|
1512
1512
|
flex-direction: column;
|
|
@@ -1675,14 +1675,14 @@
|
|
|
1675
1675
|
}
|
|
1676
1676
|
}
|
|
1677
1677
|
}
|
|
1678
|
-
`;class
|
|
1678
|
+
`;class lS extends t.Component{setup(){this.state=t.useState({panel:Dg.get(this.props.component)}),t.onWillUpdateProps((e=>this.state.panel=Dg.get(e.component)))}getTitle(){return"function"==typeof this.state.panel.title?this.state.panel.title(this.env):this.state.panel.title}}lS.template="o-spreadsheet-SidePanel",lS.props={component:String,panelProps:{type:Object,optional:!0},onCloseSidePanel:Function};const cS={MergeIsDestructive:s("Merging these cells will only preserve the top-leftmost value. Merge anyway?"),MergeInFilter:s("You can't merge cells inside of an existing filter.")};fo`
|
|
1679
1679
|
.o-topbar-composer {
|
|
1680
1680
|
height: fit-content;
|
|
1681
1681
|
margin-top: -1px;
|
|
1682
1682
|
border: 1px solid;
|
|
1683
1683
|
z-index: ${ce.TopBarComposer};
|
|
1684
1684
|
}
|
|
1685
|
-
`;class
|
|
1685
|
+
`;class hS extends t.Component{get composerStyle(){const e={padding:"5px 0px 5px 8px","max-height":"100px","line-height":"24px"};return e.height="inactive"===this.props.focus?"34px":"fit-content",Co(e)}get containerStyle(){return"inactive"===this.props.focus?Co({"border-color":M,"border-right":"none"}):Co({"border-color":E})}}hS.template="o-spreadsheet-TopBarComposer",hS.components={Composer:Yg},hS.props={focus:{validate:e=>["inactive","cellFocus","contentFocus"].includes(e)},onComposerContentFocused:Function},fo`
|
|
1686
1686
|
.o-font-size-editor {
|
|
1687
1687
|
height: calc(100% - 4px);
|
|
1688
1688
|
input.o-font-size {
|
|
@@ -1697,7 +1697,7 @@
|
|
|
1697
1697
|
-webkit-appearance: none;
|
|
1698
1698
|
}
|
|
1699
1699
|
}
|
|
1700
|
-
`;class
|
|
1700
|
+
`;class dS extends t.Component{constructor(){super(...arguments),this.fontSizes=de,this.dropdown=t.useState({isOpen:!1}),this.inputRef=t.useRef("inputFontSize"),this.rootEditorRef=t.useRef("FontSizeEditor")}setup(){t.useExternalListener(window,"click",this.onExternalClick,{capture:!0})}onExternalClick(e){Bn(this.rootEditorRef.el,e)||this.closeFontList()}get currentFontSize(){return this.env.model.getters.getCurrentStyle().fontSize||q}toggleFontList(){this.dropdown.isOpen?this.closeFontList():(this.props.onToggle(),this.inputRef.el.focus())}closeFontList(){this.dropdown.isOpen=!1}setSize(e){const t=ke(Math.floor(parseFloat(e)),1,400);Vr(this.env,{fontSize:t}),this.closeFontList()}setSizeFromInput(e){this.setSize(e.target.value)}setSizeFromList(e){this.setSize(e)}onInputFocused(e){this.dropdown.isOpen=!0,e.target.select()}onInputKeydown(e){if("Enter"===e.key||"Escape"===e.key){this.closeFontList();const t=e.target;"Escape"===e.key&&(t.value=`${this.currentFontSize}`),this.props.onToggle()}}}dS.template="o-spreadsheet-FontSizeEditor",dS.components={},dS.props={onToggle:Function,dropdownStyle:String,class:String};const uS=[{name:"automatic",text:Ds.Automatic},{name:"number",text:Ds.Number,description:"1,000.12",value:"#,##0.00"},{name:"percent",text:Ds.Percent,description:"10.12%",value:"0.00%"},{name:"currency",text:Ds.Currency,description:"$1,000.12",value:"[$$]#,##0.00"},{name:"currency_rounded",text:Ds.CurrencyRounded,description:"$1,000",value:"[$$]#,##0"},{name:"date",text:Ds.Date,description:"9/26/2008",value:"m/d/yyyy"},{name:"time",text:Ds.Time,description:"10:43:00 PM",value:"hh:mm:ss a"},{name:"datetime",text:Ds.DateTime,description:"9/26/2008 22:43:00",value:"m/d/yyyy hh:mm:ss"},{name:"duration",text:Ds.Duration,description:"27:51:38",value:"hhhh:mm:ss"}],gS=[{name:"custom_currency",text:Ds.CustomCurrency,sidePanel:"CustomCurrency"}],pS="#4a4f59";fo`
|
|
1701
1701
|
.o-spreadsheet-topbar {
|
|
1702
1702
|
background-color: white;
|
|
1703
1703
|
line-height: 1.2;
|
|
@@ -1707,7 +1707,7 @@
|
|
|
1707
1707
|
line-height: 1.2;
|
|
1708
1708
|
user-select: none;
|
|
1709
1709
|
font-weight: 500;
|
|
1710
|
-
color: ${
|
|
1710
|
+
color: ${pS};
|
|
1711
1711
|
|
|
1712
1712
|
.o-topbar-top {
|
|
1713
1713
|
border-bottom: 1px solid ${M};
|
|
@@ -1774,7 +1774,7 @@
|
|
|
1774
1774
|
svg path,
|
|
1775
1775
|
polygon,
|
|
1776
1776
|
rect {
|
|
1777
|
-
fill: ${
|
|
1777
|
+
fill: ${pS};
|
|
1778
1778
|
}
|
|
1779
1779
|
}
|
|
1780
1780
|
|
|
@@ -1899,7 +1899,7 @@
|
|
|
1899
1899
|
}
|
|
1900
1900
|
}
|
|
1901
1901
|
}
|
|
1902
|
-
`;class
|
|
1902
|
+
`;class mS extends t.Component{constructor(){super(...arguments),this.commonFormats=uS,this.customFormats=gS,this.currentFormatName="automatic",this.style={},this.state=t.useState({menuState:{isOpen:!1,position:null,menuItems:[]},activeTool:""}),this.isSelectingMenu=!1,this.openedEl=null,this.inMerge=!1,this.cannotMerge=!1,this.undoTool=!1,this.redoTool=!1,this.paintFormatTool=!1,this.fillColor="#ffffff",this.textColor="#000000",this.menus=[]}get dropdownStyle(){return`max-height:${this.props.dropdownMaxHeight}px`}setup(){t.useExternalListener(window,"click",this.onExternalClick),t.onWillStart((()=>this.updateCellState())),t.onWillUpdateProps((()=>this.updateCellState()))}get topbarComponents(){return kg.getAll().filter((e=>!e.isVisible||e.isVisible(this.env)))}onExternalClick(e){this.openedEl!==e.target&&this.closeMenus()}onClick(){this.props.onClick(),this.closeMenus()}toggleStyle(e){Vr(this.env,{[e]:!this.style[e]})}toggleFormat(e){const t=uS.find((t=>t.name===e)),i=t&&t.value||"";Ur(this.env,i)}toggleHorizontalAlign(e){Vr(this.env,{align:e}),this.onClick()}toggleVerticalAlign(e){Vr(this.env,{verticalAlign:e}),this.onClick()}toggleTextWrapping(e){Vr(this.env,{wrapping:e}),this.onClick()}onMenuMouseOver(e,t){this.isSelectingMenu&&this.openMenu(e,t)}toggleDropdownTool(e,t){const i=this.state.activeTool===e;this.closeMenus(),this.state.activeTool=i?"":e,this.openedEl=i?null:t.target}toggleContextMenu(e,t){this.state.menuState.isOpen?this.closeMenus():this.openMenu(e,t)}openMenu(e,t){const{left:i,top:o,height:n}=t.target.getBoundingClientRect();this.state.menuState.isOpen=!0,this.state.menuState.position={x:i,y:o+n},this.state.menuState.menuItems=e.children(this.env),this.state.menuState.parentMenu=e,this.isSelectingMenu=!0,this.openedEl=t.target,this.env.model.dispatch("STOP_EDITION")}closeMenus(){this.state.activeTool="",this.state.menuState.isOpen=!1,this.state.menuState.parentMenu=void 0,this.isSelectingMenu=!1,this.openedEl=null}updateCellState(){const e=this.env.model.getters.getSelectedZones(),{col:t,row:i,sheetId:o}=this.env.model.getters.getActivePosition();this.inMerge=!1;const{top:n,left:s,right:r,bottom:a}=this.env.model.getters.getSelectedZone(),{xSplit:l,ySplit:c}=this.env.model.getters.getPaneDivisions(o);if(this.cannotMerge=e.length>1||n===a&&s===r||s<l&&l<=r||n<c&&c<=a,!this.cannotMerge){const n=this.env.model.getters.expandZone(o,lo({col:t,row:i}));this.inMerge=Yi(e[0],n)}this.undoTool=this.env.model.getters.canUndo(),this.redoTool=this.env.model.getters.canRedo(),this.paintFormatTool=this.env.model.getters.isPaintingFormat();const h=this.env.model.getters.getActiveCell();if(h.format){const e=this.commonFormats.find((e=>e.value===h.format));this.currentFormatName=e?e.name:""}else this.currentFormatName="automatic";this.style={...this.env.model.getters.getCurrentStyle()},this.style.align=this.style.align||h.defaultAlign,this.fillColor=this.style.fillColor||"#ffffff",this.textColor=this.style.textColor||"#000000",this.menus=og.getMenuItems()}getMenuName(e){return e.name(this.env)}toggleMerge(){if(this.cannotMerge)return;const e=this.env.model.getters.getSelectedZones(),t=[e[e.length-1]],i=this.env.model.getters.getActiveSheetId();this.inMerge?this.env.model.dispatch("REMOVE_MERGE",{sheetId:i,target:t}):function(e,t,i){const o=e.model.dispatch("ADD_MERGE",{sheetId:t,target:i});o.isCancelledBecause(80)?e.raiseError(cS.MergeInFilter):o.isCancelledBecause(3)&&e.askConfirmation(cS.MergeIsDestructive,(()=>{e.model.dispatch("ADD_MERGE",{sheetId:t,target:i,force:!0})}))}(this.env,i,t)}setColor(e,t){Vr(this.env,{[e]:t}),this.onClick()}setBorder(e){this.env.model.dispatch("SET_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),border:e}),this.onClick()}setFormat(e,t){t?this.openCustomFormatSidePanel(e):this.toggleFormat(e),this.onClick()}openCustomFormatSidePanel(e){const t=gS.find((t=>t.name===e)),i=t&&t.sidePanel||"";this.env.openSidePanel(i)}setDecimal(e){this.env.model.dispatch("SET_DECIMAL",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones(),step:e})}paintFormat(){this.env.model.dispatch("ACTIVATE_PAINT_FORMAT",{target:this.env.model.getters.getSelectedZones()})}clearFormatting(){this.env.model.dispatch("CLEAR_FORMATTING",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}doAction(e){e(this.env),this.closeMenus()}undo(){this.env.model.dispatch("REQUEST_UNDO")}redo(){this.env.model.dispatch("REQUEST_REDO")}get selectionContainsFilter(){const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZones();return this.env.model.getters.doesZonesContainFilter(e,t)}get cannotCreateFilter(){return!uo(...this.env.model.getters.getSelectedZones())}createFilter(){if(this.cannotCreateFilter)return;this.env.model.selection.selectTableAroundSelection();const e=this.env.model.getters.getActiveSheetId(),t=this.env.model.getters.getSelectedZones();Nr(this.env,e,t)}removeFilter(){this.env.model.dispatch("REMOVE_FILTER_TABLE",{sheetId:this.env.model.getters.getActiveSheetId(),target:this.env.model.getters.getSelectedZones()})}}mS.template="o-spreadsheet-TopBar",mS.components={ColorPickerWidget:fg,Menu:ts,TopBarComposer:hS,FontSizeEditor:dS},mS.props={onClick:Function,focusComposer:String,onComposerContentFocused:Function,dropdownMaxHeight:Number};class fS{constructor(e){this.clipboard=e}async write(e){var t;try{null===(t=this.clipboard)||void 0===t||t.write(this.getClipboardItems(e))}catch(e){}}async writeText(e){var t;try{null===(t=this.clipboard)||void 0===t||t.writeText(e)}catch(e){}}async readText(){let e;try{e=await navigator.permissions.query({name:"clipboard-read"})}catch(e){}try{return{status:"ok",content:await this.clipboard.readText()}}catch(t){return{status:"denied"===(null==e?void 0:e.state)?"permissionDenied":"notImplemented"}}}getClipboardItems(e){return[new ClipboardItem({[cn.PlainText]:this.getBlob(e,cn.PlainText),[cn.Html]:this.getBlob(e,cn.Html)})]}getBlob(e,t){return new Blob([e[t]||""],{type:t})}}fo`
|
|
1903
1903
|
.o-spreadsheet {
|
|
1904
1904
|
position: relative;
|
|
1905
1905
|
display: grid;
|
|
@@ -1972,23 +1972,23 @@
|
|
|
1972
1972
|
outline: none;
|
|
1973
1973
|
}
|
|
1974
1974
|
}
|
|
1975
|
-
`;class mS extends t.Component{constructor(){super(...arguments),this.isViewportTooSmall=!1}get model(){return this.props.model}getStyle(){return this.env.isDashboard()?"grid-template-rows: auto;":"grid-template-rows: 63px auto 37px"}setup(){this.sidePanel=t.useState({isOpen:!1,panelProps:{}}),this.composer=t.useState({topBarFocus:"inactive",gridFocusMode:"inactive"}),this.keyDownMapping={"CTRL+H":()=>this.toggleSidePanel("FindAndReplace",{}),"CTRL+F":()=>this.toggleSidePanel("FindAndReplace",{})};const e=this.model.config.external.fileStore;t.useSubEnv({model:this.model,imageProvider:e?new Yb(e):void 0,loadCurrencies:this.model.config.external.loadCurrencies,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.openSidePanel.bind(this),toggleSidePanel:this.toggleSidePanel.bind(this),_t:mS._t,clipboard:this.env.clipboard||new pS(navigator.clipboard),startCellEdition:e=>this.onGridComposerCellFocused(e)}),t.useExternalListener(window,"resize",(()=>this.render(!0))),t.useExternalListener(window,"beforeunload",this.unbindModelEvents.bind(this)),this.bindModelEvents(),t.onMounted((()=>{this.checkViewportSize()})),t.onWillUnmount((()=>this.unbindModelEvents())),t.onPatched((()=>{this.checkViewportSize()}))}get focusTopBarComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.topBarFocus}get focusGridComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.gridFocusMode}bindModelEvents(){this.model.on("update",this,(()=>this.render(!0))),this.model.on("notify-ui",this,this.onNotifyUI)}unbindModelEvents(){this.model.off("update",this),this.model.off("notify-ui",this)}checkViewportSize(){const{xRatio:e,yRatio:t}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());if(t>.85||e>.85){if(this.isViewportTooSmall)return;this.env.notifyUser({text:s("The current window is too small to display this sheet properly. Consider resizing your browser window or adjusting frozen rows and columns."),tag:"viewportTooSmall"}),this.isViewportTooSmall=!0}else this.isViewportTooSmall=!1}onNotifyUI(e){if("ERROR"===e.type)this.env.raiseError(e.text)}openSidePanel(e,t){this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.isOpen=!1,this.focusGrid()}toggleSidePanel(e,t){this.sidePanel.isOpen&&e===this.sidePanel.component?(this.sidePanel.isOpen=!1,this.focusGrid()):this.openSidePanel(e,t)}focusGrid(){if(!this._focusGrid)throw new Error("_focusGrid should be exposed by the grid component");this._focusGrid()}onKeydown(e){let t="";(e.ctrlKey||e.metaKey)&&(t+="CTRL+"),t+=e.key.toUpperCase();let i=this.keyDownMapping[t];if(i)return e.preventDefault(),e.stopPropagation(),void i()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent({selection:e}||{}))}onGridComposerContentFocused(){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({}))}onGridComposerCellFocused(e,t){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}get gridHeight(){const{height:e}=this.env.model.getters.getSheetViewDimension();return e}}mS.template="o-spreadsheet-Spreadsheet",mS.components={TopBar:gS,Grid:Sp,BottomBar:oS,SidePanel:rS,SpreadsheetDashboard:sS},mS._t=e=>e,mS.props={model:Object};class fS{constructor(){this.listeners=[]}sendMessage(e){for(const{callback:t}of this.listeners)t(e)}onNewMessage(e,t){this.listeners.push({id:e,callback:t})}leave(e){this.listeners=this.listeners.filter((t=>t.id!==e))}}function vS(e){return Er.get(e.type)(e)}function bS(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class SS{constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){var e;return null===(e=this.operations[this.operations.length-1])||void 0===e?void 0:e.id}getFirstOperationAmong(e,t){for(const i of this.operations){if(i.id===e)return e;if(i.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const i=this.buildTransformation.with(e.data),{before:o,operation:n,after:s}=this.locateOperation(t);this.operations=[...o,n,e,...s.map((e=>e.transformed(i)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new SS(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:i}=this.locateOperation(e);this.operations=t.concat([i])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class CS{constructor(e,t){this.id=e,this.data=t}transformed(e){return new ES(this.id,rt((()=>e(this.data))))}}class ES{constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new ES(this.id,this.lazyData.map(e))}}class wS{constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new wS(function*(e,t){for(const i of e)if(yield i,i.operation.id===t)return}(this.operations,e))}stopBefore(e){return new wS(function*(e,t){for(const i of e){if(i.operation.id===t)return;yield i}}(this.operations,e))}startAfter(e){return new wS(function*(e,t){let i=!0;for(const o of e)i||(yield o),o.operation.id===t&&(i=!1)}(this.operations,e))}}class yS{constructor(e,t){this.buildTransformation=e,this.branchingOperationIds=new Map,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new wS(We(this._execution(e),this._execution(e)))}revertedExecution(e){return new wS(We(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){var i;const o=e.getLastOperationId()||(null===(i=this.previousBranch(e))||void 0===i?void 0:i.getLastOperationId());e.append(t),o&&this.insertPrevious(e,t,o)}insertOperationAfter(e,t,i){e.insert(t,i),this.updateNextWith(e,t,i),this.insertPrevious(e,t,i)}undo(e,t){const i=this.buildTransformation.without(t.data),o=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const n=e.fork(t.id);o&&this.branchingOperationIds.set(n,o),this.insertBranchAfter(e,n),this.transform(n,i)}redo(e){const t=this.nextBranch(e);if(!t)return;const i=this.nextBranch(t);this.removeBranchFromTree(t);const o=this.branchingOperationIds.get(t);o?this.branchingOperationIds.set(e,o):this.branchingOperationIds.delete(e),i&&this.rebaseUp(i)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const i of this.revertedExecution(e))if(i.operation.id===t)return i;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!t||!i)return;const o=this.buildTransformation.without(i.data),n=t.fork(i.id);this.branchingOperationIds.set(n,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,n),n.transform(o);const s=this.nextBranch(n);s&&this.rebaseUp(s)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const i=this.branches.findIndex((t=>t===e));this.branches.splice(i+1,0,t)}updateNextWith(e,t,i){const o=this.branchingOperationIds.get(e),n=this.nextBranch(e);if(o&&n)if(e.getFirstOperationAmong(i,o)===o){const s=this.addToNextBranch(e,n,o,t,i);this.updateNextWith(n,s,i)}else{const e=this.buildTransformation.with(t.data);this.transform(n,e)}}addToNextBranch(e,t,i,o,n){let s=o;return n===i?(s=this.getTransformedOperation(e,i,o),t.prepend(s)):t.contains(n)?(s=this.getTransformedOperation(e,i,o),t.insert(s,n)):t.append(o),s}getTransformedOperation(e,t,i){const o=e.getOperation(t),n=this.buildTransformation.without(o.data);return i.transformed(n)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const i=this.nextBranch(e);i&&this.transform(i,t)}insertPrevious(e,t,i){const{previousBranch:o,branchingOperation:n}=this.findPreviousBranchingOperation(e);if(!o||!n)return;const s=this.buildTransformation.with(n.data),r=e.fork(i);r.transform(s),o.cutAfter(i),o.appendBranch(r);const a=t.transformed(s);this.insertPrevious(o,a,i)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const i=this.branchingOperationIds.get(t);return i?{previousBranch:t,branchingOperation:t.getOperation(i)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let i=!!t;const o=e.getOperations();for(let n=o.length-1;n>=0;n--){const s=o[n];s.id===t&&(i=!1),i||(yield{operation:s,branch:e,isCancelled:!this.shouldExecute(e,s)})}const n=this.previousBranch(e);yield*n?this._revertedExecution(n):[]}*_execution(e){for(const t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){const t=this.nextBranch(e);return void(yield*t?this._execution(t):[])}if(!this.branchingOperationIds.get(e)){const t=this.nextBranch(e);yield*t?this._execution(t):[]}}}class xS{constructor(e,t,i,o,n){this.applyOperation=t,this.revertOperation=i,this.buildEmpty=o,this.buildTransformation=n,this.HEAD_BRANCH=new SS(this.buildTransformation),this.tree=new yS(n,this.HEAD_BRANCH);const s=new CS(e,o(e));this.tree.insertOperationLast(this.HEAD_BRANCH,s),this.HEAD_OPERATION=s}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const i=new CS(e,t),o=this.tree.getLastBranch();this.tree.insertOperationLast(o,i),this.HEAD_BRANCH=o,this.HEAD_OPERATION=i}insert(e,t,i){const o=new CS(e,t);this.revertTo(i),this.tree.insertOperationAfter(this.HEAD_BRANCH,o,i),this.fastForward()}undo(e,t,i){const{branch:o,operation:n}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(o,n),this.fastForward(),this.insert(t,this.buildEmpty(t),i)}redo(e,t,i){const{branch:o}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(o),this.fastForward(),this.insert(t,this.buildEmpty(t),i)}drop(e){this.revertBefore(e),this.tree.drop(e)}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:i,isCancelled:o}of e)o||this.revertOperation(i.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:i,isCancelled:o}of e)o||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=i}}function IS(e,t,i){return new xS(e,(e=>{const o=e.commands.slice(),{changes:n}=t((()=>{for(const e of o)i(e)}));e.setChanges(n)}),(e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){RS(t.changes[e],"before")}}([e])),(e=>new yb(e,"empty",[],[])),{with:e=>t=>new yb(t.id,t.clientId,Eb(t.commands,e.commands)),without:e=>t=>new yb(t.id,t.clientId,Eb(t.commands,e.commands.map(vS).flat()))})}function RS(e,t){let i=e.path[0];const o=e.path[e.path.length-1];for(let t=1;t<e.path.slice(0,-1).length;t++){const o=e.path[t];if(void 0===i[o]){const n=e.path[t+1];i[o]=bS(n)}i=i[o]}void 0===e[t]?delete i[o]:i[o]=e[t]}class TS extends t.EventBus{constructor(e,t){super(),this.dispatch=e,this.session=t,this.undoStack=[],this.redoStack=[],this.session.on("new-local-state-update",this,this.onNewLocalStateUpdate),this.session.on("revision-undone",this,(({commands:e})=>this.selectiveUndo(e))),this.session.on("revision-redone",this,(({commands:e})=>this.selectiveRedo(e))),this.session.on("pending-revisions-dropped",this,(({revisionIds:e})=>this.drop(e))),this.session.on("snapshot",this,(()=>{this.undoStack=[],this.redoStack=[]}))}allowDispatch(e){switch(e.type){case"REQUEST_UNDO":if(!this.canUndo())return 6;break;case"REQUEST_REDO":if(!this.canRedo())return 7}return 0}beforeHandle(e){}handle(e){switch(e.type){case"REQUEST_UNDO":case"REQUEST_REDO":this.requestHistoryChange("REQUEST_UNDO"===e.type?"UNDO":"REDO")}}finalize(){}requestHistoryChange(e){const t="UNDO"===e?this.undoStack.pop():this.redoStack.pop();t&&("UNDO"===e?(this.session.undo(t),this.redoStack.push(t)):(this.session.redo(t),this.undoStack.push(t)))}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}drop(e){this.undoStack=this.undoStack.filter((t=>!e.includes(t))),this.redoStack=[]}onNewLocalStateUpdate({id:e}){this.undoStack.push(e),this.redoStack=[],this.undoStack.length>99&&this.undoStack.shift()}selectiveUndo(e){this.dispatch("UNDO",{commands:e})}selectiveRedo(e){this.dispatch("REDO",{commands:e})}}class AS{constructor(){this.observers=[]}registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||(this.mainSubscription=this.defaultSubscription)}observe(e,t){this.observers.push({owner:e,callbacks:t})}capture(e,t){var i,o,n;if(this.observers.find((t=>t.owner===e)))throw new Error("You are already subscribed forever");(null===(i=this.mainSubscription)||void 0===i?void 0:i.owner)&&this.mainSubscription.owner!==e&&(null===(n=(o=this.mainSubscription.callbacks).release)||void 0===n||n.call(o)),this.mainSubscription={owner:e,callbacks:t}}release(e){var t;(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)!==e||this.observers.find((t=>t.owner===e))||(this.mainSubscription=this.defaultSubscription)}getBackToDefault(){var e,t,i;this.mainSubscription!==this.defaultSubscription&&(null===(i=null===(e=this.mainSubscription)||void 0===e?void 0:(t=e.callbacks).release)||void 0===i||i.call(t),this.mainSubscription=this.defaultSubscription)}isListening(e){var t;return(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)===e}send(e){var t;null===(t=this.mainSubscription)||void 0===t||t.callbacks.handleEvent(e),[...this.observers].forEach((t=>t.callbacks.handleEvent(e)))}}class MS{constructor(e){this.getters=e,this.stream=new AS,this.anchor={cell:{col:0,row:0},zone:lo({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,i){this.stream.capture(e,i),this.anchor=t}registerAsDefault(e,t,i){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,i),this.defaultAnchor=t,this.capture(e,t,i)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}selectZone(e){return this.modifyAnchor(e,"overrideSelection","ZonesSelected")}modifyAnchor(e,t,i){const o=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(o,e.zone)},this.processEvent({type:i,anchor:e,mode:t})}selectCell(e,t){const i=lo({col:e,row:t});return this.selectZone({zone:i,cell:{col:e,row:t}})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new mn(83);const{col:i,row:o}=this.getNextAvailablePosition(e,t);return this.selectCell(i,o)}setAnchorCorner(e,t){const i=this.getters.getActiveSheetId(),{col:o,row:n}=this.anchor.cell,s={left:Math.min(o,e),top:Math.min(n,t),right:Math.max(o,e),bottom:Math.max(n,t)},r={zone:this.getters.expandZone(i,s),cell:{col:o,row:n}};return this.processEvent({type:"AlterZone",mode:"updateAnchor",anchor:r})}addCellToSelection(e,t){const i=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:i,col:e,row:t}));const o=this.getters.expandZone(i,lo({col:e,row:t}));return this.processEvent({type:"ZonesSelected",anchor:{zone:o,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new mn(83);const i=this.getters.getActiveSheetId(),o=this.anchor,{col:n,row:s}=o.cell,{left:r,right:a,top:l,bottom:c}=o.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return mn.Success;let g=o.zone;const p=e=>{e=ao(e);const{left:t,right:o,top:n,bottom:s}=this.getters.expandZone(i,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(i)-1,o),top:Math.max(0,n),bottom:Math.min(this.getters.getNumberRows(i)-1,s)}},{col:m,row:f}=this.getReferencePosition();let v=0;for(;null!==g;){if(v++,d<0){const e=this.getNextAvailableCol(d,a-(v-1),f);g=m<=a-v?p({top:l,left:r,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,r+(v-1),f);g=r+v<=m?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,m,c-(v-1));g=f<=c-v?p({top:l,left:r,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,m,l+(v-1));g=l+v<=f?p({top:e,left:r,bottom:c,right:a}):null}if(g=g?ao(g):g,g&&!Yi(g,o.zone))return this.processEvent({type:"ZonesSelected",mode:"updateAnchor",anchor:{zone:g,cell:{col:n,row:s}}})}g=p(ji({top:s,bottom:s,left:n,right:n},ao({top:this.getNextAvailableRow(u,m,l),left:this.getNextAvailableCol(d,r,f),bottom:this.getNextAvailableRow(u,m,c),right:this.getNextAvailableCol(d,a,f)})));const b={zone:g,cell:{col:n,row:s}};return this.processEvent({type:"ZonesSelected",anchor:b,mode:"updateAnchor"})}selectColumn(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.getNumberRows(i)-1;let n={left:e,right:e,top:0,bottom:o};const s=this.getters.findFirstVisibleColRowIndex(i,"ROW");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=e,a=s;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),n=ji(n,{left:r,right:r,top:s,bottom:o})}return this.processEvent({type:"HeadersSelected",anchor:{zone:n,cell:{col:r,row:a}},mode:t})}selectRow(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.getNumberCols(i)-1;let n={top:e,bottom:e,left:0,right:o};const s=this.getters.findFirstVisibleColRowIndex(i,"COL");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=s,a=e;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),n=ji(n,{left:s,right:o,top:a,bottom:a})}return this.processEvent({type:"HeadersSelected",anchor:{zone:n,cell:{col:r,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor;if(Yi(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:lo(t.cell)},"updateAnchor","AlterZone");const i=this.expandZoneToTable(t.zone);return ct(i,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:i},"updateAnchor","AlterZone")}selectTableAroundSelection(){const e=this.expandZoneToTable(this.anchor.zone);return this.modifyAnchor({...this.anchor,zone:e},"updateAnchor","AlterZone")}selectAll(){const e=this.getters.getActiveSheetId(),t={left:0,top:0,bottom:this.getters.getNumberRows(e)-1,right:this.getters.getNumberCols(e)-1};return this.processEvent({type:"HeadersSelected",mode:"overrideSelection",anchor:{zone:t,cell:this.anchor.cell}})}isListening(e){return this.stream.isListening(e)}processEvent(e){const t={...e,previousAnchor:_e(this.anchor)},i=this.checkEventAnchorZone(t);return 0!==i?new mn(i):(this.anchor=t.anchor,this.stream.send(t),mn.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:i}=e;if(!Qi(t.col,t.row,i))return 16;const{left:o,right:n,top:s,bottom:r}=i,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",o,n);return void 0===this.getters.findVisibleHeader(a,"ROW",s,r)||void 0===l?17:0}checkAnchorZoneOrThrow(e){if(16===this.checkAnchorZone(e))throw new Error(n("The provided anchor is invalid. The cell must be part of the zone."))}getNextAvailablePosition(e,t=1){const{col:i,row:o}=this.anchor.cell,n=this.deltaToTarget({col:i,row:o},e,t);return{col:this.getNextAvailableCol(n[0],i,o),row:this.getNextAvailableRow(n[1],i,o)}}getNextAvailableCol(e,t,i){const o=this.getters.getActiveSheetId(),n={col:t,row:i};return this.getNextAvailableHeader(e,"COL",t,n,(e=>this.getters.isInSameMerge(o,t,i,e,i)))}getNextAvailableRow(e,t,i){const o=this.getters.getActiveSheetId(),n={col:t,row:i};return this.getNextAvailableHeader(e,"ROW",i,n,(e=>this.getters.isInSameMerge(o,t,i,t,e)))}getNextAvailableHeader(e,t,i,o,n){const s=this.getters.getActiveSheetId();if(0===e)return i;const r=Math.sign(e);let a=i+e;for(;n(a);)a+=r;for(;this.getters.isHeaderHidden(s,t,a);)a+=r;return a<0||a>this.getters.getNumberHeaders(s,t)-1?this.getters.isHeaderHidden(s,t,i)?this.getNextAvailableHeader(-r,t,i,o,n):i:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:i,right:o,top:n,bottom:s}=t.zone,{col:r,row:a}=t.cell;return{col:this.getters.isColHidden(e,r)&&this.getters.findVisibleHeader(e,"COL",i,o)||r,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",n,s)||a}}deltaToTarget(e,t,i){switch(t){case"up":return"end"!==i?[0,-i]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==i?[0,i]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==i?[-i,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==i?[i,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:i}=this.getPosition();const o=this.anchor.zone;switch(e){case"down":case"up":i=i===o.top?o.bottom:o.top;break;case"left":case"right":t=t===o.right?o.left:o.right}return{col:t,row:i}}getEndOfCluster(e,t,i){const o=this.getters.getActiveSheet();let n=e;const s=this.getNextCellPosition(e,t,i);let r=this.isCellEmpty(n,o.id)||this.isCellEmpty(s,o.id)?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(n,t,i);if(n.col===e.col&&n.row===e.row)break;const s=this.isCellEmpty(e,o.id);if("endOfCluster"===r&&s)break;if("nextCluster"===r&&!s){n=e;break}n=e}return"cols"===t?n.col:n.row}isCellEmpty({col:e,row:t},i=this.getters.getActiveSheetId()){const o=this.getters.getMainCellPosition({sheetId:i,col:e,row:t});return this.getters.getEvaluatedCell(o).type===ln.empty}getNextCellPosition(e,t,i){const o="cols"===t?"col":"row",n={...e},s="cols"===t?this.getNextAvailableCol(i,n.col,n.row):this.getNextAvailableRow(i,n.col,n.row);return n[o]=s,{col:n.col,row:n.row}}getPosition(){return{...this.anchor.cell}}expandZoneToTable(e){const t=e=>{for(const t of He(e.left,e.right+1)){if(!this.isCellEmpty({col:t,row:e.top-1}))return{...e,top:e.top-1};if(!this.isCellEmpty({col:t,row:e.bottom+1}))return{...e,bottom:e.bottom+1}}for(const t of He(e.top,e.bottom+1)){if(!this.isCellEmpty({col:e.left-1,row:t}))return{...e,left:e.left-1};if(!this.isCellEmpty({col:e.right+1,row:t}))return{...e,right:e.right+1}}return e};let i=!1,o=e;do{i=!1;const e=t(o);Yi(o,e)||(i=!0,o=e)}while(i);return o}}class OS{constructor(){this.changes=[],this.commands=[]}recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop();let i=e[0],o=e[e.length-1];const n=e.length-2;for(let t=1;t<=n;t++){const o=e[t];if(void 0===i[o]){const n=e[t+1];i[o]=bS(n)}i=i[o]}i[o]!==t&&(this.changes.push({path:e,before:i[o],after:t}),void 0===t?delete i[o]:i[o]=t)}}const NS=17781237,_S=88853993;function FS(e,t,i){const o=[["xmlns:r",Mp],["xmlns:a",Ip],["xmlns:c",Rp]],n=DS({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let s=nv``;e.data.title&&(s=nv`
|
|
1975
|
+
`;class vS extends t.Component{constructor(){super(...arguments),this.isViewportTooSmall=!1}get model(){return this.props.model}getStyle(){return this.env.isDashboard()?"grid-template-rows: auto;":"grid-template-rows: 63px auto 37px"}setup(){this.sidePanel=t.useState({isOpen:!1,panelProps:{}}),this.composer=t.useState({topBarFocus:"inactive",gridFocusMode:"inactive"}),this.keyDownMapping={"CTRL+H":()=>this.toggleSidePanel("FindAndReplace",{}),"CTRL+F":()=>this.toggleSidePanel("FindAndReplace",{})};const e=this.model.config.external.fileStore;t.useSubEnv({model:this.model,imageProvider:e?new Qb(e):void 0,loadCurrencies:this.model.config.external.loadCurrencies,isDashboard:()=>this.model.getters.isDashboard(),openSidePanel:this.openSidePanel.bind(this),toggleSidePanel:this.toggleSidePanel.bind(this),_t:vS._t,clipboard:this.env.clipboard||new fS(navigator.clipboard),startCellEdition:e=>this.onGridComposerCellFocused(e)}),t.useExternalListener(window,"resize",(()=>this.render(!0))),t.useExternalListener(window,"beforeunload",this.unbindModelEvents.bind(this)),this.bindModelEvents(),t.onMounted((()=>{this.checkViewportSize()})),t.onWillUnmount((()=>this.unbindModelEvents())),t.onPatched((()=>{this.checkViewportSize()}))}get focusTopBarComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.topBarFocus}get focusGridComposer(){return"inactive"===this.model.getters.getEditionMode()?"inactive":this.composer.gridFocusMode}bindModelEvents(){this.model.on("update",this,(()=>this.render(!0))),this.model.on("notify-ui",this,this.onNotifyUI)}unbindModelEvents(){this.model.off("update",this),this.model.off("notify-ui",this)}checkViewportSize(){const{xRatio:e,yRatio:t}=this.env.model.getters.getFrozenSheetViewRatio(this.env.model.getters.getActiveSheetId());if(t>.85||e>.85){if(this.isViewportTooSmall)return;this.env.notifyUser({text:s("The current window is too small to display this sheet properly. Consider resizing your browser window or adjusting frozen rows and columns."),tag:"viewportTooSmall"}),this.isViewportTooSmall=!0}else this.isViewportTooSmall=!1}onNotifyUI(e){if("ERROR"===e.type)this.env.raiseError(e.text)}openSidePanel(e,t){this.sidePanel.component=e,this.sidePanel.panelProps=t,this.sidePanel.isOpen=!0}closeSidePanel(){this.sidePanel.isOpen=!1,this.focusGrid()}toggleSidePanel(e,t){this.sidePanel.isOpen&&e===this.sidePanel.component?(this.sidePanel.isOpen=!1,this.focusGrid()):this.openSidePanel(e,t)}focusGrid(){if(!this._focusGrid)throw new Error("_focusGrid should be exposed by the grid component");this._focusGrid()}onKeydown(e){let t="";qn(e)&&(t+="CTRL+"),t+=e.key.toUpperCase();let i=this.keyDownMapping[t];if(i)return e.preventDefault(),e.stopPropagation(),void i()}onTopBarComposerFocused(e){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="contentFocus",this.composer.gridFocusMode="inactive",this.setComposerContent({selection:e}||{}))}onGridComposerContentFocused(){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="contentFocus",this.setComposerContent({}))}onGridComposerCellFocused(e,t){this.model.getters.isReadonly()||(this.model.dispatch("UNFOCUS_SELECTION_INPUT"),this.composer.topBarFocus="inactive",this.composer.gridFocusMode="cellFocus",this.setComposerContent({content:e,selection:t}||{}))}setComposerContent({content:e,selection:t}){"inactive"===this.model.getters.getEditionMode()?this.model.dispatch("START_EDITION",{text:e,selection:t}):e&&this.model.dispatch("SET_CURRENT_CONTENT",{content:e,selection:t})}get gridHeight(){const{height:e}=this.env.model.getters.getSheetViewDimension();return e}}vS.template="o-spreadsheet-Spreadsheet",vS.components={TopBar:mS,Grid:Ep,BottomBar:sS,SidePanel:lS,SpreadsheetDashboard:aS},vS._t=e=>e,vS.props={model:Object};class bS{constructor(){this.listeners=[]}sendMessage(e){for(const{callback:t}of this.listeners)t(e)}onNewMessage(e,t){this.listeners.push({id:e,callback:t})}leave(e){this.listeners=this.listeners.filter((t=>t.id!==e))}}function SS(e){return yr.get(e.type)(e)}function CS(e){if("string"==typeof e)return{};if("number"==typeof e)return[];throw new Error("Cannot create new node")}class ES{constructor(e,t=[]){this.buildTransformation=e,this.operations=t}getOperations(){return this.operations}getOperation(e){const t=this.operations.find((t=>t.id===e));if(!t)throw new Error(`Operation ${e} not found`);return t}getLastOperationId(){var e;return null===(e=this.operations[this.operations.length-1])||void 0===e?void 0:e.id}getFirstOperationAmong(e,t){for(const i of this.operations){if(i.id===e)return e;if(i.id===t)return t}throw new Error(`Operation ${e} and ${t} not found`)}contains(e){return!!this.operations.find((t=>t.id===e))}prepend(e){const t=this.buildTransformation.with(e.data);this.operations=[e,...this.operations.map((e=>e.transformed(t)))]}insert(e,t){const i=this.buildTransformation.with(e.data),{before:o,operation:n,after:s}=this.locateOperation(t);this.operations=[...o,n,e,...s.map((e=>e.transformed(i)))]}append(e){this.operations.push(e)}appendBranch(e){this.operations=this.operations.concat(e.operations)}fork(e){const{after:t}=this.locateOperation(e);return new ES(this.buildTransformation,t)}transform(e){this.operations=this.operations.map((t=>t.transformed(e)))}cutBefore(e){this.operations=this.locateOperation(e).before}cutAfter(e){const{before:t,operation:i}=this.locateOperation(e);this.operations=t.concat([i])}locateOperation(e){const t=this.operations.findIndex((t=>t.id===e));if(-1===t)throw new Error(`Operation ${e} not found`);return{before:this.operations.slice(0,t),operation:this.operations[t],after:this.operations.slice(t+1)}}}class wS{constructor(e,t){this.id=e,this.data=t}transformed(e){return new yS(this.id,rt((()=>e(this.data))))}}class yS{constructor(e,t){this.id=e,this.lazyData=t}get data(){return this.lazyData()}transformed(e){return new yS(this.id,this.lazyData.map(e))}}class xS{constructor(e){this.operations=e}[Symbol.iterator](){return this.operations[Symbol.iterator]()}stopWith(e){return new xS(function*(e,t){for(const i of e)if(yield i,i.operation.id===t)return}(this.operations,e))}stopBefore(e){return new xS(function*(e,t){for(const i of e){if(i.operation.id===t)return;yield i}}(this.operations,e))}startAfter(e){return new xS(function*(e,t){let i=!0;for(const o of e)i||(yield o),o.operation.id===t&&(i=!1)}(this.operations,e))}}class IS{constructor(e,t){this.buildTransformation=e,this.branchingOperationIds=new Map,this.branches=[t]}getLastBranch(){return this.branches[this.branches.length-1]}execution(e){return new xS(We(this._execution(e),this._execution(e)))}revertedExecution(e){return new xS(We(this._revertedExecution(e),this._revertedExecution(e)))}insertOperationLast(e,t){var i;const o=e.getLastOperationId()||(null===(i=this.previousBranch(e))||void 0===i?void 0:i.getLastOperationId());e.append(t),o&&this.insertPrevious(e,t,o)}insertOperationAfter(e,t,i){e.insert(t,i),this.updateNextWith(e,t,i),this.insertPrevious(e,t,i)}undo(e,t){const i=this.buildTransformation.without(t.data),o=this.branchingOperationIds.get(e);this.branchingOperationIds.set(e,t.id);const n=e.fork(t.id);o&&this.branchingOperationIds.set(n,o),this.insertBranchAfter(e,n),this.transform(n,i)}redo(e){const t=this.nextBranch(e);if(!t)return;const i=this.nextBranch(t);this.removeBranchFromTree(t);const o=this.branchingOperationIds.get(t);o?this.branchingOperationIds.set(e,o):this.branchingOperationIds.delete(e),i&&this.rebaseUp(i)}drop(e){for(const t of this.branches)t.contains(e)&&t.cutBefore(e)}findOperation(e,t){for(const i of this.revertedExecution(e))if(i.operation.id===t)return i;throw new Error(`Operation ${t} not found`)}rebaseUp(e){const{previousBranch:t,branchingOperation:i}=this.findPreviousBranchingOperation(e);if(!t||!i)return;const o=this.buildTransformation.without(i.data),n=t.fork(i.id);this.branchingOperationIds.set(n,this.branchingOperationIds.get(e)),this.removeBranchFromTree(e),this.insertBranchAfter(t,n),n.transform(o);const s=this.nextBranch(n);s&&this.rebaseUp(s)}removeBranchFromTree(e){const t=this.branches.findIndex((t=>t===e));this.branches.splice(t,1)}insertBranchAfter(e,t){const i=this.branches.findIndex((t=>t===e));this.branches.splice(i+1,0,t)}updateNextWith(e,t,i){const o=this.branchingOperationIds.get(e),n=this.nextBranch(e);if(o&&n)if(e.getFirstOperationAmong(i,o)===o){const s=this.addToNextBranch(e,n,o,t,i);this.updateNextWith(n,s,i)}else{const e=this.buildTransformation.with(t.data);this.transform(n,e)}}addToNextBranch(e,t,i,o,n){let s=o;return n===i?(s=this.getTransformedOperation(e,i,o),t.prepend(s)):t.contains(n)?(s=this.getTransformedOperation(e,i,o),t.insert(s,n)):t.append(o),s}getTransformedOperation(e,t,i){const o=e.getOperation(t),n=this.buildTransformation.without(o.data);return i.transformed(n)}shouldExecute(e,t){return t.id!==this.branchingOperationIds.get(e)}transform(e,t){e.transform(t);const i=this.nextBranch(e);i&&this.transform(i,t)}insertPrevious(e,t,i){const{previousBranch:o,branchingOperation:n}=this.findPreviousBranchingOperation(e);if(!o||!n)return;const s=this.buildTransformation.with(n.data),r=e.fork(i);r.transform(s),o.cutAfter(i),o.appendBranch(r);const a=t.transformed(s);this.insertPrevious(o,a,i)}findPreviousBranchingOperation(e){const t=this.previousBranch(e);if(!t)return{previousBranch:void 0,branchingOperation:void 0};const i=this.branchingOperationIds.get(t);return i?{previousBranch:t,branchingOperation:t.getOperation(i)}:{previousBranch:void 0,branchingOperation:void 0}}nextBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t+1]}previousBranch(e){const t=this.branches.findIndex((t=>t===e));if(-1!==t)return this.branches[t-1]}*_revertedExecution(e){const t=this.branchingOperationIds.get(e);let i=!!t;const o=e.getOperations();for(let n=o.length-1;n>=0;n--){const s=o[n];s.id===t&&(i=!1),i||(yield{operation:s,branch:e,isCancelled:!this.shouldExecute(e,s)})}const n=this.previousBranch(e);yield*n?this._revertedExecution(n):[]}*_execution(e){for(const t of e.getOperations())if(yield{operation:t,branch:e,isCancelled:!this.shouldExecute(e,t)},t.id===this.branchingOperationIds.get(e)){const t=this.nextBranch(e);return void(yield*t?this._execution(t):[])}if(!this.branchingOperationIds.get(e)){const t=this.nextBranch(e);yield*t?this._execution(t):[]}}}class RS{constructor(e,t,i,o,n){this.applyOperation=t,this.revertOperation=i,this.buildEmpty=o,this.buildTransformation=n,this.HEAD_BRANCH=new ES(this.buildTransformation),this.tree=new IS(n,this.HEAD_BRANCH);const s=new wS(e,o(e));this.tree.insertOperationLast(this.HEAD_BRANCH,s),this.HEAD_OPERATION=s}get(e){return this.tree.findOperation(this.HEAD_BRANCH,e).operation.data}append(e,t){const i=new wS(e,t),o=this.tree.getLastBranch();this.tree.insertOperationLast(o,i),this.HEAD_BRANCH=o,this.HEAD_OPERATION=i}insert(e,t,i){const o=new wS(e,t);this.revertTo(i),this.tree.insertOperationAfter(this.HEAD_BRANCH,o,i),this.fastForward()}undo(e,t,i){const{branch:o,operation:n}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.undo(o,n),this.fastForward(),this.insert(t,this.buildEmpty(t),i)}redo(e,t,i){const{branch:o}=this.tree.findOperation(this.HEAD_BRANCH,e);this.revertBefore(e),this.tree.redo(o),this.fastForward(),this.insert(t,this.buildEmpty(t),i)}drop(e){this.revertBefore(e),this.tree.drop(e)}revertBefore(e){const t=this.tree.revertedExecution(this.HEAD_BRANCH).stopWith(e);this.revert(t)}revertTo(e){const t=e?this.tree.revertedExecution(this.HEAD_BRANCH).stopBefore(e):this.tree.revertedExecution(this.HEAD_BRANCH);this.revert(t)}revert(e){for(const{next:t,operation:i,isCancelled:o}of e)o||this.revertOperation(i.data),t&&(this.HEAD_BRANCH=t.branch,this.HEAD_OPERATION=t.operation)}fastForward(){const e=this.HEAD_OPERATION?this.tree.execution(this.HEAD_BRANCH).startAfter(this.HEAD_OPERATION.id):this.tree.execution(this.HEAD_BRANCH);for(const{operation:t,branch:i,isCancelled:o}of e)o||this.applyOperation(t.data),this.HEAD_OPERATION=t,this.HEAD_BRANCH=i}}function TS(e,t,i){return new RS(e,(e=>{const o=e.commands.slice(),{changes:n}=t((()=>{for(const e of o)i(e)}));e.setChanges(n)}),(e=>function(e){for(const t of e.slice().reverse())for(let e=t.changes.length-1;e>=0;e--){AS(t.changes[e],"before")}}([e])),(e=>new Ib(e,"empty",[],[])),{with:e=>t=>new Ib(t.id,t.clientId,yb(t.commands,e.commands)),without:e=>t=>new Ib(t.id,t.clientId,yb(t.commands,e.commands.map(SS).flat()))})}function AS(e,t){let i=e.path[0];const o=e.path[e.path.length-1];for(let t=1;t<e.path.slice(0,-1).length;t++){const o=e.path[t];if(void 0===i[o]){const n=e.path[t+1];i[o]=CS(n)}i=i[o]}void 0===e[t]?delete i[o]:i[o]=e[t]}class MS extends t.EventBus{constructor(e,t){super(),this.dispatch=e,this.session=t,this.undoStack=[],this.redoStack=[],this.session.on("new-local-state-update",this,this.onNewLocalStateUpdate),this.session.on("revision-undone",this,(({commands:e})=>this.selectiveUndo(e))),this.session.on("revision-redone",this,(({commands:e})=>this.selectiveRedo(e))),this.session.on("pending-revisions-dropped",this,(({revisionIds:e})=>this.drop(e))),this.session.on("snapshot",this,(()=>{this.undoStack=[],this.redoStack=[]}))}allowDispatch(e){switch(e.type){case"REQUEST_UNDO":if(!this.canUndo())return 6;break;case"REQUEST_REDO":if(!this.canRedo())return 7}return 0}beforeHandle(e){}handle(e){switch(e.type){case"REQUEST_UNDO":case"REQUEST_REDO":this.requestHistoryChange("REQUEST_UNDO"===e.type?"UNDO":"REDO")}}finalize(){}requestHistoryChange(e){const t="UNDO"===e?this.undoStack.pop():this.redoStack.pop();t&&("UNDO"===e?(this.session.undo(t),this.redoStack.push(t)):(this.session.redo(t),this.undoStack.push(t)))}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}drop(e){this.undoStack=this.undoStack.filter((t=>!e.includes(t))),this.redoStack=[]}onNewLocalStateUpdate({id:e}){this.undoStack.push(e),this.redoStack=[],this.undoStack.length>99&&this.undoStack.shift()}selectiveUndo(e){this.dispatch("UNDO",{commands:e})}selectiveRedo(e){this.dispatch("REDO",{commands:e})}}class OS{constructor(){this.observers=[]}registerAsDefault(e,t){this.defaultSubscription={owner:e,callbacks:t},this.mainSubscription||(this.mainSubscription=this.defaultSubscription)}observe(e,t){this.observers.push({owner:e,callbacks:t})}capture(e,t){var i,o,n;if(this.observers.find((t=>t.owner===e)))throw new Error("You are already subscribed forever");(null===(i=this.mainSubscription)||void 0===i?void 0:i.owner)&&this.mainSubscription.owner!==e&&(null===(n=(o=this.mainSubscription.callbacks).release)||void 0===n||n.call(o)),this.mainSubscription={owner:e,callbacks:t}}release(e){var t;(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)!==e||this.observers.find((t=>t.owner===e))||(this.mainSubscription=this.defaultSubscription)}getBackToDefault(){var e,t,i;this.mainSubscription!==this.defaultSubscription&&(null===(i=null===(e=this.mainSubscription)||void 0===e?void 0:(t=e.callbacks).release)||void 0===i||i.call(t),this.mainSubscription=this.defaultSubscription)}isListening(e){var t;return(null===(t=this.mainSubscription)||void 0===t?void 0:t.owner)===e}send(e){var t;null===(t=this.mainSubscription)||void 0===t||t.callbacks.handleEvent(e),[...this.observers].forEach((t=>t.callbacks.handleEvent(e)))}}class NS{constructor(e){this.getters=e,this.stream=new OS,this.anchor={cell:{col:0,row:0},zone:lo({col:0,row:0})},this.defaultAnchor=this.anchor}capture(e,t,i){this.stream.capture(e,i),this.anchor=t}registerAsDefault(e,t,i){this.checkAnchorZoneOrThrow(t),this.stream.registerAsDefault(e,i),this.defaultAnchor=t,this.capture(e,t,i)}resetDefaultAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t),this.defaultAnchor=t}resetAnchor(e,t){this.checkAnchorZoneOrThrow(t),this.stream.isListening(e)&&(this.anchor=t)}observe(e,t){this.stream.observe(e,t)}release(e){this.stream.isListening(e)&&(this.stream.release(e),this.anchor=this.defaultAnchor)}getBackToDefault(){this.stream.getBackToDefault()}selectZone(e){return this.modifyAnchor(e,"overrideSelection","ZonesSelected")}modifyAnchor(e,t,i){const o=this.getters.getActiveSheetId();return e={...e,zone:this.getters.expandZone(o,e.zone)},this.processEvent({type:i,anchor:e,mode:t})}selectCell(e,t){const i=lo({col:e,row:t});return this.selectZone({zone:i,cell:{col:e,row:t}})}moveAnchorCell(e,t=1){if("end"!==t&&t<=0)return new mn(83);const{col:i,row:o}=this.getNextAvailablePosition(e,t);return this.selectCell(i,o)}setAnchorCorner(e,t){const i=this.getters.getActiveSheetId(),{col:o,row:n}=this.anchor.cell,s={left:Math.min(o,e),top:Math.min(n,t),right:Math.max(o,e),bottom:Math.max(n,t)},r={zone:this.getters.expandZone(i,s),cell:{col:o,row:n}};return this.processEvent({type:"AlterZone",mode:"updateAnchor",anchor:r})}addCellToSelection(e,t){const i=this.getters.getActiveSheetId();({col:e,row:t}=this.getters.getMainCellPosition({sheetId:i,col:e,row:t}));const o=this.getters.expandZone(i,lo({col:e,row:t}));return this.processEvent({type:"ZonesSelected",anchor:{zone:o,cell:{col:e,row:t}},mode:"newAnchor"})}resizeAnchorZone(e,t=1){if("end"!==t&&t<=0)return new mn(83);const i=this.getters.getActiveSheetId(),o=this.anchor,{col:n,row:s}=o.cell,{left:r,right:a,top:l,bottom:c}=o.zone,h=this.getStartingPosition(e);let[d,u]=this.deltaToTarget(h,e,t);if(0===d&&0===u)return mn.Success;let g=o.zone;const p=e=>{e=ao(e);const{left:t,right:o,top:n,bottom:s}=this.getters.expandZone(i,e);return{left:Math.max(0,t),right:Math.min(this.getters.getNumberCols(i)-1,o),top:Math.max(0,n),bottom:Math.min(this.getters.getNumberRows(i)-1,s)}},{col:m,row:f}=this.getReferencePosition();let v=0;for(;null!==g;){if(v++,d<0){const e=this.getNextAvailableCol(d,a-(v-1),f);g=m<=a-v?p({top:l,left:r,bottom:c,right:e}):null}if(d>0){const e=this.getNextAvailableCol(d,r+(v-1),f);g=r+v<=m?p({top:l,left:e,bottom:c,right:a}):null}if(u<0){const e=this.getNextAvailableRow(u,m,c-(v-1));g=f<=c-v?p({top:l,left:r,bottom:e,right:a}):null}if(u>0){const e=this.getNextAvailableRow(u,m,l+(v-1));g=l+v<=f?p({top:e,left:r,bottom:c,right:a}):null}if(g=g?ao(g):g,g&&!Yi(g,o.zone))return this.processEvent({type:"ZonesSelected",mode:"updateAnchor",anchor:{zone:g,cell:{col:n,row:s}}})}g=p(ji({top:s,bottom:s,left:n,right:n},ao({top:this.getNextAvailableRow(u,m,l),left:this.getNextAvailableCol(d,r,f),bottom:this.getNextAvailableRow(u,m,c),right:this.getNextAvailableCol(d,a,f)})));const b={zone:g,cell:{col:n,row:s}};return this.processEvent({type:"ZonesSelected",anchor:b,mode:"updateAnchor"})}selectColumn(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.getNumberRows(i)-1;let n={left:e,right:e,top:0,bottom:o};const s=this.getters.findFirstVisibleColRowIndex(i,"ROW");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=e,a=s;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),n=ji(n,{left:r,right:r,top:s,bottom:o})}return this.processEvent({type:"HeadersSelected",anchor:{zone:n,cell:{col:r,row:a}},mode:t})}selectRow(e,t){const i=this.getters.getActiveSheetId(),o=this.getters.getNumberCols(i)-1;let n={top:e,bottom:e,left:0,right:o};const s=this.getters.findFirstVisibleColRowIndex(i,"COL");let r,a;switch(t){case"overrideSelection":case"newAnchor":r=s,a=e;break;case"updateAnchor":({col:r,row:a}=this.anchor.cell),n=ji(n,{left:s,right:o,top:a,bottom:a})}return this.processEvent({type:"HeadersSelected",anchor:{zone:n,cell:{col:r,row:a}},mode:t})}loopSelection(){const e=this.getters.getActiveSheetId(),t=this.anchor;if(Yi(this.anchor.zone,this.getters.getSheetZone(e)))return this.modifyAnchor({...t,zone:lo(t.cell)},"updateAnchor","AlterZone");const i=this.expandZoneToTable(t.zone);return ct(i,t.zone)?this.selectAll():this.modifyAnchor({...t,zone:i},"updateAnchor","AlterZone")}selectTableAroundSelection(){const e=this.expandZoneToTable(this.anchor.zone);return this.modifyAnchor({...this.anchor,zone:e},"updateAnchor","AlterZone")}selectAll(){const e=this.getters.getActiveSheetId(),t={left:0,top:0,bottom:this.getters.getNumberRows(e)-1,right:this.getters.getNumberCols(e)-1};return this.processEvent({type:"HeadersSelected",mode:"overrideSelection",anchor:{zone:t,cell:this.anchor.cell}})}isListening(e){return this.stream.isListening(e)}processEvent(e){const t={...e,previousAnchor:_e(this.anchor)},i=this.checkEventAnchorZone(t);return 0!==i?new mn(i):(this.anchor=t.anchor,this.stream.send(t),mn.Success)}checkEventAnchorZone(e){return this.checkAnchorZone(e.anchor)}checkAnchorZone(e){const{cell:t,zone:i}=e;if(!Qi(t.col,t.row,i))return 16;const{left:o,right:n,top:s,bottom:r}=i,a=this.getters.getActiveSheetId(),l=this.getters.findVisibleHeader(a,"COL",o,n);return void 0===this.getters.findVisibleHeader(a,"ROW",s,r)||void 0===l?17:0}checkAnchorZoneOrThrow(e){if(16===this.checkAnchorZone(e))throw new Error(n("The provided anchor is invalid. The cell must be part of the zone."))}getNextAvailablePosition(e,t=1){const{col:i,row:o}=this.anchor.cell,n=this.deltaToTarget({col:i,row:o},e,t);return{col:this.getNextAvailableCol(n[0],i,o),row:this.getNextAvailableRow(n[1],i,o)}}getNextAvailableCol(e,t,i){const o=this.getters.getActiveSheetId(),n={col:t,row:i};return this.getNextAvailableHeader(e,"COL",t,n,(e=>this.getters.isInSameMerge(o,t,i,e,i)))}getNextAvailableRow(e,t,i){const o=this.getters.getActiveSheetId(),n={col:t,row:i};return this.getNextAvailableHeader(e,"ROW",i,n,(e=>this.getters.isInSameMerge(o,t,i,t,e)))}getNextAvailableHeader(e,t,i,o,n){const s=this.getters.getActiveSheetId();if(0===e)return i;const r=Math.sign(e);let a=i+e;for(;n(a);)a+=r;for(;this.getters.isHeaderHidden(s,t,a);)a+=r;return a<0||a>this.getters.getNumberHeaders(s,t)-1?this.getters.isHeaderHidden(s,t,i)?this.getNextAvailableHeader(-r,t,i,o,n):i:a}getReferencePosition(){const e=this.getters.getActiveSheetId(),t=this.anchor,{left:i,right:o,top:n,bottom:s}=t.zone,{col:r,row:a}=t.cell;return{col:this.getters.isColHidden(e,r)&&this.getters.findVisibleHeader(e,"COL",i,o)||r,row:this.getters.isRowHidden(e,a)&&this.getters.findVisibleHeader(e,"ROW",n,s)||a}}deltaToTarget(e,t,i){switch(t){case"up":return"end"!==i?[0,-i]:[0,this.getEndOfCluster(e,"rows",-1)-e.row];case"down":return"end"!==i?[0,i]:[0,this.getEndOfCluster(e,"rows",1)-e.row];case"left":return"end"!==i?[-i,0]:[this.getEndOfCluster(e,"cols",-1)-e.col,0];case"right":return"end"!==i?[i,0]:[this.getEndOfCluster(e,"cols",1)-e.col,0]}}getStartingPosition(e){let{col:t,row:i}=this.getPosition();const o=this.anchor.zone;switch(e){case"down":case"up":i=i===o.top?o.bottom:o.top;break;case"left":case"right":t=t===o.right?o.left:o.right}return{col:t,row:i}}getEndOfCluster(e,t,i){const o=this.getters.getActiveSheet();let n=e;const s=this.getNextCellPosition(e,t,i);let r=this.isCellEmpty(n,o.id)||this.isCellEmpty(s,o.id)?"nextCluster":"endOfCluster";for(;;){const e=this.getNextCellPosition(n,t,i);if(n.col===e.col&&n.row===e.row)break;const s=this.isCellEmpty(e,o.id);if("endOfCluster"===r&&s)break;if("nextCluster"===r&&!s){n=e;break}n=e}return"cols"===t?n.col:n.row}isCellEmpty({col:e,row:t},i=this.getters.getActiveSheetId()){const o=this.getters.getMainCellPosition({sheetId:i,col:e,row:t});return this.getters.getEvaluatedCell(o).type===ln.empty}getNextCellPosition(e,t,i){const o="cols"===t?"col":"row",n={...e},s="cols"===t?this.getNextAvailableCol(i,n.col,n.row):this.getNextAvailableRow(i,n.col,n.row);return n[o]=s,{col:n.col,row:n.row}}getPosition(){return{...this.anchor.cell}}expandZoneToTable(e){const t=e=>{for(const t of He(e.left,e.right+1)){if(!this.isCellEmpty({col:t,row:e.top-1}))return{...e,top:e.top-1};if(!this.isCellEmpty({col:t,row:e.bottom+1}))return{...e,bottom:e.bottom+1}}for(const t of He(e.top,e.bottom+1)){if(!this.isCellEmpty({col:e.left-1,row:t}))return{...e,left:e.left-1};if(!this.isCellEmpty({col:e.right+1,row:t}))return{...e,right:e.right+1}}return e};let i=!1,o=e;do{i=!1;const e=t(o);Yi(o,e)||(i=!0,o=e)}while(i);return o}}class _S{constructor(){this.changes=[],this.commands=[]}recordChanges(e){return this.changes=[],this.commands=[],e(),{changes:this.changes,commands:this.commands}}addCommand(e){this.commands.push(e)}addChange(...e){const t=e.pop();let i=e[0],o=e[e.length-1];const n=e.length-2;for(let t=1;t<=n;t++){const o=e[t];if(void 0===i[o]){const n=e[t+1];i[o]=CS(n)}i=i[o]}i[o]!==t&&(this.changes.push({path:e,before:i[o],after:t}),void 0===t?delete i[o]:i[o]=t)}}const FS=17781237,DS=88853993;function kS(e,t,i){const o=[["xmlns:r",Np],["xmlns:a",Tp],["xmlns:c",Ap]],n=LS({backgroundColor:e.data.backgroundColor,line:{color:"000000"}});let s=rv``;e.data.title&&(s=rv`
|
|
1976
1976
|
<c:title>
|
|
1977
|
-
${
|
|
1977
|
+
${US(e.data.title,e.data.fontColor)}
|
|
1978
1978
|
<c:overlay val="0" />
|
|
1979
1979
|
</c:title>
|
|
1980
|
-
`);let r=
|
|
1980
|
+
`);let r=rv``;switch(e.data.type){case"bar":r=function(e){const t=new xs,i=[];for(const[o,n]of Object.entries(e.dataSets)){const s=us(t.next()),r=LS({backgroundColor:s,line:{color:s}});i.push(rv`
|
|
1981
1981
|
<c:ser>
|
|
1982
1982
|
<c:idx val="${o}"/>
|
|
1983
1983
|
<c:order val="${o}"/>
|
|
1984
|
-
${n.label?
|
|
1984
|
+
${n.label?rv`<c:tx>${HS(n.label)}</c:tx>`:""}
|
|
1985
1985
|
${r}
|
|
1986
|
-
${e.labelRange?
|
|
1986
|
+
${e.labelRange?rv`<c:cat>${HS(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
|
|
1987
1987
|
<c:val> <!-- x-coordinate values -->
|
|
1988
|
-
${
|
|
1988
|
+
${$S(n.range)}
|
|
1989
1989
|
</c:val>
|
|
1990
1990
|
</c:ser>
|
|
1991
|
-
`)}const o="left"===e.verticalAxisPosition?"l":"r",n=e.stacked?"stacked":"clustered",s=e.stacked?100:-20;return
|
|
1991
|
+
`)}const o="left"===e.verticalAxisPosition?"l":"r",n=e.stacked?"stacked":"clustered",s=e.stacked?100:-20;return rv`
|
|
1992
1992
|
<c:barChart>
|
|
1993
1993
|
<c:barDir val="col"/>
|
|
1994
1994
|
<c:grouping val="${n}"/>
|
|
@@ -1996,13 +1996,13 @@
|
|
|
1996
1996
|
<c:gapWidth val="70"/>
|
|
1997
1997
|
<!-- each data marker in the series does not have a different color -->
|
|
1998
1998
|
<c:varyColors val="0"/>
|
|
1999
|
-
${
|
|
2000
|
-
<c:axId val="${
|
|
2001
|
-
<c:axId val="${
|
|
1999
|
+
${sv(i)}
|
|
2000
|
+
<c:axId val="${FS}" />
|
|
2001
|
+
<c:axId val="${DS}" />
|
|
2002
2002
|
</c:barChart>
|
|
2003
|
-
${
|
|
2004
|
-
${
|
|
2005
|
-
`}(e.data);break;case"line":r=function(e){const t=new
|
|
2003
|
+
${BS("b","c:catAx",FS,DS,{fontColor:e.fontColor})}
|
|
2004
|
+
${BS(o,"c:valAx",DS,FS,{fontColor:e.fontColor})}
|
|
2005
|
+
`}(e.data);break;case"line":r=function(e){const t=new xs,i=[];for(const[o,n]of Object.entries(e.dataSets)){const s=LS({line:{width:2.5,style:"solid",color:us(t.next())}});i.push(rv`
|
|
2006
2006
|
<c:ser>
|
|
2007
2007
|
<c:idx val="${o}"/>
|
|
2008
2008
|
<c:order val="${o}"/>
|
|
@@ -2011,50 +2011,50 @@
|
|
|
2011
2011
|
<c:symbol val="circle" />
|
|
2012
2012
|
<c:size val="5"/>
|
|
2013
2013
|
</c:marker>
|
|
2014
|
-
${n.label?
|
|
2014
|
+
${n.label?rv`<c:tx>${HS(n.label)}</c:tx>`:""}
|
|
2015
2015
|
${s}
|
|
2016
|
-
${e.labelRange?
|
|
2016
|
+
${e.labelRange?rv`<c:cat>${HS(e.labelRange)}</c:cat>`:""} <!-- x-coordinate values -->
|
|
2017
2017
|
<c:val> <!-- x-coordinate values -->
|
|
2018
|
-
${
|
|
2018
|
+
${$S(n.range)}
|
|
2019
2019
|
</c:val>
|
|
2020
2020
|
</c:ser>
|
|
2021
|
-
`)}const o="left"===e.verticalAxisPosition?"l":"r",n=e.stacked?"stacked":"standard";return
|
|
2021
|
+
`)}const o="left"===e.verticalAxisPosition?"l":"r",n=e.stacked?"stacked":"standard";return rv`
|
|
2022
2022
|
<c:lineChart>
|
|
2023
2023
|
<c:grouping val="${n}"/>
|
|
2024
2024
|
<!-- each data marker in the series does not have a different color -->
|
|
2025
2025
|
<c:varyColors val="0"/>
|
|
2026
|
-
${
|
|
2027
|
-
<c:axId val="${
|
|
2028
|
-
<c:axId val="${
|
|
2026
|
+
${sv(i)}
|
|
2027
|
+
<c:axId val="${FS}" />
|
|
2028
|
+
<c:axId val="${DS}" />
|
|
2029
2029
|
</c:lineChart>
|
|
2030
|
-
${
|
|
2031
|
-
${
|
|
2032
|
-
`}(e.data);break;case"pie":r=function(e,t,i,{holeSize:o}={holeSize:50}){const n=new
|
|
2030
|
+
${BS("b","c:catAx",FS,DS,{fontColor:e.fontColor})}
|
|
2031
|
+
${BS(o,"c:valAx",DS,FS,{fontColor:e.fontColor})}
|
|
2032
|
+
`}(e.data);break;case"pie":r=function(e,t,i,{holeSize:o}={holeSize:50}){const n=new xs,s=Math.max(...e.dataSets.map((e=>Nf(e.range,t,i)))),r=He(0,s).map((()=>us(n.next()))),a=[];for(const[o,n]of Object.entries(e.dataSets).reverse()){const s=Nf(n.range,t,i),l=[];for(const e of He(0,s)){const t=LS({backgroundColor:r[e],line:{color:"FFFFFF",width:1.5}});l.push(rv`
|
|
2033
2033
|
<c:dPt>
|
|
2034
2034
|
<c:idx val="${e}"/>
|
|
2035
2035
|
${t}
|
|
2036
2036
|
</c:dPt>
|
|
2037
|
-
`)}a.push(
|
|
2037
|
+
`)}a.push(rv`
|
|
2038
2038
|
<c:ser>
|
|
2039
2039
|
<c:idx val="${o}"/>
|
|
2040
2040
|
<c:order val="${o}"/>
|
|
2041
|
-
${n.label?
|
|
2042
|
-
${
|
|
2043
|
-
${
|
|
2044
|
-
${e.labelRange?
|
|
2041
|
+
${n.label?rv`<c:tx>${HS(n.label)}</c:tx>`:""}
|
|
2042
|
+
${sv(l)}
|
|
2043
|
+
${zS({showLeaderLines:!0})}
|
|
2044
|
+
${e.labelRange?rv`<c:cat>${HS(e.labelRange)}</c:cat>`:""}
|
|
2045
2045
|
<c:val>
|
|
2046
|
-
${
|
|
2046
|
+
${$S(n.range)}
|
|
2047
2047
|
</c:val>
|
|
2048
2048
|
</c:ser>
|
|
2049
|
-
`)}return
|
|
2049
|
+
`)}return rv`
|
|
2050
2050
|
<c:doughnutChart>
|
|
2051
2051
|
<c:varyColors val="1" />
|
|
2052
2052
|
<c:holeSize val="${o}" />
|
|
2053
|
-
${
|
|
2054
|
-
${
|
|
2053
|
+
${zS()}
|
|
2054
|
+
${sv(a)}
|
|
2055
2055
|
</c:doughnutChart>
|
|
2056
|
-
`}(e.data,t,i,{holeSize:0})}let a="t";switch(e.data.legendPosition){case"bottom":a="b";break;case"left":a="l";break;case"right":a="r";break;case"top":a="t"}const l=e.data.fontColor,c=
|
|
2057
|
-
<c:chartSpace ${
|
|
2056
|
+
`}(e.data,t,i,{holeSize:0})}let a="t";switch(e.data.legendPosition){case"bottom":a="b";break;case"left":a="l";break;case"right":a="r";break;case"top":a="t"}const l=e.data.fontColor,c=rv`
|
|
2057
|
+
<c:chartSpace ${iv(o)}>
|
|
2058
2058
|
<c:roundedCorners val="0" />
|
|
2059
2059
|
<!-- <manualLayout/> to manually position the chart in the figure container -->
|
|
2060
2060
|
${n}
|
|
@@ -2065,32 +2065,32 @@
|
|
|
2065
2065
|
<!-- how the chart element is placed on the chart -->
|
|
2066
2066
|
<c:layout />
|
|
2067
2067
|
${r}
|
|
2068
|
-
${
|
|
2068
|
+
${LS({backgroundColor:e.data.backgroundColor})}
|
|
2069
2069
|
</c:plotArea>
|
|
2070
|
-
${function(e,t){return
|
|
2070
|
+
${function(e,t){return rv`
|
|
2071
2071
|
<c:legend>
|
|
2072
2072
|
<c:legendPos val="${e}"/>
|
|
2073
2073
|
<c:overlay val="0"/>
|
|
2074
|
-
${
|
|
2074
|
+
${VS(10,t)}
|
|
2075
2075
|
</c:legend>
|
|
2076
2076
|
`}(a,l)}
|
|
2077
2077
|
</c:chart>
|
|
2078
2078
|
</c:chartSpace>
|
|
2079
|
-
`;return
|
|
2079
|
+
`;return ov(c)}function LS(e){return rv`
|
|
2080
2080
|
<c:spPr>
|
|
2081
|
-
${e.backgroundColor?
|
|
2082
|
-
${e.line?function(e){const t=[["cmpd","sng"]];e.width&&t.push(["w",
|
|
2083
|
-
<a:ln ${
|
|
2084
|
-
${
|
|
2081
|
+
${e.backgroundColor?PS(e.backgroundColor):""}
|
|
2082
|
+
${e.line?function(e){const t=[["cmpd","sng"]];e.width&&t.push(["w",Of(e.width)]);const i=e.style?rv`<a:prstDash val="${e.style}"/>`:"";return rv`
|
|
2083
|
+
<a:ln ${iv(t)}>
|
|
2084
|
+
${PS(e.color)}
|
|
2085
2085
|
${i}
|
|
2086
2086
|
</a:ln>
|
|
2087
2087
|
`}(e.line):""}
|
|
2088
2088
|
</c:spPr>
|
|
2089
|
-
`}function
|
|
2089
|
+
`}function PS(e){return rv`
|
|
2090
2090
|
<a:solidFill>
|
|
2091
2091
|
<a:srgbClr val="${e}"/>
|
|
2092
2092
|
</a:solidFill>
|
|
2093
|
-
`}function
|
|
2093
|
+
`}function US(e,t="000000",i=22){return rv`
|
|
2094
2094
|
<c:tx>
|
|
2095
2095
|
<c:rich>
|
|
2096
2096
|
<a:bodyPr />
|
|
@@ -2098,7 +2098,7 @@
|
|
|
2098
2098
|
<a:p>
|
|
2099
2099
|
<a:pPr lvl="0">
|
|
2100
2100
|
<a:defRPr b="0">
|
|
2101
|
-
${
|
|
2101
|
+
${PS(t)}
|
|
2102
2102
|
<a:latin typeface="+mn-lt"/>
|
|
2103
2103
|
</a:defRPr>
|
|
2104
2104
|
</a:pPr>
|
|
@@ -2109,20 +2109,20 @@
|
|
|
2109
2109
|
</a:p>
|
|
2110
2110
|
</c:rich>
|
|
2111
2111
|
</c:tx>
|
|
2112
|
-
`}function
|
|
2112
|
+
`}function VS(e=12,t="000000",i=!1,o=!1){return rv`
|
|
2113
2113
|
<c:txPr>
|
|
2114
2114
|
<a:bodyPr/>
|
|
2115
2115
|
<a:lstStyle/>
|
|
2116
2116
|
<a:p>
|
|
2117
2117
|
<a:pPr lvl="0">
|
|
2118
|
-
<a:defRPr ${
|
|
2119
|
-
${
|
|
2118
|
+
<a:defRPr ${iv([["b",i?"1":"0"],["i",o?"1":"0"],["sz",100*e]])}>
|
|
2119
|
+
${PS(t)}
|
|
2120
2120
|
<a:latin typeface="+mn-lt"/>
|
|
2121
2121
|
</a:defRPr>
|
|
2122
2122
|
</a:pPr>
|
|
2123
2123
|
</a:p>
|
|
2124
2124
|
</c:txPr>
|
|
2125
|
-
`}function
|
|
2125
|
+
`}function zS({showLeaderLines:e}={showLeaderLines:!1}){return rv`
|
|
2126
2126
|
<dLbls>
|
|
2127
2127
|
<c:showLegendKey val="0"/>
|
|
2128
2128
|
<c:showVal val="0"/>
|
|
@@ -2132,7 +2132,7 @@
|
|
|
2132
2132
|
<c:showBubbleSize val="0"/>
|
|
2133
2133
|
<c:showLeaderLines val="${e?"1":"0"}"/>
|
|
2134
2134
|
</dLbls>
|
|
2135
|
-
`}function
|
|
2135
|
+
`}function BS(e,t,i,o,{fontColor:n}){return rv`
|
|
2136
2136
|
<${t}>
|
|
2137
2137
|
<c:axId val="${i}"/>
|
|
2138
2138
|
<c:crossAx val="${o}"/> <!-- reference to the other axe of the chart -->
|
|
@@ -2141,62 +2141,62 @@
|
|
|
2141
2141
|
<c:orientation val="minMax" />
|
|
2142
2142
|
</c:scaling>
|
|
2143
2143
|
<c:axPos val="${e}" />
|
|
2144
|
-
${function(e="B7B7B7"){return
|
|
2144
|
+
${function(e="B7B7B7"){return rv`
|
|
2145
2145
|
<c:majorGridlines>
|
|
2146
|
-
${
|
|
2146
|
+
${LS({line:{color:e}})}
|
|
2147
2147
|
</c:majorGridlines>
|
|
2148
2148
|
`}()}
|
|
2149
2149
|
<c:majorTickMark val="out" />
|
|
2150
2150
|
<c:minorTickMark val="none" />
|
|
2151
2151
|
<c:numFmt formatCode="General" sourceLinked="1" />
|
|
2152
2152
|
<c:title>
|
|
2153
|
-
${
|
|
2153
|
+
${US("")}
|
|
2154
2154
|
</c:title>
|
|
2155
|
-
${
|
|
2155
|
+
${VS(10,n)}
|
|
2156
2156
|
</${t}>
|
|
2157
2157
|
<!-- <tickLblPos/> omitted -->
|
|
2158
|
-
`}function
|
|
2158
|
+
`}function HS(e){return rv`
|
|
2159
2159
|
<c:strRef>
|
|
2160
2160
|
<c:f>${e}</c:f>
|
|
2161
2161
|
</c:strRef>
|
|
2162
|
-
`}function
|
|
2162
|
+
`}function $S(e){return rv`
|
|
2163
2163
|
<c:numRef>
|
|
2164
2164
|
<c:f>${e}</c:f>
|
|
2165
2165
|
<c:numCache />
|
|
2166
2166
|
</c:numRef>
|
|
2167
|
-
`}function
|
|
2167
|
+
`}function WS(e){const t=e.content,i=tg.content,o=[];let n=rv``;if(_m(t).filter((e=>"FUNCTION"===e.type)).every((e=>i[e.value.toUpperCase()].isExported))){let i=rv``;const s=qS(t);return e.value===a.CircularDependency&&(o.push(["t","str"]),i=rv`<v>${e.value}</v>`),n=rv`
|
|
2168
2168
|
<f>
|
|
2169
2169
|
${s}
|
|
2170
2170
|
</f>
|
|
2171
2171
|
${i}
|
|
2172
|
-
`,{attrs:o,node:n}}{const t=e.value,i=function(e){switch(typeof e){case"boolean":return"b";case"string":return"str";case"number":return"n"}}(t);return o.push(["t",i]),n=
|
|
2172
|
+
`,{attrs:o,node:n}}{const t=e.value,i=function(e){switch(typeof e){case"boolean":return"b";case"string":return"str";case"number":return"n"}}(t);return o.push(["t",i]),n=rv`<v>${t}</v>`,{attrs:o,node:n}}}function GS(e,t,i=!1){let o=e;const n=[];if(!i&&["TRUE","FALSE"].includes(o.trim()))o="TRUE"===o?"1":"0",n.push(["t","b"]);else if(i||!oi(o)){const{id:i}=If(e,t);o=i.toString(),n.push(["t","s"])}return{attrs:n,node:rv`<v>${o}</v>`}}function qS(e){let t;"="===e[0]&&(e=e.slice(1));try{t=Jm(e)}catch(t){return e}return t=tf(t,"STRING",ZS),t=tf(t,"FUNCALL",(e=>e=function(e){const t=e.value.toUpperCase(),i=e.args,o=Vp[t];if(o){const n=tg.content[t].args.filter((e=>!e.optional)),s=n.length-e.args.length;if(s)for(let t=e.args.length;t<n.length;t++){const e=o[t-s];i.push({type:e.type,value:e.value})}}return{...e,args:i}}(e=function(e){const t=e.value.toUpperCase();return{...e,value:zp.includes(t)?`_xlfn.${t}`:t}}(e={...e,value:e.value.toUpperCase()})))),t?of(t):e}function ZS(e){const t=e.value.replace(new RegExp('"',"g"),""),i=Ee(t);if(i){let o=[];return(t.match(ve)||t.match(be))&&o.push("yyyy-mm-dd"),t.match(Se)&&o.push("hh:mm:ss"),{...e,value:mi(i.value,o.join(" "))}}return{...e,value:e.value.replace(/\\"/g,'""')}}function jS(e,t){const i=[];for(const o of t)switch(o.rule.type){case"CellIsRule":i.push(XS(o,o.rule,e));break;case"ColorScaleRule":i.push(YS(o,o.rule));break;case"IconSetRule":i.push(KS(o,o.rule));break;default:console.warn(`Conditional formatting ${o.rule.type} not implemented`)}return i}function XS(e,t,i){const o=QS(e),n=bf(t.operator);o.push(...function(e){const t=bf(e.operator);switch(e.operator){case"ContainsText":case"NotContains":case"BeginsWith":case"EndsWith":return[["type",t],["text",e.values[0]]];case"IsEmpty":case"IsNotEmpty":return[["type",t]];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":case"Between":case"NotBetween":return[["type","cellIs"]]}}(t),["operator",n]);const s=function(e,t){const i=e[0].split(":")[0],o=t.values;switch(t.operator){case"ContainsText":return[`NOT(ISERROR(SEARCH("${o[0]}",${i})))`];case"NotContains":return[`ISERROR(SEARCH("${o[0]}",${i}))`];case"BeginsWith":return[`LEFT(${i},LEN("${o[0]}"))="${o[0]}"`];case"EndsWith":return[`RIGHT(${i},LEN("${o[0]}"))="${o[0]}"`];case"IsEmpty":return[`LEN(TRIM(${i}))=0`];case"IsNotEmpty":return[`LEN(TRIM(${i}))>0`];case"Equal":case"NotEqual":case"GreaterThan":case"GreaterThanOrEqual":case"LessThan":case"LessThanOrEqual":return[o[0]];case"Between":case"NotBetween":return[o[0],o[1]]}}(e.ranges,t).map((e=>rv`<formula>${e}</formula>`)),r={font:{color:{rgb:t.style.textColor},bold:t.style.bold,italic:t.style.italic,strike:t.style.strikethrough,underline:t.style.underline}};t.style.fillColor&&(r.fill={fgColor:{rgb:t.style.fillColor}});const{id:a}=If(r,i);return o.push(["dxfId",a]),rv`
|
|
2173
2173
|
<conditionalFormatting sqref="${e.ranges.join(" ")}">
|
|
2174
|
-
<cfRule ${
|
|
2175
|
-
${
|
|
2174
|
+
<cfRule ${iv(o)}>
|
|
2175
|
+
${sv(s)}
|
|
2176
2176
|
</cfRule>
|
|
2177
2177
|
</conditionalFormatting>
|
|
2178
|
-
`}function
|
|
2178
|
+
`}function YS(e,t){const i=QS(e);i.push(["type","colorScale"]);const o=[];for(const n of e.ranges){const e=[],s=[];let r=!0;for(let i of["minimum","midpoint","maximum"]){const o=t[i];o&&("formula"!==o.type?(e.push(eC(o,i)),s.push([["rgb",us(Ct(o.color))]])):r=!1)}if(!r){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const a=e.map((e=>rv`<cfvo ${iv(e)}/>`)),l=s.map((e=>rv`<color ${iv(e)}/>`));o.push(rv`
|
|
2179
2179
|
<conditionalFormatting sqref="${n}">
|
|
2180
|
-
<cfRule ${
|
|
2180
|
+
<cfRule ${iv(i)}>
|
|
2181
2181
|
<colorScale>
|
|
2182
|
-
${
|
|
2183
|
-
${
|
|
2182
|
+
${sv(a)}
|
|
2183
|
+
${sv(l)}
|
|
2184
2184
|
</colorScale>
|
|
2185
2185
|
</cfRule>
|
|
2186
2186
|
</conditionalFormatting>
|
|
2187
|
-
`)}return
|
|
2187
|
+
`)}return sv(o)}function KS(e,t){const i=QS(e);i.push(["type","iconSet"]);const o=[];for(const n of e.ranges){const e=[[["type","percent"],["val",0]]];let s=!0;for(let i of["lowerInflectionPoint","upperInflectionPoint"]){if("formula"===t[i].type){s=!1;continue}const o=t[i];e.push([...eC(o,i),["gte","ge"===o.operator?"1":"0"]])}if(!s){console.warn("Conditional formats with formula rules are not supported at the moment. The rule is therefore skipped.");continue}const r=e.map((e=>rv`<cfvo ${iv(e)} />`));o.push(rv`
|
|
2188
2188
|
<conditionalFormatting sqref="${n}">
|
|
2189
|
-
<cfRule ${
|
|
2190
|
-
<iconSet iconSet="${
|
|
2191
|
-
${
|
|
2189
|
+
<cfRule ${iv(i)}>
|
|
2190
|
+
<iconSet iconSet="${JS(t.icons)}">
|
|
2191
|
+
${sv(r)}
|
|
2192
2192
|
</iconSet>
|
|
2193
2193
|
</cfRule>
|
|
2194
2194
|
</conditionalFormatting>
|
|
2195
|
-
`)}return
|
|
2196
|
-
<xdr:wsDr ${
|
|
2197
|
-
${
|
|
2195
|
+
`)}return sv(o)}function QS(e){return[["priority",1],["stopIfTrue",e.stopIfTrue?1:0]]}function JS(e){return Ip[Object.keys(Ip).find((t=>e.upper.toLowerCase().startsWith(t)))||"dots"]}function eC(e,t){const i=function(e,t){switch(e){case"value":return"minimum"===t?"min":"max";case"number":return"num";case"percentage":return"percent";default:return e}}(e.type,t),o=[["type",i]];if("min"!==i&&"max"!==i){let t=e.value;if("formula"===i)try{t=qS(e.value)}catch(i){t=e.value}o.push(["val",t])}return o}function tC(e,t,i){const o=[["xmlns:xdr",Rp.drawing],["xmlns:r",Np],["xmlns:a",Tp],["xmlns:c",Ap]],n=[];for(const[o,s]of Object.entries(i))switch(null==s?void 0:s.tag){case"chart":n.push(nC(s,t,e[o]));break;case"image":n.push(sC(s,t,e[o]))}return ov(rv`
|
|
2196
|
+
<xdr:wsDr ${iv(o)}>
|
|
2197
|
+
${sv(n)}
|
|
2198
2198
|
</xdr:wsDr>
|
|
2199
|
-
`)}function
|
|
2199
|
+
`)}function iC(e,t){const{x:i,y:o,height:n,width:s}=e,r=Object.values(t.cols),a=Object.values(t.rows),{index:l,offset:c}=oC(r,i),{index:h,offset:d}=oC(r,i+s),{index:u,offset:g}=oC(a,o),{index:p,offset:m}=oC(a,o+n);return{from:{col:l,colOff:c,row:u,rowOff:g},to:{col:h,colOff:d,row:p,rowOff:m}}}function oC(e,t){let i=0;for(const[o,n]of Object.entries(e)){if(i<=t&&t<i+n.size)return{index:parseInt(o),offset:Of(t-i+W)};i+=n.size}return{index:e.length-1,offset:Of(t-i+W)}}function nC(e,t,i){const{from:o,to:n}=iC(e,t),s=Tf(e.id),r=[["id",s],["name",`Chart ${s}`],["title","Chart"]];return rv`
|
|
2200
2200
|
<xdr:twoCellAnchor>
|
|
2201
2201
|
<xdr:from>
|
|
2202
2202
|
<xdr:col>${o.col}</xdr:col>
|
|
@@ -2212,7 +2212,7 @@
|
|
|
2212
2212
|
</xdr:to>
|
|
2213
2213
|
<xdr:graphicFrame>
|
|
2214
2214
|
<xdr:nvGraphicFramePr>
|
|
2215
|
-
<xdr:cNvPr ${
|
|
2215
|
+
<xdr:cNvPr ${iv(r)} />
|
|
2216
2216
|
<xdr:cNvGraphicFramePr />
|
|
2217
2217
|
</xdr:nvGraphicFramePr>
|
|
2218
2218
|
<xdr:xfrm>
|
|
@@ -2220,14 +2220,14 @@
|
|
|
2220
2220
|
<a:ext cx="0" cy="0"/>
|
|
2221
2221
|
</xdr:xfrm>
|
|
2222
2222
|
<a:graphic>
|
|
2223
|
-
<a:graphicData uri="${
|
|
2223
|
+
<a:graphicData uri="${Ap}">
|
|
2224
2224
|
<c:chart r:id="${i}" />
|
|
2225
2225
|
</a:graphicData>
|
|
2226
2226
|
</a:graphic>
|
|
2227
2227
|
</xdr:graphicFrame>
|
|
2228
2228
|
<xdr:clientData fLocksWithSheet="0"/>
|
|
2229
2229
|
</xdr:twoCellAnchor>
|
|
2230
|
-
`}function
|
|
2230
|
+
`}function sC(e,t,i){const{from:o,to:n}=iC(e,t),s=Mf(e.id),r=[["id",s],["name",`Image ${s}`],["title","Image"]];return rv`
|
|
2231
2231
|
<xdr:twoCellAnchor editAs="oneCell">
|
|
2232
2232
|
<xdr:from>
|
|
2233
2233
|
<xdr:col>${o.col}</xdr:col>
|
|
@@ -2243,7 +2243,7 @@
|
|
|
2243
2243
|
</xdr:to>
|
|
2244
2244
|
<xdr:pic>
|
|
2245
2245
|
<xdr:nvPicPr>
|
|
2246
|
-
<xdr:cNvPr ${
|
|
2246
|
+
<xdr:cNvPr ${iv(r)}/>
|
|
2247
2247
|
<xdr:cNvPicPr preferRelativeResize="0"/>
|
|
2248
2248
|
</xdr:nvPicPr>
|
|
2249
2249
|
<xdr:blipFill>
|
|
@@ -2261,69 +2261,69 @@
|
|
|
2261
2261
|
</xdr:pic>
|
|
2262
2262
|
<xdr:clientData fLocksWithSheet="0"/>
|
|
2263
2263
|
</xdr:twoCellAnchor>
|
|
2264
|
-
`}function
|
|
2264
|
+
`}function rC(e){return ot(e)?rv``:rv`
|
|
2265
2265
|
<font>
|
|
2266
|
-
${e.bold?
|
|
2267
|
-
${e.italic?
|
|
2268
|
-
${e.underline?
|
|
2269
|
-
${e.strike?
|
|
2270
|
-
${e.size?
|
|
2271
|
-
${e.color&&e.color.rgb?
|
|
2272
|
-
${e.name?
|
|
2266
|
+
${e.bold?rv`<b />`:""}
|
|
2267
|
+
${e.italic?rv`<i />`:""}
|
|
2268
|
+
${e.underline?rv`<u />`:""}
|
|
2269
|
+
${e.strike?rv`<strike />`:""}
|
|
2270
|
+
${e.size?rv`<sz val="${e.size}" />`:""}
|
|
2271
|
+
${e.color&&e.color.rgb?rv`<color rgb="${us(e.color.rgb)}" />`:""}
|
|
2272
|
+
${e.name?rv`<name val="${e.name}" />`:""}
|
|
2273
2273
|
</font>
|
|
2274
|
-
`}function
|
|
2275
|
-
<table ${
|
|
2276
|
-
${function(e){const t=[["ref",e.range]];return
|
|
2277
|
-
<autoFilter ${
|
|
2278
|
-
${
|
|
2279
|
-
<filterColumn ${
|
|
2280
|
-
${
|
|
2274
|
+
`}function aC(e){return e?iv([["style",e.style],["color",us(e.color.rgb)]]):rv``}const lC=rv`<tableStyleInfo name="TableStyleLight8" showFirstColumn="0" showLastColumn="0" showRowStripes="0" showColumnStripes="0"/>`;function cC(e,t,i){const o=rv`
|
|
2275
|
+
<table ${iv([["id",t],["name",`Table${t}`],["displayName",`Table${t}`],["ref",e.range],["xmlns",Rp.table],["xmlns:xr",Rp.revision],["xmlns:xr3",Rp.revision3],["xmlns:mc",Rp.markupCompatibility]])}>
|
|
2276
|
+
${function(e){const t=[["ref",e.range]];return rv`
|
|
2277
|
+
<autoFilter ${iv(t)}>
|
|
2278
|
+
${sv(function(e){const t=[];for(const i of e.filters){const e=rv`
|
|
2279
|
+
<filterColumn ${iv([["colId",i.colId]])}>
|
|
2280
|
+
${hC(i)}
|
|
2281
2281
|
</filterColumn>
|
|
2282
2282
|
`;t.push(e)}return t}(e))}
|
|
2283
2283
|
</autoFilter>
|
|
2284
2284
|
`}(e)}
|
|
2285
|
-
${function(e,t){var i;const o=Bi(e.range),n=[];for(const e of He(0,io(o).numberOfCols)){const s=qt(o.left+e,o.top),r=[["id",e+1],["name",(null===(i=t.cells[s])||void 0===i?void 0:i.content)||`col${e}`]];n.push(
|
|
2286
|
-
<tableColumns ${
|
|
2287
|
-
${
|
|
2285
|
+
${function(e,t){var i;const o=Bi(e.range),n=[];for(const e of He(0,io(o).numberOfCols)){const s=qt(o.left+e,o.top),r=[["id",e+1],["name",(null===(i=t.cells[s])||void 0===i?void 0:i.content)||`col${e}`]];n.push(rv`<tableColumn ${iv(r)}/>`)}return rv`
|
|
2286
|
+
<tableColumns ${iv([["count",n.length]])}>
|
|
2287
|
+
${sv(n)}
|
|
2288
2288
|
</tableColumns>
|
|
2289
2289
|
`}(e,i)}
|
|
2290
|
-
${
|
|
2290
|
+
${lC}
|
|
2291
2291
|
</table>
|
|
2292
|
-
`;return
|
|
2293
|
-
<filters ${
|
|
2294
|
-
${
|
|
2292
|
+
`;return ov(o)}function hC(e){const t=e.displayedValues.map((e=>rv`<filter ${iv([["val",e]])}/>`));return rv`
|
|
2293
|
+
<filters ${iv(e.displayBlanks?[["blank",1]]:[])}>
|
|
2294
|
+
${sv(t)}
|
|
2295
2295
|
</filters>
|
|
2296
|
-
`}function
|
|
2297
|
-
<col ${
|
|
2298
|
-
`)}return
|
|
2296
|
+
`}function dC(e){if(!Object.values(e).length)return rv``;const t=[];for(let[i,o]of Object.entries(e)){const e=[["min",parseInt(i)+1],["max",parseInt(i)+1],["width",Cf(o.size||F)],["customWidth",1],["hidden",o.isHidden?1:0]];t.push(rv`
|
|
2297
|
+
<col ${iv(e)}/>
|
|
2298
|
+
`)}return rv`
|
|
2299
2299
|
<cols>
|
|
2300
|
-
${
|
|
2300
|
+
${sv(t)}
|
|
2301
2301
|
</cols>
|
|
2302
|
-
`}function
|
|
2303
|
-
<c ${
|
|
2302
|
+
`}function uC(e,t,i){const o=[];for(let n=0;n<i.rowNumber;n++){const s=[["r",n+1]],r=i.rows[n]||{};s.push(["ht",Sf(r.size||D)],["customHeight",1],["hidden",r.isHidden?1:0]);const a=[];for(let o=0;o<i.colNumber;o++){const s=qt(o,n),r=i.cells[s];if(r){const l=[["r",s]],c=yf(e,wf(r,t));l.push(["s",c]);let h=[],d=rv``;if(r.isFormula)({attrs:h,node:d}=WS(r));else if(r.content&&je(r.content)){const{label:t}=Ke(r.content);({attrs:h,node:d}=GS(t,e.sharedStrings))}else if(r.content&&""!==r.content){const t=gC(o,n,i);({attrs:h,node:d}=GS(r.content,e.sharedStrings,t))}l.push(...h),a.push(rv`
|
|
2303
|
+
<c ${iv(l)}>
|
|
2304
2304
|
${d}
|
|
2305
2305
|
</c>
|
|
2306
|
-
`)}}(a.length||r.size!==D||r.isHidden)&&o.push(
|
|
2307
|
-
<row ${
|
|
2308
|
-
${
|
|
2306
|
+
`)}}(a.length||r.size!==D||r.isHidden)&&o.push(rv`
|
|
2307
|
+
<row ${iv(s)}>
|
|
2308
|
+
${sv(a)}
|
|
2309
2309
|
</row>
|
|
2310
|
-
`)}return
|
|
2310
|
+
`)}return rv`
|
|
2311
2311
|
<sheetData>
|
|
2312
|
-
${
|
|
2312
|
+
${sv(o)}
|
|
2313
2313
|
</sheetData>
|
|
2314
|
-
`}function
|
|
2314
|
+
`}function gC(e,t,i){return i.filterTables.some((i=>{const o=Bi(i.range),n={...o,bottom:o.top};return Qi(e,t,n)}))}function pC(e,t,i){var o;const n=t.sheets[i].cells,s=[];for(const r in n){const a=null===(o=n[r])||void 0===o?void 0:o.content;if(a&&je(a)){const{label:o,url:n}=Ke(a);if(Je(n)){const e=tt(n),i=t.sheets.find((t=>t.id===e)),a=i?`${i.name}!A1`:K;s.push(rv`
|
|
2315
2315
|
<hyperlink display="${o}" location="${a}" ref="${r}"/>
|
|
2316
|
-
`)}else{const t=
|
|
2316
|
+
`)}else{const t=xf(e.relsFiles,`xl/worksheets/_rels/sheet${i}.xml.rels`,{target:Ro(n),type:Op.hyperlink,targetMode:"External"});s.push(rv`
|
|
2317
2317
|
<hyperlink r:id="${t}" ref="${r}"/>
|
|
2318
|
-
`)}}}return s.length?
|
|
2318
|
+
`)}}}return s.length?rv`
|
|
2319
2319
|
<hyperlinks>
|
|
2320
|
-
${
|
|
2320
|
+
${sv(s)}
|
|
2321
2321
|
</hyperlinks>
|
|
2322
|
-
`:
|
|
2322
|
+
`:rv``}function mC(e){if(e.length){const t=e.map((e=>rv`<mergeCell ref="${e}" />`));return rv`
|
|
2323
2323
|
<mergeCells count="${e.length}">
|
|
2324
|
-
${
|
|
2324
|
+
${sv(t)}
|
|
2325
2325
|
</mergeCells>
|
|
2326
|
-
`}return
|
|
2326
|
+
`}return rv``}function fC(e){const t=e.panes;let i=rv``;if(t&&(t.xSplit||t.ySplit)){const e=qt(t.xSplit,t.ySplit),o=t.xSplit?rv`xSplit="${t.xSplit}"`:"",n=t.ySplit?rv`ySplit="${t.ySplit}"`:"",s=t.xSplit?rv`<selection pane="topRight"/>`:"",r=t.ySplit?rv`<selection pane="bottomLeft"/>`:"",a=t.xSplit&&t.ySplit?rv`<selection pane="bottomRight"/>`:"";i=rv`
|
|
2327
2327
|
<pane
|
|
2328
2328
|
${o}
|
|
2329
2329
|
${n}
|
|
@@ -2333,126 +2333,126 @@
|
|
|
2333
2333
|
${s}
|
|
2334
2334
|
${r}
|
|
2335
2335
|
${a}
|
|
2336
|
-
`}return
|
|
2336
|
+
`}return rv`
|
|
2337
2337
|
<sheetViews>
|
|
2338
2338
|
<sheetView showGridLines="${e.areGridLinesVisible?1:0}" workbookViewId="0">
|
|
2339
2339
|
${i}
|
|
2340
2340
|
</sheetView>
|
|
2341
2341
|
</sheetViews>
|
|
2342
|
-
`}function
|
|
2343
|
-
<sheet ${
|
|
2344
|
-
`),
|
|
2345
|
-
<workbook ${
|
|
2342
|
+
`}function vC(e){const t=[],i={relsFiles:[],sharedStrings:[],styles:[{fontId:0,fillId:0,numFmtId:0,borderId:0,alignment:{vertical:"center"}}],fonts:[{size:q,family:2,color:{rgb:"000000"},name:"Calibri"}],fills:[{reservedAttribute:"none"},{reservedAttribute:"gray125"}],borders:[{}],numFmts:[],dxfs:[]};return t.push(function(e,t){const i=[["xmlns",Rp.workbook],["xmlns:r",Np]],o=[];for(const[i,n]of Object.entries(e.sheets)){const e=[["state",n.isVisible?"visible":"hidden"],["name",n.name],["sheetId",parseInt(i)+1],["r:id",`rId${parseInt(i)+1}`]];o.push(rv`
|
|
2343
|
+
<sheet ${iv(e)} />
|
|
2344
|
+
`),xf(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:Op.sheet,target:`worksheets/sheet${i}.xml`})}return ev(ov(rv`
|
|
2345
|
+
<workbook ${iv(i)}>
|
|
2346
2346
|
<sheets>
|
|
2347
|
-
${
|
|
2347
|
+
${sv(o)}
|
|
2348
2348
|
</sheets>
|
|
2349
2349
|
</workbook>
|
|
2350
|
-
`),"xl/workbook.xml","workbook")}(e,i)),t.push(...function(e,t){const i=[];let o=1;for(const[n,s]of Object.entries(e.sheets)){const r=[["xmlns",
|
|
2351
|
-
<worksheet ${
|
|
2352
|
-
${
|
|
2353
|
-
<sheetFormatPr ${
|
|
2354
|
-
${
|
|
2355
|
-
${
|
|
2356
|
-
${
|
|
2357
|
-
${
|
|
2358
|
-
${
|
|
2350
|
+
`),"xl/workbook.xml","workbook")}(e,i)),t.push(...function(e,t){const i=[];let o=1;for(const[n,s]of Object.entries(e.sheets)){const r=[["xmlns",Rp.worksheet],["xmlns:r",Np]],a=[["defaultRowHeight",Sf(D)],["defaultColWidth",Cf(F)]],l=bC(s,n,o,t,i);o+=s.filterTables.length;let c=rv``;const h=[];for(const o of s.charts){const s=Tf(o.id),r=xf(t.relsFiles,`xl/drawings/_rels/drawing${n}.xml.rels`,{target:`../charts/chart${s}.xml`,type:Op.chart});h.push(r),i.push(ev(kS(o,n,e),`xl/charts/chart${s}.xml`,"chart"))}for(const e of s.images){const o=e.data.mimetype;if(void 0===o)continue;const s=am[o];if(void 0===s)continue;let r=`image${Mf(e.id)}.${s}`;const a=xf(t.relsFiles,`xl/drawings/_rels/drawing${n}.xml.rels`,{target:`../media/${r}`,type:Op.image});h.push(a),i.push({path:`xl/media/${r}`,imageSrc:e.data.path})}const d=[...s.charts,...s.images];if(d.length){const e=xf(t.relsFiles,`xl/worksheets/_rels/sheet${n}.xml.rels`,{target:`../drawings/drawing${n}.xml`,type:Op.drawing});i.push(ev(tC(h,s,d),`xl/drawings/drawing${n}.xml`,"drawing")),c=rv`<drawing r:id="${e}" />`}const u=rv`
|
|
2351
|
+
<worksheet ${iv(r)}>
|
|
2352
|
+
${fC(s)}
|
|
2353
|
+
<sheetFormatPr ${iv(a)} />
|
|
2354
|
+
${dC(s.cols)}
|
|
2355
|
+
${uC(t,e,s)}
|
|
2356
|
+
${mC(s.merges)}
|
|
2357
|
+
${sv(jS(t.dxfs,s.conditionalFormats))}
|
|
2358
|
+
${pC(t,e,n)}
|
|
2359
2359
|
${c}
|
|
2360
2360
|
${l}
|
|
2361
2361
|
</worksheet>
|
|
2362
|
-
`;i.push(
|
|
2363
|
-
<styleSheet ${
|
|
2364
|
-
${function(e){const t=[];for(let[i,o]of Object.entries(e)){const e=[["numFmtId",parseInt(i)+
|
|
2365
|
-
<numFmt ${
|
|
2366
|
-
`)}return
|
|
2362
|
+
`;i.push(ev(ov(u),`xl/worksheets/sheet${n}.xml`,"sheet"))}return xf(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:Op.sharedStrings,target:"sharedStrings.xml"}),xf(t.relsFiles,"xl/_rels/workbook.xml.rels",{type:Op.styles,target:"styles.xml"}),i}(e,i)),t.push(function(e){const t=rv`
|
|
2363
|
+
<styleSheet ${iv([["xmlns",Rp.styleSheet],["xmlns:r",Np]])}>
|
|
2364
|
+
${function(e){const t=[];for(let[i,o]of Object.entries(e)){const e=[["numFmtId",parseInt(i)+Up],["formatCode",o.format]];t.push(rv`
|
|
2365
|
+
<numFmt ${iv(e)}/>
|
|
2366
|
+
`)}return rv`
|
|
2367
2367
|
<numFmts count="${e.length}">
|
|
2368
|
-
${
|
|
2368
|
+
${sv(t)}
|
|
2369
2369
|
</numFmts>
|
|
2370
2370
|
`}(e.numFmts)}
|
|
2371
|
-
${i=e.fonts,
|
|
2371
|
+
${i=e.fonts,rv`
|
|
2372
2372
|
<fonts count="${i.length}">
|
|
2373
|
-
${
|
|
2373
|
+
${sv(Object.values(i).map(rC))}
|
|
2374
2374
|
</fonts>
|
|
2375
2375
|
`}
|
|
2376
|
-
${function(e){const t=[];for(let i of Object.values(e))void 0!==i.reservedAttribute?t.push(
|
|
2376
|
+
${function(e){const t=[];for(let i of Object.values(e))void 0!==i.reservedAttribute?t.push(rv`
|
|
2377
2377
|
<fill>
|
|
2378
2378
|
<patternFill patternType="${i.reservedAttribute}" />
|
|
2379
2379
|
</fill>
|
|
2380
|
-
`):t.push(
|
|
2380
|
+
`):t.push(rv`
|
|
2381
2381
|
<fill>
|
|
2382
2382
|
<patternFill patternType="solid">
|
|
2383
|
-
<fgColor rgb="${
|
|
2383
|
+
<fgColor rgb="${us(i.fgColor.rgb)}" />
|
|
2384
2384
|
<bgColor indexed="64" />
|
|
2385
2385
|
</patternFill>
|
|
2386
2386
|
</fill>
|
|
2387
|
-
`);return
|
|
2387
|
+
`);return rv`
|
|
2388
2388
|
<fills count="${e.length}">
|
|
2389
|
-
${
|
|
2389
|
+
${sv(t)}
|
|
2390
2390
|
</fills>
|
|
2391
2391
|
`}(e.fills)}
|
|
2392
|
-
${function(e){const t=[];for(let i of Object.values(e))t.push(
|
|
2392
|
+
${function(e){const t=[];for(let i of Object.values(e))t.push(rv`
|
|
2393
2393
|
<border>
|
|
2394
|
-
<left ${
|
|
2395
|
-
<right ${
|
|
2396
|
-
<top ${
|
|
2397
|
-
<bottom ${
|
|
2398
|
-
<diagonal ${
|
|
2394
|
+
<left ${aC(i.left)} />
|
|
2395
|
+
<right ${aC(i.right)} />
|
|
2396
|
+
<top ${aC(i.top)} />
|
|
2397
|
+
<bottom ${aC(i.bottom)} />
|
|
2398
|
+
<diagonal ${aC(i.diagonal)} />
|
|
2399
2399
|
</border>
|
|
2400
|
-
`);return
|
|
2400
|
+
`);return rv`
|
|
2401
2401
|
<borders count="${e.length}">
|
|
2402
|
-
${
|
|
2402
|
+
${sv(t)}
|
|
2403
2403
|
</borders>
|
|
2404
2404
|
`}(e.borders)}
|
|
2405
|
-
${function(e){const t=[];for(let i of e){const e=[["numFmtId",i.numFmtId],["fillId",i.fillId],["fontId",i.fontId],["borderId",i.borderId]],o=[];i.alignment&&i.alignment.vertical&&o.push(["vertical",i.alignment.vertical]),i.alignment&&i.alignment.horizontal&&o.push(["horizontal",i.alignment.horizontal]),t.push(
|
|
2406
|
-
<xf ${
|
|
2407
|
-
${o?
|
|
2405
|
+
${function(e){const t=[];for(let i of e){const e=[["numFmtId",i.numFmtId],["fillId",i.fillId],["fontId",i.fontId],["borderId",i.borderId]],o=[];i.alignment&&i.alignment.vertical&&o.push(["vertical",i.alignment.vertical]),i.alignment&&i.alignment.horizontal&&o.push(["horizontal",i.alignment.horizontal]),t.push(rv`
|
|
2406
|
+
<xf ${iv(e)}>
|
|
2407
|
+
${o?rv`<alignment ${iv(o)} />`:""}
|
|
2408
2408
|
</xf>
|
|
2409
|
-
`)}return
|
|
2409
|
+
`)}return rv`
|
|
2410
2410
|
<cellXfs count="${e.length}">
|
|
2411
|
-
${
|
|
2411
|
+
${sv(t)}
|
|
2412
2412
|
</cellXfs>
|
|
2413
2413
|
`}(e.styles)}
|
|
2414
|
-
${function(e){const t=[];for(const i of e){let e=
|
|
2414
|
+
${function(e){const t=[];for(const i of e){let e=rv``;i.font&&(e=rC(i.font));let o=rv``;i.fill&&(o=rv`
|
|
2415
2415
|
<fill>
|
|
2416
2416
|
<patternFill>
|
|
2417
|
-
<bgColor rgb="${
|
|
2417
|
+
<bgColor rgb="${us(i.fill.fgColor.rgb)}" />
|
|
2418
2418
|
</patternFill>
|
|
2419
2419
|
</fill>
|
|
2420
|
-
`),t.push(
|
|
2420
|
+
`),t.push(rv`
|
|
2421
2421
|
<dxf>
|
|
2422
2422
|
${e}
|
|
2423
2423
|
${o}
|
|
2424
2424
|
</dxf>
|
|
2425
|
-
`)}return
|
|
2425
|
+
`)}return rv`
|
|
2426
2426
|
<dxfs count="${e.length}">
|
|
2427
|
-
${
|
|
2427
|
+
${sv(t)}
|
|
2428
2428
|
</dxfs>
|
|
2429
2429
|
`}(e.dxfs)}
|
|
2430
2430
|
</styleSheet>
|
|
2431
|
-
`;var i;return
|
|
2432
|
-
<sst ${
|
|
2433
|
-
${
|
|
2431
|
+
`;var i;return ev(ov(t),"xl/styles.xml","styles")}(i)),t.push(function(e){const t=[["xmlns",Rp.sst],["count",e.length],["uniqueCount",e.length]],i=e.map((e=>rv`<si><t>${e}</t></si>`));return ev(ov(rv`
|
|
2432
|
+
<sst ${iv(t)}>
|
|
2433
|
+
${sv(i)}
|
|
2434
2434
|
</sst>
|
|
2435
|
-
`),"xl/sharedStrings.xml","sharedStrings")}(i.sharedStrings)),t.push(...function(e){const t=[];for(const i of e){const e=[];for(const t of i.rels){const i=[["Id",t.id],["Target",t.target],["Type",t.type]];t.targetMode&&i.push(["TargetMode",t.targetMode]),e.push(
|
|
2436
|
-
<Relationship ${
|
|
2437
|
-
`)}const o=
|
|
2438
|
-
<Relationships xmlns="${
|
|
2439
|
-
${
|
|
2435
|
+
`),"xl/sharedStrings.xml","sharedStrings")}(i.sharedStrings)),t.push(...function(e){const t=[];for(const i of e){const e=[];for(const t of i.rels){const i=[["Id",t.id],["Target",t.target],["Type",t.type]];t.targetMode&&i.push(["TargetMode",t.targetMode]),e.push(rv`
|
|
2436
|
+
<Relationship ${iv(i)} />
|
|
2437
|
+
`)}const o=rv`
|
|
2438
|
+
<Relationships xmlns="${Rp.Relationships}">
|
|
2439
|
+
${sv(e)}
|
|
2440
2440
|
</Relationships>
|
|
2441
|
-
`;t.push(
|
|
2441
|
+
`;t.push(ev(ov(o),i.path))}return t}(i.relsFiles)),t.push(function(e){const t=[],i=Object.entries(am).map((([e,t])=>function(e,t){return rv`
|
|
2442
2442
|
<Default Extension="${e}" ContentType="${t}" />
|
|
2443
|
-
`}(t,e)));for(const i of e)"contentType"in i&&i.contentType&&t.push(
|
|
2444
|
-
<Types xmlns="${
|
|
2445
|
-
${
|
|
2443
|
+
`}(t,e)));for(const i of e)"contentType"in i&&i.contentType&&t.push(nv("/"+i.path,Mp[i.contentType]));return ev(ov(rv`
|
|
2444
|
+
<Types xmlns="${Rp.Types}">
|
|
2445
|
+
${sv(Object.values(i))}
|
|
2446
2446
|
<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml" />
|
|
2447
2447
|
<Default Extension="xml" ContentType="application/xml" />
|
|
2448
|
-
${
|
|
2448
|
+
${sv(t)}
|
|
2449
2449
|
</Types>
|
|
2450
|
-
`),"[Content_Types].xml")}(t)),t.push(function(){const e=[["Id","rId1"],["Type",
|
|
2451
|
-
<Relationships xmlns="${
|
|
2452
|
-
<Relationship ${
|
|
2450
|
+
`),"[Content_Types].xml")}(t)),t.push(function(){const e=[["Id","rId1"],["Type",Op.document],["Target","xl/workbook.xml"]];return ev(ov(rv`
|
|
2451
|
+
<Relationships xmlns="${Rp.Relationships}">
|
|
2452
|
+
<Relationship ${iv(e)} />
|
|
2453
2453
|
</Relationships>
|
|
2454
|
-
`),"_rels/.rels")}()),{name:"my_spreadsheet.xlsx",files:t}}function
|
|
2454
|
+
`),"_rels/.rels")}()),{name:"my_spreadsheet.xlsx",files:t}}function bC(e,t,i,o,n){let s=i;if(!e.filterTables.length)return new wp("");const r=`xl/worksheets/_rels/sheet${t}.xml.rels`,a=[];for(const t of e.filterTables){const i=xf(o.relsFiles,r,{target:`../tables/table${s}.xml`,type:Op.table});n.push(ev(cC(t,s,e),`xl/tables/table${s}.xml`,"table")),a.push(rv`<tablePart r:id="${i}" />`),s++}return rv`
|
|
2455
2455
|
<tableParts count="${e.filterTables.length}">
|
|
2456
|
-
${
|
|
2456
|
+
${sv(a)}
|
|
2457
2457
|
</tableParts>
|
|
2458
|
-
`}var
|
|
2458
|
+
`}var SC;!function(e){e[e.Ready=0]="Ready",e[e.Running=1]="Running",e[e.RunningCore=2]="RunningCore",e[e.Finalizing=3]="Finalizing"}(SC||(SC={}));const CC={},EC={MIN_ROW_HEIGHT:10,MIN_COL_WIDTH:5,HEADER_HEIGHT:N,HEADER_WIDTH:_,TOPBAR_HEIGHT:63,BOTTOMBAR_HEIGHT:36,DEFAULT_CELL_WIDTH:F,DEFAULT_CELL_HEIGHT:D,SCROLLBAR_WIDTH:k},wC={autofillModifiersRegistry:Tn,autofillRulesRegistry:An,cellMenuRegistry:ua,colMenuRegistry:ga,linkMenuRegistry:ls,functionRegistry:tg,featurePluginRegistry:jb,statefulUIPluginRegistry:Xb,coreViewsPluginRegistry:Yb,corePluginRegistry:Zb,rowMenuRegistry:pa,sidePanelRegistry:Dg,figureRegistry:Sr,chartSidePanelComponentRegistry:Ig,chartComponentRegistry:pr,chartRegistry:gr,topbarMenuRegistry:og,topbarComponentRegistry:kg,clickableCellRegistry:Kb,otRegistry:sg,inverseCommandRegistry:yr,urlRegistry:To,cellPopoverRegistry:ds},yC={arg:va,toBoolean:$o,toJsDate:Wo,toNumber:Po,toString:Vo,toXC:qt,toZone:Bi,toCartesian:Gt,numberToLetters:$t,UuidGenerator:Vi,formatValue:mi,computeTextWidth:Pe,createEmptyWorkbookData:Nv,createEmptySheet:Ov,createEmptyExcelSheet:_v,getDefaultChartJsRuntime:Bs,chartFontColor:Is,ChartColors:xs,EvaluationError:c,CellErrorLevel:l,getFillingMode:Gs,rgbaToHex:Rt,colorToRGBA:Tt,positionToZone:lo,isDefined:it,lazy:rt},xC={isMarkdownLink:je,parseMarkdownLink:Ke,markdownLink:Ye,openLink:_o,urlRepresentation:No},IC={ChartPanel:Rg,ChartFigure:fr,ChartJsComponent:go,Grid:Ep,GridOverlay:sp,ScorecardChart:wo,LineConfigPanel:Eg,LineBarPieDesignPanel:vg,BarConfigPanel:dg,LineBarPieConfigPanel:hg,GaugeChartConfigPanel:Sg,GaugeChartDesignPanel:Cg,ScorecardChartConfigPanel:yg,ScorecardChartDesignPanel:xg,FigureComponent:Lg};e.AbstractChart=gs,e.CorePlugin=Dv,e.DATETIME_FORMAT=Y,e.DispatchResult=mn,e.EvaluationError=c,e.Model=class extends bb{constructor(e={},i={},o=[],n=new Vi,s=!0){super(),this.corePlugins=[],this.featurePlugins=[],this.statefulUIPlugins=[],this.coreViewsPlugins=[],this.isReplayingCommand=!1,this.renderers=[],this.status=0,this.handlers=[],this.coreHandlers=[],this.dispatch=(e,t)=>{const i={...t,type:e};let o=this.status;if(this.getters.isReadonly()&&(n=i,!un.has(n.type)))return new mn(67);var n;if(!this.session.canApplyOptimisticUpdate())return new mn(64);switch(o){case 0:const t=this.checkDispatchAllowed(i);if(!t.isSuccessful)return t;this.status=1;const{changes:o,commands:n}=this.state.recordChanges((()=>{pn(i)&&this.state.addCommand(i),this.dispatchToHandlers(this.handlers,i),this.finalize()}));this.session.save(n,o),this.status=0,this.trigger("update");break;case 1:if(pn(i)){const e=this.checkDispatchAllowed(i);if(!e.isSuccessful)return e;this.state.addCommand(i)}this.dispatchToHandlers(this.handlers,i);break;case 3:throw new Error("Cannot dispatch commands in the finalize state");case 2:if(pn(i))throw new Error(`A UI plugin cannot dispatch ${e} while handling a core command`);this.dispatchToHandlers(this.handlers,i)}return mn.Success},this.dispatchFromCorePlugin=(e,t)=>{const i={...t,type:e},o=this.status;this.status=2;const n=this.isReplayingCommand?[this.range,...this.corePlugins,...this.coreViewsPlugins]:this.handlers;return this.dispatchToHandlers(n,i),this.status=o,mn.Success},o=Av(e,o);const r=Rv(e,s);this.state=new _S,this.uuidGenerator=n,this.config=this.setupConfig(i),this.session=this.setupSession(r.revisionId),this.history=new MS(this.dispatchFromCorePlugin,this.session),this.coreGetters={},this.range=new Yv(this.coreGetters),this.coreGetters.getRangeString=this.range.getRangeString.bind(this.range),this.coreGetters.getRangeFromSheetXC=this.range.getRangeFromSheetXC.bind(this.range),this.coreGetters.createAdaptedRanges=this.range.createAdaptedRanges.bind(this.range),this.coreGetters.getRangeDataFromXc=this.range.getRangeDataFromXc.bind(this.range),this.coreGetters.getRangeDataFromZone=this.range.getRangeDataFromZone.bind(this.range),this.coreGetters.getRangeFromRangeData=this.range.getRangeFromRangeData.bind(this.range),this.coreGetters.getSelectionRangeString=this.range.getSelectionRangeString.bind(this.range),this.getters={isReadonly:()=>"readonly"===this.config.mode||"dashboard"===this.config.mode,isDashboard:()=>"dashboard"===this.config.mode,canUndo:this.history.canUndo.bind(this.history),canRedo:this.history.canRedo.bind(this.history),getClient:this.session.getClient.bind(this.session),getConnectedClients:this.session.getConnectedClients.bind(this.session),isFullySynchronized:this.session.isFullySynchronized.bind(this.session)},this.uuidGenerator.setIsFastStrategy(!0),this.selection=new NS(this.getters),this.coreHandlers.push(this.range),this.handlers.push(this.range),this.corePluginConfig=this.setupCorePluginConfig(),this.uiPluginConfig=this.setupUiPluginConfig();for(let e of Zb.getAll())this.setupCorePlugin(e,r);Object.assign(this.getters,this.coreGetters);for(let e of Xb.getAll()){const t=this.setupUiPlugin(e);this.statefulUIPlugins.push(t),this.handlers.push(t)}for(let e of Yb.getAll()){const t=this.setupUiPlugin(e);this.coreViewsPlugins.push(t),this.handlers.push(t),this.coreHandlers.push(t)}for(let e of jb.getAll()){const t=this.setupUiPlugin(e);this.featurePlugins.push(t),this.handlers.push(t)}this.uuidGenerator.setIsFastStrategy(!1),this.handlers.push(this.history),this.dispatch("START"),this.selection.observe(this,{handleEvent:()=>this.trigger("update")}),this.setupSessionEvents(),this.session.loadInitialMessages(o),this.joinSession(),i.snapshotRequested&&(this.session.snapshot(this.exportData()),this.garbageCollectExternalResources()),t.markRaw(this)}joinSession(){this.session.join(this.config.client)}leaveSession(){this.session.leave()}setupUiPlugin(e){const t=new e(this.uiPluginConfig);for(let i of e.getters){if(!(i in t))throw new Error(`Invalid getter name: ${i} for plugin ${t.constructor}`);if(i in this.getters)throw new Error(`Getter "${i}" is already defined.`);this.getters[i]=t[i].bind(t)}const i=e.layers.map((e=>[t,e]));return this.renderers.push(...i),this.renderers.sort(((e,t)=>e[1]-t[1])),t}setupCorePlugin(e,t){const i=new e(this.corePluginConfig);for(let t of e.getters){if(!(t in i))throw new Error(`Invalid getter name: ${t} for plugin ${i.constructor}`);if(t in this.coreGetters)throw new Error(`Getter "${t}" is already defined.`);this.coreGetters[t]=i[t].bind(i)}i.import(t),this.corePlugins.push(i),this.coreHandlers.push(i),this.handlers.push(i)}onRemoteRevisionReceived({commands:e}){for(let t of e){const e=this.status;this.status=2,this.dispatchToHandlers(this.statefulUIPlugins,t),this.status=e}this.finalize()}setupSession(e){return new Tb(TS(e,this.state.recordChanges.bind(this.state),(e=>{this.checkDispatchAllowed(e).isSuccessful&&(this.isReplayingCommand=!0,this.dispatchToHandlers([this.range,...this.corePlugins,...this.coreViewsPlugins],e),this.isReplayingCommand=!1)})),this.config.transportService,e)}setupSessionEvents(){this.session.on("remote-revision-received",this,this.onRemoteRevisionReceived),this.session.on("revision-redone",this,this.finalize),this.session.on("revision-undone",this,this.finalize),this.session.on("unexpected-revision-id",this,(()=>this.trigger("unexpected-revision-id"))),this.session.on("collaborative-event-received",this,(()=>{this.trigger("update")}))}setupConfig(e){const t=e.client||{id:this.uuidGenerator.uuidv4(),name:s("Anonymous").toString()},i=e.transportService||new bS;return{...e,mode:e.mode||"normal",custom:e.custom||{},external:e.external||{},transportService:i,client:t,moveClient:()=>{},snapshotRequested:!1,notifyUI:e=>this.trigger("notify-ui",e),lazyEvaluation:!("lazyEvaluation"in e)||e.lazyEvaluation}}setupCorePluginConfig(){return{getters:this.coreGetters,stateObserver:this.state,range:this.range,dispatch:this.dispatchFromCorePlugin,uuidGenerator:this.uuidGenerator,custom:this.config.custom,external:this.config.external}}setupUiPluginConfig(){return{getters:this.getters,stateObserver:this.state,dispatch:this.dispatch,selection:this.selection,moveClient:this.session.move.bind(this.session),custom:this.config.custom,uiActions:this.config,lazyEvaluation:this.config.lazyEvaluation}}checkDispatchAllowed(e){const t=this.handlers.map((t=>t.allowDispatch(e)));return t.some((e=>0!==e))?new mn(t.flat()):mn.Success}finalize(){this.status=3;for(const e of this.handlers)e.finalize();this.status=0}dispatchToHandlers(e,t){t=_e(t);for(const i of e)i.beforeHandle(t);for(const i of e)i.handle(t)}drawGrid(e){for(let[t,i]of this.renderers)e.ctx.save(),t.drawGrid(e,i),e.ctx.restore()}exportData(){let e=Nv();for(let t of this.handlers)t instanceof Dv&&t.export(e);return e.revisionId=this.session.getRevisionId()||Q,e=_e(e),e}updateMode(e){"normal"!==e&&this.dispatch("STOP_EDITION",{cancel:!0}),this.config.mode=e,this.trigger("update")}exportXLSX(){this.dispatch("EVALUATE_CELLS");let e={...Nv(),sheets:[_v(Iv,"Sheet1")]};for(let t of this.handlers)t instanceof Fv&&t.exportForExcel(e);return e=_e(e),vC(e)}garbageCollectExternalResources(){for(const e of this.corePlugins)e.garbageCollectExternalResources()}},e.Registry=Io,e.Revision=Ib,e.SPREADSHEET_DIMENSIONS=EC,e.Spreadsheet=vS,e.UIPlugin=Qv,e.__info__=CC,e.addFunction=function(e,t){tg.add(e,t)},e.astToFormula=of,e.compile=ff,e.components=IC,e.convertAstNodes=tf,e.coreTypes=gn,e.findCellInNewZone=ro,e.functionCache=mf,e.helpers=yC,e.invalidateEvaluationCommands=hn,e.links=xC,e.load=Rv,e.parse=Jm,e.readonlyAllowedCommands=un,e.registries=wC,e.setTranslationMethod=function(e){i=e},e.tokenize=_m,Object.defineProperty(e,"__esModule",{value:!0}),CC.version="16.2.26",CC.date="2024-01-04T16:19:52.806Z",CC.hash="ef51232"}(this.o_spreadsheet=this.o_spreadsheet||{},owl);
|