@omegagrid/bundle 0.6.1 → 0.6.3

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/omegagrid.js CHANGED
@@ -2157,7 +2157,7 @@
2157
2157
  .item:hover div.lvl {
2158
2158
  display: flex;
2159
2159
  }
2160
- `,Cf=ma({display:"block",position:"relative",top:"5px",left:"4px"}),Mf={[ff.Checked]:{value:"checked",color:null},[ff.CheckedByParent]:{value:"checked",color:"#555555"},[ff.None]:{value:"none",color:null},[ff.Unchecked]:{value:"unchecked",color:"#ff0000"}};class _f{get term(){return this._term}get hasFilter(){return""==this._term||null==this._term}constructor(t){this.model=t,this._term=null,this._property="value"}filter(t){this._term=t;const e=((t,e)=>{const i=new RegExp(`${ht(at(t))}`,"ig");let o;return t=>{const n=[];for(;o=i.exec(at((t[e]??"").toString()));)n.push([o.index,i.lastIndex]);return n}})(this._term,this._property);let i;this.model.nodes.forEach((o=>{o.collapsed=!1,o.htmlValue=null,t?(i=e(o),o.filterState=i.length>0?ln.Matched:ln.Filtered):(o.filterState=ln.Matched,o.collapse()),o.filterState==ln.Matched&&(o.walkUp((t=>{t.filterState==ln.Filtered&&(t.filterState=ln.ChildMatched)})),t&&(o.htmlValue=Kt(o.value,i)))})),this.model.indexVisibleNodes()}clear(){this._term=null,this.model.nodes.forEach((t=>{t.filterState=ln.Matched,t.collapsed=!1,t.htmlValue=null})),this.model.indexVisibleNodes()}}function*Sf(t,e){const i="function"==typeof e;if(void 0!==t){let o=-1;for(const n of t)o>-1&&(yield i?e(o):e),o++,yield n}}var Ef=function(t,e,i,o){var n,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(r<3?n(s):r>3?n(e,i,s):n(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s};class zf extends Event{constructor(t,e){super(t,{bubbles:!1,cancelable:!0,composed:!1}),Object.assign(this,e)}}class Lf extends PointerEvent{constructor(t,e,i){super(`tree.${t}`,e),Object.assign(this,i)}}class Rf extends DragEvent{constructor(t,e,i){super(`tree.${t}`,e),Object.assign(this,i)}}let If=class extends Qr{get size(){return this.model?.visibleNodes.length??0}get hasGlobalLevels(){return(this.options.selectMode==pf.Multiple||this.options.selectMode==pf.MultipleLevels)&&this.options.globalLevels&&this.model.maxLevel>0}constructor(){super(),this.options=wf(),this.selection=new vf(this.options),this.logger=new rn("Ωtree"),this.maxHeight=null,this.itemHeight=bf.LIST_ITEM_HEIGHT,this.disableAutoload=!1,this.loading=!1,this.noMatches=!1,this._onDragover=t=>{if(this.options.fileDrop&&(t.preventDefault(),t.stopPropagation(),"Files"==t.dataTransfer.types[0])){t.dataTransfer.dropEffect="move";const e=t.composedPath().find((t=>t.classList&&t.classList.contains("item")));this._onDragLeave(),e&&e.classList.add("drag"),this._lastDragItem=e}},this._onDrop=t=>{t.preventDefault(),this._onDragLeave();const e=t.composedPath().find((t=>t.classList&&t.classList.contains("item"))),i=this.model.nodes[parseInt(e.dataset.node)];this.dispatchEvent(new Rf("drop",t,{tree:this,node:i}))},this._onDragLeave=()=>{this._lastDragItem&&this._lastDragItem.classList.remove("drag"),this._lastDragItem=null},this.keyActions={ArrowRight:()=>{const t=this.model.visibleNodes[this.list.selectedIndex];t.collapsed&&(this.toggleNodeCollapse(t),this.model.indexVisibleNodes(),this.list.size=this.size)},ArrowLeft:()=>{const t=this.model.visibleNodes[this.list.selectedIndex];t.collapsed||(this.toggleNodeCollapse(t),this.model.indexVisibleNodes(),this.list.size=this.size)}},this._onGlobalLevelSelect=async t=>{this.toggleNode(this.model.root,t.level,!0),this.globalTreeLevels.requestUpdate(),this.requestUpdate(),await this.list.updateComplete,this.list.renderItems(!0)},this._onSearch=()=>{this.list.size=this.size,this.list.select(0),this.renderItems(!0),this.noMatches=0==this.size},this._onListRender=()=>{this.awaitFilter&&(this.filter(this.awaitFilter),this.awaitFilter=null)},this._onListMenu=t=>{this.dispatchEvent(new Lf("menu",t,{tree:this,node:this.model.visibleNodes[t.index]}))},this.addEventListener("dragover",this._onDragover),this.addEventListener("dragleave",this._onDragLeave),this.addEventListener("drop",this._onDrop)}destroy(){this.logger.info("destroy")}connectedCallback(){super.connectedCallback(),this.logger.info("init"),this.tabIndex=0}setSourceData(t,e=null){Object.assign(this.options,e??{}),this.model=new uf(t,this.options),t?.length>0&&void 0!==t[0].s&&this.selection.setItems(t.filter((t=>t.s)).map((t=>[t.k,0,1]))),this.dispatchEvent(new zf("load",{component:this}))}setValue(t){this.selection.populate(t)}async loadData(t){this.loading=!0,this.list&&(this.list.size=0),this.model=null,t=t??{};const[e,i]=await Promise.all([this.adapter.getTree(t),this.adapter.getOptions()]);this.setSourceData(e,i),i?.pageSize>0&&(this.updateNodeLoadState(this.model.root,this.model.root.children.length),this.model.indexVisibleNodes()),this.loading=!1}async loadMore(t){const e=t.children.length,i=await this.adapter.getTree({parent:t,parentKey:t.key,offset:e}),o=new uf(i,this.options);t.insertChildren(o.root.children,e),this.updateNodeLoadState(t,o.root.children.length),this.model.indexNodesByTree(!0),this.list.size=this.size,this.list.requestUpdate()}willUpdate(t){t.has("adapter")&&this.adapter&&(this.model=null,this.adapter.attach(this),this.disableAutoload||this.loadData()),this.model=this.model??new uf([],null),this.filtering=new _f(this.model),t.has("options")&&(this.options=wf(this.options),this.model.options=this.options,this.selection.options=this.options)}updated(t){t.has("model")&&this.list&&(this.list.size=this.size,this.list.requestUpdate())}async firstUpdated(){var t;this.value&&this.selection.setItems(this.value??[]),this.list.itemRenderer=(t=this,(e,i,o)=>{const n=t.model.visibleNodes[i];if(n.placeholder)return((t,e)=>{const i=e.parent,o=i.model.options;return e.element=t,Ir`
2160
+ `,Cf=ma({display:"block",position:"relative",top:"5px",left:"4px"}),Mf={[ff.Checked]:{value:"checked",color:null},[ff.CheckedByParent]:{value:"checked",color:"#555555"},[ff.None]:{value:"none",color:null},[ff.Unchecked]:{value:"unchecked",color:"#ff0000"}};class _f{get term(){return this._term}get hasFilter(){return""==this._term||null==this._term}constructor(t){this.model=t,this._term=null,this._property="value"}filter(t){this._term=t;const e=((t,e)=>{const i=new RegExp(`${ht(at(t))}`,"ig");let o;return t=>{const n=[];for(;o=i.exec(at((t[e]??"").toString()));)n.push([o.index,i.lastIndex]);return n}})(this._term,this._property);let i;this.model.nodes.forEach((o=>{o.collapsed=!1,o.htmlValue=null,t?(i=e(o),o.filterState=i.length>0?ln.Matched:ln.Filtered):(o.filterState=ln.Matched,o.collapse()),o.filterState==ln.Matched&&(o.walkUp((t=>{t.filterState==ln.Filtered&&(t.filterState=ln.ChildMatched)})),t&&(o.htmlValue=Kt(o.value,i)))})),this.model.indexVisibleNodes()}clear(){this._term=null,this.model.nodes.forEach((t=>{t.filterState=ln.Matched,t.collapsed=!1,t.htmlValue=null})),this.model.indexVisibleNodes()}}function*Sf(t,e){const i="function"==typeof e;if(void 0!==t){let o=-1;for(const n of t)o>-1&&(yield i?e(o):e),o++,yield n}}var Ef=function(t,e,i,o){var n,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(r<3?n(s):r>3?n(e,i,s):n(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s};class zf extends Event{constructor(t,e){super(t,{bubbles:!1,cancelable:!0,composed:!1}),Object.assign(this,e)}}class Lf extends PointerEvent{constructor(t,e,i){super(`tree.${t}`,e),Object.assign(this,i)}}class Rf extends DragEvent{constructor(t,e,i){super(`tree.${t}`,e),Object.assign(this,i)}}let If=class extends Qr{get size(){return this.model?.visibleNodes.length??0}get hasGlobalLevels(){return(this.options.selectMode==pf.Multiple||this.options.selectMode==pf.MultipleLevels)&&this.options.globalLevels&&this.model.maxLevel>0}constructor(){super(),this.options=wf(),this.selection=new vf(this.options),this.logger=new rn("Ωtree"),this.maxHeight=null,this.itemHeight=bf.LIST_ITEM_HEIGHT,this.disableAutoload=!1,this.loading=!1,this.noMatches=!1,this._onDragover=t=>{if(this.options.fileDrop&&(t.preventDefault(),t.stopPropagation(),"Files"==t.dataTransfer.types[0])){t.dataTransfer.dropEffect="move";const e=t.composedPath().find((t=>t.classList&&t.classList.contains("item")));this._onDragLeave(),e&&e.classList.add("drag"),this._lastDragItem=e}},this._onDrop=t=>{t.preventDefault(),this._onDragLeave();const e=t.composedPath().find((t=>t.classList&&t.classList.contains("item"))),i=this.model.nodes[parseInt(e.dataset.node)];this.dispatchEvent(new Rf("drop",t,{tree:this,node:i}))},this._onDragLeave=()=>{this._lastDragItem&&this._lastDragItem.classList.remove("drag"),this._lastDragItem=null},this.keyActions={ArrowRight:()=>{const t=this.model.visibleNodes[this.list.selectedIndex];t.collapsed&&(this.toggleNodeCollapse(t),this.model.indexVisibleNodes(),this.list.size=this.size)},ArrowLeft:()=>{const t=this.model.visibleNodes[this.list.selectedIndex];t.collapsed||(this.toggleNodeCollapse(t),this.model.indexVisibleNodes(),this.list.size=this.size)}},this._onGlobalLevelSelect=async t=>{this.toggleNode(this.model.root,t.level,!0),this.globalTreeLevels.requestUpdate(),this.requestUpdate(),await this.list.updateComplete,this.list.renderItems(!0)},this._onSearch=()=>{this.list.size=this.size,this.list.select(0),this.renderItems(!0),this.noMatches=0==this.size},this._onListRender=()=>{this.awaitFilter&&(this.filter(this.awaitFilter),this.awaitFilter=null)},this._onListMenu=t=>{this.dispatchEvent(new Lf("menu",t,{tree:this,node:this.model.visibleNodes[t.index]}))},this.addEventListener("dragover",this._onDragover),this.addEventListener("dragleave",this._onDragLeave),this.addEventListener("drop",this._onDrop)}destroy(){this.logger.info("destroy")}connectedCallback(){super.connectedCallback(),this.logger.info("init"),this.tabIndex=0}setSourceData(t,e=null){Object.assign(this.options,e??{}),this.model=new uf(t,this.options),t?.length>0&&void 0!==t[0].s&&this.selection.setItems(t.filter((t=>t.s)).map((t=>[t.k,0,1]))),this.dispatchEvent(new zf("load",{component:this}))}setValue(t){this.selection.populate(t)}async loadData(t){this.loading=!0,this.list&&(this.list.size=0),this.model=null,t=t??{};const[e,i]=await Promise.all([this.adapter.getTree(t),this.adapter.getOptions()]);this.setSourceData(e,i),i?.pageSize>0&&(this.updateNodeLoadState(this.model.root,this.model.root.children.length),this.model.indexVisibleNodes()),this.loading=!1}async loadMore(t){const e=t.children.length,i=await this.adapter.getTree({parent:t,parentKey:t.key,offset:e}),o=new uf(i,this.options);t.insertChildren(o.root.children,e),this.updateNodeLoadState(t,o.root.children.length),this.model.indexNodesByTree(!0),this.list.size=this.size,this.list.requestUpdate()}willUpdate(t){t.has("adapter")&&this.adapter&&(this.model=null,this.adapter.attach(this),this.disableAutoload||this.loadData()),this.model=this.model??new uf([],null),this.filtering=new _f(this.model),t.has("options")&&(this.options=wf(this.options),this.model.options=this.options,this.selection.options=this.options)}updated(t){t.has("model")&&this.list&&(this.list.size=this.size,this.noMatches=this.noMatches&&0==this.size,this.list.requestUpdate())}async firstUpdated(){var t;this.value&&this.selection.setItems(this.value??[]),this.list.itemRenderer=(t=this,(e,i,o)=>{const n=t.model.visibleNodes[i];if(n.placeholder)return((t,e)=>{const i=e.parent,o=i.model.options;return e.element=t,Ir`
2161
2161
  <div
2162
2162
  class="placeholder"
2163
2163
  style="${ma({paddingLeft:(i.level+1)*o.levelIndent+5+"px"})}">
@@ -2227,13 +2227,13 @@
2227
2227
  `:null,this.hasGlobalLevels&&!this.noMatches?Ir`
2228
2228
  <div class="toolbar">
2229
2229
  <og-tree-levels
2230
- id="globalLevels"
2230
+ id="globalLevels"
2231
2231
  count="${(this.options.maxLevel??this.model.maxLevel)+1}"
2232
2232
  .selection="${this.selection.getLevelSelection(this.model.root)}"
2233
2233
  @levelselect="${this._onGlobalLevelSelect}">
2234
2234
  </og-tree-levels>
2235
2235
  </div>
2236
- `:null,e,t],(()=>" "))}renderItems(t=!1){this.list&&(this.list.size=this.size,this.list.renderItems(t))}clearSelection(){this.selection.clear(),this.requestUpdate()}async filter(t){this.loading?this.awaitFilter=t:this.options.customSearch&&this.adapter?await this.loadData({filter:t}):(null==t?(this.filtering?.clear(),this.noMatches=!1):(this.filtering?.filter(t),this.noMatches=0==this.size),this.list.size=this.size,this.list.select(0),this.list.requestUpdate())}async clearFilter(){await this.filter()}};If.styles=[xf],Ef([is({type:Object})],If.prototype,"model",void 0),Ef([is({type:Object})],If.prototype,"adapter",void 0),Ef([is({type:Object})],If.prototype,"options",void 0),Ef([is({type:Object})],If.prototype,"selection",void 0),Ef([is({type:Object})],If.prototype,"logger",void 0),Ef([is({type:Number})],If.prototype,"maxHeight",void 0),Ef([is({type:Number})],If.prototype,"itemHeight",void 0),Ef([is({type:Array})],If.prototype,"value",void 0),Ef([is({type:Boolean})],If.prototype,"disableAutoload",void 0),Ef([rs("og-list")],If.prototype,"list",void 0),Ef([rs("og-tree-search")],If.prototype,"searchBar",void 0),Ef([rs("#globalLevels")],If.prototype,"globalTreeLevels",void 0),Ef([os()],If.prototype,"loading",void 0),Ef([os()],If.prototype,"noMatches",void 0),If=Ef([Jr("og-tree")],If);class Hf extends wu{getOptions(){return null}}const Tf=Gn`
2236
+ `:null,e,t],(()=>" "))}highlightFirstSelectedNode(){if(!this.list)return;if(!this.selection?.count)return;const t=this.selection.items.keys().next().value,e=this.model.nodeMap.get(t);e?(this.list.selectedIndex=e.index,this.list.scrollToIndex(e.index)):this.list.selectedIndex=-1}renderItems(t=!1){this.list&&(this.list.size=this.size,this.list.renderItems(t))}clearSelection(){this.selection.clear(),this.requestUpdate()}async filter(t){this.loading?this.awaitFilter=t:this.options.customSearch&&this.adapter?await this.loadData({filter:t}):(null==t?(this.filtering?.clear(),this.noMatches=!1):(this.filtering?.filter(t),this.noMatches=0==this.size),this.list.size=this.size,this.list.select(0),this.list.requestUpdate())}async clearFilter(){await this.filter()}};If.styles=[xf],Ef([is({type:Object})],If.prototype,"model",void 0),Ef([is({type:Object})],If.prototype,"adapter",void 0),Ef([is({type:Object})],If.prototype,"options",void 0),Ef([is({type:Object})],If.prototype,"selection",void 0),Ef([is({type:Object})],If.prototype,"logger",void 0),Ef([is({type:Number})],If.prototype,"maxHeight",void 0),Ef([is({type:Number})],If.prototype,"itemHeight",void 0),Ef([is({type:Array})],If.prototype,"value",void 0),Ef([is({type:Boolean})],If.prototype,"disableAutoload",void 0),Ef([rs("og-list")],If.prototype,"list",void 0),Ef([rs("og-tree-search")],If.prototype,"searchBar",void 0),Ef([rs("#globalLevels")],If.prototype,"globalTreeLevels",void 0),Ef([os()],If.prototype,"loading",void 0),Ef([os()],If.prototype,"noMatches",void 0),If=Ef([Jr("og-tree")],If);class Hf extends wu{getOptions(){return null}}const Tf=Gn`
2237
2237
  og-input {
2238
2238
  flex: 1;
2239
2239
  border: 1px solid var(--og-accent-color);
@@ -2263,7 +2263,7 @@
2263
2263
  #content {
2264
2264
  display: flex;
2265
2265
  }
2266
- `;var Af=function(t,e,i,o){var n,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(r<3?n(s):r>3?n(e,i,s):n(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s};let Of=class extends gd{get hasCrossButton(){return this.cross&&(this.selection.count>0&&this.options.allowEmpty||""!==this.searchTerm)}get tree(){return this._tree||(this._tree=new If,this._tree.disableAutoload=!0,this._tree.model=this.adapter?null:this.model,this._tree.adapter=this.adapter,this._tree.selection=this.selection,this._tree.options=this.options,this._tree.maxHeight=this.maxHeight,this._tree.addEventListener("change",(t=>this._onChange(t))),this._tree.addEventListener("render",this._onTreeRender),this._tree.slot="inner-content"),this._tree}_onChange(t){this.selectedItems=null,this.selectedItems=t.component.selection.items,this.value=t.component.selection.serialize(),this.options.autoClose&&this.close(),this.dispatchEvent(new zf(t.type,{component:t.component,node:t.node}))}async open(){this.tree.parentElement!=this.dropdown&&this.dropdown.appendChild(this._tree),await super.open()}async willUpdate(t){this.buttonInput&&(this.options.search=!1),t.has("value")&&(this.selection.setItems(this.value),this.selectedItems=null,this.selectedItems=this.selection.items,this.tree.renderItems(!0)),this._tree&&(t.has("adapter")&&(this._tree.adapter=this.adapter),t.has("model")&&(this._tree.model=this.model)),t.has("adapter")&&this.adapter&&(this._firstOpen=!0,this.options=wf(await this.adapter.getOptions(),this.options)),this._renderDropdown=!0}async filter(t){this.input&&(this.searchTerm=t),await this.updateComplete,this.input&&(this.input.value=t),await this.tree.updateComplete,this.tree.filter(t)}async clearFilter(){this.input&&(this.searchTerm=""),await this.updateComplete,this.input&&(this.input.value=""),await this.tree.updateComplete,this.tree.clearFilter()}focus(){this.buttonInput?this.input?.focus():super.focus()}constructor(){super(),this.options=wf(),this.selection=new vf(this.options),this.maxHeight=300,this.maxWidth=400,this.cross=!1,this.buttonInput=!1,this.preventInputEnter=!1,this.dynamicWidth=!1,this.selectedItems=new Map,this.searchTerm="",this._renderDropdown=!0,this._firstOpen=!0,this._onTreeRender=()=>{this.dropdown&&(Nt(this.dropdown),this.dynamicWidth&&this.adjustWidth())},this.tooltip=gt("og-tooltip"),this._onMouseOver=()=>{this.contentDiv&&this.contentDiv.scrollWidth>this.contentDiv.clientWidth&&(this.tooltip.parentElement||(document.body.appendChild(this.tooltip),this.tooltip.style.maxWidth="200px"),this.tooltip.content=this.getButtonContentHtml(),this.tooltip.attachTo(this.button,"bottom"))},this._onMouseOut=()=>{this.tooltip.deatach()},this._debounceFilter=U((t=>this.tree.filter(t))),this._onInput=async t=>{this.isOpen||await this.open();const e=t.target.value;this._debounceFilter(e),this.searchTerm=e},this._onInputKeyDown=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.tree.list.moveDown();break;case"ArrowUp":t.preventDefault(),this.tree.list.moveUp();break;case"Enter":if(t.preventDefault(),this.preventInputEnter)return;this.tree.list.select(this.tree.list.selectedIndex,qd.Enter),setTimeout((()=>this.input.focus()),100)}},this._onInputBlur=()=>this.input.value=this.getSelectionText(),this.render=()=>Ir`
2266
+ `;var Af=function(t,e,i,o){var n,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(r<3?n(s):r>3?n(e,i,s):n(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s};let Of=class extends gd{get hasCrossButton(){return this.cross&&(this.selection.count>0&&this.options.allowEmpty||""!==this.searchTerm)}get tree(){return this._tree||(this._tree=new If,this._tree.disableAutoload=!0,this._tree.model=this.adapter?null:this.model,this._tree.adapter=this.adapter,this._tree.selection=this.selection,this._tree.options=this.options,this._tree.maxHeight=this.maxHeight,this._tree.addEventListener("change",(t=>this._onChange(t))),this._tree.addEventListener("render",this._onTreeRender),this._tree.slot="inner-content"),this._tree}_onChange(t){this.selectedItems=null,this.selectedItems=t.component.selection.items,this.value=t.component.selection.serialize(),this.options.autoClose&&this.close(),this.dispatchEvent(new zf(t.type,{component:t.component,node:t.node}))}async open(){this.tree.parentElement!=this.dropdown&&this.dropdown.appendChild(this._tree),await super.open()}async willUpdate(t){this.buttonInput&&(this.options.search=!1),t.has("value")&&(this.selection.setItems(this.value),this.selectedItems=null,this.selectedItems=this.selection.items,this.tree.highlightFirstSelectedNode(),this.tree.renderItems(!0)),this._tree&&(t.has("adapter")&&(this._tree.adapter=this.adapter),t.has("model")&&(this._tree.model=this.model)),t.has("adapter")&&this.adapter&&(this._firstOpen=!0,this.options=wf(await this.adapter.getOptions(),this.options)),this._renderDropdown=!0}async filter(t){this.input&&(this.searchTerm=t),await this.updateComplete,this.input&&(this.input.value=t),await this.tree.updateComplete,this.tree.filter(t)}async clearFilter(){this.input&&(this.searchTerm=""),await this.updateComplete,this.input&&(this.input.value=""),await this.tree.updateComplete,this.tree.clearFilter()}focus(){this.buttonInput?this.input?.focus():super.focus()}constructor(){super(),this.options=wf(),this.selection=new vf(this.options),this.maxHeight=300,this.maxWidth=400,this.cross=!1,this.buttonInput=!1,this.preventInputEnter=!1,this.dynamicWidth=!1,this.selectedItems=new Map,this.searchTerm="",this._renderDropdown=!0,this._firstOpen=!0,this._onTreeRender=()=>{this.dropdown&&(Nt(this.dropdown),this.dynamicWidth&&this.adjustWidth())},this.tooltip=gt("og-tooltip"),this._onMouseOver=()=>{this.contentDiv&&this.contentDiv.scrollWidth>this.contentDiv.clientWidth&&(this.tooltip.parentElement||(document.body.appendChild(this.tooltip),this.tooltip.style.maxWidth="200px"),this.tooltip.content=this.getButtonContentHtml(),this.tooltip.attachTo(this.button,"bottom"))},this._onMouseOut=()=>{this.tooltip.deatach()},this._debounceFilter=U((t=>this.tree.filter(t))),this._onInput=async t=>{this.isOpen||await this.open();const e=t.target.value;this._debounceFilter(e),this.searchTerm=e},this._onInputKeyDown=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.tree.list.moveDown();break;case"ArrowUp":t.preventDefault(),this.tree.list.moveUp();break;case"Enter":if(t.preventDefault(),this.preventInputEnter)return;this.tree.list.selectedIndex>-1&&(this.tree.list.select(this.tree.list.selectedIndex,qd.Enter),setTimeout((()=>this.input.focus()),100))}},this._onInputBlur=()=>this.input.value=this.getSelectionText(),this.render=()=>Ir`
2267
2267
  ${this.buttonInput?Ir`
2268
2268
  <og-input
2269
2269
  @input="${this._onInput}"
@@ -2648,7 +2648,7 @@
2648
2648
  padding-right: 2px;
2649
2649
  }
2650
2650
 
2651
- `,Rm={enabled:!1,includeChildren:!0,includeParents:!0},Im={enabled:!0,reversed:!1},Hm={ROW_HEIGHT:22,RESIZE_TRESHOLD:10,ROW_HEADER_WIDTH:60,SLIDER_SIZE:12,EXPANDER_SIZE:13,MAX_CACHE_ITEMS:5e3,CACHE_CLEAN_INTERVAL:30,COMMENT_HIDE_TIMEOUT:1e3,SELECTOR_BORDER_WIDTH:2,MIN_ROW_HEIGHT:5,MIN_COL_WIDTH:5,SPARKLINE_GAP:4,AUTOSCROLL_TRESHOLD:100,AUTOSCROLL_RATIO:1.1,AUTOSCROLL_INTERVAL:100,DEFAULT_SPARKLINE_OPTIONS:{minValue:"auto",maxValue:"auto",type:"line",style:{color:"0094FF",weight:1},marker:{color:"ff0000"}},DEFAULT_OPTIONS:{rows:100,columns:20,readOnly:!1,rowNumbers:!0,rowPriority:2,rowTree:{enabled:!0},columnTree:{enabled:!0},colLetters:!0,emptyPlaceholder:!0,freezeTop:0,fontSize:12,rowHeight:22,rowResize:!0,columnWidth:100,columnResize:!0,columnPriority:1,freezeLeft:0,freezeRight:0,freezeBottom:0,maxSortingColumns:3,numberFormat:null,levelIndentFactor:2,cellIndentFactor:10,emptyClickable:!1,grid:!0,autofill:!0,undoRedo:!0,commandWindow:!0,cellCache:!0,singleCellModel:!1,editing:{rowInsertion:!0,rowDeletion:!0,colInsertion:!0,colDeletion:!0,rowOutline:!0,colOutline:!0},comments:{hideTimeout:1e3,offsetX:30,offsetY:-30,zIndex:500,headerPosition:"top"},scrolling:{verticalOverscroll:!0,horizontalOverscroll:!0,scrollbarVisibilityTreshold:100},selecting:{enabled:!0,multiSelect:!0},events:{click:{mouseMoveTreshold:10}}},...W},Tm=/^(?!.*[\\\/\*\[\]\:\?"])(.{1,31})$/;function Am(t){return Tm.test(t)}function Om(t){return["\\","/","*","[","]",":","?",'"'].forEach((e=>t=t.replace(new RegExp(`\\${e}`,"g"),""))),t}function $m(t,e){return!isNaN(t)&&null!=t||!isNaN(e)&&null!=e||(t=null==t?"":at(t.toString()).toLowerCase(),e=null==e?"":at(e.toString()).toLowerCase()),t>e?1:t<e?-1:0}function Dm(t,e){const i=Z(e);return Z(t)?(t=t.toString().trim()).startsWith("=")?0==$m(e,i?t.substring(1):parseFloat(t.substring(1))):t.startsWith(">=")?$m(e,i?t.substring(2):parseFloat(t.substring(2)))>=0:t.startsWith("<=")?$m(e,i?t.substring(2):parseFloat(t.substring(2)))<=0:t.startsWith(">")?$m(e,i?t.substring(1):parseFloat(t.substring(1)))>0:t.startsWith("<")?$m(e,i?t.substring(1):parseFloat(t.substring(1)))<0:0==$m(e,i?t:isNaN(t)?t||"":parseFloat(t)):e==t}const Nm=new Map([["=",["==",1,0]],[">",[">",1,0]],["<",["<",1,0]],[">=",[">=",1,0]],["<=",["<=",1,0]],["+",["+",2,0]],["-",["-",2,0]],["*",["*",3,0]],["/",["/",3,0]]]),Pm=t=>["=",">","<",">=","<="].includes(t),jm=t=>["+","-","*","/"].includes(t),Vm=t=>jm(t)||Pm(t);function Bm(t,e,i){switch(i){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":return t/e;case"=":return 0==$m(t,e);case">":return $m(t,e)>0;case"<":return $m(t,e)<0;case">=":return $m(t,e)>=0;case"<=":return $m(t,e)<=0;default:throw new Error(`Invalid operator: ${i}`)}}function Fm(t,e,i){const o=Array.isArray(t),n=Array.isArray(e);if(!o&&!n)return[[Bm(t,e,i)]];const r=Math.max(o?t.length:0,n?e.length:0),s=Math.max(o?t[0].length:0,n?e[0].length:0),a=[];for(let l=0;l<r;l++){const r=[];for(let a=0;a<s;a++){const s=o?t[l]?.[a]:t,c=n?e[l]?.[a]:e,h=null==s&&null==c?null:Bm(s,c,i);r.push(h)}a.push(r)}return a}var Wm;!function(t){t[t.Number=0]="Number",t[t.Boolean=1]="Boolean",t[t.String=2]="String",t[t.StringQuote=3]="StringQuote",t[t.Function=4]="Function",t[t.ArgumentSeparator=5]="ArgumentSeparator",t[t.OpenBracket=6]="OpenBracket",t[t.CloseBracket=7]="CloseBracket",t[t.Operator=8]="Operator",t[t.Cell=9]="Cell",t[t.Variable=10]="Variable",t[t.Range=11]="Range",t[t.Sheet=12]="Sheet",t[t.SheetQuote=13]="SheetQuote",t[t.SheetSeparator=14]="SheetSeparator",t[t.Unknown=15]="Unknown",t[t.Operand=16]="Operand"}(Wm||(Wm={}));const Um=t=>t===Wm.Number||t===Wm.Boolean||t===Wm.String||t===Wm.Cell||t===Wm.Variable||t===Wm.Range,Gm=t=>t>=48&&t<=57,qm=t=>"true"===(t=t.toLowerCase())||"false"===t,Ym=t=>t>=65&&t<=90||t>=97&&t<=122||t>=192&&t<=687,Zm={decimalPoint:".",stringQuote:'"',sheetQuote:"'",argumentSeparator:","};class Xm{constructor(t){this.options=Object.assign(Zm,t)}tokenize(t){const e=[],i=t.length;let o,n,r,s,a=0,l="",c=!1,h=!1,d=!1;for(;a<i;){if(o=t.charAt(a),n=o.charCodeAt(0),"="==o&&0==a)++a;else if(Gm(n)){for(l=(d?"-":"")+o,++a;a<i;)if(o=t.charAt(a),n=o.charCodeAt(0),Gm(n))l+=o,++a;else{if(o!==this.options.decimalPoint)break;l+=".",++a}d=!1,e.push([l,Wm.Number])}else if(Ym(n)||"$"==o){l=o,r=null,++a;do{if(o=t.charAt(a),n=o.charCodeAt(0),Ym(n)||Gm(n)||"."===o||"$"===o||"_"===o)"_"==o?r=Wm.Variable:Gm(n)&&!c&&null==r&&(r=Wm.Cell),l+=o,++a,a==i&&e.push([l,r||Wm.Variable]);else{if("("==o){e.push([l.toUpperCase(),Wm.Function]),e.push([o,Wm.OpenBracket]),++a;break}if("'"==o)e.push([l,Wm.Sheet]),l="",e.push([o,Wm.SheetQuote]),c=!0,++a;else if(":"==o)r=Wm.Range,l+=o,++a;else{if(!c||" "!=o){if("!"==o){""!==l&&e.push([l,Wm.Sheet]),e.push([o,Wm.SheetSeparator]),c=!1,l="",++a;break}e.push([l,r||(qm(l)?Wm.Boolean:Wm.Variable)]);break}l+=o,++a}}}while(a<i)}else if(Vm(o)){if("-"===o&&Gm(t.charCodeAt(a+1))&&(null==s||"("==s[0]||Pm(s[0])||s[1]==Wm.ArgumentSeparator))d=!0;else{for(l=o;Pm(t.charAt(a+1));)l+=t.charAt(++a);e.push([l,Wm.Operator])}++a}else if("("===o)e.push([o,Wm.OpenBracket]),++a;else if(")"===o)e.push([o,Wm.CloseBracket]),++a;else if("'"===o)e.push([o,Wm.SheetQuote]),c=!0,++a;else if(o===this.options.argumentSeparator)e.push([o,Wm.ArgumentSeparator]),++a;else if(o===this.options.stringQuote){for(h=!1,e.push([o,Wm.StringQuote]),l="";++a<i;){if(o=t.charAt(a),o===this.options.stringQuote){h=!0,++a;break}l+=o}e.push([l,Wm.String]),h&&e.push([this.options.stringQuote,Wm.StringQuote])}else e.push([o,Wm.Unknown]),++a;s=e[e.length-1]}return e}}function Qm(t,e,i=null,o=!0){return t+=e,0==e?t:t>=0?i?o?t%i:Math.min(t,i-1):t:o&&i?i+t%i:Math.max(t,0)}const Km=/(?:'?([\w\s]*)'?!)?(\$?)([a-z]*)(\$?)(\d*)(?::(\$?)([a-z]*)(\$?)(\d*))?/i;class Jm{constructor(t,e,i,o,n){this.setCoords(t,e,i,o),this.sheet=n}setCoords(t,e,i,o){this.c1=null==t&&null==i?0:t,this.r1=null==e&&null==o?0:e,this.c2=null==o&&null!=t||null!=i?null==i?t:i:1/0,this.r2=null==i&&null!=e||null!=o?null==o?e:o:1/0,this.normalize()}get size(){return{columns:this.c2-this.c1+1,rows:this.r2-this.r1+1}}get count(){const{columns:t,rows:e}=this.size;return t*e}normalize(){const[t,e]=[Math.min(this.c1,this.c2),Math.max(this.c1,this.c2)],[i,o]=[Math.min(this.r1,this.r2),Math.max(this.r1,this.r2)];return this.c1=t,this.c2=e,this.r1=i,this.r2=o,this}move(t,e,i=null,o=null,n=!0){const r=Qm(this.c1,t,i,n);n&&(e+=this.c1+t!=r&&0!=t?t>0?1:-1:0),this.c1=r,this.r1=Qm(this.r1,e,o,n),this.c2=Qm(this.c2,t,i,n),this.r2=Qm(this.r2,e,o,n)}contains(t){return t.c1>=this.c1&&t.c2<=this.c2&&t.r1>=this.r1&&t.r2<=this.r2}containsColumn(t){return this.c1<=t&&this.c2>=t}containsRow(t){return this.r1<=t&&this.r2>=t}removeAnchors(){return this.c1Anchor=!1,this.c2Anchor=!1,this.r1Anchor=!1,this.r2Anchor=!1,this}addAnchors(){return this.c1Anchor=!0,this.c2Anchor=!0,this.r1Anchor=!0,this.r2Anchor=!0,this}shiftLeft(t,e=1,i=null,o=!1){return t<=this.c1&&(o||!this.c1Anchor)&&(null==i||this.c1<=i)&&(this.c1-=e),t<=this.c2&&(o||!this.c2Anchor)&&(null==i||this.c2<=i)&&(this.c2-=e),this}shiftRight(t,e=1,i=null,o=!1){return t<=this.c1&&(o||!this.c1Anchor)&&(null==i||this.c1<=i)&&(this.c1+=e),t<=this.c2&&(o||!this.c2Anchor)&&(null==i||this.c2<=i)&&(this.c2+=e),this}shiftUp(t,e=1,i=null,o=!1){return t<=this.r1&&(o||!this.r1Anchor)&&(null==i||this.r1<=i)&&(this.r1-=e),t<=this.r2&&(o||!this.r2Anchor)&&(null==i||this.r2<=i)&&(this.r2-=e),this}shiftDown(t,e=1,i=null,o=!1){return t<=this.r1&&(o||!this.r1Anchor)&&(null==i||this.r1<=i)&&(this.r1+=e),t<=this.r2&&(o||!this.r2Anchor)&&(null==i||this.r2<=i)&&(this.r2+=e),this}shift(t){const{index:e,offset:i,direction:o,maxIndex:n,ignoreAnchors:r}=t;switch(o){case"down":return this.shiftDown(e,i,n,r);case"up":return this.shiftUp(e,i,n,r);case"left":return this.shiftLeft(e,i,n,r);case"right":return this.shiftRight(e,i,n,r)}}intersect(t){this.normalize(),t.normalize();const e=Math.max(t.c1,this.c1),i=Math.min(t.c2,this.c2),o=Math.max(t.r1,this.r1),n=Math.min(t.r2,this.r2);return e<=i&&o<=n?new Jm(e,o,i,n,this.sheet):null}unite(t){return this.normalize(),t.normalize(),new Jm(Math.min(this.c1,t.c1),Math.min(this.r1,t.r1),Math.max(this.c2,t.c2),Math.max(this.r2,t.r2),this.sheet)}clone(){const t=new Jm(this.c1,this.r1,this.c2,this.r2,this.sheet);return t.c1Anchor=this.c1Anchor,t.r1Anchor=this.r1Anchor,t.c2Anchor=this.c2Anchor,t.r2Anchor=this.r2Anchor,t}equals(t,e=!1){return t.c1==this.c1&&t.r1==this.r1&&t.c2==this.c2&&t.r2==this.r2&&(0==e||t.c1Anchor==this.c1Anchor&&t.r1Anchor==this.r1Anchor&&t.c2Anchor==this.c2Anchor&&t.r2Anchor==this.r2Anchor)}get isCell(){return this.c2==this.c2&&this.r2==this.r1}get isRange(){return this.c2!=this.c1||this.r2!=this.r1}get isColumn(){return 0==this.r1&&this.r2==1/0}get isRow(){return 0==this.c1&&this.c2==1/0}get A1(){const t=this.isRange,e=(this.c1Anchor?"$":"")+(0!==this.c1||this.c2!==1/0?iv(this.c1):"")+(0===this.r1&&this.r2===1/0?"":(this.r1Anchor?"$":"")+tv(this.r1)),i=t?(this.c2Anchor?"$":"")+(!isNaN(this.c2)&&this.c2<1/0?iv(this.c2):"")+(this.r2Anchor?"$":"")+(!isNaN(this.r2)&&this.r2<1/0?tv(this.r2):""):e;return(null==this.sheet?"":((o=this.sheet).indexOf(" ")>-1?"'"+o+"'":o)+"!")+(e==i?e:e+":"+i);var o}get bounds(){return[[new Jm(this.c1,this.r1),this.c2<1/0?new Jm(this.c2,this.r1):null],[this.r2<1/0?new Jm(this.c1,this.r2):null,this.r2<1/0&&this.c2<1/0?new Jm(this.c2,this.r2):null]]}*cells(){for(let t=this.r1;t<=this.r2;t++)for(let e=this.c1;e<=this.c2;e++)yield new Jm(e,t)}static fromA1(t){const e=Km.exec(t),i=new Jm(e[3]?ov(e[3]):null,e[5]?ev(e[5]):null,e[7]?ov(e[7]):null,e[9]?ev(e[9]):null,e[1]||null);return!e[2]&&e[3]||(i.c1Anchor=!0),!e[4]&&e[5]||(i.r1Anchor=!0),(e[6]||e[2]&&!e[7])&&(i.c2Anchor=!0),(e[8]||e[4]&&!e[9])&&(i.r2Anchor=!0),i}}function tv(t){return(t+1).toString()}function ev(t){return parseInt(t)-1}function iv(t){++t;let e,i="";for(;t>0;)e=(t-1)%26,i=String.fromCharCode(e+65)+i,t=(t-e-1)/26;return i}function ov(t){const e=t.length;let i=0;for(let o=0;o<e;o++)i+=(t.charCodeAt(o)-64)*Math.pow(26,e-o-1);return i-1}function nv(t){return t.sort(((t,e)=>{const i=Math.min(t.r1,t.r2),o=Math.min(e.r1,e.r2),n=Math.min(t.c1,t.c2),r=Math.min(e.c1,e.c2);return i<o?-1:i>o?1:n<r?-1:r>n?1:0}))}function rv(t){return t.formula.cells.map((e=>t.cell.model.getCellByRange(e[1])))}function sv(t){let e=t;for(;Array.isArray(e);)e=e.length>0?e[0]:null;return e}function av(t){return Array.isArray(t)?t:[[t]]}function lv(t,e,i,o){if(!Array.isArray(t))return e(t,i,o);for(let o=0;o<t.length;o++)if(!1===lv(t[o],e,null==i?o:i,null==i?void 0:o))return!1}Jm.fromA1s=(t,e=";")=>t.split(e).map((t=>Jm.fromA1(t))),Jm.toA1s=(t,e=";")=>t.map((t=>t.A1)).join(e),Jm.fromCoords=t=>new Jm(t.c1,t.r1,t.c2,t.r2),Jm.fullColumn=t=>new Jm(t,0,t,1/0),Jm.fullRow=t=>new Jm(0,t,1/0,t);const cv=new Set(["SUMPRODUCT","FILTER"]),hv=t=>cv.has(t),dv=t=>!!(t&&t.length>0&&"="==t.charAt(0)),uv=t=>dv(t)?t:"="+(t??""),pv=t=>dv(t)?t.substring(1):t,gv=["#5B97FF","#FF616B","#B77CFF","#00B02C","#FC58BE","#FF9000","#2EB0B3"],fv=t=>gv[t%gv.length],mv=new Map([["FORMULATEXT","_xlfn."],["CONCAT","_xlfn."],["INDIRECT","_xlfn."],["ISOWEEKNUM","_xlfn."],["SWITCH","_xlfn."],["XOR","_xlfn."]]);class vv{get fn(){return this._fn??(this._fn=new Function("t","ctx","return "+this.compile()))}get tokens(){return this._tokens}get variables(){return this._variables}get cells(){return this._cells}get ranges(){return this._ranges}get colors(){if(!this._colors){let t;this._colors=new Map,this._tokens.forEach(((e,i)=>{if([Wm.Cell,Wm.Range].includes(e[1])){const o=(t?"'"+t+"'!":"")+e[0];this._colors.set(o,{color:fv(this._colors.size),address:e[0],sheet:t,type:e[1],tokenIndex:i}),t=null}else e[1]==Wm.Sheet&&(t=e[0])}))}return this._colors}constructor(t,e){this.expression=t,this.tokenizer=e,this._tokens=e.tokenize(this.expression),this.updateDependecies()}findTokenIndexAtPosition(t){let e=0;return this._tokens.findIndex((i=>{const o=i[0].length;if(t>=e&&t<=e+o)return!0;e+=o}))}findSheetTokenIndex(t){const e=this._tokens[t];if(![Wm.Cell,Wm.Range].includes(e[1]))return-1;if(0==t||this._tokens[t-1][1]!=Wm.SheetSeparator)return-1;let i=t-2;for(;i>=0;){if(this._tokens[i][1]==Wm.Sheet)return i;i--}return-1}removeSheetToken(t){if(this._tokens[t][1]!=Wm.Sheet&&(t=this.findSheetTokenIndex(t)),t>-1){t>0&&this._tokens[t-1][1]==Wm.SheetQuote&&t--;let e=t;for(;e<this._tokens.length&&[Wm.SheetSeparator,Wm.SheetQuote,Wm.Sheet].includes(this._tokens[e][1]);)e++;return this._tokens.splice(t,e-t),e-t}return 0}getNamedColor(t){return this.colors.get(t)?.color??"inherit"}getTokenPosition(t){let e=0;for(let i=0;i<t;i++)e+=this._tokens[i][0].length;return{min:e,max:e+this._tokens[t][0].length}}updateToken(t,e){this._fn=null,this._formula=null,this._xlFormula=null,this._tokens[t][0]=e}removeToken(t){this._fn=null,this._formula=null,this._xlFormula=null,this._tokens.splice(t,1)}insertToken(t,e,i){this._fn=null,this._formula=null,this._xlFormula=null;const o=[];return i==Wm.Sheet&&/\s/.test(e)?(o.push([this.tokenizer.options.sheetQuote,Wm.SheetQuote]),o.push([e,Wm.Sheet]),o.push([this.tokenizer.options.sheetQuote,Wm.SheetQuote])):o.push([e,i]),o.push(["!",Wm.SheetSeparator]),this._tokens.splice(t,0,...o),o.length}clone(){return new vv(this.createFormulaString(),this.tokenizer)}updateDependecies(){let t;this._variables=[],this._cells=[],this._ranges=[],this._tokens.forEach(((e,i)=>{switch(e[1]){case Wm.Sheet:t=e[0];break;case Wm.Variable:this._variables.push([i,e[0],t]),t=void 0;break;case Wm.Cell:this._cells.push([i,Jm.fromA1(e[0]),t]),t=void 0;break;case Wm.Range:this._ranges.push([i,Jm.fromA1(e[0]),t]),t=void 0}}))}createFormulaString(t=!1,e=!1){const i=this.tokenizer.options;let o,n,r,s="";for(let l=0;l<this._tokens.length;l++)switch(o=this._tokens[l],o[1]){case Wm.SheetQuote:s+="'";break;case Wm.SheetSeparator:s+="!";break;case Wm.Sheet:n=o[0],s+=t?`<span style="font-style:italic">${n}</span>`:n;break;case Wm.Variable:s+=o[0];break;case Wm.Range:case Wm.Cell:r=(n?"'"+n+"'!":"")+o[0],s+=t?`<span style="color:${this.getNamedColor(r)}">${o[0]}</span>`:o[0],n=null;break;case Wm.StringQuote:s+=i.stringQuote;break;case Wm.String:s+=o[0].replace(new RegExp(i.stringQuote,"g"),"\\"+i.stringQuote);break;case Wm.ArgumentSeparator:s+=i.argumentSeparator;break;case Wm.Function:s+=(e?(a=o[0],mv.get(a)??""):"")+o[0];break;case Wm.Unknown:s+=t?`<span style="background:#f00;color:#fff">${o[0]}</span>`:o[0];break;default:s+=o[0]}var a;return s}createExpressionTree(){const t=[],e=[],i=this.tokens;let o,n,r,s,a,l=null;for(let c=0;c<i.length;c++)switch(o=i[c],o[1]){case Wm.Sheet:l=o[0];break;case Wm.Cell:case Wm.Range:t.push({t:o[0],tt:o[1],s:l}),l=null;break;case Wm.Number:case Wm.String:case Wm.Boolean:case Wm.Variable:t.push({t:o[0],tt:o[1]});break;case Wm.Operator:for(0==t.length&&t.push({t:"",tt:Wm.Operand}),r=Nm.get(o[0]);e.length>0&&(s=Nm.get(e[e.length-1][0]),s)&&(0===r[2]&&r[1]<=s[1]||1===r[2]&&r[1]<s[1]);)n=e.pop(),a=[t.pop(),t.pop()].reverse(),t.push({t:n[0],tt:n[1],c:a});e.push(o);break;case Wm.Function:case Wm.OpenBracket:e.push(o);break;case Wm.ArgumentSeparator:for(;e.length>0&&(n=e[e.length-1],![Wm.OpenBracket,Wm.ArgumentSeparator].includes(n[1]));)n=e.pop(),a=[t.pop(),t.pop()].reverse(),t.push({t:n[0],tt:n[1],c:a});e.push(o);break;case Wm.CloseBracket:for(a=[];e.length>0&&e[e.length-1][1]!==Wm.OpenBracket;)n=e.pop(),n[1]==Wm.Operator?a.push({t:n[0],tt:n[1],c:[t.pop(),t.pop()].reverse()}):n[1]==Wm.ArgumentSeparator&&t.length>0&&a.push(t.pop());e.pop(),e.length>0&&e[e.length-1][1]===Wm.Function?(n=e.pop(),a=a.reverse(),t.length>0&&i[c-1][1]!==Wm.OpenBracket&&a.unshift(t.pop()),t.push({t:n[0],tt:n[1],c:a})):t.push(...a)}for(;e.length>0;)n=e.pop(),t.push({t:n[0],tt:n[1],c:[t.pop(),t.pop()].reverse()});return t.pop()}createExpressionJSCode(t,e,i){let o;switch(t.tt){case Wm.Range:return"t.rn('"+t.t+"'"+(t.s?",'"+t.s+"'":"")+")";case Wm.Cell:return"t.cl('"+t.t+"'"+(t.s?",'"+t.s+"'":"")+")";case Wm.Operand:return"t.cl()";case Wm.Variable:return i||e?.tt===Wm.Function?"t.nr('"+t.t+"'"+(t.s?",'"+t.s+"'":"")+")":"t.nv('"+t.t+"'"+(t.s?",'"+t.s+"'":"")+")";case Wm.String:return"'"+t.t.replace(/'/g,"\\'")+"'";case Wm.Boolean:return"T"==t.t[0].toUpperCase()?"1":"0";case Wm.Function:return o=t.c.map((e=>this.createExpressionJSCode(e,t,i||hv(t.t)))),"t.fn('"+t.t+"').call(ctx"+(o.length>0?","+o.join(","):"")+")";case Wm.Operator:return i?(o=t.c.map((e=>this.createExpressionJSCode(e,t,i||hv(t.t)))),"t.op("+o[0]+","+o[1]+",'"+t.t+"')"):Nm.has(t.t)?"("+t.c.map((e=>this.createExpressionJSCode(e,t,i))).join(Nm.get(t.t)[0])+")":null;default:return t.t}}compile(){const t=this.createExpressionTree();return this.createExpressionJSCode(t)}toString(t=!1){return(t?"=":"")+(this._formula??(this._formula=this.createFormulaString()))}toExcelString(){return this._xlFormula??(this._xlFormula=this.createFormulaString(!1,!0))}shift(t){const{index:e,offset:i,direction:o,maxIndex:n,sheet:r,allSheets:s}=t;return this._cells&&this._cells.forEach((t=>{if(s||null==t[2]||t[2]==r){switch(o){case"up":t[1].shiftUp(e,i,n);break;case"right":t[1].shiftRight(e,i,n);break;case"down":t[1].shiftDown(e,i,n);break;case"left":t[1].shiftLeft(e,i,n)}this._tokens[t[0]][0]=t[1].A1}})),this._ranges&&this._ranges.forEach((t=>{if(s||null==t[2]||t[2]==r){switch(o){case"up":t[1].shiftUp(e,i,n);break;case"right":t[1].shiftRight(e,i,n);break;case"down":t[1].shiftDown(e,i,n);break;case"left":t[1].shiftLeft(e,i,n)}this._tokens[t[0]][0]=t[1].A1}})),this}hasSheetReference(t){for(const e of this._cells)if(e[2]==t)return!0;for(const e of this._ranges)if(e[2]==t)return!0;for(const e of this._variables)if(e[2]==t)return!0;return!1}renameSheet(t,e){let i=!1;return this._tokens.forEach((o=>{o[1]==Wm.Sheet&&o[0]==t&&(o[0]=e,i=!0)})),i}}function bv(t,e){return e&&(t=Go(this.cell.model.options.locale,Qo(e,"d"),!1)(t)),null==t?"":t.toString()}function yv(t,e){return(t=null==t?"":t.toString()).substring(0,e)}function wv(t,e){return(t=null==t?"":t.toString()).substring(Math.max(0,t.length-e),t.length)}function xv(t,e,i){return(t=null==t?"":t.toString()).substring(e,e+i)}function kv(...t){let e="";return lv(t,(t=>e+=null==t?"":t.toString())),e}function Cv(t){return t instanceof Date?t:Z(t)?zo(t,ho()):No(t)}function Mv(t){return K(t)?t:Do(t instanceof Date?t:zo(t,ho()))}function _v(t){return Z(t)?Mv(t):t}function Sv(t,e){const i=Cv(t).getDay();switch(e){case 2:return i;case 3:return i-1;default:return i%7+1}}function Ev(t,e,i){return Po(Mv(sv(t)),e)}function zv(){return Do(new Date)}function Lv(t){return null==(t=sv(t))||""===t}function Rv(t,e,i){return Do(new Date(t,e-1,i))}function Iv(t){return Cv(t).getFullYear()}function Hv(t){return Cv(t).getMonth()+1}function Tv(t){return Cv(t).getDate()}function Av(t,e){const i=Cv(t);return i.setMonth(i.getMonth()+e+1),i.setDate(0),Do(i)}function Ov(t){return pi(Cv(t))}function $v(t){return Math.acos(t)}function Dv(t){return Math.acosh(t)}function Nv(t){return Math.PI/2-Math.atan(t)}function Pv(t){return.5*Math.log((t+1)/(t-1))}function jv(t){return Math.asin(t)}function Vv(t){return Math.asinh(t)}function Bv(t){return Math.atan(t)}function Fv(t){return Math.atanh(t)}function Wv(t){return Math.cos(t)}function Uv(t){return Math.cosh(t)}function Gv(t){return 1/Math.tan(t)}function qv(t){return 1/Math.tanh(t)}function Yv(t){return 1/Math.sin(t)}function Zv(t){return 1/Math.sinh(t)}function Xv(t){return 180*t/Math.PI}function Qv(){return Math.PI}function Kv(t){return 1/Math.cos(t)}function Jv(t){return 1/Math.cosh(t)}function tb(t){return Math.sin(t)}function eb(t){return Math.sinh(t)}function ib(t){return Math.tan(t)}function ob(t){return Math.tanh(t)}function nb(t){return Math.abs(t)}function rb(t){if(t<0)throw new Error("#NUM");return Math.ceil(t)}function sb(t){return(t=Math.ceil(t))%2==0?t:t+1}function ab(t){return Math.pow(Math.E,t)}function lb(t){return t<0?-1:0==t?1:t*lb(t-1)}function cb(t){return t<=0?1:t*cb(t-2)}function hb(t){return Math.floor(t)}function db(t){return t%1!=0}function ub(t){return!db(t)&&t%2==0}function pb(t){return db(t)||t%2==1}function gb(t){return Math.log(t)}function fb(t,e){return Math.log(t)/Math.log(e)}function mb(t){return Math.log10(t)}function vb(t,e){return t%e}function bb(t){return(t=Math.ceil(t))%2==0?t+1:t}function yb(t,e){return Math.pow(t,e)}function wb(...t){let e=1;return lv(t,(t=>e*=t||1)),e}function xb(t,e){return Math.floor(t/e)}function kb(t){return t*Math.PI/180}function Cb(){return Math.random()}function Mb(t,e){const i=Array(t).fill(null).map((()=>Array(e)));for(let o=0;o<t;o++)for(let t=0;t<e;t++)i[o][t]=Math.random();return i}function _b(t,e){return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t}function Sb(t,e){return t.toFixed(e)}function Eb(t,e){return e=e||0,Math.floor(t*Math.pow(10,e))/Math.pow(10,e)}function zb(t,e){return e=e||0,Math.ceil(t*Math.pow(10,e))/Math.pow(10,e)}function Lb(t,e,i=1,o=1){const n=Array(t).fill(null).map((()=>Array(e)));let r=i;for(let i=0;i<t;i++)for(let t=0;t<e;t++)n[i][t]=r,r+=o;return n}function Rb(t){return t<0?-1:t>0?1:0}function Ib(t){return Math.sqrt(t)}function Hb(t){return Math.sqrt(Math.PI*t)}function Tb(...t){let e=0;return lv(t,(t=>e+=null==t?0:1)),e}function Ab(...t){let e=0;return lv(t,(t=>e+=null==t?1:0)),e}function Ob(t,e){let i=0;return lv(t,(t=>i+=Dm(e,t)?1:0)),i}function $b(...t){let e=0;const i=new Map;return lv(t,(t=>{i.has(t)||(i.set(t,t),++e)})),e}function Db(...t){let e=0;return lv(t,(t=>e+=isNaN(t)?0:t)),e}function Nb(t,e,i){let o=0;if(i){const n=av(i);lv(t,((t,i,r)=>o+=Dm(e,t)&&n[i]&&n[i][r]&&!isNaN(n[i][r])?n[i][r]:0))}else lv(t,(t=>o+=Dm(e,t)&&!isNaN(t)?t:0));return o}function Pb(t,e){let i=0;return lv(t,(t=>i+=Dm(e,t)&&!isNaN(t)?t*t:0)),i}function jb(...t){let e=0;const i=t.shift();if(0===t.length)lv(i,(t=>e+=isNaN(t)?0:t));else{const o=av(t[0]);lv(i,((t,i,n)=>e+=o[i]&&o[i][n]&&!isNaN(t)&&!isNaN(o[i][n])?t*o[i][n]:0))}return e}function Vb(t,e){return t=null==t?"":t.toString(),e?e=>e==t:(t=t.toLowerCase(),e=>(e??"").toString().toLowerCase().includes(t))}function Bb(t,e,i=1){const o=new Jm(Math.max((e||0)-1,0),Math.max((t||0)-1,0));return 1!=i&&2!=i||(o.r1Anchor=!0),1!=i&&3!=i||(o.c1Anchor=!0),o.A1}function Fb(t,e,i,o=!1){let n,r;const s=Vb(t,o);for(n=0;n<e.length;n++)for(r=0;r<e[n].length;r++)if(s(e[n][r]))return e[n][i-1];return null}function Wb(t,e,i,o=!1){let n,r;const s=Vb(t,o);for(n=0;n<e.length;n++)for(r=0;r<e[n].length;r++)if(s(e[n][r]))return e[i-1][r];return null}function Ub(t,e,i){let o,n;t:for(o=0;o<e.length;o++)for(n=0;n<e[o].length;n++)if(e[o][n]==t)break t;return i?i[o]?i[o][n]:null:e[o][e[o].length-1]}function Gb(t,...e){let i=null,o=0;return lv(e,(e=>{if(t==++o)return i=e,!1})),i}function qb(t){return(t?Jm.fromA1(t).c1:this.cell.c)+1}function Yb(t){return(t?Jm.fromA1(t).r1:this.cell.r)+1}function Zb(t){return Array.isArray(t)?t[0]?.length:1}function Xb(t){return Array.isArray(t)?t.length:1}function Qb(){const t=rv(this)[0];return t&&t.hasFormula?" "+uv(t.formula):""}function Kb(t,e,i){return e=e||1,i=i||1,Array.isArray(t)?t[e-1]?t[e-1][i-1]:null:1==e&&1==i?t:null}function Jb(t){const e=this.cell,i=e.model,o=i.getCellByA1(t);let n;return i.calculations.dependencies.cellDependencies.has(e.address)?n=i.calculations.dependencies.cellDependencies.get(e.address):(n=new Map,i.calculations.dependencies.cellDependencies.set(e.address,n)),n.set(o.address,[o.range]),i.calculations.dependencies.cellDependants.has(o.address)?n=i.calculations.dependencies.cellDependants.get(o.address):(n=new Map,i.calculations.dependencies.cellDependants.set(o.address,n)),n.set(e.address,[e.range]),o.value}function ty(t,e,i=0){let o,n;for(o=0;o<e.length;o++)for(n=0;n<e[o].length;n++){if(0==i&&e[o][n]==t)return Math.max(o+1,n+1);if(1==i&&e[o][n]>t)return Math.max(o+1,n+1);if(-1==i&&e[o][n]<t)return Math.max(o+1,n+1)}return null}function ey(t,e,i,o,n){const r=rv(this)[0],s=[];o=o||1,n=n||1;for(let t=0;t<o;t++){const o=[];for(let s=0;s<n;s++){const n=r.model.rows[r.r+t+e].cell(r.c+s+i);o.push(n?r.value:null)}s.push(o)}return s}function iy(t,e){const i=[];if(t.length==e.length)for(let o=0;o<t.length;o++){let n=!0;for(let t=0;t<e[o].length;t++)if(!e[o][t]){n=!1;break}n&&i.push(t[o])}return i}const oy=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],ny=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]];function ry(t){const e=t*t;let i,o=oy[0][4]*e,n=e;for(i=0;i<3;i+=1)o=(o+oy[0][i])*e,n=(n+ny[0][i])*e;return t*(o+oy[0][3])/(n+ny[0][3])}function sy(...t){let e=!0;return lv(t,(t=>{if(!t)return e=!1})),e}function ay(...t){let e=!1;return lv(t,(t=>{if(t)return e=!0})),e}function ly(...t){let e=null;return lv(t,(t=>{e=null===e?!!t:!!t!=e})),e}function cy(...t){const e=t[0];for(let i=1;i<t.length;i+=2){if(i==t.length-1)return t[i];if(e==t[i])return t[i+1]}return null}function hy(t,e,i){return t?e:i}function dy(t){return!t}function uy(){return!1}function py(){return!0}function gy(t,e){return e=""===e?null:e,t===1/0||t===-1/0||Number.isNaN(t)?e:t}var fy=i(235),my=i.n(fy),vy=i(5949),by=i.n(vy);function yy(...t){let e=0,i=0;return lv(t,(t=>{null==t||isNaN(t)||(e+=t||0,++i)})),e/i}function wy(t,e){const i=by()(),o=av(t),n=av(e);for(let t=0;t<o.length;t++)for(let e=0;e<o[t].length;e++)i(o[t][e],(n[t]?n[t][e]:1)??1);return i()}function xy(...t){const e=function(t){const e=[];return lv(t,(t=>e.push(t))),e}(t),i=my()(e.length,e,1);return e.reduce(((t,e)=>t+Math.abs(e-i)),0)/e.length}function ky(...t){let e=1/0;return lv(t,(t=>e=Math.min(e,t))),e}function Cy(...t){let e=-1/0;return lv(t,(t=>e=Math.max(e,t))),e}function My(t,e){Object.keys(e).forEach((i=>t.set(nt(i,"_").replace(/_/g,".").toUpperCase(),e[i])))}const _y=new Map;My(_y,C),My(_y,M),My(_y,_),My(_y,S),My(_y,z),My(_y,E),My(_y,L);class Sy{constructor(t){this.model=t,this.getModel=t=>{const e=t?this.model.getConnectedModel(t):this.model;if(e)return e;throw new Error(`Sheet "${t}" not found`)},this.cl=(t,e)=>{const i=this.getModel(e);return(null==t?this.currentCell:i.getCellByA1(t)).value},this.rn=(t,e)=>this.getModel(e).getValuesInRange(Jm.fromA1(t)),this.nv=(t,e)=>this.getModel(e).getCellByName(t,this.currentCell.range).value,this.nr=(t,e)=>{const i=this.getModel(e).getValueMatrixByName(t);return 1===i.length&&1===i[0].length?i[0][0]:i},this.fn=t=>{const e=_y.get(t);if(e)return e;throw new Error(`Function "${t}" not found`)},this.op=(t,e,i)=>Fm(t,e,i)}}function Ey(t,e){const i=Array(e).fill(null);let o=0,n=[];if(t.length>1){n=t.map((t=>parseFloat(t.value)||0)),o=n[1]-n[0];for(let t=2;t<n.length;t++)if(n[t]-n[t-1]!==o){o=0;break}}if(0==o)for(let o=0;o<e;o++)i[o]=t[o%t.length]?.value;else{let t=n[n.length-1];for(let n=0;n<e;n++)t=i[n]=t+o}return i}function zy(t,e,i){const o=new vv(t.formula,t.model.calculations.tokenizer),n=[];for(let t=0;t<i;t++)n.push(uv(o.shift({index:0,offset:1,direction:e,allSheets:!0}).createFormulaString()));return n}function Ly(t,e,i,o){const n=t.getCellMatrix(e);let r;"right"==o?r=En(n):"down"==o?r=Sn(n):"left"==o?r=Mn(n):"up"==o&&(r=Mn(Sn(n)));const s=new Array(i.size.rows);for(let t=0;t<i.size.rows;t++){s[t]=new Array(i.size.columns);for(let e=0;e<i.size.columns;e++){const i=n.length>t?n[t][n[t].length>e?e:0]:n[0][e];s[t][e]=i.hasDisplayValue?i.displayValue:null}}const a=i.size["down"==o||"up"==o?"rows":"columns"];let l=r.map((t=>t[t.length-1].hasFormula?zy(t[t.length-1],o,a):Ey(t,a)));return"down"==o?l=Sn(l):"left"==o?l=Mn(l):"up"==o&&(l=_n(Sn(l))),t.spillValues({cell:t.getCellByRange(i.bounds[0][0]),values:l,propertyCell:t.getCellByRange(e.bounds[0][0]),displayValues:s})}class Ry{get address(){return null}get renderer(){return this._renderer}set renderer(t){this._renderer=t}get afterRenderer(){return this._afterRenderer}set afterRenderer(t){this._afterRenderer=t}get commentRenderer(){return this._commentRenderer}set commentRenderer(t){this._commentRenderer=t}get type(){return this._type}set type(t){this._type=t}get name(){return this._name}set name(t){this._name=t}get style(){return this._style}set style(t){this._style=t}get commentable(){return this._commentable}set commentable(t){this._commentable=t}get clickable(){return this._clickable}set clickable(t){this._clickable=t}get editable(){return this._editable}set editable(t){this._editable=t}get allowInvalid(){return this._allowInvalid}set allowInvalid(t){this._allowInvalid=t}get hasFormula(){return!!this._formula}get formula(){return this._formula}set formula(t){this._formula=t?t.replace(/^=/,""):null}get value2(){return this.hasFormula?uv(this.formula):null}get editorContent(){return this._editorContent}set editorContent(t){this._editorContent=t}get adapter(){return this._adapter}set adapter(t){this._adapter=t}get properties(){return this._properties}set properties(t){this._properties=t}getProperty(t){return this._properties?.[t]}setProperty(t,e){this._properties||(this._properties={}),this._properties[t]=e}get format(){return this._format}set format(t){this._format=t,this._valueFormatter=null}get valueFormatter(){return this._valueFormatter}constructor(t,e){this.model=t,this._type=null,this._clickable=!1,e&&this.populate(e)}populate(t){this._renderer=t.renderer,this._afterRenderer=t.afterRenderer,this._commentRenderer=t.commentRenderer,this._name=t.name,this._type=t.t,this._editorContent=t.content,this._adapter=t.adapter,this._format=t.z,this._formula=t.f,this._editable=t.e,this._commentable=t.commentable,this._clickable=t.clickable,this._allowInvalid=t.allowInvalid,this._properties=t.props,this._style=null==t.s?null:this.model.styles.add(t.s).id}getSourceData(){const t={};return null!=this._type&&(t.t=this._type),null!=this._format&&(t.z=this._format),null!=this._formula&&(t.f=this._formula),null!=this._editable&&(t.e=this._editable),null!=this._commentable&&(t.commentable=this._commentable),null!=this._clickable&&(t.clickable=this._clickable),this._properties&&(t.props=it(this._properties)),null!=this._editorContent&&(t.content=q(this._editorContent)?it(this._editorContent):this._editorContent),null!=this._style&&(t.s=this._style),null!=this._name&&(t.name=this._name),t}setStyleProperties(t,e=!1){this.style=e?this.model.styles.set(this.style,t).id:this.model.styles.duplicate(this.style,t).id}removeStyleProperties(t){null!==this.style&&this.model.styles.unset(this.style,t)}get composedStyle(){return this.model.styles.get(this.style)}}function Iy(t){const e={};return t.split(";").forEach((t=>{const[i,o]=t.split(":");e[i]=o.trim()})),e}const Hy=new Map([["thin",{width:1.5,style:"solid"}],["medium",{width:2,style:"solid"}],["thick",{width:3,style:"solid"}],["double",{width:3,style:"double"}],["dotted",{width:1.5,style:"dotted"}],["hair",{width:1,style:"solid"}],["dashed",{width:1.5,style:"dashed"}],["mediumDashed",{width:2,style:"dashed"}],["dashDot",{width:1.5,style:"dashed"}],["mediumDashDot",{width:2,style:"dashed"}],["dashDotDot",{width:1.5,style:"dotted"}],["mediumDashDotDot",{width:2,style:"dotted"}],["slantDashDot",{width:1.5,style:"dashed"}],["none",{width:1.5,style:"solid"}]]),Ty=(()=>{const t=new Map;return Hy.forEach(((e,i)=>{let o=t.get(e.style);o||(o=t.set(e.style,new Map).get(e.style)),o.set(e.width,i)})),t})();function Ay(t){return"middle"==t?"center":t}function Oy(t){return 3==(t="#"==t.charAt(0)?t.substring(1):t).length?t[0]+t[0]+t[1]+t[1]+t[2]+t[2]:t}const $y=t=>{if("none"==t)return null;const e=t.split(" "),i=parseInt(e[0].charAt(0))||1,o=e.length>1?e[1]:"solid",n=Ty.get(o);return{style:(n?n.get(i):null)??"thin",color:e.length>2?Oy(e[2]):"CCCCCC"}},Dy=t=>{const e=Hy.get(t.style||"none");return e?[It(e.width),e.style,"none"==t.style?"var(--og-cell-background)":`#${t.color}`].join(" "):"none"},Ny=(t,e)=>{const i="#"+(e.fgColor||"000000"),o="#"+(e.bgColor||"FFFFFF");switch(e.patternType){case"solid":t.backgroundColor=i||o;break;case"darkGray":t.backgroundColor=fn(o,.75);break;case"mediumGray":t.backgroundColor=fn(o,.5);break;case"lightGray":t.backgroundColor=fn(o,.25);break;case"gray125":t.backgroundColor=fn(o,.125);break;case"gray0625":t.backgroundColor=fn(o,.0625);break;case"darkHorizontal":t.backgroundImage=`linear-gradient(0deg, ${i} 33.33%, ${o} 33.33%, ${o} 50%, ${i} 50%, ${i} 83.33%, ${o} 83.33%, ${o} 100%)`,t.backgroundSize="6px 6px";break;case"darkVertical":t.backgroundImage=`linear-gradient(90deg, ${i} 33.33%, ${o} 33.33%, ${o} 50%, ${i} 50%, ${i} 83.33%, ${o} 83.33%, ${o} 100%)`,t.backgroundSize="6px 6px";break;case"darkDown":t.backgroundImage=`linear-gradient(45deg, ${i} 33.33%, ${o} 33.33%, ${o} 50%, ${i} 50%, ${i} 83.33%, ${o} 83.33%, ${o} 100%)`,t.backgroundSize="6px 6px";break;case"darkUp":t.backgroundImage=`linear-gradient(-45deg, ${i} 33.33%, ${o} 33.33%, ${o} 50%, ${i} 50%, ${i} 83.33%, ${o} 83.33%, ${o} 100%)`,t.backgroundSize="6px 6px";break;case"lightHorizontal":t.backgroundImage=`linear-gradient(0deg, ${o} 25%, ${i} 25%, ${i} 50%, ${o} 50%, ${o} 75%, ${i} 75%, ${i} 100%)`,t.backgroundSize="4px 4px";break;case"lightVertical":t.backgroundImage=`linear-gradient(90deg, ${o} 25%, ${i} 25%, ${i} 50%, ${o} 50%, ${o} 75%, ${i} 75%, ${i} 100%)`,t.backgroundSize="4px 4px";break;case"lightDown":t.backgroundImage=`linear-gradient(45deg, ${o} 25%, ${i} 25%, ${i} 50%, ${o} 50%, ${o} 75%, ${i} 75%, ${i} 100%)`,t.backgroundSize="4px 4px";break;case"lightUp":t.backgroundImage=`linear-gradient(-45deg, ${o} 25%, ${i} 25%, ${i} 50%, ${o} 50%, ${o} 75%, ${i} 75%, ${i} 100%)`,t.backgroundSize="4px 4px";break;case"darkGrid":t.backgroundImage=`linear-gradient(${o} 0.5px, transparent 0.5px), linear-gradient(90deg, ${o} 0.5px, transparent 0.5px)`,t.backgroundSize="2px 2px";break;case"lightGrid":t.backgroundImage=`linear-gradient(${o} 0.5px, transparent 0.5px), linear-gradient(90deg, ${o} 0.5px, transparent 0.5px)`,t.backgroundSize="1px 1px";break;case"darkTrellis":t.backgroundImage=`linear-gradient(45deg, ${o} 0.5px, transparent 0.5px), linear-gradient(90deg, ${o} 0.5px, transparent 0.5px)`,t.backgroundSize="2px 2px";break;case"lightTrellis":t.backgroundImage=`linear-gradient(45deg, ${o} 0.5px, transparent 0.5px), linear-gradient(90deg, ${o} 0.5px, transparent 0.5px)`,t.backgroundSize="1px 1px"}return t},Py=(t,e)=>(t.backgroundImage=`linear-gradient(${(e.angle??0)+90}deg,${e.stops.map((t=>`#${t.rgb} ${100*t.v}%`)).join(",")})`,t),jy=t=>{const e=t.cssStyle?{...t.cssStyle}:{};return null!=t.bold&&(e.fontWeight=t.bold?"bold":"normal"),t.italic&&(e.fontStyle="italic"),t.underline?e.textDecoration="underline":t.strike&&(e.textDecoration="line-through"),t.sz&&(e.fontSize=Rt(t.sz)),t.color&&(e.color="#"+t.color),t.top&&(e.borderTop=Dy(t.top)),t.right&&(e.borderRight=Dy(t.right)),t.bottom&&(e.borderBottom=Dy(t.bottom)),t.left&&(e.borderLeft=Dy(t.left)),(t.top||t.right||t.bottom||t.left)&&(e.zIndex="1"),t.alignment&&t.alignment.vertical?(e.display="flex",e.justifyContent=t.alignment.horizontal,e.alignItems="top"==t.alignment.vertical?"start":"bottom"==t.alignment.vertical?"end":"center"):t.alignment&&t.alignment.horizontal&&(e.textAlign=t.alignment.horizontal),t.alignment&&t.alignment.wrapText&&(e.display="flex",e.justifyContent=e.justifyContent??"left",e.alignItems=e.alignItems??"center",e.whiteSpace="normal"),t.patternType?Ny(e,t):t.stops&&t.stops.length?Py(e,t):t.fgColor?e.backgroundColor="#"+t.fgColor:t.bgColor&&(e.backgroundColor="#"+t.bgColor),e},Vy=t=>{const e=q(t)?t:Iy(t),i={};let o;for(const t in e){const n=e[t];if(null!=n)switch(t){case"borderTop":case"border-top":i.top=$y(n);break;case"borderTopColor":case"border-top-color":i.top?i.top.color=Oy(n):i.top={style:"thin",color:Oy(n)};break;case"borderRight":case"border-right":i.right=$y(n);break;case"borderRightColor":case"border-right-color":i.right?i.right.color=Oy(n):i.right={style:"thin",color:Oy(n)};break;case"borderBottom":case"border-bottom":i.bottom=$y(n);break;case"borderBottomColor":case"border-bottom-color":i.bottom?i.bottom.color=Oy(n):i.bottom={style:"thin",color:Oy(n)};break;case"borderLeft":case"border-left":i.left=$y(n);break;case"borderLeftColor":case"border-left-color":i.left?i.left.color=Oy(n):i.left={style:"thin",color:Oy(n)};break;case"border":o=$y(n),i.top=i.top||o,i.right=i.right||o,i.bottom=i.bottom||o,i.left=i.left||o;break;case"textAlign":case"text-align":i.alignment=i.alignment||{},i.alignment.horizontal=n;break;case"verticalAlign":case"vertical-align":i.alignment=i.alignment||{},i.alignment.vertical=Ay(n);break;case"whiteSpace":case"white-space":i.alignment=i.alignment||{},i.alignment.wrapText=n&&"nowrap"!=n;break;case"color":i.color=Oy(n);break;case"background":case"backgroundColor":i.fgColor=Oy(n);break;case"fontSize":case"font-size":i.sz=parseFloat(n);break;case"fontWeight":case"font-weight":i.bold="bold"==n;break;case"fontStyle":case"font-style":i.italic="italic"==n;break;default:i[t]=n}}return i},By={n:t=>{const e=Z(t)?parseFloat(t):t;return Number.isNaN(e)?t:e},t:t=>t,d:(t,e)=>Z(t)?X(t)?Q(t):Do(zo(t,e.model.options.formatLocale)):t instanceof Date?Do(t):t,tm:t=>Z(t)?new Date(t):t,dt:t=>Z(t)?new Date(t):t,b:t=>!!t&&"0"!==t&&"false"!==t.toString().toLowerCase(),s:t=>t,m:t=>t,g:t=>{if(null==t)return null;const e=parseFloat(t);return isNaN(e)?t:e},a:t=>Z(t)?JSON.parse(t):t,h:t=>t},Fy=new Map;class Wy extends Ry{get tooltip(){return this._tooltip}set tooltip(t){this._tooltip=t}get hasTooltip(){return null!=this._tooltip}get rowspan(){return this._rowspan}set rowspan(t){this._rowspan=t}get colspan(){return this._colspan}set colspan(t){this._colspan=t}get r(){return this.row.index}get c(){return this.column.index}get hasValue(){return null!=this._value}get value(){return this._evaluated||this.evaluate(),this._value}set value(t){t&&dv(t.toString())?(this._value=void 0,this.formula=t):(this._value=By[this.type](t,this),this.row.data&&this.column.data&&(this.row.data[this.column.data]=this._value))}evaluate(){return this._value=By[this.type](this.model.calculations.evaluate(this),this),this._evaluated=!0,this._value}get value2(){return this.hasFormula?uv(this.formula):this.value}get hasDisplayValue(){return null!=this._displayValue}get displayValue(){return this._displayValue}set displayValue(t){this._displayValue=t}get error(){return this._error}set error(t){this._error=t}get hasError(){return!!this._error}clearError(){this._error=void 0}get spillRange(){return this._spillRange}get prevSpillRange(){return this._prevSpillRange}set spillRange(t){!this._spillRange||t&&this._spillRange.equals(t)||(this._prevSpillRange=this._spillRange),this._spillRange=t}get isSpillSource(){return null!=this._spillRange}get spillSource(){return this._spillSource}get isSpilled(){return null!=this._spillSource}spillValue(t,e){this.value=t,this._spillSource=e}clearSpilledValue(){this._spillSource=void 0,this._value=void 0}get hasSparkline(){return null===this._sparkline?this._sparkline=this.model.sparklines.has(this.address):this._sparkline}get hasComment(){return null===this._hasComment?this._hasComment=(this.model.comments.get(this.address)??[]).length>0:this._hasComment}get comments(){return this.model.comments.get(this.address)}get valueFormatter(){const t=super.valueFormatter??this.row.valueFormatter??this.column.valueFormatter;if(t)return t;const e=this.type,i=this.format,{locale:o,fixNumberFormat:n}=this.model.options,r=this.value;if(null==r||""===r)return null;if("n"==e)return null!=i?Go(o,i,n):this.model.options.numberFormatter;if("g"==e){if(null!=i)return Go(o,i,n);if(K(r))return this.model.options.numberFormatter}else{if("t"==e)return null==i?null:Go(o,i,!1);if("d"==e)return i?Lo(o,i):this.model.options.dateFormatter;if("s"==e&&this.editorContent)return(t=>{if(t=t||null,!Fy.has(t))if(t){const e=t.reduce(((t,e)=>t.set(e.k,e.v)),new Map);Fy.set(t,(t=>e.has(t)?e.get(t):t))}else Fy.set(t,(t=>t));return Fy.get(t)})(this.editorContent)}return null}get formattedValue(){if(null==this.value)return"";const t=this.valueFormatter;return t?t(this.value):this.hasDisplayValue?this.displayValue:this.value.toString()}get elm1(){return this.row.priority>=this.column.priority?this.row:this.column}get elm2(){return this.row.priority<this.column.priority?this.row:this.column}get clickable(){return super.clickable??this.elm1.clickable??this.elm2.clickable}get type(){return super.type??this.elm1.type??this.elm2.type??"g"}set type(t){this._type=t}get editorContent(){return super.editorContent??this.elm1.editorContent??this.elm2.editorContent??null}get adapter(){return super.adapter??this.elm1.adapter??this.elm2.adapter}set adapter(t){this._adapter=t}get address(){return this.column.address+this.row.address}get range(){return Jm.fromA1(this.address)}get allowInvalid(){return super.allowInvalid??this.elm1.allowInvalid??this.elm2.allowInvalid??this.model.options.allowInvalid}get editable(){return super.editable??this.elm1.editable??this.elm2.editable??this.model.options.editable}set editable(t){this._editable=t}get commentable(){return super.commentable??this.elm1.commentable??this.elm2.commentable??this.model.options.commentable}get renderer(){return super.renderer??this.elm1.renderer??this.elm2.renderer}get afterRenderer(){return super.afterRenderer??this.elm1.afterRenderer??this.elm2.afterRenderer??this.model.options.afterRenderer}get commentRenderer(){return super.commentRenderer??this.elm1.commentRenderer??this.elm2.commentRenderer??this.model.options.comments.renderer}get format(){return super.format??this.elm1.format??this.elm2.format}set format(t){super.format=t}get hasOwnFormula(){return!!this._formula}get hasFormula(){return null==this._hasFormula&&(this._hasFormula=!!this.formula),this._hasFormula}get formula(){return this._formula??this.elm1.formula??this.elm2.formula}set formula(t){super.formula=t,this.refreshFormula()}invalidateValue(){this.hasFormula?(this._value=void 0,this._evaluated=!1):this._evaluated=!0,this.clearError()}refreshFormula(){this.invalidateValue(),this._hasFormula=null}clearFormula(){this._formula=null,this._hasFormula=!1,this._evaluated=!0}constructor(t,e){super(t),this._evaluated=!0,this._sparkline=null,this._hasComment=null,this._hasStyle=null,this.row=t.rows[e.r],this.column=t.columns[e.c],this.populate(e)}populate(t){super.populate(t),this._colspan=t.cs??1,this._rowspan=t.rs??1,this._tooltip=t.tooltip,this._displayValue=t.dv,null!=t.f?this._evaluated=!1:null!=t.v&&(this.value=t.v)}getSourceData(){const t=super.getSourceData();return this._colspan>1&&(t.cs=this._colspan),this._rowspan>1&&(t.rs=this._rowspan),null!=this.value&&(t.v=this.value),this.hasTooltip&&(t.tooltip=this._tooltip),t}createComposedStyle(t,e,i){const o=[];return t=t||this.column.style,e=e||this.row.style,null!=t&&null!=e?this.column.priority>this.row.priority?o.push(e,t):o.push(t,e):null!=t?o.push(t):null!=e&&o.push(e),null!=this.style&&o.push(this.style),null!=i&&o.push(i),o.length>0?this.model.styles.merge(...o):null}get composedStyle(){if(null===this._hasStyle){const t=this.createComposedStyle(null,null,this.model.conditionalFormats.evaluate(this));this._hasStyle=null!=t,this._composedStyle=t}return this._composedStyle}get calculatedIndent(){const t=this.composedStyle;return t?.alignment?.indent?t.alignment.indent:this.column.levelIndent&&this.row.level>0?this.row.level*this.model.options.levelIndentFactor:null}get cssStyle(){if(!1===this._hasStyle)return null;if(!this._cssStyle){const t=this.composedStyle;t&&(this._cssStyle=jy(t))}return this._cssStyle}invalidateStyle(){this._hasComment=null,this._hasStyle=null,this._composedStyle=null,this._cssStyle=null,this._sparkline=null}setStyleProperties(t){super.setStyleProperties(t),this.invalidateStyle()}removeStyleProperties(t){super.removeStyleProperties(t),this.invalidateStyle()}previewStyleProperties(t,e="cell"){const i=Object.assign({},this.createComposedStyle("column"==e?t:null,"row"==e?t:null)??{});if("cell"==e)for(const e in t)i[e]=t[e];this._hasStyle=!0,this._cssStyle=jy(i)}toString(){return this.address}}const Uy={property:"value",enabled:!0};class Gy extends(hn(Ry)){get comparer(){return this._comparer}set comparer(t){this._comparer=t}get filter(){return this._filter??(this.model.options.filters?.enabled?Uy:{enabled:!1})}set filter(t){this._filter=t}get hasFilter(){return this.filter.enabled}get sorting(){return this._sorting??this.model.options.columnSorting}set sorting(t){this._sorting=t}get width(){return this._width??this.model.options.columnWidth}set width(t){this._width=t}get levelIndent(){return this._levelIndent}set levelIndent(t){this._levelIndent=t}get levelButtons(){return this._levelButtons}set levelButtons(t){this._levelButtons=t}get priority(){return this._priority}set priority(t){this._priority=t}get address(){return iv(this.index)}get range(){return new Jm(this.index,null,this.index,null)}get hasFormula(){return!!this._formula}get formula(){return this._formula}set formula(t){super.formula=t;const e=this.index;this.model.rows.forEach((t=>t.cells[e]?.refreshFormula()))}constructor(t,e){super(t,e),null==this._priority&&(this._priority=t.options.columnPriority)}get mergedHeaders(){return this._mergedHeaders??(this._mergedHeaders=this._header?.filter((t=>t.cs>1||t.rs>1))??[])}updateMergedHeaders(){this._mergedHeaders=null}set header(t){this._mergedHeaders=null,this._header=t}get header(){if(!this._header||this._header.length<this.model.headerCount){this._header=this._header??[];for(let t=this._header.length;t<this.model.headerCount;t++)this._header.push({r:t})}return this._header}convertSourceHeader(t){return Array.isArray(t)?t.map(((t,e)=>((t=t??{r:e}).r=e,t._style=null==t.style?null:this.model.styles.add(t.style).id,t))):Z(t)?[{label:t,r:0}]:null}populate(t){super.populate(t),this._width=t.w,this._levelIndent=t.levelIndent,this._levelButtons=t.levelButtons,this._header=this.convertSourceHeader(t.header),this._sorting=t.sorting,this._filter=q(t.filter)?Object.assign({enabled:!0},t.filter):t.filter?Uy:!1===t.filter?{enabled:!1}:null,this._comparer=t.comparer,this.data=t.data,this._mergedHeaders=null,null!=t.priority&&(this._priority=t.priority)}getSourceData(){const t=super.getSourceData();return null!=this._width&&(t.w=this._width),null!=this._levelIndent&&(t.levelIndent=this._levelIndent),null!=this._levelButtons&&(t.levelButtons=this._levelButtons),null!=this._header&&(t.header=this._header),null!=this._sorting&&(t.sorting=this._sorting),null!=this._filter&&(t.filter=this._filter),null!=this.data&&(t.data=this.data),t}expand(t){super.expand(t),this.model.indexVisibleColumns()}collapse(){super.collapse(),this.model.indexVisibleColumns()}get prev(){return this.model.columns[this.index-1]}get next(){return this.model.columns[this.index+1]}get prevVisible(){const t=this.model.visibleColumnIndex[this.index];return null==t||0===t?null:this.model.visibleColumns[t-1]}get nextVisible(){const t=this.model.visibleColumnIndex[this.index];return null==t?null:this.model.visibleColumns[t+1]}calculateRealColspan(t){let e=1,i=this.nextVisible;for(;i&&i.index-this.index<t&&e<t;)++e,i=i.nextVisible;return e}cell(t){return this.model.rows[t].cell(this.index)}clearCalculatedValues(){this.model.rows.forEach((t=>{const e=t.cells[this.index];e&&this.model.calculations.refreshFormula(e)}))}}var qy;!function(t){t[t.Asc=1]="Asc",t[t.Desc=-1]="Desc"}(qy||(qy={}));const Yy={g:(t,e)=>t.value==e.value?0:t.value>e.value?1:-1,t:(t,e)=>(t.value||"").toString().localeCompare((e.value||"").toString()),s:(t,e)=>t.value==e.value?0:t.value>e.value?1:-1,m:(t,e)=>t.value==e.value?0:t.value>e.value?1:-1,n:(t,e)=>t.value-e.value,d:(t,e)=>(t.value instanceof Date?t.value.getTime():0)-(e.value instanceof Date?e.value.getTime():0),tm:(t,e)=>(t.value instanceof Date?t.value.getTime():0)-(e.value instanceof Date?e.value.getTime():0),dt:(t,e)=>(t.value instanceof Date?t.value.getTime():0)-(e.value instanceof Date?e.value.getTime():0),b:(t,e)=>t.value-e.value,h:(t,e)=>(t.value||"").localeCompare(e.value),a:()=>0},Zy={g:(t,e)=>e.value==t.value?0:e.value>t.value?1:-1,t:(t,e)=>(e.value||"").toString().localeCompare((t.value||"").toString()),s:(t,e)=>e.value==t.value?0:e.value>t.value?1:-1,m:(t,e)=>e.value==t.value?0:e.value>t.value?1:-1,n:(t,e)=>e.value-t.value,d:(t,e)=>(e.value instanceof Date?e.value.getTime():0)-(t.value instanceof Date?t.value.getTime():0),tm:(t,e)=>(e.value instanceof Date?e.value.getTime():0)-(t.value instanceof Date?t.value.getTime():0),dt:(t,e)=>(e.value instanceof Date?e.value.getTime():0)-(t.value instanceof Date?t.value.getTime():0),b:(t,e)=>e.value-t.value,h:(t,e)=>(e.value||"").localeCompare(t.value),a:()=>0},Xy=(t,e)=>t.origIndex-e.origIndex;class Qy extends EventTarget{get settings(){return this._settings}set settings(t){this._settings=t,this.colMap.clear(),this.settings.length>0&&(this.settings.forEach(((t,e)=>this.colMap.set(t.c,e))),this.applySort(),an().info(`sorting applied: ${JSON.stringify(this.settings)}`))}constructor(t,e=[]){super(),this.model=t,this.colMap=new Map,this._settings=[],this.settings=e}get(t){return this.colMap.has(t)?this.settings[this.colMap.get(t)]:null}sort(t,e=null,i=!1){let o=this.get(t);return o&&o.ord==qy.Desc&&null===e?(this.settings.splice(this.colMap.get(t),1),o=null):o?(o.ord=qy.Desc,this.settings.splice(this.colMap.get(t),1)):o={c:t,ord:qy.Asc},o&&(null!==e&&(o.ord=e),this.colMap.set(t,0),this.settings.unshift(o)),this.settings.length>this.model.options.maxSortingColumns&&this.settings.pop(),this.colMap.clear(),this.settings.forEach(((t,e)=>{t.index=e,this.colMap.set(t.c,e)})),i||(this.settings.length>0?this.applySort():this.resetSort()),o}applySort(){const t=this.model,e=this.settings.map((e=>{const i=t.columns[e.c];return i?i.comparer?e.ord==qy.Asc?i.comparer:(t,e)=>-i.comparer(t,e):e.ord==qy.Asc?Yy[i.type??"t"]:Zy[i.type??"t"]:(an().warn(`Column sorting: Column with index ${e.c} not found`),null)})).filter((t=>t)),i=e.length;let o,n,r;t.rowRoot.sort(((t,s)=>{if(!1===t.sortable||!1===s.sortable)return t.origIndex-s.origIndex;for(n=0;n<i;n++)if(r=this.settings[n].c,o=e[n](t.cell(r),s.cell(r)),0!=o)return o;return 0})),t.indexRowsByTree()}resetSort(){this.settings=[],this.colMap.clear(),this.model.rowRoot.sort(Xy),this.model.indexRowsByTree()}persistSort(){this.model.rows.forEach(((t,e)=>t.origIndex=e))}}class Ky{get properties(){return this._properties}set properties(t){this._properties=t}constructor(t){t&&this.pupulate(t)}pupulate(t){this.author=t.author,this.text=t.text,this.date=t.date?new Date(t.date):null,this.data=t.data,this.readOnly=!!t.readOnly,this._properties=t.props}getSourceData(){const t={};return this._properties&&(t.props=this._properties),this.author&&(t.author=this.author),this.text&&(t.text=this.text),this.data&&(t.data=this.data),null!==this.readOnly&&(t.readOnly=this.readOnly),this.date&&(t.date=Lo("en-US")(this.date,"yyyy-MM-dd HH:mm:ss")),t}}class Jy{constructor(t,e){this.model=t,this._commentMap=new Map,this.has=t=>this._commentMap.has(t),this.delete=t=>this._commentMap.delete(t),this.cleanCell=t=>{this.has(t)&&this._commentMap.set(t,this.get(t).filter((t=>(t.text??"").length>0||null!=t.data)))},this.get=t=>(this.has(t)||this._commentMap.set(t,[]),this._commentMap.get(t)),this.set=(t,e)=>{this._commentMap.set(t,e),this.cleanCell(t)},e&&this.populate(e)}populate(t){t.forEach((t=>{const e=t.a1||new Jm(t.c,t.r).A1;this._commentMap.has(e)||this._commentMap.set(e,[]),this._commentMap.get(e).push(new Ky(t))})),this._commentMap.forEach((t=>{t.sort(((t,e)=>(e.date?e.date.getTime():0)-(t.date?t.date.getTime():0)))}))}shift(t){Array.from(this._commentMap.keys()).forEach((e=>{const i=Jm.fromA1(e);i.shift(t),i.A1!=e&&(this._commentMap.set(i.A1,this._commentMap.get(e)),this._commentMap.delete(e))}))}}class tw{get tokenizer(){return this._tokenizer}get dependencies(){return this._dependencies}get formulas(){return this._formulas}constructor(t){this.model=t,this._tokenizer=new Xm,this._formulas=new Map,this._dependencies=new cw(t),this.context=new Sy(t)}createFormula(t){const e=new vv(t.formula,this.tokenizer);return this._formulas.set(t.address,e),t.hasOwnFormula&&(t.formula=e.createFormulaString()),this.createDependecies(t),e}createDependecies(t){const e=t.address;if(this.formulas.has(e)){const i=this.formulas.get(e);i.ranges.forEach((([t,i,o])=>this._dependencies.add(e,i.A1,o))),i.cells.forEach((([t,i,o])=>this._dependencies.add(e,i.A1,o))),i.variables.forEach((([i,o])=>{const n=this.model.getCellByName(o,t.range);n&&this._dependencies.add(e,n.address,null)}))}return this}refreshFormula(t){return t.refreshFormula(),this.formulas.delete(t.address),this.clearDependecies(t),this}updateDependencies(t){return this.clearDependecies(t).getFormula(t),this}getFormula(t){return this._formulas.has(t.address)?this._formulas.get(t.address):this.createFormula(t)}refresh(){this.dependencies.clear(),this._formulas.clear()}clearDependecies(t){const e=t.address;return this.dependencies.clearCellDependecies(e),this.formulas.delete(e),this}evaluateFormula(t,e){return this.context.currentCell=e,t.fn(this.context,{cell:e,formula:t})}evaluateExpression(t,e){this.context.currentCell=e;const i=new vv(t,this.tokenizer);return i.fn(this.context,{cell:e,formula:i})}evaluate(t,e){if(!t)return null;let i=null;if(t.hasFormula){const o=this.getFormula(t);try{t.clearError(),this.context.currentCell=t,i=o.fn(this.context,{cell:t,formula:o}),Array.isArray(i)?(e||this.model.spillValues({cell:t,values:i}).range,i=i.length>0&&i[0].length>0?i[0][0]:null,e&&(t.value=i)):t.value=i}catch(e){t.error=function(t){return t instanceof RangeError?"Maximum call stack size exceeded"==t.message?"infinite loop":t.message:t.toString()}(e)}}else i=t.value;return i}evaluateAll(){this.model.rows.forEach((t=>this.model.columns.forEach(((e,i)=>t.cell(i).evaluate()))))}calculateViewport(t){const e=[];return t.rows.forEach((t=>t.cells.forEach((t=>{if(t.hasFormula){if(!t.hasValue&&(this.evaluate(t),t.spillRange))for(const i of this.model.getRangeIterator(t.spillRange))e.push(i);e.push(t)}})))),e}shift(t){this.getFormulaCells().forEach((e=>{e.formula=this.getFormula(e).shift(t).createFormulaString(!1),this.updateDependencies(e)}));const e=this.model.name;return this.dependencies.sheetDependants.forEach((i=>{const o=this.model.getConnectedModel(i);o?.calculations.getFormulaCells().forEach((i=>{const n=o.calculations.getFormula(i);n.hasSheetReference(e)&&(i.formula=n.shift(t).createFormulaString(!1),o.calculations.updateDependencies(i))}))})),this}getFormulaCells(){const t=this.model,e=[];let i;const o=t.rows.length,n=t.columns.length;for(let r=0;r<o;r++){i=t.rows[r];for(let t=0;t<n;t++)i.hasCellFormula(t)&&e.push(i.cell(t))}return e}renameSheet(t,e){let i=!1;return this.dependencies.renameSheet(t,e),this.getFormulaCells().forEach((o=>{const n=this.getFormula(o);n.renameSheet(t,e)&&(o.formula=n.createFormulaString(),this.refreshFormula(o),i=!0)})),i}invalidateCellDependants(t){const e=[];return this.dependencies.getDependants(t.range).forEach((([t,i])=>{e.push([t,i]),t.invalidateValue()})),e}invalidateDependants(t){const e=new Map,i=new Map;for(const i of t)this.invalidateCellDependants(i).forEach((([t,i])=>e.set(t,i)));e.forEach(((t,e)=>i.set(e,t)));for(const i of t)e.set(i,null);return e.forEach(((t,e)=>{this.model.sparklines.dependencies.getDependants(e.range).forEach((([t,e])=>{i.set(t,e)})),this.model.conditionalFormats.dependencies.getDependants(e.range).forEach((([t,e])=>{this.model.conditionalFormats.invalidateExtremes(t),t.invalidateStyle(),i.set(t,e)}))})),i}}const ew="#ff0000",iw="#fcd53f",ow="#00bb5e",nw="#555555",rw=new Map([["3Arrows",[{icon:["fas","down"],color:ew},{icon:["fas","right"],color:iw},{icon:["fas","up"],color:ow}]],["3ArrowsGray",[{icon:["fas","down"],color:nw},{icon:["fas","right"],color:nw},{icon:["fas","up"],color:nw}]],["3Flags",[{icon:["fas","flag-pennant"],color:ew},{icon:["fas","flag-pennant"],color:iw},{icon:["fas","flag-pennant"],color:ow}]],["3TrafficLights1",[{icon:["fas","circle"],color:ew},{icon:["fas","circle"],color:iw},{icon:["fas","circle"],color:ow}]],["3TrafficLights2",[{icon:["fas","square-o"],color:ew},{icon:["fas","square-o"],color:iw},{icon:["fas","square-o"],color:ow}]],["3Signs",[{icon:["fas","square"],rotation:45,color:ew},{icon:["fas","triangle"],color:iw},{icon:["fas","circle"],color:ow}]],["3Symbols",[{icon:["fas","circle-xmark"],color:ew},{icon:["fas","circle-exclamation"],color:iw},{icon:["fas","circle-check"],color:ow}]],["3Symbols2",[{icon:["fas","xmark"],color:ew},{icon:["fas","exclamation"],color:iw},{icon:["fas","check"],color:ow}]],["3Stars",[{icon:["fal","star"],color:iw},{icon:["fas","star-half-stroke"],color:iw},{icon:["fas","star"],color:iw}]],["3Triangles",[{icon:"caret-down",color:ew},{icon:"dash",color:iw},{icon:"caret-up",color:ow}]],["4Arrows",[{icon:["fas","down"],color:ew},{icon:["fas","down-right"],color:iw},{icon:["fas","up-right"],color:iw},{icon:["fas","up"],color:ow}]],["4ArrowsGray",[{icon:["fas","down"],color:nw},{icon:["fas","down-right"],color:nw},{icon:["fas","up-right"],color:nw},{icon:["fas","up"],color:nw}]],["4RedToBlack",[{icon:["fas","circle"],color:"#000000"},{icon:["fas","circle"],color:"#b1b1b1"},{icon:["fas","circle"],color:"#edb2a3"},{icon:["fas","circle"],color:ew}]],["4Rating",[{icon:"signal-bars-weak",color:"#4a7db1"},{icon:"signal-bars-fair",color:"#4a7db1"},{icon:"signal-bars-good",color:"#4a7db1"},{icon:["fas","signal-bars"],color:"#4a7db1"}]],["4TrafficLights",[{icon:["fas","circle"],color:"#000000"},{icon:["fas","circle"],color:ew},{icon:["fas","circle"],color:iw},{icon:["fas","circle"],color:ow}]],["5Arrows",[{icon:["fas","down"],color:ew},{icon:["fas","down-right"],color:iw},{icon:["fas","right"],color:iw},{icon:["fas","up-right"],color:iw},{icon:["fas","up"],color:ow}]],["5ArrowsGray",[{icon:["fas","down"],color:nw},{icon:["fas","down-right"],color:nw},{icon:["fas","right"],color:nw},{icon:["fas","up-right"],color:nw},{icon:["fas","up"],color:nw}]],["5Rating",[{icon:["fal","signal-bars"]},{icon:["fal","signal-bars-weak"],color:"#4a7db1"},{icon:["fal","signal-bars-fair"],color:"#4a7db1"},{icon:["fal","signal-bars-good"],color:"#4a7db1"},{icon:["fas","signal-bars"],color:"#4a7db1"}]],["5Quarters",[{icon:["fal","circle"],color:"#505050"},{icon:["fas","circle-quarter-stroke"],color:"#505050"},{icon:["fas","circle-half-stroke"],color:"#505050"},{icon:["fas","circle-three-quarters-stroke"],color:"#505050"},{icon:["fas","circle"],color:"#505050"}]]]),sw=(t,e)=>{const i=rw.get(t);return i?i[e]:null};class aw{get dependencies(){return this._dependencies}constructor(t,e){this.model=t,this.formats=[],this.cellFormatMap=new Map,this.extremes=new Map,this._dependencies=new cw(t),e&&this.populate(e)}populate(t){t.forEach((t=>{try{this.add(t)}catch(e){an().error(`conditional format error: ${JSON.stringify(t)}`,e)}}))}refresh(){this.dependencies.clear(),this.cellFormatMap.clear(),this.extremes.clear(),this.formats.forEach((t=>this.initConditionalFormat(t)))}clearCellDependecies(t){const e=t.address;return this.dependencies.clearCellDependecies(e),this.cellFormatMap.get(e).forEach((t=>({cf:t.cf}))),this}getExtremes(t){if(!this.extremes.has(t.key)){let e=1/0,i=-1/0;t.ranges.forEach((t=>{for(const o of this.model.getValuesInRange(t))for(const t of o)null!=t&&(isNaN(t)||(e=Math.min(e,t),i=Math.max(i,t)))})),this.extremes.set(t.key,[e,i])}return this.extremes.get(t.key)}invalidateExtremes(t){this.cellFormatMap.get(t.address).forEach((t=>this.extremes.delete(t.cf.key)))}evaluateScaleFormat(t,e){const i=t.value;if(null==i)return null;const[o,n]=this.getExtremes(e.cf);let r;const s=(i-o)/(n-o);if(e.cf.cmid?.color)r=.5==s?"#"+e.cf.cmid.color:s>.5?bn("#"+e.cf.cmid.color,"#"+e.cf.cmax.color,2*(s-.5)):bn("#"+e.cf.cmin.color,"#"+e.cf.cmid.color,2*s);else{if(!e.cf.cmin?.color||!e.cf.cmax?.color)return null;r=bn("#"+e.cf.cmin.color,"#"+e.cf.cmax.color,s)}return{color:yn(r).substring(1),fgColor:r.substring(1)}}evaluateBarFormat(t,e){const i=t.value;if(null==i)return null;const o=this.getExtremes(e.cf);let n=o[0];const r=o[1],s=n<0;s||(n-=.1*(r-n));const a=Math.round(100*(i-n)/(r-n));e.initialized||(e.initialized=!0,e.cf.ranges.forEach((e=>this._dependencies.add(t.address,e.A1,null))));const l=[];if(s){const t=Math.round(-100*n/(r-n));i>=0?(l.push(`#00000000 ${t}%`),l.push(`#${e.cf.color} ${t}%`),l.push(`#${e.cf.color} ${a}%`),l.push(`#00000000 ${a}%`)):(l.push(`#00000000 ${a}%`),l.push(`#ff0000 ${a}%`),l.push(`#ff0000 ${t}%`),l.push(`#00000000 ${t}%`))}else l.push(`#${e.cf.color} ${a}%`),l.push(`#00000000 ${a}%`);return{cssStyle:{backgroundClip:"padding-box",backgroundImage:`linear-gradient(90deg, ${l.join(",")})`}}}evaluateFormulaFormat(t,e){if(!e.initialized&&e.cf.condition){e.initialized=!0;const i=t.address,o=new vv(e.cf.condition,this.model.calculations.tokenizer);e.f=o.shift({index:0,offset:t.c-e.cf.firstCell.c1,direction:"right"}).shift({index:0,offset:t.r-e.cf.firstCell.r1,direction:"down"}),o.cells.forEach((t=>this._dependencies.add(i,t[1].A1,t[2]))),o.ranges.forEach((t=>this._dependencies.add(i,t[1].A1,t[2]))),o.variables.forEach((([e,o])=>{const n=this.model.getCellByName(o,t.range);n&&this._dependencies.add(i,n.address,null)}))}if(e.f&&!this.model.calculations.evaluateFormula(e.f,t))return null;const i={...e.cf.style};return i.color||wn(yn(xn(e.cf.style.fgColor))),i}evaluateIconFormat(t,e){const i=t.value;if(null==i)return null;const[o,n]=this.getExtremes(e.cf);let r;for(let t=e.cf.thresh.length-1;t>=0;t--){const s=e.cf.thresh[t];if("percent"===s.t){if(null==r&&(r=100*(i-o)/(n-o)),r>=s.v)return{icon:sw(e.cf.v,t)}}else if("num"===s.t&&i>=s.v)return{icon:sw(e.cf.v,t)}}return null}evaluate(t){const e=t.address,i=this.cellFormatMap.get(e);if(!i)return null;let o=null,n=null;for(const e of i){try{switch(e.cf.type){case"formula":n=this.evaluateFormulaFormat(t,e);break;case"scale":n=this.evaluateScaleFormat(t,e);break;case"bar":n=this.evaluateBarFormat(t,e);break;case"icon":n=this.evaluateIconFormat(t,e);break;default:n=null}}catch(t){an().error(`Conditional format error: ${JSON.stringify(e)}`,t)}if(n&&(o=o?{...o,...n}:n,e.cf.stop))break}return o}initConditionalFormat(t){return t.firstCell=null,t.ranges.forEach((e=>{for(const i of new yw(e.intersect(this.model.gridRange))){const e=i.A1;"formula"===t.type&&(t.firstCell||(t.firstCell=i,t.formula=t.condition?new vv(t.condition,this.model.calculations.tokenizer):null)),(this.cellFormatMap.get(e)||this.cellFormatMap.set(e,[]).get(e)).push({cf:t})}})),t}add(t){const e={key:t.ranges,ranges:Jm.fromA1s(t.ranges),type:t.type||"formula",firstCell:null,formula:null,style:t.style?this.model.styles.add(t.style):null,condition:t.condition,stop:!!t.stop,cmin:t.cmin,cmid:t.cmid,cmax:t.cmax,color:t.color,v:t.v,thresh:t.thresh};this.formats.push(this.initConditionalFormat(e))}getSourceData(){return this.formats.map((t=>({type:t.type,ranges:Jm.toA1s(t.ranges),style:t.style,condition:t.condition,stop:t.stop,cmin:t.cmin,cmid:t.cmid,cmax:t.cmax,color:t.color,v:t.v,thresh:t.thresh})))}}function lw(t,e,i){t.forEach((t=>t.forEach((t=>{t[1]==e&&(t[1]=i)}))))}class cw{get cellDependencies(){return this._cellDependencies}get cellDependants(){return this._cellDependants}get rangeDependencies(){return this._rangeDependencies}get rangeDependants(){return this._rangeDependants}get sheetDependencies(){return this._sheetDependencies}get sheetDependants(){return this._sheetDependants}constructor(t){this.model=t,this._cellDependencies=new Map,this._cellDependants=new Map,this._rangeDependencies=new Map,this._rangeDependants=new Map,this._sheetDependencies=new Map,this._sheetDependants=new Map}clear(){this._cellDependants.clear(),this._cellDependencies.clear(),this._rangeDependencies.clear(),this._rangeDependants.clear()}clearCellDependecies(t){return this._cellDependencies.has(t)&&this._cellDependencies.delete(t),this._rangeDependencies.has(t)&&this._rangeDependants.delete(t),this}has(t){return this._cellDependencies.has(t)||this._rangeDependencies.has(t)}add(t,e,i){const o=Jm.fromA1(t).removeAnchors(),n=Jm.fromA1(e).removeAnchors();e=n.A1;const r=n.isRange,s=r?this._rangeDependencies:this._cellDependencies;let a=null;if((s.has(t)?s.get(t):s.set(t,new Map).get(t)).set(e,[n,i]),i){const t=this.model.getConnectedModel(i);t&&(t.calculations.dependencies.sheetDependants.set(this.model.name,this.model.name),this.sheetDependencies.set(i,i),a=r?t.calculations.dependencies.rangeDependants:t.calculations.dependencies.cellDependants),i=this.model.name}else a=r?this._rangeDependants:this._cellDependants;a&&(a.has(e)||a.set(e,new Map),a.get(e).set(t,[o,i]))}getDependants(t,e=null){const i=t.A1;return e=e??new Map,this._cellDependants.has(i)&&this._cellDependants.get(i).forEach((([t,o])=>{if(e.has(t))return;const n=e.set(t,[(o?this.model.getConnectedModel(o):this.model).getCellByRange(t),o]);t.A1!=i&&this.getDependants(t,n)})),this._rangeDependants.forEach(((i,o)=>{Jm.fromA1(o).contains(t)&&i.forEach((([t,i])=>{e.has(t)||(e.delete(t),this.getDependants(t,e.set(t,[(i?this.model.getConnectedModel(i):this.model).getCellByRange(t),i])))}))})),e}renameSheet(t,e){this._sheetDependants.has(t)&&(this._sheetDependants.delete(t),this._sheetDependants.set(e,e)),this._sheetDependencies.has(t)&&(this._sheetDependencies.delete(t),this._sheetDependencies.set(e,e)),lw(this._cellDependants,t,e),lw(this._cellDependencies,t,e),lw(this._rangeDependants,t,e),lw(this._rangeDependencies,t,e)}}const hw=(t,e)=>{const i=new RegExp(`${ht(t)}`,"ig");return t=>(i.lastIndex=0,i.test(at((t[e]??"").toString())))},dw=(t,e)=>i=>!!i[e]===t,uw=(t,e)=>{const i=t.map((t=>t.key?.toString()));return t=>null!=t[e]&&i.includes(t[e].toString())},pw=(t,e)=>t=>!1,gw=(t,e,i)=>(i=i??"value","b"===t?dw(e,i):"s"===t&&Array.isArray(e)?uw(e,"value"):"s"===t?hw(e?.toString(),"formattedValue"):"m"===t&&Array.isArray(e)?pw(e,i):hw(e?.toString(),"d"===t?"formattedValue":i));class fw extends Event{constructor(){super("filter",{bubbles:!1,cancelable:!0,composed:!0})}}class mw extends EventTarget{constructor(t){super(),this.model=t,this.settings=new Map,this.custom=!1}get(t){return this.settings.has(t)?this.settings.get(t):null}filter(t,e=!0){null===t.term||""===t.term?this.settings.delete(t.c):this.settings.set(t.c,t),this.custom||(this.settings.size>0?this.applyFilter(!1):this.resetFilter(!1)),e&&this.dispatchEvent(new fw)}applyFilter(t=!0){const e=[];this.settings.forEach(((t,i)=>{const o=this.model.columns[i];e.push({c:i,matcher:gw(o.type,t.term,o.filter?.property)})}));const i=e.length,o=this.model.options.filters?.includeParents??!0,n=this.model.options.filters?.includeChildren??!0,r=new Set;this.model.rows.forEach((t=>{const s=r.has(t.index);(t=>{if(!t.filterable)return!0;for(let o=0;o<i;o++)if(!e[o].matcher(t.cell(e[o].c)))return!1;return!0})(t)?(t.filterState=ln.Matched,o&&t.walkUp((t=>{if(r.has(t.index)&&t.filterState>0)return!1;t.filterState=ln.ChildMatched,r.add(t.index)})),n&&t.walk((t=>{if(r.has(t.index)&&t.filterState>0)return!1;t.filterState=ln.ParentMatched,r.add(t.index)}))):s||(t.filterState=ln.Filtered),r.add(t.index)})),this.model.indexRows(),t&&this.dispatchEvent(new fw)}resetFilter(t=!0){this.settings.clear(),this.model.rows.forEach((t=>t.filterState=ln.Matched)),this.model.indexRows(),t&&this.dispatchEvent(new fw)}}class vw{get dependencies(){return this._dependencies}constructor(t,e){this.model=t,this.map=new Map,this.groups=new Map,this.extremes=new Map,this.maxIndex=0,this.updateRangeMap=!1,this._dependencies=new cw(t),this.populate(e)}populate(t){t?.forEach((t=>{try{this.add(Jm.fromA1(t.location),Array.isArray(t.data)?t.data.map((t=>[Jm.fromA1(t)])):t.data.split(",").map((t=>[Jm.fromA1(t)])),et({},Hm.DEFAULT_SPARKLINE_OPTIONS,t.options))}catch(e){this.model.logger.error(`sparkline error: ${JSON.stringify(t)}`,e)}}))}getSourceData(){const t=[];return this.groups.forEach((e=>{t.push({location:e.locRange.A1,data:e.dataRanges.map((t=>t[0].A1)).join(","),options:{minValue:e.minValue,maxValue:e.maxValue,type:e.type,style:e.style,marker:e.marker}})})),t}has(t){return this.map.has(t)}get(t){return this.map.get(t)}createDependencies(t){this.map.get(t)[1].forEach((e=>this._dependencies.add(t,e[0].A1,e[1])))}updateRangeMaps(){this.dependencies.clear(),this.map.clear(),this.groups.forEach(((t,e)=>this.createRangeMap(e,t.locRange,t.dataRanges)))}getValues(t){this.updateRangeMap&&this.updateRangeMaps();const e=this.map.get(t),i=e[1][0][1]?this.model.getConnectedModel(e[1][0][1]):this.model;return this._dependencies.has(t)||this.createDependencies(t),e[1].flatMap((t=>i.getValuesInRange(t[0])[0]))}getExtremes(t){const e=this.map.get(t),i=e[1][0][1]?this.model.getConnectedModel(e[1][0][1]):this.model,o=this.groups.get(e[0]);let n,r,s,a;return null==o.minValue||Z(o.minValue)?"auto"==(o.minValue||"auto")?(n=n??st(...e[1].map((t=>i.getValuesInRange(t[0])))),s=n[0]):(this.extremes.has(e[0])||this.extremes.set(e[0],st(...o.dataRanges.map((t=>i.getValuesInRange(t[0]))))),r=this.extremes.get(e[0]),s=r[0]):s=o.minValue,null==o.maxValue||Z(o.maxValue)?"auto"==(o.maxValue||"auto")?(n=n??st(...e[1].map((t=>i.getValuesInRange(t[0])))),a=n[1]):(this.extremes.has(e[0])||this.extremes.set(e[0],st(...o.dataRanges.map((t=>i.getValuesInRange(t[0]))))),r=this.extremes.get(e[0]),a=r[1]):a=o.maxValue,[s,a]}createRangeMap(t,e,i){e=e.intersect(this.model.gridRange);const o=i[0][0].size,n=e.size;if(n.columns>1&&n.rows>1)return void this.model.logger?.error(`invalid sparkline location range: ${e.A1}`);let r=!1;if(r=1==n.columns&&1==n.rows?o.rows>1:n.columns>1,r)for(let o=e.c1;o<=e.c2;o++)this.map.set(new Jm(o,e.r1).A1,[t,i.map((([t,i])=>[new Jm(t.c1+o-e.c1,t.r1,t.c1+o-e.c1,t.r2),i]))]);else for(let o=e.r1;o<=e.r2;o++)this.map.set(new Jm(e.c1,o).A1,[t,i.map((([t,i])=>[new Jm(t.c1,t.r1+o-e.r1,t.c2,t.r1+o-e.r1),i]))])}add(t,e,i){const o=++this.maxIndex;t&&e&&this.createRangeMap(o,t,e),this.groups.set(o,Object.assign({dataRanges:e,locRange:t},JSON.parse(JSON.stringify(Hm.DEFAULT_SPARKLINE_OPTIONS)),i))}update(t,e,i,o){const n=this.groups.get(t);Object.assign(n,{dataRanges:i,locRange:e},o),this.updateRangeMap=!0}delete(t){this.groups.delete(t),this.updateRangeMap=!0}shift(t){this.groups.forEach((e=>{e.dataRanges.forEach((([e])=>e.shift(t))),e.locRange.shift(t)})),this.updateRangeMaps()}}class bw extends Jm{constructor(t,e,i=!1){super(e.c1,e.r1,e.c2,e.r2),this.model=t,this.initializedOnly=i,this.r=0,this.c=-1,this.done=!1}[Symbol.iterator](){return this}nextInitialized(){let t;for(;!this.done&&!t;)this.c<this.size.columns-1?this.c++:this.r<this.size.rows-1&&(this.c=0,this.r++),t=this.model.rows[this.r].cells[this.c],this.done=this.c>=this.size.columns-1&&this.r>=this.size.rows-1;return t}next(){if(this.done)return{done:!0};this.c<this.size.columns-1?this.c++:this.r<this.size.rows-1&&(this.c=0,this.r++),this.done=this.c>=this.size.columns-1&&this.r>=this.size.rows-1;const t=this.model.rows[this.r+this.r1],e=this.c+this.c1,i=this.initializedOnly&&!t.isCellInitialized(e)?this.nextInitialized():t?.cell(e);return i?{done:!1,value:i}:{done:!0}}forEach(t){let e;for(;e=this.next().value;)t(e)}}class yw extends Jm{constructor(t){super(t.c1,t.r1,t.c2,t.r2),this.r=0,this.c=-1,this.done=!1}[Symbol.iterator](){return this}next(){return this.done?{done:!0}:(this.c<this.size.columns-1?this.c++:this.r<this.size.rows-1&&(this.c=0,this.r++),this.done=this.c==this.size.columns-1&&this.r==this.size.rows-1,{done:!1,value:new Jm(this.c+this.c1,this.r+this.r1)})}}class ww{constructor(t,e){this.model=t,this.names=new Map,this.rangeMap=new Map,e&&this.populate(e)}populate(t){t.forEach((({name:t,ref:e})=>this.set(t,q(e)?Jm.fromCoords(e):Jm.fromA1(e))))}set(t,e){this.names.set(t,e),this.rangeMap.set(e.A1,t)}delete(t){const e=this.names.get(t);e&&(this.rangeMap.delete(e.A1),this.names.delete(t))}findCellByName(t){let e;const i=this.model.rows,o=this.model.columns.length;for(let n=0;n<i.length;n++){e=i[n];for(let i=0;i<o;i++)if(e.hasCellName(i)){const o=e.cell(i);if(o.name==t)return o.range}}return null}getCellByName(t,e){const i=this.names.get(t)??this.findCellByName(t);return i?i.isColumn?this.model.rows.length>e.r1?this.model.columns[i.c1].cell(e.r1):null:i.isRow?this.model.columns.length>e.c1?this.model.rows[i.r1].cell(e.c1):null:this.model.rows[i.r1].cell(i.c1):null}getRangeByName(t,e=!0){const i=this.names.get(t);return e?i?.intersect(this.model.gridRange):i}shift(t){this.names.forEach(((e,i)=>{const o=e.A1;e.shift(t);const n=e.A1;o!=n&&(this.rangeMap.delete(o),this.rangeMap.set(n,i))}))}}function xw(t,e=null){const i=et({},Hm.DEFAULT_OPTIONS,e,Pn(t,e));return i.numberFormat?i.numberFormatter=Go(i.locale,i.numberFormat):i.numberFormatter||(i.numberFormatter=Go(i.locale)),i.dateFormat?i.dateFormatter=Lo(i.locale,i.dateFormat):i.dateFormatter||(i.dateFormatter=Lo(i.locale)),i.columnSorting&&(i.sorting=i.sorting||{enabled:!0}),!1===i.filters&&(i.filters={enabled:!1}),i.filters=Object.assign({},Rm,i.filters),!1===i.rowTree&&(i.rowTree={enabled:!1}),i.rowTree=Object.assign({},Im,i.rowTree),!1===i.columnTree&&(i.columnTree={enabled:!1}),i.columnTree=Object.assign({},Im,i.columnTree),i}class kw extends(hn(Ry)){get cells(){return this._cells}get data(){return this._data}set data(t){this._data=t}get height(){return this._height??this.model.options.rowHeight}set height(t){this._height=t}get priority(){return this._priority}set priority(t){this._priority=t}get address(){return tv(this.index)}get range(){return new Jm(null,this.index,null,this.index)}get hasFormula(){return!!this._formula}get formula(){return this._formula}set formula(t){super.formula=t,this.model.columns.forEach((t=>this.cell(t.index).refreshFormula()))}get values(){return this.model.columns.map((t=>this.cell(t.index).value))}cell(t,e){if(this.model.options.singleCellModel)return this._singleCell||(this._singleCell=new Wy(this.model,{c:t,r:this.index})),this._singleCell.row=this,this._singleCell.column=this.model.columns[t],this._singleCell;let i=this._cells[t];if((e||!i)&&this.model.columns[t]){if(i=new Wy(this.model,e??{c:t,r:this.index}),this._data){const e=this.model.columns[t].data;null!=e&&(q(this._data[e])?i.populate(this._data[e]):i.hasValue||(i.value=this._data[e]))}i.name&&this.model.names.set(i.name,i.range),this._cells[t]=i}return i}constructor(t,e){super(t,e),this.isCellInitialized=t=>!!this.cells[t],this._cells=[],null==this._priority&&(this._priority=t.options.rowPriority)}populate(t){super.populate(t),this._height=t.h??this.model.options.rowHeight,this._data=t.data,null!=t.priority&&(this._priority=t.priority)}getSourceData(){const t=super.getSourceData();return null!=this._height&&this._height!=this.model.options.rowHeight&&(t.h=this._height),t}expand(t){super.expand(t),this.model.indexVisibleRows()}collapse(){super.collapse(),this.model.indexVisibleRows()}get prev(){return this.model.rows[this.index-1]}get next(){return this.model.rows[this.index+1]}get prevVisible(){let t=this.prev;for(;t&&!t.visible;)t=t.prev;return t}get nextVisible(){let t=this.next;for(;t&&!t.visible;)t=t.next;return t}hasCellFormula(t){return this.cells[t]&&this.cells[t].hasFormula||this._data&&this._data[this.model.columns[t].data]&&this._data[this.model.columns[t].data].f}hasCellName(t){return this.cells[t]&&null!=this.cells[t].name||this._data&&this._data[this.model.columns[t].data]&&null!=this._data[this.model.columns[t].data].name}insertColumns(t,e,i=!1){let o;const n=this.model.columns.length,r=this.model.calculations;if(i)for(let i=0;i<n;i++)this.hasCellFormula(i)&&(o=this.cell(i),o.formula=r.getFormula(o).shift({index:t,offset:e,direction:"right"}).createFormulaString(!1));t<this.cells.length&&this.cells.splice(t,0,...Array(e).fill(null))}deleteColumns(t,e,i=!1){let o;const n=this.model.columns.length,r=this.model.calculations;if(i)for(let i=0;i<n;i++)this.hasCellFormula(i)&&(o=this.cell(i),o.formula=r.getFormula(o).shift({index:t,offset:e,direction:"left"}).createFormulaString(!1));return t<this.cells.length?this.cells.splice(t,e):null}clearCalculatedValues(){this.cells.forEach((t=>t&&this.model.calculations.refreshFormula(t)))}}var Cw=i(4418),Mw=i.n(Cw);const _w=t=>t?"1":"0",Sw=t=>null==t?"_":t,Ew=t=>null==t?"_":t.toString(),zw=t=>null==t?"_":JSON.stringify(t),Lw=t=>Sw(t&&t.color?t.color:"_")+Sw(t&&t.style?t.style:"_"),Rw=t=>Sw(t?t.horizontal:null)+Sw(t?t.vertical:null)+Sw(t?t.horizontal:null)+Ew(t?t.indent:null)+_w(t?t.wrapText:null)+Ew(t?t.textRotation:null),Iw=t=>Mw()("s_"+_w(t.bold)+_w(t.italic)+_w(t.underline)+Ew(t.sz)+Sw(t.font)+Sw(t.color)+Lw(t.top)+Lw(t.right)+Lw(t.bottom)+Lw(t.left)+Sw(t.patternType)+Sw(t.fgColor)+Sw(t.bgColor)+Rw(t.alignment)+Ew(t.angle)+zw(t.stops)+_w(t.hidden)+_w(t.editable)+zw(t.cssStyle)+zw(t.icon));function Hw(t){const e={...t};return delete e.id,delete e.hash,e}class Tw{constructor(t){this.model=t,this._count=0,this.hashmap=new Map,this.map=new Map}add(t){if(!isNaN(t))return this.get(t);const e=this.model.options.cssStyles?Vy(t):t,i=e.hash?e.hash:Iw(e);return this.hashmap.has(i)?this.map.get(this.hashmap.get(i)):(null==e.id&&(e.id=this._count),this._count=Math.max(e.id+1,this._count+1),e.hash=i,this.hashmap.set(i,e.id),this.map.set(e.id,e),e)}populate(t){t.forEach((t=>this.add(t)))}get(t){return this.map.has(t)?this.map.get(t):null}remove(t){const e="object"==typeof t?t:this.map.get(t);this.hashmap.delete(e.hash),this.map.delete(e.id)}merge(...t){const e=Object.assign({},...t.map((t=>q(t)?t:this.get(t))));return this.add(Hw(e))}duplicate(t,e){const i=this.get(t);return this.add(Hw({...i,...e}))}set(t,e){let i=this.map.has(t)?this.map.get(t):{};for(const t in e)i[t]=e[t];return i=i.id?i:this.add(i),i}unset(t,e){if(this.map.has(t)){const i=this.map.get(t);for(const t of e)delete i[t]}}getSourceData(){return Array.from(this.map.values())}clean(){const t=new Map(Array.from(this.map.entries()).map((([t])=>[t,0])));this.model.columns.forEach((e=>{const i=t.get(e.style);null!=i&&t.set(e.style,i+1)})),this.model.rows.forEach((e=>{const i=t.get(e.style);null!=i&&t.set(e.style,i+1),e.cells.forEach((e=>{const i=t.get(e.style);null!=i&&t.set(e.style,i+1)}))})),t.forEach(((t,e)=>{0==t&&this.remove(e)}))}}function Aw(t,e,i){const o="rows"==i?e.rows:e.columns,n=function(t){const e=new Map;for(const i of t)e.has(i.level)||e.set(i.level,[]),e.get(i.level).push(i);return e}(o);for(const i of t){let t;if(t=i.index>-1?[o[i.index]]:i.level>-1?n.get(i.level):o,i.name){const e=i.name instanceof RegExp?i.name:new RegExp(ht(i.name));t=t.filter((t=>e.test(t.name)))}t.forEach((t=>{i.type?e.conditionalFormats.add(Object.assign({ranges:`${t.address}:${t.address}`},i)):t.style=e.styles.add(i.style).id}))}}function Ow(t,e){!function(t,e){for(const i of t)if(i.type)e.conditionalFormats.add(Object.assign({ranges:"A:"+e.columns[e.columns.length-1].address},i));else for(const t of e.columns)null==t.style&&(t.style=e.styles.add(i.style).id)}(t.cells??[],e),Aw(t.columns??[],e,"columns"),Aw(t.rows??[],e,"rows")}const $w=["index","name","rows","columns","cells","options","sparklines","rules","comments","styles","names","props","tab","theme"];class Dw{get comments(){return this._comments}get calculations(){return this._calculations}get names(){return this._names}get sparklines(){return this._sparklines}get conditionalFormats(){return this._conditionalFormats}get mergedHeaders(){return this._mergedHeaders}get mergedCells(){return this._mergedCells}get hiddenCells(){return this._hiddenCells}get hasFilter(){return this._filter}get hasRowTree(){return this._maxRowLevel>0}get hasRowTreeEnabled(){return this.hasRowTree&&this.options.rowTree.enabled}get maxRowLevel(){return this._maxRowLevel}get hasColumnTree(){return this._maxColumnLevel>0}get hasColumnTreeEnabled(){return this.hasColumnTree&&this.options.columnTree.enabled}get maxColumnLevel(){return this._maxColumnLevel}get headerCount(){return this._headerCount}get columnHeaderCount(){return this.headerCount+(this.hasColumnTreeEnabled?1:0)+(this.hasFilter?1:0)}get properties(){return this._properties}set properties(t){this._properties=t}constructor(t,e,i){this.otherModels={},this.styles=new Tw(this),this._comments=new Jy(this),this._calculations=new tw(this),this._names=new ww(this),this._sparklines=new vw(this),this._conditionalFormats=new aw(this),this._hiddenCells=new Map,this._filter=!1,this._maxRowLevel=0,this._maxColumnLevel=0,this._headerCount=0,this._levelBasedRowTree=!0,this._levelBasedColTree=!0,this.clearRows=()=>(this.rowRoot.clearChildren(),this.rows=[],this.rows),this.clearColumns=()=>this.columns=[],this.logger=i,this.options=e??xw(t.options),this.populate(t)}getConnectedModel(t){return this.group?this.group.get(t):null}getModelByRange(t){return t.sheet?this.getConnectedModel(t.sheet):this}getCellByA1(t){return this.getCellByRange(Jm.fromA1(t))}getCellByRange(t){return this.getCellByCoords(t.r1,t.c1)}getCellByCoords(t,e){return this.rows[t].cell(e)}cell(t,e){return isNaN(t)?t instanceof Jm?this.getCellByRange(t):"string"==typeof t?this.getCellByA1(t):null:this.getCellByCoords(t,e||0)}createRows(t,e=new kw(this,{l:-1}),i=0){let o=!1,n=!1;const r=t.map(((t,e)=>{t||(t={}),isNaN(t.l)||(o=!0),null!=t.p&&(n=!0);const r=new kw(this,t);return r.origIndex=e+i,r.name&&this.names.set(r.name,Jm.fullRow(e)),r}));let s=-1;return o?s=dn(r,e,{reverse:this.options.rowTree.reversed}):n?s=un(r,e):e.children=r,[e,r,s,o]}insertRowData(t,e,i){const o=this.createRows(i,new kw(this,{l:t.level}),e);this._maxRowLevel=Math.max(this._maxRowLevel,o[2]),t.insertChildren(o[0].children,e),this.indexRowsByTree()}applyTheme(t,e){if(e)for(const t of this.getInitializedCellIterator())t.invalidateStyle();Ow(t,this)}populate(t){this.index=t.index,this.name=t.name??this.name,this.tab=t.tab;let e=!1,i=!1;if(t.columns||(t.columns=new Array(this.options.columns).fill({})),t.rows||(t.rows=new Array(this.options.rows).fill({})),t.styles&&this.styles.populate(t.styles),this.columns=t.columns.map(((t,o)=>{t||(t={}),t.l>0&&(e=!0),null!=t.p&&(i=!0);const n=new Gy(this,t);return this._filter=n.hasFilter||this._filter,n.name&&this.names.set(n.name,Jm.fullColumn(o)),n})),this._levelBasedColTree=e,this._maxColumnLevel=-1,this.colRoot=new Gy(this,{l:-1}),e?this._maxColumnLevel=dn(this.columns,this.colRoot,{reverse:this.options.columnTree.reversed}):i?this._maxColumnLevel=un(this.columns,this.colRoot):this.colRoot.children=this.columns,this.indexColumns(),this.indexVisibleColumns(),[this.rowRoot,this.rows,this._maxRowLevel,this._levelBasedRowTree]=this.createRows(t.rows),this.indexRows(),this.indexVisibleRows(),this.options.pageSize&&this.options.pageSize<=this.rows.length&&(this.rowRoot.count=1/0),this._mergedCells=[],t.cells?.forEach(((t,e)=>{const i=this.rows[t.r]?this.rows[t.r].cell(t.c,t):null;i?(i.colspan>1||i.rowspan>1)&&this._mergedCells.push({r:i.r,c:i.c,rs:i.rowspan,cs:i.colspan}):this.logger?.error(`invalid cell definition (index ${e}): ${JSON.stringify(t)}`)})),this.indexHiddenCells(),t.sparklines)try{this.sparklines.populate(t.sparklines)}catch(t){an().error(`Sparkline init error: ${t}`)}if(t.names)try{this.names.populate(t.names)}catch(t){an().error(`Named range init error: ${t}`)}if(t.rules)try{this.conditionalFormats.populate(t.rules)}catch(t){an().error(`Conditional formats init error: ${t}`)}if(t.theme)try{this.applyTheme(t.theme)}catch(t){an().error(`Theme init error: ${t}`)}if(t.comments)try{this.comments.populate(t.comments)}catch(t){an().error(`Comment init error: ${t}`)}this._properties=t.props,this.otherSourceData={};const o=new Set($w),n=Object.keys(t).filter((t=>!o.has(t)));n.forEach((e=>this.otherSourceData[e]=t[e])),this.calcHeaderHeights()}getSourceData(){const t={index:this.index,name:this.name,tab:this.tab,columns:this.columns.map((t=>t.getSourceData())),rows:this.rows.map((t=>t.getSourceData())),styles:this.styles.getSourceData(),rules:this.conditionalFormats.getSourceData(),sparklines:this.sparklines.getSourceData(),options:this.options};this._properties&&(t.props=this._properties);const e=[];let i;for(let t=0;t<this.rows.length;t++)for(let o=0;o<this.columns.length;o++)i=this.rows[t].cell(o).getSourceData(),Object.keys(i).length>0&&(i.r=t,i.c=o,e.push(i));e.length>0&&(t.cells=e);const o=[];return this.styles.clean(),this.styles.map.forEach((t=>o.push(t))),o.length>0&&(t.styles=o),new Set([...Object.keys(this.otherModels??{}),...Object.keys(this.otherSourceData??{})]).forEach((e=>t[e]=this.otherModels[e]?Array.from(this.otherModels[e]).map((t=>t.getSourceData())):this.otherSourceData[e])),t}calcHeaderHeights(){this._headerCount=0,this._headerHeights=[],this.columns.forEach((t=>{this._headerCount=t.header?t.header.length:this._headerCount,this._headerHeights.length<this._headerCount&&this._headerHeights.push(...Array(this._headerCount-this._headerHeights.length).fill(0)),t.header?.forEach(((t,e)=>{e>=this._headerHeights.length&&this._headerHeights.push(0),this._headerHeights[e]=Math.max(this._headerHeights[e],t.height??0)}))}))}indexRows(){this.visibleRows=[],this.rows.forEach(((t,e)=>{t.index=e,t.isLoaded||(t.collapsed=!0),t.hidden||t.filterState==ln.Filtered||this.visibleRows.push(t)}))}indexVisibleRows(){this.visibleRows=[];let t=0;if(this._levelBasedRowTree){if(this.rowRoot.walkVisible((e=>{e.visibleIndex=t++,this.visibleRows.push(e)})),this.options.rowTree.reversed){const e=new Array(this.visibleRows.length);this.visibleRows.forEach(((i,o)=>{t=this.visibleRows.length-o-1,i.visibleIndex=t,e[t]=i})),this.visibleRows=e}}else this.rowRoot.walkVisible((t=>this.visibleRows[t.index]=t)),this.visibleRows=this.visibleRows.filter((e=>!!e&&(e.visibleIndex=t++,!0)))}indexRowsByTree(){this.rows=[];let t=0;this.rowRoot.walk((e=>{e.index=t++,this.rows.push(e)})),this.options.rowTree.reversed&&this.rows.reverse(),this.indexVisibleRows()}indexColumns(){this.visibleColumns=[],this.columns.forEach(((t,e)=>{t.index=e,t.hidden||this.visibleColumns.push(t)}))}indexVisibleColumns(){this.visibleColumns=[],this.visibleColumnIndex={};let t=0;if(this.colRoot.walkVisible((e=>{e.visibleIndex=t,this.visibleColumnIndex[e.index]=t++,this.visibleColumns.push(e)})),this.options.columnTree.reversed){this.visibleColumnIndex={};const e=new Array(this.visibleColumns.length);this.visibleColumns.forEach(((i,o)=>{t=this.visibleColumns.length-o-1,i.visibleIndex=t,this.visibleColumnIndex[i.index]=t,e[t]=i})),this.visibleColumns=e}this.indexHeaders()}indexHeaders(){this._mergedHeaders=[],this._headerCount=0,this.colRoot.walkVisible((t=>{this._headerCount=Math.max(t.header?t.header.length:0,this._headerCount),t.mergedHeaders.forEach((e=>this._mergedHeaders.push({h:e,c:t.index,r:e.r,cs:t.calculateRealColspan(e.cs??1),rs:e.rs??1})))})),this._mergedHeaders.forEach((t=>{if(!t.h.hidden)for(let e=t.c;e<t.c+t.cs;e++)for(let i=t.r;i<t.r+t.rs;i++)(i>t.r||e>t.c)&&this.columns[e]&&this.columns[e].header[i]&&(this.columns[e].header[i].hidden=!0)})),this.calcHeaderHeights()}removeHeader(t){this.columns.forEach((e=>{t<e.header.length&&e.header.splice(t,1)})),this.indexHeaders()}clear(){this.clearRows(),this.clearColumns(),this.resetViewport()}resetViewport(){return this._viewport=null,this}getViewport(t,e,i){const o=[],n=[];let r,s,a=e.h,l=0;for(l=0;l<i.t;l++)r=this.visibleRows[l],a-=r.height,o.push(r);for(l=this.visibleRows.length-i.b;l<this.visibleRows.length;l++)r=this.visibleRows[l],a-=r.height;for(l=i.t+t.r;a>0&&l<this.visibleRows.length;)r=this.visibleRows[l++],a-=r.height,o.push(r);for(l=this.visibleRows.length-i.b;l<this.visibleRows.length;l++)o.push(this.visibleRows[l]);let c=e.w,h=0;for(h=0;h<i.l;h++)s=this.visibleColumns[h],c-=s.width,n.push(s);for(h=this.visibleColumns.length-i.r;h<this.visibleColumns.length;h++)s=this.visibleColumns[h],c-=s.width;for(h=i.l+t.c;c>0&&h<this.visibleColumns.length;)s=this.visibleColumns[h++],c-=s.width,n.push(s);for(h=this.visibleColumns.length-i.r;h<this.visibleColumns.length;h++)n.push(this.visibleColumns[h]);return this._viewport={rows:o,columns:n}}calculateViewport(){return this._viewport?this.calculations.calculateViewport(this._viewport):[]}getValuesInRange(t,e=!1){if(!(t=t.intersect(this.gridRange)))return[];const{columns:i,rows:o}=t.size,n=new Array(o);let r,s=0,a=0;for(let o=t.r1;o<=t.r2;o++){n[s]=new Array(i),a=0,r=this.rows[o];for(let i=t.c1;i<=t.c2;i++)n[s][a++]=e?r.cell(i).formattedValue:r.cell(i).value;++s}return n}setRowExpandLevel(t){this.rows.forEach((e=>{e.collapsed=!e.isLoaded&&!e.isPartialyLoaded||e.level>=t,e.level<=t&&(e.hidden=!1)})),this.indexVisibleRows()}setColumnExpandLevel(t){this.columns.forEach((e=>e.collapsed=e.level>=t)),this.indexVisibleColumns()}getViewportRange(){return this._viewport?new Jm(this._viewport.columns[0].index,this._viewport.rows[0].index,this._viewport.columns[this._viewport.columns.length-1].index,this._viewport.rows[this._viewport.rows.length-1].index):null}get gridRange(){return new Jm(0,0,this.columns.length-1,this.rows.length-1)}getRangeIterator(t,e=!1){return new bw(this,e&&this._viewport?t.intersect(this.getViewportRange()):t.intersect(this.gridRange))}getInitializedCellIterator(){return new bw(this,this.gridRange,!0)}getCellArray(t){const e=[];for(const i of this.getRangeIterator(t))e.push(i);return e}transformRangeToMatrix(t,e){let i,o,n;const r=[];for(let s=(t=t.intersect(this.gridRange)).r1;s<=t.r2;s++)if(i=this.rows[s],i){n=[];for(let r=t.c1;r<=t.c2;r++)o=i.cell(r),o&&n.push(e(o));r.push(n)}return r}getCellMatrix(t){return this.getModelByRange(t)?.transformRangeToMatrix(t,(t=>t))}getValueMatrix(t){return this.getModelByRange(t)?.transformRangeToMatrix(t,(t=>t.value))}shiftMerges(t){const{index:e,offset:i,direction:o}=t,n={down:t=>{e<=t.r?t.r+=i:e>t.r&&e<t.r+t.rs&&(this.rows[t.r].cell(t.c).rowspan=t.rs+=i)},up:t=>{e<=t.r?t.r-=i:e>t.r&&e<t.r+t.rs&&(this.rows[t.r].cell(t.c).rowspan=t.rs-=i)},right:t=>{e<=t.c?t.c+=i:e>t.c&&e<t.c+t.cs&&(this.rows[t.r].cell(t.c).colspan=t.cs+=i)},left:t=>{e<=t.c?t.c-=i:e>t.c&&e<t.c+t.cs&&(this.rows[t.r].cell(t.c).colspan=t.cs-=i)}};this.mergedCells.forEach(n[o]),this.indexHiddenCells()}indexHiddenCells(){this._hiddenCells.clear(),this.mergedCells.forEach((t=>{if(!(t.r>0||this._hiddenCells.has(t.r)&&this._hiddenCells.get(t.r).has(t.c)))for(let e=t.r;e<t.r+t.rs;e++)for(let i=t.c;i<t.c+t.cs;i++)(e>t.r||i>t.c)&&(this._hiddenCells.has(e)||this._hiddenCells.set(e,new Map),this._hiddenCells.get(e).set(i,t))}))}shift(t){t.sheet=this.name,this.shiftMerges(t),this.calculations.shift(t),this.names.shift(t),this.comments.shift(t),this.sparklines.shift(t)}clearCalculations(t=!1){t&&this.group?this.group.models.forEach((t=>t.calculations.refresh())):this.calculations.refresh()}refreshSparklines(){this.sparklines.updateRangeMaps();for(const t of this.getInitializedCellIterator())t.invalidateStyle()}clearCalculatedStyles(){this.conditionalFormats.refresh();const t=[];for(const e of this.getInitializedCellIterator())t.push(e),e.invalidateStyle()}insertColumns(t,e,i=!1){const o=this.columns[Math.min(this.columns.length-1,t)].parent;i&&++t,this.shift({index:t,offset:e,direction:"right"});for(let i=0;i<this.rows.length;i++)this.rows[i].insertColumns(t,e,!1);const n=new Array(e).fill(null).map((()=>new Gy(this)));return this.columns.splice(t,0,...n),this.maxColumnLevel>0&&o.insertChildren(n,t-(o.index||-1)-1),this.indexColumns(),this.clearCalculations(!0),n}deleteColumns(t,e){const i=this.columns[t].parent;this.shift({index:t,offset:e,direction:"left"});const o=[];for(let i=0;i<this.rows.length;i++)o.push(this.rows[i].deleteColumns(t,e,!1));const n=this.columns.splice(t,e);return i?.deleteChildren(n),this.indexColumns(),this.clearCalculations(!0),n}insertRows(t,e,i=!1){const o=Math.min(this.rows.length-1,t),n=o<0?this.rowRoot:this.rows[o].parent;i&&++t;const r=isNaN(e)?e.length:e;this.shift({index:t,offset:r,direction:"down"});const s=isNaN(e)?e:new Array(r).fill(null).map((()=>new kw(this)));return this.rows.splice(t,0,...s),this.maxRowLevel>0&&n.insertChildren(s,t-(n.index||-1)-1),this.indexRows(),this.clearCalculations(!0),s}deleteRows(t,e){const i=this.rows[t].parent;this.shift({index:t,offset:e,direction:"up"});const o=this.rows.splice(t,e);return i?.deleteChildren(o),this.indexRows(),this.clearCalculations(!0),o}moveRows(t,e,i){const o=this.rows.splice(t,e);return this.rows.splice(i,0,...o),this.shift({index:t,offset:i-t,direction:"down",maxIndex:t+e-1}),this.indexRows(),this.clearCalculations(!0),o}moveColumns(t,e,i){const o=this.columns.splice(t,e);return this.columns.splice(i,0,...o),this.shift({index:t,offset:i-t,direction:"right",maxIndex:t+e-1}),this.indexColumns(),this.clearCalculations(!0),o}spillValues(t){const{cell:e,values:i,displayValues:o,propertyCell:n}=t,r=[],s=[],a=0===i.length||0===i[0].length;let l,c;const h=a?null:new Jm(e.c,e.r,e.c+i[0].length-1,e.r+i.length-1);if(e.spillRange&&this.getRangeIterator(e.spillRange,!0).forEach((t=>{e==t||h?.contains(t.range)||t.clearSpilledValue()})),e.spillRange=h,a)return{cells:r,oldValues:s,range:null};for(let t=h.r1;t<=h.r2;t++){if(l=this.rows[t],!l)continue;const a=t-h.r1;for(let t=h.c1;t<=h.c2;t++){const d=t-h.c1;c=l.cell(t),c.editable&&(s.push(c.value2),c.spillValue(i[a][d],e),n&&(c.format=n.format,c.type=n.type),o&&null!=o[a][d]&&(c.displayValue=o[a][d]),r.push(c))}}return{cells:r,oldValues:s,range:h}}getCellByName(t,e,i=!0){return this.names.getCellByName(t,e)||(this.group&&i?this.group.getCellByName(t,e):null)}getRangeByName(t,e=!0){return this.names.getRangeByName(t)||(this.group&&e?this.group.getRangeByName(t):null)}getValueMatrixByName(t,e=!0){const i=this.names.getRangeByName(t);return i?this.getValueMatrix(i):this.group&&e?this.group.getValueMatrixByName(t):null}rebuildRowTree(){const t=this._levelBasedRowTree?dn:un;this._maxRowLevel=t(this.rows,this.rowRoot,{reverse:this.options.rowTree.reversed}),this.indexRowsByTree()}rebuildColumnTree(){const t=this._levelBasedColTree?dn:un;this._maxColumnLevel=t(this.columns,this.colRoot,{reverse:this.options.columnTree.reversed}),this.indexColumns()}calculateCellOffset(t){let e=0,i=0;for(let i=0;i<t.c1&&this.columns[i];i++)e+=this.columns[i].width;for(let e=0;e<t.r1&&this.rows[e];e++)i+=this.rows[e].height;return{x:e,y:i}}}class Nw{get errors(){return this._errors}get(t){return this.models.get(t)}has(t){return this.models.has(t)}getNewName(){let t;do{t=`sheet${this._max}`}while(this.models.has(t));return t}add(t){if(t.index=t.index??this._max,++this._max,t.name=t.name||this.getNewName(),this.models.has(t.name))throw Error(`sheet "${t.name}" already exists`);return this.models.set(t.name,t),t.group=this,t}duplicate(t){const e=this.get(t);if(!e)return;const i=new Dw(e.getSourceData(),e.options);let o=1;for(;this.models.has(`${t}_${o}`);)++o;return i.name=`${t}_${o}`,this.add(i),i}remove(t){return this.models.delete(t),this}rename(t,e){if(this.has(t)){if(this.has(e))throw new Error(`Model '${e}' already exists`);const i=this.get(t);i.name=e,this.models.set(e,i),this.models.delete(t),this.models.forEach((i=>{i.calculations.renameSheet(t,e)&&i.calculateViewport()}))}return this}clear(){this.models.clear(),this._errors=[]}constructor(t){this._max=0,this.models=new Map,this.themes=new Map,this._errors=[],t&&this.populate(t)}populate(t){this.clear(),t.models.forEach((t=>{const e=new Dw(t);try{this.add(e)}catch(t){this.errors.push(t)}})),t.themes&&t.themes.forEach((t=>this.themes.set(t.name,t)))}getSourceData(){const t={models:[]};return this.models.forEach((e=>t.models.push(e.getSourceData()))),t}getCellByName(t,e){for(const i of this.models.values()){const o=i.getCellByName(t,e,!1);if(o)return o}return null}getRangeByName(t){for(const e of this.models.values()){const i=e.getRangeByName(t,!1);if(i)return i}return null}getValueMatrixByName(t){for(const e of this.models.values()){const i=e.getValueMatrixByName(t,!1);if(i)return i}return null}}class Pw{constructor(t){this.model=t,this.stack=[],this.restack=[]}push(t){return this.restack=[],t.timestamp||(t.timestamp=Date.now()),this.stack.push(t),this}pop(t=1){let e=0;const i=[];for(;e++<t&&this.stack.length>0;){const t=this.stack.pop();i.push(t),this.restack.push(t)}return i}pop2(t=1){let e=0;const i=[];for(;e++<t&&this.restack.length>0;){const t=this.restack.pop();i.push(t),this.stack.push(t)}return i}}class jw{get activeCellCoords(){return{c:this.range.c1+this.activeCell.c1,r:this.range.r1+this.activeCell.r1}}constructor(t,e,i,o){this.hidden=!1,this.range=new Jm(t,e,i,o),this.activeCell=new Jm(0,0)}static fromRange(t){return new jw(t.c1,t.r1,t.c2,t.r2)}setCoords(t,e,i,o){this.range.setCoords(t,e,i,o),this.activeCell.setCoords(0,0)}setRange(t){"string"==typeof t&&(t=Jm.fromA1(t)),this.range.setCoords(t.c1,t.r1,t.c2,t.r2),this.activeCell.setCoords(0,0)}move(t,e,i,o){this.range.setCoords(this.range.c1+this.activeCell.c1,this.range.r1+this.activeCell.r1,this.range.c1+this.activeCell.c2,this.range.r1+this.activeCell.r2),this.range.move(t,e,i,o,!1),this.activeCell.setCoords(0,0)}moveRange(t,e,i,o){this.range.move(t,e,i,o,!0)}moveActiveCell(t,e){const{columns:i,rows:o}=this.range.size;this.activeCell.move(t,e,i,o,!0)}}const Vw=Hm;class Bw{constructor(t,e,i=Vw.MAX_CACHE_ITEMS){this.maxCacheItems=i,this.queue=[],this.disabled=!1,this.table=new Array(e).fill(null).map((()=>new Array(t)))}get(t,e){return this.table[e][t]}delete(t,e){return this.table[e][t]=null,this}deleteColumn(t){for(let e=0;e<this.table.length;e++)this.table[e][t]=null;return this}deleteRow(t){return this.table[t]=new Array(this.table[0].length).fill(null),this}set(t,e,i){this.disabled||(this.get(t,e)||this.queue.push([e,t]),this.table[e][t]=i)}clear(){this.queue=[],this.table=this.table.map((t=>new Array(t.length)))}clean(){if(this.maxCacheItems>0&&this.queue.length>this.maxCacheItems){let t=this.queue.length;for(let e=0;e<this.queue.length;e++){const i=this.queue[e];if(!this.table[i[0]][i[1]].parentNode&&(this.queue[e]=null,this.table[i[0]][i[1]]=null,--t<=this.maxCacheItems))break}t<this.queue.length&&(this.queue=this.queue.filter((t=>t)))}}}var Fw=function(t,e,i,o){var n,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(r<3?n(s):r>3?n(e,i,s):n(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s};let Ww=class extends Qr{constructor(){super(),this.render=()=>Ir`
2651
+ `,Rm={enabled:!1,includeChildren:!0,includeParents:!0},Im={enabled:!0,reversed:!1},Hm={ROW_HEIGHT:22,RESIZE_TRESHOLD:10,ROW_HEADER_WIDTH:60,SLIDER_SIZE:12,EXPANDER_SIZE:13,MAX_CACHE_ITEMS:5e3,CACHE_CLEAN_INTERVAL:30,COMMENT_HIDE_TIMEOUT:1e3,SELECTOR_BORDER_WIDTH:2,MIN_ROW_HEIGHT:5,MIN_COL_WIDTH:5,SPARKLINE_GAP:4,AUTOSCROLL_TRESHOLD:100,AUTOSCROLL_RATIO:1.1,AUTOSCROLL_INTERVAL:100,DEFAULT_SPARKLINE_OPTIONS:{minValue:"auto",maxValue:"auto",type:"line",style:{color:"0094FF",weight:1},marker:{color:"ff0000"}},DEFAULT_OPTIONS:{rows:100,columns:20,readOnly:!1,rowNumbers:!0,rowPriority:2,rowTree:{enabled:!0},columnTree:{enabled:!0},colLetters:!0,emptyPlaceholder:!0,freezeTop:0,fontSize:12,rowHeight:22,rowResize:!0,columnWidth:100,columnResize:!0,columnPriority:1,freezeLeft:0,freezeRight:0,freezeBottom:0,maxSortingColumns:3,numberFormat:null,levelIndentFactor:2,cellIndentFactor:10,emptyClickable:!1,grid:!0,autofill:!0,undoRedo:!0,commandWindow:!0,cellCache:!0,singleCellModel:!1,editing:{rowInsertion:!0,rowDeletion:!0,colInsertion:!0,colDeletion:!0,rowOutline:!0,colOutline:!0},comments:{hideTimeout:1e3,offsetX:30,offsetY:-30,zIndex:500,headerPosition:"top"},scrolling:{verticalOverscroll:!0,horizontalOverscroll:!0,scrollbarVisibilityTreshold:100},selecting:{enabled:!0,multiSelect:!0},events:{click:{mouseMoveTreshold:10}},clipboard:{pasteProps:["v","dv"]}},...W},Tm=/^(?!.*[\\\/\*\[\]\:\?"])(.{1,31})$/;function Am(t){return Tm.test(t)}function Om(t){return["\\","/","*","[","]",":","?",'"'].forEach((e=>t=t.replace(new RegExp(`\\${e}`,"g"),""))),t}function $m(t,e){return!isNaN(t)&&null!=t||!isNaN(e)&&null!=e||(t=null==t?"":at(t.toString()).toLowerCase(),e=null==e?"":at(e.toString()).toLowerCase()),t>e?1:t<e?-1:0}function Dm(t,e){const i=Z(e);return Z(t)?(t=t.toString().trim()).startsWith("=")?0==$m(e,i?t.substring(1):parseFloat(t.substring(1))):t.startsWith(">=")?$m(e,i?t.substring(2):parseFloat(t.substring(2)))>=0:t.startsWith("<=")?$m(e,i?t.substring(2):parseFloat(t.substring(2)))<=0:t.startsWith(">")?$m(e,i?t.substring(1):parseFloat(t.substring(1)))>0:t.startsWith("<")?$m(e,i?t.substring(1):parseFloat(t.substring(1)))<0:0==$m(e,i?t:isNaN(t)?t||"":parseFloat(t)):e==t}const Nm=new Map([["=",["==",1,0]],[">",[">",1,0]],["<",["<",1,0]],[">=",[">=",1,0]],["<=",["<=",1,0]],["+",["+",2,0]],["-",["-",2,0]],["*",["*",3,0]],["/",["/",3,0]]]),Pm=t=>["=",">","<",">=","<="].includes(t),jm=t=>["+","-","*","/"].includes(t),Vm=t=>jm(t)||Pm(t);function Bm(t,e,i){switch(i){case"+":return t+e;case"-":return t-e;case"*":return t*e;case"/":return t/e;case"=":return 0==$m(t,e);case">":return $m(t,e)>0;case"<":return $m(t,e)<0;case">=":return $m(t,e)>=0;case"<=":return $m(t,e)<=0;default:throw new Error(`Invalid operator: ${i}`)}}function Fm(t,e,i){const o=Array.isArray(t),n=Array.isArray(e);if(!o&&!n)return[[Bm(t,e,i)]];const r=Math.max(o?t.length:0,n?e.length:0),s=Math.max(o?t[0].length:0,n?e[0].length:0),a=[];for(let l=0;l<r;l++){const r=[];for(let a=0;a<s;a++){const s=o?t[l]?.[a]:t,c=n?e[l]?.[a]:e,h=null==s&&null==c?null:Bm(s,c,i);r.push(h)}a.push(r)}return a}var Wm;!function(t){t[t.Number=0]="Number",t[t.Boolean=1]="Boolean",t[t.String=2]="String",t[t.StringQuote=3]="StringQuote",t[t.Function=4]="Function",t[t.ArgumentSeparator=5]="ArgumentSeparator",t[t.OpenBracket=6]="OpenBracket",t[t.CloseBracket=7]="CloseBracket",t[t.Operator=8]="Operator",t[t.Cell=9]="Cell",t[t.Variable=10]="Variable",t[t.Range=11]="Range",t[t.Sheet=12]="Sheet",t[t.SheetQuote=13]="SheetQuote",t[t.SheetSeparator=14]="SheetSeparator",t[t.Unknown=15]="Unknown",t[t.Operand=16]="Operand"}(Wm||(Wm={}));const Um=t=>t===Wm.Number||t===Wm.Boolean||t===Wm.String||t===Wm.Cell||t===Wm.Variable||t===Wm.Range,Gm=t=>t>=48&&t<=57,qm=t=>"true"===(t=t.toLowerCase())||"false"===t,Ym=t=>t>=65&&t<=90||t>=97&&t<=122||t>=192&&t<=687,Zm={decimalPoint:".",stringQuote:'"',sheetQuote:"'",argumentSeparator:","};class Xm{constructor(t){this.options=Object.assign(Zm,t)}tokenize(t){const e=[],i=t.length;let o,n,r,s,a=0,l="",c=!1,h=!1,d=!1;for(;a<i;){if(o=t.charAt(a),n=o.charCodeAt(0),"="==o&&0==a)++a;else if(Gm(n)){for(l=(d?"-":"")+o,++a;a<i;)if(o=t.charAt(a),n=o.charCodeAt(0),Gm(n))l+=o,++a;else{if(o!==this.options.decimalPoint)break;l+=".",++a}d=!1,e.push([l,Wm.Number])}else if(Ym(n)||"$"==o){l=o,r=null,++a;do{if(o=t.charAt(a),n=o.charCodeAt(0),Ym(n)||Gm(n)||"."===o||"$"===o||"_"===o)"_"==o?r=Wm.Variable:Gm(n)&&!c&&null==r&&(r=Wm.Cell),l+=o,++a,a==i&&e.push([l,r||Wm.Variable]);else{if("("==o){e.push([l.toUpperCase(),Wm.Function]),e.push([o,Wm.OpenBracket]),++a;break}if("'"==o)e.push([l,Wm.Sheet]),l="",e.push([o,Wm.SheetQuote]),c=!0,++a;else if(":"==o)r=Wm.Range,l+=o,++a;else{if(!c||" "!=o){if("!"==o){""!==l&&e.push([l,Wm.Sheet]),e.push([o,Wm.SheetSeparator]),c=!1,l="",++a;break}e.push([l,r||(qm(l)?Wm.Boolean:Wm.Variable)]);break}l+=o,++a}}}while(a<i)}else if(Vm(o)){if("-"===o&&Gm(t.charCodeAt(a+1))&&(null==s||"("==s[0]||Pm(s[0])||s[1]==Wm.ArgumentSeparator))d=!0;else{for(l=o;Pm(t.charAt(a+1));)l+=t.charAt(++a);e.push([l,Wm.Operator])}++a}else if("("===o)e.push([o,Wm.OpenBracket]),++a;else if(")"===o)e.push([o,Wm.CloseBracket]),++a;else if("'"===o)e.push([o,Wm.SheetQuote]),c=!0,++a;else if(o===this.options.argumentSeparator)e.push([o,Wm.ArgumentSeparator]),++a;else if(o===this.options.stringQuote){for(h=!1,e.push([o,Wm.StringQuote]),l="";++a<i;){if(o=t.charAt(a),o===this.options.stringQuote){h=!0,++a;break}l+=o}e.push([l,Wm.String]),h&&e.push([this.options.stringQuote,Wm.StringQuote])}else e.push([o,Wm.Unknown]),++a;s=e[e.length-1]}return e}}function Qm(t,e,i=null,o=!0){return t+=e,0==e?t:t>=0?i?o?t%i:Math.min(t,i-1):t:o&&i?i+t%i:Math.max(t,0)}const Km=/(?:'?([\w\s]*)'?!)?(\$?)([a-z]*)(\$?)(\d*)(?::(\$?)([a-z]*)(\$?)(\d*))?/i;class Jm{constructor(t,e,i,o,n){this.setCoords(t,e,i,o),this.sheet=n}setCoords(t,e,i,o){this.c1=null==t&&null==i?0:t,this.r1=null==e&&null==o?0:e,this.c2=null==o&&null!=t||null!=i?null==i?t:i:1/0,this.r2=null==i&&null!=e||null!=o?null==o?e:o:1/0,this.normalize()}get size(){return{columns:this.c2-this.c1+1,rows:this.r2-this.r1+1}}get count(){const{columns:t,rows:e}=this.size;return t*e}normalize(){const[t,e]=[Math.min(this.c1,this.c2),Math.max(this.c1,this.c2)],[i,o]=[Math.min(this.r1,this.r2),Math.max(this.r1,this.r2)];return this.c1=t,this.c2=e,this.r1=i,this.r2=o,this}move(t,e,i=null,o=null,n=!0){const r=Qm(this.c1,t,i,n);n&&(e+=this.c1+t!=r&&0!=t?t>0?1:-1:0),this.c1=r,this.r1=Qm(this.r1,e,o,n),this.c2=Qm(this.c2,t,i,n),this.r2=Qm(this.r2,e,o,n)}contains(t){return t.c1>=this.c1&&t.c2<=this.c2&&t.r1>=this.r1&&t.r2<=this.r2}containsColumn(t){return this.c1<=t&&this.c2>=t}containsRow(t){return this.r1<=t&&this.r2>=t}removeAnchors(){return this.c1Anchor=!1,this.c2Anchor=!1,this.r1Anchor=!1,this.r2Anchor=!1,this}addAnchors(){return this.c1Anchor=!0,this.c2Anchor=!0,this.r1Anchor=!0,this.r2Anchor=!0,this}shiftLeft(t,e=1,i=null,o=!1){return t<=this.c1&&(o||!this.c1Anchor)&&(null==i||this.c1<=i)&&(this.c1-=e),t<=this.c2&&(o||!this.c2Anchor)&&(null==i||this.c2<=i)&&(this.c2-=e),this}shiftRight(t,e=1,i=null,o=!1){return t<=this.c1&&(o||!this.c1Anchor)&&(null==i||this.c1<=i)&&(this.c1+=e),t<=this.c2&&(o||!this.c2Anchor)&&(null==i||this.c2<=i)&&(this.c2+=e),this}shiftUp(t,e=1,i=null,o=!1){return t<=this.r1&&(o||!this.r1Anchor)&&(null==i||this.r1<=i)&&(this.r1-=e),t<=this.r2&&(o||!this.r2Anchor)&&(null==i||this.r2<=i)&&(this.r2-=e),this}shiftDown(t,e=1,i=null,o=!1){return t<=this.r1&&(o||!this.r1Anchor)&&(null==i||this.r1<=i)&&(this.r1+=e),t<=this.r2&&(o||!this.r2Anchor)&&(null==i||this.r2<=i)&&(this.r2+=e),this}shift(t){const{index:e,offset:i,direction:o,maxIndex:n,ignoreAnchors:r}=t;switch(o){case"down":return this.shiftDown(e,i,n,r);case"up":return this.shiftUp(e,i,n,r);case"left":return this.shiftLeft(e,i,n,r);case"right":return this.shiftRight(e,i,n,r)}}intersect(t){this.normalize(),t.normalize();const e=Math.max(t.c1,this.c1),i=Math.min(t.c2,this.c2),o=Math.max(t.r1,this.r1),n=Math.min(t.r2,this.r2);return e<=i&&o<=n?new Jm(e,o,i,n,this.sheet):null}unite(t){return this.normalize(),t.normalize(),new Jm(Math.min(this.c1,t.c1),Math.min(this.r1,t.r1),Math.max(this.c2,t.c2),Math.max(this.r2,t.r2),this.sheet)}clone(){const t=new Jm(this.c1,this.r1,this.c2,this.r2,this.sheet);return t.c1Anchor=this.c1Anchor,t.r1Anchor=this.r1Anchor,t.c2Anchor=this.c2Anchor,t.r2Anchor=this.r2Anchor,t}equals(t,e=!1){return t.c1==this.c1&&t.r1==this.r1&&t.c2==this.c2&&t.r2==this.r2&&(0==e||t.c1Anchor==this.c1Anchor&&t.r1Anchor==this.r1Anchor&&t.c2Anchor==this.c2Anchor&&t.r2Anchor==this.r2Anchor)}get isCell(){return this.c2==this.c2&&this.r2==this.r1}get isRange(){return this.c2!=this.c1||this.r2!=this.r1}get isColumn(){return 0==this.r1&&this.r2==1/0}get isRow(){return 0==this.c1&&this.c2==1/0}get A1(){const t=this.isRange,e=(this.c1Anchor?"$":"")+(0!==this.c1||this.c2!==1/0?iv(this.c1):"")+(0===this.r1&&this.r2===1/0?"":(this.r1Anchor?"$":"")+tv(this.r1)),i=t?(this.c2Anchor?"$":"")+(!isNaN(this.c2)&&this.c2<1/0?iv(this.c2):"")+(this.r2Anchor?"$":"")+(!isNaN(this.r2)&&this.r2<1/0?tv(this.r2):""):e;return(null==this.sheet?"":((o=this.sheet).indexOf(" ")>-1?"'"+o+"'":o)+"!")+(e==i?e:e+":"+i);var o}get bounds(){return[[new Jm(this.c1,this.r1),this.c2<1/0?new Jm(this.c2,this.r1):null],[this.r2<1/0?new Jm(this.c1,this.r2):null,this.r2<1/0&&this.c2<1/0?new Jm(this.c2,this.r2):null]]}*cells(){for(let t=this.r1;t<=this.r2;t++)for(let e=this.c1;e<=this.c2;e++)yield new Jm(e,t)}static fromA1(t){const e=Km.exec(t),i=new Jm(e[3]?ov(e[3]):null,e[5]?ev(e[5]):null,e[7]?ov(e[7]):null,e[9]?ev(e[9]):null,e[1]||null);return!e[2]&&e[3]||(i.c1Anchor=!0),!e[4]&&e[5]||(i.r1Anchor=!0),(e[6]||e[2]&&!e[7])&&(i.c2Anchor=!0),(e[8]||e[4]&&!e[9])&&(i.r2Anchor=!0),i}}function tv(t){return(t+1).toString()}function ev(t){return parseInt(t)-1}function iv(t){++t;let e,i="";for(;t>0;)e=(t-1)%26,i=String.fromCharCode(e+65)+i,t=(t-e-1)/26;return i}function ov(t){const e=t.length;let i=0;for(let o=0;o<e;o++)i+=(t.charCodeAt(o)-64)*Math.pow(26,e-o-1);return i-1}function nv(t){return t.sort(((t,e)=>{const i=Math.min(t.r1,t.r2),o=Math.min(e.r1,e.r2),n=Math.min(t.c1,t.c2),r=Math.min(e.c1,e.c2);return i<o?-1:i>o?1:n<r?-1:r>n?1:0}))}function rv(t){return t.formula.cells.map((e=>t.cell.model.getCellByRange(e[1])))}function sv(t){let e=t;for(;Array.isArray(e);)e=e.length>0?e[0]:null;return e}function av(t){return Array.isArray(t)?t:[[t]]}function lv(t,e,i,o){if(!Array.isArray(t))return e(t,i,o);for(let o=0;o<t.length;o++)if(!1===lv(t[o],e,null==i?o:i,null==i?void 0:o))return!1}Jm.fromA1s=(t,e=";")=>t.split(e).map((t=>Jm.fromA1(t))),Jm.toA1s=(t,e=";")=>t.map((t=>t.A1)).join(e),Jm.fromCoords=t=>new Jm(t.c1,t.r1,t.c2,t.r2),Jm.fullColumn=t=>new Jm(t,0,t,1/0),Jm.fullRow=t=>new Jm(0,t,1/0,t);const cv=new Set(["SUMPRODUCT","FILTER"]),hv=t=>cv.has(t),dv=t=>!!(t&&t.length>0&&"="==t.charAt(0)),uv=t=>dv(t)?t:"="+(t??""),pv=t=>dv(t)?t.substring(1):t,gv=["#5B97FF","#FF616B","#B77CFF","#00B02C","#FC58BE","#FF9000","#2EB0B3"],fv=t=>gv[t%gv.length],mv=new Map([["FORMULATEXT","_xlfn."],["CONCAT","_xlfn."],["INDIRECT","_xlfn."],["ISOWEEKNUM","_xlfn."],["SWITCH","_xlfn."],["XOR","_xlfn."]]);class vv{get fn(){return this._fn??(this._fn=new Function("t","ctx","return "+this.compile()))}get tokens(){return this._tokens}get variables(){return this._variables}get cells(){return this._cells}get ranges(){return this._ranges}get colors(){if(!this._colors){let t;this._colors=new Map,this._tokens.forEach(((e,i)=>{if([Wm.Cell,Wm.Range].includes(e[1])){const o=(t?"'"+t+"'!":"")+e[0];this._colors.set(o,{color:fv(this._colors.size),address:e[0],sheet:t,type:e[1],tokenIndex:i}),t=null}else e[1]==Wm.Sheet&&(t=e[0])}))}return this._colors}constructor(t,e){this.expression=t,this.tokenizer=e,this._tokens=e.tokenize(this.expression),this.updateDependecies()}findTokenIndexAtPosition(t){let e=0;return this._tokens.findIndex((i=>{const o=i[0].length;if(t>=e&&t<=e+o)return!0;e+=o}))}findSheetTokenIndex(t){const e=this._tokens[t];if(![Wm.Cell,Wm.Range].includes(e[1]))return-1;if(0==t||this._tokens[t-1][1]!=Wm.SheetSeparator)return-1;let i=t-2;for(;i>=0;){if(this._tokens[i][1]==Wm.Sheet)return i;i--}return-1}removeSheetToken(t){if(this._tokens[t][1]!=Wm.Sheet&&(t=this.findSheetTokenIndex(t)),t>-1){t>0&&this._tokens[t-1][1]==Wm.SheetQuote&&t--;let e=t;for(;e<this._tokens.length&&[Wm.SheetSeparator,Wm.SheetQuote,Wm.Sheet].includes(this._tokens[e][1]);)e++;return this._tokens.splice(t,e-t),e-t}return 0}getNamedColor(t){return this.colors.get(t)?.color??"inherit"}getTokenPosition(t){let e=0;for(let i=0;i<t;i++)e+=this._tokens[i][0].length;return{min:e,max:e+this._tokens[t][0].length}}updateToken(t,e){this._fn=null,this._formula=null,this._xlFormula=null,this._tokens[t][0]=e}removeToken(t){this._fn=null,this._formula=null,this._xlFormula=null,this._tokens.splice(t,1)}insertToken(t,e,i){this._fn=null,this._formula=null,this._xlFormula=null;const o=[];return i==Wm.Sheet&&/\s/.test(e)?(o.push([this.tokenizer.options.sheetQuote,Wm.SheetQuote]),o.push([e,Wm.Sheet]),o.push([this.tokenizer.options.sheetQuote,Wm.SheetQuote])):o.push([e,i]),o.push(["!",Wm.SheetSeparator]),this._tokens.splice(t,0,...o),o.length}clone(){return new vv(this.createFormulaString(),this.tokenizer)}updateDependecies(){let t;this._variables=[],this._cells=[],this._ranges=[],this._tokens.forEach(((e,i)=>{switch(e[1]){case Wm.Sheet:t=e[0];break;case Wm.Variable:this._variables.push([i,e[0],t]),t=void 0;break;case Wm.Cell:this._cells.push([i,Jm.fromA1(e[0]),t]),t=void 0;break;case Wm.Range:this._ranges.push([i,Jm.fromA1(e[0]),t]),t=void 0}}))}createFormulaString(t=!1,e=!1){const i=this.tokenizer.options;let o,n,r,s="";for(let l=0;l<this._tokens.length;l++)switch(o=this._tokens[l],o[1]){case Wm.SheetQuote:s+="'";break;case Wm.SheetSeparator:s+="!";break;case Wm.Sheet:n=o[0],s+=t?`<span style="font-style:italic">${n}</span>`:n;break;case Wm.Variable:s+=o[0];break;case Wm.Range:case Wm.Cell:r=(n?"'"+n+"'!":"")+o[0],s+=t?`<span style="color:${this.getNamedColor(r)}">${o[0]}</span>`:o[0],n=null;break;case Wm.StringQuote:s+=i.stringQuote;break;case Wm.String:s+=o[0].replace(new RegExp(i.stringQuote,"g"),"\\"+i.stringQuote);break;case Wm.ArgumentSeparator:s+=i.argumentSeparator;break;case Wm.Function:s+=(e?(a=o[0],mv.get(a)??""):"")+o[0];break;case Wm.Unknown:s+=t?`<span style="background:#f00;color:#fff">${o[0]}</span>`:o[0];break;default:s+=o[0]}var a;return s}createExpressionTree(){const t=[],e=[],i=this.tokens;let o,n,r,s,a,l=null;for(let c=0;c<i.length;c++)switch(o=i[c],o[1]){case Wm.Sheet:l=o[0];break;case Wm.Cell:case Wm.Range:t.push({t:o[0],tt:o[1],s:l}),l=null;break;case Wm.Number:case Wm.String:case Wm.Boolean:case Wm.Variable:t.push({t:o[0],tt:o[1]});break;case Wm.Operator:for(0==t.length&&t.push({t:"",tt:Wm.Operand}),r=Nm.get(o[0]);e.length>0&&(s=Nm.get(e[e.length-1][0]),s)&&(0===r[2]&&r[1]<=s[1]||1===r[2]&&r[1]<s[1]);)n=e.pop(),a=[t.pop(),t.pop()].reverse(),t.push({t:n[0],tt:n[1],c:a});e.push(o);break;case Wm.Function:case Wm.OpenBracket:e.push(o);break;case Wm.ArgumentSeparator:for(;e.length>0&&(n=e[e.length-1],![Wm.OpenBracket,Wm.ArgumentSeparator].includes(n[1]));)n=e.pop(),a=[t.pop(),t.pop()].reverse(),t.push({t:n[0],tt:n[1],c:a});e.push(o);break;case Wm.CloseBracket:for(a=[];e.length>0&&e[e.length-1][1]!==Wm.OpenBracket;)n=e.pop(),n[1]==Wm.Operator?a.push({t:n[0],tt:n[1],c:[t.pop(),t.pop()].reverse()}):n[1]==Wm.ArgumentSeparator&&t.length>0&&a.push(t.pop());e.pop(),e.length>0&&e[e.length-1][1]===Wm.Function?(n=e.pop(),a=a.reverse(),t.length>0&&i[c-1][1]!==Wm.OpenBracket&&a.unshift(t.pop()),t.push({t:n[0],tt:n[1],c:a})):t.push(...a)}for(;e.length>0;)n=e.pop(),t.push({t:n[0],tt:n[1],c:[t.pop(),t.pop()].reverse()});return t.pop()}createExpressionJSCode(t,e,i){let o;switch(t.tt){case Wm.Range:return"t.rn('"+t.t+"'"+(t.s?",'"+t.s+"'":"")+")";case Wm.Cell:return"t.cl('"+t.t+"'"+(t.s?",'"+t.s+"'":"")+")";case Wm.Operand:return"t.cl()";case Wm.Variable:return i||e?.tt===Wm.Function?"t.nr('"+t.t+"'"+(t.s?",'"+t.s+"'":"")+")":"t.nv('"+t.t+"'"+(t.s?",'"+t.s+"'":"")+")";case Wm.String:return"'"+t.t.replace(/'/g,"\\'")+"'";case Wm.Boolean:return"T"==t.t[0].toUpperCase()?"1":"0";case Wm.Function:return o=t.c.map((e=>this.createExpressionJSCode(e,t,i||hv(t.t)))),"t.fn('"+t.t+"').call(ctx"+(o.length>0?","+o.join(","):"")+")";case Wm.Operator:return i?(o=t.c.map((e=>this.createExpressionJSCode(e,t,i||hv(t.t)))),"t.op("+o[0]+","+o[1]+",'"+t.t+"')"):Nm.has(t.t)?"("+t.c.map((e=>this.createExpressionJSCode(e,t,i))).join(Nm.get(t.t)[0])+")":null;default:return t.t}}compile(){const t=this.createExpressionTree();return this.createExpressionJSCode(t)}toString(t=!1){return(t?"=":"")+(this._formula??(this._formula=this.createFormulaString()))}toExcelString(){return this._xlFormula??(this._xlFormula=this.createFormulaString(!1,!0))}shift(t){const{index:e,offset:i,direction:o,maxIndex:n,sheet:r,allSheets:s}=t;return this._cells&&this._cells.forEach((t=>{if(s||null==t[2]||t[2]==r){switch(o){case"up":t[1].shiftUp(e,i,n);break;case"right":t[1].shiftRight(e,i,n);break;case"down":t[1].shiftDown(e,i,n);break;case"left":t[1].shiftLeft(e,i,n)}this._tokens[t[0]][0]=t[1].A1}})),this._ranges&&this._ranges.forEach((t=>{if(s||null==t[2]||t[2]==r){switch(o){case"up":t[1].shiftUp(e,i,n);break;case"right":t[1].shiftRight(e,i,n);break;case"down":t[1].shiftDown(e,i,n);break;case"left":t[1].shiftLeft(e,i,n)}this._tokens[t[0]][0]=t[1].A1}})),this}hasSheetReference(t){for(const e of this._cells)if(e[2]==t)return!0;for(const e of this._ranges)if(e[2]==t)return!0;for(const e of this._variables)if(e[2]==t)return!0;return!1}renameSheet(t,e){let i=!1;return this._tokens.forEach((o=>{o[1]==Wm.Sheet&&o[0]==t&&(o[0]=e,i=!0)})),i}}function bv(t,e){return e&&(t=Go(this.cell.model.options.locale,Qo(e,"d"),!1)(t)),null==t?"":t.toString()}function yv(t,e){return(t=null==t?"":t.toString()).substring(0,e)}function wv(t,e){return(t=null==t?"":t.toString()).substring(Math.max(0,t.length-e),t.length)}function xv(t,e,i){return(t=null==t?"":t.toString()).substring(e,e+i)}function kv(...t){let e="";return lv(t,(t=>e+=null==t?"":t.toString())),e}function Cv(t){return t instanceof Date?t:Z(t)?zo(t,ho()):No(t)}function Mv(t){return K(t)?t:Do(t instanceof Date?t:zo(t,ho()))}function _v(t){return Z(t)?Mv(t):t}function Sv(t,e){const i=Cv(t).getDay();switch(e){case 2:return i;case 3:return i-1;default:return i%7+1}}function Ev(t,e,i){return Po(Mv(sv(t)),e)}function zv(){return Do(new Date)}function Lv(t){return null==(t=sv(t))||""===t}function Rv(t,e,i){return Do(new Date(t,e-1,i))}function Iv(t){return Cv(t).getFullYear()}function Hv(t){return Cv(t).getMonth()+1}function Tv(t){return Cv(t).getDate()}function Av(t,e){const i=Cv(t);return i.setMonth(i.getMonth()+e+1),i.setDate(0),Do(i)}function Ov(t){return pi(Cv(t))}function $v(t){return Math.acos(t)}function Dv(t){return Math.acosh(t)}function Nv(t){return Math.PI/2-Math.atan(t)}function Pv(t){return.5*Math.log((t+1)/(t-1))}function jv(t){return Math.asin(t)}function Vv(t){return Math.asinh(t)}function Bv(t){return Math.atan(t)}function Fv(t){return Math.atanh(t)}function Wv(t){return Math.cos(t)}function Uv(t){return Math.cosh(t)}function Gv(t){return 1/Math.tan(t)}function qv(t){return 1/Math.tanh(t)}function Yv(t){return 1/Math.sin(t)}function Zv(t){return 1/Math.sinh(t)}function Xv(t){return 180*t/Math.PI}function Qv(){return Math.PI}function Kv(t){return 1/Math.cos(t)}function Jv(t){return 1/Math.cosh(t)}function tb(t){return Math.sin(t)}function eb(t){return Math.sinh(t)}function ib(t){return Math.tan(t)}function ob(t){return Math.tanh(t)}function nb(t){return Math.abs(t)}function rb(t){if(t<0)throw new Error("#NUM");return Math.ceil(t)}function sb(t){return(t=Math.ceil(t))%2==0?t:t+1}function ab(t){return Math.pow(Math.E,t)}function lb(t){return t<0?-1:0==t?1:t*lb(t-1)}function cb(t){return t<=0?1:t*cb(t-2)}function hb(t){return Math.floor(t)}function db(t){return t%1!=0}function ub(t){return!db(t)&&t%2==0}function pb(t){return db(t)||t%2==1}function gb(t){return Math.log(t)}function fb(t,e){return Math.log(t)/Math.log(e)}function mb(t){return Math.log10(t)}function vb(t,e){return t%e}function bb(t){return(t=Math.ceil(t))%2==0?t+1:t}function yb(t,e){return Math.pow(t,e)}function wb(...t){let e=1;return lv(t,(t=>e*=t||1)),e}function xb(t,e){return Math.floor(t/e)}function kb(t){return t*Math.PI/180}function Cb(){return Math.random()}function Mb(t,e){const i=Array(t).fill(null).map((()=>Array(e)));for(let o=0;o<t;o++)for(let t=0;t<e;t++)i[o][t]=Math.random();return i}function _b(t,e){return t=Math.ceil(t),e=Math.floor(e),Math.floor(Math.random()*(e-t+1))+t}function Sb(t,e){return t.toFixed(e)}function Eb(t,e){return e=e||0,Math.floor(t*Math.pow(10,e))/Math.pow(10,e)}function zb(t,e){return e=e||0,Math.ceil(t*Math.pow(10,e))/Math.pow(10,e)}function Lb(t,e,i=1,o=1){const n=Array(t).fill(null).map((()=>Array(e)));let r=i;for(let i=0;i<t;i++)for(let t=0;t<e;t++)n[i][t]=r,r+=o;return n}function Rb(t){return t<0?-1:t>0?1:0}function Ib(t){return Math.sqrt(t)}function Hb(t){return Math.sqrt(Math.PI*t)}function Tb(...t){let e=0;return lv(t,(t=>e+=null==t?0:1)),e}function Ab(...t){let e=0;return lv(t,(t=>e+=null==t?1:0)),e}function Ob(t,e){let i=0;return lv(t,(t=>i+=Dm(e,t)?1:0)),i}function $b(...t){let e=0;const i=new Map;return lv(t,(t=>{i.has(t)||(i.set(t,t),++e)})),e}function Db(...t){let e=0;return lv(t,(t=>e+=isNaN(t)?0:t)),e}function Nb(t,e,i){let o=0;if(i){const n=av(i);lv(t,((t,i,r)=>o+=Dm(e,t)&&n[i]&&n[i][r]&&!isNaN(n[i][r])?n[i][r]:0))}else lv(t,(t=>o+=Dm(e,t)&&!isNaN(t)?t:0));return o}function Pb(t,e){let i=0;return lv(t,(t=>i+=Dm(e,t)&&!isNaN(t)?t*t:0)),i}function jb(...t){let e=0;const i=t.shift();if(0===t.length)lv(i,(t=>e+=isNaN(t)?0:t));else{const o=av(t[0]);lv(i,((t,i,n)=>e+=o[i]&&o[i][n]&&!isNaN(t)&&!isNaN(o[i][n])?t*o[i][n]:0))}return e}function Vb(t,e){return t=null==t?"":t.toString(),e?e=>e==t:(t=t.toLowerCase(),e=>(e??"").toString().toLowerCase().includes(t))}function Bb(t,e,i=1){const o=new Jm(Math.max((e||0)-1,0),Math.max((t||0)-1,0));return 1!=i&&2!=i||(o.r1Anchor=!0),1!=i&&3!=i||(o.c1Anchor=!0),o.A1}function Fb(t,e,i,o=!1){let n,r;const s=Vb(t,o);for(n=0;n<e.length;n++)for(r=0;r<e[n].length;r++)if(s(e[n][r]))return e[n][i-1];return null}function Wb(t,e,i,o=!1){let n,r;const s=Vb(t,o);for(n=0;n<e.length;n++)for(r=0;r<e[n].length;r++)if(s(e[n][r]))return e[i-1][r];return null}function Ub(t,e,i){let o,n;t:for(o=0;o<e.length;o++)for(n=0;n<e[o].length;n++)if(e[o][n]==t)break t;return i?i[o]?i[o][n]:null:e[o][e[o].length-1]}function Gb(t,...e){let i=null,o=0;return lv(e,(e=>{if(t==++o)return i=e,!1})),i}function qb(t){return(t?Jm.fromA1(t).c1:this.cell.c)+1}function Yb(t){return(t?Jm.fromA1(t).r1:this.cell.r)+1}function Zb(t){return Array.isArray(t)?t[0]?.length:1}function Xb(t){return Array.isArray(t)?t.length:1}function Qb(){const t=rv(this)[0];return t&&t.hasFormula?" "+uv(t.formula):""}function Kb(t,e,i){return e=e||1,i=i||1,Array.isArray(t)?t[e-1]?t[e-1][i-1]:null:1==e&&1==i?t:null}function Jb(t){const e=this.cell,i=e.model,o=i.getCellByA1(t);let n;return i.calculations.dependencies.cellDependencies.has(e.address)?n=i.calculations.dependencies.cellDependencies.get(e.address):(n=new Map,i.calculations.dependencies.cellDependencies.set(e.address,n)),n.set(o.address,[o.range]),i.calculations.dependencies.cellDependants.has(o.address)?n=i.calculations.dependencies.cellDependants.get(o.address):(n=new Map,i.calculations.dependencies.cellDependants.set(o.address,n)),n.set(e.address,[e.range]),o.value}function ty(t,e,i=0){let o,n;for(o=0;o<e.length;o++)for(n=0;n<e[o].length;n++){if(0==i&&e[o][n]==t)return Math.max(o+1,n+1);if(1==i&&e[o][n]>t)return Math.max(o+1,n+1);if(-1==i&&e[o][n]<t)return Math.max(o+1,n+1)}return null}function ey(t,e,i,o,n){const r=rv(this)[0],s=[];o=o||1,n=n||1;for(let t=0;t<o;t++){const o=[];for(let s=0;s<n;s++){const n=r.model.rows[r.r+t+e].cell(r.c+s+i);o.push(n?r.value:null)}s.push(o)}return s}function iy(t,e){const i=[];if(t.length==e.length)for(let o=0;o<t.length;o++){let n=!0;for(let t=0;t<e[o].length;t++)if(!e[o][t]){n=!1;break}n&&i.push(t[o])}return i}const oy=[[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,2.1531153547440383e-8],[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097]],ny=[[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],[2.568520192289822,1.8729528499234604,.5279051029514285,.06051834131244132,.0023352049762686918]];function ry(t){const e=t*t;let i,o=oy[0][4]*e,n=e;for(i=0;i<3;i+=1)o=(o+oy[0][i])*e,n=(n+ny[0][i])*e;return t*(o+oy[0][3])/(n+ny[0][3])}function sy(...t){let e=!0;return lv(t,(t=>{if(!t)return e=!1})),e}function ay(...t){let e=!1;return lv(t,(t=>{if(t)return e=!0})),e}function ly(...t){let e=null;return lv(t,(t=>{e=null===e?!!t:!!t!=e})),e}function cy(...t){const e=t[0];for(let i=1;i<t.length;i+=2){if(i==t.length-1)return t[i];if(e==t[i])return t[i+1]}return null}function hy(t,e,i){return t?e:i}function dy(t){return!t}function uy(){return!1}function py(){return!0}function gy(t,e){return e=""===e?null:e,t===1/0||t===-1/0||Number.isNaN(t)?e:t}var fy=i(235),my=i.n(fy),vy=i(5949),by=i.n(vy);function yy(...t){let e=0,i=0;return lv(t,(t=>{null==t||isNaN(t)||(e+=t||0,++i)})),e/i}function wy(t,e){const i=by()(),o=av(t),n=av(e);for(let t=0;t<o.length;t++)for(let e=0;e<o[t].length;e++)i(o[t][e],(n[t]?n[t][e]:1)??1);return i()}function xy(...t){const e=function(t){const e=[];return lv(t,(t=>e.push(t))),e}(t),i=my()(e.length,e,1);return e.reduce(((t,e)=>t+Math.abs(e-i)),0)/e.length}function ky(...t){let e=1/0;return lv(t,(t=>e=Math.min(e,t))),e}function Cy(...t){let e=-1/0;return lv(t,(t=>e=Math.max(e,t))),e}function My(t,e){Object.keys(e).forEach((i=>t.set(nt(i,"_").replace(/_/g,".").toUpperCase(),e[i])))}const _y=new Map;My(_y,C),My(_y,M),My(_y,_),My(_y,S),My(_y,z),My(_y,E),My(_y,L);class Sy{constructor(t){this.model=t,this.getModel=t=>{const e=t?this.model.getConnectedModel(t):this.model;if(e)return e;throw new Error(`Sheet "${t}" not found`)},this.cl=(t,e)=>{const i=this.getModel(e);return(null==t?this.currentCell:i.getCellByA1(t)).value},this.rn=(t,e)=>this.getModel(e).getValuesInRange(Jm.fromA1(t)),this.nv=(t,e)=>this.getModel(e).getCellByName(t,this.currentCell.range).value,this.nr=(t,e)=>{const i=this.getModel(e).getValueMatrixByName(t);return 1===i.length&&1===i[0].length?i[0][0]:i},this.fn=t=>{const e=_y.get(t);if(e)return e;throw new Error(`Function "${t}" not found`)},this.op=(t,e,i)=>Fm(t,e,i)}}function Ey(t,e){const i=Array(e).fill(null);let o=0,n=[];if(t.length>1){n=t.map((t=>parseFloat(t.value)||0)),o=n[1]-n[0];for(let t=2;t<n.length;t++)if(n[t]-n[t-1]!==o){o=0;break}}if(0==o)for(let o=0;o<e;o++)i[o]=t[o%t.length]?.value;else{let t=n[n.length-1];for(let n=0;n<e;n++)t=i[n]=t+o}return i}function zy(t,e,i){const o=new vv(t.formula,t.model.calculations.tokenizer),n=[];for(let t=0;t<i;t++)n.push(uv(o.shift({index:0,offset:1,direction:e,allSheets:!0}).createFormulaString()));return n}function Ly(t,e,i,o){const n=t.getCellMatrix(e);let r;"right"==o?r=En(n):"down"==o?r=Sn(n):"left"==o?r=Mn(n):"up"==o&&(r=Mn(Sn(n)));const s=new Array(i.size.rows);for(let t=0;t<i.size.rows;t++){s[t]=new Array(i.size.columns);for(let e=0;e<i.size.columns;e++){const i=n.length>t?n[t][n[t].length>e?e:0]:n[0][e];s[t][e]=i.hasDisplayValue?i.displayValue:null}}const a=i.size["down"==o||"up"==o?"rows":"columns"];let l=r.map((t=>t[t.length-1].hasFormula?zy(t[t.length-1],o,a):Ey(t,a)));return"down"==o?l=Sn(l):"left"==o?l=Mn(l):"up"==o&&(l=_n(Sn(l))),t.spillValues({cell:t.getCellByRange(i.bounds[0][0]),values:l,propertyCell:t.getCellByRange(e.bounds[0][0]),displayValues:s})}class Ry{get address(){return null}get renderer(){return this._renderer}set renderer(t){this._renderer=t}get afterRenderer(){return this._afterRenderer}set afterRenderer(t){this._afterRenderer=t}get commentRenderer(){return this._commentRenderer}set commentRenderer(t){this._commentRenderer=t}get type(){return this._type}set type(t){this._type=t}get name(){return this._name}set name(t){this._name=t}get style(){return this._style}set style(t){this._style=t}get commentable(){return this._commentable}set commentable(t){this._commentable=t}get clickable(){return this._clickable}set clickable(t){this._clickable=t}get editable(){return this._editable}set editable(t){this._editable=t}get allowInvalid(){return this._allowInvalid}set allowInvalid(t){this._allowInvalid=t}get hasFormula(){return!!this._formula}get formula(){return this._formula}set formula(t){this._formula=t?t.replace(/^=/,""):null}get value2(){return this.hasFormula?uv(this.formula):null}get editorContent(){return this._editorContent}set editorContent(t){this._editorContent=t}get adapter(){return this._adapter}set adapter(t){this._adapter=t}get properties(){return this._properties}set properties(t){this._properties=t}getProperty(t){return this._properties?.[t]}setProperty(t,e){this._properties||(this._properties={}),this._properties[t]=e}get format(){return this._format}set format(t){this._format=t,this._valueFormatter=null}get valueFormatter(){return this._valueFormatter}constructor(t,e){this.model=t,this._type=null,this._clickable=!1,e&&this.populate(e)}populate(t){this._renderer=t.renderer,this._afterRenderer=t.afterRenderer,this._commentRenderer=t.commentRenderer,this._name=t.name,this._type=t.t,this._editorContent=t.content,this._adapter=t.adapter,this._format=t.z,this._formula=t.f,this._editable=t.e,this._commentable=t.commentable,this._clickable=t.clickable,this._allowInvalid=t.allowInvalid,this._properties=t.props,this._style=null==t.s?null:this.model.styles.add(t.s).id}update(t){const e={};if(null!=t.renderer&&(e.renderer=this._renderer,this._renderer=t.renderer),null!=t.afterRenderer&&(this._afterRenderer=t.afterRenderer),null!=t.commentRenderer&&(this._commentRenderer=t.commentRenderer),null!=t.name&&(e.name=this._name,this._name=t.name),null!=t.t&&(e.t=this._type,this._type=t.t),null!=t.content&&(e.content=this._editorContent,this._editorContent=t.content),null!=t.adapter&&(e.adapter=this._adapter,this._adapter=t.adapter),null!=t.z&&(e.z=this._format,this._format=t.z),null!=t.f&&(e.f=this._formula,this._formula=t.f),null!=t.e&&(e.e=this._editable,this._editable=t.e),null!=t.commentable&&(e.commentable=this._commentable,this._commentable=t.commentable),null!=t.clickable&&(e.clickable=this._clickable,this._clickable=t.clickable),null!=t.allowInvalid&&(e.allowInvalid=this._allowInvalid,this._allowInvalid=t.allowInvalid),null!=t.props&&(e.props=this._properties,this._properties=t.props),null!=t.s){const i=this.model.styles.add(t.s).id;this._style!==i&&(e.s=this._style,this._style=i)}return e}getSourceData(){const t={};return null!=this._type&&(t.t=this._type),null!=this._format&&(t.z=this._format),null!=this._formula&&(t.f=this._formula),null!=this._editable&&(t.e=this._editable),null!=this._commentable&&(t.commentable=this._commentable),null!=this._clickable&&(t.clickable=this._clickable),this._properties&&(t.props=it(this._properties)),null!=this._editorContent&&(t.content=q(this._editorContent)?it(this._editorContent):this._editorContent),null!=this._style&&(t.s=this._style),null!=this._name&&(t.name=this._name),t}setStyleProperties(t,e=!1){this.style=e?this.model.styles.set(this.style,t).id:this.model.styles.duplicate(this.style,t).id}removeStyleProperties(t){null!==this.style&&this.model.styles.unset(this.style,t)}get composedStyle(){return this.model.styles.get(this.style)}}function Iy(t){const e={};return t.split(";").forEach((t=>{const[i,o]=t.split(":");e[i]=o.trim()})),e}const Hy=new Map([["thin",{width:1.5,style:"solid"}],["medium",{width:2,style:"solid"}],["thick",{width:3,style:"solid"}],["double",{width:3,style:"double"}],["dotted",{width:1.5,style:"dotted"}],["hair",{width:1,style:"solid"}],["dashed",{width:1.5,style:"dashed"}],["mediumDashed",{width:2,style:"dashed"}],["dashDot",{width:1.5,style:"dashed"}],["mediumDashDot",{width:2,style:"dashed"}],["dashDotDot",{width:1.5,style:"dotted"}],["mediumDashDotDot",{width:2,style:"dotted"}],["slantDashDot",{width:1.5,style:"dashed"}],["none",{width:1.5,style:"solid"}]]),Ty=(()=>{const t=new Map;return Hy.forEach(((e,i)=>{let o=t.get(e.style);o||(o=t.set(e.style,new Map).get(e.style)),o.set(e.width,i)})),t})();function Ay(t){return"middle"==t?"center":t}function Oy(t){return 3==(t="#"==t.charAt(0)?t.substring(1):t).length?t[0]+t[0]+t[1]+t[1]+t[2]+t[2]:t}const $y=t=>{if("none"==t)return null;const e=t.split(" "),i=parseInt(e[0].charAt(0))||1,o=e.length>1?e[1]:"solid",n=Ty.get(o);return{style:(n?n.get(i):null)??"thin",color:e.length>2?Oy(e[2]):"CCCCCC"}},Dy=t=>{const e=Hy.get(t.style||"none");return e?[It(e.width),e.style,"none"==t.style?"var(--og-cell-background)":`#${t.color}`].join(" "):"none"},Ny=(t,e)=>{const i="#"+(e.fgColor||"000000"),o="#"+(e.bgColor||"FFFFFF");switch(e.patternType){case"solid":t.backgroundColor=i||o;break;case"darkGray":t.backgroundColor=fn(o,.75);break;case"mediumGray":t.backgroundColor=fn(o,.5);break;case"lightGray":t.backgroundColor=fn(o,.25);break;case"gray125":t.backgroundColor=fn(o,.125);break;case"gray0625":t.backgroundColor=fn(o,.0625);break;case"darkHorizontal":t.backgroundImage=`linear-gradient(0deg, ${i} 33.33%, ${o} 33.33%, ${o} 50%, ${i} 50%, ${i} 83.33%, ${o} 83.33%, ${o} 100%)`,t.backgroundSize="6px 6px";break;case"darkVertical":t.backgroundImage=`linear-gradient(90deg, ${i} 33.33%, ${o} 33.33%, ${o} 50%, ${i} 50%, ${i} 83.33%, ${o} 83.33%, ${o} 100%)`,t.backgroundSize="6px 6px";break;case"darkDown":t.backgroundImage=`linear-gradient(45deg, ${i} 33.33%, ${o} 33.33%, ${o} 50%, ${i} 50%, ${i} 83.33%, ${o} 83.33%, ${o} 100%)`,t.backgroundSize="6px 6px";break;case"darkUp":t.backgroundImage=`linear-gradient(-45deg, ${i} 33.33%, ${o} 33.33%, ${o} 50%, ${i} 50%, ${i} 83.33%, ${o} 83.33%, ${o} 100%)`,t.backgroundSize="6px 6px";break;case"lightHorizontal":t.backgroundImage=`linear-gradient(0deg, ${o} 25%, ${i} 25%, ${i} 50%, ${o} 50%, ${o} 75%, ${i} 75%, ${i} 100%)`,t.backgroundSize="4px 4px";break;case"lightVertical":t.backgroundImage=`linear-gradient(90deg, ${o} 25%, ${i} 25%, ${i} 50%, ${o} 50%, ${o} 75%, ${i} 75%, ${i} 100%)`,t.backgroundSize="4px 4px";break;case"lightDown":t.backgroundImage=`linear-gradient(45deg, ${o} 25%, ${i} 25%, ${i} 50%, ${o} 50%, ${o} 75%, ${i} 75%, ${i} 100%)`,t.backgroundSize="4px 4px";break;case"lightUp":t.backgroundImage=`linear-gradient(-45deg, ${o} 25%, ${i} 25%, ${i} 50%, ${o} 50%, ${o} 75%, ${i} 75%, ${i} 100%)`,t.backgroundSize="4px 4px";break;case"darkGrid":t.backgroundImage=`linear-gradient(${o} 0.5px, transparent 0.5px), linear-gradient(90deg, ${o} 0.5px, transparent 0.5px)`,t.backgroundSize="2px 2px";break;case"lightGrid":t.backgroundImage=`linear-gradient(${o} 0.5px, transparent 0.5px), linear-gradient(90deg, ${o} 0.5px, transparent 0.5px)`,t.backgroundSize="1px 1px";break;case"darkTrellis":t.backgroundImage=`linear-gradient(45deg, ${o} 0.5px, transparent 0.5px), linear-gradient(90deg, ${o} 0.5px, transparent 0.5px)`,t.backgroundSize="2px 2px";break;case"lightTrellis":t.backgroundImage=`linear-gradient(45deg, ${o} 0.5px, transparent 0.5px), linear-gradient(90deg, ${o} 0.5px, transparent 0.5px)`,t.backgroundSize="1px 1px"}return t},Py=(t,e)=>(t.backgroundImage=`linear-gradient(${(e.angle??0)+90}deg,${e.stops.map((t=>`#${t.rgb} ${100*t.v}%`)).join(",")})`,t),jy=t=>{const e=t.cssStyle?{...t.cssStyle}:{};return null!=t.bold&&(e.fontWeight=t.bold?"bold":"normal"),t.italic&&(e.fontStyle="italic"),t.underline?e.textDecoration="underline":t.strike&&(e.textDecoration="line-through"),t.sz&&(e.fontSize=Rt(t.sz)),t.color&&(e.color="#"+t.color),t.top&&(e.borderTop=Dy(t.top)),t.right&&(e.borderRight=Dy(t.right)),t.bottom&&(e.borderBottom=Dy(t.bottom)),t.left&&(e.borderLeft=Dy(t.left)),(t.top||t.right||t.bottom||t.left)&&(e.zIndex="1"),t.alignment&&t.alignment.vertical?(e.display="flex",e.justifyContent=t.alignment.horizontal,e.alignItems="top"==t.alignment.vertical?"start":"bottom"==t.alignment.vertical?"end":"center"):t.alignment&&t.alignment.horizontal&&(e.textAlign=t.alignment.horizontal),t.alignment&&t.alignment.wrapText&&(e.display="flex",e.justifyContent=e.justifyContent??"left",e.alignItems=e.alignItems??"center",e.whiteSpace="normal"),t.patternType?Ny(e,t):t.stops&&t.stops.length?Py(e,t):t.fgColor?e.backgroundColor="#"+t.fgColor:t.bgColor&&(e.backgroundColor="#"+t.bgColor),e},Vy=t=>{const e=q(t)?t:Iy(t),i={};let o;for(const t in e){const n=e[t];if(null!=n)switch(t){case"borderTop":case"border-top":i.top=$y(n);break;case"borderTopColor":case"border-top-color":i.top?i.top.color=Oy(n):i.top={style:"thin",color:Oy(n)};break;case"borderRight":case"border-right":i.right=$y(n);break;case"borderRightColor":case"border-right-color":i.right?i.right.color=Oy(n):i.right={style:"thin",color:Oy(n)};break;case"borderBottom":case"border-bottom":i.bottom=$y(n);break;case"borderBottomColor":case"border-bottom-color":i.bottom?i.bottom.color=Oy(n):i.bottom={style:"thin",color:Oy(n)};break;case"borderLeft":case"border-left":i.left=$y(n);break;case"borderLeftColor":case"border-left-color":i.left?i.left.color=Oy(n):i.left={style:"thin",color:Oy(n)};break;case"border":o=$y(n),i.top=i.top||o,i.right=i.right||o,i.bottom=i.bottom||o,i.left=i.left||o;break;case"textAlign":case"text-align":i.alignment=i.alignment||{},i.alignment.horizontal=n;break;case"verticalAlign":case"vertical-align":i.alignment=i.alignment||{},i.alignment.vertical=Ay(n);break;case"whiteSpace":case"white-space":i.alignment=i.alignment||{},i.alignment.wrapText=n&&"nowrap"!=n;break;case"color":i.color=Oy(n);break;case"background":case"backgroundColor":i.fgColor=Oy(n);break;case"fontSize":case"font-size":i.sz=parseFloat(n);break;case"fontWeight":case"font-weight":i.bold="bold"==n;break;case"fontStyle":case"font-style":i.italic="italic"==n;break;default:i[t]=n}}return i},By={n:t=>{const e=Z(t)?parseFloat(t):t;return Number.isNaN(e)?t:e},t:t=>t,d:(t,e)=>Z(t)?X(t)?Q(t):Do(zo(t,e.model.options.formatLocale)):t instanceof Date?Do(t):t,tm:t=>Z(t)?new Date(t):t,dt:t=>Z(t)?new Date(t):t,b:t=>!!t&&"0"!==t&&"false"!==t.toString().toLowerCase(),s:t=>t,m:t=>t,g:t=>{if(null==t)return null;const e=parseFloat(t);return isNaN(e)?t:e},a:t=>Z(t)?JSON.parse(t):t,h:t=>t},Fy=new Map;class Wy extends Ry{get tooltip(){return this._tooltip}set tooltip(t){this._tooltip=t}get hasTooltip(){return null!=this._tooltip}get rowspan(){return this._rowspan}set rowspan(t){this._rowspan=t}get colspan(){return this._colspan}set colspan(t){this._colspan=t}get r(){return this.row.index}get c(){return this.column.index}get hasValue(){return null!=this._value}get value(){return this._evaluated||this.evaluate(),this._value}set value(t){if(t&&dv(t.toString()))this._value=void 0,this.formula=t;else{const e=By[this.type](t,this);e!==this._value&&(this._value=e,this._displayValue=void 0),this.row.data&&this.column.data&&(this.row.data[this.column.data]=this._value)}}evaluate(){return this._value=By[this.type](this.model.calculations.evaluate(this),this),this._evaluated=!0,this._value}get value2(){return this.hasFormula?uv(this.formula):this.value}get hasDisplayValue(){return null!=this._displayValue}get displayValue(){return this._displayValue}set displayValue(t){this._displayValue=t}get prefersDisplayValue(){return["s","m"].includes(this.type)}get error(){return this._error}set error(t){this._error=t}get hasError(){return!!this._error}clearError(){this._error=void 0}get spillRange(){return this._spillRange}get prevSpillRange(){return this._prevSpillRange}set spillRange(t){!this._spillRange||t&&this._spillRange.equals(t)||(this._prevSpillRange=this._spillRange),this._spillRange=t}get isSpillSource(){return null!=this._spillRange}get spillSource(){return this._spillSource}get isSpilled(){return null!=this._spillSource}spillValue(t,e){this.value=t,this._spillSource=e}clearSpilledValue(){this._spillSource=void 0,this._value=void 0}get hasSparkline(){return null===this._sparkline?this._sparkline=this.model.sparklines.has(this.address):this._sparkline}get hasComment(){return null===this._hasComment?this._hasComment=(this.model.comments.get(this.address)??[]).length>0:this._hasComment}get comments(){return this.model.comments.get(this.address)}get valueFormatter(){const t=super.valueFormatter??this.row.valueFormatter??this.column.valueFormatter;if(t)return t;const e=this.type,i=this.format,{locale:o,fixNumberFormat:n}=this.model.options,r=this.value;if(null==r||""===r)return null;if("n"==e)return null!=i?Go(o,i,n):this.model.options.numberFormatter;if("g"==e){if(null!=i)return Go(o,i,n);if(K(r))return this.model.options.numberFormatter}else{if("t"==e)return null==i?null:Go(o,i,!1);if("d"==e)return i?Lo(o,i):this.model.options.dateFormatter;if("s"==e&&this.editorContent)return(t=>{if(t=t||null,!Fy.has(t))if(t){const e=t.reduce(((t,e)=>t.set(e.k,e.v)),new Map);Fy.set(t,(t=>e.has(t)?e.get(t):t))}else Fy.set(t,(t=>t));return Fy.get(t)})(this.editorContent)}return null}get formattedValue(){return null==this.value?"":this.hasDisplayValue?this.displayValue:this.valueFormatter?this.valueFormatter(this.value):this.value.toString()}get elm1(){return this.row.priority>=this.column.priority?this.row:this.column}get elm2(){return this.row.priority<this.column.priority?this.row:this.column}get clickable(){return super.clickable??this.elm1.clickable??this.elm2.clickable}get type(){return super.type??this.elm1.type??this.elm2.type??"g"}set type(t){this._type=t}get editorContent(){return super.editorContent??this.elm1.editorContent??this.elm2.editorContent??null}get adapter(){return super.adapter??this.elm1.adapter??this.elm2.adapter}set adapter(t){this._adapter=t}get address(){return this.column.address+this.row.address}get range(){return Jm.fromA1(this.address)}get allowInvalid(){return super.allowInvalid??this.elm1.allowInvalid??this.elm2.allowInvalid??this.model.options.allowInvalid}get editable(){return super.editable??this.elm1.editable??this.elm2.editable??this.model.options.editable}set editable(t){this._editable=t}get commentable(){return super.commentable??this.elm1.commentable??this.elm2.commentable??this.model.options.commentable}get renderer(){return super.renderer??this.elm1.renderer??this.elm2.renderer}get afterRenderer(){return super.afterRenderer??this.elm1.afterRenderer??this.elm2.afterRenderer??this.model.options.afterRenderer}get commentRenderer(){return super.commentRenderer??this.elm1.commentRenderer??this.elm2.commentRenderer??this.model.options.comments.renderer}get format(){return super.format??this.elm1.format??this.elm2.format}set format(t){super.format=t}get hasOwnFormula(){return!!this._formula}get hasFormula(){return null==this._hasFormula&&(this._hasFormula=!!this.formula),this._hasFormula}get formula(){return this._formula??this.elm1.formula??this.elm2.formula}set formula(t){super.formula=t,this.refreshFormula()}invalidateValue(){this.hasFormula?(this._value=void 0,this._evaluated=!1):this._evaluated=!0,this.clearError()}refreshFormula(){this.invalidateValue(),this._hasFormula=null}clearFormula(){this._formula=null,this._hasFormula=!1,this._evaluated=!0}constructor(t,e){super(t),this._evaluated=!0,this._sparkline=null,this._hasComment=null,this._hasStyle=null,this.row=t.rows[e.r],this.column=t.columns[e.c],this.populate(e)}populate(t){super.populate(t),this._colspan=t.cs??1,this._rowspan=t.rs??1,this._tooltip=t.tooltip,null!=t.f?this._evaluated=!1:null!=t.v&&(this.value=t.v),this._displayValue=t.dv}update(t){const e=super.update(t);return null!=t.cs&&(e.cs=this._colspan,this._colspan=t.cs),null!=t.rs&&(e.rs=this._rowspan,this._rowspan=t.rs),null!=t.tooltip&&(e.tooltip=this._tooltip,this._tooltip=t.tooltip),null!=t.f?this._evaluated=!1:null!=t.v&&(e.v=this.value,this.value=t.v),null!=t.dv&&(e.dv=this._displayValue,this._displayValue=t.dv),e}getSourceData(t){const e=super.getSourceData();return this._colspan>1&&(e.cs=this._colspan),this._rowspan>1&&(e.rs=this._rowspan),null!=this.value&&(e.v=this.value),this.hasTooltip&&(e.tooltip=this._tooltip),t&&t.displayValue&&this.hasDisplayValue&&(e.dv=this._displayValue),e}createComposedStyle(t,e,i){const o=[];return t=t||this.column.style,e=e||this.row.style,null!=t&&null!=e?this.column.priority>this.row.priority?o.push(e,t):o.push(t,e):null!=t?o.push(t):null!=e&&o.push(e),null!=this.style&&o.push(this.style),null!=i&&o.push(i),o.length>0?this.model.styles.merge(...o):null}get composedStyle(){if(null===this._hasStyle){const t=this.createComposedStyle(null,null,this.model.conditionalFormats.evaluate(this));this._hasStyle=null!=t,this._composedStyle=t}return this._composedStyle}get calculatedIndent(){const t=this.composedStyle;return t?.alignment?.indent?t.alignment.indent:this.column.levelIndent&&this.row.level>0?this.row.level*this.model.options.levelIndentFactor:null}get cssStyle(){if(!1===this._hasStyle)return null;if(!this._cssStyle){const t=this.composedStyle;t&&(this._cssStyle=jy(t))}return this._cssStyle}invalidateStyle(){this._hasComment=null,this._hasStyle=null,this._composedStyle=null,this._cssStyle=null,this._sparkline=null}setStyleProperties(t){super.setStyleProperties(t),this.invalidateStyle()}removeStyleProperties(t){super.removeStyleProperties(t),this.invalidateStyle()}previewStyleProperties(t,e="cell"){const i=Object.assign({},this.createComposedStyle("column"==e?t:null,"row"==e?t:null)??{});if("cell"==e)for(const e in t)i[e]=t[e];this._hasStyle=!0,this._cssStyle=jy(i)}toString(){return this.address}}const Uy={property:"value",enabled:!0};class Gy extends(hn(Ry)){get comparer(){return this._comparer}set comparer(t){this._comparer=t}get filter(){return this._filter??(this.model.options.filters?.enabled?Uy:{enabled:!1})}set filter(t){this._filter=t}get hasFilter(){return this.filter.enabled}get sorting(){return this._sorting??this.model.options.columnSorting}set sorting(t){this._sorting=t}get width(){return this._width??this.model.options.columnWidth}set width(t){this._width=t}get levelIndent(){return this._levelIndent}set levelIndent(t){this._levelIndent=t}get levelButtons(){return this._levelButtons}set levelButtons(t){this._levelButtons=t}get priority(){return this._priority}set priority(t){this._priority=t}get address(){return iv(this.index)}get range(){return new Jm(this.index,null,this.index,null)}get hasFormula(){return!!this._formula}get formula(){return this._formula}set formula(t){super.formula=t;const e=this.index;this.model.rows.forEach((t=>t.cells[e]?.refreshFormula()))}constructor(t,e){super(t,e),null==this._priority&&(this._priority=t.options.columnPriority)}get mergedHeaders(){return this._mergedHeaders??(this._mergedHeaders=this._header?.filter((t=>t.cs>1||t.rs>1))??[])}updateMergedHeaders(){this._mergedHeaders=null}set header(t){this._mergedHeaders=null,this._header=t}get header(){if(!this._header||this._header.length<this.model.headerCount){this._header=this._header??[];for(let t=this._header.length;t<this.model.headerCount;t++)this._header.push({r:t})}return this._header}convertSourceHeader(t){return Array.isArray(t)?t.map(((t,e)=>((t=t??{r:e}).r=e,t._style=null==t.style?null:this.model.styles.add(t.style).id,t))):Z(t)?[{label:t,r:0}]:null}populate(t){super.populate(t),this._width=t.w,this._levelIndent=t.levelIndent,this._levelButtons=t.levelButtons,this._header=this.convertSourceHeader(t.header),this._sorting=t.sorting,this._filter=q(t.filter)?Object.assign({enabled:!0},t.filter):t.filter?Uy:!1===t.filter?{enabled:!1}:null,this._comparer=t.comparer,this.data=t.data,this._mergedHeaders=null,null!=t.priority&&(this._priority=t.priority)}getSourceData(){const t=super.getSourceData();return null!=this._width&&(t.w=this._width),null!=this._levelIndent&&(t.levelIndent=this._levelIndent),null!=this._levelButtons&&(t.levelButtons=this._levelButtons),null!=this._header&&(t.header=this._header),null!=this._sorting&&(t.sorting=this._sorting),null!=this._filter&&(t.filter=this._filter),null!=this.data&&(t.data=this.data),t}expand(t){super.expand(t),this.model.indexVisibleColumns()}collapse(){super.collapse(),this.model.indexVisibleColumns()}get prev(){return this.model.columns[this.index-1]}get next(){return this.model.columns[this.index+1]}get prevVisible(){const t=this.model.visibleColumnIndex[this.index];return null==t||0===t?null:this.model.visibleColumns[t-1]}get nextVisible(){const t=this.model.visibleColumnIndex[this.index];return null==t?null:this.model.visibleColumns[t+1]}calculateRealColspan(t){let e=1,i=this.nextVisible;for(;i&&i.index-this.index<t&&e<t;)++e,i=i.nextVisible;return e}cell(t){return this.model.rows[t].cell(this.index)}clearCalculatedValues(){this.model.rows.forEach((t=>{const e=t.cells[this.index];e&&this.model.calculations.refreshFormula(e)}))}}var qy;!function(t){t[t.Asc=1]="Asc",t[t.Desc=-1]="Desc"}(qy||(qy={}));const Yy={g:(t,e)=>t.value==e.value?0:t.value>e.value?1:-1,t:(t,e)=>(t.value||"").toString().localeCompare((e.value||"").toString()),s:(t,e)=>t.value==e.value?0:t.value>e.value?1:-1,m:(t,e)=>t.value==e.value?0:t.value>e.value?1:-1,n:(t,e)=>t.value-e.value,d:(t,e)=>(t.value instanceof Date?t.value.getTime():0)-(e.value instanceof Date?e.value.getTime():0),tm:(t,e)=>(t.value instanceof Date?t.value.getTime():0)-(e.value instanceof Date?e.value.getTime():0),dt:(t,e)=>(t.value instanceof Date?t.value.getTime():0)-(e.value instanceof Date?e.value.getTime():0),b:(t,e)=>t.value-e.value,h:(t,e)=>(t.value||"").localeCompare(e.value),a:()=>0},Zy={g:(t,e)=>e.value==t.value?0:e.value>t.value?1:-1,t:(t,e)=>(e.value||"").toString().localeCompare((t.value||"").toString()),s:(t,e)=>e.value==t.value?0:e.value>t.value?1:-1,m:(t,e)=>e.value==t.value?0:e.value>t.value?1:-1,n:(t,e)=>e.value-t.value,d:(t,e)=>(e.value instanceof Date?e.value.getTime():0)-(t.value instanceof Date?t.value.getTime():0),tm:(t,e)=>(e.value instanceof Date?e.value.getTime():0)-(t.value instanceof Date?t.value.getTime():0),dt:(t,e)=>(e.value instanceof Date?e.value.getTime():0)-(t.value instanceof Date?t.value.getTime():0),b:(t,e)=>e.value-t.value,h:(t,e)=>(e.value||"").localeCompare(t.value),a:()=>0},Xy=(t,e)=>t.origIndex-e.origIndex;class Qy extends EventTarget{get settings(){return this._settings}set settings(t){this._settings=t,this.colMap.clear(),this.settings.length>0&&(this.settings.forEach(((t,e)=>this.colMap.set(t.c,e))),this.applySort(),an().info(`sorting applied: ${JSON.stringify(this.settings)}`))}constructor(t,e=[]){super(),this.model=t,this.colMap=new Map,this._settings=[],this.settings=e}get(t){return this.colMap.has(t)?this.settings[this.colMap.get(t)]:null}sort(t,e=null,i=!1){let o=this.get(t);return o&&o.ord==qy.Desc&&null===e?(this.settings.splice(this.colMap.get(t),1),o=null):o?(o.ord=qy.Desc,this.settings.splice(this.colMap.get(t),1)):o={c:t,ord:qy.Asc},o&&(null!==e&&(o.ord=e),this.colMap.set(t,0),this.settings.unshift(o)),this.settings.length>this.model.options.maxSortingColumns&&this.settings.pop(),this.colMap.clear(),this.settings.forEach(((t,e)=>{t.index=e,this.colMap.set(t.c,e)})),i||(this.settings.length>0?this.applySort():this.resetSort()),o}applySort(){const t=this.model,e=this.settings.map((e=>{const i=t.columns[e.c];return i?i.comparer?e.ord==qy.Asc?i.comparer:(t,e)=>-i.comparer(t,e):e.ord==qy.Asc?Yy[i.type??"t"]:Zy[i.type??"t"]:(an().warn(`Column sorting: Column with index ${e.c} not found`),null)})).filter((t=>t)),i=e.length;let o,n,r;t.rowRoot.sort(((t,s)=>{if(!1===t.sortable||!1===s.sortable)return t.origIndex-s.origIndex;for(n=0;n<i;n++)if(r=this.settings[n].c,o=e[n](t.cell(r),s.cell(r)),0!=o)return o;return 0})),t.indexRowsByTree()}resetSort(){this.settings=[],this.colMap.clear(),this.model.rowRoot.sort(Xy),this.model.indexRowsByTree()}persistSort(){this.model.rows.forEach(((t,e)=>t.origIndex=e))}}class Ky{get properties(){return this._properties}set properties(t){this._properties=t}constructor(t){t&&this.pupulate(t)}pupulate(t){this.author=t.author,this.text=t.text,this.date=t.date?new Date(t.date):null,this.data=t.data,this.readOnly=!!t.readOnly,this._properties=t.props}getSourceData(){const t={};return this._properties&&(t.props=this._properties),this.author&&(t.author=this.author),this.text&&(t.text=this.text),this.data&&(t.data=this.data),null!==this.readOnly&&(t.readOnly=this.readOnly),this.date&&(t.date=Lo("en-US")(this.date,"yyyy-MM-dd HH:mm:ss")),t}}class Jy{constructor(t,e){this.model=t,this._commentMap=new Map,this.has=t=>this._commentMap.has(t),this.delete=t=>this._commentMap.delete(t),this.cleanCell=t=>{this.has(t)&&this._commentMap.set(t,this.get(t).filter((t=>(t.text??"").length>0||null!=t.data)))},this.get=t=>(this.has(t)||this._commentMap.set(t,[]),this._commentMap.get(t)),this.set=(t,e)=>{this._commentMap.set(t,e),this.cleanCell(t)},e&&this.populate(e)}populate(t){t.forEach((t=>{const e=t.a1||new Jm(t.c,t.r).A1;this._commentMap.has(e)||this._commentMap.set(e,[]),this._commentMap.get(e).push(new Ky(t))})),this._commentMap.forEach((t=>{t.sort(((t,e)=>(e.date?e.date.getTime():0)-(t.date?t.date.getTime():0)))}))}shift(t){Array.from(this._commentMap.keys()).forEach((e=>{const i=Jm.fromA1(e);i.shift(t),i.A1!=e&&(this._commentMap.set(i.A1,this._commentMap.get(e)),this._commentMap.delete(e))}))}}class tw{get tokenizer(){return this._tokenizer}get dependencies(){return this._dependencies}get formulas(){return this._formulas}constructor(t){this.model=t,this._tokenizer=new Xm,this._formulas=new Map,this._dependencies=new cw(t),this.context=new Sy(t)}createFormula(t){const e=new vv(t.formula,this.tokenizer);return this._formulas.set(t.address,e),t.hasOwnFormula&&(t.formula=e.createFormulaString()),this.createDependecies(t),e}createDependecies(t){const e=t.address;if(this.formulas.has(e)){const i=this.formulas.get(e);i.ranges.forEach((([t,i,o])=>this._dependencies.add(e,i.A1,o))),i.cells.forEach((([t,i,o])=>this._dependencies.add(e,i.A1,o))),i.variables.forEach((([i,o])=>{const n=this.model.getCellByName(o,t.range);n&&this._dependencies.add(e,n.address,null)}))}return this}refreshFormula(t){return t.refreshFormula(),this.formulas.delete(t.address),this.clearDependecies(t),this}updateDependencies(t){return this.clearDependecies(t).getFormula(t),this}getFormula(t){return this._formulas.has(t.address)?this._formulas.get(t.address):this.createFormula(t)}refresh(){this.dependencies.clear(),this._formulas.clear()}clearDependecies(t){const e=t.address;return this.dependencies.clearCellDependecies(e),this.formulas.delete(e),this}evaluateFormula(t,e){return this.context.currentCell=e,t.fn(this.context,{cell:e,formula:t})}evaluateExpression(t,e){this.context.currentCell=e;const i=new vv(t,this.tokenizer);return i.fn(this.context,{cell:e,formula:i})}evaluate(t,e){if(!t)return null;let i=null;if(t.hasFormula){const o=this.getFormula(t);try{t.clearError(),this.context.currentCell=t,i=o.fn(this.context,{cell:t,formula:o}),Array.isArray(i)?(e||this.model.spillValues({cell:t,values:i}).range,i=i.length>0&&i[0].length>0?i[0][0]:null,e&&(t.value=i)):t.value=i}catch(e){t.error=function(t){return t instanceof RangeError?"Maximum call stack size exceeded"==t.message?"infinite loop":t.message:t.toString()}(e)}}else i=t.value;return i}evaluateAll(){this.model.rows.forEach((t=>this.model.columns.forEach(((e,i)=>t.cell(i).evaluate()))))}calculateViewport(t){const e=[];return t.rows.forEach((t=>t.cells.forEach((t=>{if(t.hasFormula){if(!t.hasValue&&(this.evaluate(t),t.spillRange))for(const i of this.model.getRangeIterator(t.spillRange))e.push(i);e.push(t)}})))),e}shift(t){this.getFormulaCells().forEach((e=>{e.formula=this.getFormula(e).shift(t).createFormulaString(!1),this.updateDependencies(e)}));const e=this.model.name;return this.dependencies.sheetDependants.forEach((i=>{const o=this.model.getConnectedModel(i);o?.calculations.getFormulaCells().forEach((i=>{const n=o.calculations.getFormula(i);n.hasSheetReference(e)&&(i.formula=n.shift(t).createFormulaString(!1),o.calculations.updateDependencies(i))}))})),this}getFormulaCells(){const t=this.model,e=[];let i;const o=t.rows.length,n=t.columns.length;for(let r=0;r<o;r++){i=t.rows[r];for(let t=0;t<n;t++)i.hasCellFormula(t)&&e.push(i.cell(t))}return e}renameSheet(t,e){let i=!1;return this.dependencies.renameSheet(t,e),this.getFormulaCells().forEach((o=>{const n=this.getFormula(o);n.renameSheet(t,e)&&(o.formula=n.createFormulaString(),this.refreshFormula(o),i=!0)})),i}invalidateCellDependants(t){const e=[];return this.dependencies.getDependants(t.range).forEach((([t,i])=>{e.push([t,i]),t.invalidateValue()})),e}invalidateDependants(t){const e=new Map,i=new Map;for(const i of t)this.invalidateCellDependants(i).forEach((([t,i])=>e.set(t,i)));e.forEach(((t,e)=>i.set(e,t)));for(const i of t)e.set(i,null);return e.forEach(((t,e)=>{this.model.sparklines.dependencies.getDependants(e.range).forEach((([t,e])=>{i.set(t,e)})),this.model.conditionalFormats.dependencies.getDependants(e.range).forEach((([t,e])=>{this.model.conditionalFormats.invalidateExtremes(t),t.invalidateStyle(),i.set(t,e)}))})),i}}const ew="#ff0000",iw="#fcd53f",ow="#00bb5e",nw="#555555",rw=new Map([["3Arrows",[{icon:["fas","down"],color:ew},{icon:["fas","right"],color:iw},{icon:["fas","up"],color:ow}]],["3ArrowsGray",[{icon:["fas","down"],color:nw},{icon:["fas","right"],color:nw},{icon:["fas","up"],color:nw}]],["3Flags",[{icon:["fas","flag-pennant"],color:ew},{icon:["fas","flag-pennant"],color:iw},{icon:["fas","flag-pennant"],color:ow}]],["3TrafficLights1",[{icon:["fas","circle"],color:ew},{icon:["fas","circle"],color:iw},{icon:["fas","circle"],color:ow}]],["3TrafficLights2",[{icon:["fas","square-o"],color:ew},{icon:["fas","square-o"],color:iw},{icon:["fas","square-o"],color:ow}]],["3Signs",[{icon:["fas","square"],rotation:45,color:ew},{icon:["fas","triangle"],color:iw},{icon:["fas","circle"],color:ow}]],["3Symbols",[{icon:["fas","circle-xmark"],color:ew},{icon:["fas","circle-exclamation"],color:iw},{icon:["fas","circle-check"],color:ow}]],["3Symbols2",[{icon:["fas","xmark"],color:ew},{icon:["fas","exclamation"],color:iw},{icon:["fas","check"],color:ow}]],["3Stars",[{icon:["fal","star"],color:iw},{icon:["fas","star-half-stroke"],color:iw},{icon:["fas","star"],color:iw}]],["3Triangles",[{icon:"caret-down",color:ew},{icon:"dash",color:iw},{icon:"caret-up",color:ow}]],["4Arrows",[{icon:["fas","down"],color:ew},{icon:["fas","down-right"],color:iw},{icon:["fas","up-right"],color:iw},{icon:["fas","up"],color:ow}]],["4ArrowsGray",[{icon:["fas","down"],color:nw},{icon:["fas","down-right"],color:nw},{icon:["fas","up-right"],color:nw},{icon:["fas","up"],color:nw}]],["4RedToBlack",[{icon:["fas","circle"],color:"#000000"},{icon:["fas","circle"],color:"#b1b1b1"},{icon:["fas","circle"],color:"#edb2a3"},{icon:["fas","circle"],color:ew}]],["4Rating",[{icon:"signal-bars-weak",color:"#4a7db1"},{icon:"signal-bars-fair",color:"#4a7db1"},{icon:"signal-bars-good",color:"#4a7db1"},{icon:["fas","signal-bars"],color:"#4a7db1"}]],["4TrafficLights",[{icon:["fas","circle"],color:"#000000"},{icon:["fas","circle"],color:ew},{icon:["fas","circle"],color:iw},{icon:["fas","circle"],color:ow}]],["5Arrows",[{icon:["fas","down"],color:ew},{icon:["fas","down-right"],color:iw},{icon:["fas","right"],color:iw},{icon:["fas","up-right"],color:iw},{icon:["fas","up"],color:ow}]],["5ArrowsGray",[{icon:["fas","down"],color:nw},{icon:["fas","down-right"],color:nw},{icon:["fas","right"],color:nw},{icon:["fas","up-right"],color:nw},{icon:["fas","up"],color:nw}]],["5Rating",[{icon:["fal","signal-bars"]},{icon:["fal","signal-bars-weak"],color:"#4a7db1"},{icon:["fal","signal-bars-fair"],color:"#4a7db1"},{icon:["fal","signal-bars-good"],color:"#4a7db1"},{icon:["fas","signal-bars"],color:"#4a7db1"}]],["5Quarters",[{icon:["fal","circle"],color:"#505050"},{icon:["fas","circle-quarter-stroke"],color:"#505050"},{icon:["fas","circle-half-stroke"],color:"#505050"},{icon:["fas","circle-three-quarters-stroke"],color:"#505050"},{icon:["fas","circle"],color:"#505050"}]]]),sw=(t,e)=>{const i=rw.get(t);return i?i[e]:null};class aw{get dependencies(){return this._dependencies}constructor(t,e){this.model=t,this.formats=[],this.cellFormatMap=new Map,this.extremes=new Map,this._dependencies=new cw(t),e&&this.populate(e)}populate(t){t.forEach((t=>{try{this.add(t)}catch(e){an().error(`conditional format error: ${JSON.stringify(t)}`,e)}}))}refresh(){this.dependencies.clear(),this.cellFormatMap.clear(),this.extremes.clear(),this.formats.forEach((t=>this.initConditionalFormat(t)))}clearCellDependecies(t){const e=t.address;return this.dependencies.clearCellDependecies(e),this.cellFormatMap.get(e).forEach((t=>({cf:t.cf}))),this}getExtremes(t){if(!this.extremes.has(t.key)){let e=1/0,i=-1/0;t.ranges.forEach((t=>{for(const o of this.model.getValuesInRange(t))for(const t of o)null!=t&&(isNaN(t)||(e=Math.min(e,t),i=Math.max(i,t)))})),this.extremes.set(t.key,[e,i])}return this.extremes.get(t.key)}invalidateExtremes(t){this.cellFormatMap.get(t.address).forEach((t=>this.extremes.delete(t.cf.key)))}evaluateScaleFormat(t,e){const i=t.value;if(null==i)return null;const[o,n]=this.getExtremes(e.cf);let r;const s=(i-o)/(n-o);if(e.cf.cmid?.color)r=.5==s?"#"+e.cf.cmid.color:s>.5?bn("#"+e.cf.cmid.color,"#"+e.cf.cmax.color,2*(s-.5)):bn("#"+e.cf.cmin.color,"#"+e.cf.cmid.color,2*s);else{if(!e.cf.cmin?.color||!e.cf.cmax?.color)return null;r=bn("#"+e.cf.cmin.color,"#"+e.cf.cmax.color,s)}return{color:yn(r).substring(1),fgColor:r.substring(1)}}evaluateBarFormat(t,e){const i=t.value;if(null==i)return null;const o=this.getExtremes(e.cf);let n=o[0];const r=o[1],s=n<0;s||(n-=.1*(r-n));const a=Math.round(100*(i-n)/(r-n));e.initialized||(e.initialized=!0,e.cf.ranges.forEach((e=>this._dependencies.add(t.address,e.A1,null))));const l=[];if(s){const t=Math.round(-100*n/(r-n));i>=0?(l.push(`#00000000 ${t}%`),l.push(`#${e.cf.color} ${t}%`),l.push(`#${e.cf.color} ${a}%`),l.push(`#00000000 ${a}%`)):(l.push(`#00000000 ${a}%`),l.push(`#ff0000 ${a}%`),l.push(`#ff0000 ${t}%`),l.push(`#00000000 ${t}%`))}else l.push(`#${e.cf.color} ${a}%`),l.push(`#00000000 ${a}%`);return{cssStyle:{backgroundClip:"padding-box",backgroundImage:`linear-gradient(90deg, ${l.join(",")})`}}}evaluateFormulaFormat(t,e){if(!e.initialized&&e.cf.condition){e.initialized=!0;const i=t.address,o=new vv(e.cf.condition,this.model.calculations.tokenizer);e.f=o.shift({index:0,offset:t.c-e.cf.firstCell.c1,direction:"right"}).shift({index:0,offset:t.r-e.cf.firstCell.r1,direction:"down"}),o.cells.forEach((t=>this._dependencies.add(i,t[1].A1,t[2]))),o.ranges.forEach((t=>this._dependencies.add(i,t[1].A1,t[2]))),o.variables.forEach((([e,o])=>{const n=this.model.getCellByName(o,t.range);n&&this._dependencies.add(i,n.address,null)}))}if(e.f&&!this.model.calculations.evaluateFormula(e.f,t))return null;const i={...e.cf.style};return i.color||wn(yn(xn(e.cf.style.fgColor))),i}evaluateIconFormat(t,e){const i=t.value;if(null==i)return null;const[o,n]=this.getExtremes(e.cf);let r;for(let t=e.cf.thresh.length-1;t>=0;t--){const s=e.cf.thresh[t];if("percent"===s.t){if(null==r&&(r=100*(i-o)/(n-o)),r>=s.v)return{icon:sw(e.cf.v,t)}}else if("num"===s.t&&i>=s.v)return{icon:sw(e.cf.v,t)}}return null}evaluate(t){const e=t.address,i=this.cellFormatMap.get(e);if(!i)return null;let o=null,n=null;for(const e of i){try{switch(e.cf.type){case"formula":n=this.evaluateFormulaFormat(t,e);break;case"scale":n=this.evaluateScaleFormat(t,e);break;case"bar":n=this.evaluateBarFormat(t,e);break;case"icon":n=this.evaluateIconFormat(t,e);break;default:n=null}}catch(t){an().error(`Conditional format error: ${JSON.stringify(e)}`,t)}if(n&&(o=o?{...o,...n}:n,e.cf.stop))break}return o}initConditionalFormat(t){return t.firstCell=null,t.ranges.forEach((e=>{for(const i of new yw(e.intersect(this.model.gridRange))){const e=i.A1;"formula"===t.type&&(t.firstCell||(t.firstCell=i,t.formula=t.condition?new vv(t.condition,this.model.calculations.tokenizer):null)),(this.cellFormatMap.get(e)||this.cellFormatMap.set(e,[]).get(e)).push({cf:t})}})),t}add(t){const e={key:t.ranges,ranges:Jm.fromA1s(t.ranges),type:t.type||"formula",firstCell:null,formula:null,style:t.style?this.model.styles.add(t.style):null,condition:t.condition,stop:!!t.stop,cmin:t.cmin,cmid:t.cmid,cmax:t.cmax,color:t.color,v:t.v,thresh:t.thresh};this.formats.push(this.initConditionalFormat(e))}getSourceData(){return this.formats.map((t=>({type:t.type,ranges:Jm.toA1s(t.ranges),style:t.style,condition:t.condition,stop:t.stop,cmin:t.cmin,cmid:t.cmid,cmax:t.cmax,color:t.color,v:t.v,thresh:t.thresh})))}}function lw(t,e,i){t.forEach((t=>t.forEach((t=>{t[1]==e&&(t[1]=i)}))))}class cw{get cellDependencies(){return this._cellDependencies}get cellDependants(){return this._cellDependants}get rangeDependencies(){return this._rangeDependencies}get rangeDependants(){return this._rangeDependants}get sheetDependencies(){return this._sheetDependencies}get sheetDependants(){return this._sheetDependants}constructor(t){this.model=t,this._cellDependencies=new Map,this._cellDependants=new Map,this._rangeDependencies=new Map,this._rangeDependants=new Map,this._sheetDependencies=new Map,this._sheetDependants=new Map}clear(){this._cellDependants.clear(),this._cellDependencies.clear(),this._rangeDependencies.clear(),this._rangeDependants.clear()}clearCellDependecies(t){return this._cellDependencies.has(t)&&this._cellDependencies.delete(t),this._rangeDependencies.has(t)&&this._rangeDependants.delete(t),this}has(t){return this._cellDependencies.has(t)||this._rangeDependencies.has(t)}add(t,e,i){const o=Jm.fromA1(t).removeAnchors(),n=Jm.fromA1(e).removeAnchors();e=n.A1;const r=n.isRange,s=r?this._rangeDependencies:this._cellDependencies;let a=null;if((s.has(t)?s.get(t):s.set(t,new Map).get(t)).set(e,[n,i]),i){const t=this.model.getConnectedModel(i);t&&(t.calculations.dependencies.sheetDependants.set(this.model.name,this.model.name),this.sheetDependencies.set(i,i),a=r?t.calculations.dependencies.rangeDependants:t.calculations.dependencies.cellDependants),i=this.model.name}else a=r?this._rangeDependants:this._cellDependants;a&&(a.has(e)||a.set(e,new Map),a.get(e).set(t,[o,i]))}getDependants(t,e=null){const i=t.A1;return e=e??new Map,this._cellDependants.has(i)&&this._cellDependants.get(i).forEach((([t,o])=>{if(e.has(t))return;const n=e.set(t,[(o?this.model.getConnectedModel(o):this.model).getCellByRange(t),o]);t.A1!=i&&this.getDependants(t,n)})),this._rangeDependants.forEach(((i,o)=>{Jm.fromA1(o).contains(t)&&i.forEach((([t,i])=>{e.has(t)||(e.delete(t),this.getDependants(t,e.set(t,[(i?this.model.getConnectedModel(i):this.model).getCellByRange(t),i])))}))})),e}renameSheet(t,e){this._sheetDependants.has(t)&&(this._sheetDependants.delete(t),this._sheetDependants.set(e,e)),this._sheetDependencies.has(t)&&(this._sheetDependencies.delete(t),this._sheetDependencies.set(e,e)),lw(this._cellDependants,t,e),lw(this._cellDependencies,t,e),lw(this._rangeDependants,t,e),lw(this._rangeDependencies,t,e)}}const hw=(t,e)=>{const i=new RegExp(`${ht(t)}`,"ig");return t=>(i.lastIndex=0,i.test(at((t[e]??"").toString())))},dw=(t,e)=>i=>!!i[e]===t,uw=(t,e)=>{const i=t.map((t=>t.key?.toString()));return t=>null!=t[e]&&i.includes(t[e].toString())},pw=(t,e)=>t=>!1,gw=(t,e,i)=>(i=i??"value","b"===t?dw(e,i):"s"===t&&Array.isArray(e)?uw(e,"value"):"s"===t?hw(e?.toString(),"formattedValue"):"m"===t&&Array.isArray(e)?pw(e,i):hw(e?.toString(),"d"===t?"formattedValue":i));class fw extends Event{constructor(){super("filter",{bubbles:!1,cancelable:!0,composed:!0})}}class mw extends EventTarget{constructor(t){super(),this.model=t,this.settings=new Map,this.custom=!1}get(t){return this.settings.has(t)?this.settings.get(t):null}filter(t,e=!0){null===t.term||""===t.term?this.settings.delete(t.c):this.settings.set(t.c,t),this.custom||(this.settings.size>0?this.applyFilter(!1):this.resetFilter(!1)),e&&this.dispatchEvent(new fw)}applyFilter(t=!0){const e=[];this.settings.forEach(((t,i)=>{const o=this.model.columns[i];e.push({c:i,matcher:gw(o.type,t.term,o.filter?.property)})}));const i=e.length,o=this.model.options.filters?.includeParents??!0,n=this.model.options.filters?.includeChildren??!0,r=new Set;this.model.rows.forEach((t=>{const s=r.has(t.index);(t=>{if(!t.filterable)return!0;for(let o=0;o<i;o++)if(!e[o].matcher(t.cell(e[o].c)))return!1;return!0})(t)?(t.filterState=ln.Matched,o&&t.walkUp((t=>{if(r.has(t.index)&&t.filterState>0)return!1;t.filterState=ln.ChildMatched,r.add(t.index)})),n&&t.walk((t=>{if(r.has(t.index)&&t.filterState>0)return!1;t.filterState=ln.ParentMatched,r.add(t.index)}))):s||(t.filterState=ln.Filtered),r.add(t.index)})),this.model.indexRows(),t&&this.dispatchEvent(new fw)}resetFilter(t=!0){this.settings.clear(),this.model.rows.forEach((t=>t.filterState=ln.Matched)),this.model.indexRows(),t&&this.dispatchEvent(new fw)}}class vw{get dependencies(){return this._dependencies}constructor(t,e){this.model=t,this.map=new Map,this.groups=new Map,this.extremes=new Map,this.maxIndex=0,this.updateRangeMap=!1,this._dependencies=new cw(t),this.populate(e)}populate(t){t?.forEach((t=>{try{this.add(Jm.fromA1(t.location),Array.isArray(t.data)?t.data.map((t=>[Jm.fromA1(t)])):t.data.split(",").map((t=>[Jm.fromA1(t)])),et({},Hm.DEFAULT_SPARKLINE_OPTIONS,t.options))}catch(e){this.model.logger.error(`sparkline error: ${JSON.stringify(t)}`,e)}}))}getSourceData(){const t=[];return this.groups.forEach((e=>{t.push({location:e.locRange.A1,data:e.dataRanges.map((t=>t[0].A1)).join(","),options:{minValue:e.minValue,maxValue:e.maxValue,type:e.type,style:e.style,marker:e.marker}})})),t}has(t){return this.map.has(t)}get(t){return this.map.get(t)}createDependencies(t){this.map.get(t)[1].forEach((e=>this._dependencies.add(t,e[0].A1,e[1])))}updateRangeMaps(){this.dependencies.clear(),this.map.clear(),this.groups.forEach(((t,e)=>this.createRangeMap(e,t.locRange,t.dataRanges)))}getValues(t){this.updateRangeMap&&this.updateRangeMaps();const e=this.map.get(t),i=e[1][0][1]?this.model.getConnectedModel(e[1][0][1]):this.model;return this._dependencies.has(t)||this.createDependencies(t),e[1].flatMap((t=>i.getValuesInRange(t[0])[0]))}getExtremes(t){const e=this.map.get(t),i=e[1][0][1]?this.model.getConnectedModel(e[1][0][1]):this.model,o=this.groups.get(e[0]);let n,r,s,a;return null==o.minValue||Z(o.minValue)?"auto"==(o.minValue||"auto")?(n=n??st(...e[1].map((t=>i.getValuesInRange(t[0])))),s=n[0]):(this.extremes.has(e[0])||this.extremes.set(e[0],st(...o.dataRanges.map((t=>i.getValuesInRange(t[0]))))),r=this.extremes.get(e[0]),s=r[0]):s=o.minValue,null==o.maxValue||Z(o.maxValue)?"auto"==(o.maxValue||"auto")?(n=n??st(...e[1].map((t=>i.getValuesInRange(t[0])))),a=n[1]):(this.extremes.has(e[0])||this.extremes.set(e[0],st(...o.dataRanges.map((t=>i.getValuesInRange(t[0]))))),r=this.extremes.get(e[0]),a=r[1]):a=o.maxValue,[s,a]}createRangeMap(t,e,i){e=e.intersect(this.model.gridRange);const o=i[0][0].size,n=e.size;if(n.columns>1&&n.rows>1)return void this.model.logger?.error(`invalid sparkline location range: ${e.A1}`);let r=!1;if(r=1==n.columns&&1==n.rows?o.rows>1:n.columns>1,r)for(let o=e.c1;o<=e.c2;o++)this.map.set(new Jm(o,e.r1).A1,[t,i.map((([t,i])=>[new Jm(t.c1+o-e.c1,t.r1,t.c1+o-e.c1,t.r2),i]))]);else for(let o=e.r1;o<=e.r2;o++)this.map.set(new Jm(e.c1,o).A1,[t,i.map((([t,i])=>[new Jm(t.c1,t.r1+o-e.r1,t.c2,t.r1+o-e.r1),i]))])}add(t,e,i){const o=++this.maxIndex;t&&e&&this.createRangeMap(o,t,e),this.groups.set(o,Object.assign({dataRanges:e,locRange:t},JSON.parse(JSON.stringify(Hm.DEFAULT_SPARKLINE_OPTIONS)),i))}update(t,e,i,o){const n=this.groups.get(t);Object.assign(n,{dataRanges:i,locRange:e},o),this.updateRangeMap=!0}delete(t){this.groups.delete(t),this.updateRangeMap=!0}shift(t){this.groups.forEach((e=>{e.dataRanges.forEach((([e])=>e.shift(t))),e.locRange.shift(t)})),this.updateRangeMaps()}}class bw extends Jm{constructor(t,e,i=!1){super(e.c1,e.r1,e.c2,e.r2),this.model=t,this.initializedOnly=i,this.r=0,this.c=-1,this.done=!1}[Symbol.iterator](){return this}nextInitialized(){let t;for(;!this.done&&!t;)this.c<this.size.columns-1?this.c++:this.r<this.size.rows-1&&(this.c=0,this.r++),t=this.model.rows[this.r].cells[this.c],this.done=this.c>=this.size.columns-1&&this.r>=this.size.rows-1;return t}next(){if(this.done)return{done:!0};this.c<this.size.columns-1?this.c++:this.r<this.size.rows-1&&(this.c=0,this.r++),this.done=this.c>=this.size.columns-1&&this.r>=this.size.rows-1;const t=this.model.rows[this.r+this.r1],e=this.c+this.c1,i=this.initializedOnly&&!t.isCellInitialized(e)?this.nextInitialized():t?.cell(e);return i?{done:!1,value:i}:{done:!0}}forEach(t){let e;for(;e=this.next().value;)t(e)}}class yw extends Jm{constructor(t){super(t.c1,t.r1,t.c2,t.r2),this.r=0,this.c=-1,this.done=!1}[Symbol.iterator](){return this}next(){return this.done?{done:!0}:(this.c<this.size.columns-1?this.c++:this.r<this.size.rows-1&&(this.c=0,this.r++),this.done=this.c==this.size.columns-1&&this.r==this.size.rows-1,{done:!1,value:new Jm(this.c+this.c1,this.r+this.r1)})}}class ww{constructor(t,e){this.model=t,this.names=new Map,this.rangeMap=new Map,e&&this.populate(e)}populate(t){t.forEach((({name:t,ref:e})=>this.set(t,q(e)?Jm.fromCoords(e):Jm.fromA1(e))))}set(t,e){this.names.set(t,e),this.rangeMap.set(e.A1,t)}delete(t){const e=this.names.get(t);e&&(this.rangeMap.delete(e.A1),this.names.delete(t))}findCellByName(t){let e;const i=this.model.rows,o=this.model.columns.length;for(let n=0;n<i.length;n++){e=i[n];for(let i=0;i<o;i++)if(e.hasCellName(i)){const o=e.cell(i);if(o.name==t)return o.range}}return null}getCellByName(t,e){const i=this.names.get(t)??this.findCellByName(t);return i?i.isColumn?this.model.rows.length>e.r1?this.model.columns[i.c1].cell(e.r1):null:i.isRow?this.model.columns.length>e.c1?this.model.rows[i.r1].cell(e.c1):null:this.model.rows[i.r1].cell(i.c1):null}getRangeByName(t,e=!0){const i=this.names.get(t);return e?i?.intersect(this.model.gridRange):i}shift(t){this.names.forEach(((e,i)=>{const o=e.A1;e.shift(t);const n=e.A1;o!=n&&(this.rangeMap.delete(o),this.rangeMap.set(n,i))}))}}function xw(t,e=null){const i=et({},Hm.DEFAULT_OPTIONS,e,Pn(t,e));return i.numberFormat?i.numberFormatter=Go(i.locale,i.numberFormat):i.numberFormatter||(i.numberFormatter=Go(i.locale)),i.dateFormat?i.dateFormatter=Lo(i.locale,i.dateFormat):i.dateFormatter||(i.dateFormatter=Lo(i.locale)),i.columnSorting&&(i.sorting=i.sorting||{enabled:!0}),!1===i.filters&&(i.filters={enabled:!1}),i.filters=Object.assign({},Rm,i.filters),!1===i.rowTree&&(i.rowTree={enabled:!1}),i.rowTree=Object.assign({},Im,i.rowTree),!1===i.columnTree&&(i.columnTree={enabled:!1}),i.columnTree=Object.assign({},Im,i.columnTree),i}class kw extends(hn(Ry)){get cells(){return this._cells}get data(){return this._data}set data(t){this._data=t}get height(){return this._height??this.model.options.rowHeight}set height(t){this._height=t}get priority(){return this._priority}set priority(t){this._priority=t}get address(){return tv(this.index)}get range(){return new Jm(null,this.index,null,this.index)}get hasFormula(){return!!this._formula}get formula(){return this._formula}set formula(t){super.formula=t,this.model.columns.forEach((t=>this.cell(t.index).refreshFormula()))}get values(){return this.model.columns.map((t=>this.cell(t.index).value))}cell(t,e){if(this.model.options.singleCellModel)return this._singleCell||(this._singleCell=new Wy(this.model,{c:t,r:this.index})),this._singleCell.row=this,this._singleCell.column=this.model.columns[t],this._singleCell;let i=this._cells[t];if((e||!i)&&this.model.columns[t]){if(i=new Wy(this.model,e??{c:t,r:this.index}),this._data){const e=this.model.columns[t].data;null!=e&&(q(this._data[e])?i.populate(this._data[e]):i.hasValue||(i.value=this._data[e]))}i.name&&this.model.names.set(i.name,i.range),this._cells[t]=i}return i}constructor(t,e){super(t,e),this.isCellInitialized=t=>!!this.cells[t],this._cells=[],null==this._priority&&(this._priority=t.options.rowPriority)}populate(t){super.populate(t),this._height=t.h??this.model.options.rowHeight,this._data=t.data,null!=t.priority&&(this._priority=t.priority)}getSourceData(){const t=super.getSourceData();return null!=this._height&&this._height!=this.model.options.rowHeight&&(t.h=this._height),t}expand(t){super.expand(t),this.model.indexVisibleRows()}collapse(){super.collapse(),this.model.indexVisibleRows()}get prev(){return this.model.rows[this.index-1]}get next(){return this.model.rows[this.index+1]}get prevVisible(){let t=this.prev;for(;t&&!t.visible;)t=t.prev;return t}get nextVisible(){let t=this.next;for(;t&&!t.visible;)t=t.next;return t}hasCellFormula(t){return this.cells[t]&&this.cells[t].hasFormula||this._data&&this._data[this.model.columns[t].data]&&this._data[this.model.columns[t].data].f}hasCellName(t){return this.cells[t]&&null!=this.cells[t].name||this._data&&this._data[this.model.columns[t].data]&&null!=this._data[this.model.columns[t].data].name}insertColumns(t,e,i=!1){let o;const n=this.model.columns.length,r=this.model.calculations;if(i)for(let i=0;i<n;i++)this.hasCellFormula(i)&&(o=this.cell(i),o.formula=r.getFormula(o).shift({index:t,offset:e,direction:"right"}).createFormulaString(!1));t<this.cells.length&&this.cells.splice(t,0,...Array(e).fill(null))}deleteColumns(t,e,i=!1){let o;const n=this.model.columns.length,r=this.model.calculations;if(i)for(let i=0;i<n;i++)this.hasCellFormula(i)&&(o=this.cell(i),o.formula=r.getFormula(o).shift({index:t,offset:e,direction:"left"}).createFormulaString(!1));return t<this.cells.length?this.cells.splice(t,e):null}clearCalculatedValues(){this.cells.forEach((t=>t&&this.model.calculations.refreshFormula(t)))}}var Cw=i(4418),Mw=i.n(Cw);const _w=t=>t?"1":"0",Sw=t=>null==t?"_":t,Ew=t=>null==t?"_":t.toString(),zw=t=>null==t?"_":JSON.stringify(t),Lw=t=>Sw(t&&t.color?t.color:"_")+Sw(t&&t.style?t.style:"_"),Rw=t=>Sw(t?t.horizontal:null)+Sw(t?t.vertical:null)+Sw(t?t.horizontal:null)+Ew(t?t.indent:null)+_w(t?t.wrapText:null)+Ew(t?t.textRotation:null),Iw=t=>Mw()("s_"+_w(t.bold)+_w(t.italic)+_w(t.underline)+Ew(t.sz)+Sw(t.font)+Sw(t.color)+Lw(t.top)+Lw(t.right)+Lw(t.bottom)+Lw(t.left)+Sw(t.patternType)+Sw(t.fgColor)+Sw(t.bgColor)+Rw(t.alignment)+Ew(t.angle)+zw(t.stops)+_w(t.hidden)+_w(t.editable)+zw(t.cssStyle)+zw(t.icon));function Hw(t){const e={...t};return delete e.id,delete e.hash,e}class Tw{constructor(t){this.model=t,this._count=0,this.hashmap=new Map,this.map=new Map}add(t){if(!isNaN(t))return this.get(t);const e=this.model.options.cssStyles?Vy(t):t,i=e.hash?e.hash:Iw(e);return this.hashmap.has(i)?this.map.get(this.hashmap.get(i)):(null==e.id&&(e.id=this._count),this._count=Math.max(e.id+1,this._count+1),e.hash=i,this.hashmap.set(i,e.id),this.map.set(e.id,e),e)}populate(t){t.forEach((t=>this.add(t)))}get(t){return this.map.has(t)?this.map.get(t):null}remove(t){const e="object"==typeof t?t:this.map.get(t);this.hashmap.delete(e.hash),this.map.delete(e.id)}merge(...t){const e=Object.assign({},...t.map((t=>q(t)?t:this.get(t))));return this.add(Hw(e))}duplicate(t,e){const i=this.get(t);return this.add(Hw({...i,...e}))}set(t,e){let i=this.map.has(t)?this.map.get(t):{};for(const t in e)i[t]=e[t];return i=i.id?i:this.add(i),i}unset(t,e){if(this.map.has(t)){const i=this.map.get(t);for(const t of e)delete i[t]}}getSourceData(){return Array.from(this.map.values())}clean(){const t=new Map(Array.from(this.map.entries()).map((([t])=>[t,0])));this.model.columns.forEach((e=>{const i=t.get(e.style);null!=i&&t.set(e.style,i+1)})),this.model.rows.forEach((e=>{const i=t.get(e.style);null!=i&&t.set(e.style,i+1),e.cells.forEach((e=>{const i=t.get(e.style);null!=i&&t.set(e.style,i+1)}))})),t.forEach(((t,e)=>{0==t&&this.remove(e)}))}}function Aw(t,e,i){const o="rows"==i?e.rows:e.columns,n=function(t){const e=new Map;for(const i of t)e.has(i.level)||e.set(i.level,[]),e.get(i.level).push(i);return e}(o);for(const i of t){let t;if(t=i.index>-1?[o[i.index]]:i.level>-1?n.get(i.level):o,i.name){const e=i.name instanceof RegExp?i.name:new RegExp(ht(i.name));t=t.filter((t=>e.test(t.name)))}t.forEach((t=>{i.type?e.conditionalFormats.add(Object.assign({ranges:`${t.address}:${t.address}`},i)):t.style=e.styles.add(i.style).id}))}}function Ow(t,e){!function(t,e){for(const i of t)if(i.type)e.conditionalFormats.add(Object.assign({ranges:"A:"+e.columns[e.columns.length-1].address},i));else for(const t of e.columns)null==t.style&&(t.style=e.styles.add(i.style).id)}(t.cells??[],e),Aw(t.columns??[],e,"columns"),Aw(t.rows??[],e,"rows")}const $w=["index","name","rows","columns","cells","options","sparklines","rules","comments","styles","names","props","tab","theme"];class Dw{get comments(){return this._comments}get calculations(){return this._calculations}get names(){return this._names}get sparklines(){return this._sparklines}get conditionalFormats(){return this._conditionalFormats}get mergedHeaders(){return this._mergedHeaders}get mergedCells(){return this._mergedCells}get hiddenCells(){return this._hiddenCells}get hasFilter(){return this._filter}get hasRowTree(){return this._maxRowLevel>0}get hasRowTreeEnabled(){return this.hasRowTree&&this.options.rowTree.enabled}get maxRowLevel(){return this._maxRowLevel}get hasColumnTree(){return this._maxColumnLevel>0}get hasColumnTreeEnabled(){return this.hasColumnTree&&this.options.columnTree.enabled}get maxColumnLevel(){return this._maxColumnLevel}get headerCount(){return this._headerCount}get columnHeaderCount(){return this.headerCount+(this.hasColumnTreeEnabled?1:0)+(this.hasFilter?1:0)}get properties(){return this._properties}set properties(t){this._properties=t}constructor(t,e,i){this.otherModels={},this.styles=new Tw(this),this._comments=new Jy(this),this._calculations=new tw(this),this._names=new ww(this),this._sparklines=new vw(this),this._conditionalFormats=new aw(this),this._hiddenCells=new Map,this._filter=!1,this._maxRowLevel=0,this._maxColumnLevel=0,this._headerCount=0,this._levelBasedRowTree=!0,this._levelBasedColTree=!0,this.clearRows=()=>(this.rowRoot.clearChildren(),this.rows=[],this.rows),this.clearColumns=()=>this.columns=[],this.logger=i,this.options=e??xw(t.options),this.populate(t)}getConnectedModel(t){return this.group?this.group.get(t):null}getModelByRange(t){return t.sheet?this.getConnectedModel(t.sheet):this}getCellByA1(t){return this.getCellByRange(Jm.fromA1(t))}getCellByRange(t){return this.getCellByCoords(t.r1,t.c1)}getCellByCoords(t,e){return this.rows[t].cell(e)}cell(t,e){return isNaN(t)?t instanceof Jm?this.getCellByRange(t):"string"==typeof t?this.getCellByA1(t):null:this.getCellByCoords(t,e||0)}createRows(t,e=new kw(this,{l:-1}),i=0){let o=!1,n=!1;const r=t.map(((t,e)=>{t||(t={}),isNaN(t.l)||(o=!0),null!=t.p&&(n=!0);const r=new kw(this,t);return r.origIndex=e+i,r.name&&this.names.set(r.name,Jm.fullRow(e)),r}));let s=-1;return o?s=dn(r,e,{reverse:this.options.rowTree.reversed}):n?s=un(r,e):e.children=r,[e,r,s,o]}insertRowData(t,e,i){const o=this.createRows(i,new kw(this,{l:t.level}),e);this._maxRowLevel=Math.max(this._maxRowLevel,o[2]),t.insertChildren(o[0].children,e),this.indexRowsByTree()}applyTheme(t,e){if(e)for(const t of this.getInitializedCellIterator())t.invalidateStyle();Ow(t,this)}populate(t){this.index=t.index,this.name=t.name??this.name,this.tab=t.tab;let e=!1,i=!1;if(t.columns||(t.columns=new Array(this.options.columns).fill({})),t.rows||(t.rows=new Array(this.options.rows).fill({})),t.styles&&this.styles.populate(t.styles),this.columns=t.columns.map(((t,o)=>{t||(t={}),t.l>0&&(e=!0),null!=t.p&&(i=!0);const n=new Gy(this,t);return this._filter=n.hasFilter||this._filter,n.name&&this.names.set(n.name,Jm.fullColumn(o)),n})),this._levelBasedColTree=e,this._maxColumnLevel=-1,this.colRoot=new Gy(this,{l:-1}),e?this._maxColumnLevel=dn(this.columns,this.colRoot,{reverse:this.options.columnTree.reversed}):i?this._maxColumnLevel=un(this.columns,this.colRoot):this.colRoot.children=this.columns,this.indexColumns(),this.indexVisibleColumns(),[this.rowRoot,this.rows,this._maxRowLevel,this._levelBasedRowTree]=this.createRows(t.rows),this.indexRows(),this.indexVisibleRows(),this.options.pageSize&&this.options.pageSize<=this.rows.length&&(this.rowRoot.count=1/0),this._mergedCells=[],t.cells?.forEach(((t,e)=>{const i=this.rows[t.r]?this.rows[t.r].cell(t.c,t):null;i?(i.colspan>1||i.rowspan>1)&&this._mergedCells.push({r:i.r,c:i.c,rs:i.rowspan,cs:i.colspan}):this.logger?.error(`invalid cell definition (index ${e}): ${JSON.stringify(t)}`)})),this.indexHiddenCells(),t.sparklines)try{this.sparklines.populate(t.sparklines)}catch(t){an().error(`Sparkline init error: ${t}`)}if(t.names)try{this.names.populate(t.names)}catch(t){an().error(`Named range init error: ${t}`)}if(t.rules)try{this.conditionalFormats.populate(t.rules)}catch(t){an().error(`Conditional formats init error: ${t}`)}if(t.theme)try{this.applyTheme(t.theme)}catch(t){an().error(`Theme init error: ${t}`)}if(t.comments)try{this.comments.populate(t.comments)}catch(t){an().error(`Comment init error: ${t}`)}this._properties=t.props,this.otherSourceData={};const o=new Set($w),n=Object.keys(t).filter((t=>!o.has(t)));n.forEach((e=>this.otherSourceData[e]=t[e])),this.calcHeaderHeights()}getSourceData(){const t={index:this.index,name:this.name,tab:this.tab,columns:this.columns.map((t=>t.getSourceData())),rows:this.rows.map((t=>t.getSourceData())),styles:this.styles.getSourceData(),rules:this.conditionalFormats.getSourceData(),sparklines:this.sparklines.getSourceData(),options:this.options};this._properties&&(t.props=this._properties);const e=[];let i;for(let t=0;t<this.rows.length;t++)for(let o=0;o<this.columns.length;o++)i=this.rows[t].cell(o).getSourceData(),Object.keys(i).length>0&&(i.r=t,i.c=o,e.push(i));e.length>0&&(t.cells=e);const o=[];return this.styles.clean(),this.styles.map.forEach((t=>o.push(t))),o.length>0&&(t.styles=o),new Set([...Object.keys(this.otherModels??{}),...Object.keys(this.otherSourceData??{})]).forEach((e=>t[e]=this.otherModels[e]?Array.from(this.otherModels[e]).map((t=>t.getSourceData())):this.otherSourceData[e])),t}calcHeaderHeights(){this._headerCount=0,this._headerHeights=[],this.columns.forEach((t=>{this._headerCount=t.header?t.header.length:this._headerCount,this._headerHeights.length<this._headerCount&&this._headerHeights.push(...Array(this._headerCount-this._headerHeights.length).fill(0)),t.header?.forEach(((t,e)=>{e>=this._headerHeights.length&&this._headerHeights.push(0),this._headerHeights[e]=Math.max(this._headerHeights[e],t.height??0)}))}))}indexRows(){this.visibleRows=[],this.rows.forEach(((t,e)=>{t.index=e,t.isLoaded||(t.collapsed=!0),t.hidden||t.filterState==ln.Filtered||this.visibleRows.push(t)}))}indexVisibleRows(){this.visibleRows=[];let t=0;if(this._levelBasedRowTree){if(this.rowRoot.walkVisible((e=>{e.visibleIndex=t++,this.visibleRows.push(e)})),this.options.rowTree.reversed){const e=new Array(this.visibleRows.length);this.visibleRows.forEach(((i,o)=>{t=this.visibleRows.length-o-1,i.visibleIndex=t,e[t]=i})),this.visibleRows=e}}else this.rowRoot.walkVisible((t=>this.visibleRows[t.index]=t)),this.visibleRows=this.visibleRows.filter((e=>!!e&&(e.visibleIndex=t++,!0)))}indexRowsByTree(){this.rows=[];let t=0;this.rowRoot.walk((e=>{e.index=t++,this.rows.push(e)})),this.options.rowTree.reversed&&this.rows.reverse(),this.indexVisibleRows()}indexColumns(){this.visibleColumns=[],this.columns.forEach(((t,e)=>{t.index=e,t.hidden||this.visibleColumns.push(t)}))}indexVisibleColumns(){this.visibleColumns=[],this.visibleColumnIndex={};let t=0;if(this.colRoot.walkVisible((e=>{e.visibleIndex=t,this.visibleColumnIndex[e.index]=t++,this.visibleColumns.push(e)})),this.options.columnTree.reversed){this.visibleColumnIndex={};const e=new Array(this.visibleColumns.length);this.visibleColumns.forEach(((i,o)=>{t=this.visibleColumns.length-o-1,i.visibleIndex=t,this.visibleColumnIndex[i.index]=t,e[t]=i})),this.visibleColumns=e}this.indexHeaders()}indexHeaders(){this._mergedHeaders=[],this._headerCount=0,this.colRoot.walkVisible((t=>{this._headerCount=Math.max(t.header?t.header.length:0,this._headerCount),t.mergedHeaders.forEach((e=>this._mergedHeaders.push({h:e,c:t.index,r:e.r,cs:t.calculateRealColspan(e.cs??1),rs:e.rs??1})))})),this._mergedHeaders.forEach((t=>{if(!t.h.hidden)for(let e=t.c;e<t.c+t.cs;e++)for(let i=t.r;i<t.r+t.rs;i++)(i>t.r||e>t.c)&&this.columns[e]&&this.columns[e].header[i]&&(this.columns[e].header[i].hidden=!0)})),this.calcHeaderHeights()}removeHeader(t){this.columns.forEach((e=>{t<e.header.length&&e.header.splice(t,1)})),this.indexHeaders()}clear(){this.clearRows(),this.clearColumns(),this.resetViewport()}resetViewport(){return this._viewport=null,this}getViewport(t,e,i){const o=[],n=[];let r,s,a=e.h,l=0;for(l=0;l<i.t;l++)r=this.visibleRows[l],a-=r.height,o.push(r);for(l=this.visibleRows.length-i.b;l<this.visibleRows.length;l++)r=this.visibleRows[l],a-=r.height;for(l=i.t+t.r;a>0&&l<this.visibleRows.length;)r=this.visibleRows[l++],a-=r.height,o.push(r);for(l=this.visibleRows.length-i.b;l<this.visibleRows.length;l++)o.push(this.visibleRows[l]);let c=e.w,h=0;for(h=0;h<i.l;h++)s=this.visibleColumns[h],c-=s.width,n.push(s);for(h=this.visibleColumns.length-i.r;h<this.visibleColumns.length;h++)s=this.visibleColumns[h],c-=s.width;for(h=i.l+t.c;c>0&&h<this.visibleColumns.length;)s=this.visibleColumns[h++],c-=s.width,n.push(s);for(h=this.visibleColumns.length-i.r;h<this.visibleColumns.length;h++)n.push(this.visibleColumns[h]);return this._viewport={rows:o,columns:n}}calculateViewport(){return this._viewport?this.calculations.calculateViewport(this._viewport):[]}getValuesInRange(t,e=!1){if(!(t=t.intersect(this.gridRange)))return[];const{columns:i,rows:o}=t.size,n=new Array(o);let r,s=0,a=0;for(let o=t.r1;o<=t.r2;o++){n[s]=new Array(i),a=0,r=this.rows[o];for(let i=t.c1;i<=t.c2;i++)n[s][a++]=e?r.cell(i).formattedValue:r.cell(i).value;++s}return n}setRowExpandLevel(t){this.rows.forEach((e=>{e.collapsed=!e.isLoaded&&!e.isPartialyLoaded||e.level>=t,e.level<=t&&(e.hidden=!1)})),this.indexVisibleRows()}setColumnExpandLevel(t){this.columns.forEach((e=>e.collapsed=e.level>=t)),this.indexVisibleColumns()}getViewportRange(){return this._viewport?new Jm(this._viewport.columns[0].index,this._viewport.rows[0].index,this._viewport.columns[this._viewport.columns.length-1].index,this._viewport.rows[this._viewport.rows.length-1].index):null}get gridRange(){return new Jm(0,0,this.columns.length-1,this.rows.length-1)}getRangeIterator(t,e=!1){return new bw(this,e&&this._viewport?t.intersect(this.getViewportRange()):t.intersect(this.gridRange))}getInitializedCellIterator(){return new bw(this,this.gridRange,!0)}getCellArray(t){const e=[];for(const i of this.getRangeIterator(t))e.push(i);return e}transformRangeToMatrix(t,e){let i,o,n;const r=[];for(let s=(t=t.intersect(this.gridRange)).r1;s<=t.r2;s++)if(i=this.rows[s],i){n=[];for(let r=t.c1;r<=t.c2;r++)o=i.cell(r),o&&n.push(e(o));r.push(n)}return r}getCellMatrix(t){return this.getModelByRange(t)?.transformRangeToMatrix(t,(t=>t))}getValueMatrix(t){return this.getModelByRange(t)?.transformRangeToMatrix(t,(t=>t.value))}shiftMerges(t){const{index:e,offset:i,direction:o}=t,n={down:t=>{e<=t.r?t.r+=i:e>t.r&&e<t.r+t.rs&&(this.rows[t.r].cell(t.c).rowspan=t.rs+=i)},up:t=>{e<=t.r?t.r-=i:e>t.r&&e<t.r+t.rs&&(this.rows[t.r].cell(t.c).rowspan=t.rs-=i)},right:t=>{e<=t.c?t.c+=i:e>t.c&&e<t.c+t.cs&&(this.rows[t.r].cell(t.c).colspan=t.cs+=i)},left:t=>{e<=t.c?t.c-=i:e>t.c&&e<t.c+t.cs&&(this.rows[t.r].cell(t.c).colspan=t.cs-=i)}};this.mergedCells.forEach(n[o]),this.indexHiddenCells()}indexHiddenCells(){this._hiddenCells.clear(),this.mergedCells.forEach((t=>{if(!(t.r>0||this._hiddenCells.has(t.r)&&this._hiddenCells.get(t.r).has(t.c)))for(let e=t.r;e<t.r+t.rs;e++)for(let i=t.c;i<t.c+t.cs;i++)(e>t.r||i>t.c)&&(this._hiddenCells.has(e)||this._hiddenCells.set(e,new Map),this._hiddenCells.get(e).set(i,t))}))}shift(t){t.sheet=this.name,this.shiftMerges(t),this.calculations.shift(t),this.names.shift(t),this.comments.shift(t),this.sparklines.shift(t)}clearCalculations(t=!1){t&&this.group?this.group.models.forEach((t=>t.calculations.refresh())):this.calculations.refresh()}refreshSparklines(){this.sparklines.updateRangeMaps();for(const t of this.getInitializedCellIterator())t.invalidateStyle()}clearCalculatedStyles(){this.conditionalFormats.refresh();const t=[];for(const e of this.getInitializedCellIterator())t.push(e),e.invalidateStyle()}insertColumns(t,e,i=!1){const o=this.columns[Math.min(this.columns.length-1,t)].parent;i&&++t,this.shift({index:t,offset:e,direction:"right"});for(let i=0;i<this.rows.length;i++)this.rows[i].insertColumns(t,e,!1);const n=new Array(e).fill(null).map((()=>new Gy(this)));return this.columns.splice(t,0,...n),this.maxColumnLevel>0&&o.insertChildren(n,t-(o.index||-1)-1),this.indexColumns(),this.clearCalculations(!0),n}deleteColumns(t,e){const i=this.columns[t].parent;this.shift({index:t,offset:e,direction:"left"});const o=[];for(let i=0;i<this.rows.length;i++)o.push(this.rows[i].deleteColumns(t,e,!1));const n=this.columns.splice(t,e);return i?.deleteChildren(n),this.indexColumns(),this.clearCalculations(!0),n}insertRows(t,e,i=!1){const o=Math.min(this.rows.length-1,t),n=o<0?this.rowRoot:this.rows[o].parent;i&&++t;const r=isNaN(e)?e.length:e;this.shift({index:t,offset:r,direction:"down"});const s=isNaN(e)?e:new Array(r).fill(null).map((()=>new kw(this)));return this.rows.splice(t,0,...s),this.maxRowLevel>0&&n.insertChildren(s,t-(n.index||-1)-1),this.indexRows(),this.clearCalculations(!0),s}deleteRows(t,e){const i=this.rows[t].parent;this.shift({index:t,offset:e,direction:"up"});const o=this.rows.splice(t,e);return i?.deleteChildren(o),this.indexRows(),this.clearCalculations(!0),o}moveRows(t,e,i){const o=this.rows.splice(t,e);return this.rows.splice(i,0,...o),this.shift({index:t,offset:i-t,direction:"down",maxIndex:t+e-1}),this.indexRows(),this.clearCalculations(!0),o}moveColumns(t,e,i){const o=this.columns.splice(t,e);return this.columns.splice(i,0,...o),this.shift({index:t,offset:i-t,direction:"right",maxIndex:t+e-1}),this.indexColumns(),this.clearCalculations(!0),o}spillValues(t){const{cell:e,values:i,displayValues:o,propertyCell:n}=t,r=[],s=[],a=0===i.length||0===i[0].length;let l,c;const h=a?null:new Jm(e.c,e.r,e.c+i[0].length-1,e.r+i.length-1);if(e.spillRange&&this.getRangeIterator(e.spillRange,!0).forEach((t=>{e==t||h?.contains(t.range)||t.clearSpilledValue()})),e.spillRange=h,a)return{cells:r,oldValues:s,range:null};for(let t=h.r1;t<=h.r2;t++){if(l=this.rows[t],!l)continue;const a=t-h.r1;for(let t=h.c1;t<=h.c2;t++){const d=t-h.c1;c=l.cell(t),c.editable&&(s.push(c.value2),c.spillValue(i[a][d],e),n&&(c.format=n.format,c.type=n.type),o&&null!=o[a][d]&&(c.displayValue=o[a][d]),r.push(c))}}return{cells:r,oldValues:s,range:h}}getCellByName(t,e,i=!0){return this.names.getCellByName(t,e)||(this.group&&i?this.group.getCellByName(t,e):null)}getRangeByName(t,e=!0){return this.names.getRangeByName(t)||(this.group&&e?this.group.getRangeByName(t):null)}getValueMatrixByName(t,e=!0){const i=this.names.getRangeByName(t);return i?this.getValueMatrix(i):this.group&&e?this.group.getValueMatrixByName(t):null}rebuildRowTree(){const t=this._levelBasedRowTree?dn:un;this._maxRowLevel=t(this.rows,this.rowRoot,{reverse:this.options.rowTree.reversed}),this.indexRowsByTree()}rebuildColumnTree(){const t=this._levelBasedColTree?dn:un;this._maxColumnLevel=t(this.columns,this.colRoot,{reverse:this.options.columnTree.reversed}),this.indexColumns()}calculateCellOffset(t){let e=0,i=0;for(let i=0;i<t.c1&&this.columns[i];i++)e+=this.columns[i].width;for(let e=0;e<t.r1&&this.rows[e];e++)i+=this.rows[e].height;return{x:e,y:i}}}class Nw{get errors(){return this._errors}get(t){return this.models.get(t)}has(t){return this.models.has(t)}getNewName(){let t;do{t=`sheet${this._max}`}while(this.models.has(t));return t}add(t){if(t.index=t.index??this._max,++this._max,t.name=t.name||this.getNewName(),this.models.has(t.name))throw Error(`sheet "${t.name}" already exists`);return this.models.set(t.name,t),t.group=this,t}duplicate(t){const e=this.get(t);if(!e)return;const i=new Dw(e.getSourceData(),e.options);let o=1;for(;this.models.has(`${t}_${o}`);)++o;return i.name=`${t}_${o}`,this.add(i),i}remove(t){return this.models.delete(t),this}rename(t,e){if(this.has(t)){if(this.has(e))throw new Error(`Model '${e}' already exists`);const i=this.get(t);i.name=e,this.models.set(e,i),this.models.delete(t),this.models.forEach((i=>{i.calculations.renameSheet(t,e)&&i.calculateViewport()}))}return this}clear(){this.models.clear(),this._errors=[]}constructor(t){this._max=0,this.models=new Map,this.themes=new Map,this._errors=[],t&&this.populate(t)}populate(t){this.clear(),t.models.forEach((t=>{const e=new Dw(t);try{this.add(e)}catch(t){this.errors.push(t)}})),t.themes&&t.themes.forEach((t=>this.themes.set(t.name,t)))}getSourceData(){const t={models:[]};return this.models.forEach((e=>t.models.push(e.getSourceData()))),t}getCellByName(t,e){for(const i of this.models.values()){const o=i.getCellByName(t,e,!1);if(o)return o}return null}getRangeByName(t){for(const e of this.models.values()){const i=e.getRangeByName(t,!1);if(i)return i}return null}getValueMatrixByName(t){for(const e of this.models.values()){const i=e.getValueMatrixByName(t,!1);if(i)return i}return null}}class Pw{constructor(t){this.model=t,this.stack=[],this.restack=[]}push(t){return this.restack=[],t.timestamp||(t.timestamp=Date.now()),this.stack.push(t),this}pop(t=1){let e=0;const i=[];for(;e++<t&&this.stack.length>0;){const t=this.stack.pop();i.push(t),this.restack.push(t)}return i}pop2(t=1){let e=0;const i=[];for(;e++<t&&this.restack.length>0;){const t=this.restack.pop();i.push(t),this.stack.push(t)}return i}}class jw{get activeCellCoords(){return{c:this.range.c1+this.activeCell.c1,r:this.range.r1+this.activeCell.r1}}constructor(t,e,i,o){this.hidden=!1,this.range=new Jm(t,e,i,o),this.activeCell=new Jm(0,0)}static fromRange(t){return new jw(t.c1,t.r1,t.c2,t.r2)}setCoords(t,e,i,o){this.range.setCoords(t,e,i,o),this.activeCell.setCoords(0,0)}setRange(t){"string"==typeof t&&(t=Jm.fromA1(t)),this.range.setCoords(t.c1,t.r1,t.c2,t.r2),this.activeCell.setCoords(0,0)}move(t,e,i,o){this.range.setCoords(this.range.c1+this.activeCell.c1,this.range.r1+this.activeCell.r1,this.range.c1+this.activeCell.c2,this.range.r1+this.activeCell.r2),this.range.move(t,e,i,o,!1),this.activeCell.setCoords(0,0)}moveRange(t,e,i,o){this.range.move(t,e,i,o,!0)}moveActiveCell(t,e){const{columns:i,rows:o}=this.range.size;this.activeCell.move(t,e,i,o,!0)}}const Vw={...Hm,CUSTOM_CLIPBOARD_TYPE:"web application/json"};class Bw{constructor(t,e,i=Vw.MAX_CACHE_ITEMS){this.maxCacheItems=i,this.queue=[],this.disabled=!1,this.table=new Array(e).fill(null).map((()=>new Array(t)))}get(t,e){return this.table[e][t]}delete(t,e){return this.table[e][t]=null,this}deleteColumn(t){for(let e=0;e<this.table.length;e++)this.table[e][t]=null;return this}deleteRow(t){return this.table[t]=new Array(this.table[0].length).fill(null),this}set(t,e,i){this.disabled||(this.get(t,e)||this.queue.push([e,t]),this.table[e][t]=i)}clear(){this.queue=[],this.table=this.table.map((t=>new Array(t.length)))}clean(){if(this.maxCacheItems>0&&this.queue.length>this.maxCacheItems){let t=this.queue.length;for(let e=0;e<this.queue.length;e++){const i=this.queue[e];if(!this.table[i[0]][i[1]].parentNode&&(this.queue[e]=null,this.table[i[0]][i[1]]=null,--t<=this.maxCacheItems))break}t<this.queue.length&&(this.queue=this.queue.filter((t=>t)))}}}var Fw=function(t,e,i,o){var n,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(r<3?n(s):r>3?n(e,i,s):n(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s};let Ww=class extends Qr{constructor(){super(),this.render=()=>Ir`
2652
2652
  <og-icon id="filterIcon" .icon="${{icon:"filter"}}"></og-icon>
2653
2653
  <div class="text">${G(this.value)?Ir`
2654
2654
  <og-icon .icon="${this.value?"square-check":"square"}"></og-icon>
@@ -3073,7 +3073,7 @@
3073
3073
  <thead ${Vh(this.theadRef)}></thead>
3074
3074
  <tbody ${Vh(this.tbodyRef)}></tbody>
3075
3075
  </table>
3076
- `,this.clearHeaderCache=()=>{this.resetFreezeLeft(),this.hCache=new Bw(this.model.columns.length,this.columnHeaderCount),this.hCache.disabled=!this.model.options.cellCache},this.clearBodyCache=()=>{this.bCache=new Bw(this.model.columns.length,this.model.rows.length),this.bCache.disabled=!this.model.options.cellCache},this.cellRenderSchedules=new WeakMap}willUpdate(){this._viewport=null,this._viewportSize=null,this.model&&(this.clearHeaderCache(),this.clearBodyCache())}updated(){this.model&&(this.createColumns(),this.createHeaderRows(),this.createBodyRows(),this.renderCells())}refresh(){this.clearHeaderCache(),this.clearBodyCache(),this.requestUpdate()}createColumns(){this._freezeLeft=null;const t=this.renderColCount;if(!this.cols||this.cols.length!=t){this.cols=new Array(t);for(let e=0;e<t;e++)this.cols[e]=gt("col"),this.cols.forEach((()=>this.colgroup.appendChild(this.cols[e])))}}createHeaderRows(){const t=this.columnHeaderCount,e=this.renderColCount;if(xt(this.thead),!this.hRows||this.hRows.length!=t||!this.hRows[0]||this.hRows[0].children.length!=e){this.hRows=new Array(t);for(let i=0;i<t;i++){this.hRows[i]=gt("tr");for(let t=0;t<e;t++)this.hRows[i].appendChild(gt("th"))}}xt(this.thead),this.hRows.forEach((t=>this.thead.appendChild(t)))}createBodyRows(){const t=this.renderRowCount,e=this.renderColCount,i=this.rowHeaderCount;if(!this.bRows||0==this.bRows.length||this.bRows.length!=t||this.bRows[0].children.length!=e)if(0==t&&this.grid.options.emptyPlaceholder)this.bRows=[gt("tr")],this.bRows[0].appendChild(gt("td"));else{this.bRows=new Array(t);for(let o=0;o<t;o++){this.bRows[o]=gt("tr");for(let t=0;t<i;t++)this.bRows[o].appendChild(gt("th"));for(let t=i;t<e;t++)this.bRows[o].appendChild(gt("td"))}}xt(this.tbody),this.bRows.forEach((t=>this.tbody.appendChild(t)))}renderCells(t={vertical:!0,horizontal:!0}){(t.vertical||t.horizontal)&&(this._viewport=null,this.tbody.remove(),t.horizontal&&this.renderHeader(),this.model.rows.length>0?(this.renderBody(),t.vertical&&this.renderRowTree(),this.table.appendChild(this.tbody)):this.model.options.emptyPlaceholder&&(this.renderEmptyBody(),this.table.appendChild(this.tbody)),this.dispatchEvent(new tx("rendercells")))}renderEmptyBody(){const t=this.bRows[0].children[0];t.innerHTML="no data",t.className="empty-placeholder",t.colSpan=this.viewport.columns.length+this.rowHeaderCount}renderHeader(){let t;this.colMap.clear();const e=this.rowHeaderCount,i=this.viewport;this.model.hasRowTreeEnabled&&Ht(this.colgroup.children[0],{w:this.treeHeaderWidth},!0),this.model.options.rowNumbers&&Ht(this.colgroup.children[e-1],{w:Vw.ROW_HEADER_WIDTH},!0);for(let o=0;o<i.columns.length;o++)t=i.columns[o],this.colMap.set(t.index,o),Ht(this.colgroup.children[o+e],{w:t.width}),At(this.colgroup.children[o+e],{w:t.width}),Tt(this.colgroup.children[o+e],{w:t.width});let o=0;this.model.hasColumnTreeEnabled&&(this.renderHeaderRowTree(this.hRows[o],o),++o),this.model.options.colLetters&&(Ht(this.hRows[o],{h:this.model.options.rowHeight}),this.renderHeaderRowLetters(this.hRows[o],o),++o);for(let t=0;t<this.model.headerCount;t++)this.renderHeaderRowLabels(this.hRows[o+t],o+t,t);o+=this.model.headerCount,this.model.hasFilter&&(Ht(this.hRows[o],{h:this.model.options.rowHeight}),this.renderHeaderRowFilters(this.hRows[o],o))}renderHeaderRowLetters(t,e){let i,o;const n=this.viewport,r=e-this.columnHeaderCount;let s=0;if(Ht(t,{h:this.model.options.rowHeight}),(this.model.hasRowTree||this.model.options.rowNumbers)&&!this.model.hasColumnTree){i=t.children[s],i.colSpan=this.rowHeaderCount,i.rowSpan=this.columnHeaderCount;const e=s-this.rowHeaderCount,o=this.model.options.levelButtonCell;(!o||r==o.r&&e==o.c)&&this.renderHeaderRowCornerCell(i),s++}for(let e=s;e<this.rowHeaderCount;e++)wt(t.children[e]),s++;for(let e=s;e<t.children.length;e++)o=e-s,i=t.children[e],i.className="hlabel",n.columns.length>o?(i.innerHTML=n.columns[o].address,i.c=n.columns[o].index,yt(i)):wt(i)}renderHeaderRowTree(t,e){if(!this.model.hasColumnTreeEnabled)return;let i,o,n=0;const r=e-this.columnHeaderCount,s=this.viewport,a=this.model.options.rowNumbers,l=this.model.hasRowTreeEnabled;if(Ht(t,{h:this.treeHeaderHeight}),i=t.children[n],!i)return;i.rowSpan=a||l?this.columnHeaderCount:1,i.colSpan=this.rowHeaderCount;const c=n-this.rowHeaderCount,h=this.model.options.levelButtonCell;let d=null;(!h&&(a||l)||h&&r==h.r&&c==h.c)&&(d=c,this.renderHeaderRowCornerCell(i)),(a||l)&&(++n,l&&(i=t.children[n],i.innerHTML="",wt(i),++n));for(let r=n;r<t.children.length;r++)o=r-n,i=t.children[r],s.columns.length>o?(d!=r&&(i.innerHTML="",i.className="htree",this.renderHeaderRowTreeCell(t,e,s.columns[o],i)),yt(i)):wt(i)}renderHeaderRowTreeCell(t,e,i,o){let n=this.hCache.get(i.index,e);if(!n){n=gt("div"),this.hCache.set(i.index,e,n);const t=i.width+1,o=this.treeHeaderHeight/this.model.maxColumnLevel;if(i.hasChildren){const e=new Td;e.addEventListener("toggle",(()=>this.grid.rendering.toggleColumn(i.index))),n.expander=e,n.appendChild(e),Ot(e,{l:t/2-Vw.EXPANDER_SIZE/2,t:i.level*o+o/2-Vw.EXPANDER_SIZE/2}),n.expanderLine=this.createExpanderLine("h"),n.appendChild(n.expanderLine),Ot(n.expanderLine,{l:this.model.options.columnTree.reversed?0:t/2,t:i.level*o+o/2}),Ht(n.expanderLine,{h:o/2,w:t/2+1})}if(i.hasParent){let e=i;for(;e.hasParent;){e=e.parent;const i=this.createExpanderLine("h");n.appendChild(i),Ht(i,{h:o/2,w:t-1}),Ot(i,{l:0,t:e.level*o+o/2})}}}n.expander&&(n.expander.state=i.collapsed?"closed":"open"),o.appendChild(n)}createExpanderLine(t){const e=gt("div");return e.className=`${t}tree-line`,e}renderHeaderRowLabels(t,e,i){let o,n,r,s,a=0;const l=this.viewport,c=e-this.columnHeaderCount,h=this.model.options.levelButtonCell;let d;this.model.hasRowTreeEnabled&&(n=t.children[a],n.innerHTML="",this.model.hasColumnTreeEnabled||this.model.options.colLetters||i>0?wt(n):(n.rowSpan=this.columnHeaderCount,n.colSpan=this.rowHeaderCount,this.renderHeaderRowCornerCell(n)),++a),this.model.options.rowNumbers&&(n=t.children[a],n.innerHTML="",this.model.hasRowTreeEnabled||this.model.options.colLetters||this.model.hasColumnTreeEnabled||i>0?wt(n):(n.rowSpan=this.columnHeaderCount,n.colSpan=this.rowHeaderCount,this.renderHeaderRowCornerCell(n)),++a);for(let u=a;u<t.children.length;u++)if(s=u-a,n=t.children[u],n.className="hlabel",n.innerHTML="",l.columns.length>s)if(o=l.columns[s],r=o.header[i],r.height&&(d=Math.max(r.height,d||0)),n.colSpan=1,n.rowSpan=1,n.c=o.index,n.r=i,r?.hidden)if(s==this.freezeLeft){let t=o.prevVisible,r=0;for(;t&&t.header[i]?.hidden;)t=t.prevVisible,++r;t&&t.header[i].cs?(yt(n),n.colSpan=t.header[i].cs-r-1,n.rowSpan=t.header[i].rs||1,this.renderHeaderRowLabelCell(n,t,e,i)):wt(n)}else wt(n);else{if(o.header&&o.header[i]){const t=o.header[i].cs||1;n.colSpan=t>1?o.calculateRealColspan(t):1,n.rowSpan=o.header[i].rs||1}yt(n),this.renderHeaderRowLabelCell(n,o,e,i),h&&h.r==c&&h.c==o.index&&this.renderHeaderRowCornerCell(n)}else wt(n);Ht(t,{h:d??this.model.options.rowHeight})}renderHeaderRowLabelCell(t,e,i,o){let n=this.hCache.get(e.index,i);const r=e.header[o];if(n||(n=gt("div"),r?r.html?n.innerHTML=r.label??"":n.innerText=r.label??"":n.innerHTML="",r&&null!=r._style&&dk(n,jy(this.model.styles.get(r._style))),this.hCache.set(e.index,i,n)),this.model.options.columnHeaderTreeButtons&&e.hasChildren&&o==e.level){let t=n.expander;t||(t=new Td,t.addEventListener("toggle",(()=>this.grid.rendering.toggleColumn(e.index))),n.expander=t,n.prepend(t),Ot(t,{l:4,t:4})),t.state=e.collapsed?"closed":"open"}this.grid.sorting.sortingModel&&e.sorting&&o==e.header.length-1&&(t.className+=" sort",n.sortingArrow||(n.sortingArrow=new Kw,n.appendChild(n.sortingArrow),Ot(n.sortingArrow,{t:0,r:5})),n.sortingArrow.sortSettings=this.grid.sorting.sortingModel.get(e.index)),t.appendChild(n)}renderHeaderRowFilters(t,e){let i,o,n=0;const r=this.viewport;this.model.hasRowTreeEnabled&&(i=t.children[n],i.innerHTML="",this.model.columnHeaderCount>1?wt(i):i.colSpan=this.model.columnHeaderCount,++n),this.model.options.rowNumbers&&(i=t.children[n],i.innerHTML="",this.model.hasRowTreeEnabled||this.model.options.colLetters||this.model.hasColumnTreeEnabled||this.model.headerCount>0?wt(i):(i.rowSpan=this.columnHeaderCount,i.colSpan=this.rowHeaderCount,this.renderHeaderRowCornerCell(i)),++n);for(let s=n;s<t.children.length;s++)if(o=s-n,i=t.children[s],r.columns.length>o){yt(i);const n=r.columns[o];n.hasFilter?this.renderHeaderRowFilterCell(t,e,n,i):i.innerHTML=""}else wt(i)}renderHeaderRowFilterCell(t,e,i,o){o.innerHTML="",o.className="filter",o.c=i.index;let n=this.hCache.get(i.index,e);n||(n=gt("div"),n.filter=gt("og-filter-label"),n.appendChild(n.filter),this.hCache.set(i.index,e,n));const r=this.grid.filtering.filter.get(i.index)?.term;n.filter.value=Array.isArray(r)?r.map((t=>t.value??t.key)).join(", "):r,o.appendChild(n)}renderHeaderRowCornerCell(t){this.cornerDiv=gt("div");const e=Math.max((this.treeHeaderWidth||Vw.EXPANDER_SIZE+2)/(this.model.maxRowLevel+1),Vw.EXPANDER_SIZE+2);if(this.model.hasRowTree)for(let t=0;t<=this.model.maxRowLevel;t++){const i=new Ad;i.level=t,this.cornerDiv.appendChild(i),Ot(i,{l:t*e+e/2-Vw.EXPANDER_SIZE/2,b:3}),i.addEventListener("mousedown",(t=>t.stopPropagation())),i.addEventListener("toggle",(t=>{this.model.columns.filter((t=>t.levelButtons)).forEach((t=>this.bCache.deleteColumn(t.index))),this.grid.rendering.setRowExpandLevel(t.level)}))}if(this.model.hasColumnTree){const i=(this.model.hasColumnTree?this.treeHeaderHeight:t.clientHeight)/(this.model.maxColumnLevel+1),o=15*this.model.maxColumnLevel+20<=t.clientHeight;for(let t=0;t<=this.model.maxColumnLevel;t++){const n=new Ad;n.level=t,this.cornerDiv.appendChild(n),Ot(n,o?{t:t*i+i/2-Vw.EXPANDER_SIZE/2,r:3}:{r:t*e+e/2-Vw.EXPANDER_SIZE/2,b:3}),n.addEventListener("mousedown",(t=>t.stopPropagation())),n.addEventListener("toggle",(t=>{this.grid.rendering.setColumnExpandLevel(t.level)}))}}xt(t),t.appendChild(this.cornerDiv)}renderBody(){let t,e,i,o,n,r,s;const a=this.rowHeaderCount,l=this.model.options.rowNumbers,c=this.viewport,h=[];this.rowMap.clear();for(let d=0;d<this.bRows.length;d++)if(t=this.bRows[d],d<c.rows.length){i=c.rows[d],o=i.index,Ht(t,{h:i.height}),i.height<this.model.options.rowHeight&&(Dt(t,i.height),t.style.lineHeight=It(i.height)),this.rowMap.set(o,d),l&&(e=t.children[a-1],e.className="vlabel",e.r=o,e.c=-1,e.innerHTML=`<div>${tv(o)}</div>`);for(let l=a;l<t.children.length;l++)e=t.children[l],l-a<c.columns.length?(r=c.columns[l-a],n=r.index,e.r=o,e.c=n,e.colSpan=1,e.rowSpan=1,s=i.cell(n),(s.colspan>1||s.rowspan>1)&&h.push({r:d,c:l,cs:s.colspan,rs:s.rowspan}),yt(e),this.renderBodyCell(s,e)):wt(e);t.style.display="table-row",t.className=i.filterState>1?"filtered":""}else t.style.display="none";this.mergeBodyCells(h)}scheduleRenderBodyCell(t,e){this.cellRenderSchedules.has(e)&&(window.clearTimeout(this.cellRenderSchedules.get(e)),this.cellRenderSchedules.delete(e)),this.cellRenderSchedules.set(e,window.setTimeout((()=>this.renderBodyCell(t,e))))}fixCellBorders(t,e){"none"==e.bottom?.style&&(t.style.borderBottomColor="transparent"),"none"==e.top?.style&&(t.style.borderTop="transparent"),"none"==e.right?.style&&(t.style.borderRight="transparent"),"none"==e.left?.style&&(t.style.borderLeft="transparent")}renderBodyCell(t,e){const i=!e;if(e=e||this.getCellByCellModel(t)){let o=i?null:this.bCache.get(t.c,t.r);if(o||(o=gt("div"),xk(t).call(this,o,t),this.bCache.set(t.c,t.r,o)),this.renderAll){const i=t.composedStyle;i&&this.fixCellBorders(e,i)}xt(e),e.appendChild(o)}else this.bCache.delete(t.c,t.r)}mergeBodyCells(t){let e;const i=new Set;for(const o of t)if(e=this.bRows[o.r].cells[o.c],e&&!i.has(e))for(let t=o.r;t<o.r+o.rs;t++)for(let n=o.c;n<o.c+o.cs;n++)e=this.bRows[t].cells[n],e&&(t==o.r&&n==o.c?(e.colSpan=o.cs,e.rowSpan=o.rs):(i.add(e),wt(e)))}renderRowTree(){if(!this.model.hasRowTreeEnabled)return;let t;const e=this.viewport,i=-this.rowHeaderCount;for(let o=0;o<this.bRows.length;o++)t=this.bRows[o].children[0],t.innerHTML="",o<e.rows.length&&(t.className="vtree",this.renderRowTreeCell(i,e.rows[o],t))}renderRowTreeCell(t,e,i){let o=this.bCache.get(t,e.index);if(!o){o=gt("div"),this.bCache.set(t,e.index,o);const n=e.height+1,r=this.treeHeaderWidth/this.model.maxRowLevel;if(e.hasChildren){const t=new Td;t.addEventListener("toggle",(()=>this.grid.rendering.toggleRow(e.index))),i.parentElement.expander=t,o.expander=t,o.appendChild(t),Ot(t,{t:n/2-Vw.EXPANDER_SIZE/2,l:e.level*r+r/2-Vw.EXPANDER_SIZE/2});const s=this.createExpanderLine("v");o.appendChild(s),Ot(s,{t:this.model.options.rowTree.reversed?0:n/2,l:e.level*r+r/2}),Ht(s,{w:r/2,h:n/2+1})}if(e.hasParent){let t=e;for(;t.hasParent;){t=t.parent;const e=this.createExpanderLine("v");o.appendChild(e),Ht(e,{w:r/2,h:n+2}),Ot(e,{t:-1,l:t.level*r+r/2})}}}o.expander&&(o.expander.state=e.collapsed?"closed":"open"),i.appendChild(o)}};ex.styles=[Xw],Jw([is({type:Object})],ex.prototype,"model",void 0),Jw([is({type:Number,hasChanged:()=>!1})],ex.prototype,"rowOffset",void 0),Jw([is({type:Number,hasChanged:()=>!1})],ex.prototype,"colOffset",void 0),Jw([is({type:Number,reflect:!0})],ex.prototype,"zoom",void 0),Jw([is({type:Boolean,reflect:!0})],ex.prototype,"nogrid",void 0),Jw([is({type:Boolean,reflect:!0})],ex.prototype,"renderAll",void 0),ex=Jw([Jr("og-table")],ex);const ix=["F5","F12"];class ox extends Event{get selection(){return this.grid.selecting.selection}get activeCell(){return this.selection.activeCell}constructor(t,e){super(`grid.${t}`,{bubbles:!0,composed:!0}),Object.assign(this,e),this.cell&&(this.row=this.cell.row,this.column=this.cell.column)}}class nx extends ox{constructor(t){super("edit",t)}}class rx extends su{constructor(t,e,i){super(`grid.${t}`,i),this.grid=e}}class sx extends rx{constructor(t,e,i,o){super(t,e,o),this.column=i}}class ax extends rx{constructor(t,e,i,o){super(t,e,o),this.row=i}}class lx{get model(){return this.grid.model}get selection(){return this.grid.selection}get table(){return this.grid.table}constructor(t){this.grid=t,this.clickDisabled=!1,this.editDisabled=!1,this.clicked=!1,this.startOffset={x:0,y:0},this.suspendClick=()=>this.clickDisabled=!0,this.resumeClick=(t=!1)=>{this.isSliding||(t?setTimeout((()=>this.clickDisabled=!1),100):this.clickDisabled=!1)},this._onKeyDown=t=>{switch(ix.includes(t.key)||t.preventDefault(),t.key){case"Tab":t.preventDefault(),this.grid.selecting.shiftActiveCell(t.shiftKey?-1:1,!0);break;case"ArrowRight":this.grid.selecting.debounceMoveSelector(1,0);break;case"ArrowLeft":this.grid.selecting.debounceMoveSelector(-1,0);break;case"ArrowDown":this.grid.selecting.debounceMoveSelector(0,1);break;case"ArrowUp":this.grid.selecting.debounceMoveSelector(0,-1);break;case"PageUp":this.grid.selecting.debounceMoveSelector(0,-this.table.viewport.rows.length);break;case"PageDown":this.grid.selecting.debounceMoveSelector(0,this.table.viewport.rows.length);break;case"Home":this.grid.selecting.debounceMoveSelector(-this.selection.range.c1,t.ctrlKey?-this.selection.range.r1:0);break;case"End":this.grid.selecting.debounceMoveSelector(this.model.gridRange.c2-this.selection.range.c1,t.ctrlKey?this.model.gridRange.r2-this.selection.range.r1:0);break;case"Enter":this.grid.selecting.enter();break;case"Escape":this.grid.selecting.hideCopySelector();break;case"c":t.ctrlKey&&this.grid.editing.copySelection();break;case"v":t.ctrlKey&&this.grid.editing.paste();break;case"z":if(!this.grid.options.undoRedo)return;t.ctrlKey&&this.grid.editing.undo();break;case"y":if(!this.grid.options.undoRedo)return;t.ctrlKey&&this.grid.editing.redo();break;case"F2":t.preventDefault(),this.grid.editing.startEdit();break;case"Delete":t.preventDefault(),this.grid.objects.delete(),this.grid.editing.clearSelection();break;case"Backspace":t.preventDefault(),this.grid.editing.clearSelection()}1!=t.key.length||t.ctrlKey||this.grid.editing.startEdit(t.key)},this._onMouseMove=t=>{let e=!0;const i=this.grid.hSizer,o=this.grid.vSizer,{offsetX:n,offsetY:r}=t;let s=this.model.options.scrolling.scrollbarVisibilityTreshold;s<=0&&(s=Math.max(this.grid.clientWidth,this.grid.clientHeight)),n>this.grid.clientWidth-s?this.grid.vSlider.show():this.grid.vSlider.hide(),r>this.grid.clientHeight-s?this.grid.hSlider.show():this.grid.hSlider.hide();const a=this.table.findNearestTableCellByOffset(n,r);if(a&&"TH"==a.tagName)return this.model.options.columnResize&&!i.resizing&&a.classList.contains("hlabel")?a.offsetWidth-t.offsetX+a.offsetLeft<Vw.RESIZE_TRESHOLD?(i.snap(a,this.grid),this.grid.rendering.currentResizedColumn=this.model.columns[a.c]):vt(i):this.model.options.rowResize&&!o.resizing&&a.classList.contains("vlabel")&&(a.offsetHeight-t.offsetY+a.offsetTop<Vw.RESIZE_TRESHOLD?(o.snap(a,this.grid),this.grid.rendering.currentResizedRow=this.model.rows[a.r]):vt(o)),void(this.grid.selecting.isSelecting&&(this.suspendClick(),this.grid.selecting.updateSelecting(a.c,a.r)));if(a&&"TD"==a.tagName)if(this.grid.selecting.isSelectorOperationActive||this.grid.selecting.isFormulaSelectorOperationActive){const{top:e,left:i}=Et(a,this.grid);this.grid.rendering.autoscroll({x:i-this.table.totalHeaderWidth+t.offsetX-a.offsetLeft,y:e-this.table.thead.clientHeight+t.offsetY-a.offsetTop}),this.grid.selecting.isSelecting&&this.suspendClick(),this.grid.selecting.updateSelecting(a.c,a.r)}else{const t=this.model.rows[a.r]?.cell(a.c);t&&t.hasTooltip&&(e=!1,this.grid.tooltip.attachToCell(a,t)),t&&t.hasComment&&(e=!1,this.grid.comment.attachTo(a,t))}e&&(this.grid.tooltip.deatach(),this.grid.comment.deatach(this.model.options.comments.hideTimeout)),vt(i),vt(o)},this._onMouseDown=t=>{if(1&t.buttons){this.grid.setPointerCapture(t.pointerId),this.startOffset={x:t.offsetX,y:t.offsetY};for(const e of t.composedPath()){if("TD"==e.tagName){const t=e;this.grid.selecting.startCellSelecting(new Jm(t.c,t.r));break}if("TH"==e.tagName){const t=e;e.matches(".sort")?this.grid.sorting.sort(t.c):t.classList.contains("filter")?this.grid.filtering.openFilter(this.model.columns[t.c],t):t.classList.contains("hlabel")?this.grid.selecting.startColumnSelecting(t.c):t.classList.contains("vlabel")&&this.grid.selecting.startRowSelecting(t.r);break}}}},this._onMouseUp=t=>{if(0!=t.buttons)return;const e=Math.abs(this.startOffset.x-t.offsetX),i=Math.abs(this.startOffset.y-t.offsetY);Math.sqrt(Math.pow(e,2)+Math.pow(i,2))<this.model.options.events.click.mouseMoveTreshold&&this.resumeClick(),this.grid.releasePointerCapture(t.pointerId),this.grid.selecting.stopSelectOperations()},this._onClick=t=>{if(this.clickDisabled)return;if(this.grid.clientHeight-t.offsetY<this.grid.hSlider.offsetHeight)return;if(this.grid.clientWidth-t.offsetX<this.grid.vSlider.offsetWidth)return;const e=this.table.findTableCellByOffset(t.offsetX,t.offsetY),i="TD"==e?.tagName?this.model.rows[e.r]?.cell(e.c):null;this.grid.dispatchEvent(new ox("click",{grid:this.grid,cell:i}))},this._onContextMenu=t=>{t.preventDefault();for(const e of t.composedPath())if("TD"==e.tagName){const i=e;this.grid.menus.openCellMenu(this.model.rows[i.r].cell(i.c),{x:t.pageX,y:t.pageY})}else if("TH"==e.tagName){const i=e;i.classList.contains("hlabel")?this.grid.menus.openColumnMenu(this.model.columns[i.c],{x:t.pageX,y:t.pageY}):i.classList.contains("vlabel")&&this.grid.menus.openRowMenu(this.model.rows[i.r],{x:t.pageX,y:t.pageY})}},this._onVerticalSlide=t=>{this.table.rowOffset=Math.min(t.value,this.model.visibleRows.length-1),this.grid.rendering.requireVerticalUpdate=!0,this.grid.logger.info(`v-slide: ${t.value}`),this.grid.rendering.renderCells()},this._onHorizontalSlide=t=>{this.table.colOffset=Math.min(t.value,this.model.visibleColumns.length-1),this.grid.rendering.requireHorizontalUpdate=!0,this.grid.logger.info(`h-slide: ${t.value}`),this.grid.rendering.renderCells()},this._onSlideStart=()=>{this.suspendClick()},this._onSlideStop=()=>{this.resumeClick(!0)},this._denbounceHorizontalScroll=U((t=>this.grid.rendering.scrollHorizontalByPixels(t)),50),this._onWheel=t=>{t.ctrlKey||(0!=t.deltaY&&this.grid.rendering.scrollVerticalByPixels(t.deltaY),0!=t.deltaX&&this._denbounceHorizontalScroll(Math.sign(t.deltaX)*Math.min(100,Math.abs(t.deltaX))))},this._onTouchStart=t=>{this.grid.rendering.touchStartX=t.touches[0],this.grid.rendering.touchStartY=t.touches[0]},this._onTouchEnd=t=>{this.grid.rendering.touchStartX=t.touches[0],this.grid.rendering.touchStartY=t.touches[0]},this._onTouchMove=t=>{const e=this.grid.rendering;if(e.touchStartY){const i=e.touchStartY.clientY-t.touches[0].clientY;Math.abs(i)>this.model.options.rowHeight&&this.table.viewport.rows.length>0&&(e.scrollVerticalByPixels(i),e.touchStartY=t.touches[0])}if(e.touchStartX){const i=e.touchStartX.clientX-t.touches[0].clientX;Math.abs(i)>this.model.options.columnWidth&&this.table.viewport.columns.length>0&&(e.scrollHorizontalByPixels(i),e.touchStartX=t.touches[0])}},this._onHorizontalResizeStart=()=>{this.grid.rendering.resizing=!0,this.grid.rendering.currentResizedColumnWidth=this.grid.rendering.currentResizedColumn.width},this._onHorizontalResizeStop=t=>{this.suspendClick(),this.grid.rendering.resizing=!1,this.table.clearHeaderCache(),this.table.renderCells({horizontal:!0}),this.grid.dispatchEvent(new sx("column.resize",this.grid,this.grid.rendering.currentResizedColumn,t))},this._onHorizontalResize=t=>{const e=this.grid.rendering;e.currentResizedColumn.width=e.currentResizedColumnWidth+t.deltaX,Ht(this.table.getColumnByModelIndex(e.currentResizedColumn.index),{w:e.currentResizedColumn.width},!0),this.grid.selecting.updateSelector()},this._onVerticalResizeStart=()=>{this.grid.rendering.resizing=!0,this.grid.rendering.currentResizedRowHeight=this.grid.rendering.currentResizedRow.height},this._onVerticalResizeStop=t=>{this.suspendClick(),this.grid.rendering.resizing=!1,this.table.clearBodyCache(),this.table.renderCells({vertical:!0}),this.grid.dispatchEvent(new ax("row.resize",this.grid,this.grid.rendering.currentResizedRow,t))},this._onVerticalResize=t=>{const e=this.grid.rendering;e.currentResizedRow.height=e.currentResizedRowHeight+t.deltaY,Ht(this.table.getRowByModelIndex(e.currentResizedRow.index),{h:e.currentResizedRow.height},!1),this.grid.selecting.updateSelector()},this._onCommentCommit=t=>{this.grid.model.comments.set(t.cell.address,t.items),t.cell.invalidateStyle(),this.grid.rendering.updateCells([t.cell])},this._onAutofill=t=>{if(this.suspendClick(),this.grid.selection.range.equals(t.selector.autofillRange))return;const{cells:e,oldValues:i}=Ly(this.model,this.grid.selection.range,t.selector.autofillRange,t.selector.autofillDirection);this.grid.rendering.updateCells(e,!0),this.grid.selection.setRange(this.grid.selection.range.unite(t.selector.autofillRange)),this.grid.selecting.updateSelector(),this.grid.dispatchEvent(new nx({grid:this.grid,editType:"autofill",cells:e,oldValues:i,newValues:e.map((t=>t.value2))}))},this._onEdit=t=>{if(t.fromHistory)return;const e=[],i=[],o=this.model.names.rangeMap;let n=[],r=[];switch(t.editType){case"value":n=t.newValues,r=t.oldValues,t.cells.forEach((t=>{const n=t.address;e.push(n),i.push(o.get(n))}));break;case"insert_column":case"insert_row":t.newValues.forEach((t=>{const r=t.address;e.push(r),i.push(o.get(r)),n.push(t.getSourceData())}))}this.grid.history.push({type:t.editType,addresses:e,names:i,oldValues:r,newValues:n})},this._onSelectorMove=t=>{this.suspendClick(),this.selection.setRange(t.toRange),t.fromRange.isRow?this.grid.editing.moveRows({index:t.fromRange.r1,count:t.fromRange.size.rows,targetIndex:t.toRange.r1}):t.fromRange.isColumn?this.grid.editing.moveColumns({index:t.fromRange.c1,count:t.fromRange.size.columns,targetIndex:t.toRange.c1}):console.log(t)},this._onMouseLeave=()=>{this.grid.rendering.hideSliders()},this.debounceHideSliders=U((()=>this.grid.rendering.hideSliders()),1e3,{isImmediate:!1}),this._onRender=()=>{const t=this.grid;t.selecting.updateSelectors(),t.dispatchEvent(new ox("render",{grid:this.grid})),t.adapter&&t.options.pageSize&&t.rendering.isLastRowInViewport()&&t.rendering.loadNextPage(),t.rendering.updateSliderVisibility(),this.model.options.scrolling.scrollbarVisibilityTreshold>0&&this.debounceHideSliders()},this._onHorizontalSizerDblClick=t=>{t.stopPropagation(),this.editDisabled=!0,this.grid.rendering.autofitColumn(this.grid.rendering.currentResizedColumn.index),this.grid.dispatchEvent(new sx("column.resize",this.grid,this.grid.rendering.currentResizedColumn,t))},this._onDblClick=()=>{this.editDisabled?this.editDisabled=!1:this.grid.editing.startEdit()}}get isSliding(){return this.grid.hSlider.sliding||this.grid.vSlider.sliding}async init(){await this.grid.updateComplete,await this.table.updateComplete;const t=this.grid;t.addEventListener("wheel",this._onWheel,{passive:!0}),t.addEventListener("touchstart",this._onTouchStart,{passive:!0}),t.addEventListener("touchend",this._onTouchEnd,{passive:!0}),t.addEventListener("touchmove",this._onTouchMove,{passive:!0}),t.hSizer.addEventListener("resizestart",this._onHorizontalResizeStart),t.hSizer.addEventListener("resizestop",this._onHorizontalResizeStop),t.hSizer.addEventListener("resize",this._onHorizontalResize),t.hSizer.addEventListener("dblclick",this._onHorizontalSizerDblClick),t.vSizer.addEventListener("resizestart",this._onVerticalResizeStart),t.vSizer.addEventListener("resizestop",this._onVerticalResizeStop),t.vSizer.addEventListener("resize",this._onVerticalResize),t.comment.addEventListener("comment.commit",this._onCommentCommit),t.addEventListener("keydown",this._onKeyDown),t.addEventListener("click",this._onClick),t.addEventListener("contextmenu",this._onContextMenu),t.addEventListener("toggle",(()=>t.rendering.debounceCalculateViewport())),t.addEventListener("pointerup",this._onMouseUp),t.addEventListener("pointerdown",this._onMouseDown);const e=U(this._onMouseMove,20,{maxWait:50,isImmediate:!0});t.addEventListener("pointermove",e),t.addEventListener("mouseleave",this._onMouseLeave),t.table.addEventListener("rendercells",this._onRender),t.selector.addEventListener("grid.selector.autofill",this._onAutofill),t.selector.addEventListener("grid.selector.move",this._onSelectorMove),t.addEventListener("dblclick",this._onDblClick),t.addEventListener("grid.edit",this._onEdit)}}class cx{get vScrolling(){return this._vScrolling}get hScrolling(){return this._hScrolling}get model(){return this.grid.model}get selection(){return this.grid.selection}get table(){return this.grid.table}constructor(t){this.grid=t,this.requireVerticalUpdate=!0,this.requireHorizontalUpdate=!1,this.resizing=!1,this._vScrolling=!0,this._hScrolling=!0,this.debounceRenderCells=U(this.renderCells,50,{isImmediate:!1,maxWait:100}),this.debounceCalculateViewport=U(this.calculateViewport,200)}isLastRowInViewport(){const t=this.grid.table.viewport.rows,e=this.model.visibleRows;return t[t.length-1]==e[e.length-1]}renderCells(t){t=t||{vertical:this.requireVerticalUpdate,horizontal:this.requireHorizontalUpdate},this.grid.comment.deatach(),this.grid.table.renderCells(t),this.requireHorizontalUpdate=!1,this.requireVerticalUpdate=!1,this.debounceCalculateViewport(),this.grid.objects.updatePostions()}renderAll(t=!1){this.grid.group?this.grid.group.grids.forEach((e=>e.rendering.render(t))):this.render(t)}async render(t=!1){this.grid.table&&this.model&&(this.grid.table.clearHeaderCache(),this.grid.table.clearBodyCache(),this.grid.table.isConnected&&(t&&(this.grid.table.requestUpdate(),await this.grid.table.updateComplete),this.grid.table.renderCells({horizontal:!0,vertical:!0}),this.calculateViewport()))}updateRange(t,e=!1){for(const i of this.model.getRangeIterator(t))this.updateCells([i],e)}updateCell(t,e=!1){this.updateCells([t],e)}updateSpilledCells(t){let e;t.prevSpillRange&&(e=new Set,this.model.getRangeIterator(t.prevSpillRange).forEach((t=>e.add(t)))),t.spillRange&&(e=e||new Set,this.model.getRangeIterator(t.spillRange).forEach((t=>e.add(t)))),e?.size>0&&this.updateCells(e)}updateCells(t,e=!1){if(e)for(const e of t)e.invalidateStyle(),e.invalidateValue(),this.model.calculations.clearDependecies(e).evaluate(e),this.updateSpilledCells(e);const i=this.grid.table;for(const e of t)i.renderBodyCell(e);e&&(this.model.calculations.invalidateDependants(t).forEach(((t,e)=>{t?this.grid.group.getGrid(t)?.table.renderBodyCell(e):i.renderBodyCell(e),this.updateSpilledCells(e)})),this.grid.dispatchGridEvent("calculate",{cells:Array.from(t)}))}updateHeaders(){this.model.indexVisibleColumns(),this.table.clearHeaderCache(),this.table.createHeaderRows(),this.table.renderHeader()}calculateViewport(t=!1){this.grid.logger.info("calculate viwport"),this.updateCells(this.model.calculateViewport(),t)}updateSliders(){const t=this.table.viewportSize;this.grid.vSlider.maxValue=this.model.visibleRows.length,this.grid.vSlider.pageSize=t.h/this.model.options.rowHeight,this.grid.vSlider.value=this.table.rowOffset,this.grid.hSlider.maxValue=this.model.visibleColumns.length,this.grid.hSlider.pageSize=t.w/this.model.options.columnWidth,this.grid.hSlider.value=this.table.colOffset}isVerticalScrollingEnabled(){return!1!==this.grid.options.scrolling.verticalOverscroll||this.table.viewport.rows.length<this.model.visibleRows.length}isHorizontalScrollingEnabled(){return!1!==this.grid.options.scrolling.horizontalOverscroll||this.table.viewport.columns.length<this.model.visibleColumns.length}updateSliderVisibility(){this._vScrolling=this.isVerticalScrollingEnabled(),this._vScrolling?(this.grid.vSlider.show(),mt(this.grid.vSlider)):(this.grid.vSlider.hide(),vt(this.grid.vSlider)),this._hScrolling=this.isHorizontalScrollingEnabled(),this._hScrolling?(this.grid.hSlider.show(),mt(this.grid.hSlider)):(this.grid.hSlider.hide(),vt(this.grid.hSlider))}hideSliders(){this.grid.vSlider.hide(),this.grid.hSlider.hide()}scrollVerticalByPixels(t){if(!this.vScrolling)return;let e,i=this.table.rowOffset,o=0,n=0;if(t>0){for(;o<t&&i+n<this.model.visibleRows.length;)o+=this.model.visibleRows[i+n++].height+2;i+=n}else if(t<0){for(t=Math.abs(t);o<t&&i+n>=0;)e=this.model.visibleRows[Math.min(this.model.visibleRows.length-1,i+n--)],o+=(e?e.height:0)+2;i+=n}i>=this.model.visibleRows.length&&(i=this.model.visibleRows.length-1),this.requireVerticalUpdate=!0,this.table.rowOffset=Math.max(0,i),this.debounceRenderCells(),this.updateSliders()}scrollHorizontalByPixels(t){if(!this.hScrolling)return;let e=this.table.colOffset,i=0,o=0;if(t>0){for(;i<t&&e+o<this.model.visibleColumns.length;)i+=this.model.visibleColumns[e+o++].width+2;e+=o}else if(t<0){for(t=Math.abs(t);i<t&&e+o>=0;)i+=this.model.visibleColumns[Math.min(this.model.visibleColumns.length-1,e+o--)].width+2;e+=o}e>=this.model.visibleColumns.length&&(e=this.model.visibleColumns.length-1),this.requireHorizontalUpdate=!0,this.table.colOffset=Math.max(0,e),this.debounceRenderCells(),this.updateSliders()}updateCellSelectionRange(){const t=this.table;for(const e of this.model.getRangeIterator(this.selection.range,!1))t.renderBodyCell(e)}getAdapterRequestFilters(){return{offset:0,filter:this.grid.filtering?.filter?Array.from(this.grid.filtering.filter.settings.values()):null,order:this.grid.sorting?.sortingModel?.settings}}async toggleRow(t,e=!0){const i=this.model.rows[t];if(i.isLoaded||i.isPartialyLoaded)i.toggleCollapse(!1,this.model.options.unhideRowAfterExpand),this.table.renderCells({vertical:!0});else if(this.grid.adapter){const e=this.table.getRowByModelIndex(t);e&&e.expander&&(e.expander.state="waiting"),i.collapsed=!1;const[o]=await Promise.all([this.grid.adapter.getRows(Object.assign(this.getAdapterRequestFilters(),{parent:{r:i.index,props:i.properties}}))]);this.model.insertRowData(i,0,o),this.table.requestUpdate()}this.updateSliders(),e&&this.grid.dispatchEvent(new ox("row.toggle",{grid:this.grid,row:i}))}toggleColumn(t,e=!0){const i=this.model.columns[t];i.toggleCollapse(!1,this.model.options.unhideColumnAfterExpand),this.table.renderCells({horizontal:!0}),this.updateSliders(),e&&this.grid.dispatchEvent(new ox("column.toggle",{grid:this.grid,column:i}))}setRowExpandLevel(t){this.model.setRowExpandLevel(t),this.table.rowOffset=0,this.table.renderCells({vertical:!0}),this.updateSliders(),this.grid.dispatchEvent(new ox("row.toggle",{grid:this.grid}))}setColumnExpandLevel(t){this.model.setColumnExpandLevel(t),this.table.colOffset=0,this.table.renderCells({horizontal:!0}),this.updateSliders(),this.grid.dispatchEvent(new ox("column.toggle",{grid:this.grid}))}async exportHTML(){const t=gt("div");vt(t),document.body.appendChild(t);const e=gt("og-table");e.grid=this.grid,e.model=this.model,e.renderAll=!0,t.appendChild(e),await e.updateComplete;const i=`\n\t\t\t<style>\n\t\t\t\thtml {\n\t\t\t\t\t${ea(ca().themes.get("light")).cssText}\n\t\t\t\t}\n\t\t\t\t${ex.styles.map((t=>t.cssText)).join("\n")}\n\t\t\t</style>\n\n\t\t`,o=i+e.shadowRoot.innerHTML.replace(/<!---->/g,"");return t.remove(),o}stopAutoscroll(){this.autoscrollTimer&&window.clearInterval(this.autoscrollTimer)}startAutoscroll(){this.stopAutoscroll(),this.autoscrollTimer=window.setInterval((()=>{if(0==this.autoscrollValue)return this.stopAutoscroll();const t=Math.pow(this.autoscrollValue,Hm.AUTOSCROLL_RATIO);switch(this.autoscrollDirection){case"down":this.scrollVerticalByPixels(t);break;case"up":this.scrollVerticalByPixels(-t);break;case"left":this.scrollHorizontalByPixels(-t);break;case"right":this.scrollHorizontalByPixels(t)}}),Hm.AUTOSCROLL_INTERVAL)}autoscroll(t){const{x:e,y:i}=t,o=this.table.clientWidth/this.table.zoom-this.table.totalHeaderWidth,n=this.table.clientHeight/this.table.zoom-this.table.totalHeaderHeight;let r,s=0;e<Hm.AUTOSCROLL_TRESHOLD&&e<i&&e<n-i?(r="left",s=Hm.AUTOSCROLL_TRESHOLD-e):o-e<Hm.AUTOSCROLL_TRESHOLD&&o-e<i&&o-e<n-i?(r="right",s=Hm.AUTOSCROLL_TRESHOLD-o+e):i<Hm.AUTOSCROLL_TRESHOLD?(r="up",s=Hm.AUTOSCROLL_TRESHOLD-i):n-i<Hm.AUTOSCROLL_TRESHOLD&&(r="down",s=Hm.AUTOSCROLL_TRESHOLD-n+i),this.autoscrollDirection=r,this.autoscrollValue=s,this.stopAutoscroll(),s>0&&this.startAutoscroll()}async loadNextPage(t=null,e=!1){if(this.grid.loading)return;const i=null!=t?this.model.rows[t]:this.model.rowRoot;if(!e&&i.isLoaded)return;this.grid.dispatchEvent(new ox("beforeLoad",{grid:this.grid})),this.grid.loading=!0;const o=this.model.rows.length;this.grid.logger.info(`loading rows offset = ${o}`);const[n]=await Promise.all([this.grid.adapter.getRows(Object.assign(this.getAdapterRequestFilters(),{offset:o,parent:{r:t,props:null}}))]);n.length>0&&null===t&&this.model.insertRowData(i,o,n),this.table.requestUpdate(),n.length>=this.model.options.pageSize?i.count=1/0:i.count=i.children.length,this.grid.logger.info(`loaded ${n.length} rows`),this.grid.loading=!1,this.grid.dispatchEvent(new ox("afterLoad",{grid:this.grid}))}get totalSize(){return{width:this.table.totalHeaderWidth+this.model.visibleColumns.reduce(((t,e)=>t+e.width),0),height:this.table.thead.offsetHeight+this.model.visibleRows.reduce(((t,e)=>t+e.height),0)}}autofitColumn(t,e=!1){const i="number"==typeof t?this.model.columns[t]:t,o=this.autofitDiv??(this.autofitDiv=gt("div"));o.style.position="absolute",o.style.zIndex="100000",Ot(o,{l:-1e3,t:-1e3}),this.grid.shadowRoot.appendChild(o);let n=0;for(const t of this.model.getRangeIterator(Jm.fromA1(i.address),!!e)){const e=xk(t).call(this.table,o,t)||o;e.style.width="auto",n=Math.max(n,e.offsetWidth)}i.width=n+10,this.table.renderCells({horizontal:!0})}autofitColumns(t=!1){this.model.columns.forEach((e=>this.autofitColumn(e,t)))}scrollTo(t,e=0){let i;i=Z(t)?Jm.fromA1(t):new Jm(e,t),this.table.rowOffset=i.r1,this.table.colOffset=i.c1,this.requireVerticalUpdate=!0,this.requireHorizontalUpdate=!0,this.debounceRenderCells(),this.updateSliders()}}class hx{get model(){return this.grid.model}get selection(){return this.grid.editing.isFormulaMode?this.formulaSelection:this.grid.selection}get selector(){return this.grid.editing.isFormulaMode?this.grid.formulaSelector:this.grid.selector}get formulaSelection(){return this._formulaSelection}get events(){return this.grid.events}get table(){return this.grid.table}get isSelecting(){return this.isCellSelecting||this.columnSelecting||this.rowSelecting}get isCellSelecting(){return this.selector.isSelecting}get isAutofilling(){return this.selector.isAutofilling}get isMoving(){return this.selector.isMoving}get isSelectorOperationActive(){return this.selector.isSelectorOperationActive}get isFormulaSelectorOperationActive(){if(!this.grid.editing.isFormulaMode)return!1;for(const t of this.formulaSelectors.values())if(t.isSelectorOperationActive)return!0;return!1}get activeCell(){const{c:t,r:e}=this.selection.activeCellCoords;return this.model.rows[e]?.cell(t)}constructor(t){this.grid=t,this.columnSelecting=!1,this.rowSelecting=!1,this._formulaSelection=new jw(0,0,0,0),this.formulaSelectors=new Map,this.debounceMoveSelector=U(((t,e)=>this.moveSelector(t,e)),10)}moveToSelection(){const t=new Jm(this.selection.range.c1,this.selection.range.r1);this.table.viewportRange.contains(t)}select(t,e=!1){this.selection.setRange(t),this.updateSelector(),e&&this.grid.dispatchEvent(new ox("select",{grid:this.grid}))}startCellSelecting(t){this.grid.style.cursor="cell",this.startSelectingRange=t.clone(),this.select(t,!0),this.selector.startSelecting(t)}startColumnSelecting(t){this.columnSelecting=!0;const e=new Jm(t,null,t,null);this.startSelectingRange=e.clone(),this.select(e,!0)}startRowSelecting(t){this.rowSelecting=!0;const e=new Jm(null,t,null,t);this.startSelectingRange=e.clone(),this.select(e,!0)}updateSelecting(t,e){const i=this.model.options.selecting.multiSelect;(this.isCellSelecting||this.rowSelecting)&&(i||(this.selection.range.r1=e),this.selection.range.r2=e),(this.isCellSelecting||this.columnSelecting)&&(i||(this.selection.range.c1=t),this.selection.range.c2=t),this.grid.editing.isFormulaMode?(this.updateFormulaSelector(),this.formulaSelectors.forEach((i=>i.updateMovingOperations(t,e)))):(this.updateSelector(),this.hideFormulaSelector(),this.selector.updateMovingOperations(t,e))}stopSelecting(){this.grid.rendering.stopAutoscroll(),this.isSelecting&&!this.selection.range.equals(this.startSelectingRange)&&this.grid.dispatchEvent(new ox("select",{grid:this.grid})),this.columnSelecting=!1,this.rowSelecting=!1,this.startSelectingRange=null,this.selector.stopSelectorOperations()}highlightSelection(){const t=this.selection.range,[e,i]=[Math.min(t.c1,t.c2),Math.max(t.c1,t.c2)],[o,n]=[Math.min(t.r1,t.r2),Math.max(t.r1,t.r2)],r=i-e+1,s=n-o+1;this.table.highlightColHeaderCells(r<1/0?Array.from(new Array(r),((t,i)=>i+e)):[]),this.table.highlightRowHeaderCells(s<1/0?Array.from(new Array(s),((t,e)=>e+o)):[])}updateSelector(t=!0){this.model.options.selecting.enabled?(this.showSelector(t),this.highlightSelection()):this.hideSelector(),this.grid.editing.isFormulaMode||this.grid.editing.endEdit()}showSelector(t=!0){this.selector&&(this.selector.show(),this.selector.select(this.selection.range,t))}hideSelector(){this.selector.hide()}moveSelector(t,e){if(this.selection.move(t,e,this.model.columns.length,this.model.rows.length),0!=e&&!this.model.rows[this.selection.range.r1].visible){const t=e>0?this.model.rows[this.selection.range.r1].nextVisible:this.model.rows[this.selection.range.r1].prevVisible;t&&(this.selection.range.r1=t.index,this.selection.range.r2=t.index)}if(0!=t&&!this.model.columns[this.selection.range.c1].visible){const e=t>0?this.model.columns[this.selection.range.c1].nextVisible:this.model.columns[this.selection.range.c1].prevVisible;e&&(this.selection.range.c1=e.index,this.selection.range.c2=e.index)}this.selector.selection=this.selection.range,this.selector.updatePosition();const i={c:0,r:0};(e>0&&this.selector.offsetTop+this.selector.offsetHeight>this.grid.clientHeight||e<0&&this.selector.offsetTop<this.table.totalHeaderHeight-1||e>=this.table.viewport.rows.length)&&(i.r+=e),(t>0&&this.selector.offsetLeft+this.selector.offsetWidth>this.grid.clientWidth||t<0&&this.selector.offsetLeft<this.table.totalHeaderWidth-1)&&(i.c+=t),0==i.c&&0==i.r||(this.table.colOffset=Math.max(0,this.table.colOffset+i.c),this.table.rowOffset=Math.min(Math.max(0,this.table.rowOffset+i.r),this.model.visibleRows.length-1),this.table.renderCells({horizontal:0!=i.c,vertical:0!=i.r}),this.grid.rendering.updateSliders()),this.grid.editing.isFormulaMode||this.grid.editing.endEdit(),this.highlightSelection(),this.grid.dispatchEvent(new ox("select",{grid:this.grid}))}shiftActiveCell(t,e=!1){this.selection.moveActiveCell(t,0),this.selector.updatePosition(),e&&this.grid.dispatchEvent(new ox("select",{grid:this.grid}))}updateFormulaSelector(t=!0){this.grid.editing.isFormulaMode?this.showFormulaSelector(t):this.hideFormulaSelector()}showFormulaSelector(t=!0){this.grid.formulaSelector.show(),this.grid.formulaSelector?.select(this.formulaSelection.range,t)}hideFormulaSelector(){this.grid.formulaSelector.hide()}updateFormulaSelectors(){this.formulaSelectors.forEach((t=>t.updatePosition()))}highlightColorItem(t){const e=jw.fromRange(Jm.fromA1(t.address)),i=gt("og-selector");this.grid.shadowRoot.appendChild(i),i.addEventListener("grid.selector.move",(t=>this.select(t.selector.selection.clone()))),i.addEventListener("grid.selector.resize",(t=>this.select(t.selector.selection.clone()))),i.grid=this.grid,i.color=t.color,i.subselector=!1,i.movable=!0,i.resizable=!0,i.index=t.tokenIndex,this.formulaSelectors.set(t.tokenIndex,i),i.select(e.range.clone(),!1),i.show()}highlightFormula(t){this.removeFormulaHighlight(),this.formulaSelectors.clear();const e=new Set;t.colors.forEach((t=>{if(null==t.sheet||t.sheet==this.model.name)this.highlightColorItem(t);else if(this.grid.group){const i=this.grid.group.getGrid(t.sheet);if(!i)return;e.has(i)||(e.add(i),i.selecting.removeFormulaHighlight()),i.isConnected&&i.selecting.highlightColorItem(t)}}))}removeFormulaHighlight(){this.formulaSelectors?.forEach((t=>kt(t))),this.formulaSelectors.clear()}updateCopySelector(){this.grid.copySelector.isVisible&&this.grid.copySelector.updatePosition()}showCopySelector(){this.grid.copySelector.show(),this.grid.copySelector?.select(this.selection.range.clone(),!1)}hideCopySelector(){this.grid.copySelector.hide()}mergeSelection(){const t=this.selection.range,e=this.model.rows[t.r1]?.cell(t.c1);e&&(e.rowspan=t.size.rows,e.colspan=t.size.columns,this.grid.rendering.renderCells({vertical:!0,horizontal:!0}))}unmergeSelection(){const t=this.selection.range,e=this.model.rows[t.r1]?.cell(t.c1);e&&(e.rowspan=1,e.colspan=1,this.grid.rendering.renderCells({vertical:!0,horizontal:!0}))}updateSelectors(){this.updateSelector(!1),this.updateCopySelector(),this.updateFormulaSelectors()}stopSelectOperations(){this.stopSelecting(),this.formulaSelectors.forEach((t=>t.stopSelectorOperations())),this.grid.style.removeProperty("cursor")}enter(){const t=this.grid.group;if(this.grid.editing.isFormulaMode&&t){const e=t.formulaModeGrid;e.editing.commitEdit(),t.activateGrid(e.model.name)}else this.debounceMoveSelector(0,1)}}class dx extends Event{}class ux extends Qr{constructor(){super(),this.cancel=!1,this._open=!1,this.init()}init(){this.addEventListener("keydown",(t=>{"Enter"==t.key?this.close():"Escape"==t.key?(this.cancel=!0,this.close()):t.stopPropagation()}))}connectedCallback(){super.connectedCallback(),this.performUpdate()}alignWithCell(){if(!this.activeCell)return;const t=Et(this.activeCell,this.grid);Ot(this,{t:t.top*this.grid.zoom,l:t.left*this.grid.zoom}),Ht(this,{w:this.activeCell.offsetWidth,h:this.activeCell.offsetHeight})}open(t,e=null,i=!0){this.initialValue=e,this._open=!0,this.grid=t;const o=t.selecting.activeCell;return this.activeCellModel=o,this.activeCell=this.grid.table.getCellByModelIndex(o.c,o.r),this.grid.selector.hide(),mt(this),i&&this.alignWithCell(),this.activate(o),null!==e&&this.setValue(e),Gt(this,this.grid.zoom),this}commit(){this._open&&!this.cancel&&this.activeCellModel&&(this.grid.editing.updateCellValue(this.activeCellModel,this.getValue()),this.grid.rendering.updateCell(this.activeCellModel,!0)),this.cancel=!1}close(){this._open&&(this.deactivate(),vt(this),this.grid.table.renderBodyCell(this.activeCellModel),this.grid.selecting.showSelector(),this.grid.focus(),this._open=!1,this.grid.editing.endEdit()),this.cancel=!1}activate(t){this.activeCellModel=t,this.dispatchEvent(new dx("activate"))}deactivate(){this.dispatchEvent(new dx("deactivate"))}}ux.baseStyles=Gn`
3076
+ `,this.clearHeaderCache=()=>{this.resetFreezeLeft(),this.hCache=new Bw(this.model.columns.length,this.columnHeaderCount),this.hCache.disabled=!this.model.options.cellCache},this.clearBodyCache=()=>{this.bCache=new Bw(this.model.columns.length,this.model.rows.length),this.bCache.disabled=!this.model.options.cellCache},this.cellRenderSchedules=new WeakMap}willUpdate(){this._viewport=null,this._viewportSize=null,this.model&&(this.clearHeaderCache(),this.clearBodyCache())}updated(){this.model&&(this.createColumns(),this.createHeaderRows(),this.createBodyRows(),this.renderCells())}refresh(){this.clearHeaderCache(),this.clearBodyCache(),this.requestUpdate()}createColumns(){this._freezeLeft=null;const t=this.renderColCount;if(!this.cols||this.cols.length!=t){this.cols=new Array(t);for(let e=0;e<t;e++)this.cols[e]=gt("col"),this.cols.forEach((()=>this.colgroup.appendChild(this.cols[e])))}}createHeaderRows(){const t=this.columnHeaderCount,e=this.renderColCount;if(xt(this.thead),!this.hRows||this.hRows.length!=t||!this.hRows[0]||this.hRows[0].children.length!=e){this.hRows=new Array(t);for(let i=0;i<t;i++){this.hRows[i]=gt("tr");for(let t=0;t<e;t++)this.hRows[i].appendChild(gt("th"))}}xt(this.thead),this.hRows.forEach((t=>this.thead.appendChild(t)))}createBodyRows(){const t=this.renderRowCount,e=this.renderColCount,i=this.rowHeaderCount;if(!this.bRows||0==this.bRows.length||this.bRows.length!=t||this.bRows[0].children.length!=e)if(0==t&&this.grid.options.emptyPlaceholder)this.bRows=[gt("tr")],this.bRows[0].appendChild(gt("td"));else{this.bRows=new Array(t);for(let o=0;o<t;o++){this.bRows[o]=gt("tr");for(let t=0;t<i;t++)this.bRows[o].appendChild(gt("th"));for(let t=i;t<e;t++)this.bRows[o].appendChild(gt("td"))}}xt(this.tbody),this.bRows.forEach((t=>this.tbody.appendChild(t)))}renderCells(t={vertical:!0,horizontal:!0}){(t.vertical||t.horizontal)&&(this._viewport=null,this.tbody.remove(),t.horizontal&&this.renderHeader(),this.model.rows.length>0?(this.renderBody(),t.vertical&&this.renderRowTree(),this.table.appendChild(this.tbody)):this.model.options.emptyPlaceholder&&(this.renderEmptyBody(),this.table.appendChild(this.tbody)),this.dispatchEvent(new tx("rendercells")))}renderEmptyBody(){const t=this.bRows[0].children[0];t.innerHTML="no data",t.className="empty-placeholder",t.colSpan=this.viewport.columns.length+this.rowHeaderCount}renderHeader(){let t;this.colMap.clear();const e=this.rowHeaderCount,i=this.viewport;this.model.hasRowTreeEnabled&&Ht(this.colgroup.children[0],{w:this.treeHeaderWidth},!0),this.model.options.rowNumbers&&Ht(this.colgroup.children[e-1],{w:Vw.ROW_HEADER_WIDTH},!0);for(let o=0;o<i.columns.length;o++)t=i.columns[o],this.colMap.set(t.index,o),Ht(this.colgroup.children[o+e],{w:t.width}),At(this.colgroup.children[o+e],{w:t.width}),Tt(this.colgroup.children[o+e],{w:t.width});let o=0;this.model.hasColumnTreeEnabled&&(this.renderHeaderRowTree(this.hRows[o],o),++o),this.model.options.colLetters&&(Ht(this.hRows[o],{h:this.model.options.rowHeight}),this.renderHeaderRowLetters(this.hRows[o],o),++o);for(let t=0;t<this.model.headerCount;t++)this.renderHeaderRowLabels(this.hRows[o+t],o+t,t);o+=this.model.headerCount,this.model.hasFilter&&(Ht(this.hRows[o],{h:this.model.options.rowHeight}),this.renderHeaderRowFilters(this.hRows[o],o))}renderHeaderRowLetters(t,e){let i,o;const n=this.viewport,r=e-this.columnHeaderCount;let s=0;if(Ht(t,{h:this.model.options.rowHeight}),(this.model.hasRowTree||this.model.options.rowNumbers)&&!this.model.hasColumnTree){i=t.children[s],i.colSpan=this.rowHeaderCount,i.rowSpan=this.columnHeaderCount;const e=s-this.rowHeaderCount,o=this.model.options.levelButtonCell;(!o||r==o.r&&e==o.c)&&this.renderHeaderRowCornerCell(i),s++}for(let e=s;e<this.rowHeaderCount;e++)wt(t.children[e]),s++;for(let e=s;e<t.children.length;e++)o=e-s,i=t.children[e],i.className="hlabel",n.columns.length>o?(i.innerHTML=n.columns[o].address,i.c=n.columns[o].index,yt(i)):wt(i)}renderHeaderRowTree(t,e){if(!this.model.hasColumnTreeEnabled)return;let i,o,n=0;const r=e-this.columnHeaderCount,s=this.viewport,a=this.model.options.rowNumbers,l=this.model.hasRowTreeEnabled;if(Ht(t,{h:this.treeHeaderHeight}),i=t.children[n],!i)return;i.rowSpan=a||l?this.columnHeaderCount:1,i.colSpan=this.rowHeaderCount;const c=n-this.rowHeaderCount,h=this.model.options.levelButtonCell;let d=null;(!h&&(a||l)||h&&r==h.r&&c==h.c)&&(d=c,this.renderHeaderRowCornerCell(i)),(a||l)&&(++n,l&&(i=t.children[n],i.innerHTML="",wt(i),++n));for(let r=n;r<t.children.length;r++)o=r-n,i=t.children[r],s.columns.length>o?(d!=r&&(i.innerHTML="",i.className="htree",this.renderHeaderRowTreeCell(t,e,s.columns[o],i)),yt(i)):wt(i)}renderHeaderRowTreeCell(t,e,i,o){let n=this.hCache.get(i.index,e);if(!n){n=gt("div"),this.hCache.set(i.index,e,n);const t=i.width+1,o=this.treeHeaderHeight/this.model.maxColumnLevel;if(i.hasChildren){const e=new Td;e.addEventListener("toggle",(()=>this.grid.rendering.toggleColumn(i.index))),n.expander=e,n.appendChild(e),Ot(e,{l:t/2-Vw.EXPANDER_SIZE/2,t:i.level*o+o/2-Vw.EXPANDER_SIZE/2}),n.expanderLine=this.createExpanderLine("h"),n.appendChild(n.expanderLine),Ot(n.expanderLine,{l:this.model.options.columnTree.reversed?0:t/2,t:i.level*o+o/2}),Ht(n.expanderLine,{h:o/2,w:t/2+1})}if(i.hasParent){let e=i;for(;e.hasParent;){e=e.parent;const i=this.createExpanderLine("h");n.appendChild(i),Ht(i,{h:o/2,w:t-1}),Ot(i,{l:0,t:e.level*o+o/2})}}}n.expander&&(n.expander.state=i.collapsed?"closed":"open"),o.appendChild(n)}createExpanderLine(t){const e=gt("div");return e.className=`${t}tree-line`,e}renderHeaderRowLabels(t,e,i){let o,n,r,s,a=0;const l=this.viewport,c=e-this.columnHeaderCount,h=this.model.options.levelButtonCell;let d;this.model.hasRowTreeEnabled&&(n=t.children[a],n.innerHTML="",this.model.hasColumnTreeEnabled||this.model.options.colLetters||i>0?wt(n):(n.rowSpan=this.columnHeaderCount,n.colSpan=this.rowHeaderCount,this.renderHeaderRowCornerCell(n)),++a),this.model.options.rowNumbers&&(n=t.children[a],n.innerHTML="",this.model.hasRowTreeEnabled||this.model.options.colLetters||this.model.hasColumnTreeEnabled||i>0?wt(n):(n.rowSpan=this.columnHeaderCount,n.colSpan=this.rowHeaderCount,this.renderHeaderRowCornerCell(n)),++a);for(let u=a;u<t.children.length;u++)if(s=u-a,n=t.children[u],n.className="hlabel",n.innerHTML="",l.columns.length>s)if(o=l.columns[s],r=o.header[i],r.height&&(d=Math.max(r.height,d||0)),n.colSpan=1,n.rowSpan=1,n.c=o.index,n.r=i,r?.hidden)if(s==this.freezeLeft){let t=o.prevVisible,r=0;for(;t&&t.header[i]?.hidden;)t=t.prevVisible,++r;t&&t.header[i].cs?(yt(n),n.colSpan=t.header[i].cs-r-1,n.rowSpan=t.header[i].rs||1,this.renderHeaderRowLabelCell(n,t,e,i)):wt(n)}else wt(n);else{if(o.header&&o.header[i]){const t=o.header[i].cs||1;n.colSpan=t>1?o.calculateRealColspan(t):1,n.rowSpan=o.header[i].rs||1}yt(n),this.renderHeaderRowLabelCell(n,o,e,i),h&&h.r==c&&h.c==o.index&&this.renderHeaderRowCornerCell(n)}else wt(n);Ht(t,{h:d??this.model.options.rowHeight})}renderHeaderRowLabelCell(t,e,i,o){let n=this.hCache.get(e.index,i);const r=e.header[o];if(n||(n=gt("div"),r?r.html?n.innerHTML=r.label??"":n.innerText=r.label??"":n.innerHTML="",r&&null!=r._style&&dk(n,jy(this.model.styles.get(r._style))),this.hCache.set(e.index,i,n)),this.model.options.columnHeaderTreeButtons&&e.hasChildren&&o==e.level){let t=n.expander;t||(t=new Td,t.addEventListener("toggle",(()=>this.grid.rendering.toggleColumn(e.index))),n.expander=t,n.prepend(t),Ot(t,{l:4,t:4})),t.state=e.collapsed?"closed":"open"}this.grid.sorting.sortingModel&&e.sorting&&o==e.header.length-1&&(t.className+=" sort",n.sortingArrow||(n.sortingArrow=new Kw,n.appendChild(n.sortingArrow),Ot(n.sortingArrow,{t:0,r:5})),n.sortingArrow.sortSettings=this.grid.sorting.sortingModel.get(e.index)),t.appendChild(n)}renderHeaderRowFilters(t,e){let i,o,n=0;const r=this.viewport;this.model.hasRowTreeEnabled&&(i=t.children[n],i.innerHTML="",this.model.columnHeaderCount>1?wt(i):i.colSpan=this.model.columnHeaderCount,++n),this.model.options.rowNumbers&&(i=t.children[n],i.innerHTML="",this.model.hasRowTreeEnabled||this.model.options.colLetters||this.model.hasColumnTreeEnabled||this.model.headerCount>0?wt(i):(i.rowSpan=this.columnHeaderCount,i.colSpan=this.rowHeaderCount,this.renderHeaderRowCornerCell(i)),++n);for(let s=n;s<t.children.length;s++)if(o=s-n,i=t.children[s],r.columns.length>o){yt(i);const n=r.columns[o];n.hasFilter?this.renderHeaderRowFilterCell(t,e,n,i):i.innerHTML=""}else wt(i)}renderHeaderRowFilterCell(t,e,i,o){o.innerHTML="",o.className="filter",o.c=i.index;let n=this.hCache.get(i.index,e);n||(n=gt("div"),n.filter=gt("og-filter-label"),n.appendChild(n.filter),this.hCache.set(i.index,e,n));const r=this.grid.filtering.filter.get(i.index)?.term;n.filter.value=Array.isArray(r)?r.map((t=>t.value??t.key)).join(", "):r,o.appendChild(n)}renderHeaderRowCornerCell(t){this.cornerDiv=gt("div");const e=Math.max((this.treeHeaderWidth||Vw.EXPANDER_SIZE+2)/(this.model.maxRowLevel+1),Vw.EXPANDER_SIZE+2);if(this.model.hasRowTree)for(let t=0;t<=this.model.maxRowLevel;t++){const i=new Ad;i.level=t,this.cornerDiv.appendChild(i),Ot(i,{l:t*e+e/2-Vw.EXPANDER_SIZE/2,b:3}),i.addEventListener("mousedown",(t=>t.stopPropagation())),i.addEventListener("toggle",(t=>{this.model.columns.filter((t=>t.levelButtons)).forEach((t=>this.bCache.deleteColumn(t.index))),this.grid.rendering.setRowExpandLevel(t.level)}))}if(this.model.hasColumnTree){const i=(this.model.hasColumnTree?this.treeHeaderHeight:t.clientHeight)/(this.model.maxColumnLevel+1),o=15*this.model.maxColumnLevel+20<=t.clientHeight;for(let t=0;t<=this.model.maxColumnLevel;t++){const n=new Ad;n.level=t,this.cornerDiv.appendChild(n),Ot(n,o?{t:t*i+i/2-Vw.EXPANDER_SIZE/2,r:3}:{r:t*e+e/2-Vw.EXPANDER_SIZE/2,b:3}),n.addEventListener("mousedown",(t=>t.stopPropagation())),n.addEventListener("toggle",(t=>{this.grid.rendering.setColumnExpandLevel(t.level)}))}}xt(t),t.appendChild(this.cornerDiv)}renderBody(){let t,e,i,o,n,r,s;const a=this.rowHeaderCount,l=this.model.options.rowNumbers,c=this.viewport,h=[];this.rowMap.clear();for(let d=0;d<this.bRows.length;d++)if(t=this.bRows[d],d<c.rows.length){i=c.rows[d],o=i.index,Ht(t,{h:i.height}),i.height<this.model.options.rowHeight&&(Dt(t,i.height),t.style.lineHeight=It(i.height)),this.rowMap.set(o,d),l&&(e=t.children[a-1],e.className="vlabel",e.r=o,e.c=-1,e.innerHTML=`<div>${tv(o)}</div>`);for(let l=a;l<t.children.length;l++)e=t.children[l],l-a<c.columns.length?(r=c.columns[l-a],n=r.index,e.r=o,e.c=n,e.colSpan=1,e.rowSpan=1,s=i.cell(n),(s.colspan>1||s.rowspan>1)&&h.push({r:d,c:l,cs:s.colspan,rs:s.rowspan}),yt(e),this.renderBodyCell(s,e)):wt(e);t.style.display="table-row",t.className=i.filterState>1?"filtered":""}else t.style.display="none";this.mergeBodyCells(h)}scheduleRenderBodyCell(t,e){this.cellRenderSchedules.has(e)&&(window.clearTimeout(this.cellRenderSchedules.get(e)),this.cellRenderSchedules.delete(e)),this.cellRenderSchedules.set(e,window.setTimeout((()=>this.renderBodyCell(t,e))))}fixCellBorders(t,e){"none"==e.bottom?.style&&(t.style.borderBottomColor="transparent"),"none"==e.top?.style&&(t.style.borderTop="transparent"),"none"==e.right?.style&&(t.style.borderRight="transparent"),"none"==e.left?.style&&(t.style.borderLeft="transparent")}renderBodyCell(t,e){const i=!e;if(e=e||this.getCellByCellModel(t)){let o=i?null:this.bCache.get(t.c,t.r);if(o||(o=gt("div"),xk(t).call(this,o,t),this.bCache.set(t.c,t.r,o)),this.renderAll){const i=t.composedStyle;i&&this.fixCellBorders(e,i)}xt(e),e.appendChild(o)}else this.bCache.delete(t.c,t.r)}mergeBodyCells(t){let e;const i=new Set;for(const o of t)if(e=this.bRows[o.r].cells[o.c],e&&!i.has(e))for(let t=o.r;t<o.r+o.rs;t++)for(let n=o.c;n<o.c+o.cs;n++)e=this.bRows[t].cells[n],e&&(t==o.r&&n==o.c?(e.colSpan=o.cs,e.rowSpan=o.rs):(i.add(e),wt(e)))}renderRowTree(){if(!this.model.hasRowTreeEnabled)return;let t;const e=this.viewport,i=-this.rowHeaderCount;for(let o=0;o<this.bRows.length;o++)t=this.bRows[o].children[0],t.innerHTML="",o<e.rows.length&&(t.className="vtree",this.renderRowTreeCell(i,e.rows[o],t))}renderRowTreeCell(t,e,i){let o=this.bCache.get(t,e.index);if(!o){o=gt("div"),this.bCache.set(t,e.index,o);const n=e.height+1,r=this.treeHeaderWidth/this.model.maxRowLevel;if(e.hasChildren){const t=new Td;t.addEventListener("toggle",(()=>this.grid.rendering.toggleRow(e.index))),i.parentElement.expander=t,o.expander=t,o.appendChild(t),Ot(t,{t:n/2-Vw.EXPANDER_SIZE/2,l:e.level*r+r/2-Vw.EXPANDER_SIZE/2});const s=this.createExpanderLine("v");o.appendChild(s),Ot(s,{t:this.model.options.rowTree.reversed?0:n/2,l:e.level*r+r/2}),Ht(s,{w:r/2,h:n/2+1})}if(e.hasParent){let t=e;for(;t.hasParent;){t=t.parent;const e=this.createExpanderLine("v");o.appendChild(e),Ht(e,{w:r/2,h:n+2}),Ot(e,{t:-1,l:t.level*r+r/2})}}}o.expander&&(o.expander.state=e.collapsed?"closed":"open"),i.appendChild(o)}};ex.styles=[Xw],Jw([is({type:Object})],ex.prototype,"model",void 0),Jw([is({type:Number,hasChanged:()=>!1})],ex.prototype,"rowOffset",void 0),Jw([is({type:Number,hasChanged:()=>!1})],ex.prototype,"colOffset",void 0),Jw([is({type:Number,reflect:!0})],ex.prototype,"zoom",void 0),Jw([is({type:Boolean,reflect:!0})],ex.prototype,"nogrid",void 0),Jw([is({type:Boolean,reflect:!0})],ex.prototype,"renderAll",void 0),ex=Jw([Jr("og-table")],ex);const ix=["F5","F12"];class ox extends Event{get selection(){return this.grid.selecting.selection}get activeCell(){return this.selection.activeCell}constructor(t,e){super(`grid.${t}`,{bubbles:!0,composed:!0}),Object.assign(this,e),this.cell&&(this.row=this.cell.row,this.column=this.cell.column)}}class nx extends ox{constructor(t){super("edit",t)}}class rx extends su{constructor(t,e,i){super(`grid.${t}`,i),this.grid=e}}class sx extends rx{constructor(t,e,i,o){super(t,e,o),this.column=i}}class ax extends rx{constructor(t,e,i,o){super(t,e,o),this.row=i}}class lx{get model(){return this.grid.model}get selection(){return this.grid.selection}get table(){return this.grid.table}constructor(t){this.grid=t,this.clickDisabled=!1,this.editDisabled=!1,this.clicked=!1,this.startOffset={x:0,y:0},this.suspendClick=()=>this.clickDisabled=!0,this.resumeClick=(t=!1)=>{this.isSliding||(t?setTimeout((()=>this.clickDisabled=!1),100):this.clickDisabled=!1)},this._onKeyDown=t=>{switch(ix.includes(t.key)||t.preventDefault(),t.key){case"Tab":t.preventDefault(),this.grid.selecting.shiftActiveCell(t.shiftKey?-1:1,!0);break;case"ArrowRight":this.grid.selecting.debounceMoveSelector(1,0);break;case"ArrowLeft":this.grid.selecting.debounceMoveSelector(-1,0);break;case"ArrowDown":this.grid.selecting.debounceMoveSelector(0,1);break;case"ArrowUp":this.grid.selecting.debounceMoveSelector(0,-1);break;case"PageUp":this.grid.selecting.debounceMoveSelector(0,-this.table.viewport.rows.length);break;case"PageDown":this.grid.selecting.debounceMoveSelector(0,this.table.viewport.rows.length);break;case"Home":this.grid.selecting.debounceMoveSelector(-this.selection.range.c1,t.ctrlKey?-this.selection.range.r1:0);break;case"End":this.grid.selecting.debounceMoveSelector(this.model.gridRange.c2-this.selection.range.c1,t.ctrlKey?this.model.gridRange.r2-this.selection.range.r1:0);break;case"Enter":this.grid.selecting.enter();break;case"Escape":this.grid.selecting.hideCopySelector();break;case"c":t.ctrlKey&&this.grid.editing.copySelection();break;case"v":t.ctrlKey&&this.grid.editing.paste();break;case"z":if(!this.grid.options.undoRedo)return;t.ctrlKey&&this.grid.editing.undo();break;case"y":if(!this.grid.options.undoRedo)return;t.ctrlKey&&this.grid.editing.redo();break;case"F2":t.preventDefault(),this.grid.editing.startEdit();break;case"Delete":t.preventDefault(),this.grid.objects.delete(),this.grid.editing.clearSelection();break;case"Backspace":t.preventDefault(),this.grid.editing.clearSelection()}1!=t.key.length||t.ctrlKey||this.grid.editing.startEdit(t.key)},this._onMouseMove=t=>{let e=!0;const i=this.grid.hSizer,o=this.grid.vSizer,{offsetX:n,offsetY:r}=t;let s=this.model.options.scrolling.scrollbarVisibilityTreshold;s<=0&&(s=Math.max(this.grid.clientWidth,this.grid.clientHeight)),n>this.grid.clientWidth-s?this.grid.vSlider.show():this.grid.vSlider.hide(),r>this.grid.clientHeight-s?this.grid.hSlider.show():this.grid.hSlider.hide();const a=this.table.findNearestTableCellByOffset(n,r);if(a&&"TH"==a.tagName)return this.model.options.columnResize&&!i.resizing&&a.classList.contains("hlabel")?a.offsetWidth-t.offsetX+a.offsetLeft<Vw.RESIZE_TRESHOLD?(i.snap(a,this.grid),this.grid.rendering.currentResizedColumn=this.model.columns[a.c]):vt(i):this.model.options.rowResize&&!o.resizing&&a.classList.contains("vlabel")&&(a.offsetHeight-t.offsetY+a.offsetTop<Vw.RESIZE_TRESHOLD?(o.snap(a,this.grid),this.grid.rendering.currentResizedRow=this.model.rows[a.r]):vt(o)),void(this.grid.selecting.isSelecting&&(this.suspendClick(),this.grid.selecting.updateSelecting(a.c,a.r)));if(a&&"TD"==a.tagName)if(this.grid.selecting.isSelectorOperationActive||this.grid.selecting.isFormulaSelectorOperationActive){const{top:e,left:i}=Et(a,this.grid);this.grid.rendering.autoscroll({x:i-this.table.totalHeaderWidth+t.offsetX-a.offsetLeft,y:e-this.table.thead.clientHeight+t.offsetY-a.offsetTop}),this.grid.selecting.isSelecting&&this.suspendClick(),this.grid.selecting.updateSelecting(a.c,a.r)}else{const t=this.model.rows[a.r]?.cell(a.c);t&&t.hasTooltip&&(e=!1,this.grid.tooltip.attachToCell(a,t)),t&&t.hasComment&&(e=!1,this.grid.comment.attachTo(a,t))}e&&(this.grid.tooltip.deatach(),this.grid.comment.deatach(this.model.options.comments.hideTimeout)),vt(i),vt(o)},this._onMouseDown=t=>{if(1&t.buttons){this.grid.setPointerCapture(t.pointerId),this.startOffset={x:t.offsetX,y:t.offsetY};for(const e of t.composedPath()){if("TD"==e.tagName){const t=e;this.grid.selecting.startCellSelecting(new Jm(t.c,t.r));break}if("TH"==e.tagName){const t=e;e.matches(".sort")?this.grid.sorting.sort(t.c):t.classList.contains("filter")?this.grid.filtering.openFilter(this.model.columns[t.c],t):t.classList.contains("hlabel")?this.grid.selecting.startColumnSelecting(t.c):t.classList.contains("vlabel")&&this.grid.selecting.startRowSelecting(t.r);break}}}},this._onMouseUp=t=>{if(0!=t.buttons)return;const e=Math.abs(this.startOffset.x-t.offsetX),i=Math.abs(this.startOffset.y-t.offsetY);Math.sqrt(Math.pow(e,2)+Math.pow(i,2))<this.model.options.events.click.mouseMoveTreshold&&this.resumeClick(),this.grid.releasePointerCapture(t.pointerId),this.grid.selecting.stopSelectOperations()},this._onClick=t=>{if(this.clickDisabled)return;if(this.grid.clientHeight-t.offsetY<this.grid.hSlider.offsetHeight)return;if(this.grid.clientWidth-t.offsetX<this.grid.vSlider.offsetWidth)return;const e=this.table.findTableCellByOffset(t.offsetX,t.offsetY),i="TD"==e?.tagName?this.model.rows[e.r]?.cell(e.c):null;this.grid.dispatchEvent(new ox("click",{grid:this.grid,cell:i}))},this._onContextMenu=t=>{t.preventDefault();for(const e of t.composedPath())if("TD"==e.tagName){const i=e;this.grid.menus.openCellMenu(this.model.rows[i.r].cell(i.c),{x:t.pageX,y:t.pageY})}else if("TH"==e.tagName){const i=e;i.classList.contains("hlabel")?this.grid.menus.openColumnMenu(this.model.columns[i.c],{x:t.pageX,y:t.pageY}):i.classList.contains("vlabel")&&this.grid.menus.openRowMenu(this.model.rows[i.r],{x:t.pageX,y:t.pageY})}},this._onVerticalSlide=t=>{this.table.rowOffset=Math.min(t.value,this.model.visibleRows.length-1),this.grid.rendering.requireVerticalUpdate=!0,this.grid.logger.info(`v-slide: ${t.value}`),this.grid.rendering.renderCells()},this._onHorizontalSlide=t=>{this.table.colOffset=Math.min(t.value,this.model.visibleColumns.length-1),this.grid.rendering.requireHorizontalUpdate=!0,this.grid.logger.info(`h-slide: ${t.value}`),this.grid.rendering.renderCells()},this._onSlideStart=()=>{this.suspendClick()},this._onSlideStop=()=>{this.resumeClick(!0)},this._denbounceHorizontalScroll=U((t=>this.grid.rendering.scrollHorizontalByPixels(t)),50),this._onWheel=t=>{t.ctrlKey||(0!=t.deltaY&&this.grid.rendering.scrollVerticalByPixels(t.deltaY),0!=t.deltaX&&this._denbounceHorizontalScroll(Math.sign(t.deltaX)*Math.min(100,Math.abs(t.deltaX))))},this._onTouchStart=t=>{this.grid.rendering.touchStartX=t.touches[0],this.grid.rendering.touchStartY=t.touches[0]},this._onTouchEnd=t=>{this.grid.rendering.touchStartX=t.touches[0],this.grid.rendering.touchStartY=t.touches[0]},this._onTouchMove=t=>{const e=this.grid.rendering;if(e.touchStartY){const i=e.touchStartY.clientY-t.touches[0].clientY;Math.abs(i)>this.model.options.rowHeight&&this.table.viewport.rows.length>0&&(e.scrollVerticalByPixels(i),e.touchStartY=t.touches[0])}if(e.touchStartX){const i=e.touchStartX.clientX-t.touches[0].clientX;Math.abs(i)>this.model.options.columnWidth&&this.table.viewport.columns.length>0&&(e.scrollHorizontalByPixels(i),e.touchStartX=t.touches[0])}},this._onHorizontalResizeStart=()=>{this.grid.rendering.resizing=!0,this.grid.rendering.currentResizedColumnWidth=this.grid.rendering.currentResizedColumn.width},this._onHorizontalResizeStop=t=>{this.suspendClick(),this.grid.rendering.resizing=!1,this.table.clearHeaderCache(),this.table.renderCells({horizontal:!0}),this.grid.dispatchEvent(new sx("column.resize",this.grid,this.grid.rendering.currentResizedColumn,t))},this._onHorizontalResize=t=>{const e=this.grid.rendering;e.currentResizedColumn.width=e.currentResizedColumnWidth+t.deltaX,Ht(this.table.getColumnByModelIndex(e.currentResizedColumn.index),{w:e.currentResizedColumn.width},!0),this.grid.selecting.updateSelector()},this._onVerticalResizeStart=()=>{this.grid.rendering.resizing=!0,this.grid.rendering.currentResizedRowHeight=this.grid.rendering.currentResizedRow.height},this._onVerticalResizeStop=t=>{this.suspendClick(),this.grid.rendering.resizing=!1,this.table.clearBodyCache(),this.table.renderCells({vertical:!0}),this.grid.dispatchEvent(new ax("row.resize",this.grid,this.grid.rendering.currentResizedRow,t))},this._onVerticalResize=t=>{const e=this.grid.rendering;e.currentResizedRow.height=e.currentResizedRowHeight+t.deltaY,Ht(this.table.getRowByModelIndex(e.currentResizedRow.index),{h:e.currentResizedRow.height},!1),this.grid.selecting.updateSelector()},this._onCommentCommit=t=>{this.grid.model.comments.set(t.cell.address,t.items),t.cell.invalidateStyle(),this.grid.rendering.updateCells([t.cell])},this._onAutofill=t=>{if(this.suspendClick(),this.grid.selection.range.equals(t.selector.autofillRange))return;const{cells:e,oldValues:i}=Ly(this.model,this.grid.selection.range,t.selector.autofillRange,t.selector.autofillDirection);this.grid.rendering.updateCells(e,!0),this.grid.selection.setRange(this.grid.selection.range.unite(t.selector.autofillRange)),this.grid.selecting.updateSelector(),this.grid.dispatchEvent(new nx({grid:this.grid,editType:"autofill",cells:e,oldValues:i,newValues:e.map((t=>t.value2))}))},this._onEdit=t=>{if(t.fromHistory)return;const e=[],i=[],o=this.model.names.rangeMap;let n=[],r=[],s=[],a=[];switch(t.editType){case"value":n=t.newValues,r=t.newProps,s=t.oldValues,a=t.oldProps,t.cells.forEach((t=>{const n=t.address;e.push(n),i.push(o.get(n))}));break;case"insert_column":case"insert_row":t.newValues.forEach((t=>{const r=t.address;e.push(r),i.push(o.get(r)),n.push(t.getSourceData())}))}this.grid.history.push({type:t.editType,addresses:e,names:i,oldValues:s,oldProps:a,newValues:n,newProps:r})},this._onSelectorMove=t=>{this.suspendClick(),this.selection.setRange(t.toRange),t.fromRange.isRow?this.grid.editing.moveRows({index:t.fromRange.r1,count:t.fromRange.size.rows,targetIndex:t.toRange.r1}):t.fromRange.isColumn?this.grid.editing.moveColumns({index:t.fromRange.c1,count:t.fromRange.size.columns,targetIndex:t.toRange.c1}):console.log(t)},this._onMouseLeave=()=>{this.grid.rendering.hideSliders()},this.debounceHideSliders=U((()=>this.grid.rendering.hideSliders()),1e3,{isImmediate:!1}),this._onRender=()=>{const t=this.grid;t.selecting.updateSelectors(),t.dispatchEvent(new ox("render",{grid:this.grid})),t.adapter&&t.options.pageSize&&t.rendering.isLastRowInViewport()&&t.rendering.loadNextPage(),t.rendering.updateSliderVisibility(),this.model.options.scrolling.scrollbarVisibilityTreshold>0&&this.debounceHideSliders()},this._onHorizontalSizerDblClick=t=>{t.stopPropagation(),this.editDisabled=!0,this.grid.rendering.autofitColumn(this.grid.rendering.currentResizedColumn.index),this.grid.dispatchEvent(new sx("column.resize",this.grid,this.grid.rendering.currentResizedColumn,t))},this._onDblClick=()=>{this.editDisabled?this.editDisabled=!1:this.grid.editing.startEdit()}}get isSliding(){return this.grid.hSlider.sliding||this.grid.vSlider.sliding}async init(){await this.grid.updateComplete,await this.table.updateComplete;const t=this.grid;t.addEventListener("wheel",this._onWheel,{passive:!0}),t.addEventListener("touchstart",this._onTouchStart,{passive:!0}),t.addEventListener("touchend",this._onTouchEnd,{passive:!0}),t.addEventListener("touchmove",this._onTouchMove,{passive:!0}),t.hSizer.addEventListener("resizestart",this._onHorizontalResizeStart),t.hSizer.addEventListener("resizestop",this._onHorizontalResizeStop),t.hSizer.addEventListener("resize",this._onHorizontalResize),t.hSizer.addEventListener("dblclick",this._onHorizontalSizerDblClick),t.vSizer.addEventListener("resizestart",this._onVerticalResizeStart),t.vSizer.addEventListener("resizestop",this._onVerticalResizeStop),t.vSizer.addEventListener("resize",this._onVerticalResize),t.comment.addEventListener("comment.commit",this._onCommentCommit),t.addEventListener("keydown",this._onKeyDown),t.addEventListener("click",this._onClick),t.addEventListener("contextmenu",this._onContextMenu),t.addEventListener("toggle",(()=>t.rendering.debounceCalculateViewport())),t.addEventListener("pointerup",this._onMouseUp),t.addEventListener("pointerdown",this._onMouseDown);const e=U(this._onMouseMove,20,{maxWait:50,isImmediate:!0});t.addEventListener("pointermove",e),t.addEventListener("mouseleave",this._onMouseLeave),t.table.addEventListener("rendercells",this._onRender),t.selector.addEventListener("grid.selector.autofill",this._onAutofill),t.selector.addEventListener("grid.selector.move",this._onSelectorMove),t.addEventListener("dblclick",this._onDblClick),t.addEventListener("grid.edit",this._onEdit)}}class cx{get vScrolling(){return this._vScrolling}get hScrolling(){return this._hScrolling}get model(){return this.grid.model}get selection(){return this.grid.selection}get table(){return this.grid.table}constructor(t){this.grid=t,this.requireVerticalUpdate=!0,this.requireHorizontalUpdate=!1,this.resizing=!1,this._vScrolling=!0,this._hScrolling=!0,this.debounceRenderCells=U(this.renderCells,50,{isImmediate:!1,maxWait:100}),this.debounceCalculateViewport=U(this.calculateViewport,200)}isLastRowInViewport(){const t=this.grid.table.viewport.rows,e=this.model.visibleRows;return t[t.length-1]==e[e.length-1]}renderCells(t){t=t||{vertical:this.requireVerticalUpdate,horizontal:this.requireHorizontalUpdate},this.grid.comment.deatach(),this.grid.table.renderCells(t),this.requireHorizontalUpdate=!1,this.requireVerticalUpdate=!1,this.debounceCalculateViewport(),this.grid.objects.updatePostions()}renderAll(t=!1){this.grid.group?this.grid.group.grids.forEach((e=>e.rendering.render(t))):this.render(t)}async render(t=!1){this.grid.table&&this.model&&(this.grid.table.clearHeaderCache(),this.grid.table.clearBodyCache(),this.grid.table.isConnected&&(t&&(this.grid.table.requestUpdate(),await this.grid.table.updateComplete),this.grid.table.renderCells({horizontal:!0,vertical:!0}),this.calculateViewport()))}updateRange(t,e=!1){for(const i of this.model.getRangeIterator(t))this.updateCells([i],e)}updateCell(t,e=!1){this.updateCells([t],e)}updateSpilledCells(t){let e;t.prevSpillRange&&(e=new Set,this.model.getRangeIterator(t.prevSpillRange).forEach((t=>e.add(t)))),t.spillRange&&(e=e||new Set,this.model.getRangeIterator(t.spillRange).forEach((t=>e.add(t)))),e?.size>0&&this.updateCells(e)}updateCells(t,e=!1){if(e)for(const e of t)e.invalidateStyle(),e.invalidateValue(),this.model.calculations.clearDependecies(e).evaluate(e),this.updateSpilledCells(e);const i=this.grid.table;for(const e of t)i.renderBodyCell(e);e&&(this.model.calculations.invalidateDependants(t).forEach(((t,e)=>{t?this.grid.group.getGrid(t)?.table.renderBodyCell(e):i.renderBodyCell(e),this.updateSpilledCells(e)})),this.grid.dispatchGridEvent("calculate",{cells:Array.from(t)}))}updateHeaders(){this.model.indexVisibleColumns(),this.table.clearHeaderCache(),this.table.createHeaderRows(),this.table.renderHeader()}calculateViewport(t=!1){this.grid.logger.info("calculate viwport"),this.updateCells(this.model.calculateViewport(),t)}updateSliders(){const t=this.table.viewportSize;this.grid.vSlider.maxValue=this.model.visibleRows.length,this.grid.vSlider.pageSize=t.h/this.model.options.rowHeight,this.grid.vSlider.value=this.table.rowOffset,this.grid.hSlider.maxValue=this.model.visibleColumns.length,this.grid.hSlider.pageSize=t.w/this.model.options.columnWidth,this.grid.hSlider.value=this.table.colOffset}isVerticalScrollingEnabled(){return!1!==this.grid.options.scrolling.verticalOverscroll||this.table.viewport.rows.length<this.model.visibleRows.length}isHorizontalScrollingEnabled(){return!1!==this.grid.options.scrolling.horizontalOverscroll||this.table.viewport.columns.length<this.model.visibleColumns.length}updateSliderVisibility(){this._vScrolling=this.isVerticalScrollingEnabled(),this._vScrolling?(this.grid.vSlider.show(),mt(this.grid.vSlider)):(this.grid.vSlider.hide(),vt(this.grid.vSlider)),this._hScrolling=this.isHorizontalScrollingEnabled(),this._hScrolling?(this.grid.hSlider.show(),mt(this.grid.hSlider)):(this.grid.hSlider.hide(),vt(this.grid.hSlider))}hideSliders(){this.grid.vSlider.hide(),this.grid.hSlider.hide()}scrollVerticalByPixels(t){if(!this.vScrolling)return;let e,i=this.table.rowOffset,o=0,n=0;if(t>0){for(;o<t&&i+n<this.model.visibleRows.length;)o+=this.model.visibleRows[i+n++].height+2;i+=n}else if(t<0){for(t=Math.abs(t);o<t&&i+n>=0;)e=this.model.visibleRows[Math.min(this.model.visibleRows.length-1,i+n--)],o+=(e?e.height:0)+2;i+=n}i>=this.model.visibleRows.length&&(i=this.model.visibleRows.length-1),this.requireVerticalUpdate=!0,this.table.rowOffset=Math.max(0,i),this.debounceRenderCells(),this.updateSliders()}scrollHorizontalByPixels(t){if(!this.hScrolling)return;let e=this.table.colOffset,i=0,o=0;if(t>0){for(;i<t&&e+o<this.model.visibleColumns.length;)i+=this.model.visibleColumns[e+o++].width+2;e+=o}else if(t<0){for(t=Math.abs(t);i<t&&e+o>=0;)i+=this.model.visibleColumns[Math.min(this.model.visibleColumns.length-1,e+o--)].width+2;e+=o}e>=this.model.visibleColumns.length&&(e=this.model.visibleColumns.length-1),this.requireHorizontalUpdate=!0,this.table.colOffset=Math.max(0,e),this.debounceRenderCells(),this.updateSliders()}updateCellSelectionRange(){const t=this.table;for(const e of this.model.getRangeIterator(this.selection.range,!1))t.renderBodyCell(e)}getAdapterRequestFilters(){return{offset:0,filter:this.grid.filtering?.filter?Array.from(this.grid.filtering.filter.settings.values()):null,order:this.grid.sorting?.sortingModel?.settings}}async toggleRow(t,e=!0){const i=this.model.rows[t];if(i.isLoaded||i.isPartialyLoaded)i.toggleCollapse(!1,this.model.options.unhideRowAfterExpand),this.table.renderCells({vertical:!0});else if(this.grid.adapter){const e=this.table.getRowByModelIndex(t);e&&e.expander&&(e.expander.state="waiting"),i.collapsed=!1;const[o]=await Promise.all([this.grid.adapter.getRows(Object.assign(this.getAdapterRequestFilters(),{parent:{r:i.index,props:i.properties}}))]);this.model.insertRowData(i,0,o),this.table.requestUpdate()}this.updateSliders(),e&&this.grid.dispatchEvent(new ox("row.toggle",{grid:this.grid,row:i}))}toggleColumn(t,e=!0){const i=this.model.columns[t];i.toggleCollapse(!1,this.model.options.unhideColumnAfterExpand),this.table.renderCells({horizontal:!0}),this.updateSliders(),e&&this.grid.dispatchEvent(new ox("column.toggle",{grid:this.grid,column:i}))}setRowExpandLevel(t){this.model.setRowExpandLevel(t),this.table.rowOffset=0,this.table.renderCells({vertical:!0}),this.updateSliders(),this.grid.dispatchEvent(new ox("row.toggle",{grid:this.grid}))}setColumnExpandLevel(t){this.model.setColumnExpandLevel(t),this.table.colOffset=0,this.table.renderCells({horizontal:!0}),this.updateSliders(),this.grid.dispatchEvent(new ox("column.toggle",{grid:this.grid}))}async exportHTML(){const t=gt("div");vt(t),document.body.appendChild(t);const e=gt("og-table");e.grid=this.grid,e.model=this.model,e.renderAll=!0,t.appendChild(e),await e.updateComplete;const i=`\n\t\t\t<style>\n\t\t\t\thtml {\n\t\t\t\t\t${ea(ca().themes.get("light")).cssText}\n\t\t\t\t}\n\t\t\t\t${ex.styles.map((t=>t.cssText)).join("\n")}\n\t\t\t</style>\n\n\t\t`,o=i+e.shadowRoot.innerHTML.replace(/<!---->/g,"");return t.remove(),o}stopAutoscroll(){this.autoscrollTimer&&window.clearInterval(this.autoscrollTimer)}startAutoscroll(){this.stopAutoscroll(),this.autoscrollTimer=window.setInterval((()=>{if(0==this.autoscrollValue)return this.stopAutoscroll();const t=Math.pow(this.autoscrollValue,Hm.AUTOSCROLL_RATIO);switch(this.autoscrollDirection){case"down":this.scrollVerticalByPixels(t);break;case"up":this.scrollVerticalByPixels(-t);break;case"left":this.scrollHorizontalByPixels(-t);break;case"right":this.scrollHorizontalByPixels(t)}}),Hm.AUTOSCROLL_INTERVAL)}autoscroll(t){const{x:e,y:i}=t,o=this.table.clientWidth/this.table.zoom-this.table.totalHeaderWidth,n=this.table.clientHeight/this.table.zoom-this.table.totalHeaderHeight;let r,s=0;e<Hm.AUTOSCROLL_TRESHOLD&&e<i&&e<n-i?(r="left",s=Hm.AUTOSCROLL_TRESHOLD-e):o-e<Hm.AUTOSCROLL_TRESHOLD&&o-e<i&&o-e<n-i?(r="right",s=Hm.AUTOSCROLL_TRESHOLD-o+e):i<Hm.AUTOSCROLL_TRESHOLD?(r="up",s=Hm.AUTOSCROLL_TRESHOLD-i):n-i<Hm.AUTOSCROLL_TRESHOLD&&(r="down",s=Hm.AUTOSCROLL_TRESHOLD-n+i),this.autoscrollDirection=r,this.autoscrollValue=s,this.stopAutoscroll(),s>0&&this.startAutoscroll()}async loadNextPage(t=null,e=!1){if(this.grid.loading)return;const i=null!=t?this.model.rows[t]:this.model.rowRoot;if(!e&&i.isLoaded)return;this.grid.dispatchEvent(new ox("beforeLoad",{grid:this.grid})),this.grid.loading=!0;const o=this.model.rows.length;this.grid.logger.info(`loading rows offset = ${o}`);const[n]=await Promise.all([this.grid.adapter.getRows(Object.assign(this.getAdapterRequestFilters(),{offset:o,parent:{r:t,props:null}}))]);n.length>0&&null===t&&this.model.insertRowData(i,o,n),this.table.requestUpdate(),n.length>=this.model.options.pageSize?i.count=1/0:i.count=i.children.length,this.grid.logger.info(`loaded ${n.length} rows`),this.grid.loading=!1,this.grid.dispatchEvent(new ox("afterLoad",{grid:this.grid}))}get totalSize(){return{width:this.table.totalHeaderWidth+this.model.visibleColumns.reduce(((t,e)=>t+e.width),0),height:this.table.thead.offsetHeight+this.model.visibleRows.reduce(((t,e)=>t+e.height),0)}}autofitColumn(t,e=!1){const i="number"==typeof t?this.model.columns[t]:t,o=this.autofitDiv??(this.autofitDiv=gt("div"));o.style.position="absolute",o.style.zIndex="100000",Ot(o,{l:-1e3,t:-1e3}),this.grid.shadowRoot.appendChild(o);let n=0;for(const t of this.model.getRangeIterator(Jm.fromA1(i.address),!!e)){const e=xk(t).call(this.table,o,t)||o;e.style.width="auto",n=Math.max(n,e.offsetWidth)}i.width=n+10,this.table.renderCells({horizontal:!0})}autofitColumns(t=!1){this.model.columns.forEach((e=>this.autofitColumn(e,t)))}scrollTo(t,e=0){let i;i=Z(t)?Jm.fromA1(t):new Jm(e,t),this.table.rowOffset=i.r1,this.table.colOffset=i.c1,this.requireVerticalUpdate=!0,this.requireHorizontalUpdate=!0,this.debounceRenderCells(),this.updateSliders()}}class hx{get model(){return this.grid.model}get selection(){return this.grid.editing.isFormulaMode?this.formulaSelection:this.grid.selection}get selector(){return this.grid.editing.isFormulaMode?this.grid.formulaSelector:this.grid.selector}get formulaSelection(){return this._formulaSelection}get events(){return this.grid.events}get table(){return this.grid.table}get isSelecting(){return this.isCellSelecting||this.columnSelecting||this.rowSelecting}get isCellSelecting(){return this.selector.isSelecting}get isAutofilling(){return this.selector.isAutofilling}get isMoving(){return this.selector.isMoving}get isSelectorOperationActive(){return this.selector.isSelectorOperationActive}get isFormulaSelectorOperationActive(){if(!this.grid.editing.isFormulaMode)return!1;for(const t of this.formulaSelectors.values())if(t.isSelectorOperationActive)return!0;return!1}get activeCell(){const{c:t,r:e}=this.selection.activeCellCoords;return this.model.rows[e]?.cell(t)}constructor(t){this.grid=t,this.columnSelecting=!1,this.rowSelecting=!1,this._formulaSelection=new jw(0,0,0,0),this.formulaSelectors=new Map,this.debounceMoveSelector=U(((t,e)=>this.moveSelector(t,e)),10)}moveToSelection(){const t=new Jm(this.selection.range.c1,this.selection.range.r1);this.table.viewportRange.contains(t)}select(t,e=!1){this.selection.setRange(t),this.updateSelector(),e&&this.grid.dispatchEvent(new ox("select",{grid:this.grid}))}startCellSelecting(t){this.grid.style.cursor="cell",this.startSelectingRange=t.clone(),this.select(t,!0),this.selector.startSelecting(t)}startColumnSelecting(t){this.columnSelecting=!0;const e=new Jm(t,null,t,null);this.startSelectingRange=e.clone(),this.select(e,!0)}startRowSelecting(t){this.rowSelecting=!0;const e=new Jm(null,t,null,t);this.startSelectingRange=e.clone(),this.select(e,!0)}updateSelecting(t,e){const i=this.model.options.selecting.multiSelect;(this.isCellSelecting||this.rowSelecting)&&(i||(this.selection.range.r1=e),this.selection.range.r2=e),(this.isCellSelecting||this.columnSelecting)&&(i||(this.selection.range.c1=t),this.selection.range.c2=t),this.grid.editing.isFormulaMode?(this.updateFormulaSelector(),this.formulaSelectors.forEach((i=>i.updateMovingOperations(t,e)))):(this.updateSelector(),this.hideFormulaSelector(),this.selector.updateMovingOperations(t,e))}stopSelecting(){this.grid.rendering.stopAutoscroll(),this.isSelecting&&!this.selection.range.equals(this.startSelectingRange)&&this.grid.dispatchEvent(new ox("select",{grid:this.grid})),this.columnSelecting=!1,this.rowSelecting=!1,this.startSelectingRange=null,this.selector.stopSelectorOperations()}highlightSelection(){const t=this.selection.range,[e,i]=[Math.min(t.c1,t.c2),Math.max(t.c1,t.c2)],[o,n]=[Math.min(t.r1,t.r2),Math.max(t.r1,t.r2)],r=i-e+1,s=n-o+1;this.table.highlightColHeaderCells(r<1/0?Array.from(new Array(r),((t,i)=>i+e)):[]),this.table.highlightRowHeaderCells(s<1/0?Array.from(new Array(s),((t,e)=>e+o)):[])}updateSelector(t=!0){this.model.options.selecting.enabled?(this.showSelector(t),this.highlightSelection()):this.hideSelector(),this.grid.editing.isFormulaMode||this.grid.editing.endEdit()}showSelector(t=!0){this.selector&&(this.selector.show(),this.selector.select(this.selection.range,t))}hideSelector(){this.selector.hide()}moveSelector(t,e){if(this.selection.move(t,e,this.model.columns.length,this.model.rows.length),0!=e&&!this.model.rows[this.selection.range.r1].visible){const t=e>0?this.model.rows[this.selection.range.r1].nextVisible:this.model.rows[this.selection.range.r1].prevVisible;t&&(this.selection.range.r1=t.index,this.selection.range.r2=t.index)}if(0!=t&&!this.model.columns[this.selection.range.c1].visible){const e=t>0?this.model.columns[this.selection.range.c1].nextVisible:this.model.columns[this.selection.range.c1].prevVisible;e&&(this.selection.range.c1=e.index,this.selection.range.c2=e.index)}this.selector.selection=this.selection.range,this.selector.updatePosition();const i={c:0,r:0};(e>0&&this.selector.offsetTop+this.selector.offsetHeight>this.grid.clientHeight||e<0&&this.selector.offsetTop<this.table.totalHeaderHeight-1||e>=this.table.viewport.rows.length)&&(i.r+=e),(t>0&&this.selector.offsetLeft+this.selector.offsetWidth>this.grid.clientWidth||t<0&&this.selector.offsetLeft<this.table.totalHeaderWidth-1)&&(i.c+=t),0==i.c&&0==i.r||(this.table.colOffset=Math.max(0,this.table.colOffset+i.c),this.table.rowOffset=Math.min(Math.max(0,this.table.rowOffset+i.r),this.model.visibleRows.length-1),this.table.renderCells({horizontal:0!=i.c,vertical:0!=i.r}),this.grid.rendering.updateSliders()),this.grid.editing.isFormulaMode||this.grid.editing.endEdit(),this.highlightSelection(),this.grid.dispatchEvent(new ox("select",{grid:this.grid}))}shiftActiveCell(t,e=!1){this.selection.moveActiveCell(t,0),this.selector.updatePosition(),e&&this.grid.dispatchEvent(new ox("select",{grid:this.grid}))}updateFormulaSelector(t=!0){this.grid.editing.isFormulaMode?this.showFormulaSelector(t):this.hideFormulaSelector()}showFormulaSelector(t=!0){this.grid.formulaSelector.show(),this.grid.formulaSelector?.select(this.formulaSelection.range,t)}hideFormulaSelector(){this.grid.formulaSelector.hide()}updateFormulaSelectors(){this.formulaSelectors.forEach((t=>t.updatePosition()))}highlightColorItem(t){const e=jw.fromRange(Jm.fromA1(t.address)),i=gt("og-selector");this.grid.shadowRoot.appendChild(i),i.addEventListener("grid.selector.move",(t=>this.select(t.selector.selection.clone()))),i.addEventListener("grid.selector.resize",(t=>this.select(t.selector.selection.clone()))),i.grid=this.grid,i.color=t.color,i.subselector=!1,i.movable=!0,i.resizable=!0,i.index=t.tokenIndex,this.formulaSelectors.set(t.tokenIndex,i),i.select(e.range.clone(),!1),i.show()}highlightFormula(t){this.removeFormulaHighlight(),this.formulaSelectors.clear();const e=new Set;t.colors.forEach((t=>{if(null==t.sheet||t.sheet==this.model.name)this.highlightColorItem(t);else if(this.grid.group){const i=this.grid.group.getGrid(t.sheet);if(!i)return;e.has(i)||(e.add(i),i.selecting.removeFormulaHighlight()),i.isConnected&&i.selecting.highlightColorItem(t)}}))}removeFormulaHighlight(){this.formulaSelectors?.forEach((t=>kt(t))),this.formulaSelectors.clear()}updateCopySelector(){this.grid.copySelector.isVisible&&this.grid.copySelector.updatePosition()}showCopySelector(){this.grid.copySelector.show(),this.grid.copySelector?.select(this.selection.range.clone(),!1)}hideCopySelector(){this.grid.copySelector.hide()}mergeSelection(){const t=this.selection.range,e=this.model.rows[t.r1]?.cell(t.c1);e&&(e.rowspan=t.size.rows,e.colspan=t.size.columns,this.grid.rendering.renderCells({vertical:!0,horizontal:!0}))}unmergeSelection(){const t=this.selection.range,e=this.model.rows[t.r1]?.cell(t.c1);e&&(e.rowspan=1,e.colspan=1,this.grid.rendering.renderCells({vertical:!0,horizontal:!0}))}updateSelectors(){this.updateSelector(!1),this.updateCopySelector(),this.updateFormulaSelectors()}stopSelectOperations(){this.stopSelecting(),this.formulaSelectors.forEach((t=>t.stopSelectorOperations())),this.grid.style.removeProperty("cursor")}enter(){const t=this.grid.group;if(this.grid.editing.isFormulaMode&&t){const e=t.formulaModeGrid;e.editing.commitEdit(),t.activateGrid(e.model.name)}else this.debounceMoveSelector(0,1)}}class dx extends Event{}class ux extends Qr{constructor(){super(),this.cancel=!1,this._open=!1,this.init()}getDisplayValue(){return null}init(){this.addEventListener("keydown",(t=>{"Enter"==t.key?this.close():"Escape"==t.key?(this.cancel=!0,this.close()):t.stopPropagation()}))}connectedCallback(){super.connectedCallback(),this.performUpdate()}alignWithCell(){if(!this.activeCell)return;const t=Et(this.activeCell,this.grid);Ot(this,{t:t.top*this.grid.zoom,l:t.left*this.grid.zoom}),Ht(this,{w:this.activeCell.offsetWidth,h:this.activeCell.offsetHeight})}open(t,e=null,i=!0){this.initialValue=e,this._open=!0,this.grid=t;const o=t.selecting.activeCell;return this.activeCellModel=o,this.activeCell=this.grid.table.getCellByModelIndex(o.c,o.r),this.grid.selector.hide(),mt(this),i&&this.alignWithCell(),this.activate(o),null!==e&&this.setValue(e),Gt(this,this.grid.zoom),this}commit(){this._open&&!this.cancel&&this.activeCellModel&&(this.grid.editing.updateCell(this.activeCellModel,{v:this.getValue(),dv:this.getDisplayValue()}),this.grid.rendering.updateCell(this.activeCellModel,!0)),this.cancel=!1}close(){this._open&&(this.deactivate(),vt(this),this.grid.table.renderBodyCell(this.activeCellModel),this.grid.selecting.showSelector(),this.grid.focus(),this._open=!1,this.grid.editing.endEdit()),this.cancel=!1}activate(t){this.activeCellModel=t,this.dispatchEvent(new dx("activate"))}deactivate(){this.dispatchEvent(new dx("deactivate"))}}ux.baseStyles=Gn`
3077
3077
  * { box-sizing: border-box }
3078
3078
 
3079
3079
  :host {
@@ -3101,7 +3101,7 @@
3101
3101
  font-size: var(--og-font-size);
3102
3102
  box-sizing: border-box;
3103
3103
  }
3104
- `],fx=gx=function(t,e,i,o){var n,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(r<3?n(s):r>3?n(e,i,s):n(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s}([Jr("og-grid-texteditor")],fx);let mx=class extends fx{validate(t){return t=t.replace(",","."),dv(t)||!isNaN(Number(t))||"-"==t}_onKey(t){1===t.key.length&&(this.validate(this.input.value+t.key)||t.preventDefault())}setValue(t){this.input.value=this.validate(t)?t:""}firstUpdated(){this.input.addEventListener("keydown",(t=>this._onKey(t))),this.input.addEventListener("keypress",(t=>this._onKey(t)))}getValue(){return""===this.input.value?null:this.input.value.replace(",",".")}};mx=function(t,e,i,o){var n,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(r<3?n(s):r>3?n(e,i,s):n(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s}([Jr("og-grid-numbereditor")],mx);var vx=function(t,e,i,o){var n,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(r<3?n(s):r>3?n(e,i,s):n(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s};let bx=class extends ux{constructor(){super(),this._onChange=t=>{if("s"==this.activeCellModel.type){this.currentValue=null,this.currentDisplayValue=null;for(const[t,e]of this.dropdown.selectedItems){this.currentValue=t,this.currentDisplayValue=e.value;break}}else this.currentValue=this.dropdown.selection.serialize(),this.currentDisplayValue=this.dropdown.getSelectionText();this.activeCellModel.displayValue=this.currentDisplayValue,this.commit(),"s"==this.activeCellModel.type&&(this.dropdown.close(),this.close())},this.render=()=>Ir`<og-tree-dropdown @change="${this._onChange}" buttonInput cross></og-tree-dropdown>`}init(){this.addEventListener("keydown",(t=>{if("Enter"==t.key){if(null==this.dropdown?.input.value)return;if(!this.activeCellModel?.allowInvalid)return;this.currentValue=this.dropdown.input.value,this.currentDisplayValue=this.dropdown.input.value,this.activeCellModel.displayValue=this.currentDisplayValue,this.commit()}})),super.init()}async activate(t){if(super.activate(t),this.currentValue=null,await this.dropdown.updateComplete,this.dropdown.updateOptions({selectMode:"s"==t.type?pf.Single:pf.Multiple}),t.editorContent){let e=t.editorContent;e&&0!=e.length||(e=t.hasValue?[{k:t.value,v:t.value}]:[]),this.dropdown.value=null,this.dropdown.adapter=null,this.dropdown.setSourceData(e)}else t.adapter&&(this.dropdown.adapter=t.adapter);await this.dropdown.open(),this.setValue(this.currentValue??t.value)}getValue(){return this.currentValue}setValue(t){this.currentValue=t,null==t?this.dropdown.value=null:"s"==this.activeCellModel.type?this.dropdown.value=this.activeCellModel.value==t&&null!=this.activeCellModel.displayValue?[[t,null,null,{value:this.activeCellModel.displayValue}]]:[[t]]:Array.isArray(t)?this.dropdown.value=mf(t):this.dropdown.value=null,null!=this.initialValue&&this.dropdown.filter(t.toString())}close(){this.currentValue=null,super.close(),this.dropdown.close()}};bx.styles=[ux.baseStyles,Gn`
3104
+ `],fx=gx=function(t,e,i,o){var n,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(r<3?n(s):r>3?n(e,i,s):n(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s}([Jr("og-grid-texteditor")],fx);let mx=class extends fx{validate(t){return t=t.replace(",","."),dv(t)||!isNaN(Number(t))||"-"==t}_onKey(t){1===t.key.length&&(this.validate(this.input.value+t.key)||t.preventDefault())}setValue(t){this.input.value=this.validate(t)?t:""}firstUpdated(){this.input.addEventListener("keydown",(t=>this._onKey(t))),this.input.addEventListener("keypress",(t=>this._onKey(t)))}getValue(){return""===this.input.value?null:this.input.value.replace(",",".")}};mx=function(t,e,i,o){var n,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(r<3?n(s):r>3?n(e,i,s):n(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s}([Jr("og-grid-numbereditor")],mx);var vx=function(t,e,i,o){var n,r=arguments.length,s=r<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,o);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(s=(r<3?n(s):r>3?n(e,i,s):n(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s};let bx=class extends ux{constructor(){super(),this._onChange=t=>{if("s"==this.activeCellModel.type){this.currentValue=null,this.currentDisplayValue=null;for(const[t,e]of this.dropdown.selectedItems){this.currentValue=t,this.currentDisplayValue=e.value;break}}else this.currentValue=this.dropdown.selection.serialize(),this.currentDisplayValue=this.dropdown.getSelectionText();this.commit(),"s"==this.activeCellModel.type&&(this.dropdown.close(),this.close())},this.render=()=>Ir`<og-tree-dropdown @change="${this._onChange}" buttonInput cross></og-tree-dropdown>`}init(){this.addEventListener("keydown",(t=>{if("Enter"==t.key){if(null==this.dropdown?.input.value)return;if(!this.activeCellModel?.allowInvalid)return;this.currentValue=this.dropdown.input.value,this.currentDisplayValue=this.dropdown.input.value,this.activeCellModel.displayValue=this.currentDisplayValue,this.commit()}})),super.init()}async activate(t){if(super.activate(t),this.currentValue=null,await this.dropdown.updateComplete,this.dropdown.updateOptions({selectMode:"s"==t.type?pf.Single:pf.Multiple}),t.editorContent){let e=t.editorContent;e&&0!=e.length||(e=t.hasValue?[{k:t.value,v:t.value}]:[]),this.dropdown.value=null,this.dropdown.adapter=null,this.dropdown.setSourceData(e)}else t.adapter&&(this.dropdown.adapter=t.adapter);await this.dropdown.open(),this.setValue(this.currentValue??t.value)}getValue(){return this.currentValue}getDisplayValue(){return this.currentDisplayValue}setValue(t){this.currentValue=t,null==t?this.dropdown.value=null:"s"==this.activeCellModel.type?this.dropdown.value=this.activeCellModel.value==t&&null!=this.activeCellModel.displayValue?[[t,null,null,{value:this.activeCellModel.displayValue}]]:[[t]]:Array.isArray(t)?this.dropdown.value=mf(t):this.dropdown.value=null,null!=this.initialValue&&this.dropdown.filter(t.toString())}close(){this.currentValue=null,super.close(),this.dropdown.close()}};bx.styles=[ux.baseStyles,Gn`
3105
3105
  og-tree-dropdown {
3106
3106
  width: 100%;
3107
3107
  height: 100%;
@@ -3112,7 +3112,7 @@
3112
3112
  @formula.commit="${this._onInputCommit}"
3113
3113
  @formula.discard="${this._onInputDiscard}">
3114
3114
  </og-grid-formula>
3115
- `}commit(){this._open&&!this.cancel&&this.activeCellModel&&(this.grid.editing.updateCellValue(this.activeCellModel,this.getValue(),!0),this.grid.rendering.updateCells([this.activeCellModel],!0)),this.cancel=!1,this.close()}close(){this.grid.selecting.removeFormulaHighlight(),this.grid.selecting.updateFormulaSelector(),super.close()}activate(t){this.grid.editing.startFormulaMode(),super.activate(t),this.input.tokenizer=t.model.calculations.tokenizer,this.setValue(t.hasOwnFormula?t.formula:"");const e=this.grid.group?this.grid.group:this.grid;e.addEventListener("grid.selector.resize",this._onGridSelectorUpdate),e.addEventListener("grid.selector.move",this._onGridSelectorUpdate),e.addEventListener("grid.select",this._onGridSelect)}deactivate(){const t=this.grid.group?this.grid.group:this.grid;t.removeEventListener("grid.selector.resize",this._onGridSelectorUpdate),t.removeEventListener("grid.selector.move",this._onGridSelectorUpdate),t.removeEventListener("grid.select",this._onGridSelect),this.grid.editing.endFormulaMode(),super.deactivate()}getValue(){return this.input.value}setValue(t){Ht(this.input,{w:this.clientWidth}),this.input.activate("="!=(t||"=").charAt(0)?"="+t:t)}focus(){this.input.focus()}};xx.styles=[ux.baseStyles,Gn`
3115
+ `}commit(){this._open&&!this.cancel&&this.activeCellModel&&(this.grid.editing.updateCells([this.activeCellModel],[this.getValue()],!0),this.grid.rendering.updateCells([this.activeCellModel],!0)),this.cancel=!1,this.close()}close(){this.grid.selecting.removeFormulaHighlight(),this.grid.selecting.updateFormulaSelector(),super.close()}activate(t){this.grid.editing.startFormulaMode(),super.activate(t),this.input.tokenizer=t.model.calculations.tokenizer,this.setValue(t.hasOwnFormula?t.formula:"");const e=this.grid.group?this.grid.group:this.grid;e.addEventListener("grid.selector.resize",this._onGridSelectorUpdate),e.addEventListener("grid.selector.move",this._onGridSelectorUpdate),e.addEventListener("grid.select",this._onGridSelect)}deactivate(){const t=this.grid.group?this.grid.group:this.grid;t.removeEventListener("grid.selector.resize",this._onGridSelectorUpdate),t.removeEventListener("grid.selector.move",this._onGridSelectorUpdate),t.removeEventListener("grid.select",this._onGridSelect),this.grid.editing.endFormulaMode(),super.deactivate()}getValue(){return this.input.value}setValue(t){Ht(this.input,{w:this.clientWidth}),this.input.activate("="!=(t||"=").charAt(0)?"="+t:t)}focus(){this.input.focus()}};xx.styles=[ux.baseStyles,Gn`
3116
3116
  og-grid-formula {
3117
3117
  display: block;
3118
3118
  border: 1px solid var(--og-accent-color, ${Un(Vw.DEFAULT_ACCENT_COLOR)});
@@ -3121,7 +3121,7 @@
3121
3121
  height: 100%;
3122
3122
  padding: 0;
3123
3123
  }
3124
- `],wx([rs("og-grid-formula")],xx.prototype,"input",void 0),xx=wx([Jr("og-grid-formulaeditor")],xx);const kx=new Map([["t",{createComponent:()=>new fx}],["n",{createComponent:()=>new mx}],["b",{createComponent:()=>new px}],["s",{createComponent:()=>new bx}],["m",{createComponent:()=>new bx}],["d",{createComponent:()=>new yx}]]);class Cx{get model(){return this.grid.model}get selection(){return this.grid.selection}get selector(){return this.grid.selector}get events(){return this.grid.events}get table(){return this.grid.table}get isEditing(){return!!this.editor}get activeEditor(){return this.editor}get isFormulaMode(){return this._formulaMode||this.grid.group?.isFormulaMode}constructor(t){this.grid=t,this.editorMap=new Map,this.columnMoving=!1,this.rowMoving=!1,this._formulaMode=!1}canEdit(t){return t.editable||this.grid.designMode}updateCellValue(t,e,i=!0,o=!1){this.updateCellValues([t],[e],i,o)}updateCellValues(t,e,i=!0,o=!1){const n=[],r=[],s=[];t.forEach(((t,o)=>{t.value!==e[o]&&(i&&(n.push(t.value),r.push(e[o]),s.push(t)),t.clearFormula(),t.value=e[o],e[o]=t.value)})),i&&s.length&&this.grid.dispatchEvent(new nx({grid:this.grid,fromHistory:!!o,cells:s,editType:"value",newValues:r,oldValues:n}))}startFormulaMode(){this._formulaMode=!0,this.grid.group&&this.grid.group.startFormulaMode(this.grid)}endFormulaMode(t=!0){this._formulaMode=!1,t&&this.grid.group&&this.grid.group.endFormulaMode(),this.grid.selecting.hideFormulaSelector(),this.grid.selecting.removeFormulaHighlight(),this.grid.selecting.showSelector()}startEdit(t=null){const e=this.grid.selecting.activeCell;if(e&&this.canEdit(e)){this.grid.logger.info(`start edit ${new Jm(e.c,e.r).A1}`);let i=!0;dv(t)||null==t&&e.hasOwnFormula?this.editor=this.getFormulaEditor().open(this.grid,t):(i=!1,this.editor=this.getEditor(e).open(this.grid,t)),this.grid.dispatchEvent(new ox("startEdit",{grid:this.grid})),i&&(this.startFormulaMode(),this.grid.dispatchEvent(new ox("startFormulaEdit",{grid:this.grid})))}}endEdit(){this.editor&&(this.grid.logger.info("end edit"),this.grid.editing.endFormulaMode(),this.editor?.close(),this.editor=null,this.grid.dispatchEvent(new ox("endEdit",{grid:this.grid})))}commitEdit(){this.editor&&(this.editor.commit(),this.endEdit())}insertRows(t){const e=this.model.insertRows(t.index,t.count,t.after);return this.grid.rendering.renderAll(!0),tt(t.dispatchEvent,!0)&&this.grid.dispatchEvent(new nx({grid:this.grid,fromHistory:!!t.fromHistory,editType:"insert_row",newValues:e})),e}insertColumns(t){const e=this.model.insertColumns(t.index,t.count,t.after);return this.grid.rendering.renderAll(!0),tt(t.dispatchEvent,!0)&&this.grid.dispatchEvent(new nx({grid:this.grid,fromHistory:!!t.fromHistory,editType:"insert_column",newValues:e})),e}deleteRows(t){const e=this.model.deleteRows(t.index,t.count);return this.grid.rendering.renderAll(!0),tt(t.dispatchEvent,!0)&&this.grid.dispatchEvent(new nx({grid:this.grid,fromHistory:!!t.fromHistory,editType:"delete_row",oldValues:e})),e}deleteColumns(t){const e=this.model.deleteColumns(t.index,t.count);return this.grid.rendering.renderAll(!0),tt(t.dispatchEvent,!0)&&this.grid.dispatchEvent(new nx({grid:this.grid,fromHistory:!!t.fromHistory,editType:"delete_column",oldValues:e})),e}moveRows(t){this.model.moveRows(t.index,t.count,t.targetIndex),this.grid.rendering.renderAll(!1),tt(t.dispatchEvent,!0)&&this.grid.dispatchEvent(new nx({grid:this.grid,fromHistory:t.fromHistory,editType:"move_row",oldValues:[new Jm(0,t.index,1/0,t.index+t.count-1)],newValues:[new Jm(0,t.targetIndex,1/0,t.targetIndex+t.count-1)]}))}moveColumns(t){this.model.moveColumns(t.index,t.count,t.targetIndex),this.grid.rendering.renderAll(!1),tt(t.dispatchEvent,!0)&&this.grid.dispatchEvent(new nx({grid:this.grid,fromHistory:t.fromHistory,editType:"move_column",oldValues:[new Jm(t.index,t.index+t.count-1,1/0)],newValues:[new Jm(t.targetIndex,0,t.targetIndex+t.count-1,1/0)]}))}clearSelection(t=!0){const e=this.model.getCellArray(this.selection.range).filter((t=>this.canEdit(t)));this.updateCellValues(e,e.map((()=>null)),t),this.grid.rendering.updateCells(e,!0)}getEditor(t){const e=t.type;if(!this.editorMap.has(e)){const t=function(t){return kx.get(kx.has(t)?t:"t")}(e).createComponent();this.grid.shadowRoot.appendChild(t),this.editorMap.set(e,t)}return this.editorMap.get(e)}getFormulaEditor(){const t="formula";if(!this.editorMap.has(t)){const e=new xx;this.grid.shadowRoot.appendChild(e),this.editorMap.set(t,e)}return this.editorMap.get(t)}copySelection(){const t=this.model.getValuesInRange(this.selection.range,!0);this.grid.selecting.hideSelector(),this.grid.selecting.showCopySelector(),navigator.clipboard.writeText(en(t,{decimalSeparator:this.model.options.systemDecimalSeparator})).then((()=>{this.grid.logger.info("selected content copy")}),(()=>{this.grid.logger.error("copy rejected")}))}async paste(){const t=await navigator.clipboard.readText();if(t){const e=this.selection.range,i=on(t),o=[],n=[],r=i.length>0&&i[0].length>0&&e.size.rows%i.length==0&&e.size.columns%i[0].length==0,s=Math.min(r?e.r2:e.r1+i.length-1,this.model.rows.length-1),a=Math.min(r?e.c2:e.c1+i[0].length-1,this.model.columns.length-1);for(let t=e.r1;t<=s;t++){const r=(t-e.r1)%i.length;for(let s=e.c1;s<=a;s++){const a=this.model.rows[t].cell(s),l=(s-e.c1)%i[r].length;n.push(i[r][l]),o.push(a)}}this.updateCellValues(o,n,!0),this.grid.rendering.updateCells(o,!0)}this.grid.selecting.hideCopySelector()}openComments(t){setTimeout((()=>{this.grid.comment.attachTo(this.grid.table.getCellByCellModel(t),t,!0)}),100)}undo(){let t;const[e]=this.grid.history.pop();if(e)switch(e.type){case"value":t=e.addresses.map((t=>this.model.getCellByA1(t))),this.updateCellValues(t,e.oldValues,!0,!0),this.grid.rendering.updateCells(t,!0);break;case"insert_column":e.newValues.forEach(((t,i)=>this.grid.editing.deleteColumns({index:ov(e.addresses[i]),count:1,dispatchEvent:!0,fromHistory:!0})));break;case"insert_row":e.newValues.forEach(((t,i)=>this.grid.editing.deleteRows({index:ev(e.addresses[i]),count:1,dispatchEvent:!0,fromHistory:!0})))}}redo(){let t;const[e]=this.grid.history.pop2();if(e)switch(e.type){case"value":t=e.addresses.map((t=>this.model.getCellByA1(t))),this.updateCellValues(t,e.newValues,!0,!0),this.grid.rendering.updateCells(t,!0);break;case"insert_column":e.newValues.forEach(((t,i)=>this.grid.editing.insertColumns({index:ov(e.addresses[i]),count:1,dispatchEvent:!0,fromHistory:!0})));break;case"insert_row":e.newValues.forEach(((t,i)=>this.grid.editing.insertRows({index:ev(e.addresses[i]),count:1,dispatchEvent:!0,fromHistory:!0})))}}startColumnMoving(t){this.columnMoving=!0}}class Mx extends ox{constructor(t,e){super(`filter.${t}`,e)}}class _x extends Qr{get currentValue(){return this.filterModel.get(this.columnModel.index)?.term}constructor(){super(),this.addEventListener("keydown",(t=>t.stopPropagation())),this.addEventListener("mousedown",(t=>t.stopPropagation())),this.addEventListener("pointerdown",(t=>t.stopPropagation())),this.addEventListener("click",(t=>t.stopPropagation())),this.addEventListener("dblclick",(t=>t.stopPropagation()))}filter(t){this.filterModel.filter({term:t,c:this.columnModel.index}),this.dispatchEvent(new Mx("apply",{filter:Array.from(this.filterModel.settings.values())}))}clearFilter(){this.filterModel.filter({term:null,c:this.columnModel.index}),this.dispatchEvent(new Mx("apply",{filter:Array.from(this.filterModel.settings.values())}))}activate(){this.dispatchEvent(new Mx("activate"))}deactivate(){this.dispatchEvent(new Mx("deactivate"))}}_x.styles=[Gn`
3124
+ `],wx([rs("og-grid-formula")],xx.prototype,"input",void 0),xx=wx([Jr("og-grid-formulaeditor")],xx);const kx=new Map([["t",{createComponent:()=>new fx}],["n",{createComponent:()=>new mx}],["b",{createComponent:()=>new px}],["s",{createComponent:()=>new bx}],["m",{createComponent:()=>new bx}],["d",{createComponent:()=>new yx}]]);class Cx{get model(){return this.grid.model}get selection(){return this.grid.selection}get selector(){return this.grid.selector}get events(){return this.grid.events}get table(){return this.grid.table}get isEditing(){return!!this.editor}get activeEditor(){return this.editor}get isFormulaMode(){return this._formulaMode||this.grid.group?.isFormulaMode}constructor(t){this.grid=t,this.editorMap=new Map,this.columnMoving=!1,this.rowMoving=!1,this._formulaMode=!1}canEdit(t){return t.editable||this.grid.designMode}updateCell(t,e,i=!0,o=!1){this.updateCells([t],[e],i,o)}updateCells(t,e,i=!0,o=!1){let n,r,s,a,l;t.forEach(((t,o)=>{const c=t.value;let h,d,u;q(e[o])?(d=e[o],h="v"in d?d.v:void 0):h=e[o],d?u=t.update(d):(t.clearFormula(),c!==h&&(u={v:c,dv:t.displayValue},t.value=h)),i&&u&&(n=n||[],r=r||[],s=s||[],a=a||[],l=l||[],n.push(c),r.push(u),s.push(h),a.push(d),l.push(t))})),i&&l?.length&&this.grid.dispatchEvent(new nx({grid:this.grid,fromHistory:!!o,cells:l,editType:"value",newValues:s,newProps:a,oldValues:n,oldProps:r}))}startFormulaMode(){this._formulaMode=!0,this.grid.group&&this.grid.group.startFormulaMode(this.grid)}endFormulaMode(t=!0){this._formulaMode=!1,t&&this.grid.group&&this.grid.group.endFormulaMode(),this.grid.selecting.hideFormulaSelector(),this.grid.selecting.removeFormulaHighlight(),this.grid.selecting.showSelector()}startEdit(t=null){const e=this.grid.selecting.activeCell;if(e&&this.canEdit(e)){this.grid.logger.info(`start edit ${new Jm(e.c,e.r).A1}`);let i=!0;dv(t)||null==t&&e.hasOwnFormula?this.editor=this.getFormulaEditor().open(this.grid,t):(i=!1,this.editor=this.getEditor(e).open(this.grid,t)),this.grid.dispatchEvent(new ox("startEdit",{grid:this.grid})),i&&(this.startFormulaMode(),this.grid.dispatchEvent(new ox("startFormulaEdit",{grid:this.grid})))}}endEdit(){this.editor&&(this.grid.logger.info("end edit"),this.grid.editing.endFormulaMode(),this.editor?.close(),this.editor=null,this.grid.dispatchEvent(new ox("endEdit",{grid:this.grid})))}commitEdit(){this.editor&&(this.editor.commit(),this.endEdit())}insertRows(t){const e=this.model.insertRows(t.index,t.count,t.after);return this.grid.rendering.renderAll(!0),tt(t.dispatchEvent,!0)&&this.grid.dispatchEvent(new nx({grid:this.grid,fromHistory:!!t.fromHistory,editType:"insert_row",newValues:e})),e}insertColumns(t){const e=this.model.insertColumns(t.index,t.count,t.after);return this.grid.rendering.renderAll(!0),tt(t.dispatchEvent,!0)&&this.grid.dispatchEvent(new nx({grid:this.grid,fromHistory:!!t.fromHistory,editType:"insert_column",newValues:e})),e}deleteRows(t){const e=this.model.deleteRows(t.index,t.count);return this.grid.rendering.renderAll(!0),tt(t.dispatchEvent,!0)&&this.grid.dispatchEvent(new nx({grid:this.grid,fromHistory:!!t.fromHistory,editType:"delete_row",oldValues:e})),e}deleteColumns(t){const e=this.model.deleteColumns(t.index,t.count);return this.grid.rendering.renderAll(!0),tt(t.dispatchEvent,!0)&&this.grid.dispatchEvent(new nx({grid:this.grid,fromHistory:!!t.fromHistory,editType:"delete_column",oldValues:e})),e}moveRows(t){this.model.moveRows(t.index,t.count,t.targetIndex),this.grid.rendering.renderAll(!1),tt(t.dispatchEvent,!0)&&this.grid.dispatchEvent(new nx({grid:this.grid,fromHistory:t.fromHistory,editType:"move_row",oldValues:[new Jm(0,t.index,1/0,t.index+t.count-1)],newValues:[new Jm(0,t.targetIndex,1/0,t.targetIndex+t.count-1)]}))}moveColumns(t){this.model.moveColumns(t.index,t.count,t.targetIndex),this.grid.rendering.renderAll(!1),tt(t.dispatchEvent,!0)&&this.grid.dispatchEvent(new nx({grid:this.grid,fromHistory:t.fromHistory,editType:"move_column",oldValues:[new Jm(t.index,t.index+t.count-1,1/0)],newValues:[new Jm(t.targetIndex,0,t.targetIndex+t.count-1,1/0)]}))}clearSelection(t=!0){const e=this.model.getCellArray(this.selection.range).filter((t=>this.canEdit(t)));this.updateCells(e,e.map((()=>null)),t),this.grid.rendering.updateCells(e,!0)}getEditor(t){const e=t.type;if(!this.editorMap.has(e)){const t=function(t){return kx.get(kx.has(t)?t:"t")}(e).createComponent();this.grid.shadowRoot.appendChild(t),this.editorMap.set(e,t)}return this.editorMap.get(e)}getFormulaEditor(){const t="formula";if(!this.editorMap.has(t)){const e=new xx;this.grid.shadowRoot.appendChild(e),this.editorMap.set(t,e)}return this.editorMap.get(t)}getSelectionCellData(){return this.model.getCellMatrix(this.selection.range).map((t=>t.map((t=>t.getSourceData({displayValue:!0})))))}copySelection(){const t=this.model.getValuesInRange(this.selection.range,!0);this.grid.selecting.hideSelector(),this.grid.selecting.showCopySelector();const e={"text/plain":new Blob([en(t,{decimalSeparator:this.model.options.systemDecimalSeparator})],{type:"text/plain"})};ClipboardItem.supports(Vw.CUSTOM_CLIPBOARD_TYPE)?e[Vw.CUSTOM_CLIPBOARD_TYPE]=new Blob([JSON.stringify(this.getSelectionCellData())],{type:"application/json"}):this.grid.logger.warn("Browser does not support custom clipboard type"),navigator.clipboard.write([new ClipboardItem(e)]).then((()=>this.grid.logger.info("selected content copied")),(()=>this.grid.logger.error("copy rejected")))}pasteMatrix(t){const e=this.selection.range,i=[],o=[],n="all"==(this.model.options.clipboard?.pasteProps??"all")?null:this.model.options.clipboard.pasteProps,r=t.length>0&&t[0].length>0&&e.size.rows%t.length==0&&e.size.columns%t[0].length==0,s=Math.min(r?e.r2:e.r1+t.length-1,this.model.rows.length-1),a=Math.min(r?e.c2:e.c1+t[0].length-1,this.model.columns.length-1);for(let r=e.r1;r<=s;r++){const s=(r-e.r1)%t.length;for(let l=e.c1;l<=a;l++){const a=this.model.rows[r].cell(l);if(!a.editable)continue;const c=(l-e.c1)%t[s].length;if(n&&q(t[s][c])){const e={};n.forEach((i=>{e[i]=t[s][c][i]})),a.prefersDisplayValue||(e.dv=void 0),o.push(e)}else o.push(t[s][c]);i.push(a)}}this.updateCells(i,o,!0),this.grid.rendering.updateCells(i,!0)}pasteText(t){this.pasteMatrix(on(t))}async paste(){this.grid.selecting.hideCopySelector();try{const t=await navigator.clipboard.read();if(0==t.length)return;const e=t[0];if(e.types.includes(Vw.CUSTOM_CLIPBOARD_TYPE)){const t=await e.getType(Vw.CUSTOM_CLIPBOARD_TYPE);this.pasteMatrix(JSON.parse(await t.text()))}else if(e.types.includes("text/plain")){const t=await e.getType("text/plain");this.pasteText(await t.text())}}catch(t){return void this.grid.logger.error("paste rejected")}}openComments(t){setTimeout((()=>{this.grid.comment.attachTo(this.grid.table.getCellByCellModel(t),t,!0)}),100)}undo(){let t;const[e]=this.grid.history.pop();if(e)switch(e.type){case"value":t=e.addresses.map((t=>this.model.getCellByA1(t))),this.updateCells(t,e.oldProps,!0,!0),this.grid.rendering.updateCells(t,!0);break;case"insert_column":e.newValues.forEach(((t,i)=>this.grid.editing.deleteColumns({index:ov(e.addresses[i]),count:1,dispatchEvent:!0,fromHistory:!0})));break;case"insert_row":e.newValues.forEach(((t,i)=>this.grid.editing.deleteRows({index:ev(e.addresses[i]),count:1,dispatchEvent:!0,fromHistory:!0})))}}redo(){let t;const[e]=this.grid.history.pop2();if(e)switch(e.type){case"value":t=e.addresses.map((t=>this.model.getCellByA1(t))),this.updateCells(t,e.newValues,!0,!0),this.grid.rendering.updateCells(t,!0);break;case"insert_column":e.newValues.forEach(((t,i)=>this.grid.editing.insertColumns({index:ov(e.addresses[i]),count:1,dispatchEvent:!0,fromHistory:!0})));break;case"insert_row":e.newValues.forEach(((t,i)=>this.grid.editing.insertRows({index:ev(e.addresses[i]),count:1,dispatchEvent:!0,fromHistory:!0})))}}startColumnMoving(t){this.columnMoving=!0}}class Mx extends ox{constructor(t,e){super(`filter.${t}`,e)}}class _x extends Qr{get currentValue(){return this.filterModel.get(this.columnModel.index)?.term}constructor(){super(),this.addEventListener("keydown",(t=>t.stopPropagation())),this.addEventListener("mousedown",(t=>t.stopPropagation())),this.addEventListener("pointerdown",(t=>t.stopPropagation())),this.addEventListener("click",(t=>t.stopPropagation())),this.addEventListener("dblclick",(t=>t.stopPropagation()))}filter(t){this.filterModel.filter({term:t,c:this.columnModel.index}),this.dispatchEvent(new Mx("apply",{filter:Array.from(this.filterModel.settings.values())}))}clearFilter(){this.filterModel.filter({term:null,c:this.columnModel.index}),this.dispatchEvent(new Mx("apply",{filter:Array.from(this.filterModel.settings.values())}))}activate(){this.dispatchEvent(new Mx("activate"))}deactivate(){this.dispatchEvent(new Mx("deactivate"))}}_x.styles=[Gn`
3125
3125
  :host {
3126
3126
  height: 100%;
3127
3127
  border: 1px solid var(--og-accent-color);
@@ -3632,7 +3632,7 @@
3632
3632
  </div>
3633
3633
  </og-container>
3634
3634
  </div>
3635
- `,this.addEventListener("mousedown",this._onMouseDown),this.addEventListener("mouseover",this._onMouseOver)}add(){this.items.unshift(new Ky({text:"",author:this.cellModel.model.options.user})),this.startEdit(0)}startEdit(t){this.editIndex=t,this.requestUpdate()}endEdit(){this.commit(),this.editIndex=-1}delete(t){this.items.splice(t,1),this.requestUpdate(),this.dispatchEvent(new ck("commit",this.items,null,null,this.cellModel))}commit(){this.editItem&&this.editItem.text!=this.editBody.innerText&&(this.editItem.text=this.editBody.innerText,this.editItem.date=new Date,this.dispatchEvent(new ck("commit",this.items,this.editItem,this.editIndex,this.cellModel)))}disconnectedCallback(){this.destroy()}destroy(){this._connector?.parentElement&&this._connector.remove()}updated(){this.editBody&&(this.editBody.focus(),this.editBody.addEventListener("blur",(()=>this.endEdit()),{once:!0})),this.items?.forEach(((t,e)=>{const i=this.bodies[e];Y(this.cellModel?.commentRenderer)?(i.style.whiteSpace="normal",this.cellModel?.commentRenderer(i,t,this.cellModel)):(i.style.whiteSpace="pre-wrap",i.textContent=t?.text??"")}))}canEdit(t){return this.cellModel?.commentable&&!this.items[t].readOnly}get canAdd(){return this.cellModel?.commentable}deatach(t=0){this.isAttached&&(this._hideTimerDisabled||this._hideTimer||(this._hideTimer=window.setTimeout((()=>{this._attachedTo=null,this.hide(),this._connector&&(this._connector.style.display="none"),this.parentElement&&this.parentElement.removeEventListener("mousemove",this._onParentMouseDown)}),t)))}get zIndex(){return this.cellModel?.model?.options?.comments?.zIndex??Hm.DEFAULT_OPTIONS.comments.zIndex}updateConnector(){if(!this.isAttached)return;this._connector||(this._connector=document.createElementNS("http://www.w3.org/2000/svg","svg"),document.body.appendChild(this._connector));const t=Et(this.attachedTo,document.body),e=t.left+this._attachedTo.offsetWidth<this.offsetLeft+this.offsetWidth/2,i=t.top<this.offsetTop+this.offsetHeight/2,o=e?t.left+this._attachedTo.offsetWidth:this.offsetLeft+this.offsetWidth/2,n=i?t.top:this.offsetTop+this.offsetHeight/2,r=e?this.offsetLeft+this.offsetWidth/2:t.left+this._attachedTo.offsetWidth,s=i?this.offsetTop+this.offsetHeight/2:t.top;this._connector.setAttribute("width",(r-o).toString()),this._connector.setAttribute("height",(s-n).toString()),this._connector.style.pointerEvents="none",this._connector.style.zIndex=(this.zIndex-1).toString(),Ot(this._connector,{l:o,t:n}),this._connector.style.display="block",this._connector.innerHTML=`\n\t\t\t<line \n\t\t\t\tx1="${e?0:r-o}" y1="${i?0:s-n}" \n\t\t\t\tx2="${e?r-o:0}" y2="${i?s-n:0}" \n\t\t\t\tstroke="#8b7600" stroke-width="1"/>\n\t\t`}attachTo(t,e,i=!1){this._attachedTo=t,this.items=e.comments,this.cellModel=e,this._hideTimerDisabled=i,this._hideTimer&&window.clearTimeout(this._hideTimer),this._hideTimer=null,this.parentElement!=document.body&&document.body.appendChild(this),document.body.addEventListener("mousedown",this._onParentMouseDown),this.show();const o=Et(t,document.body);Ot(this,{l:o.left+t.offsetWidth+e.model.options.comments.offsetX,t:o.top+e.model.options.comments.offsetY}),this.style.zIndex=this.zIndex.toString(),this.updateConnector(),i&&this.startEdit(0)}};hk.styles=[ak],lk([is({type:Array})],hk.prototype,"items",void 0),lk([os()],hk.prototype,"cellModel",void 0),lk([os()],hk.prototype,"editIndex",void 0),lk([as(".comment-body")],hk.prototype,"bodies",void 0),hk=lk([Jr("og-grid-comment")],hk);const dk=(t,e)=>{for(const i in e)t.style[i]=e[i]};function uk(t,e){e.hasError&&(t.innerHTML=`<span style="color:#fff;background:#f00">!${e.error}</span>`),e.cssStyle&&dk(t,e.cssStyle),e.hasSparkline&&function(t,e){const i=gt("og-grid-sparkline");i.cell=e,t.appendChild(i)}(t,e);let i=e.calculatedIndent;if(i>0&&(i*=e.model.options.cellIndentFactor??1),e.column.levelButtons){if(e.row.hasChildren){const o=new Td;o.state=e.row.collapsed?"closed":"open",o.addEventListener("toggle",(()=>this.grid.rendering.toggleRow(e.row.index))),o.addEventListener("click",(t=>t.stopPropagation())),t.appendChild(o),Ot(o,{l:4+i,t:(e.model.options.rowHeight||20)/2-6})}i+=20}if(i>0&&(t.style.paddingLeft=Rt(i)),e.hasComment||e.hasTooltip||e.clickable&&(null!==e.value||e.model.options.emptyClickable)){const i=gt("div");i.className="crn",t.appendChild(i),e.hasComment&&t.classList.add("cmt"),e.hasTooltip&&t.classList.add("tt"),e.clickable&&t.classList.add("clc")}if(e.composedStyle&&e.composedStyle.icon){const i=gt("og-icon");i.icon=e.composedStyle.icon,Ot(i,{l:4,t:2}),t.appendChild(i)}const o=e.afterRenderer;return o&&o(t,e),t}function pk(t){t.tooltip?.hide()}function gk(t,e){uk.call(this,t,e),t.style.textAlign="center",t.innerHTML="";const i=gt("og-checkbox");return i.addEventListener("mousedown",(t=>{t.stopPropagation();const o=this.grid,n="checked"!=i.value;o.editing.updateCellValue(e,n),i.value=n?"checked":"none"})),i.style.cursor="pointer",i.value=e.value?"checked":"none",t.appendChild(i),t}function fk(t,e){t=uk.call(this,t,e);try{t.textContent=e.value?e.model.options.dateFormatter(e.value,e.format):""}catch(e){t.textContent="!invalid format"}return t}function mk(t,e,i={default:!0}){if(i.default)if(null!=e.displayValue)t.textContent=e.displayValue;else{const i=e.valueFormatter;t.textContent=(i?i(e.value):e.value)??""}const o=gt("div");return o.className="triangle-down",Ot(o,{t:8,r:8}),t.appendChild(o),uk.call(this,t,e)}function vk(t,e){e.cssStyle&&e.cssStyle.textAlign||(t.style.textAlign="right");try{t.innerHTML=e.formattedValue}catch(i){t.textContent=(e.value??"").toString()}return uk.call(this,t,e)}function bk(t,e){if(e.hasDisplayValue)t.textContent=e.displayValue;else if(null!=e.value){const i=e.valueFormatter;t.textContent=i?i(e.value):e.value??""}else t.textContent="";return uk.call(this,t,e)}function yk(t,e){const i=e.value;return isNaN(i)||""===i?bk.call(this,t,e):vk.call(this,t,e)}const wk={n:vk,t:bk,tm:fk,d:fk,dt:fk,b:gk,s:mk,m:mk,g:yk,a:function(t,e){const i=(e.editorContent??e.value)||[];t.innerHTML="";const o=this.grid;return Xr(Ir`
3635
+ `,this.addEventListener("mousedown",this._onMouseDown),this.addEventListener("mouseover",this._onMouseOver)}add(){this.items.unshift(new Ky({text:"",author:this.cellModel.model.options.user})),this.startEdit(0)}startEdit(t){this.editIndex=t,this.requestUpdate()}endEdit(){this.commit(),this.editIndex=-1}delete(t){this.items.splice(t,1),this.requestUpdate(),this.dispatchEvent(new ck("commit",this.items,null,null,this.cellModel))}commit(){this.editItem&&this.editItem.text!=this.editBody.innerText&&(this.editItem.text=this.editBody.innerText,this.editItem.date=new Date,this.dispatchEvent(new ck("commit",this.items,this.editItem,this.editIndex,this.cellModel)))}disconnectedCallback(){this.destroy()}destroy(){this._connector?.parentElement&&this._connector.remove()}updated(){this.editBody&&(this.editBody.focus(),this.editBody.addEventListener("blur",(()=>this.endEdit()),{once:!0})),this.items?.forEach(((t,e)=>{const i=this.bodies[e];Y(this.cellModel?.commentRenderer)?(i.style.whiteSpace="normal",this.cellModel?.commentRenderer(i,t,this.cellModel)):(i.style.whiteSpace="pre-wrap",i.textContent=t?.text??"")}))}canEdit(t){return this.cellModel?.commentable&&!this.items[t].readOnly}get canAdd(){return this.cellModel?.commentable}deatach(t=0){this.isAttached&&(this._hideTimerDisabled||this._hideTimer||(this._hideTimer=window.setTimeout((()=>{this._attachedTo=null,this.hide(),this._connector&&(this._connector.style.display="none"),this.parentElement&&this.parentElement.removeEventListener("mousemove",this._onParentMouseDown)}),t)))}get zIndex(){return this.cellModel?.model?.options?.comments?.zIndex??Hm.DEFAULT_OPTIONS.comments.zIndex}updateConnector(){if(!this.isAttached)return;this._connector||(this._connector=document.createElementNS("http://www.w3.org/2000/svg","svg"),document.body.appendChild(this._connector));const t=Et(this.attachedTo,document.body),e=t.left+this._attachedTo.offsetWidth<this.offsetLeft+this.offsetWidth/2,i=t.top<this.offsetTop+this.offsetHeight/2,o=e?t.left+this._attachedTo.offsetWidth:this.offsetLeft+this.offsetWidth/2,n=i?t.top:this.offsetTop+this.offsetHeight/2,r=e?this.offsetLeft+this.offsetWidth/2:t.left+this._attachedTo.offsetWidth,s=i?this.offsetTop+this.offsetHeight/2:t.top;this._connector.setAttribute("width",(r-o).toString()),this._connector.setAttribute("height",(s-n).toString()),this._connector.style.pointerEvents="none",this._connector.style.zIndex=(this.zIndex-1).toString(),Ot(this._connector,{l:o,t:n}),this._connector.style.display="block",this._connector.innerHTML=`\n\t\t\t<line \n\t\t\t\tx1="${e?0:r-o}" y1="${i?0:s-n}" \n\t\t\t\tx2="${e?r-o:0}" y2="${i?s-n:0}" \n\t\t\t\tstroke="#8b7600" stroke-width="1"/>\n\t\t`}attachTo(t,e,i=!1){this._attachedTo=t,this.items=e.comments,this.cellModel=e,this._hideTimerDisabled=i,this._hideTimer&&window.clearTimeout(this._hideTimer),this._hideTimer=null,this.parentElement!=document.body&&document.body.appendChild(this),document.body.addEventListener("mousedown",this._onParentMouseDown),this.show();const o=Et(t,document.body);Ot(this,{l:o.left+t.offsetWidth+e.model.options.comments.offsetX,t:o.top+e.model.options.comments.offsetY}),this.style.zIndex=this.zIndex.toString(),this.updateConnector(),i&&this.startEdit(0)}};hk.styles=[ak],lk([is({type:Array})],hk.prototype,"items",void 0),lk([os()],hk.prototype,"cellModel",void 0),lk([os()],hk.prototype,"editIndex",void 0),lk([as(".comment-body")],hk.prototype,"bodies",void 0),hk=lk([Jr("og-grid-comment")],hk);const dk=(t,e)=>{for(const i in e)t.style[i]=e[i]};function uk(t,e){e.hasError&&(t.innerHTML=`<span style="color:#fff;background:#f00">!${e.error}</span>`),e.cssStyle&&dk(t,e.cssStyle),e.hasSparkline&&function(t,e){const i=gt("og-grid-sparkline");i.cell=e,t.appendChild(i)}(t,e);let i=e.calculatedIndent;if(i>0&&(i*=e.model.options.cellIndentFactor??1),e.column.levelButtons){if(e.row.hasChildren){const o=new Td;o.state=e.row.collapsed?"closed":"open",o.addEventListener("toggle",(()=>this.grid.rendering.toggleRow(e.row.index))),o.addEventListener("click",(t=>t.stopPropagation())),t.appendChild(o),Ot(o,{l:4+i,t:(e.model.options.rowHeight||20)/2-6})}i+=20}if(i>0&&(t.style.paddingLeft=Rt(i)),e.hasComment||e.hasTooltip||e.clickable&&(null!==e.value||e.model.options.emptyClickable)){const i=gt("div");i.className="crn",t.appendChild(i),e.hasComment&&t.classList.add("cmt"),e.hasTooltip&&t.classList.add("tt"),e.clickable&&t.classList.add("clc")}if(e.composedStyle&&e.composedStyle.icon){const i=gt("og-icon");i.icon=e.composedStyle.icon,Ot(i,{l:4,t:2}),t.appendChild(i)}const o=e.afterRenderer;return o&&o(t,e),t}function pk(t){t.tooltip?.hide()}function gk(t,e){uk.call(this,t,e),t.style.textAlign="center",t.innerHTML="";const i=gt("og-checkbox");return i.addEventListener("mousedown",(t=>{t.stopPropagation();const o=this.grid,n="checked"!=i.value;o.editing.updateCell(e,n),i.value=n?"checked":"none"})),i.style.cursor="pointer",i.value=e.value?"checked":"none",t.appendChild(i),t}function fk(t,e){t=uk.call(this,t,e);try{t.textContent=e.value?e.model.options.dateFormatter(e.value,e.format):""}catch(e){t.textContent="!invalid format"}return t}function mk(t,e,i={default:!0}){if(i.default)if(null!=e.displayValue)t.textContent=e.displayValue;else{const i=e.valueFormatter;t.textContent=(i?i(e.value):e.value)??""}const o=gt("div");return o.className="triangle-down",Ot(o,{t:8,r:8}),t.appendChild(o),uk.call(this,t,e)}function vk(t,e){e.cssStyle&&e.cssStyle.textAlign||(t.style.textAlign="right");try{t.innerHTML=e.formattedValue}catch(i){t.textContent=(e.value??"").toString()}return uk.call(this,t,e)}function bk(t,e){if(e.hasDisplayValue)t.textContent=e.displayValue;else if(null!=e.value){const i=e.valueFormatter;t.textContent=i?i(e.value):e.value??""}else t.textContent="";return uk.call(this,t,e)}function yk(t,e){const i=e.value;return isNaN(i)||""===i?bk.call(this,t,e):vk.call(this,t,e)}const wk={n:vk,t:bk,tm:fk,d:fk,dt:fk,b:gk,s:mk,m:mk,g:yk,a:function(t,e){const i=(e.editorContent??e.value)||[];t.innerHTML="";const o=this.grid;return Xr(Ir`
3636
3636
  <div class="actions">
3637
3637
  ${ls(i,(t=>Ir`
3638
3638
  <og-button
@@ -6569,7 +6569,7 @@ milkdown-block-handle {
6569
6569
  text-align: center;
6570
6570
  margin-left: 1px;
6571
6571
  }
6572
- `],qS([is({type:Object})],YS.prototype,"item",void 0),qS([is({type:String})],YS.prototype,"value",void 0),qS([rs("og-dropdown")],YS.prototype,"dropdown",void 0),qS([rs("#btnContent")],YS.prototype,"btnContent",void 0),YS=qS([Jr("og-toolbar-colorpicker")],YS);class ZS{static init(t){this.path=t}static async get(){return this.xlsx||(this.xlsx=await this.load()),this.xlsx}static getSync(){return this.xlsx}static load(){if(!An.require)throw new Error("AMDLoader is not initialized");return An.require.config({paths:{sheetjs:this.path}}),new Promise((t=>{An.require(["sheetjs/xlsx.full.min"],(()=>{t(self.XLSX)}))}))}}const XS="aaaaaa",QS={bottom:{style:"thin",color:XS},top:{style:"thin",color:XS},right:{style:"thin",color:XS},left:{style:"thin",color:XS}},KS={exportHiddenRows:!0,exportHiddenColumns:!0,gridLines:!0,defaultBorders:!1,dropdownCells:"value"},JS={alignment:{vertical:"center",horizontal:"center"},bold:!0},tE={g:"n",b:"b",t:"s",n:"n",d:"d",dt:"d",s:"s",m:"s",tm:"s",h:"s",a:"z"};function eE(t,e){return(e.exportHiddenColumns?t.columns:t.visibleColumns).map((e=>({level:e.level,wpx:e.width,hidden:null==e.visibleIndex||t.visibleColumns[e.visibleIndex]!=e})))}function iE(t,e){const i=e.exportHiddenRows?t.rows:t.visibleRows,o=t.headerCount,n=new Array(i.length+o);return[...Array(o).keys()].map((t=>n[t]={level:0})),i.map(((e,i)=>n[i+o]={level:e.level,hpt:.75*e.height,hidden:null==e.visibleIndex||t.visibleRows[e.visibleIndex]!=e})),n}function oE(t,e){const i=t.headerCount,o=e.exportHiddenColumns?t=>t.c:e=>t.columns[e.c].visibleIndex,n=t.hiddenCells,r=[];return t.mergedCells.forEach((t=>{n.get(t.r)?.get(t.c)||r.push({s:{c:o(t),r:t.r+i},e:{c:o(t)+t.cs-1,r:t.r+i+t.rs-1}})})),t.mergedHeaders.forEach((t=>{t.h?.hidden||r.push({s:{c:o(t),r:t.r},e:{c:o(t)+t.cs-1,r:t.r+t.rs-1}})})),r}function nE(t,e){const i=t.headerCount,o=e.exportHiddenColumns?t.columns:t.visibleColumns,n=lE(e);return[...Array(i).keys()].map((e=>o.map((i=>{const o=i.header[e],r={t:o?"s":"z",s:JS};return o&&(o.html?r.h=`<span>${o.label}</span>`:null!=o.label?r.v=o.label:r.t="z"),n&&(r.s||(r.s={}),r.s=Object.assign({},n,r.s)),null!=o._style&&(r.s=Object.assign({},r.s,aE(t.styles.get(o._style)))),r}))))}function rE(t){return{rgb:t}}function sE(t){return{style:t.style,color:rE(t.color)}}function aE(t){const e={};return t.color&&(e.color=rE(t.color)),t.bgColor&&(e.bgColor=rE(t.bgColor)),t.fgColor&&(e.fgColor=rE(t.fgColor)),t.patternType&&(e.patternType=t.patternType),t.alignment&&(e.alignment=t.alignment),null!=t.bold&&(e.bold=t.bold),t.sz&&(e.sz=t.sz),t.bottom&&(e.bottom=sE(t.bottom)),t.top&&(e.top=sE(t.top)),t.right&&(e.right=sE(t.right)),t.left&&(e.left=sE(t.left)),null!=t.angle&&(e.angle=t.angle),t.stops&&(e.stops=t.stops.map((t=>({v:t.v,rgb:t.rgb})))),e}function lE(t){const e=!0===t.defaultBorders?QS:t.defaultBorders;return e?function(t){const e={};return t.bottom&&(e.bottom=sE(t.bottom)),t.top&&(e.top=sE(t.top)),t.right&&(e.right=sE(t.right)),t.left&&(e.left=sE(t.left)),e}(e):null}function cE(t,e){e=gE(e);const i=t.headerCount,o=new tw(t),n=new Array(i+t.rows.length),r=new Map,s=lE(e),a=t.options.dateFormat||"yyyy-MM-dd",l="displayValue"==e.dropdownCells;nE(t,e).forEach(((t,e)=>n[e]=t));const c=e.exportHiddenRows?t.rows:t.visibleRows,h=e.exportHiddenColumns?t.columns:t.visibleColumns;return c.forEach(((t,e)=>n[e+i]=h.map((e=>{const n=t.cell(e.index),c=tE[n.type],h={t:n.hasValue?c:"z"};n.hasFormula?h.f=i>0?o.getFormula(n).clone().shift({index:0,offset:i,direction:"down"}).toExcelString():o?o.getFormula(n).toExcelString():n.formula:n.hasValue&&!n.isSpilled&&("s"==h.t?h.v=l?n.formattedValue.toString():n.value.toString():"z"!=h.t&&(h.v=n.value),"g"==n.type?Z(h.v)?h.t="s":h.t="n":"d"==n.type&&K(h.v)&&(h.t="n",h.z=a));const d=n.composedStyle;if(d&&(r.has(d.id)||r.set(d.id,aE(d)),h.s={...r.get(d.id)}),function(t,e){const i=t.calculatedIndent;i>0&&(e.s||(e.s={}),e.s.alignment||(e.s.alignment={}),e.s.alignment.indent=i)}(n,h),n.hasComment){const t=n.model.comments.get(n.address);h.c=t.filter((t=>(t.text??"").length>0)).map((t=>({a:t.author?t.author.name??t.author.id:"",t:t.text}))),h.c.hidden=!0}return null==h.z&&("n"==h.t?h.z=n.format??"General":"d"==h.t&&(h.z=n.format??a)),"n"!=h.t&&"d"!=h.t||null!=h.z||(h.z=n.format??("d"==h.t?a:"General")),s&&(h.s||(h.s={}),h.s=Object.assign({},s,h.s)),h})))),n}function hE(t,e){return t||e?{t:(t=Object.assign({},e,t)).t,v:t.v,color:rE(t.color)}:null}function dE(t){const e=t.headerCount;return t.conditionalFormats.getSourceData().map((t=>({ref:Jm.fromA1s(t.ranges).map((t=>t.shiftDown(0,e,null,!0).A1)).join(" "),t:t.type,f:t.condition&&Pm(t.condition[0])?"A1"+t.condition:t.condition??null,s:t.style?aE(t.style):null,stop:t.stop,cmin:hE(t.cmin,"bar"==t.type?{t:"min",color:t.color}:null),cmid:t.cmid?hE(t.cmid,{v:50,t:"percentile"}):null,cmax:hE(t.cmax,"bar"==t.type?{t:"max",color:t.color}:null),color:rE(t.color),v:t.v,thresh:t.thresh})))}function uE(t){return null==t.options.rowTree.reversed?t.rows.length<2?"above":t.rows[0].level>t.rows[1].level?"below":"above":t.options.rowTree.reversed?"below":"above"}function pE(t){return null==t.options.columnTree.reversed?t.columns.length<2?"left":t.columns[0].level>t.columns[1].level?"right":"left":t.options.columnTree.reversed?"right":"left"}const gE=t=>{const e=Object.assign({},KS,t);return e.defaultBorders&&(e.defaultBorders=QS),e};function fE(t,e){e=gE(e);const i={};return i["!cols"]=eE(t,e),i["!rows"]=iE(t,e),i["!merges"]=oE(t,e),i["!condfmt"]=dE(t),i["!outline"]={above:"above"==uE(t),left:"left"==pE(t)},t.options.freezeLeft||t.options.freezeTop?i["!freeze"]=`${iv(t.options.freezeLeft)}${t.headerCount+t.options.freezeTop+1}`:t.headerCount>0&&(i["!freeze"]=`A${t.headerCount+1}`),i["!gridlines"]=e.gridLines,i["!print"]={},i}async function mE(t,e){const i=ZS.get(),o=i instanceof Promise?await i:i;e=gE(e);const n=o.utils.book_new();return t.forEach(((t,i)=>{t.calculations.evaluateAll();const r={...e,...t.exportOptions},s=o.utils.sheet_add_aoa(fE(t,r),cE(t,r));let a=t.name||`Sheet${i+1}`;a.length>31&&(a=a.substring(0,31)),o.utils.book_append_sheet(n,s,a)})),n.Workbook=n.Workbook||{},n}async function vE(t,e=null){const i=ZS.get(),o=i instanceof Promise?await i:i;return e?o.writeFile(t,e,{cellStyles:!0,bookSST:!0}):o.writeXLSX(t,{cellStyles:!0,bookSST:!0,type:"buffer"})}const bE={b:"b",s:"t",n:"n",d:"d",z:"g",e:"t"};function yE(t){return t.rgb}function wE(t){return{color:yE(t.color),style:t.style}}function xE(t){const e={};return t.color&&(e.color=yE(t.color)),t.bgColor&&(e.bgColor=yE(t.bgColor)),t.fgColor&&(e.fgColor=yE(t.fgColor)),e.fgColor||"000000"!=e.color||(e.color=null),t.alignment&&(e.alignment=t.alignment),t.bold&&(e.bold=t.bold),t.sz&&(e.sz=t.sz),t.top&&(e.top=wE(t.top)),t.bottom&&(e.bottom=wE(t.bottom)),t.left&&(e.left=wE(t.left)),t.right&&(e.right=wE(t.right)),e}function kE(t,e){const i=t["!ref"]?Jm.fromA1(t["!ref"]):Jm.fromA1("A1:T100"),o={},n={};if(t["!freeze"]){const e=Jm.fromA1(t["!freeze"]);n.freezeLeft=e.c1,n.freezeTop=e.r1}return o.options=n,o.rows=function(t,e){const i=t["!rows"]??[],o=new Array(e);let n;for(let t=0;t<e;t++)n=i[t],o[t]={l:(n?n.level:0)||0,h:n?n.hpx:null};return o}(t,i.r2+1),o.columns=function(t,e){const i=t["!cols"]??[],o=new Array(e);let n;for(let t=0;t<e;t++)n=i[t],o[t]={l:(n?n.level:0)||0,w:n?n.wpx:null};return o}(t,i.c2+1),o.cells=function(t){const e=[],i=new Map;(t["!merges"]??[]).forEach((t=>{const e=new Jm(t.s.c,t.s.r);i.set(e.A1,{c:t.s.c,cs:t.e.c-t.s.c+1,r:t.s.r,rs:t.e.r-t.s.r+1})}));for(const o in t){if("!"==o[0])continue;const n=t[o],r=Jm.fromA1(o),s={r:r.r1,c:r.c1,t:bE[n.t]},a=i.get(o);a&&(s.cs=a.cs,s.rs=a.rs),n.s&&(s.s=xE(n.s)),n.f?s.f=pv(n.f):s.v=n.v,["n","d"].includes(n.t)&&null!=n.z&&"General"!=n.z&&(s.z=Qo(n.z,"d")),e.push(s)}return e}(t),o.names=e,o.rules=function(t){return t["!condfmt"]?.filter((t=>["formula","scale","bar"].includes(t.t))).map((t=>{const e={type:t.t,ranges:t.ref.toString().replace(/\s/g,";")};return e.style=t.s?xE(t.s):null,e.cmin=t.cmin?{t:t.cmin.t,color:t.cmin.color?yE(t.cmin.color):null}:null,e.cmid=t.cmid?{t:t.cmid.t,color:t.cmid.color?yE(t.cmid.color):null}:null,e.cmax=t.cmax?{t:t.cmax.t,color:t.cmax.color?yE(t.cmax.color):null}:null,e.color=t.color?yE(t.color):null,e.condition=t.f,e.stop=!0,e}))}(t),o}function CE(t){const e=new Map;return t.Workbook.Names.forEach((({Name:t,Ref:i})=>{const[o,n]=i.split("!");if(!n)return;let r=e.get(o);r||e.set(o,r=[]);const s=Jm.fromA1(n);s.c1Anchor&&!s.r1Anchor?(s.r1=0,s.r2=1/0):!s.c1Anchor&&s.r1Anchor&&(s.c1=0,s.c2=1/0),s.removeAnchors(),r.push({name:t,ref:s.A1})})),e}async function ME(t,e){return performance.mark("start_import"),SE(await t.arrayBuffer(),e)}function _E(t){const e=CE(t);performance.mark("sheets_start");const i={models:[],layout:{items:[{tabs:[]}]}};for(const o in t.Sheets)performance.mark(`sheet_start_${o}`),i.layout.items[0].tabs.push({id:o}),i.models.push({...kE(t.Sheets[o],e.get(o)),name:o}),performance.mark(`sheet_end_${o}`);return performance.mark("sheets_end"),i}async function SE(t,e){performance.mark("array_buffer");const i=t instanceof ArrayBuffer?new Uint8Array(t):t,o=(await ZS.get()).read(i,Object.assign({cellNF:!0,cellText:!1,cellStyles:!0},e||{}));return performance.mark("wb_read"),_E(o)}class EE extends Mu{init(t){ZS.get(),t.commands.register({section:"plugin",name:"export xlsx",fn:async()=>{const e=t.getGridContainer().model.models;vE(await mE(Array.from(e,(t=>t[1]))),"export.xlsx")}}),t.addEventListener("drop",(async e=>{if(e.preventDefault(),e.dataTransfer.files.length){const i=e.dataTransfer.files[0];t.setSourceData(await ME(i))}}))}}EE.pluginName="xlsx";class zE{get dataRange(){return this._dataRange}set dataRange(t){this._dataRange=t,this.invalidateData()}get seriesRange(){return this._seriesRange}set seriesRange(t){this._seriesRange=t,this.invalidateData()}get categoriesRange(){return this._categoriesRange}set categoriesRange(t){this._categoriesRange=t,this.invalidateData()}get title(){return this._title}set title(t){this._title=t,this.invalidateData()}get size(){return this._size}set size(t){this._size=t}get location(){return this._location}set location(t){this._location=t,this.invalidateData()}get type(){return this._type}set type(t){this._type=t,this.invalidateData()}get grouping(){return this._grouping}set grouping(t){this._grouping=t,this.invalidateData()}get datasheetName(){return this.dataRange?.sheet}get dependencies(){if(this._dependencies)return this._dependencies;if(this._dependencies=new Set,this.seriesRange)for(const t of this.seriesRange.cells())this._dependencies.add(t.A1);if(this.categoriesRange)for(const t of this.categoriesRange.cells())this._dependencies.add(t.A1);if(this.dataRange)for(const t of this.dataRange.cells())this._dependencies.add(t.A1);return this._dependencies}invalidateData(){this._options=void 0,this._dependencies=void 0}constructor(t,e){this.model=t,this._inverted=!1,this.populate(e),this.init()}populate(t){this._dataRange=Jm.fromA1(t.dataRange),this._title=t.title,this._size=t.size,this._location=t.location,this._type=t.type,this._grouping=t.grouping,this.zIndex=t.zIndex,t.seriesRange&&(this._seriesRange=Jm.fromA1(t.seriesRange)),t.categoriesRange&&(this._categoriesRange=Jm.fromA1(t.categoriesRange))}getSourceData(){return{dataRange:this.dataRange.A1,seriesRange:this.seriesRange?.A1,categoriesRange:this.categoriesRange?.A1,title:this.title,size:this.size,location:this.location,type:this.type,grouping:this.grouping,zIndex:this.zIndex}}getSeriesData(t,e){return t.map(((t,i)=>{return{type:this.type,name:e[i],stacking:(o=this.grouping,"stacked"===o?"normal":"percentStacked"===o?"percent":void 0),data:t.map((t=>({y:t})))};var o}))}init(){if(this._options)return this._options;let t,e,i=this.model.getValueMatrix(this.dataRange);this.seriesRange&&(this._inverted=this.seriesRange.isColumn,t=this.model.getValueMatrix(this.seriesRange).flat()),this.categoriesRange&&(this._inverted=this.seriesRange.isRow,e=this.model.getValueMatrix(this.categoriesRange).flat()),this._inverted||(i=Sn(i));const o=i.length,n=i[0].length;return t||(t=Array.from({length:o},((t,e)=>`Series ${e+1}`))),e||(e=Array.from({length:n},((t,e)=>(e+1).toString()))),this._options={plotOptions:{},series:this.getSeriesData(i,t),xAxis:{categories:e}},"pie"==this.type&&(this._options.plotOptions.pie={dataLabels:{enabled:!1},showInLegend:!0},this._options.series[0].data.forEach(((t,i)=>{t.name=e[i]})),this._options.series=[this._options.series[0]]),this._options}getOptions(){return this._options||this.init(),this._options}}class LE extends Mu{constructor(){super(...arguments),this.charts=new Map,this.dependencies=new Map,this.grids=new Set,this.getChartFactory=t=>()=>{const e=gt("og-plugin-chart");return e.model=t,this.charts.set(t.index,e),e},this._onEdit=t=>{const e=this.getAffectedModels(t.grid.model.name,t.cells.map((t=>t.address)));e.forEach((t=>this.charts.get(t)?.refresh()))}}get models(){return this.grid.model.otherModels[LE.pluginName]}getChartByModel(t){return this.charts.get(t.index)}getAffectedModels(t,e){const i=new Set;return e.forEach((e=>{const o=this.dependencies.get(t)?.get(e);o&&o.forEach((t=>i.add(t)))})),Array.from(i)}addModel(t){const e=new zE(this.grid.model,t);e.index=this.models.size;const i=e.datasheetName||this.grid.model.name,o=this.dependencies.get(i)??new Map;if(this.dependencies.set(i,o),null==e.title&&(e.title=`Chart #${this.models.size+1}`),e.dependencies.forEach((t=>{const i=o.get(t)||[];i.push(e.index),o.set(t,i)})),this.models.add(e),this.grid.objects.add({model:e,createComponent:this.getChartFactory(e)}),i){const t=this.grid.getConnectedGrid(i);this.grids.has(t)||(t.addEventListener("grid.edit",this._onEdit),this.grids.add(t))}return e}clear(){this.models.clear(),this.charts=new Map,this.dependencies=new Map}init(t){this.grid=t,t.model.otherModels[LE.pluginName]=new Set,t.addEventListener("grid.loadmodel",(t=>{this.clear(),t.grid.model.otherSourceData.charts&&t.grid.model.otherSourceData.charts.forEach((t=>this.addModel(t)))})),t.addEventListener("grid.edit",this._onEdit),this.grids.add(t)}}LE.pluginName="charts";class RE extends Mu{constructor(){super(...arguments),this._onModelChange=t=>{this.getGridByModel(t.value).plugins.get("charts").getChartByModel(t.value).refresh()},this.openSidebar=()=>this.editor.rightSidebarComponent="charts",this.closeSidebar=()=>this.editor.rightSidebarComponent=null,this.toggleSidebar=(t=null)=>!1===(t??!1)||"charts"==this.editor.rightSidebarComponent?this.closeSidebar():this.openSidebar()}get editor(){return this._editor}getGridByModel(t){return this.editor.group.getGridByModel(t.model)}init(t){this._editor=t;const e=t.createComponent;t.createComponent=t=>"charts"===t?(this.chartList||(this.chartList=gt("og-plugin-chart-list"),this.chartList.addEventListener("change",this._onModelChange)),this.chartList.filter=this._filter,this._filter=null,this.chartList):e?e(t):null,t.addEventListener("editor.toolbar.init",(()=>{const e=t.toolbar.toolbar3Config.slice(),i=e.findIndex((t=>"sparklines"===t.id))||0;e.splice(i,0,{type:"togglebutton",id:"charts",icon:{icon:"chart-column"},title:"Charts"}),t.toolbar.toolbar3Config=e})),t.addEventListener("editor.toolbar.action",(t=>{"charts"===t.action.key&&this.toggleSidebar()})),t.addEventListener("grid.init",(t=>{t.grid.plugins.register(new LE)})),t.addEventListener("grid.object.activate",(t=>{t.object instanceof zE&&(this.openSidebar(),this.chartList?this.chartList.filter=t.object.title:this._filter=t.object.title)})),t.addEventListener("grid.object.deactivate",(()=>{this.chartList&&(this.chartList.filter=null)}))}}RE.pluginName="chartEditor";class IE{static init(t){"string"==typeof t?IE.path=t:IE.highcharts=t}static async get(){return this.highcharts||(this.highcharts=await this.load()),this.highcharts}static getSync(){return this.highcharts}static async load(){if(IE.highcharts)return IE.highcharts;const t=window.define;return window.define=void 0,new Promise(((e,i)=>On.load(`${this.path}/highcharts.js`).then((()=>{window.Highcharts?(IE.highcharts=window.Highcharts,e(window.Highcharts)):i("Failed to load Highcharts")})).catch((t=>{console.error("Failed to load Highcharts",t),i(t)})).then((()=>{window.define=t}))))}}const HE={chart:{styledMode:!0}};async function TE(t){const e=await IE.get(),i={chart:{type:"column",reflow:!1},title:{text:t.title},series:[{type:"column",name:"Corn",data:[387749,28e4,129e3,64300,54e3,34300]},{type:"column",name:"Wheat",data:[45321,14e4,1e4,140500,19500,113500]}]};return e.merge(i,t.getOptions())}async function AE(t,e){const i=await IE.get(),o=await TE(t);return i.chart(e,i.merge(o,HE,{chart:{}}))}const OE=Gn`
6572
+ `],qS([is({type:Object})],YS.prototype,"item",void 0),qS([is({type:String})],YS.prototype,"value",void 0),qS([rs("og-dropdown")],YS.prototype,"dropdown",void 0),qS([rs("#btnContent")],YS.prototype,"btnContent",void 0),YS=qS([Jr("og-toolbar-colorpicker")],YS);class ZS{static init(t){this.path=t}static async get(){return this.xlsx||(this.xlsx=await this.load()),this.xlsx}static getSync(){return this.xlsx}static load(){if(!An.require)throw new Error("AMDLoader is not initialized");return An.require.config({paths:{xlsx:this.path+"/xlsx.full.min"}}),new Promise((t=>An.require(["xlsx"],(()=>t(self.XLSX)))))}}const XS="aaaaaa",QS={bottom:{style:"thin",color:XS},top:{style:"thin",color:XS},right:{style:"thin",color:XS},left:{style:"thin",color:XS}},KS={exportHiddenRows:!0,exportHiddenColumns:!0,gridLines:!0,defaultBorders:!1,dropdownCells:"value"},JS={alignment:{vertical:"center",horizontal:"center"},bold:!0},tE={g:"n",b:"b",t:"s",n:"n",d:"d",dt:"d",s:"s",m:"s",tm:"s",h:"s",a:"z"};function eE(t,e){return(e.exportHiddenColumns?t.columns:t.visibleColumns).map((e=>({level:e.level,wpx:e.width,hidden:null==e.visibleIndex||t.visibleColumns[e.visibleIndex]!=e})))}function iE(t,e){const i=e.exportHiddenRows?t.rows:t.visibleRows,o=t.headerCount,n=new Array(i.length+o);return[...Array(o).keys()].map((t=>n[t]={level:0})),i.map(((e,i)=>n[i+o]={level:e.level,hpt:.75*e.height,hidden:null==e.visibleIndex||t.visibleRows[e.visibleIndex]!=e})),n}function oE(t,e){const i=t.headerCount,o=e.exportHiddenColumns?t=>t.c:e=>t.columns[e.c].visibleIndex,n=t.hiddenCells,r=[];return t.mergedCells.forEach((t=>{n.get(t.r)?.get(t.c)||r.push({s:{c:o(t),r:t.r+i},e:{c:o(t)+t.cs-1,r:t.r+i+t.rs-1}})})),t.mergedHeaders.forEach((t=>{t.h?.hidden||r.push({s:{c:o(t),r:t.r},e:{c:o(t)+t.cs-1,r:t.r+t.rs-1}})})),r}function nE(t,e){const i=t.headerCount,o=e.exportHiddenColumns?t.columns:t.visibleColumns,n=lE(e);return[...Array(i).keys()].map((e=>o.map((i=>{const o=i.header[e],r={t:o?"s":"z",s:JS};return o&&(o.html?r.h=`<span>${o.label}</span>`:null!=o.label?r.v=o.label:r.t="z"),n&&(r.s||(r.s={}),r.s=Object.assign({},n,r.s)),null!=o._style&&(r.s=Object.assign({},r.s,aE(t.styles.get(o._style)))),r}))))}function rE(t){return{rgb:t}}function sE(t){return{style:t.style,color:rE(t.color)}}function aE(t){const e={};return t.color&&(e.color=rE(t.color)),t.bgColor&&(e.bgColor=rE(t.bgColor)),t.fgColor&&(e.fgColor=rE(t.fgColor)),t.patternType&&(e.patternType=t.patternType),t.alignment&&(e.alignment=t.alignment),null!=t.bold&&(e.bold=t.bold),t.sz&&(e.sz=t.sz),t.bottom&&(e.bottom=sE(t.bottom)),t.top&&(e.top=sE(t.top)),t.right&&(e.right=sE(t.right)),t.left&&(e.left=sE(t.left)),null!=t.angle&&(e.angle=t.angle),t.stops&&(e.stops=t.stops.map((t=>({v:t.v,rgb:t.rgb})))),e}function lE(t){const e=!0===t.defaultBorders?QS:t.defaultBorders;return e?function(t){const e={};return t.bottom&&(e.bottom=sE(t.bottom)),t.top&&(e.top=sE(t.top)),t.right&&(e.right=sE(t.right)),t.left&&(e.left=sE(t.left)),e}(e):null}function cE(t,e){e=gE(e);const i=t.headerCount,o=new tw(t),n=new Array(i+t.rows.length),r=new Map,s=lE(e),a=t.options.dateFormat||"yyyy-MM-dd",l="displayValue"==e.dropdownCells;nE(t,e).forEach(((t,e)=>n[e]=t));const c=e.exportHiddenRows?t.rows:t.visibleRows,h=e.exportHiddenColumns?t.columns:t.visibleColumns;return c.forEach(((t,e)=>n[e+i]=h.map((e=>{const n=t.cell(e.index),c=tE[n.type],h={t:n.hasValue?c:"z"};n.hasFormula?h.f=i>0?o.getFormula(n).clone().shift({index:0,offset:i,direction:"down"}).toExcelString():o?o.getFormula(n).toExcelString():n.formula:n.hasValue&&!n.isSpilled&&("s"==h.t?h.v=l?n.formattedValue.toString():n.value.toString():"z"!=h.t&&(h.v=n.value),"g"==n.type?Z(h.v)?h.t="s":h.t="n":"d"==n.type&&K(h.v)&&(h.t="n",h.z=a));const d=n.composedStyle;if(d&&(r.has(d.id)||r.set(d.id,aE(d)),h.s={...r.get(d.id)}),function(t,e){const i=t.calculatedIndent;i>0&&(e.s||(e.s={}),e.s.alignment||(e.s.alignment={}),e.s.alignment.indent=i)}(n,h),n.hasComment){const t=n.model.comments.get(n.address);h.c=t.filter((t=>(t.text??"").length>0)).map((t=>({a:t.author?t.author.name??t.author.id:"",t:t.text}))),h.c.hidden=!0}return null==h.z&&("n"==h.t?h.z=n.format??"General":"d"==h.t&&(h.z=n.format??a)),"n"!=h.t&&"d"!=h.t||null!=h.z||(h.z=n.format??("d"==h.t?a:"General")),s&&(h.s||(h.s={}),h.s=Object.assign({},s,h.s)),h})))),n}function hE(t,e){return t||e?{t:(t=Object.assign({},e,t)).t,v:t.v,color:rE(t.color)}:null}function dE(t){const e=t.headerCount;return t.conditionalFormats.getSourceData().map((t=>({ref:Jm.fromA1s(t.ranges).map((t=>t.shiftDown(0,e,null,!0).A1)).join(" "),t:t.type,f:t.condition&&Pm(t.condition[0])?"A1"+t.condition:t.condition??null,s:t.style?aE(t.style):null,stop:t.stop,cmin:hE(t.cmin,"bar"==t.type?{t:"min",color:t.color}:null),cmid:t.cmid?hE(t.cmid,{v:50,t:"percentile"}):null,cmax:hE(t.cmax,"bar"==t.type?{t:"max",color:t.color}:null),color:rE(t.color),v:t.v,thresh:t.thresh})))}function uE(t){return null==t.options.rowTree.reversed?t.rows.length<2?"above":t.rows[0].level>t.rows[1].level?"below":"above":t.options.rowTree.reversed?"below":"above"}function pE(t){return null==t.options.columnTree.reversed?t.columns.length<2?"left":t.columns[0].level>t.columns[1].level?"right":"left":t.options.columnTree.reversed?"right":"left"}const gE=t=>{const e=Object.assign({},KS,t);return e.defaultBorders&&(e.defaultBorders=QS),e};function fE(t,e){e=gE(e);const i={};return i["!cols"]=eE(t,e),i["!rows"]=iE(t,e),i["!merges"]=oE(t,e),i["!condfmt"]=dE(t),i["!outline"]={above:"above"==uE(t),left:"left"==pE(t)},t.options.freezeLeft||t.options.freezeTop?i["!freeze"]=`${iv(t.options.freezeLeft)}${t.headerCount+t.options.freezeTop+1}`:t.headerCount>0&&(i["!freeze"]=`A${t.headerCount+1}`),i["!gridlines"]=e.gridLines,i["!print"]={},i}async function mE(t,e){const i=ZS.get(),o=i instanceof Promise?await i:i;e=gE(e);const n=o.utils.book_new();return t.forEach(((t,i)=>{t.calculations.evaluateAll();const r={...e,...t.exportOptions},s=o.utils.sheet_add_aoa(fE(t,r),cE(t,r));let a=t.name||`Sheet${i+1}`;a.length>31&&(a=a.substring(0,31)),o.utils.book_append_sheet(n,s,a)})),n.Workbook=n.Workbook||{},n}async function vE(t,e=null){const i=ZS.get(),o=i instanceof Promise?await i:i;return e?o.writeFile(t,e,{cellStyles:!0,bookSST:!0}):o.writeXLSX(t,{cellStyles:!0,bookSST:!0,type:"buffer"})}const bE={b:"b",s:"t",n:"n",d:"d",z:"g",e:"t"};function yE(t){return t.rgb}function wE(t){return{color:yE(t.color),style:t.style}}function xE(t){const e={};return t.color&&(e.color=yE(t.color)),t.bgColor&&(e.bgColor=yE(t.bgColor)),t.fgColor&&(e.fgColor=yE(t.fgColor)),e.fgColor||"000000"!=e.color||(e.color=null),t.alignment&&(e.alignment=t.alignment),t.bold&&(e.bold=t.bold),t.sz&&(e.sz=t.sz),t.top&&(e.top=wE(t.top)),t.bottom&&(e.bottom=wE(t.bottom)),t.left&&(e.left=wE(t.left)),t.right&&(e.right=wE(t.right)),e}function kE(t,e){const i=t["!ref"]?Jm.fromA1(t["!ref"]):Jm.fromA1("A1:T100"),o={},n={};if(t["!freeze"]){const e=Jm.fromA1(t["!freeze"]);n.freezeLeft=e.c1,n.freezeTop=e.r1}return o.options=n,o.rows=function(t,e){const i=t["!rows"]??[],o=new Array(e);let n;for(let t=0;t<e;t++)n=i[t],o[t]={l:(n?n.level:0)||0,h:n?n.hpx:null};return o}(t,i.r2+1),o.columns=function(t,e){const i=t["!cols"]??[],o=new Array(e);let n;for(let t=0;t<e;t++)n=i[t],o[t]={l:(n?n.level:0)||0,w:n?n.wpx:null};return o}(t,i.c2+1),o.cells=function(t){const e=[],i=new Map;(t["!merges"]??[]).forEach((t=>{const e=new Jm(t.s.c,t.s.r);i.set(e.A1,{c:t.s.c,cs:t.e.c-t.s.c+1,r:t.s.r,rs:t.e.r-t.s.r+1})}));for(const o in t){if("!"==o[0])continue;const n=t[o],r=Jm.fromA1(o),s={r:r.r1,c:r.c1,t:bE[n.t]},a=i.get(o);a&&(s.cs=a.cs,s.rs=a.rs),n.s&&(s.s=xE(n.s)),n.f?s.f=pv(n.f):s.v=n.v,["n","d"].includes(n.t)&&null!=n.z&&"General"!=n.z&&(s.z=Qo(n.z,"d")),e.push(s)}return e}(t),o.names=e,o.rules=function(t){return t["!condfmt"]?.filter((t=>["formula","scale","bar"].includes(t.t))).map((t=>{const e={type:t.t,ranges:t.ref.toString().replace(/\s/g,";")};return e.style=t.s?xE(t.s):null,e.cmin=t.cmin?{t:t.cmin.t,color:t.cmin.color?yE(t.cmin.color):null}:null,e.cmid=t.cmid?{t:t.cmid.t,color:t.cmid.color?yE(t.cmid.color):null}:null,e.cmax=t.cmax?{t:t.cmax.t,color:t.cmax.color?yE(t.cmax.color):null}:null,e.color=t.color?yE(t.color):null,e.condition=t.f,e.stop=!0,e}))}(t),o}function CE(t){const e=new Map;return t.Workbook.Names.forEach((({Name:t,Ref:i})=>{const[o,n]=i.split("!");if(!n)return;let r=e.get(o);r||e.set(o,r=[]);const s=Jm.fromA1(n);s.c1Anchor&&!s.r1Anchor?(s.r1=0,s.r2=1/0):!s.c1Anchor&&s.r1Anchor&&(s.c1=0,s.c2=1/0),s.removeAnchors(),r.push({name:t,ref:s.A1})})),e}async function ME(t,e){return performance.mark("start_import"),SE(await t.arrayBuffer(),e)}function _E(t){const e=CE(t);performance.mark("sheets_start");const i={models:[],layout:{items:[{tabs:[]}]}};for(const o in t.Sheets)performance.mark(`sheet_start_${o}`),i.layout.items[0].tabs.push({id:o}),i.models.push({...kE(t.Sheets[o],e.get(o)),name:o}),performance.mark(`sheet_end_${o}`);return performance.mark("sheets_end"),i}async function SE(t,e){performance.mark("array_buffer");const i=t instanceof ArrayBuffer?new Uint8Array(t):t,o=(await ZS.get()).read(i,Object.assign({cellNF:!0,cellText:!1,cellStyles:!0,type:"buffer"},e||{}));return performance.mark("wb_read"),_E(o)}class EE extends Mu{init(t){ZS.get(),t.commands.register({section:"plugin",name:"export xlsx",fn:async()=>{const e=t.getGridContainer().model.models;vE(await mE(Array.from(e,(t=>t[1]))),"export.xlsx")}}),t.addEventListener("drop",(async e=>{if(e.preventDefault(),e.dataTransfer.files.length){const i=e.dataTransfer.files[0];t.setSourceData(await ME(i))}}))}}EE.pluginName="xlsx";class zE{get dataRange(){return this._dataRange}set dataRange(t){this._dataRange=t,this.invalidateData()}get seriesRange(){return this._seriesRange}set seriesRange(t){this._seriesRange=t,this.invalidateData()}get categoriesRange(){return this._categoriesRange}set categoriesRange(t){this._categoriesRange=t,this.invalidateData()}get title(){return this._title}set title(t){this._title=t,this.invalidateData()}get size(){return this._size}set size(t){this._size=t}get location(){return this._location}set location(t){this._location=t,this.invalidateData()}get type(){return this._type}set type(t){this._type=t,this.invalidateData()}get grouping(){return this._grouping}set grouping(t){this._grouping=t,this.invalidateData()}get datasheetName(){return this.dataRange?.sheet}get dependencies(){if(this._dependencies)return this._dependencies;if(this._dependencies=new Set,this.seriesRange)for(const t of this.seriesRange.cells())this._dependencies.add(t.A1);if(this.categoriesRange)for(const t of this.categoriesRange.cells())this._dependencies.add(t.A1);if(this.dataRange)for(const t of this.dataRange.cells())this._dependencies.add(t.A1);return this._dependencies}invalidateData(){this._options=void 0,this._dependencies=void 0}constructor(t,e){this.model=t,this._inverted=!1,this.populate(e),this.init()}populate(t){this._dataRange=Jm.fromA1(t.dataRange),this._title=t.title,this._size=t.size,this._location=t.location,this._type=t.type,this._grouping=t.grouping,this.zIndex=t.zIndex,t.seriesRange&&(this._seriesRange=Jm.fromA1(t.seriesRange)),t.categoriesRange&&(this._categoriesRange=Jm.fromA1(t.categoriesRange))}getSourceData(){return{dataRange:this.dataRange.A1,seriesRange:this.seriesRange?.A1,categoriesRange:this.categoriesRange?.A1,title:this.title,size:this.size,location:this.location,type:this.type,grouping:this.grouping,zIndex:this.zIndex}}getSeriesData(t,e){return t.map(((t,i)=>{return{type:this.type,name:e[i],stacking:(o=this.grouping,"stacked"===o?"normal":"percentStacked"===o?"percent":void 0),data:t.map((t=>({y:t})))};var o}))}init(){if(this._options)return this._options;let t,e,i=this.model.getValueMatrix(this.dataRange);this.seriesRange&&(this._inverted=this.seriesRange.isColumn,t=this.model.getValueMatrix(this.seriesRange).flat()),this.categoriesRange&&(this._inverted=this.seriesRange.isRow,e=this.model.getValueMatrix(this.categoriesRange).flat()),this._inverted||(i=Sn(i));const o=i.length,n=i[0].length;return t||(t=Array.from({length:o},((t,e)=>`Series ${e+1}`))),e||(e=Array.from({length:n},((t,e)=>(e+1).toString()))),this._options={plotOptions:{},series:this.getSeriesData(i,t),xAxis:{categories:e}},"pie"==this.type&&(this._options.plotOptions.pie={dataLabels:{enabled:!1},showInLegend:!0},this._options.series[0].data.forEach(((t,i)=>{t.name=e[i]})),this._options.series=[this._options.series[0]]),this._options}getOptions(){return this._options||this.init(),this._options}}class LE extends Mu{constructor(){super(...arguments),this.charts=new Map,this.dependencies=new Map,this.grids=new Set,this.getChartFactory=t=>()=>{const e=gt("og-plugin-chart");return e.model=t,this.charts.set(t.index,e),e},this._onEdit=t=>{const e=this.getAffectedModels(t.grid.model.name,t.cells.map((t=>t.address)));e.forEach((t=>this.charts.get(t)?.refresh()))}}get models(){return this.grid.model.otherModels[LE.pluginName]}getChartByModel(t){return this.charts.get(t.index)}getAffectedModels(t,e){const i=new Set;return e.forEach((e=>{const o=this.dependencies.get(t)?.get(e);o&&o.forEach((t=>i.add(t)))})),Array.from(i)}addModel(t){const e=new zE(this.grid.model,t);e.index=this.models.size;const i=e.datasheetName||this.grid.model.name,o=this.dependencies.get(i)??new Map;if(this.dependencies.set(i,o),null==e.title&&(e.title=`Chart #${this.models.size+1}`),e.dependencies.forEach((t=>{const i=o.get(t)||[];i.push(e.index),o.set(t,i)})),this.models.add(e),this.grid.objects.add({model:e,createComponent:this.getChartFactory(e)}),i){const t=this.grid.getConnectedGrid(i);this.grids.has(t)||(t.addEventListener("grid.edit",this._onEdit),this.grids.add(t))}return e}clear(){this.models.clear(),this.charts=new Map,this.dependencies=new Map}init(t){this.grid=t,t.model.otherModels[LE.pluginName]=new Set,t.addEventListener("grid.loadmodel",(t=>{this.clear(),t.grid.model.otherSourceData.charts&&t.grid.model.otherSourceData.charts.forEach((t=>this.addModel(t)))})),t.addEventListener("grid.edit",this._onEdit),this.grids.add(t)}}LE.pluginName="charts";class RE extends Mu{constructor(){super(...arguments),this._onModelChange=t=>{this.getGridByModel(t.value).plugins.get("charts").getChartByModel(t.value).refresh()},this.openSidebar=()=>this.editor.rightSidebarComponent="charts",this.closeSidebar=()=>this.editor.rightSidebarComponent=null,this.toggleSidebar=(t=null)=>!1===(t??!1)||"charts"==this.editor.rightSidebarComponent?this.closeSidebar():this.openSidebar()}get editor(){return this._editor}getGridByModel(t){return this.editor.group.getGridByModel(t.model)}init(t){this._editor=t;const e=t.createComponent;t.createComponent=t=>"charts"===t?(this.chartList||(this.chartList=gt("og-plugin-chart-list"),this.chartList.addEventListener("change",this._onModelChange)),this.chartList.filter=this._filter,this._filter=null,this.chartList):e?e(t):null,t.addEventListener("editor.toolbar.init",(()=>{const e=t.toolbar.toolbar3Config.slice(),i=e.findIndex((t=>"sparklines"===t.id))||0;e.splice(i,0,{type:"togglebutton",id:"charts",icon:{icon:"chart-column"},title:"Charts"}),t.toolbar.toolbar3Config=e})),t.addEventListener("editor.toolbar.action",(t=>{"charts"===t.action.key&&this.toggleSidebar()})),t.addEventListener("grid.init",(t=>{t.grid.plugins.register(new LE)})),t.addEventListener("grid.object.activate",(t=>{t.object instanceof zE&&(this.openSidebar(),this.chartList?this.chartList.filter=t.object.title:this._filter=t.object.title)})),t.addEventListener("grid.object.deactivate",(()=>{this.chartList&&(this.chartList.filter=null)}))}}RE.pluginName="chartEditor";class IE{static init(t){"string"==typeof t?IE.path=t:IE.highcharts=t}static async get(){return this.highcharts||(this.highcharts=await this.load()),this.highcharts}static getSync(){return this.highcharts}static async load(){if(IE.highcharts)return IE.highcharts;const t=window.define;return window.define=void 0,new Promise(((e,i)=>On.load(`${this.path}/highcharts.js`).then((()=>{window.Highcharts?(IE.highcharts=window.Highcharts,e(window.Highcharts)):i("Failed to load Highcharts")})).catch((t=>{console.error("Failed to load Highcharts",t),i(t)})).then((()=>{window.define=t}))))}}const HE={chart:{styledMode:!0}};async function TE(t){const e=await IE.get(),i={chart:{type:"column",reflow:!1},title:{text:t.title},series:[{type:"column",name:"Corn",data:[387749,28e4,129e3,64300,54e3,34300]},{type:"column",name:"Wheat",data:[45321,14e4,1e4,140500,19500,113500]}]};return e.merge(i,t.getOptions())}async function AE(t,e){const i=await IE.get(),o=await TE(t);return i.chart(e,i.merge(o,HE,{chart:{}}))}const OE=Gn`
6573
6573
  * {
6574
6574
  box-sizing: border-box;
6575
6575
  }
@@ -7919,4 +7919,4 @@ milkdown-block-handle {
7919
7919
  `:null}
7920
7920
  </div>
7921
7921
  </og-panel>
7922
- `:null,this.addEventListener("mousedown",(t=>t.stopPropagation()))}getTypeIndex(t){const e=this.types.findIndex((e=>e.type==t.type&&e.grouping==(t.grouping||"standard")));return e>-1?e:null}updateModel(){if(this.editTitle=!1,!this.model)return;this.titleInput&&(this.model.title=this.titleInput.value);const t=this.types[this.typeList.value];this.model.type=t.type,this.model.grouping=t.grouping,this.model.categoriesRange=this.categoryRangeInput?.value?Jm.fromA1(this.categoryRangeInput.value):null,this.model.seriesRange=this.seriesRangeInput?.value?Jm.fromA1(this.seriesRangeInput.value):null,this.model.dataRange=Jm.fromA1(this.dataRangeInput.value),this.dispatchEvent(new zn({value:this.model}))}async updated(){this.editTitle&&this.titleInput&&(await this.titleInput.updateComplete,this.titleInput.focus(),this.titleInput.selectAll())}};WE.styles=[BE],FE([is({type:Object})],WE.prototype,"model",void 0),FE([os()],WE.prototype,"editTitle",void 0),FE([rs("#title")],WE.prototype,"titleInput",void 0),FE([rs("#type")],WE.prototype,"typeList",void 0),FE([rs("#dataRange")],WE.prototype,"dataRangeInput",void 0),FE([rs("#seriesRange")],WE.prototype,"seriesRangeInput",void 0),FE([rs("#categoryRange")],WE.prototype,"categoryRangeInput",void 0),WE=FE([Jr("og-plugin-chart-form")],WE);const UE=ca().themes.get("dark");Object.assign(UE.definition,{"highcharts-title-font-size":"16px","highcharts-subtitle-font-size":"14px","highcharts-color-0":"#2caffe","highcharts-color-1":"#544fc5","highcharts-color-2":"#00e272","highcharts-color-3":"#fe6a35","highcharts-color-4":"#6b8abc","highcharts-color-5":"#d568fb","highcharts-color-6":"#2ee0ca","highcharts-color-7":"#fa4b42","highcharts-color-8":"#feb56a","highcharts-color-9":"#91e8e1","highcharts-background-color":"rgb(48, 48, 48)","highcharts-neutral-color-100":"rgb(255, 255, 255)","highcharts-neutral-color-80":"rgb(214, 214, 214)","highcharts-neutral-color-60":"rgb(173, 173, 173)","highcharts-neutral-color-40":"rgb(133, 133, 133)","highcharts-neutral-color-20":"rgb(92, 92, 92)","highcharts-neutral-color-10":"rgb(71, 71, 71)","highcharts-neutral-color-5":"rgb(61, 61, 61)","highcharts-neutral-color-3":"rgb(57, 57, 57)","highcharts-highlight-color-100":"rgb(122, 167, 255)","highcharts-highlight-color-80":"rgb(108, 144, 214)","highcharts-highlight-color-60":"rgb(94, 121, 173)","highcharts-highlight-color-20":"rgb(65, 74, 92)","highcharts-highlight-color-10":"rgb(58, 63, 71)"});const GE=ca().themes.get("light");Object.assign(GE.definition,{"highcharts-title-font-size":"16px","chart-background-color":"#2a2a2b","highcharts-color-0":"#2caffe","highcharts-color-1":"#544fc5","highcharts-color-2":"#00e272","highcharts-color-3":"#fe6a35","highcharts-color-4":"#6b8abc","highcharts-color-5":"#d568fb","highcharts-color-6":"#2ee0ca","highcharts-color-7":"#fa4b42","highcharts-color-8":"#feb56a","highcharts-color-9":"#91e8e1","highcharts-background-color":"#ffffff","highcharts-neutral-color-100":"#000000","highcharts-neutral-color-80":"#333333","highcharts-neutral-color-60":"#666666","highcharts-neutral-color-40":"#999999","highcharts-neutral-color-20":"#cccccc","highcharts-neutral-color-10":"#e6e6e6","highcharts-neutral-color-5":"#f2f2f2","highcharts-neutral-color-3":"#f7f7f7","highcharts-highlight-color-100":"#0022ff","highcharts-highlight-color-80":"#334eff","highcharts-highlight-color-60":"#667aff","highcharts-highlight-color-20":"#ccd3ff","highcharts-highlight-color-10":"#e6e9ff","highcharts-positive-color":"#06b535","highcharts-negative-color":"#f21313","highcharts-annotation-color-0":"rgba(130, 170, 255, 0.4)","highcharts-annotation-color-1":"rgba(139, 191, 216, 0.4)","highcharts-annotation-color-2":"rgba(150, 216, 192, 0.4)","highcharts-annotation-color-3":"rgba(156, 229, 161, 0.4)","highcharts-annotation-color-4":"rgba(162, 241, 130, 0.4)","highcharts-annotation-color-5":"rgba(169, 255, 101, 0.4)"});var qE=i(2439),YE=i(8022),ZE=i(6158),XE=i(127),QE=i(4505),KE=i(8659),JE=i(397),tz=i(930),ez=i(9723),iz=i(6343),oz=i(4582),nz=i(6127),rz=i(8238),sz=i(7362),az=i(452),lz=i(5390),cz=i(3368),hz=i(6288),dz=i(7513),uz=i(1386),pz=i(5764),gz=i(1261),fz=i(3071),mz=i(3285),vz=i(2356),bz=i(6780),yz=i(8542),wz=i(8385),xz=i(1025),kz=i(2034),Cz=i(8113),Mz=i(1821),_z=i(7212),Sz=i(2583),Ez=i(5360),zz=i(2377),Lz=i(2864),Rz=i(7998),Iz=i(4101),Hz=i(7813),Tz=i(5037),Az=i(7005),Oz=i(9626),$z=i(9517),Dz=i(1504),Nz=i(3838),Pz=i(4935),jz=i(7699),Vz=i(3322),Bz=i(5757),Fz=i(536),Wz=i(1673),Uz=i(8736),Gz=i(196),qz=i(5133),Yz=i(6092),Zz=i(791),Xz=i(5927),Qz=i(1802),Kz=i(9511),Jz=i(6267),tL=i(1072),eL=i(4331),iL=i(8644),oL=i(2704),nL=i(2419),rL=i(6363),sL=i(5236),aL=i(3499),lL=i(3811),cL=i(1953),hL=i(4729),dL=i(8964),uL=i(8540),pL=i(8752),gL=i(8783),fL=i(8270),mL=i(7261),vL=i(9231),bL=i(4555),yL=i(5293),wL=i(6981),xL=i(5268),kL=i(2680),CL=i(789),ML=i(4373),_L=i(436),SL=i(8573),EL=i(1808),zL=i(3247),LL=i(5143),RL=i(2415),IL=i(2561),HL=i(5726),TL=i(7436),AL=i(4201),OL=i(8248),$L=i(6433),DL=i(2698),NL=i(979),PL=i(9358),jL=i(9176),VL=i(1239),BL=i(4218),FL=i(8377),WL=i(3740),UL=i(5379),GL=i(9974),qL=i(8955),YL=i(3559),ZL=i(809),XL=i(8014),QL=i(8265),KL=i(3300),JL=i(8724),tR=i(8033),eR=i(7700),iR=i(5741),oR=i(3478),nR=i(512),rR=i(9432),sR=i(2841),aR=i(75),lR=i(9256),cR=i(444),hR=i(5633),dR=i(3788),uR=i(3573),pR=i(9948),gR=i(1836),fR=i(7029),mR=i(8532),vR=i(6639),bR=i(1633),yR=i(9805),wR=i(2171),xR=i(875),kR=i(9595),CR=i(3894),MR=i(2803),_R=i(7765),SR=i(8804),ER=i(8654),zR=i(257),LR=i(5844),RR=i(9651),IR=i(760),HR=i(9518),TR=i(4585),AR=i(1769),OR=i(643),$R=i(5156),DR=i(822),NR=i(8249),PR=i(3434),jR=i(9314),VR=i(3093),BR=i(7721),FR=i(588),WR=i(7645),UR=i(7148),GR=i(6795),qR=i(7047),YR=i(9428),ZR=i(1879),XR=i(9779),QR=i(2476),KR=i(9648),JR=i(2896),tI=i(6817),eI=i(5196),iI=i(2762),oI=i(5981),nI=i(9014),rI=i(2611),sI=i(7946),aI=i(6301),lI=i(8020),cI=i(3987),hI=i(3192),dI=i(8796),uI=i(2489),pI=i(7324),gI=i(6069),fI=i(4155),mI=i(6977),vI=i(8055),bI=i(2653),yI=i(9492),wI=i(4334),xI=i(6804),kI=i(9954),CI=i(2211),MI=i(5211),_I=i(1519),SI=i(6204),EI=i(5501),zI=i(5244),LI=i(9742),RI=i(1552),II=i(1330),HI=i(2596),TI=i(5184),AI=i(7675),OI=i(1513),$I=i(9396),DI=i(7673),NI=i(244),PI=i(1187),jI=i(1736),VI=i(4390),BI=i(7106),FI=i(2096),WI=i(9991),UI=i(5629),GI=i(3386),qI=i(6651),YI=i(1684),ZI=i(3849),XI=i(2582),QI=i(8569),KI=i(2955),JI=i(9100),tH=i(7381),eH=i(9190),iH=i(4071),oH=i(8e3),nH=i(4633),rH=i(4374),sH=i(486),aH=i(3680),lH=i(9999),cH=i(2830),hH=i(5255),dH=i(6021),uH=i(2214),pH=i(8497),gH=i(2052),fH=i(5327),mH=i(8701);const vH=[qE.w2,YE.Jt,ZE.Xk,XE.Wz,QE.UR,KE.mR,JE.cb,tz.td,ez.GF,oz.xB,iz.S$,nz.Ot,rz.fU,sz.Vp,az.HV,lz.BH,cz.Dn,hz.hy,dz.IP,uz.Nf,pz.jP,gz.AP,fz._X,mz.mu,vz.LB,bz.hS,yz.l5,wz.SI,xz.ch,Cz._u,Mz.ec,_z.jb,Sz.cW,Ez.$f,zz.qI,Lz.j3,Rz.fq,Iz.ao,Hz.Uj,Tz.GE,Az.QR,Oz.DQ,Dz.lE,$z.mE,Nz.hp,Pz.yL,jz.ub,Vz.lL,Bz.IN,Fz.B0,Wz.Ce,Uz.dm,Gz.h0,qz.sx,Yz.HF,Zz.qf,Qz.jw,Kz.k8,Jz.Am,tL.ff,eL.s6,iL.bx,oL.pS,nL.k6,rL.q9,sL.$F,aL.gK,lL.W1,cL.QL,hL.EZ,dL.DN,uL.Jy,pL.z1,gL.Gl,fL.n2,Xz.Ew,mL.QL,vL.ck,bL.I2,yL.Qv,wL.CK,xL.bn,kL.bx,CL.e6,ML.yy,_L.xg,SL.AJ,EL.py,zL.I0,LL.id,RL.qp,IL.UX,HL.PA,TL.B2,AL.It,OL.PZ,$L.aG,DL.$U,NL.S9,PL.Nb,jL.Z4,VL.qz,BL.jw,FL.cd,WL.jR,UL.qt,GL.x7,qL.oE,YL.ad,ZL.IT,XL.Ts,QL.UN,KL.jb,JL.jT,tR.w9,eR.Jm,iR.CQ,kz.$6,oR.Dw,nR.nx,rR.w2,sR.Jt,aR.Xk,lR.Wz,cR.UR,hR.mR,dR.cb,uR.td,pR.GF,fR.xB,gR.S$,vR.fU,mR.Ot,bR.Vp,yR.HV,wR.BH,xR.Dn,kR.hy,CR.IP,MR.Nf,_R.jP,SR.AP,IR._X,HR.mu,TR.LB,AR.hS,OR.l5,$R.SI,DR.ch,PR._u,jR.ec,VR.jb,GR.cW,qR.$f,YR.qI,ZR.j3,XR.fq,QR.ao,KR.Uj,JR.GE,ER.QR,zR.DQ,RR.lE,LR.mE,tI.hp,eI.yL,iI.ub,oI.lL,nI.IN,rI.B0,sI.Ce,aI.dm,BR.h0,FR.sx,WR.HF,UR.qf,cI.jw,hI.k8,dI.Am,uI.ff,pI.s6,gI.bx,fI.pS,mI.k6,vI.q9,bI.$F,yI.gK,wI.W1,xI.QL,kI.EZ,CI.DN,MI.Jy,_I.z1,SI.Gl,EI.n2,lI.Ew,zI.QL,LI.ck,RI.I2,II.Qv,HI.CK,TI.bn,AI.bx,OI.e6,$I.yy,DI.xg,NI.AJ,PI.py,jI.I0,VI.id,BI.qp,FI.UX,WI.PA,UI.B2,GI.It,qI.PZ,YI.aG,ZI.$U,XI.S9,QI.Nb,KI.Z4,JI.qz,tH.jw,eH.cd,iH.jR,oH.qt,nH.x7,rH.oE,sH.ad,aH.IT,lH.Ts,cH.UN,hH.jb,dH.jT,uH.w9,pH.Jm,gH.CQ,NR.$6,fH.Dw,mH.nx],bH={xlsx:P,charts:j},yH={name:"@omegagrid/bundle",version:"0.6.1"};ca().activate("light"),Lh.styleDefault="fal",Rh.add(...vH)})(),window.Omegagrid=o})();
7922
+ `:null,this.addEventListener("mousedown",(t=>t.stopPropagation()))}getTypeIndex(t){const e=this.types.findIndex((e=>e.type==t.type&&e.grouping==(t.grouping||"standard")));return e>-1?e:null}updateModel(){if(this.editTitle=!1,!this.model)return;this.titleInput&&(this.model.title=this.titleInput.value);const t=this.types[this.typeList.value];this.model.type=t.type,this.model.grouping=t.grouping,this.model.categoriesRange=this.categoryRangeInput?.value?Jm.fromA1(this.categoryRangeInput.value):null,this.model.seriesRange=this.seriesRangeInput?.value?Jm.fromA1(this.seriesRangeInput.value):null,this.model.dataRange=Jm.fromA1(this.dataRangeInput.value),this.dispatchEvent(new zn({value:this.model}))}async updated(){this.editTitle&&this.titleInput&&(await this.titleInput.updateComplete,this.titleInput.focus(),this.titleInput.selectAll())}};WE.styles=[BE],FE([is({type:Object})],WE.prototype,"model",void 0),FE([os()],WE.prototype,"editTitle",void 0),FE([rs("#title")],WE.prototype,"titleInput",void 0),FE([rs("#type")],WE.prototype,"typeList",void 0),FE([rs("#dataRange")],WE.prototype,"dataRangeInput",void 0),FE([rs("#seriesRange")],WE.prototype,"seriesRangeInput",void 0),FE([rs("#categoryRange")],WE.prototype,"categoryRangeInput",void 0),WE=FE([Jr("og-plugin-chart-form")],WE);const UE=ca().themes.get("dark");Object.assign(UE.definition,{"highcharts-title-font-size":"16px","highcharts-subtitle-font-size":"14px","highcharts-color-0":"#2caffe","highcharts-color-1":"#544fc5","highcharts-color-2":"#00e272","highcharts-color-3":"#fe6a35","highcharts-color-4":"#6b8abc","highcharts-color-5":"#d568fb","highcharts-color-6":"#2ee0ca","highcharts-color-7":"#fa4b42","highcharts-color-8":"#feb56a","highcharts-color-9":"#91e8e1","highcharts-background-color":"rgb(48, 48, 48)","highcharts-neutral-color-100":"rgb(255, 255, 255)","highcharts-neutral-color-80":"rgb(214, 214, 214)","highcharts-neutral-color-60":"rgb(173, 173, 173)","highcharts-neutral-color-40":"rgb(133, 133, 133)","highcharts-neutral-color-20":"rgb(92, 92, 92)","highcharts-neutral-color-10":"rgb(71, 71, 71)","highcharts-neutral-color-5":"rgb(61, 61, 61)","highcharts-neutral-color-3":"rgb(57, 57, 57)","highcharts-highlight-color-100":"rgb(122, 167, 255)","highcharts-highlight-color-80":"rgb(108, 144, 214)","highcharts-highlight-color-60":"rgb(94, 121, 173)","highcharts-highlight-color-20":"rgb(65, 74, 92)","highcharts-highlight-color-10":"rgb(58, 63, 71)"});const GE=ca().themes.get("light");Object.assign(GE.definition,{"highcharts-title-font-size":"16px","chart-background-color":"#2a2a2b","highcharts-color-0":"#2caffe","highcharts-color-1":"#544fc5","highcharts-color-2":"#00e272","highcharts-color-3":"#fe6a35","highcharts-color-4":"#6b8abc","highcharts-color-5":"#d568fb","highcharts-color-6":"#2ee0ca","highcharts-color-7":"#fa4b42","highcharts-color-8":"#feb56a","highcharts-color-9":"#91e8e1","highcharts-background-color":"#ffffff","highcharts-neutral-color-100":"#000000","highcharts-neutral-color-80":"#333333","highcharts-neutral-color-60":"#666666","highcharts-neutral-color-40":"#999999","highcharts-neutral-color-20":"#cccccc","highcharts-neutral-color-10":"#e6e6e6","highcharts-neutral-color-5":"#f2f2f2","highcharts-neutral-color-3":"#f7f7f7","highcharts-highlight-color-100":"#0022ff","highcharts-highlight-color-80":"#334eff","highcharts-highlight-color-60":"#667aff","highcharts-highlight-color-20":"#ccd3ff","highcharts-highlight-color-10":"#e6e9ff","highcharts-positive-color":"#06b535","highcharts-negative-color":"#f21313","highcharts-annotation-color-0":"rgba(130, 170, 255, 0.4)","highcharts-annotation-color-1":"rgba(139, 191, 216, 0.4)","highcharts-annotation-color-2":"rgba(150, 216, 192, 0.4)","highcharts-annotation-color-3":"rgba(156, 229, 161, 0.4)","highcharts-annotation-color-4":"rgba(162, 241, 130, 0.4)","highcharts-annotation-color-5":"rgba(169, 255, 101, 0.4)"});var qE=i(2439),YE=i(8022),ZE=i(6158),XE=i(127),QE=i(4505),KE=i(8659),JE=i(397),tz=i(930),ez=i(9723),iz=i(6343),oz=i(4582),nz=i(6127),rz=i(8238),sz=i(7362),az=i(452),lz=i(5390),cz=i(3368),hz=i(6288),dz=i(7513),uz=i(1386),pz=i(5764),gz=i(1261),fz=i(3071),mz=i(3285),vz=i(2356),bz=i(6780),yz=i(8542),wz=i(8385),xz=i(1025),kz=i(2034),Cz=i(8113),Mz=i(1821),_z=i(7212),Sz=i(2583),Ez=i(5360),zz=i(2377),Lz=i(2864),Rz=i(7998),Iz=i(4101),Hz=i(7813),Tz=i(5037),Az=i(7005),Oz=i(9626),$z=i(9517),Dz=i(1504),Nz=i(3838),Pz=i(4935),jz=i(7699),Vz=i(3322),Bz=i(5757),Fz=i(536),Wz=i(1673),Uz=i(8736),Gz=i(196),qz=i(5133),Yz=i(6092),Zz=i(791),Xz=i(5927),Qz=i(1802),Kz=i(9511),Jz=i(6267),tL=i(1072),eL=i(4331),iL=i(8644),oL=i(2704),nL=i(2419),rL=i(6363),sL=i(5236),aL=i(3499),lL=i(3811),cL=i(1953),hL=i(4729),dL=i(8964),uL=i(8540),pL=i(8752),gL=i(8783),fL=i(8270),mL=i(7261),vL=i(9231),bL=i(4555),yL=i(5293),wL=i(6981),xL=i(5268),kL=i(2680),CL=i(789),ML=i(4373),_L=i(436),SL=i(8573),EL=i(1808),zL=i(3247),LL=i(5143),RL=i(2415),IL=i(2561),HL=i(5726),TL=i(7436),AL=i(4201),OL=i(8248),$L=i(6433),DL=i(2698),NL=i(979),PL=i(9358),jL=i(9176),VL=i(1239),BL=i(4218),FL=i(8377),WL=i(3740),UL=i(5379),GL=i(9974),qL=i(8955),YL=i(3559),ZL=i(809),XL=i(8014),QL=i(8265),KL=i(3300),JL=i(8724),tR=i(8033),eR=i(7700),iR=i(5741),oR=i(3478),nR=i(512),rR=i(9432),sR=i(2841),aR=i(75),lR=i(9256),cR=i(444),hR=i(5633),dR=i(3788),uR=i(3573),pR=i(9948),gR=i(1836),fR=i(7029),mR=i(8532),vR=i(6639),bR=i(1633),yR=i(9805),wR=i(2171),xR=i(875),kR=i(9595),CR=i(3894),MR=i(2803),_R=i(7765),SR=i(8804),ER=i(8654),zR=i(257),LR=i(5844),RR=i(9651),IR=i(760),HR=i(9518),TR=i(4585),AR=i(1769),OR=i(643),$R=i(5156),DR=i(822),NR=i(8249),PR=i(3434),jR=i(9314),VR=i(3093),BR=i(7721),FR=i(588),WR=i(7645),UR=i(7148),GR=i(6795),qR=i(7047),YR=i(9428),ZR=i(1879),XR=i(9779),QR=i(2476),KR=i(9648),JR=i(2896),tI=i(6817),eI=i(5196),iI=i(2762),oI=i(5981),nI=i(9014),rI=i(2611),sI=i(7946),aI=i(6301),lI=i(8020),cI=i(3987),hI=i(3192),dI=i(8796),uI=i(2489),pI=i(7324),gI=i(6069),fI=i(4155),mI=i(6977),vI=i(8055),bI=i(2653),yI=i(9492),wI=i(4334),xI=i(6804),kI=i(9954),CI=i(2211),MI=i(5211),_I=i(1519),SI=i(6204),EI=i(5501),zI=i(5244),LI=i(9742),RI=i(1552),II=i(1330),HI=i(2596),TI=i(5184),AI=i(7675),OI=i(1513),$I=i(9396),DI=i(7673),NI=i(244),PI=i(1187),jI=i(1736),VI=i(4390),BI=i(7106),FI=i(2096),WI=i(9991),UI=i(5629),GI=i(3386),qI=i(6651),YI=i(1684),ZI=i(3849),XI=i(2582),QI=i(8569),KI=i(2955),JI=i(9100),tH=i(7381),eH=i(9190),iH=i(4071),oH=i(8e3),nH=i(4633),rH=i(4374),sH=i(486),aH=i(3680),lH=i(9999),cH=i(2830),hH=i(5255),dH=i(6021),uH=i(2214),pH=i(8497),gH=i(2052),fH=i(5327),mH=i(8701);const vH=[qE.w2,YE.Jt,ZE.Xk,XE.Wz,QE.UR,KE.mR,JE.cb,tz.td,ez.GF,oz.xB,iz.S$,nz.Ot,rz.fU,sz.Vp,az.HV,lz.BH,cz.Dn,hz.hy,dz.IP,uz.Nf,pz.jP,gz.AP,fz._X,mz.mu,vz.LB,bz.hS,yz.l5,wz.SI,xz.ch,Cz._u,Mz.ec,_z.jb,Sz.cW,Ez.$f,zz.qI,Lz.j3,Rz.fq,Iz.ao,Hz.Uj,Tz.GE,Az.QR,Oz.DQ,Dz.lE,$z.mE,Nz.hp,Pz.yL,jz.ub,Vz.lL,Bz.IN,Fz.B0,Wz.Ce,Uz.dm,Gz.h0,qz.sx,Yz.HF,Zz.qf,Qz.jw,Kz.k8,Jz.Am,tL.ff,eL.s6,iL.bx,oL.pS,nL.k6,rL.q9,sL.$F,aL.gK,lL.W1,cL.QL,hL.EZ,dL.DN,uL.Jy,pL.z1,gL.Gl,fL.n2,Xz.Ew,mL.QL,vL.ck,bL.I2,yL.Qv,wL.CK,xL.bn,kL.bx,CL.e6,ML.yy,_L.xg,SL.AJ,EL.py,zL.I0,LL.id,RL.qp,IL.UX,HL.PA,TL.B2,AL.It,OL.PZ,$L.aG,DL.$U,NL.S9,PL.Nb,jL.Z4,VL.qz,BL.jw,FL.cd,WL.jR,UL.qt,GL.x7,qL.oE,YL.ad,ZL.IT,XL.Ts,QL.UN,KL.jb,JL.jT,tR.w9,eR.Jm,iR.CQ,kz.$6,oR.Dw,nR.nx,rR.w2,sR.Jt,aR.Xk,lR.Wz,cR.UR,hR.mR,dR.cb,uR.td,pR.GF,fR.xB,gR.S$,vR.fU,mR.Ot,bR.Vp,yR.HV,wR.BH,xR.Dn,kR.hy,CR.IP,MR.Nf,_R.jP,SR.AP,IR._X,HR.mu,TR.LB,AR.hS,OR.l5,$R.SI,DR.ch,PR._u,jR.ec,VR.jb,GR.cW,qR.$f,YR.qI,ZR.j3,XR.fq,QR.ao,KR.Uj,JR.GE,ER.QR,zR.DQ,RR.lE,LR.mE,tI.hp,eI.yL,iI.ub,oI.lL,nI.IN,rI.B0,sI.Ce,aI.dm,BR.h0,FR.sx,WR.HF,UR.qf,cI.jw,hI.k8,dI.Am,uI.ff,pI.s6,gI.bx,fI.pS,mI.k6,vI.q9,bI.$F,yI.gK,wI.W1,xI.QL,kI.EZ,CI.DN,MI.Jy,_I.z1,SI.Gl,EI.n2,lI.Ew,zI.QL,LI.ck,RI.I2,II.Qv,HI.CK,TI.bn,AI.bx,OI.e6,$I.yy,DI.xg,NI.AJ,PI.py,jI.I0,VI.id,BI.qp,FI.UX,WI.PA,UI.B2,GI.It,qI.PZ,YI.aG,ZI.$U,XI.S9,QI.Nb,KI.Z4,JI.qz,tH.jw,eH.cd,iH.jR,oH.qt,nH.x7,rH.oE,sH.ad,aH.IT,lH.Ts,cH.UN,hH.jb,dH.jT,uH.w9,pH.Jm,gH.CQ,NR.$6,fH.Dw,mH.nx],bH={xlsx:P,charts:j},yH={name:"@omegagrid/bundle",version:"0.6.3"};ca().activate("light"),Lh.styleDefault="fal",Rh.add(...vH)})(),window.Omegagrid=o})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omegagrid/bundle",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "license": "UNLICENSED",
5
5
  "description": "Distribution package for Omegagrid library",
6
6
  "main": "omegagrid.js",
@@ -19,23 +19,23 @@
19
19
  "@fortawesome/fontawesome-svg-core": "6.4.2",
20
20
  "@fortawesome/pro-light-svg-icons": "6.4.2",
21
21
  "@fortawesome/pro-solid-svg-icons": "6.4.2",
22
- "@omegagrid/bucket": "^0.6.1",
23
- "@omegagrid/calendar": "^0.6.1",
24
- "@omegagrid/code": "^0.6.1",
25
- "@omegagrid/commands": "^0.6.1",
26
- "@omegagrid/core": "^0.6.1",
27
- "@omegagrid/dialog": "^0.6.1",
28
- "@omegagrid/editor": "^0.6.1",
29
- "@omegagrid/form": "^0.6.1",
30
- "@omegagrid/grid": "^0.6.1",
31
- "@omegagrid/localize": "^0.6.1",
32
- "@omegagrid/markdown": "^0.6.1",
33
- "@omegagrid/plugin-charts": "^0.6.1",
34
- "@omegagrid/plugin-xlsx": "^0.6.1",
35
- "@omegagrid/statusbar": "^0.6.1",
36
- "@omegagrid/tabs": "^0.6.1",
37
- "@omegagrid/toolbar": "^0.6.1",
38
- "@omegagrid/tree": "^0.6.1",
22
+ "@omegagrid/bucket": "^0.6.3",
23
+ "@omegagrid/calendar": "^0.6.3",
24
+ "@omegagrid/code": "^0.6.3",
25
+ "@omegagrid/commands": "^0.6.3",
26
+ "@omegagrid/core": "^0.6.3",
27
+ "@omegagrid/dialog": "^0.6.3",
28
+ "@omegagrid/editor": "^0.6.3",
29
+ "@omegagrid/form": "^0.6.3",
30
+ "@omegagrid/grid": "^0.6.3",
31
+ "@omegagrid/localize": "^0.6.3",
32
+ "@omegagrid/markdown": "^0.6.3",
33
+ "@omegagrid/plugin-charts": "^0.6.3",
34
+ "@omegagrid/plugin-xlsx": "^0.6.3",
35
+ "@omegagrid/statusbar": "^0.6.3",
36
+ "@omegagrid/tabs": "^0.6.3",
37
+ "@omegagrid/toolbar": "^0.6.3",
38
+ "@omegagrid/tree": "^0.6.3",
39
39
  "lit": "^3.1.1"
40
40
  },
41
41
  "devDependencies": {
@@ -14,7 +14,8 @@ export default (env, args) => ({
14
14
  externals: {
15
15
  'monaco-editor': 'monaco-editor',
16
16
  'highcharts': 'Highcharts',
17
- 'sheetjs': 'XLSX',
17
+ '@sheet/core': 'XLSX',
18
+ 'xlsx': 'XLSX',
18
19
  },
19
20
  devtool: args.mode == 'development' ? 'eval-source-map' : false,
20
21
  output: {